From 018ca540d5a6dbb7e62bf54871d91c1fb430d1f3 Mon Sep 17 00:00:00 2001 From: dongpd Date: Tue, 20 Oct 2020 10:55:31 +0700 Subject: [PATCH] =?UTF-8?q?fix=20bug=20=C4=91=E1=BB=93ng=20b=E1=BB=99=20d?= =?UTF-8?q?=E1=BB=AF=20li=E1=BB=87u=20nh=C3=A2n=20vi=C3=AAn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/AssignController.php | 2 +- controllers/DeviceController.php | 17 ++++++++++------- helpers/StaffGrid.php | 12 ++++++++++++ views/assign/staff.tpl | 3 ++- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/controllers/AssignController.php b/controllers/AssignController.php index df710600..b95e53d4 100644 --- a/controllers/AssignController.php +++ b/controllers/AssignController.php @@ -97,7 +97,7 @@ class AssignController extends Controller { Yii::$app->response->format = "json"; return [ "schedule" => Schedule::findOne($post['schedule'])->name, - "doors" => implode(", ", $doors) + "doors" => implode("
", $doors) ]; } } diff --git a/controllers/DeviceController.php b/controllers/DeviceController.php index 33a0bf0f..4ec02692 100644 --- a/controllers/DeviceController.php +++ b/controllers/DeviceController.php @@ -418,6 +418,8 @@ class DeviceController extends Controller { $UserInfos = []; $UserAuthorizeInfos = []; + $doorOfDevice = Door::find()->andWhere(['device_id' => $device_id])->all(); + foreach ($staff_lists as $key => $value) { $UserInfos[] = [ "CardNo" => $value["card_number"], @@ -428,13 +430,14 @@ class DeviceController extends Controller { "EndTime" => "" ]; $doors = json_decode($value["door_access"], true); - foreach ($doors as $k => $v) { - $doorInfo = Door::findOne($v); - $UserAuthorizeInfos[] = [ - "Pin" => $value["id"], - "AuthorizeTimezoneId" => $value["schedule_id"], - "AuthorizeDoorId" => $doorInfo->code - ]; + foreach ($doorOfDevice as $k => $v) { + if (in_array($v->id, $doors)) { + $UserAuthorizeInfos[] = [ + "Pin" => $value["id"], + "AuthorizeTimezoneId" => $value["schedule_id"], + "AuthorizeDoorId" => $v->code + ]; + } } } $resUser = json_decode(common::requestToCardService("/SetDeviceData/User", [ diff --git a/helpers/StaffGrid.php b/helpers/StaffGrid.php index 76a11a82..5ababf11 100644 --- a/helpers/StaffGrid.php +++ b/helpers/StaffGrid.php @@ -97,4 +97,16 @@ class StaffGrid extends CommonGrid { }; } + public static function scheduleHeader() { + return function($model) { + return ["id" => "schedule-staff-results-" . $model->id]; + }; + } + + public static function doorsHeader() { + return function($model) { + return ["id" => "schedule-door-results-" . $model->id]; + }; + } + } diff --git a/views/assign/staff.tpl b/views/assign/staff.tpl index 6d3fd6fd..10412d98 100644 --- a/views/assign/staff.tpl +++ b/views/assign/staff.tpl @@ -14,7 +14,6 @@ 'class' => 'table table-striped table-bordered table-hover', 'style' => 'background:#fff;min-width:700px;' ], - 'rowOptions' => \app\helpers\CommonGrid::rows("staff", true), 'columns' => [ [ 'class' => 'yii\grid\SerialColumn', @@ -37,12 +36,14 @@ ], [ 'attribute' => 'schedule', + 'contentOptions' => \app\helpers\StaffGrid::scheduleHeader(), 'value' => \app\helpers\StaffGrid::schedule($scheduleArray) ], [ 'attribute' => 'doors', 'format' => 'raw', 'headerOptions' => ['style' => 'width:15%'], + 'contentOptions' => \app\helpers\StaffGrid::doorsHeader(), 'value' => \app\helpers\StaffGrid::doors($doorsArray) ] ]