var ajax_url = "index.php?module=EcmInvoiceOuts&action=javahelper&to_pdf=1"; var itemsTable = 'itemsTable'; var items = new Array(); var displayArray = new Array(); var searchedProducts = new Array(); function FillTable(data, allReadOnly) { html = ''; var pozycja=1; var color; // loop throw data rows $ .each( data, function(row_index, row) { html += '
';
html += ' ';
// move down
html += '
';
html += '
';
html += '
';
html += '';
} else {
if (cell.label
&& cell.label != '')
html += '' + cell.label + '
'; html += ''; } }); html += '
');
setTimeout(function() {
var params = {
job : 'searchProducts',
searchKey : searchKey,
searchCategory : $("#productSearchCategory :selected").val(),
searchStock : $("#productSearchStock :selected").val(),
searchSort : $("#productSearchSort :selected").val(),
};
$.ajax({
type : "POST",
url : ajax_url,
dataType : "json",
success : function(data) {
if (data != '-1')
if (data.length == 0)
$('#searchResultDiv').html(
'MOD.LBL_SEARCH_NO_RESULT');
else
createSearchResult(data);
},
data : params
});
}, 1000);
}
function FormatNumber(number, precision) {
var precision = precision || 2;
// make string..
number = number + '';
number = number.replace(',', '.');
// round
number = toFixed(number, precision);
// add 1000 sep
var tmp = number.split(".");
var c = '';
for (var i = tmp[0].length; i != -1; i--) {
c += tmp[0].charAt(i);
if ((tmp[0].length - i) == 0 || i == 0)
continue;
if ((tmp[0].length - i) % 3 == 0)
c += '.';
}
// reverse c
c = c.split("").reverse().join("");
return c + ',' + tmp[1];
}
function UnformatNumber(number) {
// make string..
number = number + '';
// remove 1000 sep
number = number.replace('.', '');
// change ',' to '.'
number = number.replace(',', '.');
return parseFloat(number);
}
// round with precision
function toFixed(value, precision) {
var precision = precision || 0, neg = value < 0, power = Math.pow(10,
precision), value = Math.round(value * power), integral = String((neg ? Math.ceil
: Math.floor)(value / power)), fraction = String((neg ? -value
: value)
% power), padding = new Array(Math.max(precision - fraction.length,
0) + 1).join('0');
return precision ? integral + '.' + padding + fraction : integral;
}
// draw table
function DrawHeaders() {
var html = '';
html += '| ' + column.label + ' | '; }); html += '
| '; html += ' '; html += ' | '; html += '';
html += ' '; html += ' | ';
html += ''; html += ' |
');
setTimeout(function() {
if (searchKey == $('#searchProductsInput').val()) {
var params = {
job : 'searchProducts',
searchKey : searchKey,
searchCategory : $("#productSearchCategory :selected").val(),
searchStock : $("#productSearchStock :selected").val(),
searchSort : $("#productSearchSort :selected").val(),
};
$.ajax({
type : "POST",
url : ajax_url,
dataType : "json",
success : function(data) {
if (data != '-1')
if (data.length == 0)
$('#searchResultDiv').html(
'MOD.LBL_SEARCH_NO_RESULT');
else
createSearchResult(data);
},
data : params
});
}
}, 1000);
}
function createSearchResult(data) {
var html = '|   | '; html += 'Kod | '; html += 'Nazwa | '; if ($("#productSearchStock :selected").val() != '1') html += 'Stan | '; html += '  | '; html += '
|---|---|---|---|---|
| '; html += ' | ' + value.code + ' | '; html += '' + value.name + ' | '; if ($("#productSearchStock :selected").val() != '1') html += '' + value.stock_state + ' | '; html += '';
html += ' ';
html += '';
html += ' | ';
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 = '
|
| ';
var show_purchase_prices = false;
if (show_purchase_prices) {
html+='
| ';
}
html+='