diff --git a/controllers/OrderController.php b/controllers/OrderController.php
index 24eff1d..dd7491e 100755
--- a/controllers/OrderController.php
+++ b/controllers/OrderController.php
@@ -291,7 +291,9 @@
$model = $this->findModel($id);
if ($model->isBlocked() && $model->edit_id !== \Yii::$app->user->id) {
- throw new ForbiddenHttpException();
+ if (!\Yii::$app->user->identity->isAdmin()) {
+ throw new ForbiddenHttpException();
+ }
}
$dataProvider = new ActiveDataProvider(
@@ -381,6 +383,12 @@
throw new NotFoundHttpException('The requested page does not exist.');
}
}
+
+ public function actionExitOrder($id)
+ {
+ $this->unblockOrder($id);
+ return $this->redirect('index');
+ }
public function actionBlockOrder()
{
@@ -392,8 +400,13 @@
$model->edit_time = time();
$model->edit_id = \Yii::$app->user->id;
+ //$date = new \DateTime("NOW"/*date('D, d M Y H:i:s', $model->edit_time)*/, new \DateTimeZone('Europe/Kiev'));
+ $date = \Yii::$app->formatter->asDatetime($model->edit_time + 7200, 'php:G : i');
+
if ($model->save()) {
- return [ 'success' => true ];
+ return [
+ 'time' => $date,
+ ];
} else {
return [ 'success' => false ];
}
diff --git a/views/order/_form.php b/views/order/_form.php
index c14a0a3..cf66cd0 100755
--- a/views/order/_form.php
+++ b/views/order/_form.php
@@ -110,6 +110,18 @@ JS;
'target' => '_blank',
]
) ?>
+ = Html::a(
+ \Yii::t('app', 'Выйти'),
+ yii\helpers\Url::to(
+ [
+ 'exit-order',
+ 'id' => $model->id,
+ ]
+ ),
+ [
+ 'class' => $model->isNewRecord ? 'btn btn-info disabled btn-lg' : 'btn btn-info btn-lg',
+ ]
+ ) ?>