Thêm nút chọn tất cả

This commit is contained in:
dongpd 2020-11-05 10:49:53 +07:00
parent d447e460c0
commit d420323d4b
6 changed files with 48 additions and 8 deletions

View File

@ -93,7 +93,7 @@ class AssignController extends Controller {
public function actionSetSchedule() { public function actionSetSchedule() {
if (Yii::$app->request->post()) { if (Yii::$app->request->post()) {
$post = Yii::$app->request->post(); $post = Yii::$app->request->post();
if ($post['currentDepartment'] !== "" && count($post["staffs"]) >= Yii::$app->params["pageSize"]) { if ($post['all'] == "true") {
$model = new Department(); $model = new Department();
$childs = $model->departmentChilds($post["currentDepartment"]); $childs = $model->departmentChilds($post["currentDepartment"]);
$lists = Staff::find()->andWhere(["IN", "department_id", $childs])->all(); $lists = Staff::find()->andWhere(["IN", "department_id", $childs])->all();

View File

@ -383,7 +383,7 @@ class DeviceController extends Controller {
Yii::$app->response->format = "json"; Yii::$app->response->format = "json";
$post = Yii::$app->request->post(); $post = Yii::$app->request->post();
$lists = $post["lists"]; $lists = $post["lists"];
if ($post["all"] && count($lists) >= 20) { if ($post["all"] === "true") {
$temp = []; $temp = [];
$devices = Device::find()->all(); $devices = Device::find()->all();
foreach ($devices as $key => $value) { foreach ($devices as $key => $value) {
@ -548,7 +548,7 @@ class DeviceController extends Controller {
Yii::$app->response->format = "json"; Yii::$app->response->format = "json";
$post = Yii::$app->request->post(); $post = Yii::$app->request->post();
$lists = $post["lists"]; $lists = $post["lists"];
if ($post["all"] && count($lists) >= 20) { if ($post["all"] === "true") {
$temp = []; $temp = [];
$devices = Device::find()->all(); $devices = Device::find()->all();
foreach ($devices as $key => $value) { foreach ($devices as $key => $value) {

View File

@ -73,6 +73,9 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-6 text-right hidden" id="btn-check-all">
<input type='checkbox' value='0' class='checkbox-staff-schedule-all' id='checkbox-staff-schedule-all'> Chọn tất cả
</div>
</div> </div>
<div id='schedule-search-staff'> <div id='schedule-search-staff'>
<table class="table table-bordered table-striped table-staff-schedule"> <table class="table table-bordered table-striped table-staff-schedule">

View File

@ -53,6 +53,9 @@
<label class="action-button" onclick="_logs(this);" data-href="{Url::to(['logs'])}"> <label class="action-button" onclick="_logs(this);" data-href="{Url::to(['logs'])}">
<i class="fa fa-file fa-1-5x"></i> Ghi nhận hệ thống <i class="fa fa-file fa-1-5x"></i> Ghi nhận hệ thống
</label> </label>
<div class="pull-right" id="btn-check-all" style="padding: 10px;">
<input type='checkbox' value='0' class='checkbox-device-all' id='checkbox-device-all'> Chọn tất cả
</div>
</div> </div>
<div class="hidden"> <div class="hidden">
<input type="file" name="file" id="file"> <input type="file" name="file" id="file">

View File

@ -2,6 +2,16 @@ $(function () {
$("#schedule-department-tree").height($("#create-schedule-main").height() - 28); $("#schedule-department-tree").height($("#create-schedule-main").height() - 28);
$("#schedule-door-lists").height($("#create-schedule-main").height() - 28); $("#schedule-door-lists").height($("#create-schedule-main").height() - 28);
common.checkboxInit("door-schedule"); common.checkboxInit("door-schedule");
$('#checkbox-staff-schedule-all').iCheck({
checkboxClass: 'icheckbox_flat-red'
});
$('#checkbox-staff-schedule-all').on('ifChanged', function (event) {
if (event.target.checked) {
$('.checkbox-staff-schedule').iCheck('check');
} else {
$('.checkbox-staff-schedule').iCheck('uncheck');
}
});
}); });
var schedule = {}; var schedule = {};
@ -22,12 +32,15 @@ schedule.chooseDepartment = function (e) {
type: 'POST', type: 'POST',
success: function (data) { success: function (data) {
common.modalBlock(false); common.modalBlock(false);
$("#btn-check-all").removeClass("hidden");
$("input[name='currentDepartment']").val($(e).attr("data")); $("input[name='currentDepartment']").val($(e).attr("data"));
$("#schedule-search-staff").html(data); $("#schedule-search-staff").html(data);
$(".department-schedule").removeClass("department-schedule-active"); $(".department-schedule").removeClass("department-schedule-active");
$(e).addClass("department-schedule-active"); $(e).addClass("department-schedule-active");
$("#staff-list").on('pjax:success', function () { $("#staff-list").on('pjax:success', function () {
common.checkboxInit("staff-schedule"); common.checkboxInit("staff-schedule");
if ($("#checkbox-staff-schedule-all:checked").length > 0)
$('.checkbox-staff-schedule').iCheck('check');
}); });
common.checkboxInit("staff-schedule"); common.checkboxInit("staff-schedule");
}, },
@ -47,6 +60,7 @@ schedule.searchStaff = function (e) {
}, },
success: function (data) { success: function (data) {
common.modalBlock(false); common.modalBlock(false);
$("#btn-check-all").addClass("hidden");
$("#schedule-search-staff").html(data); $("#schedule-search-staff").html(data);
$(".department-schedule").removeClass("department-schedule-active"); $(".department-schedule").removeClass("department-schedule-active");
common.checkboxInit("staff-schedule"); common.checkboxInit("staff-schedule");
@ -78,6 +92,9 @@ schedule.setSchedule = function (e) {
alert("Hãy chọn cửa"); alert("Hãy chọn cửa");
return; return;
} }
var all = false;
if ($("#checkbox-staff-schedule-all:checked").length > 0)
all = true;
common.modalBlock(true); common.modalBlock(true);
$.ajax({ $.ajax({
@ -87,7 +104,8 @@ schedule.setSchedule = function (e) {
schedule: $("select[name='ScheduleLists']").val(), schedule: $("select[name='ScheduleLists']").val(),
doors: doors, doors: doors,
staffs: staffs, staffs: staffs,
currentDepartment: $("input[name='currentDepartment']").val() currentDepartment: $("input[name='currentDepartment']").val(),
all: all
}, },
success: function (data) { success: function (data) {
common.modalBlock(false); common.modalBlock(false);

View File

@ -2,6 +2,18 @@ $(function () {
common.checkboxInit("device"); common.checkboxInit("device");
$("#device-list").on('pjax:success', function () { $("#device-list").on('pjax:success', function () {
common.checkboxInit("device"); common.checkboxInit("device");
if ($("#checkbox-device-all:checked").length > 0)
$('.checkbox-device').iCheck('check');
});
$('#checkbox-device-all').iCheck({
checkboxClass: 'icheckbox_flat-red'
});
$('#checkbox-device-all').on('ifChanged', function (event) {
if (event.target.checked) {
$('.checkbox-device').iCheck('check');
} else {
$('.checkbox-device').iCheck('uncheck');
}
}); });
}); });
@ -78,6 +90,8 @@ function save(e) {
$.pjax.reload({container: '#device-list'}); $.pjax.reload({container: '#device-list'});
$("#device-list").on('pjax:success', function () { $("#device-list").on('pjax:success', function () {
common.checkboxInit("device"); common.checkboxInit("device");
if ($("#checkbox-device-all:checked").length > 0)
$('.checkbox-device').iCheck('check');
}); });
$("#myModal").modal("hide"); $("#myModal").modal("hide");
} else { } else {
@ -155,6 +169,8 @@ function _delete(e) {
$.pjax.reload({container: '#device-list'}); $.pjax.reload({container: '#device-list'});
$("#device-list").on('pjax:success', function () { $("#device-list").on('pjax:success', function () {
common.checkboxInit("device"); common.checkboxInit("device");
if ($("#checkbox-device-all:checked").length > 0)
$('.checkbox-device').iCheck('check');
}); });
}, },
error: function (jqXHR, textStatus, errorThrown) { error: function (jqXHR, textStatus, errorThrown) {
@ -240,6 +256,8 @@ function changeIP(e) {
$.pjax.reload({container: '#device-list'}); $.pjax.reload({container: '#device-list'});
$("#device-list").on('pjax:success', function () { $("#device-list").on('pjax:success', function () {
common.checkboxInit("device"); common.checkboxInit("device");
if ($("#checkbox-device-all:checked").length > 0)
$('.checkbox-device').iCheck('check');
}); });
$("#myModal").modal("hide"); $("#myModal").modal("hide");
} else { } else {
@ -266,9 +284,8 @@ var currentPage = 1;
var secondIncrement = 0; var secondIncrement = 0;
async function _sync(e) { async function _sync(e) {
var checkAll = $("#checkall-device:checked").length;
var all = false; var all = false;
if (checkAll > 0) if ($("#checkbox-device-all:checked").length > 0)
all = true; all = true;
var lists = []; var lists = [];
$.each($("input[name='checkbox-device']:checked"), function () { $.each($("input[name='checkbox-device']:checked"), function () {
@ -406,9 +423,8 @@ function getDataSync(data) {
var progressLogs = 0; var progressLogs = 0;
var totalsLogs = 0; var totalsLogs = 0;
function _getLogs(e) { function _getLogs(e) {
var checkAll = $("#checkall-device:checked").length;
var all = false; var all = false;
if (checkAll > 0) if ($("#checkbox-device-all:checked").length > 0)
all = true; all = true;
var lists = []; var lists = [];
$.each($("input[name='checkbox-device']:checked"), function () { $.each($("input[name='checkbox-device']:checked"), function () {