Exemple #1
0
 /**
  * Updates an existing Goods model.
  * If update is successful, the browser will be redirected to the 'view' page.
  *
  * @param integer $id
  *
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $sizes = ClothingSize::getAll(true, false);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'sizes' => $sizes]);
     }
 }
Exemple #2
0
 public function actionChange($id)
 {
     $filterForm = new models\FiltersForm();
     $print = $this->loadPrint($id);
     $colors = models\ClothingColor::getAll(true, false);
     $sizes = models\ClothingSize::getAll(true, false);
     $sex = models\ClothingSex::getAll(true, false);
     $types = models\ClothingType::getAll(true, false);
     $post = Yii::$app->request->post();
     if ($post) {
         $filterForm->load(Yii::$app->request->post());
     } else {
         $filterForm->size = isset($sizes[0]->id) ? $sizes[0]->id : null;
         $filterForm->sex = isset($sex[0]->id) ? $sex[0]->id : 3;
         $filterForm->type = isset($types[0]->id) ? $types[0]->id : null;
         $filterForm->color = isset($colors[0]->id) ? $colors[0]->id : null;
     }
     $goods = $print->getGoodsByCriteria($filterForm->getActiveQueryFilterGoods());
     return $this->render('change', ['goods' => $goods, 'colors' => $colors, 'sizes' => $sizes, 'sex' => $sex, 'types' => $types, 'print' => $print, 'filterForm' => $filterForm]);
 }