Commit 793ad526af1cfded63d6031c6d2d8a95bd2cff64
1 parent
48fb8190
-Brain fuck! with chrome and orders
Showing
3 changed files
with
27 additions
and
7 deletions
Show diff stats
controllers/OrderController.php
@@ -300,6 +300,7 @@ | @@ -300,6 +300,7 @@ | ||
300 | 300 | ||
301 | if ($orderProduct->load($post)) { | 301 | if ($orderProduct->load($post)) { |
302 | $orderProduct->save(); | 302 | $orderProduct->save(); |
303 | + $orderProduct->order->totalRecount(); | ||
303 | $output = ''; | 304 | $output = ''; |
304 | if (isset($posted[ 'count' ])) { | 305 | if (isset($posted[ 'count' ])) { |
305 | $output = Yii::$app->formatter->asDecimal($orderProduct->count, 0); | 306 | $output = Yii::$app->formatter->asDecimal($orderProduct->count, 0); |
@@ -340,6 +341,9 @@ | @@ -340,6 +341,9 @@ | ||
340 | $model->manager_id = \Yii::$app->user->id; | 341 | $model->manager_id = \Yii::$app->user->id; |
341 | } | 342 | } |
342 | 343 | ||
344 | + $headers = \Yii::$app->response->headers; | ||
345 | + $headers->set('Access-Control-Allow-Origin', '*'); | ||
346 | + | ||
343 | if ($model->load(Yii::$app->request->post()) && $model->save()) { | 347 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
344 | $this->unblockOrder($model->id); | 348 | $this->unblockOrder($model->id); |
345 | return $this->render( | 349 | return $this->render( |
@@ -426,21 +430,38 @@ | @@ -426,21 +430,38 @@ | ||
426 | } | 430 | } |
427 | } | 431 | } |
428 | 432 | ||
429 | - public function actionExitOrder($id) | 433 | + public function actionExitOrder() |
430 | { | 434 | { |
431 | try { | 435 | try { |
432 | - $model = $this->findModel($id); | 436 | + $model = Order::findOne(\Yii::$app->request->post('id')); |
433 | } catch (NotFoundHttpException $e) { | 437 | } catch (NotFoundHttpException $e) { |
434 | return $this->redirect('index'); | 438 | return $this->redirect('index'); |
435 | } | 439 | } |
436 | if ($model->edit_id == \Yii::$app->user->id) { | 440 | if ($model->edit_id == \Yii::$app->user->id) { |
437 | - $this->unblockOrder($id); | 441 | + $this->unblockOrder(\Yii::$app->request->post('id')); |
438 | } | 442 | } |
439 | 443 | ||
440 | if (!$model->published) { | 444 | if (!$model->published) { |
441 | $model->deleteUnpublished(); | 445 | $model->deleteUnpublished(); |
442 | } | 446 | } |
443 | - return $this->redirect('index'); | 447 | +// return $this->redirect('index'); |
448 | + } | ||
449 | + | ||
450 | + public function actionCloseOrder($id) | ||
451 | + { | ||
452 | + try { | ||
453 | + $model = Order::findOne($id); | ||
454 | + } catch (NotFoundHttpException $e) { | ||
455 | + return $this->redirect('index'); | ||
456 | + } | ||
457 | + if ($model->edit_id == \Yii::$app->user->id) { | ||
458 | + $this->unblockOrder($id); | ||
459 | + } | ||
460 | + | ||
461 | + if (!$model->published) { | ||
462 | + $model->deleteUnpublished(); | ||
463 | + } | ||
464 | + return $this->redirect('index'); | ||
444 | } | 465 | } |
445 | 466 | ||
446 | public function actionBlockOrder() | 467 | public function actionBlockOrder() |
views/order/_form.php
views/order/update.php
@@ -42,13 +42,12 @@ $.ajax({ | @@ -42,13 +42,12 @@ $.ajax({ | ||
42 | $js = ' | 42 | $js = ' |
43 | window.onbeforeunload = function(e) { | 43 | window.onbeforeunload = function(e) { |
44 | $.ajax({ | 44 | $.ajax({ |
45 | - type: "GET", | 45 | + type: "POST", |
46 | url: "/admin/ecommerce/order/exit-order", | 46 | url: "/admin/ecommerce/order/exit-order", |
47 | data: { | 47 | data: { |
48 | id: ' . $model->id . ', | 48 | id: ' . $model->id . ', |
49 | }, | 49 | }, |
50 | success: function() { | 50 | success: function() { |
51 | - console.log("Exit order"); | ||
52 | } | 51 | } |
53 | }); | 52 | }); |
54 | }; | 53 | }; |