Add JS files
This commit is contained in:
258
modules/EcmStockDocInsideOuts/javascript/Consignments.js
Executable file
258
modules/EcmStockDocInsideOuts/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');
|
||||
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);
|
||||
if (items[index].product_is_consignment == '1')
|
||||
if (!items[index].product_consignment_id || items[index].product_consignment_id=='')
|
||||
getConsignmentsDiv(index);
|
||||
}
|
||||
|
||||
var getInsertConsignmentsDiv = function(index) {
|
||||
$('#consignments_div_' + index).remove(); // panel exists
|
||||
var part = '';
|
||||
if (items[index].product_consignment_part && items[index].product_consignment_part.length > 0)
|
||||
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();
|
||||
}
|
||||
|
||||
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);
|
||||
$('#product_consignment_qty_' + index).val(c.availability);
|
||||
$('#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,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 (items[index].product_is_consignment && 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;
|
||||
}
|
||||
111
modules/EcmStockDocInsideOuts/javascript/EcmStockDocInsideOuts.js
Executable file
111
modules/EcmStockDocInsideOuts/javascript/EcmStockDocInsideOuts.js
Executable file
@@ -0,0 +1,111 @@
|
||||
//START:
|
||||
$(document).ready(
|
||||
function() {
|
||||
// confirm exit
|
||||
var checkgen;
|
||||
window.onbeforeunload = confirmExit;
|
||||
// prevent submit by enter press
|
||||
lockEnter();
|
||||
// categories
|
||||
getCategoriesList();
|
||||
$("#stock").change(function() {
|
||||
$("#stock_id").val(($("#stock :selected").val()));
|
||||
});
|
||||
DrawHeaders();
|
||||
|
||||
//$("#register_date").prop("disabled", true);
|
||||
$("#assigned_user_name").prop("disabled", true);
|
||||
$("#btn_assigned_user_name").hide();
|
||||
$("#btn_clr_assigned_user_name").hide();
|
||||
$(".loading_panel").css("display", "none");
|
||||
|
||||
if (($("#new_number").val() == true)
|
||||
&& ($("#duplicate").val() != true)) {
|
||||
EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmStockDocInsideOuts');
|
||||
} else if (($("#new_number").val() == true)
|
||||
&& ($("#duplicate").val() == true)) {
|
||||
EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmStockDocInsideOuts');
|
||||
getItems();
|
||||
}
|
||||
|
||||
$("#stock").change(function() {
|
||||
$("#stock_id").val(($("#stock :selected").val()));
|
||||
EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmStockDocInsideOuts');
|
||||
});
|
||||
if($("#stock_id").val()!='') {
|
||||
$("#stock_id").val(($("#stock :selected").val()));
|
||||
EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmStockDocInsideOuts');
|
||||
}
|
||||
// handle setItems
|
||||
setITEMS = function() {
|
||||
var formname = 'EditView';
|
||||
if (check_form_(formname) == true) {
|
||||
SetTab('ITEMS');
|
||||
checkProducts();
|
||||
//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();
|
||||
|
||||
});
|
||||
// handle save
|
||||
var check_form_ = check_form;
|
||||
check_form = function(formname,event) {
|
||||
window.onbeforeunload = null;
|
||||
// zapobiega zapisywaniu dokumentu firefox bug, w przypadku nacisniecia enter w polu z autocomplete
|
||||
if(event.clientY==0 && event.clientX==0){
|
||||
return false;
|
||||
}
|
||||
if (items.length == 0 || items[0].product_id=='') {
|
||||
alert("Brak produktów");
|
||||
return false;
|
||||
}
|
||||
var consigns = checkConsignmentsValues();
|
||||
if (consigns != true) {
|
||||
setITEMS('ITEMS');
|
||||
alert('Brak wymaganych informacji o partiach produktu.');
|
||||
return false;
|
||||
}
|
||||
|
||||
$(".loading_panel").css("display", "block");
|
||||
$("#register_date").prop("disabled", false);
|
||||
$("#assigned_user_name").prop("disabled", false);
|
||||
|
||||
|
||||
|
||||
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 {
|
||||
clearEmpty();
|
||||
$("#position_list").val(JSON.stringifyNoSecurity(items));
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
7
modules/EcmStockDocInsideOuts/javascript/EcmStockDocInsideOutsDetail.js
Executable file
7
modules/EcmStockDocInsideOuts/javascript/EcmStockDocInsideOutsDetail.js
Executable file
@@ -0,0 +1,7 @@
|
||||
//START:
|
||||
$(document).ready(
|
||||
function() {
|
||||
DrawHeaders();
|
||||
getItems(false);
|
||||
});
|
||||
|
||||
555
modules/EcmStockDocInsideOuts/javascript/bimit_table.js
Executable file
555
modules/EcmStockDocInsideOuts/javascript/bimit_table.js
Executable file
@@ -0,0 +1,555 @@
|
||||
var itemsTable = 'itemsTable';
|
||||
var items = new Array();
|
||||
var displayArray = new Array();
|
||||
var searchedProducts = new Array();
|
||||
var ajax_url = "index.php?module=EcmStockDocInsideOuts&action=javahelper&to_pdf=1";
|
||||
|
||||
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>';
|
||||
// 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 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.unit_name = data.unit_name;
|
||||
p.unit_id = data.unit_id;
|
||||
p.stock_state = data.stock_state;
|
||||
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 ($("#searchInputQty").val() != ''
|
||||
&& !isNaN(parseFloat(UnformatNumber($(
|
||||
"#searchInputQty").val()))))
|
||||
p.quantity = $("#searchInputQty").val();
|
||||
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].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_is_consignment = data.is_consignment;
|
||||
items[index].stock_state = data.stock_state;
|
||||
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",
|
||||
success : function(data) {
|
||||
items = data;
|
||||
if (editview)
|
||||
FillTable(items, false);
|
||||
else {
|
||||
FillTable(items, true);
|
||||
var count = $('#' + itemsTable + '_T tr').length - 1; // -1 - thead row
|
||||
for (var index = 0; index != count; index++) {
|
||||
if (items[index].product_is_consignment) {
|
||||
$('#product_code_'+index).parent().append($( "<p>"+items[index].part_no+"</p>" ));
|
||||
}
|
||||
}
|
||||
}
|
||||
$(".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"><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',
|
||||
stock: $("#stock_id").val(),
|
||||
date : $("#register_date").val(),
|
||||
};
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url : ajax_url,
|
||||
dataType : "json",
|
||||
success : function(data) {
|
||||
if (data == '-1') {
|
||||
// try loading again
|
||||
generateNumber();
|
||||
} else {
|
||||
$("#document_no").val(data.document_no);
|
||||
$("#number").val(data.number);
|
||||
$(".loading_panel").css("display", "none");
|
||||
}
|
||||
},
|
||||
data : params
|
||||
});
|
||||
}
|
||||
function 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,$("#product_precision_" + index).val()));
|
||||
},
|
||||
data : params
|
||||
});
|
||||
}
|
||||
function setRowDate(index){
|
||||
var qty = UnformatNumber($("#quantity_" + index).val());
|
||||
items[index].quantity = qty;
|
||||
}
|
||||
function checkProducts() {
|
||||
//var count = $('#' + itemsTable + '_T tr').length - 1; // -1 - thead row
|
||||
var count = items.length;
|
||||
var error = false; // hope :)
|
||||
for (var index = 0; index != count; index++) {
|
||||
if($("#product_id_" + index).val()!=''){
|
||||
refreshStock(index);
|
||||
var qty = UnformatNumber($("#quantity_" + index).val());
|
||||
var cat_id = $("#product_category_id_" + index).val();
|
||||
var part_qty = $("#product_consignment_qty_" + index).val();
|
||||
// refresh items array
|
||||
items[index].quantity = qty;
|
||||
if ($('#product_is_consignment_' + index).val() != '1') {
|
||||
part_qty=qty;
|
||||
}
|
||||
var stock = UnformatNumber($("#stock_state_" + index).val());
|
||||
if (qty>0 && qty<=part_qty && qty<=stock){
|
||||
|
||||
$("#quantity_" + index).css("color", "black");
|
||||
} else {
|
||||
error = true;
|
||||
$("#quantity_" + 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 = 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.unit_name = value.unit_name;
|
||||
p.unit_id = value.unit_id;
|
||||
p.quantity = qty * parseInt(value.quantity);
|
||||
p.product_category_id = value.product_category_id;
|
||||
|
||||
if (p.product_category_id=='d7f876b0-1a3d-43a1-7c9b-511ba40df3d1')
|
||||
return;
|
||||
items.push(p);
|
||||
});
|
||||
};
|
||||
},
|
||||
data : params
|
||||
});
|
||||
FillTable(items);
|
||||
$(".loading_panel").css("display", "none");
|
||||
}
|
||||
function getPricesInfo(index) {
|
||||
$("#price_start_div_" + index).show('slow');
|
||||
$("#price_start_div_" + index).html(
|
||||
'<img src="modules/EcmQuotes/images/loading.gif"/>');
|
||||
|
||||
var params = {
|
||||
job : 'getPricesInfo',
|
||||
product_id : $("#product_id_" + index).val(),
|
||||
pricebook_id : $("#pricebook_id :selected").val(),
|
||||
account_id : $("#parent_id").val(),
|
||||
};
|
||||
$
|
||||
.ajax({
|
||||
type : "POST",
|
||||
url : ajax_url,
|
||||
dataType : "json",
|
||||
async : false,
|
||||
success : function(data) {
|
||||
html = '<ul style="font-size: 7pt;">';
|
||||
$
|
||||
.each(
|
||||
data,
|
||||
function(key, value) {
|
||||
if (value.name == 'pricebook') {
|
||||
html += '<li style="cursor:pointer;" onClick="$(\'#price_start_'
|
||||
+ index
|
||||
+ '\').val(\''
|
||||
+ FormatNumber(value.price)
|
||||
+ '\'); $(this).closest(\'div\').hide(\'slow\');calculateRow('
|
||||
+ index
|
||||
+ ')"><u>'
|
||||
+ $(
|
||||
"#pricebook_id :selected")
|
||||
.html()
|
||||
+ ': '
|
||||
+ FormatNumber(value.price)
|
||||
+ '</u></li>';
|
||||
} else if (value.name == $(
|
||||
"#ecmprice_name").val()) {
|
||||
html += '<li style="cursor:pointer;" onClick="$(\'#price_start_'
|
||||
+ index
|
||||
+ '\').val('
|
||||
+ value.price
|
||||
+ '); $(this).closest(\'div\').hide(\'slow\');calculateRow('
|
||||
+ index
|
||||
+ ');"><b>'
|
||||
+ value.name
|
||||
+ ': '
|
||||
+ FormatNumber(value.price)
|
||||
+ '</b></li>';
|
||||
} else {
|
||||
if(value.visible=='1'){
|
||||
html += '<li style="cursor:pointer;" onClick="$(\'#price_start_'
|
||||
+ index
|
||||
+ '\').val('
|
||||
+ value.price
|
||||
+ '); $(this).closest(\'div\').hide(\'slow\');calculateRow('
|
||||
+ index
|
||||
+ ');">'
|
||||
+ value.name
|
||||
+ ': ';
|
||||
if(value.module=='EcmPrices'){
|
||||
html+='<font style="color:#7FFF00;">'+FormatNumber(value.price)+'</font>';
|
||||
}
|
||||
if(value.module=='EcmInvoiceOuts'){
|
||||
html+='<font style="color:#FF3333;">'+FormatNumber(value.price)+'</font>';
|
||||
}
|
||||
html+ '</li>';
|
||||
}
|
||||
}
|
||||
});
|
||||
html += '</ul>';
|
||||
},
|
||||
data : params
|
||||
});
|
||||
$("#price_start_div_" + index).html(html);
|
||||
}
|
||||
|
||||
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 createProduct() {
|
||||
var newProdId = document.getElementById("newProductId");
|
||||
newProduct = window.open('index.php?module=EcmProducts&action=EditView&IamPopup=1', 'newProduct', 'toolbar=no,menubar=no,scrollbars=yes,scrollbars=1');
|
||||
newProduct.newProdId = newProdId;
|
||||
newProduct.focus();
|
||||
}
|
||||
// sortable rows in main table
|
||||
$("#" + itemsTable + " tbody").sortable();
|
||||
72
modules/EcmStockDocInsideOuts/javascript/columndefs-detail.js
Executable file
72
modules/EcmStockDocInsideOuts/javascript/columndefs-detail.js
Executable file
@@ -0,0 +1,72 @@
|
||||
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();'};
|
||||
//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
|
||||
85
modules/EcmStockDocInsideOuts/javascript/columndefs.js
Executable file
85
modules/EcmStockDocInsideOuts/javascript/columndefs.js
Executable file
@@ -0,0 +1,85 @@
|
||||
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'][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' : 'consignment_qty',
|
||||
'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':"setRowDate($(this).parent('td').parent('tr').index());"};
|
||||
//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: stock_state
|
||||
columns[5] = {
|
||||
'name' : 'stock_state',
|
||||
'label' : 'Stan',
|
||||
'width' : 5,
|
||||
'content' : new Array(),
|
||||
'align' : 'right',
|
||||
};
|
||||
columns[5]['content'][0] = {'name' : '', 'type': 'text', 'isNumber' : true};
|
||||
//end: stock_state
|
||||
//begin: options
|
||||
columns[6] = {
|
||||
'name' : 'options',
|
||||
'label' : 'Opcje',
|
||||
'width' : 3,
|
||||
'content' : new Array(),
|
||||
};
|
||||
4
modules/EcmStockDocInsideOuts/javascript/searchcolumndefs.js
Executable file
4
modules/EcmStockDocInsideOuts/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="EcmStockDocInsideOuts";
|
||||
Reference in New Issue
Block a user