public function getAttachedOrders() { // grab attachment campaign info $attachedCampaigns = CampaignAttachs::getAttachedByCampaign($this->campaign_id, false); foreach ($attachedCampaigns as &$ac) { $campaingModel = new Campaign(); $c = $campaingModel->findByPk($ac['campaign_attach_id']); if ($c) { $ac['campaign_attach_name_format'] = '[' . $c->campaign_id . '] ' . $c->campaign_name; } // is there already an order for the camp? if so build order details $result = self::getOrderByParent($ac['campaign_attach_id'], $this->order_id); if (!empty($result)) { // doing this results in the instance of $this being reset to the attached order //$o = Order::model()->fillFromDbPk($result); $o = new Order(); $o->fillFromDbPk($result); $ac['order_id'] = $o->getorder_id_name_link(); $ac['status'] = $o->getstatus_image(); $ac['created'] = $o->getcreated_formatted(); unset($o); } } return $attachedCampaigns; }
public function beforeDelete() { // if there are orders for this campaign, do not allow deletion if ($this->getCountOrders()) { return false; } // No orders are present for this camp. delete any and all associated camp values // upsell products $campUpsells = new Upsells('Upsell'); $campUpsells->loadUpsellsByCampaignId($this->campaign_id); $campUpsells->deleteUpsellsFromDb(); unset($campUpsells); // camp products $campProducts = new CampaignProducts('CampaignProduct'); $campProducts->load($this->campaign_id); $campProducts->deleteCampaignProductsFromDb(); unset($campProducts); // camp shipping $campShip = new CampaignShippings('CampaignShipping'); $campShip->load($this->campaign_id); $campShip->deleteCampaignShippingsFromDb(); unset($campShip); // attach $campAttach = new CampaignAttachs('CampaignAttach'); $campAttach->load($this->campaign_id); $campAttach->deleteCampaignAttachsFromDb(); unset($campAttach); // combo $campCombos = new CCombos('CCombo'); $campCombos->load($this->campaign_id); $campCombos->deleteCampaignCombosFromDb(); unset($campCombos); // emails $campEmail = new CampaignEmails('CampaignEmail'); $campEmail->load($this->campaign_id); $campEmail->deleteCampaignEmailsFromDb(); unset($campEmail); // pixels $campPixels = new Pixels('Pixel'); $campPixels->load($this->campaign_id); $campPixels->deleteCampaignPixelsFromDb(); unset($campPixels); // pixel rates $sql = "DELETE FROM pixel_rates WHERE campaign_id = ?i"; self::$_msql->query($sql, $this->campaign_id); /*$campPixelRates = new PixelRates('PixelRate'); $campPixelRates->load($this->campaign_id); $campPixelRates->deleteCampaignPixelRatesFromDb(); unset($campPixelRates);*/ return TRUE; }
public static function createAttachedOrders($orderO, $isPayment = false) { // make sure the order is in the right stats if ($orderO->status != 'ok' || !$orderO->isFlag('paid')) { return false; } $attachedCampaigns = CampaignAttachs::getAttachedByCampaign($orderO->campaign_id); foreach ($attachedCampaigns as $ac) { $oA = clone $orderO; self::createAttachedOrder($oA, $ac['campaign_attach_id'], $isPayment); } }