calculate delivery date fix

This commit is contained in:
Michał Zieliński
2025-08-30 13:15:50 +02:00
parent eab6fc87b1
commit be27602ca3
2 changed files with 204 additions and 196 deletions

View File

@@ -15,7 +15,7 @@ $(document).ready(
window.onbeforeunload = confirmExit; window.onbeforeunload = confirmExit;
// prevent submit by enter press // prevent submit by enter press
lockEnter(); lockEnter();
// parent info
$("#delivery_date").on('inputchange', function () { $("#delivery_date").on('inputchange', function () {
calculateDate($("#delivery_date").val()); calculateDate($("#delivery_date").val());
}); });
@@ -157,6 +157,7 @@ $(document).ready(
} }
}); });
AddSearchRecord(); AddSearchRecord();
calculateDate($("#delivery_date").val());
$(".loading_panel").css("display", "none"); $(".loading_panel").css("display", "none");
}); });
// handle save // handle save
@@ -187,7 +188,6 @@ check_form = function(formname,event) {
$("#position_list").val(JSON.stringifyNoSecurity(items)); $("#position_list").val(JSON.stringifyNoSecurity(items));
if (check_form_(formname) === true) { if (check_form_(formname) === true) {
return true; return true;
} else { } else {
@@ -196,6 +196,7 @@ check_form = function(formname,event) {
return false; return false;
} }
}; };
function confirmExit() { function confirmExit() {
return ""; return "";
} }

View File

@@ -23,6 +23,13 @@ switch ($_POST['job']) {
function calculateDate($date){ function calculateDate($date){
$date = new Datetime($date); $date = new Datetime($date);
$date->modify('-1 day'); $date->modify('-1 day');
$tmp['date']=$date->format("d.m.Y");
$tmp['date_day']=date('N', strtotime($tmp['date']));
if($tmp['date_day']==7){
$date->modify('-2 day');
} else if($tmp['date_day']==6){
$date->modify('-1 day');
}
$tmp['date']=$date->format("d.m.Y"); $tmp['date']=$date->format("d.m.Y");
echo json_encode($tmp); echo json_encode($tmp);
return ''; return '';