예제 #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
 public function actionCopy($id)
 {
     $model = $this->findModel($id);
     $newModel = new Orders();
     //копируем параметры заказа
     $newModel->customers_customer_id = $model->customers_customer_id;
     $newModel->user_id = $model->user_id;
     $newModel->order_amount = $model->order_amount;
     $newModel->save();
     //тут копируем список заказаных товаров
     //которые пользователь сможет править т.к. копия создается со статусом "Черновик"
     $list = Listofgoods::find()->where(['orders_order_id' => $model->order_id])->all();
     foreach ($list as $item) {
         $newList = new Listofgoods();
         $newList->orders_order_id = $newModel->order_id;
         $newList->goods_good_1c_id = $item->goods_good_1c_id;
         $newList->good_count = $item->good_count;
         $newList->save();
     }
     return $this->redirect(['view', 'id' => $newModel->order_id]);
 }