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 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); } }