var ajaxsearch_url = 'index.php?module=EcmProducts&action=javahelper&to_pdf=1'; var dialog; var form; var currentPart=0; var group_ks_search = ''; function htmlEscape(str) { return String(str) .replace(/&/g, '&') .replace(/"/g, '"') .replace(/'/g, ''') .replace(//g, '>'); } function showdialog() { $('#searchResultDiv').html(''); $(".loading_panel").css("display", "block"); var url = 'index.php?module=EcmProducts&action=QuickCreate2'; $('#searchResultDiv'). append(''); var iframe = $('#frameid'); iframe.attr('src', url); iframe.load(function () { $(".loading_panel").css("display", "none"); callback(this, iframe); }); } function callback(frame, frame2) { $('#frameid').contents().bind({ submit: function () { $(".loading_panel").css("display", "block"); frame2.load(function () { AddProduct(searchEmpty(), $('#frameid').contents().find("#return_product_id").val()); $('#searchResultDiv').html(''); $(".loading_panel").css("display", "none"); }); } }); } function replaceAll(str, find, replace) { return str.replace(new RegExp(find, 'g'), replace); } function replaceCharters(text){ var res = replaceAll(text,'"', """); var res = replaceAll(res,"'", "'"); return res; } function FillTable(data, allReadOnly) { html = ''; // loop throw data rows var pozycja = 1; var color; $.each( data, function (row_index, row) { html += '
';
html += ' ';
// move down
html += '
';
html += '
';
html += '
';
html += ' ';
}
}else if (cellname == 'price_start_div'
&& !allReadOnly) {
html += '
';
html += '';
}else if (cellname == 'unit_div'
&& !allReadOnly) {
html += '
';
html += '';
}else if (cellname == 'ecmvat_div'
&& !allReadOnly) {
html += '
';
html += '';
} else if (cellname == 'quantity') {
if (cell.label
&& cell.label != '')
html += '' + cell.label + '
'; html += ''; if (row['quantity_used'] != '' && row['quantity_used'] != null) { html += '(' + row['quantity_used'] + ')
'; } }else if (cellname == 'stock_state') { if (cell.label && cell.label != '') html += '' + cell.label + '
'; html += ''; if (row['quantity_used'] != '' && row['quantity_used'] != null) { html += '(' + row['quantity_used'] + ')
'; } } else { if (cell.label && cell.label != '') html += '' + cell.label + '
'; html += ''; } }); html += '
');
setTimeout(function () {
if (searchKey == $('#searchProductsInput').val()) {
var params = {
job: 'searchProducts',
searchKey: searchKey,
searchCategory: $("#productSearchCategory :selected").val(),
searchStock: $("#productSearchStock :selected").val(),
searchStockId: stockid,
searchSort: $("#searchSort").val(),
searchStart: $("#searchStart").val(),
searchCount: $("#searchCount").val(),
groupKs: group_ks_search,
};
$.ajax({
type: "POST",
url: ajaxsearch_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 searchAllProducts() {
var searchKey = '%';
var stockid = module_function == 'EcmStockDocMoves' ? $("#stock_out_id")
.val() : $("#stock_id").val();
$("#searchResultDiv").html(
'
');
setTimeout(function () {
var params = {
job: 'searchProducts',
searchKey: searchKey,
searchCategory: $("#productSearchCategory :selected").val(),
searchStock: $("#productSearchStock :selected").val(),
searchStockId: stockid,
searchSort: $("#searchSort").val(),
};
$.ajax({
type: "POST",
url: ajaxsearch_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 createPaginationTable(data) {
// akcja
if (parseInt($("#searchStart").val()) - 50 >= 0) {
var img = 'start.gif';
var disabled = '';
var onclick = "$('#searchStart').val(0);searchProducts();";
} else {
var img = 'start_off.gif';
var disabled = 'disabled="disabled"';
var onclick = '';
}
// guzik
var firstbutton = '';
if (parseInt($("#searchStart").val()) - 50 >= 0) {
var img = 'previous.gif';
var disabled = '';
var onclick = "$('#searchStart').val(parseInt($('#searchStart').val())-50);searchProducts();";
} else {
var img = 'previous_off.gif';
var disabled = 'disabled="disabled"';
var onclick = '';
}
var prev = '';
if (parseInt($("#searchStart").val()) + 50 < data.count) {
var img = 'next.gif';
var disabled = '';
var onclick = "$('#searchStart').val(parseInt($('#searchStart').val())+50);searchProducts();";
} else {
var img = 'next_off.gif';
var disabled = 'disabled="disabled"';
var onclick = '';
}
var next = '';
if (parseInt($("#searchStart").val()) + 50 < data.count) {
var img = 'end.gif';
var disabled = '';
var last = Math.floor(parseInt(data.count) / 50) * 50;
if (last == data.count)
last = last - 50;
var onclick = "$('#searchStart').val(" + last + ");searchProducts();";
} else {
var img = 'end_off.gif';
var disabled = 'disabled="disabled"';
var onclick = '';
}
var lastbutton = '';
var action = "$('#searchStart').val($('#gotoPage option:selected').val());searchProducts();";
var select = '';
var close = '';
var html = '| Znaleziono ' + data.count + ' produktów | '; var page = 'Strona ' + current_page + ' z ' + total_pages; html += '' + firstbutton + ' ' + prev + ' ' + select + ' ' + next + ' ' + lastbutton + ' ' + page + ' ' + close + ' |
| L.p. | '; // jeśli wyszukujesz z tabelki blokuje zaznaczanie wielu if (single != false) { disabled = ''; } else { disabled = 'disabled="disabled"'; } html += ''; html += ' | Indeks | ';
html += 'Nazwa | ';
if ($("#productSearchStock :selected").val() != '1')
html += 'Stan | '; if (unit_show == true) html += 'J.M. | '; if (extraproductinfo_show == true) html += '  | '; html += '
|---|---|---|---|---|---|---|
| ' + number + ' | '; html += ''; html += ' | ' + value.code + ' | '; html += '' + value.name + ' | '; if ($("#productSearchStock :selected").val() != '1') html += '' + value.stock_state + ' | '; if (unit_show == true) html += '' + value.unit_name + ' | '; if (extraproductinfo_show == true) { html += '';
html += ' ';
html += '';
html += ' | ';
}
html += '
|
|
| ';
var show_purchase_prices = false;
if (show_purchase_prices) {
html += '
| ';
}
html += '