function updateAction() { $model = new Shipping(); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['model']) && $_POST['model'] == 'Shipping') { if (isset($_POST['ajax'])) { $model->fillFromArray($_POST, FALSE); $model->user_id_updated = $this->user->user_id; $model->updated = 'NOW():sql'; $model->model_uset_id = $this->user->user_id; if ($model->save()) { Message::echoJsonSuccess(__('shipping_updated')); } else { Message::echoJsonError(__('shipping_no_updated')); } die; } $model->save(); $this->redirect(); die; } $id = AF::get($this->params, 'id', FALSE); if (!$id) { throw new AFHttpException(0, 'no_id'); } if (!$model->cache()->findByPk($id)) { throw new AFHttpException(0, 'incorrect_id'); } $shipcats = Shipcat::model()->cache()->findAllInArray(); Assets::js('jquery.form'); $this->addToPageTitle('Update Shipping'); $this->render('update', array('model' => $model, 'shipcats' => $shipcats)); }
public function cacheCreateFilter($models) { $array = array('shipcat_id', 'stext'); $r = $this->checkCacheSearchFields($array); if ($r === false) { false; } $returnArray = array(); $shipcatsID = $this->searchFields['shipcat_id'] ? explode(',', $this->searchFields['shipcat_id']) : null; $shipCats = Shipcat::model()->cache()->findAllInArray(); foreach ($models as $k => $model) { $bool = true; if ($this->searchFields['stext']) { $string = $model['shipping_id'] . $model['shipping_name']; $pos = strpos($string, $this->searchFields['stext']); if ($pos === false) { $bool = false; } } if ($shipcatsID) { if (!in_array($model['shipcat_id'], $shipcatsID)) { $bool = false; } } if ($bool) { $model['shipcat_name'] = isset($shipCats[$model['shipcat_id']]['shipcat_name']) ? $shipCats[$model['shipcat_id']]['shipcat_name'] : ''; $returnArray[] = $model; } } return $returnArray; }