init
This commit is contained in:
322
modules/EcmStockDocCorrects/javascript/Consignments.js
Normal file
322
modules/EcmStockDocCorrects/javascript/Consignments.js
Normal file
@@ -0,0 +1,322 @@
|
||||
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');
|
||||
if (UnformatNumber($('#quantity_'+index).val())<=0)
|
||||
if (!items[index].product_consignment_id || items[index].product_consignment_id=='' )
|
||||
getConsignmentsDiv(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);
|
||||
console.log(items[index].product_is_consignment);
|
||||
if (items[index].product_is_consignment != '1') {
|
||||
console.log('nie partia');
|
||||
if (UnformatNumber($('#quantity_' + index).val()) > 0)
|
||||
$('#consignments_div_'+index).remove();
|
||||
else
|
||||
if (!items[index].product_consignment_id || items[index].product_consignment_id=='')
|
||||
getConsignmentsDiv(index);
|
||||
} else {
|
||||
console.log('partia');
|
||||
if (UnformatNumber($('#quantity_' + index).val()) > 0)
|
||||
getInsertConsignmentsDiv(index);
|
||||
else
|
||||
if (!items[index].product_consignment_id || items[index].product_consignment_id=='')
|
||||
getConsignmentsDiv(index);
|
||||
}
|
||||
}
|
||||
|
||||
var getInsertConsignmentsDiv = function(index) {
|
||||
if($('#product_id_' + index).val()=='' || $('#product_is_consignment_' + index).val() != '1') return '';
|
||||
$('#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();
|
||||
console.log(index);
|
||||
// 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{
|
||||
if( ($('#type').val()=='2dcd99ce-c2fe-6bbd-6d1a-5512a569c4e0') || ($('#type').val()=='1')){
|
||||
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);
|
||||
$('#product_consignment_qty_' + index).val(c.availability);
|
||||
console.log("tutut");
|
||||
|
||||
if( ($('#type').val()=='2dcd99ce-c2fe-6bbd-6d1a-5512a569c4e0')){
|
||||
$('#quantity_' + index).val(FormatNumber(c.availability,c.precision));
|
||||
} else {
|
||||
$('#quantity_' + index).val(FormatNumber(c.availability*-1,c.precision));
|
||||
}
|
||||
//$('#quantity_' + index).attr('readonly', 'readonly');
|
||||
$('#price_'+index).val(FormatNumber(c.price));
|
||||
$('#price_old_'+index).val(FormatNumber(c.price));
|
||||
console.log($('#type').val());
|
||||
if ($('#type').val() == '2dcd99ce-c2fe-6bbd-6d1a-5512a569c4e0') {
|
||||
$('#price_old_'+index).attr('type','text');
|
||||
$('<br>').insertAfter('#price_'+index);
|
||||
$('#quantity_' + index).val(FormatNumber(c.availability,c.precision));
|
||||
} else {
|
||||
$('#quantity_' + index).val(FormatNumber(c.availability*-1,c.precision));
|
||||
}
|
||||
//insert max qty
|
||||
$('#max_quantity_'+index).remove();
|
||||
$('#quantity_'+index).parent().append('<p style="text-align: right;" id="max_quantity_'+index+'">(Max: '+FormatNumber(c.availability,c.precision)+')</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.precision) + ' ' + 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);
|
||||
$('#product_consignment_qty_' + index).val(c.availability);
|
||||
if ($('#type').val() == '6ed5b076-ddd1-9809-b236-54e5b2bcbd97') {
|
||||
|
||||
|
||||
$('#price_old_'+index).remove();
|
||||
$('#onlyRemove_'+index).remove();
|
||||
|
||||
$('#price_'+index).parent().append('<div id="onlyRemove_'+index+'"><p style="text-align:right">(było: '+FormatNumber(c.price)+')</p><input type="hidden" readonly="readonly" value="'+FormatNumber(c.price)+'" onclick="$(this).select();" style="text-align: right;background-color:#ffffff;" id="price_old_'+index+'" name="price_old_'+index+'" class="inputs"></div>');
|
||||
$('#quantity_' + index).val(FormatNumber(c.availability,c.precision));
|
||||
$('#quantity_' + index).attr('readonly',true);
|
||||
} else {
|
||||
$('#quantity_' + index).val(FormatNumber(c.availability*-1,c.precision));
|
||||
}
|
||||
$('#price_'+index).val(FormatNumber(c.price));
|
||||
//insert max qty
|
||||
if ($('#type').val() == '6ed5b076-ddd1-9809-b236-54e5b2bcbd97') {
|
||||
$('#quantity_'+index).parent().append('<p style="text-align: right;" id="max_quantity_'+index+'">(Max: '+FormatNumber(c.availability,c.precision)+')</p>');
|
||||
} else {
|
||||
$('#quantity_'+index).parent().append('<p style="text-align: right;" id="max_quantity_'+index+'">(Max: '+FormatNumber(c.availability*-1,c.precision)+')</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.precision) + ' ' + 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 = items.length;//$('#' + itemsTable + '_T tr').length - 1; // -1 - thead row
|
||||
var NO_ERROR = true;
|
||||
for (var index = 0; index < count; index++) {
|
||||
if ($('#type').val()=='6ed5b076-ddd1-9809-b236-54e5b2bcbd97') {
|
||||
var tmp = items[index].product_consignment_part;
|
||||
if (!tmp) tmp = '';
|
||||
if (tmp.length==0) NO_ERROR = false;
|
||||
}
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
//START:
|
||||
$(document).ready(
|
||||
function() {
|
||||
// confirm exit
|
||||
window.onbeforeunload = confirmExit;
|
||||
// prevent submit by enter press
|
||||
lockEnter();
|
||||
// categories
|
||||
getCategoriesList();
|
||||
// searchProductInput change
|
||||
$('#searchProductsInput').keyup(function() {
|
||||
searchProducts();
|
||||
});
|
||||
$("#stock").change(function() {
|
||||
$("#stock_id").val(($("#stock :selected").val()));
|
||||
});
|
||||
DrawHeaders();
|
||||
|
||||
$("#register_date").prop("disabled", true);
|
||||
$("#assigned_user_name").prop("disabled", true);
|
||||
$("#register_date_trigger").hide();
|
||||
$("#btn_assigned_user_name").hide();
|
||||
$("#btn_clr_assigned_user_name").hide();
|
||||
|
||||
if (($("#new_number").val() == true)
|
||||
&& ($("#duplicate").val() != true)) {
|
||||
generateNumber();
|
||||
} else if (($("#new_number").val() == true)
|
||||
&& ($("#duplicate").val() == true)) {
|
||||
generateNumber();
|
||||
getItems();
|
||||
}
|
||||
// handle setItems
|
||||
setITEMS = function() {
|
||||
var formname = 'EditView';
|
||||
if (check_form_(formname) == true) {
|
||||
SetTab('ITEMS');
|
||||
checkProducts();
|
||||
//disable stock change
|
||||
$("#stock").prop("disabled", true);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
});
|
||||
// handle save
|
||||
var check_form_ = check_form;
|
||||
check_form = function(formname) {
|
||||
|
||||
window.onbeforeunload = null;
|
||||
if (items.length == 0) {
|
||||
alert("Brak produktów");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($('#type').val() == '2dcd99ce-c2fe-6bbd-6d1a-5512a569c4e0' || $('#type').val() == '1') {
|
||||
$.each(items, function(i, v) {
|
||||
if (!v.product_id || v.product_id=="") return;
|
||||
if (!v.product_consignment_id || v.product_consignment_id=="") {
|
||||
alert("Nie wybrano partii");
|
||||
return false;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$(".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();
|
||||
|
||||
$(".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");
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
//START:
|
||||
$(document).ready(
|
||||
function() {
|
||||
DrawHeaders();
|
||||
getItems(false);
|
||||
});
|
||||
|
||||
768
modules/EcmStockDocCorrects/javascript/bimit_table.js
Normal file
768
modules/EcmStockDocCorrects/javascript/bimit_table.js
Normal file
@@ -0,0 +1,768 @@
|
||||
var itemsTable = 'itemsTable';
|
||||
var items = new Array();
|
||||
var displayArray = new Array();
|
||||
var searchedProducts = new Array();
|
||||
var ajax_url = "index.php?module=EcmStockDocCorrects&action=javahelper&to_pdf=1";
|
||||
|
||||
function FillTable(data, allReadOnly) {
|
||||
html = '';
|
||||
// loop throw data rows
|
||||
$
|
||||
.each(
|
||||
data,
|
||||
function(row_index, row) {
|
||||
|
||||
html += '<tr>';
|
||||
// and insert columns
|
||||
$
|
||||
.each(
|
||||
columns,
|
||||
function(col_index, column) {
|
||||
// row must have code and name
|
||||
if (!row.product_code
|
||||
|| row.product_code == ''
|
||||
|| !row.name
|
||||
|| row.name == '')
|
||||
return; // return in each =
|
||||
// continue in php for
|
||||
// loop
|
||||
// special types
|
||||
if (column.name == 'number') {
|
||||
html += '<td><input class="inputs" style="text-align: center;" type="text" id="number_'
|
||||
+ row_index
|
||||
+ '" name="number_'
|
||||
+ row_index
|
||||
+ '" readonly value="'
|
||||
+ (row_index + 1)
|
||||
+ '"/></td>';
|
||||
} else if (column.name == 'name') {
|
||||
html += '<td><textarea style="width: 100%; height: 100%;" id="name_'
|
||||
+ row_index
|
||||
+ '" name="name_'
|
||||
+ row_index + '"';
|
||||
if (allReadOnly)
|
||||
html += ' readonly';
|
||||
html += '>' + row.name
|
||||
+ '</textarea></td>';
|
||||
} else if (column.name == 'options') {
|
||||
if (allReadOnly)
|
||||
html += '<td></tr>';
|
||||
else {
|
||||
html += '<td>';
|
||||
// move up
|
||||
html += '<a onClick="moveUpRow('
|
||||
+ row_index
|
||||
+ ')" target="_blank"><img style="cursor:pointer;" src="modules/EcmStockDocCorrects/images/moverowup.gif"/></a>';
|
||||
html += ' ';
|
||||
// move down
|
||||
html += '<a onClick="moveDownRow('
|
||||
+ row_index
|
||||
+ ')" target="_blank"><img style="cursor:pointer;" src="modules/EcmStockDocCorrects/images/moverowdown.gif"/></a>';
|
||||
html += '<br>';
|
||||
// delete row
|
||||
html += '<a onClick="deleteRow('
|
||||
+ row_index
|
||||
+ ')" target="_blank"><img style="cursor:pointer;" src="modules/EcmStockDocCorrects/images/deleterow.gif"/></a>';
|
||||
html += '</td>';
|
||||
}
|
||||
}
|
||||
// other types
|
||||
else {
|
||||
html += '<td style="'+column.style+'">';
|
||||
$
|
||||
.each(
|
||||
column.content,
|
||||
function(
|
||||
cell_index,
|
||||
cell) {
|
||||
var cellname = column.name
|
||||
+ cell.name;
|
||||
if (cellname == 'product_link') {
|
||||
html += '<a href="index.php?module=EcmProducts&action=DetailView&record='
|
||||
+ row.product_id
|
||||
+ '" target="_blank">'
|
||||
+ row.product_code
|
||||
+ '</a>';
|
||||
} else if (cellname == 'price_start_div'
|
||||
&& !allReadOnly) {
|
||||
html += '<br><img style="cursor: pointer;" src="modules/EcmQuotes/images/search.gif" onClick="if ($(\'#price_start_div_'
|
||||
+ row_index
|
||||
+ '\').css(\'display\')==\'none\') getPricesInfo('
|
||||
+ row_index
|
||||
+ '); else $(\'#price_start_div_'
|
||||
+ row_index
|
||||
+ '\').hide(\'slow\')"/>';
|
||||
html += '<div id="'
|
||||
+ cellname
|
||||
+ '_'
|
||||
+ row_index
|
||||
+ '" style="display:none;float:right;text-align:right;border: 1px #cccccc solid;padding:3px;"></div>';
|
||||
} else {
|
||||
if (cell.label
|
||||
&& cell.label != '')
|
||||
html += '<p>'
|
||||
+ cell.label
|
||||
+ '</p>';
|
||||
html += '<input class="inputs" type="'
|
||||
+ cell.type
|
||||
+ '" name="'
|
||||
+ cellname
|
||||
+ '_'
|
||||
+ row_index
|
||||
+ '" id="'
|
||||
+ cellname
|
||||
+ '_'
|
||||
+ row_index
|
||||
+ '"';
|
||||
if (cell.readonly
|
||||
|| allReadOnly)
|
||||
html += ' readonly ';
|
||||
if (column.align)
|
||||
html += ' style="text-align: '
|
||||
+ column.align
|
||||
+ ';"';
|
||||
if (cell.precision) precision = cell.precision; else precision = 2;
|
||||
if (cell.onChange
|
||||
|| cell.isNumber) {
|
||||
if (cellname == 'quantity')
|
||||
precision = 4;
|
||||
html += ' onChange="$(this).val(FormatNumber($(this).val(),'+precision+'));'
|
||||
+ cell.onChange
|
||||
+ '" onClick="$(this).select();"';
|
||||
|
||||
}
|
||||
else if (cell.onChange
|
||||
|| !cell.isNumber)
|
||||
html += ' onChange="'
|
||||
+ cell.onChange
|
||||
+ '" ';
|
||||
if (row[cellname]
|
||||
&& cell.isNumber){
|
||||
if(cellname=='stock_state'){
|
||||
precision = 4;
|
||||
}
|
||||
html += ' value="'
|
||||
+ FormatNumber(row[cellname], precision)
|
||||
+ '" ';
|
||||
}else if (row[cellname])
|
||||
html += ' value="'
|
||||
+ row[cellname]
|
||||
+ '" ';
|
||||
else {
|
||||
if (cell.isNumber){
|
||||
if (cellname == 'quantity'){
|
||||
html += ' value="0,0000" ';
|
||||
} else {
|
||||
html += ' value="0,00" ';
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
html += ' value="" ';
|
||||
}
|
||||
html += '>';
|
||||
}
|
||||
});
|
||||
html += '</td>';
|
||||
}
|
||||
|
||||
});
|
||||
html += '</tr>';
|
||||
|
||||
});
|
||||
|
||||
$('#' + itemsTable + '_T > tbody').html(html);
|
||||
if (allReadOnly)
|
||||
DrawDetailSummary();
|
||||
|
||||
}
|
||||
function calculateAll() {
|
||||
var count = $('#' + itemsTable + '_T tr').length - 1; // -1 - thead row
|
||||
for (var index = 0; index != count; index++) {
|
||||
calculateRow(index);
|
||||
}
|
||||
}
|
||||
function calculateRow(index) {
|
||||
if (index == -1)
|
||||
return;
|
||||
items[index].quantity_consignment_id = $('#quantity_consignment_id_'+index).val();
|
||||
items[index].quantity_consignment_doc = $('#quantity_consignment_doc_'+index).val();
|
||||
getConsignmentsDiv(index);
|
||||
|
||||
if( ($('#type').val()=='2dcd99ce-c2fe-6bbd-6d1a-5512a569c4e0') || ($('#type').val()=='1')){
|
||||
getConsignmentsDiv(index);
|
||||
}
|
||||
// liczone według najlepszych zasad księgowości
|
||||
var price = UnformatNumber($('#price_' + index).val());
|
||||
var quantity = UnformatNumber($('#quantity_' + index).val());
|
||||
|
||||
|
||||
//alert(palet);
|
||||
var total = price * quantity;
|
||||
|
||||
// put data
|
||||
$('#product_total_' + index).val(FormatNumber(total));
|
||||
|
||||
// put data to items array
|
||||
items[index].price = toFixed(price, 2);
|
||||
|
||||
items[index].product_total = total;
|
||||
items[index].quantity = toFixed(quantity, 4);
|
||||
|
||||
items[index].name = $('#name_' + index).val();
|
||||
items[index].unit_name = $('#unit_name_' + index).val();
|
||||
|
||||
console.log(items[index]);
|
||||
|
||||
// calculate total
|
||||
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;
|
||||
|
||||
|
||||
for (var index = 0; index != count; index++) {
|
||||
subtotal = UnformatNumber($('#product_total_' + index).val());
|
||||
if(!isNaN(subtotal)){
|
||||
all_subtotal += subtotal;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
all_total = all_subtotal;
|
||||
|
||||
DrawSummary();
|
||||
|
||||
$("#t_netto").val(FormatNumber(all_total));
|
||||
|
||||
}
|
||||
function DrawSummary() {
|
||||
$("#result_table").html('');
|
||||
html = '';
|
||||
html += '<tr id="subtotal_tr"> ';
|
||||
html += '<td class="positionsLabel" style="border-top:0px;">Suma</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>';
|
||||
$("#result_table").html(html);
|
||||
}
|
||||
function deleteRow(index) {
|
||||
items.splice(index, 1);
|
||||
FillTable(items);
|
||||
}
|
||||
|
||||
function moveUpRow(index) {
|
||||
if (index == 0)
|
||||
return; // Can't go upper.. :(
|
||||
var new_index = index - 1;
|
||||
var old_index = index;
|
||||
if (new_index >= items.length) {
|
||||
var k = new_index - items.length;
|
||||
while ((k--) + 1) {
|
||||
items.push(undefined);
|
||||
}
|
||||
}
|
||||
items.splice(new_index, 0, items.splice(old_index, 1)[0]);
|
||||
FillTable(items);
|
||||
}
|
||||
|
||||
function moveDownRow(index) {
|
||||
if (index == items.length - 1)
|
||||
return; // Can't go lower.. :(
|
||||
var new_index = index + 1;
|
||||
var old_index = index;
|
||||
if (new_index >= items.length) {
|
||||
var k = new_index - items.length;
|
||||
while ((k--) + 1) {
|
||||
items.push(undefined);
|
||||
}
|
||||
}
|
||||
items.splice(new_index, 0, items.splice(old_index, 1)[0]);
|
||||
FillTable(items);
|
||||
}
|
||||
|
||||
function FormatNumber(number, precision) {
|
||||
|
||||
var precision = precision || 2;
|
||||
// make string..
|
||||
number = number + '';
|
||||
|
||||
var minus = false;
|
||||
if (number.charAt(0) == '-') {
|
||||
minus = true;
|
||||
number = number.slice(1);
|
||||
}
|
||||
|
||||
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("");
|
||||
// minus
|
||||
if (minus)
|
||||
c = '-' + c;
|
||||
|
||||
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 minus = false;
|
||||
value+='';
|
||||
if (value.charAt(0) == '-') {
|
||||
minus = true;
|
||||
value = value.slice(1);
|
||||
}
|
||||
|
||||
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');
|
||||
|
||||
// minus
|
||||
if (minus)
|
||||
integral = '-' + integral;
|
||||
|
||||
return precision ? integral + '.' + padding + fraction : integral;
|
||||
}
|
||||
|
||||
|
||||
// draw table
|
||||
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;height: 250px;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 + '%" style="'+column.style+'">' + 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>';
|
||||
// sort? why not!
|
||||
/*
|
||||
* html += 'Sortowanie: '; html += '<select id="sort_field"
|
||||
* onChange="sortTable();"'; html += '<option value=""></option>'; html += '<option
|
||||
* value="name">Nazwa</option>'; html += '<option value="code">Kod</option>';
|
||||
* html += '<option value="category">Kategoria</option>'; html += '<option
|
||||
* value="category">Kategoria</option>'; html += '<option
|
||||
* value="price">Cena po<br>upuście</option>'; html += '<option
|
||||
* value="total">Wartość</option>'; html += '</select>';
|
||||
*/
|
||||
$('#' + itemsTable).html(html);
|
||||
}
|
||||
function searchProducts() {
|
||||
var searchKey = $('#searchProductsInput').val();
|
||||
if (searchKey.length < 2 && searchKey != '%') {
|
||||
return;
|
||||
}
|
||||
$("#searchResultDiv").html(
|
||||
'<img src="modules/EcmQuotes/images/loading.gif"/>');
|
||||
setTimeout(function() {
|
||||
if (searchKey == $('#searchProductsInput').val()) {
|
||||
var params = {
|
||||
job : 'searchProducts',
|
||||
searchKey : searchKey,
|
||||
searchCategory : $("#productSearchCategory :selected").val(),
|
||||
searchStock : $("#productSearchStock :selected").val(),
|
||||
searchSort : $("#productSearchSort :selected").val(),
|
||||
searchStockId : $("#stock :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 = '<table style="text-align: center;" cellpadding="0" cellspacing="0" width="100%" border="0" class="list view">';
|
||||
html += '<theader><tr>';
|
||||
html += '<th style="width: 15pt; margin: auto auto;"> </th>';
|
||||
html += '<th style="width: 100pt; text-align: left;">Kod</th>';
|
||||
html += '<th style="width: 300pt; text-align: left;">Nazwa</th>';
|
||||
if ($("#productSearchStock :selected").val() != '1')
|
||||
html += '<th style="width: 30pt; text-align: right;">Stan</th>';
|
||||
|
||||
html += '</tr></thead>';
|
||||
var counter;
|
||||
$
|
||||
.each(
|
||||
data,
|
||||
function(index, value) {
|
||||
if(counter%2==0){
|
||||
html += '<tr style="height: 15pt;" class="oddListRowS1">';
|
||||
} else {
|
||||
html += '<tr style="height: 15pt;" class="evenListRowS1">';
|
||||
}
|
||||
html += '<td style=""><input id="prod_'
|
||||
+ value.id + '" type="checkbox"/></td>';
|
||||
html += '<td style="text-align:left" onClick="$(\'#prod_'
|
||||
+ value.id
|
||||
+ '\').prop(\'checked\', true);">'
|
||||
+ value.code + '</td>';
|
||||
html += '<td style="text-align:left" onClick="unsetAllCheckboxes(); $(\'#prod_'
|
||||
+ value.id
|
||||
+ '\').prop(\'checked\', true); return addProducts();">'
|
||||
+ value.name + '</td>';
|
||||
if ($("#productSearchStock :selected").val() != '1')
|
||||
html += '<td style="text-align:right">'
|
||||
+ value.stock_state + '</td>';
|
||||
html += '</tr>';
|
||||
searchedProducts.push(value.id);
|
||||
counter++;
|
||||
});
|
||||
// add button
|
||||
html += '</table><br>';
|
||||
html += 'Ilość: <input type="text" id="searchInputQty" value=""/>';
|
||||
html += '<br><br><input type="button" value="Dodaj wiele" onClick="return addProducts();"/>';
|
||||
$('#searchResultDiv').html(html);
|
||||
}
|
||||
|
||||
function unsetAllCheckboxes() {
|
||||
$("#searchResultDiv input[type=checkbox]").each(function() {
|
||||
$(this).prop("checked", false);
|
||||
});
|
||||
}
|
||||
|
||||
function addProducts() {
|
||||
$(".loading_panel").css("display", "block");
|
||||
var products = new Array();
|
||||
$.each(searchedProducts, function(index, value) {
|
||||
if ($('#prod_' + value).is(':checked'))
|
||||
products[value] = true;
|
||||
});
|
||||
var stockId=$("#stock :selected").val();
|
||||
for ( var key in products) {
|
||||
var params = {
|
||||
job : 'getProduct',
|
||||
id : key,
|
||||
stockId : stockId,
|
||||
};
|
||||
$.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.product_category_id = data.product_category_id;
|
||||
if ($("#searchInputQty").val() != ''
|
||||
&& !isNaN(parseFloat(UnformatNumber($(
|
||||
"#searchInputQty").val()))))
|
||||
p.quantity = $("#searchInputQty").val();
|
||||
items.push(p);
|
||||
console.log(p);
|
||||
}
|
||||
},
|
||||
data : params
|
||||
});
|
||||
}
|
||||
FillTable(items);
|
||||
// clear results
|
||||
calculateAll();
|
||||
$('#searchResultDiv').html('');
|
||||
searchedProducts = new Array();
|
||||
$('#searchProductsInput').val('');
|
||||
|
||||
$(".loading_panel").css("display", "none");
|
||||
}
|
||||
|
||||
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",
|
||||
success : function(data) {
|
||||
items = data;
|
||||
if (editview)
|
||||
FillTable(items, false);
|
||||
else
|
||||
FillTable(items, true);
|
||||
$(".loading_panel").css("display", "none");
|
||||
},
|
||||
data : params
|
||||
});
|
||||
}
|
||||
|
||||
function DrawDetailSummary() {
|
||||
$("#result_table").html('');
|
||||
html = '';
|
||||
html += '<tr id="subtotal_tr"> ';
|
||||
html += '<td class="positionsLabel" style="border-top:0px;">Suma dokumentu</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=\''
|
||||
+ $("#doc_total").val() + '\'></td>';
|
||||
html += '</tr>';
|
||||
html += '<tr id="discount_tr"> ';
|
||||
html += '<td class="positionsLabel">Suma operacji: wyjście</td>';
|
||||
html += '<td class="positionsField"><input type="text" readonly="readonly" style="border:0px;font-weight:900;width:100%;text-align:right;" name="disc" id="disc" value=\''
|
||||
+ $("#operations_out").val() + '\'></td>';
|
||||
html += '</tr>';
|
||||
html += '<tr id="total_tr"> ';
|
||||
html += '<td class="positionsLabel">Suma operacji: wejście</td>';
|
||||
html += '<td class="positionsField"><input type="text" readonly="readonly" style="border:0px;font-weight:900;width:100%;text-align:right;" name="t_brutto" id="t_brutto" value=\''
|
||||
+ $("#operations_in").val() + '\'></td>';
|
||||
html += '</tr>';
|
||||
html += '<tr id="total_tr"> ';
|
||||
html += '<td class="positionsLabel"><a href="index.php?module=EcmStockOperations&custom_parent_id='
|
||||
+ $("input[name=record]").val()
|
||||
+ '" target="blank">Podgląd operacji magazynowych</a></td>';
|
||||
html += '<td class="positionsField"> </td>';
|
||||
html += '</tr>';
|
||||
$("#result_table").html(html);
|
||||
}
|
||||
|
||||
function generateNumber() {
|
||||
var params = {
|
||||
job : 'generateNumber'
|
||||
};
|
||||
$.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 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,4));
|
||||
},
|
||||
data : params
|
||||
});
|
||||
}
|
||||
|
||||
function checkProducts() {
|
||||
var count = items.length;
|
||||
var error = false; // hope :)
|
||||
for (var index = 0; index != count; index++) {
|
||||
refreshStock(index);
|
||||
var qty = UnformatNumber($("#quantity_" + index).val());
|
||||
var cat_id = $("#product_category_id_" + index).val();
|
||||
var con_qty = items[index].product_consignment_qty;
|
||||
// refresh items array
|
||||
var price_new = UnformatNumber($("#price_" + index).val());
|
||||
var price_old = UnformatNumber($("#price_old_" + index).val());
|
||||
items[index].quantity = qty;
|
||||
items[index].price = UnformatNumber($("#price_" + index).val());
|
||||
var stock = UnformatNumber($("#stock_state_" + index).val());
|
||||
|
||||
if ($('#product_is_consignment_' + index).val() != '1' && $('#product_consignment_id_' + index).val()=='' ) {
|
||||
con_qty=stock;
|
||||
}
|
||||
|
||||
if ($('#type').val() == '2dcd99ce-c2fe-6bbd-6d1a-5512a569c4e0') {
|
||||
if($('#product_consignment_id_' + index).val()==''){
|
||||
error=true;
|
||||
alert("Można przecenić tylko konkretną pozycje!");
|
||||
}
|
||||
if(qty<=0 || con_qty<qty || price_new==price_old || price_new<=0){
|
||||
error = true;
|
||||
$("#quantity_" + index).css("color", "red");
|
||||
|
||||
} else {
|
||||
$("#quantity_" + index).css("color", "black");
|
||||
}
|
||||
} else
|
||||
if ($('#type').val() == '1') {
|
||||
if(qty>=0){
|
||||
|
||||
|
||||
$("#quantity_" + index).css("color", "red");
|
||||
|
||||
} else {
|
||||
if(Math.abs(qty)>con_qty){
|
||||
console.log("czemu?");
|
||||
console.log(Math.abs(qty));
|
||||
console.log(con_qty);
|
||||
error = true;
|
||||
$("#quantity_" + index).css("color", "red");
|
||||
} else {
|
||||
$("#quantity_" + index).css("color", "black");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(qty<=0 || price_new<=0){
|
||||
error = true;
|
||||
$("#quantity_" + index).css("color", "red");
|
||||
|
||||
} else {
|
||||
$("#quantity_" + index).css("color", "black");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
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");
|
||||
}
|
||||
|
||||
// sortable rows in main table
|
||||
$("#" + itemsTable + " tbody").sortable();
|
||||
114
modules/EcmStockDocCorrects/javascript/columndefs-detail.js
Normal file
114
modules/EcmStockDocCorrects/javascript/columndefs-detail.js
Normal file
@@ -0,0 +1,114 @@
|
||||
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' : 'Kod',
|
||||
'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
|
||||
};
|
||||
// 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();'
|
||||
};
|
||||
columns[3]['content'][1] = {
|
||||
'name' : '_consignment_doc',
|
||||
'type' : 'text',
|
||||
};
|
||||
// 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
|
||||
162
modules/EcmStockDocCorrects/javascript/columndefs.js
Normal file
162
modules/EcmStockDocCorrects/javascript/columndefs.js
Normal file
@@ -0,0 +1,162 @@
|
||||
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' : 'Kod',
|
||||
'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'][3] = {
|
||||
'name' : 'total',
|
||||
'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());'
|
||||
};
|
||||
columns[3]['content'][1] = {
|
||||
'name' : '_consignment_doc',
|
||||
'type' : 'text',
|
||||
|
||||
};
|
||||
columns[3]['content'][2] = {
|
||||
'name' : '_consignment_id',
|
||||
'type' : 'hidden',
|
||||
};
|
||||
// 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());'
|
||||
};
|
||||
columns[4]['content'][1] = {
|
||||
'name' : '_old',
|
||||
'type' : 'text',
|
||||
'isNumber' : true,
|
||||
'readonly': true,
|
||||
};
|
||||
// end: price
|
||||
// begin: unit
|
||||
columns[5] = {
|
||||
'name' : 'unit_',
|
||||
'label' : 'J.M.',
|
||||
'width' : 5,
|
||||
'content' : new Array(),
|
||||
'align' : 'center',
|
||||
};
|
||||
columns[5]['content'][0] = {
|
||||
'name' : 'name',
|
||||
'type' : 'text',
|
||||
'readonly' : true
|
||||
};
|
||||
columns[5]['content'][1] = {
|
||||
'name' : 'id',
|
||||
'type' : 'hidden'
|
||||
};
|
||||
// end: unit
|
||||
// begin: stock_state
|
||||
columns[6] = {
|
||||
'name' : 'stock_state',
|
||||
'label' : 'Stan',
|
||||
'width' : 5,
|
||||
'content' : new Array(),
|
||||
'align' : 'right',
|
||||
};
|
||||
columns[6]['content'][0] = {
|
||||
'name' : '',
|
||||
'type' : 'text',
|
||||
'isNumber' : true,
|
||||
'readonly' : true
|
||||
};
|
||||
// end: stock_state
|
||||
// begin: options
|
||||
columns[7] = {
|
||||
'name' : 'ecmvat_',
|
||||
'label' : 'VAT (%)',
|
||||
'width' : 0,
|
||||
'style' : 'display:none',
|
||||
'content' : new Array(),
|
||||
'align' : 'right',
|
||||
};
|
||||
columns[7]['content'][0] = {
|
||||
'name' : 'name',
|
||||
'type' : 'hidden'
|
||||
};
|
||||
columns[7]['content'][1] = {
|
||||
'name' : 'value',
|
||||
'type' : 'hidden'
|
||||
};
|
||||
columns[7]['content'][2] = {
|
||||
'name' : 'id',
|
||||
'type' : 'hidden'
|
||||
};
|
||||
columns[8] = {
|
||||
'name' : 'options',
|
||||
'label' : 'Opcje',
|
||||
'width' : 3,
|
||||
'content' : new Array(),
|
||||
};
|
||||
320
modules/EcmStockDocCorrects/javascript/helper.php
Normal file
320
modules/EcmStockDocCorrects/javascript/helper.php
Normal file
@@ -0,0 +1,320 @@
|
||||
<?php
|
||||
if (! defined ( 'sugarEntry' ) || ! sugarEntry)
|
||||
die ( '-1' );
|
||||
if (! $_POST ['job'] || $_POST ['job'] == '')
|
||||
die ( '-1' );
|
||||
switch ($_POST ['job']) {
|
||||
case 'getParentInfo' :
|
||||
getParentInfo ( $_POST ['id'], $_POST ['type'] );
|
||||
break;
|
||||
case 'generateNumber' :
|
||||
generateNumber ();
|
||||
break;
|
||||
case 'searchProducts' :
|
||||
searchProducts ( $_POST ['searchKey'], $_POST ['searchCategory'], $_POST ['searchStock'], $_POST ['searchSort'], $_POST ['searchStockId'] );
|
||||
break;
|
||||
case 'getProduct' :
|
||||
getProduct ( $_POST ['id'], $_POST ['stockId'] );
|
||||
break;
|
||||
case 'getItems' :
|
||||
getItems ( $_POST ['record'] );
|
||||
break;
|
||||
case 'getCategoriesList' :
|
||||
getCategoriesList ();
|
||||
break;
|
||||
case 'getTranslation' :
|
||||
getTranslation ( $_POST ['product_id'], $_POST ['language'], $_REQUEST ['unit_id'] );
|
||||
break;
|
||||
case 'getPricesInfo' :
|
||||
getPricesInfo ( $_POST ['product_id'], $_POST ['pricebook_id'], $_POST ['account_id'] );
|
||||
break;
|
||||
case 'getStockArray' :
|
||||
getStockArray ( $_POST ['product_id'] );
|
||||
break;
|
||||
case 'getPurchaseArray' :
|
||||
getPurchaseArray ( $_POST ['product_id'] );
|
||||
break;
|
||||
case 'getStockState' :
|
||||
getStockState ( $_POST ['id'], $_POST ['stockId'] );
|
||||
break;
|
||||
case 'getComponents' :
|
||||
getComponents ( $_POST ['product_id'] );
|
||||
break;
|
||||
case 'getConsignments' :
|
||||
getConsignments ( $_POST ['prod_id'], $_REQUEST ['stock_id'] );
|
||||
break;
|
||||
case 'getConsignmentsDocs' :
|
||||
getConsignmentsDocs ( $_POST ['prod_id'], $_REQUEST ['stock_id'] );
|
||||
break;
|
||||
}
|
||||
function generateNumber() {
|
||||
$data = array ();
|
||||
$data ['number'] = EcmStockDocCorrect::generateNumber ();
|
||||
$data ['document_no'] = EcmStockDocCorrect::formatNumber ( $data ['number'] );
|
||||
echo json_encode ( $data );
|
||||
unset ( $data );
|
||||
return;
|
||||
}
|
||||
function searchProducts($searchKey, $searchCategory, $searchStock, $searchSort, $searchStockId) {
|
||||
$db = $GLOBALS ['db'];
|
||||
$q = "SELECT id, code, name FROM ecmproducts WHERE
|
||||
(UPPER(code) LIKE '%$searchKey%' OR
|
||||
UPPER(name) LIKE '%$searchKey%')
|
||||
AND deleted='0' ";
|
||||
if ($searchCategory && $searchCategory != "")
|
||||
$q .= "AND product_category_id='$searchCategory' ";
|
||||
|
||||
if ($searchSort == '1')
|
||||
$q .= "ORDER BY code";
|
||||
else if ($searchSort == '2')
|
||||
$q .= "ORDER BY code DESC";
|
||||
else if ($searchSort == '3')
|
||||
$q .= "ORDER BY name";
|
||||
else if ($searchSort == '4')
|
||||
$q .= "ORDER BY name DESC";
|
||||
|
||||
// $q .= " LIMIT 0,50";
|
||||
|
||||
$res = $db->query ( $q );
|
||||
$result = array ();
|
||||
|
||||
$stock_id = $searchStockId;
|
||||
|
||||
while ( $row = $db->fetchByAssoc ( $res ) ) {
|
||||
$tmp = array ();
|
||||
$tmp ['id'] = $row ['id'];
|
||||
$tmp ['name'] = $row ['name'];
|
||||
$tmp ['code'] = $row ['code'];
|
||||
|
||||
// get stock if necessary
|
||||
if ($searchStock != '1') {
|
||||
$tmp ['stock_state'] = EcmStockOperation::getStock ( $row ['id'], $stock_id );
|
||||
}
|
||||
|
||||
if ($searchStock == '3' && $tmp ['stock_state'] == 0)
|
||||
continue; // don't show null stock
|
||||
|
||||
$result [] = $tmp;
|
||||
}
|
||||
echo json_encode ( $result );
|
||||
return;
|
||||
}
|
||||
function getProduct($id, $stockId) {
|
||||
$db = $GLOBALS ['db'];
|
||||
$p = $db->fetchByAssoc ( $db->query ( "SELECT p.id, p.code, p.name, p.unit_id, p.product_category_id,v.id as ecmvat_id, v.name as ecmvat_name, v.value as ecmvat_value FROM ecmproducts as p INNER JOIN ecmvats as v ON v.id=p.vat_id WHERE p.id='$id'" ) );
|
||||
global $app_list_strings;
|
||||
$p ['unit_name'] = $app_list_strings ['ecmproducts_unit_dom'] [$p ['unit_id']];
|
||||
$p ['stock_state'] = $tmp ['stock_state'] = EcmStockOperation::getStock ( $id, $stockId );
|
||||
|
||||
echo json_encode ( $p );
|
||||
return;
|
||||
}
|
||||
function getItems($record) {
|
||||
$mm = new EcmStockDocCorrect ();
|
||||
$mm->retrieve ( $record );
|
||||
$pl = $mm->getPositionList ( true );
|
||||
unset ( $mm );
|
||||
echo json_encode ( $pl );
|
||||
return;
|
||||
}
|
||||
function getCategoriesList() {
|
||||
$db = $GLOBALS ['db'];
|
||||
$res = $db->query ( "SELECT id, name FROM ecmproductcategories WHERE deleted='0'" );
|
||||
$result = array ();
|
||||
while ( $row = $db->fetchByAssoc ( $res ) ) {
|
||||
$tmp = array ();
|
||||
$tmp ['id'] = $row ['id'];
|
||||
$tmp ['name'] = $row ['name'];
|
||||
$result [] = $tmp;
|
||||
}
|
||||
echo json_encode ( $result );
|
||||
return;
|
||||
}
|
||||
function getTranslation($product_id, $language, $unit_id) {
|
||||
$db = $GLOBALS ['db'];
|
||||
$result = array ();
|
||||
if ($language == 'en_us') {
|
||||
$r = $db->fetchByAssoc ( $db->query ( "SELECT short_description FROM ecmproduct_language WHERE ecmproduct_id='$product_id' AND language='en'" ) );
|
||||
$result ['name'] = htmlspecialchars_decode ( $r ['short_description'] );
|
||||
} else if ($language == 'pl_pl') {
|
||||
$p = new EcmProduct ();
|
||||
$p->retrieve ( $product_id );
|
||||
$result ['name'] = htmlspecialchars_decode ( $p->name );
|
||||
unset ( $p );
|
||||
}
|
||||
$lists = return_app_list_strings_language ( $language );
|
||||
$result ['unit_name'] = $lists ['ecmproducts_unit_dom'] [$unit_id];
|
||||
unset ( $lists );
|
||||
|
||||
echo json_encode ( $result );
|
||||
return;
|
||||
}
|
||||
function getPricesInfo($product_id, $pricebook_id, $account_id) {
|
||||
$db = $GLOBALS ['db'];
|
||||
|
||||
$result = array ();
|
||||
if ($pricebook_id && $pricebook_id != '') {
|
||||
// try get price from pricebook
|
||||
$res = $db->fetchByAssoc ( $db->query ( "SELECT price FROM ecmpricebooks_ecmproducts WHERE ecmpricebook_id='$pricebook_id' AND ecmproduct_id='$product_id' AND deleted='0'" ) );
|
||||
if ($res ['price'] && $res ['price'] != '' && $res ['price'] != 0) {
|
||||
$tmp = array ();
|
||||
$tmp ['name'] = 'pricebook';
|
||||
$tmp ['price'] = $res ['price'];
|
||||
$result [] = $tmp;
|
||||
}
|
||||
}
|
||||
|
||||
// get from ecmprices
|
||||
$res = $db->query ( "SELECT p.name, pp.price FROM ecmprices_ecmproducts AS pp
|
||||
INNER JOIN ecmprices AS p
|
||||
ON p.id=pp.ecmprice_id
|
||||
WHERE
|
||||
pp.ecmproduct_id='$product_id'
|
||||
AND pp.price!=0" );
|
||||
while ( $row = $db->fetchByAssoc ( $res ) ) {
|
||||
$tmp = array ();
|
||||
$tmp ['name'] = $row ['name'];
|
||||
$tmp ['price'] = $row ['price'];
|
||||
$result [] = $tmp;
|
||||
}
|
||||
|
||||
// get last invoice price
|
||||
if ($account_id && $account_id != '') {
|
||||
$res = $db->fetchByAssoc ( $db->query ( "SELECT ii.subprice, i.id, i.document_no FROM ecminvoiceoutitems AS ii
|
||||
INNER JOIN ecminvoiceouts AS i
|
||||
ON ii.ecminvoiceout_id=i.id
|
||||
WHERE ii.ecmproduct_id='$product_id'
|
||||
AND i.parent_id='$account_id'
|
||||
AND ii.deleted='0'
|
||||
AND i.deleted='0'
|
||||
AND i.canceled='0'
|
||||
ORDER BY i.register_date DESC
|
||||
LIMIT 0,1" ) );
|
||||
if ($res && $res ['subprice'] != '') {
|
||||
$tmp = array ();
|
||||
$tmp ['name'] = $res ['document_no'];
|
||||
$tmp ['price'] = $res ['subprice'];
|
||||
$result [] = $tmp;
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode ( $result );
|
||||
return;
|
||||
}
|
||||
function getStockArray($product_id) {
|
||||
$o = new EcmStockOperation ();
|
||||
echo json_encode ( $o->getStockArray ( $product_id ) );
|
||||
unset ( $o );
|
||||
return;
|
||||
}
|
||||
function getPurchaseArray($product_id) {
|
||||
$o = new EcmStockOperation ();
|
||||
echo json_encode ( $o->getPurchaseArray ( $product_id ) );
|
||||
unset ( $o );
|
||||
return;
|
||||
}
|
||||
function getStockState($id, $stock_id) {
|
||||
echo EcmStockOperation::getStock ( $id, $stock_id );
|
||||
return;
|
||||
}
|
||||
function getComponents($product_id) {
|
||||
$p = new EcmProduct ();
|
||||
$p->retrieve ( $product_id );
|
||||
echo json_encode ( $p->getPositionList ( true ) );
|
||||
return;
|
||||
}
|
||||
function getConsignments($prod_id, $stock_id) {
|
||||
$documents_map = array (
|
||||
'EcmStockDocIns' => 'PZ',
|
||||
'EcmStockDocCorrects' => 'KS',
|
||||
'EcmStockDocMoves' => 'MM',
|
||||
'EcmStockDocInsideIns' => 'PW'
|
||||
);
|
||||
|
||||
$db = $GLOBALS ['db'];
|
||||
$query = "
|
||||
select i.id, i.parent_id, i.parent_type, i.parent_name, i.price, i.quantity as in_qty, ifnull(sum(o.quantity),0) as out_qty, p.unit_id
|
||||
from ecmstockoperations as i
|
||||
left join ecmstockoperations as o
|
||||
on i.id = o.in_id
|
||||
inner join ecmproducts as p
|
||||
on i.product_id = p.id
|
||||
where
|
||||
i.product_id='$prod_id' and
|
||||
i.stock_id='$stock_id' and
|
||||
i.used = '0' and
|
||||
i.type='0'
|
||||
group by i.id
|
||||
order by i.date_entered;
|
||||
";
|
||||
$res = $db->query ( $query );
|
||||
$result = array ();
|
||||
global $app_list_strings, $sugar_config;
|
||||
while ( $row = $db->fetchByAssoc ( $res ) ) {
|
||||
$availability = (floatval ( $row ['in_qty'] ) - floatval ( $row ['out_qty'] ));
|
||||
if ($availability <= 0)
|
||||
continue;
|
||||
|
||||
$tmp = array ();
|
||||
$tmp ['operation_id'] = $row ['id'];
|
||||
$tmp ['document_no'] = $documents_map [$row ['parent_type']] . ' ' . $row ['parent_name'];
|
||||
$tmp ['availability'] = $availability;
|
||||
$tmp ['parent_id'] = $row ['parent_id'];
|
||||
$tmp ['parent_type'] = $row ['parent_type'];
|
||||
$tmp ['price'] = $row ['price'];
|
||||
$tmp ['unit'] = $app_list_strings ['ecmproducts_unit_dom'] [$row ['unit_id']];
|
||||
$tmp ['currency'] = $sugar_config ['default_currency_iso4217'];
|
||||
|
||||
$result [] = $tmp;
|
||||
}
|
||||
echo json_encode ( $result );
|
||||
return;
|
||||
}
|
||||
function getConsignmentsDocs($prod_id, $stock_id) {
|
||||
$documents_map = array (
|
||||
'EcmStockDocIns' => 'PZ',
|
||||
'EcmStockDocCorrects' => 'KS',
|
||||
'EcmStockDocMoves' => 'MM',
|
||||
'EcmStockDocInsideIns' => 'PW'
|
||||
);
|
||||
|
||||
$db = $GLOBALS ['db'];
|
||||
$query = "
|
||||
select i.id, i.parent_id, i.parent_type, i.parent_name, i.price, i.quantity as in_qty, ifnull(sum(o.quantity),0) as out_qty, p.unit_id
|
||||
from ecmstockoperations as i
|
||||
left join ecmstockoperations as o
|
||||
on i.id = o.in_id
|
||||
inner join ecmproducts as p
|
||||
on i.product_id = p.id
|
||||
where
|
||||
i.product_id='$prod_id' and
|
||||
i.stock_id='$stock_id' and
|
||||
i.used = '0' and
|
||||
i.type='0'
|
||||
group by i.id
|
||||
order by i.date_entered;
|
||||
";
|
||||
$res = $db->query ( $query );
|
||||
$result = array ();
|
||||
global $app_list_strings, $sugar_config;
|
||||
while ( $row = $db->fetchByAssoc ( $res ) ) {
|
||||
$availability = (floatval ( $row ['in_qty'] ) - floatval ( $row ['out_qty'] ));
|
||||
if ($availability <= 0)
|
||||
continue;
|
||||
|
||||
$tmp = array ();
|
||||
$tmp ['operation_id'] = $row ['id'];
|
||||
$tmp ['part_no'] = $documents_map [$row ['parent_type']] . ' ' . $row ['parent_name'];
|
||||
$tmp ['availability'] = round($availability,4);
|
||||
$tmp ['parent_id'] = $row ['parent_id'];
|
||||
$tmp ['parent_type'] = $row ['parent_type'];
|
||||
$tmp ['price'] = $row ['price'];
|
||||
$tmp ['unit'] = $app_list_strings ['ecmproducts_unit_dom'] [$row ['unit_id']];
|
||||
$tmp ['precision'] = 4;
|
||||
$tmp ['currency'] = $sugar_config ['default_currency_iso4217'];
|
||||
|
||||
$result [] = $tmp;
|
||||
}
|
||||
echo json_encode ( $result );
|
||||
return;
|
||||
}
|
||||
Reference in New Issue
Block a user