Exemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Temporales::find();
     $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;
     }
     $query->andFilterWhere(['idproducto' => $this->idproducto, 'fecha' => $this->fecha]);
     return $dataProvider;
 }
Exemplo n.º 2
0
 /**
  * Updates an existing Productos model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param string $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $img_model = new UploadForm();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $request = Yii::$app->request;
         $id_producto = $model->id;
         $fotos = Fotos::find()->where(['idProducto' => $id_producto])->all();
         foreach ($fotos as $foto) {
             Fotos::deleteFoto($foto);
         }
         $img_model->imageFiles = UploadedFile::getInstances($img_model, 'imageFiles');
         if ($img_model->upload($model->id)) {
             if ($model->tipo == 0) {
                 return $this->redirect(['view', 'id' => $model->id]);
             } else {
                 if ($model->tipo == 1) {
                     $porTiempo = Temporales::find()->where(['idproducto' => $model->id])->one();
                     $porTiempo->fecha = $request->post('fecha');
                     $porTiempo->idproducto = $model->id;
                     $porTiempo->save();
                     return $this->redirect(['view', 'id' => $model->id]);
                 } else {
                     $stock = Stock::find()->where(['idproducto' => $model->id])->one();
                     $cantidad = $request->post('cant');
                     $stock->stock = $cantidad;
                     $stock->idproducto = $model->id;
                     $stock->save();
                     return $this->redirect(['view', 'id' => $model->id]);
                 }
             }
         }
     } else {
         return $this->render('update', ['model' => $model, 'img_model' => $img_model]);
     }
 }
Exemplo n.º 3
0
 public function actionIndex()
 {
     $this->layout = 'frontoffice';
     $parametro = date('Y-m-d');
     $lista = Temporales::find()->where(['fecha' => $parametro])->all();
     return $this->render('index', ['model' => $lista]);
 }