production: time in production date

This commit is contained in:
Michał Zieliński
2025-10-06 20:13:50 +02:00
parent aae6334793
commit 0e8227fc82
3 changed files with 60 additions and 25 deletions

View File

@@ -8,7 +8,7 @@ $(document).ready(function () {
return false;
},
format: function (s, table, cell) {
return $(cell).find("input[id^=production-date]").val() || "2222-01-01";
return $(cell).find("input[id^=production-date]").val() + " " + $(cell).find("input[id^=production-time]").val() || "2222-01-01";
},
parsed: false,
type: "text"
@@ -304,9 +304,37 @@ function removePositions() {
});
}
function saveProductionDate(id) {
let date = $("#production-date-" + id).val();
let time = $("#production-time-" + id).val();
if (date.length !== 10) {
$("#production-date-" + id).val('');
$("#production-time-" + id).val('');
date = '';
time = '';
} else {
if (time.length === 5) {
// Sprawdź format HH:mm
const timeRegex = /^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$/;
if (!timeRegex.test(time)) {
time = "06:00";
}
} else if (time.length === 4) {
// Wstaw : pomiędzy i sprawdź format
time = time.substring(0, 2) + ":" + time.substring(2);
const timeRegex = /^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$/;
if (!timeRegex.test(time)) {
time = "06:00";
}
} else {
time = "06:00";
}
}
$("#production-time-" + id).val(time);
$.ajax({
method: "get",
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=saveProductionDate&id=" + id + "&date=" + $("#production-date-" + id).val(),
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=saveProductionDate&id=" + id + "&date=" + encodeURIComponent(date) + "&time=" + encodeURIComponent(time),
});
}
function editDescription(id) {