update thu gọn danh sách cửa khi cấp quyền truy cập

This commit is contained in:
2020-11-04 10:55:53 +07:00
parent 65aced8ccf
commit f306d207d3
4 changed files with 35 additions and 8 deletions

View File

@@ -86,14 +86,22 @@ class StaffGrid extends CommonGrid {
public static function doors($array) {
return function($model) use ($array) {
$doors = [];
$alert = $hidden = "";
if ($model->door_access) {
$ls = json_decode($model->door_access, true);
foreach ($ls as $key => $value) {
if (isset($array[$value]))
$doors[] = $array[$value];
}
if (count($ls) <= 2) {
$alert = "<div id='short-{$model->id}'>" . implode("<br>", $doors) . "</div>";
} else {
$alert = "<div id='short-{$model->id}'>" . $doors[0] . "<br>" . $doors[1] . "<a href='#' onclick='openDoorList(this, true);return false;' data='{$model->id}'><i class='fa fa-chevron-down'></i> Xem thêm</a></div>";
$hidden = "<div id='full-{$model->id}' class='hidden'>" . implode("<br>", $doors) . "<a href='#' onclick='openDoorList(this, false);return false;' data='{$model->id}'><i class='fa fa-chevron-up'></i> Thu gọn</a></div>";
}
return $alert . $hidden;
}
return implode("<br>", $doors);
return "";
};
}