calculate delivery date fix
This commit is contained in:
@@ -1,216 +1,217 @@
|
|||||||
//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");
|
||||||
$("#parent_shipping_address_name").attr("size", "70");
|
$("#parent_shipping_address_name").attr("size", "70");
|
||||||
$("#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() {
|
|
||||||
calculateDate($("#delivery_date").val());
|
|
||||||
});
|
|
||||||
var previousVal;
|
|
||||||
var pollInterval = setInterval(function() {
|
|
||||||
var val = $('#parent_id').val();
|
|
||||||
if (val !== previousVal) {
|
|
||||||
if ($('#parent_id').val() == '') return;
|
|
||||||
$(".loading_panel").css("display", "block");
|
|
||||||
setTimeout(function() {
|
|
||||||
getParentInfo($("#parent_id").val(), 'Accounts');
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
previousVal = val;
|
|
||||||
}, 500);
|
|
||||||
//newProduct
|
|
||||||
var previousVal2;
|
|
||||||
var prodInterval = setInterval(function() {
|
|
||||||
var val = $('#newProductId').val();
|
|
||||||
if (val !== previousVal2) {
|
|
||||||
if ($('#newProductId').val() == '') return;
|
|
||||||
$(".loading_panel").css("display", "block");
|
|
||||||
setTimeout(function() {
|
|
||||||
AddProduct(items.length-1, val);
|
|
||||||
}, 500);
|
|
||||||
}
|
|
||||||
previousVal2 = val;
|
|
||||||
}, 500);
|
|
||||||
// categories
|
|
||||||
|
|
||||||
$('#pdf_type').change(function () {
|
$("#delivery_date").on('inputchange', function () {
|
||||||
manageOO();
|
calculateDate($("#delivery_date").val());
|
||||||
var count = $('#' + itemsTable + '_T tr').length - 1; // -1 -
|
});
|
||||||
// thead row
|
var previousVal;
|
||||||
for (var index = 0; index != count; index++){
|
var pollInterval = setInterval(function () {
|
||||||
calculateRow(index);
|
var val = $('#parent_id').val();
|
||||||
|
if (val !== previousVal) {
|
||||||
|
if ($('#parent_id').val() == '') return;
|
||||||
|
$(".loading_panel").css("display", "block");
|
||||||
|
setTimeout(function () {
|
||||||
|
getParentInfo($("#parent_id").val(), 'Accounts');
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
previousVal = val;
|
||||||
|
}, 500);
|
||||||
|
//newProduct
|
||||||
|
var previousVal2;
|
||||||
|
var prodInterval = setInterval(function () {
|
||||||
|
var val = $('#newProductId').val();
|
||||||
|
if (val !== previousVal2) {
|
||||||
|
if ($('#newProductId').val() == '') return;
|
||||||
|
$(".loading_panel").css("display", "block");
|
||||||
|
setTimeout(function () {
|
||||||
|
AddProduct(items.length - 1, val);
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
previousVal2 = val;
|
||||||
|
}, 500);
|
||||||
|
// categories
|
||||||
|
|
||||||
}
|
$('#pdf_type').change(function () {
|
||||||
calculateTotal();
|
manageOO();
|
||||||
});
|
var count = $('#' + itemsTable + '_T tr').length - 1; // -1 -
|
||||||
|
// thead row
|
||||||
|
for (var index = 0; index != count; index++) {
|
||||||
|
calculateRow(index);
|
||||||
|
|
||||||
getCategoriesList();
|
}
|
||||||
// its vat free change
|
calculateTotal();
|
||||||
$("#no_tax").change(function() {
|
});
|
||||||
// calculate totals
|
|
||||||
var count = $('#' + itemsTable + '_T tr').length - 1; // -1 -
|
getCategoriesList();
|
||||||
// thead row
|
// its vat free change
|
||||||
for (var index = 0; index != count; index++)
|
$("#no_tax").change(function () {
|
||||||
calculateRow(index);
|
// calculate totals
|
||||||
});
|
var count = $('#' + itemsTable + '_T tr').length - 1; // -1 -
|
||||||
// language channge
|
// thead row
|
||||||
$("#ecmlanguage").change(function() {
|
for (var index = 0; index != count; index++)
|
||||||
changeLanguage();
|
calculateRow(index);
|
||||||
});
|
});
|
||||||
removeFromValidate('EditView', 'shipping_iln');
|
// language channge
|
||||||
DrawHeaders();
|
$("#ecmlanguage").change(function () {
|
||||||
// stock selector
|
changeLanguage();
|
||||||
$("#stock").change(function() {
|
});
|
||||||
$("#stock_id").val(($("#stock :selected").val()));
|
removeFromValidate('EditView', 'shipping_iln');
|
||||||
|
DrawHeaders();
|
||||||
});
|
// stock selector
|
||||||
if($("#type :selected").val()=='sales_order'){
|
$("#stock").change(function () {
|
||||||
removeFromValidate('EditView', 'invoice_date');
|
$("#stock_id").val(($("#stock :selected").val()));
|
||||||
}
|
|
||||||
$("#type").change(function() {
|
});
|
||||||
if($("#type :selected").val()=='sales_order'){
|
if ($("#type :selected").val() == 'sales_order') {
|
||||||
removeFromValidate('EditView', 'invoice_date');
|
removeFromValidate('EditView', 'invoice_date');
|
||||||
} else {
|
}
|
||||||
addToValidate('EditView', 'invoice_date', 'id', 'true', '');
|
$("#type").change(function () {
|
||||||
}
|
if ($("#type :selected").val() == 'sales_order') {
|
||||||
|
removeFromValidate('EditView', 'invoice_date');
|
||||||
});
|
} else {
|
||||||
if (($("#new_number").val() == true)
|
addToValidate('EditView', 'invoice_date', 'id', 'true', '');
|
||||||
&& ($("#duplicate").val() != true) && ($("#ecmquote_id").val() =='')) {
|
}
|
||||||
EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmSales');
|
|
||||||
//sale from subpanel??
|
});
|
||||||
var ecp = $("#ecommerce_products").val();
|
if (($("#new_number").val() == true)
|
||||||
if (ecp && ecp.length > 0) {
|
&& ($("#duplicate").val() != true) && ($("#ecmquote_id").val() == '')) {
|
||||||
loadECommerceProducts(ecp);
|
EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmSales');
|
||||||
} else if ($("#parent_id").val()!='') {
|
//sale from subpanel??
|
||||||
$(".loading_panel").css("display", "block");
|
var ecp = $("#ecommerce_products").val();
|
||||||
setTimeout(function() {
|
if (ecp && ecp.length > 0) {
|
||||||
getParentInfo($("#parent_id").val(), $(
|
loadECommerceProducts(ecp);
|
||||||
"#parent_type :selected").val());
|
} else if ($("#parent_id").val() != '') {
|
||||||
}, 1000);
|
$(".loading_panel").css("display", "block");
|
||||||
}
|
setTimeout(function () {
|
||||||
$(".loading_panel").css("display", "none");
|
getParentInfo($("#parent_id").val(), $(
|
||||||
} else if (($("#new_number").val() == true)
|
"#parent_type :selected").val());
|
||||||
&& ($("#duplicate").val() == true)) {
|
}, 1000);
|
||||||
EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmSales');
|
}
|
||||||
getParentInfo($("#parent_id").val(),
|
$(".loading_panel").css("display", "none");
|
||||||
$("#parent_type :selected").val());
|
} else if (($("#new_number").val() == true)
|
||||||
getItems();
|
&& ($("#duplicate").val() == true)) {
|
||||||
$(".loading_panel").css("display", "none");
|
EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmSales');
|
||||||
} else if (($("#new_number").val() == true)
|
getParentInfo($("#parent_id").val(),
|
||||||
&& ($("#ecmquote_id").val() != '')) {
|
$("#parent_type :selected").val());
|
||||||
|
getItems();
|
||||||
EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmSales');
|
$(".loading_panel").css("display", "none");
|
||||||
getParentInfo($("#parent_id").val(),
|
} else if (($("#new_number").val() == true)
|
||||||
'Accounts');
|
&& ($("#ecmquote_id").val() != '')) {
|
||||||
getItemsFromSale();
|
|
||||||
$(".loading_panel").css("display", "none");
|
EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmSales');
|
||||||
} else {
|
getParentInfo($("#parent_id").val(),
|
||||||
getParentInfo($("#parent_id").val(),
|
'Accounts');
|
||||||
$("#parent_type :selected").val());
|
getItemsFromSale();
|
||||||
getItems();
|
$(".loading_panel").css("display", "none");
|
||||||
$(".loading_panel").css("display", "none");
|
} else {
|
||||||
}
|
getParentInfo($("#parent_id").val(),
|
||||||
// handle setItems
|
$("#parent_type :selected").val());
|
||||||
setITEMS = function() {
|
getItems();
|
||||||
var formname = 'EditView';
|
$(".loading_panel").css("display", "none");
|
||||||
if (check_form_(formname) == true) {
|
}
|
||||||
SetTab('ITEMS');
|
// handle setItems
|
||||||
}
|
setITEMS = function () {
|
||||||
};
|
var formname = 'EditView';
|
||||||
//payment date functions
|
if (check_form_(formname) == true) {
|
||||||
$('#payment_date_days').css('height', '18');
|
SetTab('ITEMS');
|
||||||
$('#payment_date_days').val('0');
|
}
|
||||||
$('#payment_date_days').change(function() {
|
};
|
||||||
calculatePaymentDate();
|
//payment date functions
|
||||||
});
|
$('#payment_date_days').css('height', '18');
|
||||||
// parent info
|
$('#payment_date_days').val('0');
|
||||||
var previousVal4;
|
$('#payment_date_days').change(function () {
|
||||||
var pollInterval4 = setInterval(function() {
|
calculatePaymentDate();
|
||||||
var val = $('#payment_date').val();
|
});
|
||||||
if (val !== previousVal4) {
|
// parent info
|
||||||
setTimeout(function() {
|
var previousVal4;
|
||||||
calculateDateDiff();
|
var pollInterval4 = setInterval(function () {
|
||||||
}, 1000);
|
var val = $('#payment_date').val();
|
||||||
}
|
if (val !== previousVal4) {
|
||||||
previousVal4 = val;
|
setTimeout(function () {
|
||||||
}, 1000);
|
calculateDateDiff();
|
||||||
// wyszukiwanie start
|
}, 1000);
|
||||||
$('#searchProductsInput').keyup(function(e) {
|
}
|
||||||
if (e.keyCode == 13) {
|
previousVal4 = val;
|
||||||
// stronicowanie od 1 strony przy zmianie szukanego produktu
|
}, 1000);
|
||||||
$('#searchStart').val(0);
|
// wyszukiwanie start
|
||||||
searchProducts();
|
$('#searchProductsInput').keyup(function (e) {
|
||||||
}
|
if (e.keyCode == 13) {
|
||||||
});
|
// stronicowanie od 1 strony przy zmianie szukanego produktu
|
||||||
AddSearchRecord();
|
$('#searchStart').val(0);
|
||||||
$(".loading_panel").css("display", "none");
|
searchProducts();
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
AddSearchRecord();
|
||||||
|
calculateDate($("#delivery_date").val());
|
||||||
|
$(".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;
|
||||||
}
|
}
|
||||||
// usuwa rekord pomocniczy
|
// usuwa rekord pomocniczy
|
||||||
clearEmpty();
|
clearEmpty();
|
||||||
$(".loading_panel").css("display", "block");
|
$(".loading_panel").css("display", "block");
|
||||||
// calculate totals
|
// calculate totals
|
||||||
var count = $('#' + itemsTable + '_T tr').length - 1; // -1 - thead row
|
var count = $('#' + itemsTable + '_T tr').length - 1; // -1 - thead row
|
||||||
for (var index = 0; index != count; index++) {
|
for (var index = 0; index != count; index++) {
|
||||||
calculateRow(index);
|
calculateRow(index);
|
||||||
if (validation.recipient_code == true)
|
if (validation.recipient_code == true)
|
||||||
console.log('Sprawdzić kody trzeba');
|
console.log('Sprawdzić kody trzeba');
|
||||||
}
|
}
|
||||||
$("#total_netto").val($("#t_netto").val());
|
$("#total_netto").val($("#t_netto").val());
|
||||||
$("#total_brutto").val($("#t_brutto").val());
|
$("#total_brutto").val($("#t_brutto").val());
|
||||||
$("#discount").val($("#disc").val());
|
$("#discount").val($("#disc").val());
|
||||||
$("#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 {
|
window.onbeforeunload = confirmExit;
|
||||||
window.onbeforeunload = confirmExit;
|
$(".loading_panel").css("display", "none");
|
||||||
$(".loading_panel").css("display", "none");
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function confirmExit() {
|
function confirmExit() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadECommerceProducts(ecp) {
|
function loadECommerceProducts(ecp) {
|
||||||
|
|||||||
@@ -24,6 +24,13 @@ 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']=$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");
|
||||||
echo json_encode($tmp);
|
echo json_encode($tmp);
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user