update manage schedule

This commit is contained in:
2022-09-26 09:43:12 +07:00
parent ac0588b711
commit 33e439de8f
16 changed files with 677 additions and 25 deletions

View File

@@ -49,6 +49,7 @@ $(document).on('focusin', function (e) {
/**
* Các hàm sử dụng chung
*/
$('select').select2();
var common = {};
common.csrf = $('meta[name="csrf-token"]').attr("content");
common.csrfParam = $('meta[name="csrf-param"]').attr("content");
@@ -360,7 +361,26 @@ common.changeLanguage = function (e) {
error: function (jqXHR, textStatus, errorThrown) {
}
});
}
};
common.changePerPage = function (e) {
if (window.location.search !== "") {
var perPage = common.getUrlParameter("per-page");
if (perPage) {
var sPageURL = decodeURIComponent(window.location.search.substring(1));
var sURLVariables = sPageURL.split('&');
var newUrl = [];
for (var i = 0; i < sURLVariables.length; i++) {
var temp = sURLVariables[i].split('=');
if (temp[0] !== "per-page")
newUrl.push(sURLVariables[i]);
}
newUrl.push("per-page=" + $(e).val());
window.location = window.location.origin + window.location.pathname + "?" + newUrl.join("&");
} else
window.location = window.location + "&per-page=" + $(e).val();
} else
window.location = window.location + "?per-page=" + $(e).val();
};
/**
* =========================
*/

View File

@@ -1,4 +1,5 @@
var x = 0, y = 0;
var multiChoose = false;
$(function () {
common.dateTimePickerByClass("datepicker", "HH:mm DD/MM/YYYY");
common.dateTimePickerDay("birthday");
@@ -9,9 +10,13 @@ $(function () {
$("input[name='BatchDelete']").change(function () {
if (this.checked) {
$("#delete-btn-group").removeClass("hidden");
multiChoose = true;
$(".checkbox-column").removeClass("hidden");
} else {
$("tr").removeClass("delete-choose");
$("#delete-btn-group").addClass("hidden");
multiChoose = false;
$(".checkbox-column").addClass("hidden");
}
});
btnImage();
@@ -181,10 +186,22 @@ function _deleteFeature(e) {
}
function checkAll(status) {
if (status)
$("tr").addClass("delete-choose");
if (status) {
$("#list-face").find("tr").addClass("delete-choose");
$(".checkbox-column").find("input").prop('checked', true);
} else {
$("#list-face").find("tr").removeClass("delete-choose");
$(".checkbox-column").find("input").prop('checked', false);
}
}
function choose(e) {
if (!multiChoose)
return false;
if ($(e).closest("tr").hasClass("delete-choose"))
$(e).closest("tr").removeClass("delete-choose");
else
$("tr").removeClass("delete-choose");
$(e).closest("tr").addClass("delete-choose");
}
function batchDelete(e) {
@@ -671,3 +688,164 @@ function filtersLossImage(e) {
}
}
function scheduleForm(e) {
var check = $(".delete-choose");
if (check.length == 0) {
alert($("input[name='HAY_CHON_DOI_TUONG_DE_GAN_LICH_TRINH']").val());
return;
}
common.modalBlock(true);
$.ajax({
url: $(e).attr("data-href"),
type: 'POST',
success: function (data) {
common.modalBlock(false);
common.modalOpen(data.form, false, data.title);
common.dateTimePickerDay("fromDate");
common.dateTimePickerDay("toDate");
common.dateTimePickerHour("fromTime");
common.dateTimePickerHour("toTime");
},
error: function (jqXHR, textStatus, errorThrown) {
common.modalBlock(false);
common.ajaxError();
}
});
}
function addSchedule(e) {
var lists = [];
$.each($(".delete-choose"), function () {
if ($(this).attr("data-id") !== "")
lists.push($(this).attr("data-id"));
});
if (lists.length == 0) {
alert($("input[name='HAY_CHON_DOI_TUONG_DE_GAN_LICH_TRINH']").val());
return;
}
var dateOfWeek = [];
$.each($("input[name='checkbox-date']:checked"), function () {
dateOfWeek.push($(this).val());
});
common.modalBlock(true);
$.ajax({
url: $(e).attr("data-href"),
type: 'POST',
data: {
fromTime: $("input[name='FromTime']").val(),
toTime: $("input[name='ToTime']").val(),
fromDate: $("input[name='FromDate']").val(),
toDate: $("input[name='ToDate']").val(),
dateOfWeek: dateOfWeek,
lists: lists
},
success: function (data) {
common.modalBlock(false);
window.location.reload(true);
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(errorThrown);
common.modalBlock(false);
common.ajaxError();
}
});
}
function formEditSchedule(e) {
common.modalBlock(true);
$.ajax({
url: $(e).attr("data-href"),
type: 'POST',
success: function (data) {
common.modalBlock(false);
common.modalOpen(data.form, false, data.title);
common.dateTimePickerDay("fromDate");
common.dateTimePickerDay("toDate");
common.dateTimePickerHour("fromTime");
common.dateTimePickerHour("toTime");
},
error: function (jqXHR, textStatus, errorThrown) {
common.modalBlock(false);
common.ajaxError();
}
});
}
function editSchedule(e) {
var lists = [];
$.each($(".delete-choose"), function () {
if ($(this).attr("data-id") !== "")
lists.push($(this).attr("data-id"));
});
var dateOfWeek = [];
$.each($("input[name='checkbox-date']:checked"), function () {
dateOfWeek.push($(this).val());
});
common.modalBlock(true);
$.ajax({
url: $(e).attr("data-href"),
type: 'POST',
data: {
fromTime: $("input[name='FromTime']").val(),
toTime: $("input[name='ToTime']").val(),
fromDate: $("input[name='FromDate']").val(),
toDate: $("input[name='ToDate']").val(),
dateOfWeek: dateOfWeek,
lists: lists,
editAll: $("input[name='editAll']").is(":checked")
},
success: function (data) {
common.modalBlock(false);
window.location.reload(true);
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(errorThrown);
common.modalBlock(false);
common.ajaxError();
}
});
}
function formDeleteSchedule(e) {
common.modalBlock(true);
$.ajax({
url: $(e).attr("data-href"),
type: 'POST',
success: function (data) {
common.modalBlock(false);
common.modalOpen(data.form, false, data.title);
},
error: function (jqXHR, textStatus, errorThrown) {
common.modalBlock(false);
common.ajaxError();
}
});
}
function deleteSchedule(e) {
if (confirm($("input[name='BAN_CO_CHAC_CHAN_MUON_XOA_LICH_TRINH_NAY_KHONG']").val())) {
var lists = [];
$.each($(".delete-choose"), function () {
if ($(this).attr("data-id") !== "")
lists.push($(this).attr("data-id"));
});
common.modalBlock(true);
$.ajax({
url: $(e).attr("data-href"),
type: 'POST',
data: {
editAll: $("input[name='editAll']").is(":checked"),
lists: lists
},
success: function (data) {
common.modalBlock(false);
window.location.reload(true);
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(errorThrown);
common.modalBlock(false);
common.ajaxError();
}
});
}
}