Commit 52e22ec26866a8c2460f1eaaccd243d7ae1259c7
1 parent
d53d1c94
add similar products
Showing
2 changed files
with
44 additions
and
20 deletions
Show diff stats
controllers/OrderController.php
... | ... | @@ -320,9 +320,9 @@ |
320 | 320 | |
321 | 321 | return $out; |
322 | 322 | } |
323 | - | |
323 | + | |
324 | 324 | $model = $this->findModel($id); |
325 | - | |
325 | + | |
326 | 326 | /** |
327 | 327 | * @var User $user |
328 | 328 | */ |
... | ... | @@ -332,7 +332,7 @@ |
332 | 332 | throw new ForbiddenHttpException(); |
333 | 333 | } |
334 | 334 | } |
335 | - | |
335 | + | |
336 | 336 | $dataProvider = new ActiveDataProvider( |
337 | 337 | [ |
338 | 338 | 'query' => $model->getProducts() |
... | ... | @@ -345,11 +345,32 @@ |
345 | 345 | if (empty( $model->manager_id )) { |
346 | 346 | $model->manager_id = \Yii::$app->user->id; |
347 | 347 | } |
348 | - | |
348 | + | |
349 | 349 | $headers = \Yii::$app->response->headers; |
350 | 350 | $headers->set('Access-Control-Allow-Origin', '*'); |
351 | 351 | |
352 | 352 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
353 | + | |
354 | + if ($model->published != true) { | |
355 | + $model->published = true; | |
356 | + $model->save(); | |
357 | + /** | |
358 | + * @var SmsSender $sender | |
359 | + */ | |
360 | + | |
361 | + $sender = \Yii::$app->sender; | |
362 | + $sender->send( | |
363 | + $model->phone, | |
364 | + $this->renderPartial( | |
365 | + '@common/mail/smsorder', | |
366 | + [ | |
367 | + 'order_id' => $model->id, | |
368 | + ] | |
369 | + ) | |
370 | + ); | |
371 | + } | |
372 | + | |
373 | + | |
353 | 374 | $this->unblockOrder($model->id); |
354 | 375 | return $this->render( |
355 | 376 | 'update', |
... | ... | @@ -445,7 +466,7 @@ |
445 | 466 | if ($model->edit_id == \Yii::$app->user->id) { |
446 | 467 | $this->unblockOrder(\Yii::$app->request->post('id')); |
447 | 468 | } |
448 | - | |
469 | + | |
449 | 470 | if (!$model->published) { |
450 | 471 | $model->deleteUnpublished(); |
451 | 472 | } |
... | ... | @@ -508,7 +529,7 @@ |
508 | 529 | $model->save(); |
509 | 530 | } |
510 | 531 | |
511 | - public function actionPublishOrder($id) | |
532 | + public function actionPublishOrder($id,$phone) | |
512 | 533 | { |
513 | 534 | $model = Order::findOne($id); |
514 | 535 | if ($model->published == true) { |
... | ... | @@ -519,16 +540,18 @@ |
519 | 540 | /** |
520 | 541 | * @var SmsSender $sender |
521 | 542 | */ |
522 | - print_r($model->phone); | |
523 | 543 | $sender = \Yii::$app->sender; |
524 | - $sender->send( | |
525 | - $model->phone, | |
526 | - $this->renderPartial( | |
527 | - '@common/mail/smsorder', | |
528 | - [ | |
529 | - 'order_id' => $model->id, | |
530 | - ] | |
531 | - ) | |
532 | - ); | |
544 | + if(!empty($phone)){ | |
545 | + $sender->send( | |
546 | + $phone, | |
547 | + $this->renderPartial( | |
548 | + '@common/mail/smsorder', | |
549 | + [ | |
550 | + 'order_id' => $model->id, | |
551 | + ] | |
552 | + ) | |
553 | + ); | |
554 | + } | |
555 | + | |
533 | 556 | } |
534 | 557 | } | ... | ... |
views/order/_form.php
... | ... | @@ -122,20 +122,21 @@ JS; |
122 | 122 | |
123 | 123 | $js = <<< JS |
124 | 124 | $(document).on('click', '#page-submit', function() { |
125 | + var phone = $('#order-phone').val(); | |
125 | 126 | $.ajax({ |
126 | 127 | url: "/admin/ecommerce/order/publish-order", |
127 | 128 | type: "GET", |
128 | 129 | data: { |
129 | - id: {$model->id} | |
130 | + id: {$model->id}, | |
131 | + phone: phone | |
130 | 132 | }, |
131 | 133 | success: function (data) { |
132 | - alert(data); | |
133 | - $('#main-form').trigger('submit'); | |
134 | + | |
134 | 135 | }, |
135 | 136 | error: function () { |
136 | 137 | } |
137 | 138 | }); |
138 | - | |
139 | + $('#main-form').trigger('submit'); | |
139 | 140 | }); |
140 | 141 | JS; |
141 | 142 | ... | ... |