| 4754 |
mandeep.dh |
1 |
function addNewRowForLineItem(table) {
|
|
|
2 |
$(table).find('#sample-lineitem').clone(true).insertAfter($(table).find('tbody>tr:last'));
|
|
|
3 |
|
|
|
4 |
var newRow = $(table).find('tbody>tr:last');
|
|
|
5 |
|
|
|
6 |
// Enabling the new record added
|
|
|
7 |
$(newRow).find('input').removeAttr('disabled');
|
|
|
8 |
$(newRow).removeAttr('id');
|
|
|
9 |
|
|
|
10 |
// Making this row visible
|
|
|
11 |
$(newRow).show();
|
|
|
12 |
}
|
|
|
13 |
|
|
|
14 |
function updateModelNameXferPrice(trElement, itemId, supplierId) {
|
|
|
15 |
$.ajax({
|
|
|
16 |
type : 'GET',
|
|
|
17 |
url : '/inventory/purchase-order!getModelNameXferPrice',
|
|
|
18 |
data : 'itemId=' + itemId + '&supplierId=' + supplierId,
|
|
|
19 |
success : function(response) {
|
|
|
20 |
$(trElement).find('div#modelName').html(response.split('~')[0]);
|
|
|
21 |
$(trElement).find('input[name="unitPrice"]').val(response.split('~')[1]);
|
| 7676 |
amar.kumar |
22 |
$(trElement).find('input[name="nlc"]').val(response.split('~')[2]);
|
| 13054 |
manish.sha |
23 |
$(trElement).find('input[name="mrp"]').val(response.split('~')[3]);
|
| 4754 |
mandeep.dh |
24 |
}
|
|
|
25 |
});
|
|
|
26 |
}
|
|
|
27 |
|
| 7410 |
amar.kumar |
28 |
function closePO(id){
|
|
|
29 |
$.ajax({
|
| 9925 |
amar.kumar |
30 |
type : 'POST',
|
| 7410 |
amar.kumar |
31 |
url : '/inventory/purchase-order!closePO',
|
|
|
32 |
data : 'id=' + id,
|
|
|
33 |
success : function(response) {
|
|
|
34 |
window.location.href = "/inventory/purchase-order";
|
|
|
35 |
},
|
|
|
36 |
error : function(response) {
|
|
|
37 |
alert("Error in closing PO");
|
|
|
38 |
}
|
|
|
39 |
});
|
|
|
40 |
}
|
|
|
41 |
|
| 9925 |
amar.kumar |
42 |
function openPO(id){
|
| 9416 |
amar.kumar |
43 |
$.ajax({
|
| 9925 |
amar.kumar |
44 |
type : 'POST',
|
|
|
45 |
url : '/inventory/purchase-order!openPO',
|
|
|
46 |
data : 'id=' + id,
|
|
|
47 |
success : function(response) {
|
|
|
48 |
window.location.href = "/inventory/purchase-order/"+id;
|
|
|
49 |
},
|
|
|
50 |
error : function(response) {
|
|
|
51 |
alert("Error in opening PO");
|
|
|
52 |
}
|
|
|
53 |
});
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
/**function changePOWarehouse(id){
|
|
|
58 |
$.ajax({
|
| 9416 |
amar.kumar |
59 |
type : 'GET',
|
|
|
60 |
url : '/inventory/purchase-order!changeWarehouseForPO',
|
| 9832 |
amar.kumar |
61 |
data : 'id=' + id + "&warehouseId="
|
| 9416 |
amar.kumar |
62 |
success : function(response) {
|
|
|
63 |
window.location.href = "/inventory/purchase-order";
|
|
|
64 |
},
|
|
|
65 |
error : function(response) {
|
|
|
66 |
alert("Error in changing PO Warehouse");
|
|
|
67 |
}
|
|
|
68 |
});
|
| 9925 |
amar.kumar |
69 |
}*/
|
| 9416 |
amar.kumar |
70 |
|
| 4754 |
mandeep.dh |
71 |
function updateTotalAmount(supplierId) {
|
|
|
72 |
var totalAmount = 0;
|
|
|
73 |
var totalQuantity = 0;
|
|
|
74 |
|
|
|
75 |
$('div#lineitems-' + supplierId + ' table tbody>tr').each(function(index, element) {
|
|
|
76 |
// Ignoring the first sample row
|
|
|
77 |
if (index == 0) {
|
|
|
78 |
return;
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
var price = $(element).find('input[name="unitPrice"]').val();
|
|
|
82 |
var quantity = $(element).find('input[name="quantity"]').val();
|
|
|
83 |
var amount = price * quantity;
|
|
|
84 |
totalAmount += amount;
|
|
|
85 |
totalQuantity += (1 * quantity);
|
|
|
86 |
var amountInput = $(element).find('div#amount');
|
|
|
87 |
$(amountInput).html(amount);
|
|
|
88 |
});
|
|
|
89 |
|
|
|
90 |
$('#total-amount-' + supplierId).html(totalAmount);
|
|
|
91 |
$('#total-quantity-' + supplierId).html(totalQuantity);
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
function validateForm() {
|
|
|
95 |
return true;
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
function submitPurchaseOrderForm(form) {
|
|
|
99 |
if (validateForm()) {
|
|
|
100 |
// index starts from zero, Also we need to ignore first sample row
|
|
|
101 |
$(form).find('tbody>tr').each(function(rowIndex, rowElement) {
|
|
|
102 |
// Skipping first sample row
|
|
|
103 |
if (rowIndex != 0) {
|
|
|
104 |
$(rowElement).find('input').each(function(inputIndex, inputElement) {
|
|
|
105 |
if ($(inputElement).attr('name').indexOf('lineItems[') == -1) {
|
|
|
106 |
$(inputElement).attr('name', 'lineItems[' + (rowIndex - 1) + '].' + $(inputElement).attr('name'));
|
|
|
107 |
}
|
|
|
108 |
});
|
|
|
109 |
}
|
|
|
110 |
});
|
|
|
111 |
|
|
|
112 |
$.ajax({
|
|
|
113 |
type : 'POST',
|
|
|
114 |
url : '/inventory/purchase-order',
|
|
|
115 |
data : $(form).serialize(),
|
|
|
116 |
success : function(response) {
|
|
|
117 |
var responseInteger = parseInt(response);
|
|
|
118 |
if (responseInteger > 0) {
|
|
|
119 |
document.location.href = '/inventory/purchase-order/' + responseInteger + '/edit';
|
|
|
120 |
}
|
|
|
121 |
else {
|
|
|
122 |
alert(response);
|
|
|
123 |
}
|
|
|
124 |
}
|
|
|
125 |
});
|
|
|
126 |
}
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
function submitEditPurchaseOrderForm(form, purchaseOrderId) {
|
|
|
130 |
if (validateForm()) {
|
|
|
131 |
// index starts from zero, Also we need to ignore first sample row
|
|
|
132 |
$(form).find('tbody>tr').each(function(rowIndex, rowElement) {
|
|
|
133 |
// Skipping first sample row
|
|
|
134 |
if (rowIndex != 0) {
|
|
|
135 |
$(rowElement).find('input').each(function(inputIndex, inputElement) {
|
|
|
136 |
if ($(inputElement).attr('name').indexOf('lineItems[') == -1) {
|
|
|
137 |
$(inputElement).attr('name', 'lineItems[' + (rowIndex - 1) + '].' + $(inputElement).attr('name'));
|
|
|
138 |
}
|
|
|
139 |
});
|
|
|
140 |
}
|
|
|
141 |
});
|
|
|
142 |
|
|
|
143 |
$.ajax({
|
|
|
144 |
type : 'POST',
|
|
|
145 |
url : '/inventory/purchase-order!update',
|
|
|
146 |
data : $(form).serialize(),
|
|
|
147 |
success : function(response) {
|
|
|
148 |
var responseInteger = parseInt(response);
|
|
|
149 |
if (responseInteger > 0) {
|
|
|
150 |
document.location.href = '/inventory/purchase-order/' + responseInteger + '/edit';
|
|
|
151 |
}
|
|
|
152 |
else {
|
|
|
153 |
alert(response);
|
|
|
154 |
}
|
|
|
155 |
}
|
|
|
156 |
});
|
|
|
157 |
}
|
| 13051 |
manish.sha |
158 |
}
|
| 17403 |
manish.sha |
159 |
|
| 25117 |
amit.gupta |
160 |
function updateModelNameInvoicePrice(inputElement, itemId, invoicePrice, poId) {
|
|
|
161 |
$.ajax({
|
|
|
162 |
type : 'GET',
|
|
|
163 |
url : '/inventory/purchase-order!updateItemInvoicePrice',
|
|
|
164 |
data : 'itemId=' + itemId + '&poId=' + poId + '&invoicePrice=' + invoicePrice,
|
|
|
165 |
success : function(response) {
|
|
|
166 |
$(inputElement).css('background-color', '#bfbfbf');
|
|
|
167 |
}
|
|
|
168 |
});
|
|
|
169 |
}
|
|
|
170 |
|
| 13054 |
manish.sha |
171 |
/*
|
| 13051 |
manish.sha |
172 |
function submitSetWeightForm(itemId,weight,poId){
|
|
|
173 |
$.ajax({
|
|
|
174 |
type : 'POST',
|
|
|
175 |
url : '/inventory/purchase-order!setWeightForItemProdAndStaging?itemId='+itemId+"&weightVal="+weight+"&poId="+poId,
|
|
|
176 |
success : function(response) {
|
|
|
177 |
document.location.href = '/inventory/purchase-order/' + $('.poId').val();
|
|
|
178 |
},
|
|
|
179 |
error : function() {
|
|
|
180 |
//alert("Error in refund");
|
|
|
181 |
document.location.href = '/inventory/purchase-order/' + $('.poId').val();
|
|
|
182 |
}
|
|
|
183 |
});
|
|
|
184 |
|
| 13054 |
manish.sha |
185 |
}*/
|