update thu gọn danh sách cửa khi cấp quyền truy cập
This commit is contained in:
parent
65aced8ccf
commit
f306d207d3
|
@ -109,7 +109,7 @@ class AssignController extends Controller {
|
|||
Yii::$app->response->format = "json";
|
||||
return [
|
||||
"schedule" => Schedule::findOne($post['schedule'])->name,
|
||||
"doors" => implode("<br>", $doors)
|
||||
"doors" => $doors
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 "";
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||
<group>
|
||||
<file>file:/C:/xampp/htdocs/Server_AccessControl/views/device/doors.tpl</file>
|
||||
<file>file:/C:/xampp/htdocs/Server_AccessControl/web/js/device.js</file>
|
||||
<file>file:/C:/xampp/htdocs/Server_AccessControl/controllers/DeviceController.php</file>
|
||||
<file>file:/C:/xampp/htdocs/Server_AccessControl/helpers/StaffGrid.php</file>
|
||||
<file>file:/C:/xampp/htdocs/Server_AccessControl/views/assign/staff.tpl</file>
|
||||
</group>
|
||||
</open-files>
|
||||
</project-private>
|
||||
|
|
|
@ -92,8 +92,17 @@ schedule.setSchedule = function (e) {
|
|||
notification.success("Đã lưu thông tin", 1000);
|
||||
$.each($("input[name='checkbox-staff-schedule']:checked"), function () {
|
||||
if ($(this).val() !== "0") {
|
||||
$("#schedule-staff-results-" + $(this).val()).html(data.schedule);
|
||||
$("#schedule-door-results-" + $(this).val()).html(data.doors);
|
||||
var id = $(this).val();
|
||||
$("#schedule-staff-results-" + id).html(data.schedule);
|
||||
var alert = "";
|
||||
var hidden = "";
|
||||
if (data.doors.length <= 2) {
|
||||
alert = "<div id='short-{$model->id}'>" + data.doors.join("<br>") + "</div>";
|
||||
} else {
|
||||
alert = "<div id='short-" + id + "'>" + data.doors[0] + "<br>" + data.doors[1] + "<a href='#' onclick='openDoorList(this, true);return false;' data='" + id + "'><i class='fa fa-chevron-down'></i> Xem thêm</a></div>";
|
||||
hidden = "<div id='full-" + id + "' class='hidden'>" + data.doors.join("<br>") + "<a href='#' onclick='openDoorList(this, false);return false;' data='" + id + "'><i class='fa fa-chevron-up'></i> Thu gọn</a></div>";
|
||||
}
|
||||
$("#schedule-door-results-" + id).html(alert + hidden);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -103,4 +112,15 @@ schedule.setSchedule = function (e) {
|
|||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
function openDoorList(e, stt) {
|
||||
var id = $(e).attr("data");
|
||||
if (stt) {
|
||||
$("#short-" + id).addClass("hidden");
|
||||
$("#full-" + id).removeClass("hidden");
|
||||
} else {
|
||||
$("#short-" + id).removeClass("hidden");
|
||||
$("#full-" + id).addClass("hidden");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user