Commit 99de237fdf5cc08ab151d1404c76b52c0c3ac8a5
1 parent
22a34996
-Order block core finished
Showing
3 changed files
with
30 additions
and
5 deletions
Show diff stats
controllers/OrderController.php
... | ... | @@ -291,7 +291,9 @@ |
291 | 291 | $model = $this->findModel($id); |
292 | 292 | |
293 | 293 | if ($model->isBlocked() && $model->edit_id !== \Yii::$app->user->id) { |
294 | - throw new ForbiddenHttpException(); | |
294 | + if (!\Yii::$app->user->identity->isAdmin()) { | |
295 | + throw new ForbiddenHttpException(); | |
296 | + } | |
295 | 297 | } |
296 | 298 | |
297 | 299 | $dataProvider = new ActiveDataProvider( |
... | ... | @@ -381,6 +383,12 @@ |
381 | 383 | throw new NotFoundHttpException('The requested page does not exist.'); |
382 | 384 | } |
383 | 385 | } |
386 | + | |
387 | + public function actionExitOrder($id) | |
388 | + { | |
389 | + $this->unblockOrder($id); | |
390 | + return $this->redirect('index'); | |
391 | + } | |
384 | 392 | |
385 | 393 | public function actionBlockOrder() |
386 | 394 | { |
... | ... | @@ -392,8 +400,13 @@ |
392 | 400 | $model->edit_time = time(); |
393 | 401 | $model->edit_id = \Yii::$app->user->id; |
394 | 402 | |
403 | + //$date = new \DateTime("NOW"/*date('D, d M Y H:i:s', $model->edit_time)*/, new \DateTimeZone('Europe/Kiev')); | |
404 | + $date = \Yii::$app->formatter->asDatetime($model->edit_time + 7200, 'php:G : i'); | |
405 | + | |
395 | 406 | if ($model->save()) { |
396 | - return [ 'success' => true ]; | |
407 | + return [ | |
408 | + 'time' => $date, | |
409 | + ]; | |
397 | 410 | } else { |
398 | 411 | return [ 'success' => false ]; |
399 | 412 | } | ... | ... |
views/order/_form.php
... | ... | @@ -110,6 +110,18 @@ JS; |
110 | 110 | 'target' => '_blank', |
111 | 111 | ] |
112 | 112 | ) ?> |
113 | + <?= Html::a( | |
114 | + \Yii::t('app', 'Выйти'), | |
115 | + yii\helpers\Url::to( | |
116 | + [ | |
117 | + 'exit-order', | |
118 | + 'id' => $model->id, | |
119 | + ] | |
120 | + ), | |
121 | + [ | |
122 | + 'class' => $model->isNewRecord ? 'btn btn-info disabled btn-lg' : 'btn btn-info btn-lg', | |
123 | + ] | |
124 | + ) ?> | |
113 | 125 | </div> |
114 | 126 | <br> |
115 | 127 | <div class="row"> | ... | ... |
views/order/update.php
... | ... | @@ -24,11 +24,11 @@ $.ajax({ |
24 | 24 | data: { |
25 | 25 | id: ' . $model->id . ' |
26 | 26 | }, |
27 | - success: function() { | |
27 | + success: function(data) { | |
28 | 28 | $.notify({ |
29 | - message: \'Hello World\' | |
29 | + message: data.time | |
30 | 30 | },{ |
31 | - type: \'danger\' | |
31 | + type: "info" | |
32 | 32 | }); |
33 | 33 | } |
34 | 34 | });'; | ... | ... |