diff --git a/controllers/OrderController.php b/controllers/OrderController.php index 511cadb..395c64b 100755 --- a/controllers/OrderController.php +++ b/controllers/OrderController.php @@ -300,6 +300,7 @@ if ($orderProduct->load($post)) { $orderProduct->save(); + $orderProduct->order->totalRecount(); $output = ''; if (isset($posted[ 'count' ])) { $output = Yii::$app->formatter->asDecimal($orderProduct->count, 0); @@ -340,6 +341,9 @@ $model->manager_id = \Yii::$app->user->id; } + $headers = \Yii::$app->response->headers; + $headers->set('Access-Control-Allow-Origin', '*'); + if ($model->load(Yii::$app->request->post()) && $model->save()) { $this->unblockOrder($model->id); return $this->render( @@ -426,21 +430,38 @@ } } - public function actionExitOrder($id) + public function actionExitOrder() { try { - $model = $this->findModel($id); + $model = Order::findOne(\Yii::$app->request->post('id')); } catch (NotFoundHttpException $e) { return $this->redirect('index'); } if ($model->edit_id == \Yii::$app->user->id) { - $this->unblockOrder($id); + $this->unblockOrder(\Yii::$app->request->post('id')); } if (!$model->published) { $model->deleteUnpublished(); } - return $this->redirect('index'); +// return $this->redirect('index'); + } + + public function actionCloseOrder($id) + { + try { + $model = Order::findOne($id); + } catch (NotFoundHttpException $e) { + return $this->redirect('index'); + } + if ($model->edit_id == \Yii::$app->user->id) { + $this->unblockOrder($id); + } + + if (!$model->published) { + $model->deleteUnpublished(); + } + return $this->redirect('index'); } public function actionBlockOrder() diff --git a/views/order/_form.php b/views/order/_form.php index 4092fb8..05aa132 100755 --- a/views/order/_form.php +++ b/views/order/_form.php @@ -667,7 +667,7 @@ JS; \Yii::t('app', 'Выйти'), yii\helpers\Url::to( [ - 'exit-order', + 'close-order', 'id' => $model->id, ] ), diff --git a/views/order/update.php b/views/order/update.php index 58c88aa..879d04e 100755 --- a/views/order/update.php +++ b/views/order/update.php @@ -42,13 +42,12 @@ $.ajax({ $js = ' window.onbeforeunload = function(e) { $.ajax({ - type: "GET", + type: "POST", url: "/admin/ecommerce/order/exit-order", data: { id: ' . $model->id . ', }, success: function() { - console.log("Exit order"); } }); }; -- libgit2 0.21.4