fix bug đồng bộ dữ liệu nhân viên

This commit is contained in:
dongpd 2020-10-20 10:55:31 +07:00
parent ad30699a52
commit 018ca540d5
4 changed files with 25 additions and 9 deletions

View File

@ -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("<br>", $doors)
];
}
}

View File

@ -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", [

View File

@ -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];
};
}
}

View File

@ -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)
]
]