예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $order_id = 0)
 {
     if ($order_id == 0) {
         $query = Listofgoods::find();
     } else {
         $query = Listofgoods::find()->where(['orders_order_id' => $order_id]);
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->joinWith('goodsGoodId');
     $query->andFilterWhere(['orders_order_id' => $this->orders_order_id, 'good_count' => $this->good_count])->andFilterWhere(['like', 'goods.good_name', $this->goods_good_1c_id]);
     return $dataProvider;
 }
예제 #2
0
 /**
  * Deletes an existing Orders model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $model = $this->findModel($id);
     if ($model->status == 'Черновик') {
         $list = new Listofgoods();
         $list->deleteAll(['orders_order_id' => $id]);
         $model->delete();
     } else {
         throw new ForbiddenHttpException('Удалить можно только черновик');
     }
     return $this->redirect(['index']);
 }
예제 #3
0
 /**
  * Finds the Listofgoods model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Listofgoods the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Listofgoods::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }