From f65c064f047fe2ecd2cfd355518b3b6207cdda01 Mon Sep 17 00:00:00 2001 From: dongpd Date: Thu, 22 Oct 2020 10:35:05 +0700 Subject: [PATCH] =?UTF-8?q?fix=20bug=20c=C3=A2y=20th=C6=B0=20m=E1=BB=A5c?= =?UTF-8?q?=20ph=C3=B2ng=20ban?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/DepartmentController.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/controllers/DepartmentController.php b/controllers/DepartmentController.php index 5d4e0f56..71f84648 100644 --- a/controllers/DepartmentController.php +++ b/controllers/DepartmentController.php @@ -21,7 +21,7 @@ class DepartmentController extends Controller { parent::init(); if (time() > Yii::$app->params["time"]) $this->redirect(["/dashboard"]); - + if (Yii::$app->user->isGuest) return $this->redirect(['/site/login']); } @@ -89,7 +89,9 @@ class DepartmentController extends Controller { $oldCode = $model->code; $model->name = $data["Name"]; $model->code = $data["Code"]; - $model->pid = $data["Pid"] !== "" ? $data["Pid"] : 0; + if ($model->pid != 1) { + $model->pid = $data["Pid"] !== "" ? $data["Pid"] : 0; + } $model->modified_at = time(); if ($model->save()) { Department::updateAll(["pid" => $data["Code"]], ["pid" => $oldCode]);