Exemplo n.º 1
0
 /**
  * Creates a new Categories model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Categories();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Exemplo n.º 2
0
 /**
  * Creates a new Categories model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Categories();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('success', 'Your information saved.');
         return $this->redirect(['index']);
         echo Yii::$app->session->getFlash('success');
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Categories model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Categories();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         if ($model->parent_id > 0) {
             return $this->redirect(['subcat', 'SearchCategories[parent_id]' => $model->parent_id]);
         } else {
             return $this->redirect(['/categories']);
         }
     } else {
         return $this->render('create', ['model' => $model, 'parent_id' => Yii::$app->request->queryParams["parent_id"]]);
     }
 }
Exemplo n.º 4
0
 public function actionUpdate($id)
 {
     $id = (int) $id;
     if (empty($id)) {
         return $this->redirect('index');
     }
     $categ = new Categories();
     $inco_ex = new IncoExpenso();
     $inco_ex = $inco_ex->find()->all();
     $sql = $categ->sqlAactivDelete($id);
     //проверяем активна запись для изменения
     $query = Categories::findBySql($sql)->count();
     if ($query == 0) {
         return $this->redirect('index');
     }
     if ($categ->load(Yii::$app->request->post()) && $categ->validate()) {
         $q = $categ->updateCateg($id);
         return $this->redirect('index');
     }
     $sql = $categ->findOne($id);
     return $this->render('update', ['categ' => $sql, 'inco_ex' => $inco_ex]);
 }
Exemplo n.º 5
0
 public function actionUpdate($id)
 {
     $id = (int) $id;
     if (empty($id)) {
         return $this->redirect('index');
     }
     $categ = new Categories();
     $inco_ex = new IncoExpenso();
     $inco_ex = $inco_ex->find()->all();
     $sql = $this->sql_activ_delete($id);
     //проверяем активна запись для изменения
     $query = Categories::findBySql($sql)->count();
     if ($query == 0) {
         return $this->redirect('index');
     }
     $sql = $categ->findOne($id);
     if ($categ->load(Yii::$app->request->post()) && $sql->validate()) {
         //return print_r($_POST);
         $sql->updateAll(['categ_name' => $_POST['Categories']['categ_name'], 'inc_exp_id' => $_POST['Categories']['inc_exp_id']], ['categ_id' => $id]);
         return $this->redirect('index');
     }
     return $this->render('update', ['categ' => $sql, 'inco_ex' => $inco_ex]);
 }