Пример #1
0
 public function searchAttachToOrderWithId($params, $id)
 {
     $query = OrderedProduct::find()->where(['order_id' => $id]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['kolz' => $this->kolz, 'buggod' => $this->buggod]);
     $query->andFilterWhere(['like', 'kpr', $this->kpr])->andFilterWhere(['like', 'imn', $this->imn])->andFilterWhere(['like', 'otd', $this->otd])->andFilterWhere(['like', 'dsv', $this->dsv]);
     return $dataProvider;
 }
Пример #2
0
 /**
  * Возвращает JS-объект с подробной информацией о товаре по ид модели OrderedProduct
  * @param integer $id
  * @return js-object|json|string
  */
 public function actionDescViewOrdered($id)
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $ordered = OrderedProduct::findOne($id);
     $kodpart = $ordered->kodpart;
     $namepr = $ordered->dsv;
     //Имя производителя в модели Products и OrderedProduct
     $model = Products::findOne(['kodpart' => $kodpart, 'namepr' => $namepr]);
     if (!empty($model)) {
         return $model->attributes;
     } else {
         return 'empty';
     }
 }
 /**
  * Finds the OrderedProduct model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return OrderedProduct the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = OrderedProduct::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #4
0
 public static function createNewOrder($event)
 {
     $session = Yii::$app->session;
     if (Yii::$app->session->get('creatingOrder') == 1) {
         $event->orderedProduct->order_id = $session->get('idOrder');
         $session->set('countOrderedProducts', OrderedProduct::find()->countOrdered() + 1);
     } else {
         $order = self::createInstanceByAgent();
         if ($order->save()) {
             $session->set('creatingOrder', 1);
             $session->set('idOrder', $order->id);
             $session->set('countOrderedProducts', 1);
             $event->orderedProduct->order_id = $order->id;
         }
     }
 }
Пример #5
0
 public function actionGetCounters()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $totalPrice = Orders::getPriceOfOrder();
     $orderedProducts = OrderedProduct::find()->countOrdered();
     return ['totalPrice' => $totalPrice, 'orderedProducts' => $orderedProducts];
 }