function deleteAction() { $id = AF::get($_POST, 'id', 0); $modelsID = explode(',', $id); $errors = FALSE; foreach ($modelsID as $id) { $model = new Prodcat(); $model->model_uset_id = $this->user->user_id; if ($model->fillFromDbPk($id)) { $model->delete($id); } else { $errors = TRUE; } if ($model->getErrors()) { $errors = TRUE; } unset($model); } if (isset($_POST['ajax'])) { AF::setJsonHeaders('json'); if ($errors) { Message::echoJsonError(__('prodcat_not_deleted')); } else { $countE = AF::get($_POST, 'countE', 100000); if (count($modelsID) >= $countE) { $link = AF::link(array('prodcats' => 'view')); Message::echoJsonRedirect($link); } else { Message::echoJsonSuccess(__('prodcat_deleted')); } } } $this->redirect(); }
function updateAction() { $model = new Product(); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['ajax'])) { if (isset($_POST['subscription_days']) && ((int) $_POST['subscription_days'] > 180 || (int) $_POST['subscription_days'] < 1)) { $_POST['subscription_days'] = null; } $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(__('product_updated')); } else { Message::echoJsonError(__('product_no_updated')); } 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'); } $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params)); $models = AFActiveDataProvider::models('Event', $this->params, $pagination); $dataProvider = $models->getByProductID($id); $products = Product::model()->cache()->findAllInArray(); $prodcats = Prodcat::model()->cache()->findAllInArray(); //Events type list $eventModel = new Event(); $eventsTypes = $eventModel->getEventsType(); Assets::js('jquery.form'); $this->addToPageTitle('Update product'); $this->render('update', array('model' => $model, 'products' => $products, 'pagination' => $pagination, 'dataProvider' => $dataProvider, 'eventsTypes' => $eventsTypes, 'prodcats' => $prodcats)); }