コード例 #1
0
 public function actionRepeat($id)
 {
     $orderId = $id;
     $totalPrice = OrdersQuery::totalPriceThis($id);
     $order = Orders::findOne($orderId);
     $searchModel = new OrderedProductSearch();
     $dataProvider = $searchModel->searchAttachToTheOrder($id, Yii::$app->request->queryParams);
     $validOrder = true;
     $orderedProducts = $dataProvider->models;
     foreach ($orderedProducts as $orderdedProduct) {
         if (!$orderdedProduct->isProduct) {
             $validOrder = false;
         }
     }
     if ($dataProvider->count < $dataProvider->totalCount) {
         $validOrder = false;
     }
     return $this->render('repeat', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'totalPrice' => $totalPrice, 'order' => $order, 'validOrder' => $validOrder]);
 }
コード例 #2
0
 /**
  *  Список товаров прикрепленных к заказу на печать.
  * @return mixed
  */
 public function actionPrint($id = null)
 {
     $this->layout = '@app/views/layouts/print';
     if ($id) {
         $totalPrice = OrdersQuery::totalPriceThis($id);
         $totalPriceWithoutNds = OrdersQuery::totalPriceWithoutNdsThis($id);
         $order = Orders::findOne($id);
         $searchModel = new OrderedProductSearch();
         $dataProvider = $searchModel->searchAttachToTheOrder($id, Yii::$app->request->queryParams);
         $validOrder = true;
     } else {
         $totalPrice = OrdersQuery::totalPrice();
         $totalPriceWithoutNds = OrdersQuery::totalPriceWithoutNds();
         $order = Orders::findOne(Yii::$app->session->get('idOrder'));
         $searchModel = new OrderedProductSearch();
         $dataProvider = $searchModel->searchAttachToOrder(Yii::$app->request->queryParams);
         $validOrder = true;
         $orderedProducts = $dataProvider->models;
         foreach ($orderedProducts as $orderdedProduct) {
             if (!$orderdedProduct->isProduct) {
                 $validOrder = false;
             }
         }
         if ($dataProvider->count < $dataProvider->totalCount) {
             $validOrder = false;
         }
     }
     return $this->render('print', ['dataProvider' => $dataProvider, 'totalPrice' => $totalPrice, 'totalPriceWithoutNds' => $totalPriceWithoutNds, 'order' => $order, 'validOrder' => $validOrder]);
 }
コード例 #3
0
 /**
  * Изменение содержимого существующего заказа через историю.
  * @param integer $id ИД заказа
  * @return type
  */
 public function actionChange($id)
 {
     $totalPrice = OrdersQuery::totalPriceThis($id);
     $order = Orders::findOne($id);
     $searchModel = new OrderedProductSearch();
     $dataProvider = $searchModel->searchAttachToTheOrder($id, Yii::$app->request->queryParams);
     if (isset($order) && $order->load(Yii::$app->request->post()) && $order->save()) {
         $this->redirect(['/main/orders/repeat', 'id' => $id]);
     } else {
         return $this->render('change', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'totalPrice' => $totalPrice, 'order' => $order]);
     }
 }