예제 #1
0
 public function run()
 {
     $shippingTypesList = ShippingType::find()->orderBy('order DESC')->all();
     $shippingTypes = ['' => yii::t('order', 'Choose shipping type')];
     foreach ($shippingTypesList as $sht) {
         if ($sht->cost > 0) {
             $currency = yii::$app->getModule('order')->currency;
             $name = "{$sht->name} ({$sht->cost}{$currency})";
         } else {
             $name = $sht->name;
         }
         $shippingTypes[$sht->id] = $name;
     }
     $paymentTypes = ['' => yii::t('order', 'Choose payment type')];
     $paymentTypesList = PaymentType::find()->orderBy('order DESC')->all();
     foreach ($paymentTypesList as $pt) {
         $paymentTypes[$pt->id] = $pt->name;
     }
     $fieldFind = Field::find()->orderBy('order DESC');
     $fieldValueModel = new FieldValue();
     $orderModel = new Order();
     if (empty($orderModel->shipping_type_id) && ($orderShippingType = yii::$app->session->get('orderShippingType'))) {
         if ($orderShippingType > 0) {
             $orderModel->shipping_type_id = (int) $orderShippingType;
         }
     }
     $this->getView()->registerJs("pistol88.order.updateShippingType = '" . Url::toRoute(['/order/tools/update-shipping-type']) . "';");
     return $this->render($this->view, ['orderModel' => $orderModel, 'fieldFind' => $fieldFind, 'paymentTypes' => $paymentTypes, 'elements' => $this->elements, 'shippingTypes' => $shippingTypes, 'shippingTypesList' => $shippingTypesList, 'fieldValueModel' => $fieldValueModel]);
 }
예제 #2
0
 public function search($params)
 {
     $query = Field::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'type_id' => $this->type_id]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
예제 #3
0
 public function actionView($id)
 {
     $this->layout = '@vendor/pistol88/yii2-order/views/layouts/mini';
     $model = $this->findModel($id);
     if ($model->status == $this->module->defaultStatus) {
         $model->status = $this->module->operatorOpenStatus;
         $model->seller_user_id = yii::$app->user->id;
         $model->save(false);
     }
     $searchModel = new ElementSearch();
     $params = yii::$app->request->queryParams;
     if (!is_array($params)) {
         $params = [];
     }
     $params['ElementSearch']['order_id'] = $model->id;
     $dataProvider = $searchModel->search($params);
     $paymentTypes = ArrayHelper::map(PaymentType::find()->all(), 'id', 'name');
     $shippingTypes = ArrayHelper::map(ShippingType::find()->all(), 'id', 'name');
     $fieldFind = Field::find();
     return $this->render('view', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'shippingTypes' => $shippingTypes, 'fieldFind' => $fieldFind, 'paymentTypes' => $paymentTypes, 'model' => $model]);
 }
예제 #4
0
 public function getAllFields()
 {
     return Field::find()->all();
 }
예제 #5
0
 public function actionPrint($id)
 {
     $this->layout = 'print';
     $this->enableCsrfValidation = false;
     $model = $this->findModel($id);
     $searchModel = new ElementSearch();
     $params = yii::$app->request->queryParams;
     if (empty($params['ElementSearch'])) {
         $params = ['ElementSearch' => ['order_id' => $model->id]];
     }
     $dataProvider = $searchModel->search($params);
     $paymentTypes = ArrayHelper::map(PaymentType::find()->all(), 'id', 'name');
     $shippingTypes = ArrayHelper::map(ShippingType::find()->all(), 'id', 'name');
     $fieldFind = Field::find();
     return $this->render('print', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'shippingTypes' => $shippingTypes, 'fieldFind' => $fieldFind, 'paymentTypes' => $paymentTypes, 'module' => $this->module, 'model' => $model]);
 }