Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 function deleteAction()
 {
     $id = AF::get($_POST, 'id', 0);
     $modelsID = explode(',', $id);
     $errors = FALSE;
     foreach ($modelsID as $id) {
         $model = new Campaign();
         $model->model_uset_id = $this->user->user_id;
         if ($model->findByPk($id)) {
             // if beforeDelete() returns an error, indicate this to the user
             if (!$model->delete($id)) {
                 $errors = TRUE;
             }
         } else {
             $errors = TRUE;
         }
         if ($model->getErrors()) {
             $errors = TRUE;
         }
         unset($model);
     }
     if (isset($_POST['ajax'])) {
         AF::setJsonHeaders('json');
         if ($errors) {
             Message::echoJsonError(__('campaign_no_deleted'));
         } else {
             Message::echoJsonSuccess(__('campaign_deleted'));
         }
     }
     $this->redirect();
 }