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

@@ -1,6 +1,6 @@
//START: //START:
$(document).ready( $(document).ready(
function() { function () {
//set sizes //set sizes
$("#parent_name").attr("size", "70"); $("#parent_name").attr("size", "70");
$("#parent_name_copy").attr("size", "70"); $("#parent_name_copy").attr("size", "70");
@@ -8,24 +8,24 @@ $(document).ready(
$("#payment_date_days").css("width", "40"); $("#payment_date_days").css("width", "40");
//$("#payment_method").css("width", "100"); //$("#payment_method").css("width", "100");
//change parent select button //change parent select button
$("#btn_clr_parent_name").children().attr("src","themes/default/images/id-ff-add.png" ); $("#btn_clr_parent_name").children().attr("src", "themes/default/images/id-ff-add.png");
$("#btn_clr_parent_name").attr("title","Dodaj" ); $("#btn_clr_parent_name").attr("title", "Dodaj");
$("#btn_clr_parent_name").click(createAccount); $("#btn_clr_parent_name").click(createAccount);
// confirm exit // confirm exit
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());
}); });
var previousVal; var previousVal;
var pollInterval = setInterval(function() { var pollInterval = setInterval(function () {
var val = $('#parent_id').val(); var val = $('#parent_id').val();
if (val !== previousVal) { if (val !== previousVal) {
if ($('#parent_id').val() == '') return; if ($('#parent_id').val() == '') return;
$(".loading_panel").css("display", "block"); $(".loading_panel").css("display", "block");
setTimeout(function() { setTimeout(function () {
getParentInfo($("#parent_id").val(), 'Accounts'); getParentInfo($("#parent_id").val(), 'Accounts');
}, 1000); }, 1000);
} }
@@ -33,13 +33,13 @@ $(document).ready(
}, 500); }, 500);
//newProduct //newProduct
var previousVal2; var previousVal2;
var prodInterval = setInterval(function() { var prodInterval = setInterval(function () {
var val = $('#newProductId').val(); var val = $('#newProductId').val();
if (val !== previousVal2) { if (val !== previousVal2) {
if ($('#newProductId').val() == '') return; if ($('#newProductId').val() == '') return;
$(".loading_panel").css("display", "block"); $(".loading_panel").css("display", "block");
setTimeout(function() { setTimeout(function () {
AddProduct(items.length-1, val); AddProduct(items.length - 1, val);
}, 500); }, 500);
} }
previousVal2 = val; previousVal2 = val;
@@ -50,7 +50,7 @@ $(document).ready(
manageOO(); manageOO();
var count = $('#' + itemsTable + '_T tr').length - 1; // -1 - var count = $('#' + itemsTable + '_T tr').length - 1; // -1 -
// thead row // thead row
for (var index = 0; index != count; index++){ for (var index = 0; index != count; index++) {
calculateRow(index); calculateRow(index);
} }
@@ -59,7 +59,7 @@ $(document).ready(
getCategoriesList(); getCategoriesList();
// its vat free change // its vat free change
$("#no_tax").change(function() { $("#no_tax").change(function () {
// calculate totals // calculate totals
var count = $('#' + itemsTable + '_T tr').length - 1; // -1 - var count = $('#' + itemsTable + '_T tr').length - 1; // -1 -
// thead row // thead row
@@ -67,21 +67,21 @@ $(document).ready(
calculateRow(index); calculateRow(index);
}); });
// language channge // language channge
$("#ecmlanguage").change(function() { $("#ecmlanguage").change(function () {
changeLanguage(); changeLanguage();
}); });
removeFromValidate('EditView', 'shipping_iln'); removeFromValidate('EditView', 'shipping_iln');
DrawHeaders(); DrawHeaders();
// stock selector // stock selector
$("#stock").change(function() { $("#stock").change(function () {
$("#stock_id").val(($("#stock :selected").val())); $("#stock_id").val(($("#stock :selected").val()));
}); });
if($("#type :selected").val()=='sales_order'){ if ($("#type :selected").val() == 'sales_order') {
removeFromValidate('EditView', 'invoice_date'); removeFromValidate('EditView', 'invoice_date');
} }
$("#type").change(function() { $("#type").change(function () {
if($("#type :selected").val()=='sales_order'){ if ($("#type :selected").val() == 'sales_order') {
removeFromValidate('EditView', 'invoice_date'); removeFromValidate('EditView', 'invoice_date');
} else { } else {
addToValidate('EditView', 'invoice_date', 'id', 'true', ''); addToValidate('EditView', 'invoice_date', 'id', 'true', '');
@@ -89,15 +89,15 @@ $(document).ready(
}); });
if (($("#new_number").val() == true) if (($("#new_number").val() == true)
&& ($("#duplicate").val() != true) && ($("#ecmquote_id").val() =='')) { && ($("#duplicate").val() != true) && ($("#ecmquote_id").val() == '')) {
EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmSales'); EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmSales');
//sale from subpanel?? //sale from subpanel??
var ecp = $("#ecommerce_products").val(); var ecp = $("#ecommerce_products").val();
if (ecp && ecp.length > 0) { if (ecp && ecp.length > 0) {
loadECommerceProducts(ecp); loadECommerceProducts(ecp);
} else if ($("#parent_id").val()!='') { } else if ($("#parent_id").val() != '') {
$(".loading_panel").css("display", "block"); $(".loading_panel").css("display", "block");
setTimeout(function() { setTimeout(function () {
getParentInfo($("#parent_id").val(), $( getParentInfo($("#parent_id").val(), $(
"#parent_type :selected").val()); "#parent_type :selected").val());
}, 1000); }, 1000);
@@ -125,7 +125,7 @@ $(document).ready(
$(".loading_panel").css("display", "none"); $(".loading_panel").css("display", "none");
} }
// handle setItems // handle setItems
setITEMS = function() { setITEMS = function () {
var formname = 'EditView'; var formname = 'EditView';
if (check_form_(formname) == true) { if (check_form_(formname) == true) {
SetTab('ITEMS'); SetTab('ITEMS');
@@ -134,22 +134,22 @@ $(document).ready(
//payment date functions //payment date functions
$('#payment_date_days').css('height', '18'); $('#payment_date_days').css('height', '18');
$('#payment_date_days').val('0'); $('#payment_date_days').val('0');
$('#payment_date_days').change(function() { $('#payment_date_days').change(function () {
calculatePaymentDate(); calculatePaymentDate();
}); });
// parent info // parent info
var previousVal4; var previousVal4;
var pollInterval4 = setInterval(function() { var pollInterval4 = setInterval(function () {
var val = $('#payment_date').val(); var val = $('#payment_date').val();
if (val !== previousVal4) { if (val !== previousVal4) {
setTimeout(function() { setTimeout(function () {
calculateDateDiff(); calculateDateDiff();
}, 1000); }, 1000);
} }
previousVal4 = val; previousVal4 = val;
}, 1000); }, 1000);
// wyszukiwanie start // wyszukiwanie start
$('#searchProductsInput').keyup(function(e) { $('#searchProductsInput').keyup(function (e) {
if (e.keyCode == 13) { if (e.keyCode == 13) {
// stronicowanie od 1 strony przy zmianie szukanego produktu // stronicowanie od 1 strony przy zmianie szukanego produktu
$('#searchStart').val(0); $('#searchStart').val(0);
@@ -157,17 +157,18 @@ $(document).ready(
} }
}); });
AddSearchRecord(); AddSearchRecord();
calculateDate($("#delivery_date").val());
$(".loading_panel").css("display", "none"); $(".loading_panel").css("display", "none");
}); });
// handle save // handle save
var check_form_ = check_form; var check_form_ = check_form;
check_form = function(formname,event) { check_form = function (formname, event) {
// zapobiega zapisywaniu dokumentu firefox bug, w przypadku nacisniecia enter w polu z autocomplete // zapobiega zapisywaniu dokumentu firefox bug, w przypadku nacisniecia enter w polu z autocomplete
if(event.clientY==0 && event.clientX==0){ if (event.clientY == 0 && event.clientX == 0) {
return false; return false;
} }
window.onbeforeunload = null; window.onbeforeunload = null;
if (items.length == 0 || items[0].product_id=='') { if (items.length == 0 || items[0].product_id == '') {
alert("Brak produktów"); alert("Brak produktów");
return false; return false;
} }
@@ -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 "";
} }
@@ -203,9 +204,9 @@ function confirmExit() {
function lockEnter() { function lockEnter() {
// prevent default // prevent default
$(window).keydown(function(event) { $(window).keydown(function (event) {
if (event.keyCode == 13 && $(":focus").prop('tagName')!='input') { if (event.keyCode == 13 && $(":focus").prop('tagName') != 'input') {
event.preventDefault(); event.preventDefault();
return false; return false;

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 '';