124
if ($model->id_request_state == 4 && Yii::$app->user->identity->IsAdmin
== false)
{
throw new UserException ('Закрытую заявку может
редактировать только администратор');
}
$old_state = $model->id_request_state;
if ($model->load(Yii::$app->request->post()) && $model->save())
{
if ($old_state != $model->id_request_state && $model-
>id_request_state > 2)
{
$model->complete_date = date("Y-m-d H:i:s");
$model->save();
}
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing Request model.
* If deletion is successful, the browser will be redirected to the 'index' page.