Add JS files
This commit is contained in:
258
modules/EcmStockDocIns/javascript/Consignments.js
Executable file
258
modules/EcmStockDocIns/javascript/Consignments.js
Executable file
@@ -0,0 +1,258 @@
|
||||
var checkProductIsConsignment = function() {
|
||||
var count = $('#' + itemsTable + '_T tr').length - 1; // -1 - thead row
|
||||
for (var index = 0; index != count; index++) {
|
||||
if ($('#product_is_consignment_' + index).val() == '1') {
|
||||
var f = $('#quantity_' + index).attr('onchange');
|
||||
f += 'showConsignmentsOptions(\'' + index + '\');';
|
||||
$('#quantity_' + index).attr('onchange', f);
|
||||
var f2 = $('#quantity_' + index).attr('onchange');
|
||||
getInsertConsignmentsDiv(index);
|
||||
}
|
||||
}
|
||||
$('#quantity_' + (count - 2)).focus();
|
||||
$('#quantity_' + (count - 2)).select();
|
||||
addRowClickHandler();
|
||||
}
|
||||
|
||||
function addRowClickHandler() {
|
||||
$('#itemsTable').find('tr').click(function() {
|
||||
var count = $('#' + itemsTable + '_T tr').length - 1;
|
||||
for (var index = 0; index != count; index++) {
|
||||
if ($('#product_is_consignment_' + index).val() != '1')
|
||||
continue;
|
||||
var qty = UnformatNumber($('#quantity_' + index).val());
|
||||
var div_size = $('#consignments_div_' + index).size();
|
||||
// if (index == $(this).index() && div_size>0) continue;
|
||||
if (index == $(this).index() && qty > 0 && div_size == 0) {
|
||||
getInsertConsignmentsDiv(index);
|
||||
} else if (index != $(this).index() && qty > 0)
|
||||
$('#consignments_div_' + index).hide('slow', function() {
|
||||
$(this).remove();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var showConsignmentsOptions = function(index) {
|
||||
checkConsignments(index);
|
||||
getInsertConsignmentsDiv(index);
|
||||
}
|
||||
|
||||
var getInsertConsignmentsDiv = function(index) {
|
||||
$('#consignments_div_' + index).remove(); // panel exists
|
||||
var part = '';
|
||||
|
||||
if (items[index].product_consignment_part!='')
|
||||
part = items[index].product_consignment_part;
|
||||
var container = $('#itemsTable_T > tbody').find('#name_' + index).parent()
|
||||
.parent();
|
||||
var div = $('<div></div>');
|
||||
div.attr('id', 'consignments_div_' + index);
|
||||
div.attr('name', 'consignments_div_' + index);
|
||||
div.css('float', 'left');
|
||||
div.css('text-align', 'left');
|
||||
div.css('border', '1px solid rgb(204,204,204)');
|
||||
div.css('padding', '3px');
|
||||
div.css('display', 'none');
|
||||
div.css('width', '90%');
|
||||
input = $('<input></input>');
|
||||
input.attr('id', 'consignment_part_no');
|
||||
input.keyup(function(event) {
|
||||
var t = $(event.target);
|
||||
$('#product_consignment_part_' + index).val(t.val());
|
||||
items[index].product_consignment_part = t.val();
|
||||
});
|
||||
|
||||
input.css('width', '90%');
|
||||
|
||||
input.val(part);
|
||||
div.append('Nr parti: ');
|
||||
div.append(input);
|
||||
container.append(div);
|
||||
div.show('slow');
|
||||
//input.focus();
|
||||
if($('#product_consignment_part_' + index).val()=='')getPartNumber(index);
|
||||
}
|
||||
|
||||
var checkConsignments = function(index) {
|
||||
var qty = UnformatNumber($('#quantity_' + index).val());
|
||||
if (qty<0 && Math.abs(qty)>items[index].product_consignment_qty) {
|
||||
items[index].product_consignment_part='';
|
||||
items[index].product_consignment_id='';
|
||||
items[index].product_consignment_qty='';
|
||||
$('#product_consignment_part'+index).val('');
|
||||
$('#product_consignment_id'+index).val('');
|
||||
}
|
||||
}
|
||||
|
||||
var getConsignmentsDiv = function(index) {
|
||||
$('#consignments_div_' + index).remove(); // panel exists
|
||||
var prod_id = $('#itemsTable_T > tbody').find('#product_id_' + index).val();
|
||||
if (!prod_id || prod_id == "")
|
||||
return; // empty row
|
||||
var gcd = '#product_consignment_part_' + index;
|
||||
var gci = '#product_consignment_id_' + index;
|
||||
var container = $('#itemsTable_T > tbody').find('#name_' + index).parent()
|
||||
.parent();
|
||||
// if (handler.prev().attr('name') != 'vsbr') handler.before('<br
|
||||
// name="vsbr">'); //VerySpecialBR - first with name :)
|
||||
var qty = UnformatNumber($('#itemsTable_T > tbody').find(
|
||||
'#quantity_' + index).val());
|
||||
var div = $('<div></div>');
|
||||
div.attr('id', 'consignments_div_' + index);
|
||||
div.attr('name', 'consignments_div_' + index);
|
||||
div.css('float', 'left');
|
||||
div.css('text-align', 'left');
|
||||
div.css('border', '1px solid rgb(204,204,204)');
|
||||
div.css('padding', '3px');
|
||||
div.css('display', 'none');
|
||||
div.css('width', '90%');
|
||||
var qty = UnformatNumber($('#itemsTable_T > tbody').find(
|
||||
'#quantity_' + index).val());
|
||||
var prod_id = $('#itemsTable_T > tbody').find('#product_id_' + index).val();
|
||||
div.append('<table></table>');
|
||||
container.append(div);
|
||||
if (items[index].product_is_consignment == '1')
|
||||
div.append(getConsignments(prod_id, qty, $("#stock_id").val(), index));
|
||||
else
|
||||
div.append(getDocuments(prod_id, qty, $("#stock_id").val(), index));
|
||||
}
|
||||
var getDocuments = function(prod_id, qty, stock_id, index) {
|
||||
// AJAX call
|
||||
var a = jQuery
|
||||
.ajax({
|
||||
type : 'POST',
|
||||
url : 'index.php?module=EcmStockDocCorrects&action=javahelper&to_pdf=1',
|
||||
data : {
|
||||
job : 'getConsignmentsDocs',
|
||||
prod_id : prod_id,
|
||||
stock_id : stock_id
|
||||
},
|
||||
dataType : 'json',
|
||||
async : false,
|
||||
});
|
||||
var consignments = $.parseJSON(a.responseText);
|
||||
var last = consignments.length - 1;
|
||||
var container = $('<table></table>');
|
||||
container.css('width', '100%');
|
||||
$.each(consignments, function(i, c) {
|
||||
var p = $('<p></p>');
|
||||
var tr = $('<tr></tr>');
|
||||
tr.css('width', '100%');
|
||||
var a = $('<a></a>');
|
||||
a.html(c.part_no);
|
||||
a.attr('index', index);
|
||||
if (c.availability >= Math.abs(qty)) {
|
||||
a.click(function(event) {
|
||||
var t = $(event.target);
|
||||
var index = t.attr('index');
|
||||
$('#product_consignment_id_' + index).val(c.operation_id)
|
||||
$('#product_consignment_part_' + index).val(c.part_no);
|
||||
$('#price_'+index).val(FormatNumber(c.price));
|
||||
//insert max qty
|
||||
$('#quantity_'+index).parent().append('<p style="text-align: right;" id="max_quantity_'+index+'">(Max: '+FormatNumber(c.availability*-1,0)+')</p>');
|
||||
$('#quantity_'+index).focus();
|
||||
items[index].product_consignment_id = c.operation_id;
|
||||
items[index].product_consignment_part = c.part_no;
|
||||
items[index].product_consignment_qty = c.availability;
|
||||
calculateRow(index);
|
||||
var div = $('#consignments_div_' + index);
|
||||
div.hide('slow');
|
||||
});
|
||||
a.css('cursor', 'pointer');
|
||||
a.css('color', 'blue');
|
||||
} else
|
||||
a.css('color', 'red');
|
||||
var td = $('<td></td>');
|
||||
td.append(a);
|
||||
tr.append(td);
|
||||
var td = $('<td></td>');
|
||||
td.append(FormatNumber(c.availability) + ' ' + c.unit);
|
||||
tr.append(td);
|
||||
var td = $('<td></td>');
|
||||
td.append(FormatNumber(c.price) + ' ' + c.currency + ' / ' + c.unit);
|
||||
tr.append(td);
|
||||
container.append(tr);
|
||||
});
|
||||
// show div
|
||||
$('#consignments_div_' + index).show('slow');
|
||||
return container;
|
||||
}
|
||||
|
||||
var getConsignments = function(prod_id, qty, stock_id, index) {
|
||||
// AJAX call
|
||||
var a = jQuery
|
||||
.ajax({
|
||||
type : 'POST',
|
||||
url : 'index.php?module=EcmStockDocCorrects&action=javahelper&to_pdf=1',
|
||||
data : {
|
||||
job : 'getConsignments',
|
||||
prod_id : prod_id,
|
||||
stock_id : stock_id
|
||||
},
|
||||
dataType : 'json',
|
||||
async : false,
|
||||
});
|
||||
var consignments = $.parseJSON(a.responseText);
|
||||
var last = consignments.length - 1;
|
||||
var container = $('<table></table>');
|
||||
container.css('width', '100%');
|
||||
$.each(consignments, function(i, c) {
|
||||
var p = $('<p></p>');
|
||||
var tr = $('<tr></tr>');
|
||||
tr.css('width', '100%');
|
||||
var a = $('<a></a>');
|
||||
a.html(c.document_no);
|
||||
a.attr('index', index);
|
||||
if (c.availability >= Math.abs(qty)) {
|
||||
a.click(function(event) {
|
||||
var t = $(event.target);
|
||||
var index = t.attr('index');
|
||||
$('#product_consignment_id_' + index).val(c.operation_id)
|
||||
$('#product_consignment_part_' + index).val(c.part_no);
|
||||
$('#price_'+index).val(FormatNumber(c.price));
|
||||
//insert max qty
|
||||
$('#quantity_'+index).parent().append('<p style="text-align: right;" id="max_quantity_'+index+'">(Max: '+FormatNumber(c.availability*-1,0)+')</p>');
|
||||
$('#quantity_'+index).focus();
|
||||
items[index].product_consignment_id = c.operation_id;
|
||||
items[index].product_consignment_part = c.part_no;
|
||||
items[index].product_consignment_qty = c.availability;
|
||||
calculateRow(index);
|
||||
var div = $('#consignments_div_' + index);
|
||||
div.hide('slow');
|
||||
});
|
||||
a.css('cursor', 'pointer');
|
||||
a.css('color', 'blue');
|
||||
} else
|
||||
a.css('color', 'red');
|
||||
var td = $('<td></td>');
|
||||
td.append(a);
|
||||
tr.append(td);
|
||||
var td = $('<td></td>');
|
||||
td.append(c.part_no);
|
||||
tr.append(td);
|
||||
var td = $('<td></td>');
|
||||
td.append(FormatNumber(c.availability) + ' ' + c.unit);
|
||||
tr.append(td);
|
||||
var td = $('<td></td>');
|
||||
td.append(FormatNumber(c.price) + ' ' + c.currency + ' / ' + c.unit);
|
||||
tr.append(td);
|
||||
container.append(tr);
|
||||
});
|
||||
// show div
|
||||
$('#consignments_div_' + index).show('slow');
|
||||
return container;
|
||||
}
|
||||
|
||||
function checkConsignmentsValues() {
|
||||
var count = $('#' + itemsTable + '_T tr').length - 1; // -1 - thead row
|
||||
var NO_ERROR = true;
|
||||
for (var index = 0; index != count; index++) {
|
||||
if (items[index].product_is_consignment == '1') {
|
||||
var tmp = items[index].product_consignment_part;
|
||||
if (!tmp) tmp = '';
|
||||
if (tmp.length==0) NO_ERROR = false;
|
||||
}
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
191
modules/EcmStockDocIns/javascript/EcmStockDocIns.js
Executable file
191
modules/EcmStockDocIns/javascript/EcmStockDocIns.js
Executable file
@@ -0,0 +1,191 @@
|
||||
//START:
|
||||
$(document).ready(function () {
|
||||
$("#parent_name").attr("size", "70");
|
||||
$("#parent_name_copy").attr("size", "70");
|
||||
//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);
|
||||
|
||||
// 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);
|
||||
var checkgen;
|
||||
|
||||
// confirm exit
|
||||
window.onbeforeunload = confirmExit;
|
||||
// prevent submit by enter press
|
||||
lockEnter();
|
||||
// categories
|
||||
getCategoriesList();
|
||||
$('#parent_id').on('inputchange',
|
||||
function () {
|
||||
$(".loading_panel").css("display", "block");
|
||||
setTimeout(function () {
|
||||
getParentInfo($("#parent_id").val(), 'Accounts');
|
||||
}, 1000);
|
||||
});
|
||||
$("#kind").change(function () {
|
||||
if ($("#kind").val() == 'import') {
|
||||
$("#import_table").show();
|
||||
$("#import_title").show();
|
||||
} else {
|
||||
$("#import_table").hide();
|
||||
$("#import_title").hide();
|
||||
}
|
||||
});
|
||||
|
||||
DrawHeaders();
|
||||
|
||||
//$("#register_date").prop("disabled", true);
|
||||
$("#assigned_user_name").prop("disabled", true);
|
||||
//$("#register_date_trigger").hide();
|
||||
$("#import_table").hide();
|
||||
$("#import_title").hide();
|
||||
$("#btn_assigned_user_name").hide();
|
||||
$("#btn_clr_assigned_user_name").hide();
|
||||
if ($("#kind").val() == 'import') {
|
||||
$("#import_table").show();
|
||||
$("#import_title").show();
|
||||
} else {
|
||||
$("#import_table").hide();
|
||||
$("#import_title").hide();
|
||||
}
|
||||
|
||||
$(".loading_panel").css("display", "none");
|
||||
if (($("#new_number").val() == true)
|
||||
&& ($("#duplicate").val() != true)) {
|
||||
EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmStockDocIns');
|
||||
|
||||
} else if (($("#new_number").val() == false)
|
||||
&& ($("#duplicate").val() == false)) {
|
||||
EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmStockDocIns');
|
||||
getItems();
|
||||
}
|
||||
$("#stock").change(function () {
|
||||
$("#stock_id").val(($("#stock :selected").val()));
|
||||
EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmStockDocIns');
|
||||
});
|
||||
if ($("#stock_id").val() != '') {
|
||||
$("#stock_id").val(($("#stock :selected").val()));
|
||||
EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmStockDocIns');
|
||||
}
|
||||
// make pz from other doc
|
||||
if ($("#out_id").val()
|
||||
&& $("#out_module").val()) {
|
||||
getItems2();
|
||||
}
|
||||
|
||||
// handle setItems
|
||||
setITEMS = function () {
|
||||
var formname = 'EditView';
|
||||
if (check_form_(formname) == true) {
|
||||
SetTab('ITEMS');
|
||||
checkProducts();
|
||||
calculateTotal();
|
||||
//disable stock change
|
||||
$("#stock").prop("disabled", true);
|
||||
}
|
||||
};
|
||||
|
||||
// wyszukiwanie start
|
||||
$('#searchProductsInput').keyup(function () {
|
||||
// stronicowanie od 1 strony przy zmianie szukanego produktu
|
||||
$('#searchStart').val(0);
|
||||
searchProducts();
|
||||
});
|
||||
|
||||
AddSearchRecord();
|
||||
//getFirstpartNumber();
|
||||
|
||||
});
|
||||
// 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
|
||||
console.log(1);
|
||||
if (event.clientY == 0 && event.clientX == 0) {
|
||||
return false;
|
||||
}
|
||||
console.log(2);
|
||||
var consigns = checkConsignmentsValues();
|
||||
if (consigns != true) {
|
||||
setITEMS('ITEMS');
|
||||
alert('Brak wymaganych informacji o partiach produktu.');
|
||||
return false;
|
||||
}
|
||||
console.log(3);
|
||||
window.onbeforeunload = null;
|
||||
if (items.length == 0 || items[0].product_id == '') {
|
||||
alert("Brak produktów");
|
||||
return false;
|
||||
}
|
||||
console.log(4);
|
||||
clearEmpty();
|
||||
$(".loading_panel").css("display", "block");
|
||||
$("#register_date").prop("disabled", false);
|
||||
$("#assigned_user_name").prop("disabled", false);
|
||||
|
||||
$("#position_list").val(JSON.stringifyNoSecurity(items));
|
||||
|
||||
var check = checkProducts();
|
||||
|
||||
//if (confirm('Czy potwierdzić Dokument PZ?')) {
|
||||
$("#status").val("accepted");
|
||||
//} else {
|
||||
// $("#status").val("registered");
|
||||
//}
|
||||
$(".loading_panel").css("display", "none");
|
||||
if (check_form_(formname) == false || check == false) {
|
||||
$("#register_date").prop("disabled", true);
|
||||
$("#assigned_user_name").prop("disabled", true);
|
||||
window.onbeforeunload = confirmExit;
|
||||
$(".loading_panel").css("display", "none");
|
||||
console.log(5);
|
||||
return false;
|
||||
} else {
|
||||
console.log(6);
|
||||
return true;
|
||||
|
||||
}
|
||||
console.log(7);
|
||||
};
|
||||
function confirmExit() {
|
||||
return "";
|
||||
}
|
||||
|
||||
function lockEnter() {
|
||||
// prevent default
|
||||
$(window).keydown(function (event) {
|
||||
if (event.keyCode == 13 && $(":focus").prop('tagName') != 'TEXTAREA') {
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
14
modules/EcmStockDocIns/javascript/EcmStockDocInsDetail.js
Executable file
14
modules/EcmStockDocIns/javascript/EcmStockDocInsDetail.js
Executable file
@@ -0,0 +1,14 @@
|
||||
//START:
|
||||
$(document).ready(
|
||||
function() {
|
||||
DrawHeaders();
|
||||
getItems(false);
|
||||
//fill consignments
|
||||
var count = $('#' + itemsTable + '_T tr').length - 1; // -1 - thead row
|
||||
for (var index = 0; index != count; index++) {
|
||||
if (items[index].product_is_consignment) {
|
||||
$( "<p>"+items[index].part_no+"</p>" ).insertAfter( "#product_link_"+index );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
816
modules/EcmStockDocIns/javascript/bimit_table3.js
Normal file
816
modules/EcmStockDocIns/javascript/bimit_table3.js
Normal file
@@ -0,0 +1,816 @@
|
||||
var itemsTable = 'itemsTable';
|
||||
var items = new Array();
|
||||
var displayArray = new Array();
|
||||
var searchedProducts = new Array();
|
||||
var ajax_url = "index.php?module=EcmStockDocIns&action=javahelper&to_pdf=1";
|
||||
|
||||
function calculateRow(index) {
|
||||
if (index == -1)
|
||||
return;
|
||||
|
||||
// liczone według najlepszych zasad księgowości
|
||||
var price = UnformatNumber($('#price_' + index).val());
|
||||
var price_fk = UnformatNumber($('#price_fk_' + index).val());
|
||||
var vat_value = $('#ecmvat_value_' + index).val();
|
||||
var quantity = UnformatNumber($('#quantity_' + index).val());
|
||||
var palet = UnformatNumber($('#palet_' + index).val());
|
||||
var precision = UnformatNumber($('#product_precision_' + index).val());
|
||||
var waga = UnformatNumber($('#waga_' + index).val());
|
||||
var clo = UnformatNumber($('#clo_' + index).val());
|
||||
|
||||
var last_price = ($('#product_last_price_' + index).val());
|
||||
|
||||
if(price!=0){
|
||||
if(last_price!=''){
|
||||
if(parseFloat(price)!=parseFloat(last_price)){
|
||||
var content="Poprzednia cena wynoni: "+FormatNumber(last_price)+"";
|
||||
last_price = parseFloat(last_price);
|
||||
var procent = ((parseFloat(price) - last_price)/last_price)*100;
|
||||
|
||||
if(procent!=0){
|
||||
|
||||
procent = procent.toFixed(2);
|
||||
if(procent>0){
|
||||
content = content + " Cena wzrosła o: "+Math.abs(procent)+'%';
|
||||
} else {
|
||||
content = content + " Cena zmalała o: "+Math.abs(procent)+'%';
|
||||
}
|
||||
$('#row_alert_'+index).html(content);
|
||||
} else {
|
||||
$('#row_alert_'+index).html(null);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$('#row_alert_'+index).html(null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//alert(palet);
|
||||
var total = price * quantity;
|
||||
|
||||
// put data
|
||||
$('#total_' + index).val(FormatNumber(total));
|
||||
|
||||
// put data to items array
|
||||
items[index].price = toFixed(price, 2);
|
||||
items[index].price_fk = toFixed(price_fk, 2);
|
||||
items[index].palet = palet;
|
||||
items[index].total = total;
|
||||
items[index].quantity = toFixed(quantity, precision);
|
||||
items[index].ecmvat_id = $('#ecmvat_id_' + index).val();
|
||||
items[index].ecmvat_name = $('#ecmvat_name_' + index).val();
|
||||
items[index].ecmvat_value = vat_value;
|
||||
items[index].waga = waga;
|
||||
items[index].clo = clo;
|
||||
|
||||
// put other data
|
||||
items[index].recipient_code = $('#recipient_code_' + index).val();
|
||||
items[index].remarks = $('#remarks_' + index).val();
|
||||
// change name or language?
|
||||
items[index].name = htmlEscape($('#name_' + index).val());
|
||||
items[index].unit_name = $('#unit_name_' + index).val();
|
||||
|
||||
// calculate total
|
||||
calculateTotal();
|
||||
}
|
||||
function calculatePrices() {
|
||||
var count = $('#' + itemsTable + '_T tr').length - 1; // -1 - thead row
|
||||
if ($("#kind").val() == 'import') {
|
||||
var TZ = 0;
|
||||
if ($("#foreign_transport_cur_id").val() == 'PLN')
|
||||
TZ = UnformatNumber($("#foreign_transport_val").val());
|
||||
else
|
||||
TZ = UnformatNumber($("#foreign_transport_val").val()) * UnformatNumber($("#foreign_transport_cur_val").val());
|
||||
|
||||
var TK = 0;
|
||||
if ($("#country_transport_cur_id").val() == 'PLN')
|
||||
TK = UnformatNumber($("#country_transport_val").val());
|
||||
else
|
||||
TK = UnformatNumber($("#country_transport_val").val()) * UnformatNumber($("#country_transport_cur_val").val());
|
||||
var KD = 0;
|
||||
if ($("#addition_cost_cur_id").val() == 'PLN')
|
||||
KD = UnformatNumber($("#addition_cost_val").val());
|
||||
else
|
||||
KD = UnformatNumber($("#addition_cost_val").val()) * UnformatNumber($("#addition_cost_cur_val").val());
|
||||
|
||||
var inv_total = 0;
|
||||
var weight_total = 0;
|
||||
var error = false; // hope :)
|
||||
for (var index = 0; index != count; index++) {
|
||||
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].price_fk = UnformatNumber($("#price_fk_" + index).val());
|
||||
items[index].palet = UnformatNumber($("#palet_" + index).val());
|
||||
inv_total += UnformatNumber($("#price_fk_" + index).val()) * qty;
|
||||
weight_total += UnformatNumber($("#waga_" + index).val());
|
||||
}
|
||||
|
||||
var sum = 0;
|
||||
var participation = new Array();
|
||||
for (var index = 0; index != count; index++) {
|
||||
if (index != count - 1) {
|
||||
participation[index] = UnformatNumber($("#waga_" + index).val()) / weight_total;
|
||||
sum += participation[index];
|
||||
} else
|
||||
participation[index] = 1 - sum;
|
||||
}
|
||||
var currency_id = $("#currency_id").val();
|
||||
var exchange;
|
||||
var sad_exchange;
|
||||
if (currency_id == 'PLN')
|
||||
exchange = 1;
|
||||
else {
|
||||
exchange = UnformatNumber($("#currency_value").val());
|
||||
sad_exchange = UnformatNumber($("#currency_sad_value").val());
|
||||
}
|
||||
for (var index = 0; index != count; index++) {
|
||||
var pprice = 0;
|
||||
//alert(document.forms.EditView.currency_value.value);
|
||||
|
||||
var duty = UnformatNumber($("#clo_" + index).val()) / 100;
|
||||
//pprice = (participation[i]*TZ/pf(data.quantity))+(data.invoice_price*exchange * (1+duty)) + (participation[i]*TK/pf(data.quantity)) + (participation[i]*KD/pf(data.quantity));
|
||||
//data.price = pprice;
|
||||
foreign_costs = (participation[index] * TZ / UnformatNumber($("#quantity_" + index).val()));
|
||||
country_costs = (participation[index] * TK / UnformatNumber($("#quantity_" + index).val()));
|
||||
add_costs = (participation[index] * KD / UnformatNumber($("#quantity_" + index).val()));
|
||||
//alert(duty+' '+pf(data.quantity));
|
||||
//alert(foreign_costs+' '+country_costs+' '+add_costs);
|
||||
price = (UnformatNumber($("#price_fk_" + index).val()) * exchange + (UnformatNumber($("#price_fk_" + index).val()) * sad_exchange + foreign_costs) * duty);
|
||||
pprice = foreign_costs + country_costs + add_costs + price;
|
||||
items[index].price =pprice;
|
||||
$('#price_' + index).val(FormatNumber(pprice));
|
||||
var total = UnformatNumber($('#price_' + index).val()) * UnformatNumber($('#quantity_' + index).val());
|
||||
|
||||
// put data
|
||||
$('#total_' + index).val(FormatNumber(total));
|
||||
//N.row(i).cells.item(6).setData(data);
|
||||
|
||||
//N.row(i).calculateTotal();
|
||||
}
|
||||
calculateTotal();
|
||||
}
|
||||
}
|
||||
function calculateTotal() {
|
||||
var count = $('#' + itemsTable + '_T tr').length - 1; // -1 - thead row
|
||||
var vats = new Array();
|
||||
var all_subtotal = 0;
|
||||
var all_total = 0;
|
||||
var sum_vats = 0;
|
||||
var sum_discounts = 0;
|
||||
var weight_total = 0;
|
||||
var total_quantity=0;
|
||||
|
||||
|
||||
for (var index = 0; index != count; index++) {
|
||||
subtotal = UnformatNumber($('#total_' + index).val());
|
||||
all_subtotal += subtotal;
|
||||
total_quantity+=UnformatNumber($('#quantity_' + index).val());
|
||||
// font color to black
|
||||
$("#ecmvat_name_" + index).css("color", "black");
|
||||
if (!($('#ecmvat_id_' + index).val() in vats)) {
|
||||
vats[$('#ecmvat_id_' + index).val()] = new Object();
|
||||
vats[$('#ecmvat_id_' + index).val()].value_name = $(
|
||||
'#ecmvat_name_' + index).val(); // ex. 23
|
||||
vats[$('#ecmvat_id_' + index).val()].value = subtotal
|
||||
* ($('#ecmvat_value_' + index).val() / 100);
|
||||
} else
|
||||
vats[$('#ecmvat_id_' + index).val()].value += subtotal
|
||||
* ($('#ecmvat_value_' + index).val() / 100);
|
||||
sum_vats += subtotal * ($('#ecmvat_value_' + index).val() / 100);
|
||||
|
||||
}
|
||||
all_total = all_subtotal + sum_vats;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// add vats
|
||||
var html = '';
|
||||
var vats_summary = '';
|
||||
for (var x in vats) {
|
||||
if (vats[x].value_name != '') {
|
||||
html += '<tr><td class="positionsLabel">' + vats[x].value_name + '</td>';
|
||||
html += '<td class="positionsField"><input type="text" readonly="readonly" style="border:0px;font-weight:900;width:100%;text-align:right;" name="vat" id="vat" value="'
|
||||
+ FormatNumber(vats[x].value) + '"></td></tr>';
|
||||
|
||||
vats_summary += vats[x].value_name + ':' + toFixed(vats[x].value, 2)
|
||||
+ ',';
|
||||
}
|
||||
}
|
||||
DrawSummary(html);
|
||||
$("#t_netto").val(FormatNumber(all_subtotal));
|
||||
$("#t_brutto").val(FormatNumber(all_total));
|
||||
$("#total_netto").val($("#t_netto").val());
|
||||
$("#total_brutto").val(FormatNumber(all_total));
|
||||
$("#total_quantity").val(FormatNumber(total_quantity));
|
||||
$("#vats_summary").val(vats_summary);
|
||||
|
||||
}
|
||||
function DrawSummary(vats) {
|
||||
$("#result_table").html('');
|
||||
html = '';
|
||||
html += '<tr id="subtotal_tr"> ';
|
||||
html += '<td class="positionsLabel" style="border-top:0px;">Suma netto</td>';
|
||||
html += '<td class="positionsField" style="border-top:0px;"><input type="text" style="border:0px;font-weight:900;width:100%;text-align:right;" readonly="readonly" name="t_netto" id="t_netto" value=\'\'></td>';
|
||||
html += '</tr>';
|
||||
html += '<tr><td class="positionsLabel">Ilość razem</td>';
|
||||
html += '<td class="positionsField"><input type="text" readonly="readonly" style="border:0px;font-weight:900;width:100%;text-align:right;" name="total_quantity" id="total_quantity" value=""></td></tr>';
|
||||
$("#result_table").html(html);
|
||||
}
|
||||
|
||||
function DrawHeaders() {
|
||||
var html = '<link rel="stylesheet" type="text/css" href="modules/EcmQuotes/MyTable.css" />';
|
||||
html += '<div style="width:100%;border: 1px solid rgb(48,192,255);background-color:white;overflow:auto;" id="'
|
||||
+ itemsTable + 'DIV">';
|
||||
html += '<table class="positions" style="width:100%;" id="' + itemsTable
|
||||
+ '_T">';
|
||||
html += '<thead id="head">';
|
||||
html += '<tr id="tr">';
|
||||
// draw columns headers
|
||||
$.each(columns, function (index, column) {
|
||||
html += '<td width="' + column.width + '%">' + column.label + '</td>';
|
||||
});
|
||||
html += '</tr></thead><tbody></tbody></table>';
|
||||
html += '</div><br>';
|
||||
// totals table
|
||||
html += '<table width="100%"" cellpadding="0" cellspacing="0" border="0">';
|
||||
html += '<tr>';
|
||||
html += '<td width="55%" class="dataLabel" valign="top">';
|
||||
html += ' ';
|
||||
html += '</td> <!--color:#b3b9cf;-->';
|
||||
html += '<td width="40%" class="dataField" style="text-align: left;">';
|
||||
html += '<br>';
|
||||
html += '<table id="result_table" cellpadding="0" cellspacing="0" style="width:100%; height:100%; border: 1px solid rgb(48,192,255);">';
|
||||
html += '</table>';
|
||||
html += '</td>';
|
||||
html += '<td width="5%" class="dataField" style="text-align: left;"> </td>';
|
||||
html += '</tr>';
|
||||
html += '</table>';
|
||||
$('#' + itemsTable).html(html);
|
||||
}
|
||||
|
||||
function addProducts() {
|
||||
$(".loading_panel").css("display", "block");
|
||||
clearEmpty();
|
||||
var products = new Array();
|
||||
$.each(searchedProducts, function (index, value) {
|
||||
if ($('#prod_' + value).is(':checked'))
|
||||
products[value] = true;
|
||||
});
|
||||
for (var key in products) {
|
||||
var params = {
|
||||
job: 'getProduct',
|
||||
id: key,
|
||||
stockId: $("#stock_id :selected").val(),
|
||||
};
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function (data) {
|
||||
if (data != '-1') {
|
||||
var p = new Object();
|
||||
p.product_id = data.id;
|
||||
p.name = data.name;
|
||||
p.product_code = data.code;
|
||||
p.price = data.price;
|
||||
p.unit_name = data.unit_name;
|
||||
p.unit_id = data.unit_id;
|
||||
p.ecmvat_id = data.ecmvat_id;
|
||||
p.ecmvat_value = data.ecmvat_value;
|
||||
p.ecmvat_name = data.ecmvat_name;
|
||||
p.stock_state = data.stock_state;
|
||||
p.price_last = data.price_last;
|
||||
p.product_category_id = data.product_category_id;
|
||||
p.product_precision = data.unit_precision;
|
||||
p.unit_precision = data.unit_precision;
|
||||
p.product_is_consignment = data.is_consignment;
|
||||
if ($("#searchInputPrice").val() != ''
|
||||
&& !isNaN(parseFloat(UnformatNumber($(
|
||||
"#searchInputPrice").val()))))
|
||||
p.price = $("#searchInputPrice").val();
|
||||
if ($("#searchInputQty").val() != ''
|
||||
&& !isNaN(parseFloat(UnformatNumber($(
|
||||
"#searchInputQty").val()))))
|
||||
p.quantity = $("#searchInputQty").val();
|
||||
p.product_last_price=data.product_last_price;
|
||||
items.push(p);
|
||||
}
|
||||
},
|
||||
data: params
|
||||
});
|
||||
}
|
||||
AddSearchRecord();
|
||||
FillTable(items);
|
||||
checkProductIsConsignment();
|
||||
// clear results
|
||||
$('#searchResultDiv').html('');
|
||||
searchedProducts = new Array();
|
||||
$('#searchProductsInput').val('');
|
||||
|
||||
$(".loading_panel").css("display", "none");
|
||||
}
|
||||
|
||||
|
||||
|
||||
function AddProduct(index, record) {
|
||||
$(".loading_panel").css("display", "block");
|
||||
var record;
|
||||
var pricebook = $("#pricebook_id :selected").val();
|
||||
|
||||
var params = {
|
||||
job: 'getProduct',
|
||||
id: record,
|
||||
stockId: $("#stock_out_id :selected").val(),
|
||||
};
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function (data) {
|
||||
if (data != '-1') {
|
||||
|
||||
items[index].product_id = data.id;
|
||||
items[index].name = data.name;
|
||||
items[index].product_code = data.code;
|
||||
items[index].product_id = data.id;
|
||||
items[index].ecmvat_id = data.ecmvat_id;
|
||||
items[index].ecmvat_value = data.ecmvat_value;
|
||||
items[index].ecmvat_name = data.ecmvat_name;
|
||||
items[index].product_ean = data.ean;
|
||||
items[index].discount = data.discount;
|
||||
items[index].product_ean2 = data.ean2;
|
||||
items[index].unit_name = data.unit_name;
|
||||
items[index].price_last = data.price_last;
|
||||
items[index].unit_id = data.unit_id;
|
||||
items[index].price_start = data.price_start;
|
||||
items[index].recipient_code = data.recipient_code;
|
||||
items[index].product_precision = data.unit_precision;
|
||||
items[index].unit_precision = data.unit_precision;
|
||||
items[index].product_last_price=data.product_last_price;
|
||||
items[index].product_is_consignment = data.is_consignment;
|
||||
if ($("#searchInputPrice").val() != ''
|
||||
&& !isNaN(parseFloat(UnformatNumber($(
|
||||
"#searchInputPrice").val()))))
|
||||
items[index].price_start = $("#searchInputPrice").val();
|
||||
if ($("#searchInputQty").val() != ''
|
||||
&& !isNaN(parseFloat(UnformatNumber($(
|
||||
"#searchInputQty").val()))))
|
||||
items[index].quantity = $("#searchInputQty").val();
|
||||
|
||||
}
|
||||
},
|
||||
data: params
|
||||
});
|
||||
AddSearchRecord();
|
||||
|
||||
FillTable(items);
|
||||
checkProductIsConsignment();
|
||||
$('#searchResultDiv').html('');
|
||||
$(".loading_panel").css("display", "none");
|
||||
$("#quantity_" + index).focus().select();
|
||||
}
|
||||
function getItems(editview) {
|
||||
var record = '';
|
||||
if ($("#duplicate").val() == true)
|
||||
record = $("input[name='return_id']").val();
|
||||
else
|
||||
record = $("input[name='record']").val();
|
||||
if (isNaN(editview))
|
||||
editview = true;
|
||||
var params = {
|
||||
job: 'getItems',
|
||||
record: record,
|
||||
};
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function (data) {
|
||||
items = data;
|
||||
if (editview) {
|
||||
FillTable(items, false);
|
||||
} else
|
||||
FillTable(items, true);
|
||||
$(".loading_panel").css("display", "none");
|
||||
},
|
||||
data: params
|
||||
});
|
||||
}
|
||||
|
||||
function getItems2(editview) {
|
||||
var record = '';
|
||||
record = $("#out_id").val();
|
||||
var module2 = '';
|
||||
module2 = $("#out_module").val();
|
||||
if (isNaN(editview))
|
||||
editview = true;
|
||||
var params = {
|
||||
job: 'getItems2',
|
||||
record: record,
|
||||
module2: module2,
|
||||
};
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
items = data;
|
||||
if (editview)
|
||||
FillTable(items, false);
|
||||
else
|
||||
FillTable(items, true);
|
||||
$(".loading_panel").css("display", "none");
|
||||
},
|
||||
data: params
|
||||
});
|
||||
calculateTotal();
|
||||
}
|
||||
|
||||
function DrawDetailSummary() {
|
||||
$("#result_table").html('');
|
||||
html = '';
|
||||
html += '<tr id="total_quantity_tr"> ';
|
||||
html += '<td class="positionsLabel" style="border-top:0px;">Razem ilość</td>';
|
||||
html += '<td class="positionsField" style="border-top:0px;"><input type="text" style="border:0px;font-weight:900;width:100%;text-align:right;" readonly="readonly" name="total_quantity" id="total_quantity"value=\''
|
||||
+ FormatNumber($("#doc_total_quantity").val()) + '\'></td>';
|
||||
html += '</tr>';
|
||||
html += '<tr id="subtotal_tr"> ';
|
||||
html += '<td class="positionsLabel" style="border-top:0px;">Suma netto</td>';
|
||||
html += '<td class="positionsField" style="border-top:0px;"><input type="text" style="border:0px;font-weight:900;width:100%;text-align:right;" readonly="readonly" name="t_netto" id="t_netto" value=\''
|
||||
+ FormatNumber($("#doc_total").val()) + '\'></td>';
|
||||
html += '</tr>';
|
||||
$("#result_table").html(html);
|
||||
}
|
||||
|
||||
function generateNumber() {
|
||||
var params = {
|
||||
job: 'generateNumber',
|
||||
stock_id: $("#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 getParentInfo(parent_id, parent_type) {
|
||||
var params = {
|
||||
id: parent_id,
|
||||
type: parent_type,
|
||||
job: 'getParentInfo'
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data == '-1') {
|
||||
alert('Błąd');
|
||||
$("#parent_name").val('');
|
||||
$("#parent_id").val('');
|
||||
} else {
|
||||
setParentInfo(data);
|
||||
}
|
||||
},
|
||||
data: params
|
||||
});
|
||||
}
|
||||
|
||||
//insert parent info in fields
|
||||
function setParentInfo(data) {
|
||||
//pricebooks
|
||||
|
||||
if ($("#new_number").val() == false)
|
||||
return; //if edit exists load only pricebooks
|
||||
if (data.name)
|
||||
$("#parent_name_copy").val(data.name);
|
||||
if (data.name)
|
||||
$("#parent_name").val(data.name);
|
||||
if (data.parent_nip)
|
||||
$("#parent_nip").val(data.parent_nip);
|
||||
if (data.parent_address_street)
|
||||
$("#parent_address_street").val(data.parent_address_street);
|
||||
if (data.parent_address_city)
|
||||
$("#parent_address_city").val(data.parent_address_city);
|
||||
if (data.parent_address_postalcode)
|
||||
$("#parent_address_postalcode").val(data.parent_address_postalcode);
|
||||
if (data.parent_address_country)
|
||||
$("#parent_address_country").val(data.parent_address_country);
|
||||
if (data.invoice_type && data.invoice_type != 'K')
|
||||
$("#to_is_vat_free").attr('checked', true);
|
||||
if (data.ecmpaymentcondition_id && data.ecmpaymentcondition_name) {
|
||||
$("#ecmpaymentcondition_id").val(data.ecmpaymentcondition_id);
|
||||
$("#ecmpaymentcondition_name").val(data.ecmpaymentcondition_name);
|
||||
}
|
||||
if (data.ecmdeliverycondition_id && data.ecmdeliverycondition_name) {
|
||||
$("#ecmdeliverycondition_id").val(data.ecmdeliverycondition_id);
|
||||
$("#ecmdeliverycondition_name").val(data.ecmdeliverycondition_name);
|
||||
}
|
||||
if (data.currency_id)
|
||||
$("#currency_id option[value=\"" + data.currency_id + "\"]").attr('selected', 'selected');
|
||||
//hide loading
|
||||
$(".loading_panel").css("display", "none");
|
||||
}
|
||||
|
||||
function getCategoriesList() {
|
||||
var params = {
|
||||
job: 'getCategoriesList'
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
var html = '<option value=""></option>';
|
||||
$.each(data, function (index, value) {
|
||||
html += '<option value="' + value.id + '">' + value.name
|
||||
+ '</option>';
|
||||
$("#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));
|
||||
},
|
||||
data: params
|
||||
});
|
||||
}
|
||||
|
||||
function checkProducts() {
|
||||
var count = $('#' + itemsTable + '_T tr').length - 1; // -1 - thead row
|
||||
var error = false; // hope :)
|
||||
for (var index = 0; index != count; index++) {
|
||||
if($("#quantity_" + index).length == 0){
|
||||
continue;
|
||||
}
|
||||
//refreshStock(index);
|
||||
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].price_fk = UnformatNumber($("#price_fk_" + index).val());
|
||||
items[index].palet = UnformatNumber($("#palet_" + index).val());
|
||||
var stock = UnformatNumber($("#stock_state_" + index).val());
|
||||
$("#quantity_" + index).css("color", "black");
|
||||
if(!(items[index].price>0)){
|
||||
error=true;
|
||||
$("#price_" + index).css("color", "red");
|
||||
}
|
||||
}
|
||||
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_fk = items[index].price_fk;
|
||||
var palet = items[index].palet;
|
||||
//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.price_fk = value.price_fk;
|
||||
p.palet = value.palet;
|
||||
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 = '<img style="cursor: pointer;" align="left" src="themes/Sugar/images/close_inline.gif" onClick="$(\'#search_info_div2_'
|
||||
+ product_id
|
||||
+ '\').hide(\'slow\')"/>';
|
||||
html += '<a href="index.php?module=EcmProducts&action=DetailView&record='
|
||||
+ product_id + '" target="_blank">' + product_code + '</a><br><br>';
|
||||
html += '<table><tr><td style="text-align:left;">Magazyn</td><td>Ilość</td></tr>';
|
||||
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 += '<tr><td style="text-align:left;">' + key + '</td><td>' + FormatNumber(value)
|
||||
+ '</td></tr>';
|
||||
});
|
||||
},
|
||||
data: params
|
||||
});
|
||||
html += '</table>';
|
||||
|
||||
$("#search_info_div2_" + product_id).html(html);
|
||||
}
|
||||
|
||||
function getSearchInfo(product_id, product_code) {
|
||||
$("#search_info_div_" + product_id).show().draggable();
|
||||
var html = '<img style="cursor: pointer;" align="left" src="themes/Sugar/images/close_inline.gif" onClick="$(\'#search_info_div_'
|
||||
+ product_id
|
||||
+ '\').hide(\'slow\')"/>';
|
||||
html += '<a href="index.php?module=EcmProducts&action=DetailView&record='
|
||||
+ product_id + '" target="_blank">' + product_code + '</a><br><br>';
|
||||
// get prices info
|
||||
html += '<table><tr><td style="text-align:left;">Nazwa</td><td>Ilość</td><td>Cena</td><td>Data dok</td></tr>';
|
||||
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) + '<br>';
|
||||
if (value.name == $("#ecmprice_name").val())
|
||||
html += '<b>' + value.name + ': '
|
||||
+ FormatNumber(value.price) + '</b><br>';
|
||||
else
|
||||
|
||||
if (value.module == 'EcmStockDocIns') {
|
||||
html += '<tr><td style="text-align:left;">' + value.name + '</td><td>' + value.quantity + '</td><td> <font style="color:#7FFF00;text-align:right;">' + FormatNumber(value.price) + '</font></td><td>' + value.register_date + '</td></tr>';
|
||||
}
|
||||
//html += value.name + ': ' + FormatNumber(value.price)
|
||||
// + '<br>';
|
||||
});
|
||||
},
|
||||
data: params
|
||||
});
|
||||
html += '</tr></table>';
|
||||
|
||||
$("#search_info_div_" + product_id).html(html);
|
||||
}
|
||||
|
||||
function getSearchInfo3(product_id, product_code) {
|
||||
$("#search_info_div3_" + product_id).show().draggable();
|
||||
var html = '<img style="cursor: pointer;" align="left" src="themes/Sugar/images/close_inline.gif" onClick="$(\'#search_info_div3_'
|
||||
+ product_id
|
||||
+ '\').hide(\'slow\')"/>';
|
||||
html += '<a href="index.php?module=EcmProducts&action=DetailView&record='
|
||||
+ product_id + '" target="_blank">' + product_code + '</a><br><br>';
|
||||
// get prices info
|
||||
html += '<table><tr><td style="text-align:left;">Nazwa</td><td>Cena</td></tr>';
|
||||
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) + '<br>';
|
||||
if (value.name == $("#ecmprice_name").val())
|
||||
html += '<b>' + value.name + ': '
|
||||
+ FormatNumber(value.price) + '</b><br>';
|
||||
else
|
||||
|
||||
if (value.module == 'EcmPrices') {
|
||||
html += '<tr><td style="text-align:left;">' + value.name + ':</td><td> <font style="color:#7FFF00;text-align:right;">' + FormatNumber(value.price) + '</font></td></tr>';
|
||||
}
|
||||
if (value.module == 'EcmInvoiceOuts') {
|
||||
html += '<tr><td "text-align:left;">' + value.name + ':</td><td> <font style="color:#FF3333;text-align:right;">' + FormatNumber(value.price) + '</font></td></tr>';
|
||||
}
|
||||
//html += value.name + ': ' + FormatNumber(value.price)
|
||||
// + '<br>';
|
||||
});
|
||||
},
|
||||
data: params
|
||||
});
|
||||
html += '</table>';
|
||||
|
||||
$("#search_info_div3_" + product_id).html(html);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function createAccount() {
|
||||
var parent_name = document.getElementById("parent_name");
|
||||
var parent_id = document.getElementById("parent_id");
|
||||
newAccount = window.open('index.php?module=Accounts&action=EditView&IamPopup=1', 'newAccount', 'toolbar=no,menubar=no,scrollbars=yes,scrollbars=1');
|
||||
newAccount.parent_name = parent_name;
|
||||
newAccount.parent_id = parent_id;
|
||||
newAccount.focus();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
$.event.special.inputchange = {
|
||||
setup: function () {
|
||||
var self = this, val;
|
||||
$.data(this, 'timer', window.setInterval(function () {
|
||||
val = self.value;
|
||||
if ($.data(self, 'cache') != val) {
|
||||
$.data(self, 'cache', val);
|
||||
$(self).trigger('inputchange');
|
||||
}
|
||||
}, 20));
|
||||
},
|
||||
teardown: function () {
|
||||
window.clearInterval($.data(this, 'timer'));
|
||||
},
|
||||
add: function () {
|
||||
$.data(this, 'cache', this.value);
|
||||
}
|
||||
};
|
||||
$("#" + itemsTable + " tbody").sortable();
|
||||
92
modules/EcmStockDocIns/javascript/columndefs-detail.js
Executable file
92
modules/EcmStockDocIns/javascript/columndefs-detail.js
Executable file
@@ -0,0 +1,92 @@
|
||||
columns = new Array();
|
||||
//define columns
|
||||
//begin: number
|
||||
columns[0] = {
|
||||
'name' : 'number',
|
||||
'label' : 'Lp.',
|
||||
'width' : 4,
|
||||
'content' : new Array(),
|
||||
};
|
||||
columns[0]['content'][0] = {'name' : '', 'type': 'text', 'readonly' : true};
|
||||
//end: number
|
||||
//begin: code
|
||||
columns[1] = {
|
||||
'name' : 'product_',
|
||||
'label' : 'Indeks',
|
||||
'width' : 6,
|
||||
'content' : new Array(),
|
||||
};
|
||||
columns[1]['content'][0] = {'name' : 'code', 'type': 'hidden', 'readonly' : true};
|
||||
columns[1]['content'][1] = {'name' : 'id', 'type': 'hidden'};
|
||||
columns[1]['content'][2] = {'name' : 'link', 'type': 'text', 'readonly' : true};
|
||||
columns[1]['content'][3] = {'name' : 'precision', 'type': 'hidden'};
|
||||
//end: code
|
||||
//begin: name
|
||||
columns[2] = {
|
||||
'name' : 'name',
|
||||
'label' : 'Nazwa',
|
||||
'width' : 20,
|
||||
'content' : new Array(),
|
||||
};
|
||||
columns[2]['content'][0] = {'name' : '', 'type': 'text'};
|
||||
//end: name
|
||||
//begin: quantity
|
||||
columns[3] = {
|
||||
'name' : 'quantity',
|
||||
'label' : 'Ilość',
|
||||
'width' : 5,
|
||||
'content' : new Array(),
|
||||
'align' : 'right',
|
||||
};
|
||||
columns[3]['content'][0] = {'name' : '', 'type': 'text', 'isNumber' : true, 'onChange' : 'checkProducts();'};
|
||||
//end: quantity
|
||||
//begin: unit
|
||||
columns[4] = {
|
||||
'name' : 'unit_',
|
||||
'label' : 'J.M.',
|
||||
'width' : 5,
|
||||
'content' : new Array(),
|
||||
'align' : 'center',
|
||||
};
|
||||
columns[4]['content'][0] = {'name' : 'name', 'type': 'text','readonly' : true};
|
||||
columns[4]['content'][1] = {'name' : 'id', 'type': 'hidden'};
|
||||
//end: unit
|
||||
//begin: price
|
||||
columns[5] = {
|
||||
'name' : 'price',
|
||||
'label' : 'Cena',
|
||||
'width' : 5,
|
||||
'content' : new Array(),
|
||||
'align' : 'right',
|
||||
};
|
||||
columns[5]['content'][0] = {'name' : '', 'type': 'text', 'isNumber' : true};
|
||||
//end: price
|
||||
//begin: total
|
||||
columns[6] = {
|
||||
'name' : 'total',
|
||||
'label' : 'Wartość',
|
||||
'width' : 5,
|
||||
'content' : new Array(),
|
||||
'align' : 'right',
|
||||
};
|
||||
columns[6]['content'][0] = {'name' : '', 'type': 'text', 'isNumber' : true};
|
||||
//end: total
|
||||
columns[7] = {
|
||||
'name' : 'price_fk',
|
||||
'label' : 'Cena<br>na FK',
|
||||
'width' : 5,
|
||||
'content' : new Array(),
|
||||
'align' : 'right',
|
||||
};
|
||||
columns[7]['content'][0] = {'name' : '', 'type': 'text', 'isNumber' : true, 'readonly' : false,'onChange' :''};
|
||||
columns[8] = {
|
||||
'name' : 'ecmvat_',
|
||||
'label' : 'VAT (%)',
|
||||
'width' : 5,
|
||||
'content' : new Array(),
|
||||
'align' : 'right',
|
||||
};
|
||||
columns[8]['content'][0] = {'name' : 'name', 'type': 'text'};
|
||||
columns[8]['content'][1] = {'name' : 'value', 'type': 'hidden'};
|
||||
columns[8]['content'][2] = {'name' : 'id', 'type': 'hidden'};
|
||||
//columns[9]['content'][0] = {'name' : '', 'type': 'text', 'isNumber' : false, 'readonly' : false,'onChange' :''};
|
||||
143
modules/EcmStockDocIns/javascript/columndefs3.js
Executable file
143
modules/EcmStockDocIns/javascript/columndefs3.js
Executable file
@@ -0,0 +1,143 @@
|
||||
columns = new Array();
|
||||
//define columns
|
||||
//begin: number
|
||||
columns[0] = {
|
||||
'name' : 'number',
|
||||
'label' : 'Lp.',
|
||||
'width' : 4,
|
||||
'content' : new Array(),
|
||||
};
|
||||
columns[0]['content'][0] = {'name' : '', 'type': 'text', 'readonly' : true};
|
||||
//end: number
|
||||
//begin: code
|
||||
columns[1] = {
|
||||
'name' : 'product_',
|
||||
'label' : 'Indeks',
|
||||
'width' : 6,
|
||||
'content' : new Array(),
|
||||
};
|
||||
columns[1]['content'][0] = {'name' : 'code', 'type': 'hidden', 'readonly' : true};
|
||||
columns[1]['content'][1] = {'name' : 'id', 'type': 'hidden'};
|
||||
columns[1]['content'][2] = {'name' : 'link', 'type': 'text', 'readonly' : true};
|
||||
columns[1]['content'][3] = {'name' : 'category_id', 'type': 'hidden'};
|
||||
columns[1]['content'][4] = {'name' : 'precision', 'type': 'hidden'};
|
||||
columns[1]['content'][5] = {'name' : 'is_consignment', 'type': 'hidden'};
|
||||
columns[1]['content'][6] = {
|
||||
'name' : 'consignment_part',
|
||||
'type' : 'text',
|
||||
|
||||
};
|
||||
columns[1]['content'][7] = {
|
||||
'name' : 'consignment_id',
|
||||
'type' : 'hidden',
|
||||
};
|
||||
columns[1]['content'][8] = {'name' : 'last_price', 'type': 'hidden'};
|
||||
//end: code
|
||||
//begin: name
|
||||
columns[2] = {
|
||||
'name' : 'name',
|
||||
'label' : 'Nazwa',
|
||||
'width' : 20,
|
||||
'content' : new Array(),
|
||||
};
|
||||
columns[2]['content'][0] = {'name' : '', 'type': 'text'};
|
||||
//end: name
|
||||
//begin: quantity
|
||||
columns[3] = {
|
||||
'name' : 'quantity',
|
||||
'label' : 'Ilość',
|
||||
'width' : 5,
|
||||
'content' : new Array(),
|
||||
'align' : 'right',
|
||||
};
|
||||
columns[3]['content'][0] = {'name' : '', 'type': 'text', 'isNumber' : true, 'onChange' : 'calculateRow($(this).parent(\'td\').parent(\'tr\').index());', 'precision' : '2'};
|
||||
//end: quantity
|
||||
//begin: price
|
||||
columns[4] = {
|
||||
'name' : 'price',
|
||||
'label' : 'Cena',
|
||||
'width' : 5,
|
||||
'content' : new Array(),
|
||||
'align' : 'right',
|
||||
};
|
||||
columns[4]['content'][0] = {'name' : '', 'type': 'text', 'isNumber' : true, 'onChange' : 'calculateRow($(this).parent(\'td\').parent(\'tr\').index());'};
|
||||
//end: price
|
||||
//begin: unit
|
||||
columns[5] = {
|
||||
'name' : 'unit_',
|
||||
'label' : 'J.M.',
|
||||
'width' : 1,
|
||||
'content' : new Array(),
|
||||
'align' : 'center',
|
||||
};
|
||||
columns[5]['content'][0] = {'name' : 'name', 'type': 'text','readonly' : true};
|
||||
columns[5]['content'][1] = {'name' : 'id', 'type': 'hidden'};
|
||||
columns[5]['content'][1] = {'name' : 'precision', 'type': 'hidden'};
|
||||
|
||||
columns[6] = {
|
||||
'name' : 'price_last',
|
||||
'label' : 'Ostatnia cena',
|
||||
'width' : 4,
|
||||
'content' : new Array(),
|
||||
'align' : 'right',
|
||||
};
|
||||
columns[6]['content'][0] = {'name' : '', 'type': 'text', 'isNumber' : true, 'readonly':true};
|
||||
|
||||
//end: unit
|
||||
//begin: options
|
||||
columns[7] = {
|
||||
'name' : 'price_fk',
|
||||
'label' : 'Cena<br>na FK',
|
||||
'width' : 5,
|
||||
'content' : new Array(),
|
||||
'align' : 'right',
|
||||
};
|
||||
columns[7]['content'][0] = {'name' : '', 'type': 'text', 'isNumber' : true, 'readonly' : false, 'onChange' : 'calculateRow($(this).parent(\'td\').parent(\'tr\').index());'};
|
||||
//end: price_start
|
||||
//begin: ecmvat
|
||||
columns[8] = {
|
||||
'name' : 'ecmvat_',
|
||||
'label' : 'VAT (%)',
|
||||
'width' : 5,
|
||||
'content' : new Array(),
|
||||
'align' : 'right',
|
||||
};
|
||||
columns[8]['content'][0] = {'name' : 'name', 'type': 'text'};
|
||||
columns[8]['content'][1] = {'name' : 'value', 'type': 'hidden'};
|
||||
columns[8]['content'][2] = {'name' : 'id', 'type': 'hidden'};
|
||||
//end: ecmvat
|
||||
//begin: total
|
||||
columns[9] = {
|
||||
'name' : 'total',
|
||||
'label' : 'Wartość',
|
||||
'width' : 5,
|
||||
'content' : new Array(),
|
||||
'align' : 'right',
|
||||
};
|
||||
columns[9]['content'][0] = {'name' : '', 'type': 'text', 'isNumber' : true, 'readonly' : true};
|
||||
|
||||
columns[10] = {
|
||||
'name' : 'waga',
|
||||
'label' : 'Waga<br>Netto',
|
||||
'width' : 5,
|
||||
'content' : new Array(),
|
||||
'align' : 'right',
|
||||
};
|
||||
columns[10]['content'][0] = {'name' : '', 'type': 'text', 'isNumber' : true, 'readonly' : false, 'onChange' : 'calculateRow($(this).parent(\'td\').parent(\'tr\').index());'};
|
||||
|
||||
columns[11] = {
|
||||
'name' : 'clo',
|
||||
'label' : 'Pole<br>dod.',
|
||||
'width' : 5,
|
||||
'content' : new Array(),
|
||||
'align' : 'right',
|
||||
};
|
||||
|
||||
columns[11]['content'][0] = {'name' : '', 'type': 'text', 'isNumber' : true, 'readonly' : false, 'onChange' : 'calculateRow($(this).parent(\'td\').parent(\'tr\').index());'};
|
||||
|
||||
columns[12] = {
|
||||
'name' : 'options',
|
||||
'label' : 'Opcje',
|
||||
'width' : 3,
|
||||
'content' : new Array(),
|
||||
};
|
||||
4
modules/EcmStockDocIns/javascript/searchcolumndefs.js
Executable file
4
modules/EcmStockDocIns/javascript/searchcolumndefs.js
Executable file
@@ -0,0 +1,4 @@
|
||||
var extraproductinfo_show=true; // info o produkcie
|
||||
var unit_show=true; // jednostka produktu
|
||||
var number_show=false; // numeruje wiersze
|
||||
var module_function="EcmStockDocIns";
|
||||
Reference in New Issue
Block a user