Rev 17425 | Blame | Compare with Previous | Last modification | View Log | RSS feed
function addNewRowForLineItem(table) {$(table).find('#sample-lineitem').clone(true).insertAfter($(table).find('tbody>tr:last'));var newRow = $(table).find('tbody>tr:last');// Enabling the new record added$(newRow).find('input').removeAttr('disabled');$(newRow).removeAttr('id');// Making this row visible$(newRow).show();}function updateModelNameXferPrice(trElement, itemId, supplierId) {$.ajax({type : 'GET',url : '/inventory/purchase-order!getModelNameXferPrice',data : 'itemId=' + itemId + '&supplierId=' + supplierId,success : function(response) {$(trElement).find('div#modelName').html(response.split('~')[0]);$(trElement).find('input[name="unitPrice"]').val(response.split('~')[1]);$(trElement).find('input[name="nlc"]').val(response.split('~')[2]);$(trElement).find('input[name="mrp"]').val(response.split('~')[3]);}});}function closePO(id){$.ajax({type : 'POST',url : '/inventory/purchase-order!closePO',data : 'id=' + id,success : function(response) {window.location.href = "/inventory/purchase-order";},error : function(response) {alert("Error in closing PO");}});}function openPO(id){$.ajax({type : 'POST',url : '/inventory/purchase-order!openPO',data : 'id=' + id,success : function(response) {window.location.href = "/inventory/purchase-order/"+id;},error : function(response) {alert("Error in opening PO");}});}/**function changePOWarehouse(id){$.ajax({type : 'GET',url : '/inventory/purchase-order!changeWarehouseForPO',data : 'id=' + id + "&warehouseId="success : function(response) {window.location.href = "/inventory/purchase-order";},error : function(response) {alert("Error in changing PO Warehouse");}});}*/function updateTotalAmount(supplierId) {var totalAmount = 0;var totalQuantity = 0;$('div#lineitems-' + supplierId + ' table tbody>tr').each(function(index, element) {// Ignoring the first sample rowif (index == 0) {return;}var price = $(element).find('input[name="unitPrice"]').val();var quantity = $(element).find('input[name="quantity"]').val();var amount = price * quantity;totalAmount += amount;totalQuantity += (1 * quantity);var amountInput = $(element).find('div#amount');$(amountInput).html(amount);});$('#total-amount-' + supplierId).html(totalAmount);$('#total-quantity-' + supplierId).html(totalQuantity);}function validateForm() {return true;}function submitPurchaseOrderForm(form) {if (validateForm()) {// index starts from zero, Also we need to ignore first sample row$(form).find('tbody>tr').each(function(rowIndex, rowElement) {// Skipping first sample rowif (rowIndex != 0) {$(rowElement).find('input').each(function(inputIndex, inputElement) {if ($(inputElement).attr('name').indexOf('lineItems[') == -1) {$(inputElement).attr('name', 'lineItems[' + (rowIndex - 1) + '].' + $(inputElement).attr('name'));}});}});$.ajax({type : 'POST',url : '/inventory/purchase-order',data : $(form).serialize(),success : function(response) {var responseInteger = parseInt(response);if (responseInteger > 0) {document.location.href = '/inventory/purchase-order/' + responseInteger + '/edit';}else {alert(response);}}});}}function submitEditPurchaseOrderForm(form, purchaseOrderId) {if (validateForm()) {// index starts from zero, Also we need to ignore first sample row$(form).find('tbody>tr').each(function(rowIndex, rowElement) {// Skipping first sample rowif (rowIndex != 0) {$(rowElement).find('input').each(function(inputIndex, inputElement) {if ($(inputElement).attr('name').indexOf('lineItems[') == -1) {$(inputElement).attr('name', 'lineItems[' + (rowIndex - 1) + '].' + $(inputElement).attr('name'));}});}});$.ajax({type : 'POST',url : '/inventory/purchase-order!update',data : $(form).serialize(),success : function(response) {var responseInteger = parseInt(response);if (responseInteger > 0) {document.location.href = '/inventory/purchase-order/' + responseInteger + '/edit';}else {alert(response);}}});}}function updateModelNameInvoicePrice(inputElement, itemId, invoicePrice, poId) {$.ajax({type : 'GET',url : '/inventory/purchase-order!updateItemInvoicePrice',data : 'itemId=' + itemId + '&poId=' + poId + '&invoicePrice=' + invoicePrice,success : function(response) {$(inputElement).css('background-color', '#bfbfbf');}});}/*function submitSetWeightForm(itemId,weight,poId){$.ajax({type : 'POST',url : '/inventory/purchase-order!setWeightForItemProdAndStaging?itemId='+itemId+"&weightVal="+weight+"&poId="+poId,success : function(response) {document.location.href = '/inventory/purchase-order/' + $('.poId').val();},error : function() {//alert("Error in refund");document.location.href = '/inventory/purchase-order/' + $('.poId').val();}});}*/