public function actionUpdateStatus() { if ($id = yii::$app->request->post('id')) { $model = Order::findOne($id); $model->status = yii::$app->request->post('status'); if ($model->save(false)) { die(json_encode(['result' => 'success'])); } else { die(json_encode(['result' => 'fail', 'error' => 'enable to save'])); } } throw new NotFoundHttpException('The requested page does not exist.'); }
public function actionOrder($order_id = false) { $customServiceModel = new CustomService(); if ($customServiceModel->load(Yii::$app->request->post()) && $customServiceModel->save()) { yii::$app->cart->put($customServiceModel); if (yii::$app->request->post('ajax')) { die(json_encode(['result' => 'success'])); } else { \Yii::$app->session->setFlash('customServiceBuy', 'В корзине!'); } } if ($type = yii::$app->request->get('service-order-type')) { if (!in_array($type, ['net', 'table'])) { return $this->redirect('404'); } yii::$app->response->cookies->add(new \yii\web\Cookie(['name' => 'service-order-type', 'value' => $type])); } else { $type = yii::$app->request->cookies->get('service-order-type'); if (!$type) { $type = 'net'; } } $organization = false; $organizations = []; if (yii::$app->has('organization')) { $organization = yii::$app->organization->get(); $organizations = yii::$app->organization->getList(); } if ($organization) { $services = Service::find()->where('(calculator = "" OR calculator IS NULL) AND organization_id = :org_id', [':org_id' => $organization->id])->orderBy('sort DESC, id ASC')->all(); $categories = Category::find()->where(['organization_id' => $organization->id])->orderBy('sort DESC, id ASC')->all(); $complexes = Complex::find()->where(['organization_id' => $organization->id])->orderBy('sort DESC, id ASC')->all(); } else { $services = Service::find()->orderBy('sort DESC, id ASC')->all(); $categories = Category::find()->where('parent_id IS NULL OR parent_id = 0')->orderBy('sort DESC, id ASC')->all(); $complexes = Complex::find()->orderBy('sort DESC, id ASC')->all(); } $calculateServiceModel = Service::find()->where('calculator != ""')->all(); $priceModel = new Price(); $orderModel = new Order(); $paymentTypes = ArrayHelper::map(PaymentType::find()->orderBy('order DESC')->all(), 'id', 'name'); $shippingTypes = ArrayHelper::map(ShippingType::find()->orderBy('order DESC')->all(), 'id', 'name'); $prices = []; foreach ($priceModel::find()->all() as $price) { $prices[$price->service_type][$price->category_id][$price->service_id] = $price; } $this->getView()->registerJs('pistol88.service.propertyListUrl = "' . Url::toRoute(['/service/property/get-ajax-list']) . '";'); $this->getView()->registerJs('pistol88.service.searchClientByIdentUrl = "' . Url::toRoute(['/service/property/get-client-by-property']) . '";'); if ($order_id) { $order = Order::findOne($order_id); } else { $order = false; } return $this->render('order', ['order' => $order, 'organization' => $organization, 'organizations' => $organizations, 'type' => $type, 'customServiceModel' => $customServiceModel, 'calculateServiceModel' => $calculateServiceModel, 'prices' => $prices, 'services' => $services, 'complexes' => $complexes, 'categories' => $categories, 'orderModel' => $orderModel, 'priceModel' => $priceModel, 'paymentTypes' => $paymentTypes, 'shippingTypes' => $shippingTypes]); }
public function get($id) { return OrderModel::findOne($id); }