var itemsTable = 'itemsTable'; var items = new Array(); var displayArray = new Array(); var searchedProducts = new Array(); var ajax_url = "index.php?module=EcmStockDocInsideIns&action=javahelper&to_pdf=1"; // draw table function DrawHeaders() { var html = ''; html += '
'; html += ''; html += ''; html += ''; // draw columns headers $.each(columns, function(index, column) { html += ''; }); html += '
' + column.label + '
'; html += '

'; // totals table html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; html += '
'; html += ' '; html += ' '; html += '
'; html += ''; html += '
'; html += '
 
'; // sort? why not! /* * html += 'Sortowanie: '; html += ''; html += ''; $("#result_table").html(html); } function generateNumber() { var params = { job : 'generateNumber', stock: $("#stock_id").val(), date : $("#register_date").val(), }; $.ajax({ type : "POST", url : ajax_url, dataType : "json", success : function(data) { if (data == '-1') { // try loading again generateNumber(); } else { $("#document_no").val(data.document_no); $("#number").val(data.number); $(".loading_panel").css("display", "none"); } }, data : params }); } function getPricesInfo(index) { $("#price_start_div_" + index).show('slow'); $("#price_start_div_" + index).html( ''); var params = { job : 'getPricesInfo', product_id : $("#product_id_" + index).val(), pricebook_id : $("#pricebook_id :selected").val(), account_id : $("#parent_id").val(), }; $ .ajax({ type : "POST", url : ajax_url, dataType : "json", async : false, success : function(data) { html = ''; }, data : params }); $("#price_start_div_" + index).html(html); } function getCategoriesList() { var params = { job : 'getCategoriesList' }; $.ajax({ type : "POST", url : ajax_url, dataType : "json", success : function(data) { var html = ''; $.each(data, function(index, value) { html += ''; $("#productSearchCategory").html(html); }); }, data : params }); } function refreshStock(index) { var params = { job : 'getStockState', id : $("#product_id_" + index).val(), stockId : $("#stock_id").val(), }; $.ajax({ type : "POST", url : ajax_url, dataType : "json", async : false, success : function(data) { $("#stock_state_" + index).val(FormatNumber(data,$("#product_precision_" + index).val())); }, data : params }); } function checkProducts() { var count = $('#' + itemsTable + '_T tr').length - 1; // -1 - thead row var error = false; // hope :) var total_netto=0; for (var index = 0; index != count; index++) { if($("#product_id_" + index).val()!=''){ var qty = UnformatNumber($("#quantity_" + index).val()); var cat_id = $("#product_category_id_" + index).val(); // refresh items array items[index].quantity = qty; items[index].price = UnformatNumber($("#price_" + index).val()); items[index].total=items[index].quantity*items[index].price; $("#total_" + index).val(FormatNumber(items[index].total,2)); total_netto+=items[index].total; var stock = UnformatNumber($("#stock_state_" + index).val()); if(!(qty>0)){ error=true; $("#quantity_" + index).css("color", "red"); } else $("#quantity_" + index).css("color", "black"); } } $("#total_netto").val(total_netto); DrawDetailSummary(); if (error) return false; else return true; } function getComponents(index) { $(".loading_panel").css("display", "block"); var product_id = items[index].product_id; var qty = items[index].quantity; //var price = items[index].price; var params = { job : 'getComponents', product_id : product_id, }; $.ajax({ type : "POST", url : ajax_url, dataType : "json", async : false, success : function(data) { if (data.length > 0) { items.splice(index, 1); $.each(data, function(index, value) { var p = new Object(); p.product_id = value.id; p.name = value.name; p.product_code = value.code; p.price = value.price; p.unit_name = value.unit_name; p.unit_id = value.unit_id; p.quantity = qty * parseInt(value.quantity); p.product_category_id = value.product_category_id; if (p.product_category_id=='d7f876b0-1a3d-43a1-7c9b-511ba40df3d1') return; items.push(p); }); }; }, data : params }); FillTable(items); $(".loading_panel").css("display", "none"); } function getSearchInfo2(product_id, product_code) { $("#search_info_div2_" + product_id).show().draggable(); var html = ''; html += '' + product_code + '

'; html +=''; var params = { job : 'getStockArray', product_id : product_id, }; $.ajax({ type : "POST", url : ajax_url, dataType : "json", async : false, success : function(data) { $.each(data, function(key, value) { html += ''; }); }, data : params }); html += '
MagazynIlość
'+key + '' + FormatNumber(value) + '
'; $("#search_info_div2_" + product_id).html(html); } /* function getSearchInfo(product_id, product_code) { $("#search_info_div_" + product_id).show().draggable(); var html = ''; html += '' + product_code + '

'; // get prices info html +=''; var params = { job : 'getPricesInfo', product_id : product_id, pricebook_id : $("#pricebook_id :selected").val(), account_id : $("#parent_id").val(), }; $.ajax({ type : "POST", url : ajax_url, dataType : "json", async : false, success : function(data) { $.each(data, function(key, value) { if (value.name == 'pricebook') html += $("#pricebook_id :selected").html() + ': ' + FormatNumber(value.price) + '
'; if (value.name == $("#ecmprice_name").val()) html += '' + value.name + ': ' + FormatNumber(value.price) + '
'; else if(value.module=='EcmStockDocIns'){ html+=''; } //html += value.name + ': ' + FormatNumber(value.price) // + '
'; }); }, data : params }); html+='
NazwaIlośćCenaData dok
'+value.name + ''+value.quantity+' '+FormatNumber(value.price)+''+value.register_date+'
'; $("#search_info_div_" + product_id).html(html); } */ function getSearchInfo3(product_id, product_code) { $("#search_info_div3_" + product_id).show().draggable(); var html = ''; html += '' + product_code + '

'; // get prices info html +=''; var params = { job : 'getPricesInfo', product_id : product_id, pricebook_id : $("#pricebook_id :selected").val(), account_id : $("#parent_id").val(), }; $.ajax({ type : "POST", url : ajax_url, dataType : "json", async : false, success : function(data) { $.each(data, function(key, value) { if (value.name == 'pricebook') html += $("#pricebook_id :selected").html() + ': ' + FormatNumber(value.price) + '
'; if (value.name == $("#ecmprice_name").val()) html += '' + value.name + ': ' + FormatNumber(value.price) + '
'; else if(value.module=='EcmPrices'){ html+=''; } if(value.module=='EcmInvoiceOuts'){ html+=''; } //html += value.name + ': ' + FormatNumber(value.price) // + '
'; }); }, data : params }); html+='
NazwaCena
'+value.name + ': '+FormatNumber(value.price)+'
'+value.name + ': '+FormatNumber(value.price)+'
'; $("#search_info_div3_" + product_id).html(html); } function createProduct() { var newProdId = document.getElementById("newProductId"); newProduct = window.open('index.php?module=EcmProducts&action=EditView&IamPopup=1', 'newProduct', 'toolbar=no,menubar=no,scrollbars=yes,scrollbars=1'); newProduct.newProdId = newProdId; newProduct.focus(); } // sortable rows in main table $("#" + itemsTable + " tbody").sortable();