Exemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ClothingColor::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'hex', $this->hex])->andFilterWhere(['like', 'descriptions', $this->descriptions]);
     return $dataProvider;
 }
Exemplo n.º 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]);
 }
Exemplo n.º 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getColor()
 {
     return $this->hasOne(ClothingColor::className(), ['id' => 'color_id']);
 }
Exemplo n.º 4
0
 /**
  * Finds the ClothingColor model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ClothingColor the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ClothingColor::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 5
0
/* @var $model app\models\Goods */
/* @var $form yii\widgets\ActiveForm */
?>

<div class = "goods-form">

    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>

    <?php 
echo $form->field($model, 'type_id')->dropDownList(models\ClothingType::getAll());
?>

    <?php 
echo $form->field($model, 'color_id')->dropDownList(models\ClothingColor::getAll());
?>

    <?php 
echo $form->field($model, 'sex_id')->dropDownList(models\ClothingSex::getAll());
?>

    <?php 
echo $form->field($model, 'description')->textarea(['rows' => 6]);
?>
    <?php 
echo $form->field($model, 'sizes')->listBox(\yii\helpers\ArrayHelper::map($sizes, 'id', 'name'), ['multiple' => true, 'selected' => $model->getSizesIds(), 'size' => 6]);
?>
    <?php 
echo $form->field($model, 'status')->dropDownList([0 => "Отключено", 1 => 'Включено']);
?>