//START: $(document).ready( function() { // confirm exit window.onbeforeunload = confirmExit; // prevent submit by enter press lockEnter(); // parent info $("#parent_name").change( function() { $(".loading_panel").css("display", "block"); setTimeout(function() { getParentInfo($("#parent_id").val(), $( "#parent_type :selected").val()); }, 1000); }); // categories getCategoriesList(); // its vat free change $("#no_tax").change(function() { // calculate totals var count = $('#' + itemsTable + '_T tr').length - 1; // -1 - // thead row for (var index = 0; index != count; index++) calculateRow(index); }); // searchProductInput change $('#searchProductsInput').keyup(function() { searchProducts(); }); DrawHeaders(); if (($("#new_number").val() == true) && ($("#duplicate").val() != true)) { generateNumber(); console.log($("#parent_id").val()); if ($("#parent_id").val()!='') getParentInfo($("#parent_id").val(),'Accounts'); } else if (($("#new_number").val() == true) && ($("#duplicate").val() == true)) { generateNumber(); getParentInfo($("#parent_id").val(), 'Accounts'); getItems(); } else { getParentInfo($("#parent_id").val(), 'Accounts'); getItems(); } // handle setItems setITEMS = function() { var formname = 'EditView'; if (check_form_(formname) == true) { SetTab('ITEMS'); } }; }); // handle save var check_form_ = check_form; check_form = function(formname) { window.onbeforeunload = null; if (items.length == 0) { alert("Brak produktów"); return false; } $(".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); $("#total_netto").val($("#t_netto").val()); $("#total_brutto").val($("#t_brutto").val()); $("#discount").val($("#disc").val()); $("#position_list").val(JSON.stringifyNoSecurity(items)); if (check_form_(formname) == false) { window.onbeforeunload = confirmExit; $(".loading_panel").css("display", "none"); return false; } else { return true; } }; function confirmExit() { return ""; } function lockEnter() { // prevent default $(window).keydown(function(event) { if (event.keyCode == 13 && $(":focus").prop('tagName')!='TEXTAREA') { event.preventDefault(); return false; } }); }