function updateAction() { $model = new Campaign(); if (isset($_POST['country_id'])) { $_POST['country_id'] = implode(',', $_POST['country_id']); } // check if this is an attachment campaign. if so, we don't want to validate the urls or fulfillment_id if it isnot presesnt $attach = false; if (isset($_POST['attach']) && $_POST['attach']) { $attach = true; $_POST['url'] = $_POST['order_url'] = $_POST['return_url'] = 'attach'; if (!strlen($_POST['fulfillment_id'])) { $_POST['fulfillment_id'] = 0; } } else { $_POST['attach'] = 0; } // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['ajax']) && $_POST['ajax'] == 'categorys-form') { $model->fillFromArray($_POST, FALSE); $model->user_id_updated = $this->user->user_id; $model->updated = 'NOW():sql'; $model->model_uset_id = $this->user->user_id; $fulfillment_change = AF::get($_POST, 'fulfillment_change'); Campaigns::fulfillmentRelationship($model->campaign_id, $model->fulfillment_id, $fulfillment_change); if ($model->restrictions()->save()) { Message::echoJsonSuccess(__('campaign_updated')); } else { Message::echoJsonError(__('campaign_no_updated')); } die; } $id = AF::get($this->params, 'id', FALSE); if (!$id) { throw new AFHttpException(0, 'no_id'); } if (!$model->restrictions()->cache()->findByPk($id)) { throw new AFHttpException(0, 'incorrect_id'); } $model->country_id = explode(',', $model->country_id); Assets::js('jquery.form'); $this->addToPageTitle('Update campaign'); //array_unshift($fulfillments, array('fulfillment_id'=>0, 'alias'=>__('none'))); // Is this used still? $ccomboModel = new CCombo(); $ccomboModel->campaign_id = $model->campaign_id; $isCombo = $ccomboModel->checkRelationship(); $countries = Country::model()->cache()->findAllInArray(); $profiles = Profile::model()->cache()->findAllInArray(); // prepend dry run gateway array_unshift($profiles, array('profile_id' => 0, 'profile_name' => 'DRY RUN GATEWAY')); $fulfillments = Fulfillment::model()->cache()->findAllInArray(); $currencies = $model->getCountOrders() > 0 ? array() : Currency::model()->cache()->findAllInArray(); $domains = Domain::model()->cache()->findAllInArray(); $this->render('update', array('model' => $model, 'countries' => $countries, 'profiles' => $profiles, 'currencies' => $currencies, 'fulfillments' => $fulfillments, 'isCombo' => $isCombo, 'domains' => $domains)); }
public function loadPackage($pid) { //$this->package_id = $pid; $this->fillFromDbPk($pid); // load fulfillment $this->fulfillment = Fulfillment::model()->fillFromDbPk($this->fulfillment_id); // load customer $this->customer = new Customer(); $this->customer->fillFromDbPk($this->customer_id); $sql = "SELECT order_id\n FROM packages_orders\n WHERE package_id = ?i\n\t\t\t\torder by package_id asc"; $db = self::$_msql = SafeMySQL::getInstance(); $this->order_ids = $db->getCol($sql, $this->package_id); $this->orders = array(); foreach ($this->order_ids as $id) { $this->orders[$id] = new Order(); $this->orders[$id]->allFIelds = true; $this->orders[$id]->fillFromDbPk($id); } }