//START: $(document).ready( function() { //set sizes $("#parent_name").attr("size", "70"); $("#parent_name_copy").attr("size", "70"); $("#parent_shipping_address_name").attr("size", "70"); $("#payment_date_days").css("width", "40"); //$("#payment_method").css("width", "100"); //change parent select button $("#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").click(createAccount); // confirm exit window.onbeforeunload = confirmExit; // prevent submit by enter press lockEnter(); // parent info 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 getCategoriesList(); // its vat free change // language channge DrawHeaders(); // stock selector if (($("#new_number").val() == true) && ($("#duplicate").val() != true) && ($("#ecmsale_id").val() =='')) { console.log('tu?'); EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmPrepaymentInvoices'); //sale from subpanel?? if ($("#parent_id").val()!='') { $(".loading_panel").css("display", "block"); setTimeout(function() { getParentInfo($("#parent_id").val(), $( "#parent_type :selected").val()); }, 1000); } $(".loading_panel").css("display", "none"); } else if (($("#new_number").val() == true) && ($("#duplicate").val() == true)) { console.log('tam?'); EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmPrepaymentInvoices'); getParentInfo($("#parent_id").val(), $("#parent_type :selected").val()); getItems(); $(".loading_panel").css("display", "none"); } else if (($("#new_number").val() == true) && ($("#ecmsale_id").val() != '')) { EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmPrepaymentInvoices'); getParentInfo($("#parent_id").val(), 'Accounts'); getItemsFromSale(); calculateVat(); $(".loading_panel").css("display", "none"); } else { getParentInfo($("#parent_id").val(), $("#parent_type :selected").val()); getItems(); EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmPrepaymentInvoices'); console.log('t'); $(".loading_panel").css("display", "none"); } // handle setItems setITEMS = function() { var formname = 'EditView'; if (check_form_(formname) == true) { SetTab('ITEMS'); } }; $("#currency_id").change(function() { if ($('#currency_id').val() != 'PLN') { $('#curr_trigger').show(); getNBPCurrencyExchange($("#currency_id :selected").val()); } else { $('#curr_trigger').hide(); $('#currency_value_nbp').val(""); $('#currency_table_tmp').val(""); $('#currency_table').val(""); } }); var previousVal3; var prodInterval = setInterval(function() { var val = $('#register_date').val(); if (val !== previousVal3) { if ($("#currency_id :selected").val() != 'PLN') getNBPCurrencyExchange($("#currency_id :selected").val()); } previousVal3 = val; }, 500); // parent info // wyszukiwanie start $('#searchProductsInput').keyup(function() { // stronicowanie od 1 strony przy zmianie szukanego produktu $('#searchStart').val(0); searchProducts(); }); AddSearchRecord(); $(".loading_panel").css("display", "none"); }); // handle save var check_form_ = check_form; check_form = function(formname,event) { // zapobiega zapisywaniu dokumentu firefox bug, w przypadku nacisniecia enter w polu z autocomplete if(event.clientY==0 && event.clientX==0){ return false; } window.onbeforeunload = null; if (items.length == 0 || items[0].product_id=='') { alert("Brak produktów"); return false; } // usuwa rekord pomocniczy clearEmpty(); $(".loading_panel").css("display", "block"); // calculate totals var count = $('#' + itemsTable + '_T tr').length - 1; // -1 - thead row for (var index = 0; index != count; index++) { calculateRow(index); if (validation.recipient_code == true) console.log('Sprawdzić kody trzeba'); } if (check_form_(formname) == false) { window.onbeforeunload = confirmExit; $(".loading_panel").css("display", "none"); return false; } else { $("#total_netto").val($("#t_netto").val()); $("#total_brutto").val($("#t_brutto").val()); $("#discount").val($("#disc").val()); $("#position_list").val(JSON.stringifyNoSecurity(items)); return true; } }; function confirmExit() { return ""; } function lockEnter() { // prevent default $(window).keydown(function(event) { if (event.keyCode == 13 && $(":focus").prop('tagName')!='input') { event.preventDefault(); return false; } }); }