Commit 7cfb6c633843b6b473759719e904867fc4c88d26
Merge remote-tracking branch 'origin/master'
Showing
2 changed files
with
46 additions
and
17 deletions
Show diff stats
controllers/OrderController.php
@@ -176,6 +176,7 @@ | @@ -176,6 +176,7 @@ | ||
176 | 176 | ||
177 | if (!empty( $model )) { | 177 | if (!empty( $model )) { |
178 | $model->count += $count; | 178 | $model->count += $count; |
179 | + $model->removed = false; | ||
179 | } else { | 180 | } else { |
180 | $model = new OrderProduct(); | 181 | $model = new OrderProduct(); |
181 | 182 | ||
@@ -186,6 +187,7 @@ | @@ -186,6 +187,7 @@ | ||
186 | $model->sku = $productVariant->sku; | 187 | $model->sku = $productVariant->sku; |
187 | $model->price = $productVariant->price; | 188 | $model->price = $productVariant->price; |
188 | $model->count = $count; | 189 | $model->count = $count; |
190 | + $model->removed = false; | ||
189 | } | 191 | } |
190 | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | 192 | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; |
191 | 193 | ||
@@ -320,9 +322,9 @@ | @@ -320,9 +322,9 @@ | ||
320 | 322 | ||
321 | return $out; | 323 | return $out; |
322 | } | 324 | } |
323 | - | 325 | + |
324 | $model = $this->findModel($id); | 326 | $model = $this->findModel($id); |
325 | - | 327 | + |
326 | /** | 328 | /** |
327 | * @var User $user | 329 | * @var User $user |
328 | */ | 330 | */ |
@@ -332,7 +334,7 @@ | @@ -332,7 +334,7 @@ | ||
332 | throw new ForbiddenHttpException(); | 334 | throw new ForbiddenHttpException(); |
333 | } | 335 | } |
334 | } | 336 | } |
335 | - | 337 | + |
336 | $dataProvider = new ActiveDataProvider( | 338 | $dataProvider = new ActiveDataProvider( |
337 | [ | 339 | [ |
338 | 'query' => $model->getProducts() | 340 | 'query' => $model->getProducts() |
@@ -345,11 +347,32 @@ | @@ -345,11 +347,32 @@ | ||
345 | if (empty( $model->manager_id )) { | 347 | if (empty( $model->manager_id )) { |
346 | $model->manager_id = \Yii::$app->user->id; | 348 | $model->manager_id = \Yii::$app->user->id; |
347 | } | 349 | } |
348 | - | 350 | + |
349 | $headers = \Yii::$app->response->headers; | 351 | $headers = \Yii::$app->response->headers; |
350 | $headers->set('Access-Control-Allow-Origin', '*'); | 352 | $headers->set('Access-Control-Allow-Origin', '*'); |
351 | 353 | ||
352 | if ($model->load(Yii::$app->request->post()) && $model->save()) { | 354 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
355 | + | ||
356 | + if ($model->published != true) { | ||
357 | + $model->published = true; | ||
358 | + $model->save(); | ||
359 | + /** | ||
360 | + * @var SmsSender $sender | ||
361 | + */ | ||
362 | + | ||
363 | + $sender = \Yii::$app->sender; | ||
364 | + $sender->send( | ||
365 | + $model->phone, | ||
366 | + $this->renderPartial( | ||
367 | + '@common/mail/smsorder', | ||
368 | + [ | ||
369 | + 'order_id' => $model->id, | ||
370 | + ] | ||
371 | + ) | ||
372 | + ); | ||
373 | + } | ||
374 | + | ||
375 | + | ||
353 | $this->unblockOrder($model->id); | 376 | $this->unblockOrder($model->id); |
354 | return $this->render( | 377 | return $this->render( |
355 | 'update', | 378 | 'update', |
@@ -416,6 +439,7 @@ | @@ -416,6 +439,7 @@ | ||
416 | { | 439 | { |
417 | $model = OrderProduct::findOne($id); | 440 | $model = OrderProduct::findOne($id); |
418 | $model->removed = true; | 441 | $model->removed = true; |
442 | + $model->count = 0; | ||
419 | $model->save(); | 443 | $model->save(); |
420 | $order = Order::findOne($order_id); | 444 | $order = Order::findOne($order_id); |
421 | $order->totalRecount(); | 445 | $order->totalRecount(); |
@@ -445,7 +469,7 @@ | @@ -445,7 +469,7 @@ | ||
445 | if ($model->edit_id == \Yii::$app->user->id) { | 469 | if ($model->edit_id == \Yii::$app->user->id) { |
446 | $this->unblockOrder(\Yii::$app->request->post('id')); | 470 | $this->unblockOrder(\Yii::$app->request->post('id')); |
447 | } | 471 | } |
448 | - | 472 | + |
449 | if (!$model->published) { | 473 | if (!$model->published) { |
450 | $model->deleteUnpublished(); | 474 | $model->deleteUnpublished(); |
451 | } | 475 | } |
@@ -508,7 +532,7 @@ | @@ -508,7 +532,7 @@ | ||
508 | $model->save(); | 532 | $model->save(); |
509 | } | 533 | } |
510 | 534 | ||
511 | - public function actionPublishOrder($id) | 535 | + public function actionPublishOrder($id,$phone) |
512 | { | 536 | { |
513 | $model = Order::findOne($id); | 537 | $model = Order::findOne($id); |
514 | if ($model->published == true) { | 538 | if ($model->published == true) { |
@@ -520,14 +544,17 @@ | @@ -520,14 +544,17 @@ | ||
520 | * @var SmsSender $sender | 544 | * @var SmsSender $sender |
521 | */ | 545 | */ |
522 | $sender = \Yii::$app->sender; | 546 | $sender = \Yii::$app->sender; |
523 | - $sender->send( | ||
524 | - $model->phone, | ||
525 | - $this->renderPartial( | ||
526 | - '@common/mail/smsorder', | ||
527 | - [ | ||
528 | - 'order_id' => $model->id, | ||
529 | - ] | ||
530 | - ) | ||
531 | - ); | 547 | + if(!empty($phone)){ |
548 | + $sender->send( | ||
549 | + $phone, | ||
550 | + $this->renderPartial( | ||
551 | + '@common/mail/smsorder', | ||
552 | + [ | ||
553 | + 'order_id' => $model->id, | ||
554 | + ] | ||
555 | + ) | ||
556 | + ); | ||
557 | + } | ||
558 | + | ||
532 | } | 559 | } |
533 | } | 560 | } |
views/order/_form.php
@@ -122,14 +122,16 @@ JS; | @@ -122,14 +122,16 @@ JS; | ||
122 | 122 | ||
123 | $js = <<< JS | 123 | $js = <<< JS |
124 | $(document).on('click', '#page-submit', function() { | 124 | $(document).on('click', '#page-submit', function() { |
125 | + var phone = $('#order-phone').val(); | ||
125 | $.ajax({ | 126 | $.ajax({ |
126 | url: "/admin/ecommerce/order/publish-order", | 127 | url: "/admin/ecommerce/order/publish-order", |
127 | type: "GET", | 128 | type: "GET", |
128 | data: { | 129 | data: { |
129 | - id: {$model->id} | 130 | + id: {$model->id}, |
131 | + phone: phone | ||
130 | }, | 132 | }, |
131 | success: function (data) { | 133 | success: function (data) { |
132 | - | 134 | + |
133 | }, | 135 | }, |
134 | error: function () { | 136 | error: function () { |
135 | } | 137 | } |