| 30694 |
amit.gupta |
1 |
var grnhistory = grnhistory || {};
|
| 23343 |
ashik.ali |
2 |
grnhistory.searchText = "";
|
|
|
3 |
grnhistory.searchType = "";
|
|
|
4 |
grnhistory.startTime = "0";
|
|
|
5 |
grnhistory.endTime = "0";
|
|
|
6 |
|
| 30694 |
amit.gupta |
7 |
$(function () {
|
|
|
8 |
$(document).on('click', ".new_grn", function () {
|
| 23343 |
ashik.ali |
9 |
loadNewGrn("main-content");
|
|
|
10 |
});
|
|
|
11 |
|
| 30694 |
amit.gupta |
12 |
$(document).on('click', ".grn_history", function () {
|
| 30599 |
amit.gupta |
13 |
loadGrnHistory("main-content", "", "", moment(), moment);
|
| 23343 |
ashik.ali |
14 |
});
|
| 30694 |
amit.gupta |
15 |
|
|
|
16 |
$(document).on('click', ".pending_grn", function () {
|
| 23886 |
amit.gupta |
17 |
loadPendingGrn("main-content");
|
| 23343 |
ashik.ali |
18 |
});
|
|
|
19 |
|
| 30694 |
amit.gupta |
20 |
$(document).on('click', "td.startGrnSerialized", function () {
|
| 23343 |
ashik.ali |
21 |
var invoiceNumber = $(this).attr('invoiceNumber');
|
|
|
22 |
var quantity = $(this).attr('quantity');
|
|
|
23 |
var displayName = $(this).attr('displayName');
|
|
|
24 |
var itemId = $(this).attr('itemId');
|
|
|
25 |
console.log(quantity);
|
|
|
26 |
$(".modal-body .grnInvoiceNumber>span").text(invoiceNumber);
|
|
|
27 |
$(".modal-body .grnProductInfo>span").text(displayName);
|
|
|
28 |
$("#scanModel .invoiceNumber").val(invoiceNumber);
|
|
|
29 |
$("#scanModel .itemId").val(itemId);
|
| 30694 |
amit.gupta |
30 |
$("#grnImeiInformation").empty();
|
| 23343 |
ashik.ali |
31 |
var qty = parseInt(quantity);
|
|
|
32 |
var divCode = '<div class="row">CONTENT</div><p></p>';
|
| 30694 |
amit.gupta |
33 |
var innerDiv = '<div class="col-sm-3">' +
|
|
|
34 |
'<div class="input-group">' +
|
|
|
35 |
'<input type="text" class="form-control">' +
|
|
|
36 |
'</div>' +
|
|
|
37 |
'</div>';
|
|
|
38 |
while (qty != 0) {
|
|
|
39 |
var divText = "";
|
|
|
40 |
if (qty < 4) {
|
| 23343 |
ashik.ali |
41 |
var cp = qty;
|
| 30694 |
amit.gupta |
42 |
for (var i = 0; i < cp; i++) {
|
| 23343 |
ashik.ali |
43 |
divText = divText + innerDiv;
|
|
|
44 |
qty = qty - 1;
|
|
|
45 |
}
|
| 30694 |
amit.gupta |
46 |
} else {
|
|
|
47 |
for (var i = 0; i < 4; i++) {
|
| 23343 |
ashik.ali |
48 |
divText = divText + innerDiv;
|
|
|
49 |
qty = qty - 1;
|
|
|
50 |
}
|
|
|
51 |
}
|
| 30694 |
amit.gupta |
52 |
divText = divCode.replace("CONTENT", divText);
|
| 23343 |
ashik.ali |
53 |
$("#grnImeiInformation")
|
| 30694 |
amit.gupta |
54 |
.append(divText)
|
| 23343 |
ashik.ali |
55 |
}
|
|
|
56 |
});
|
|
|
57 |
|
| 30694 |
amit.gupta |
58 |
$(document).on('click', "td.startGrnNonSerialized", function () {
|
| 23343 |
ashik.ali |
59 |
var invoiceNumber = $(this).attr('invoiceNumber');
|
|
|
60 |
var quantity = $(this).attr('quantity');
|
|
|
61 |
var displayName = $(this).attr('displayName');
|
|
|
62 |
var itemId = $(this).attr('itemId');
|
|
|
63 |
console.log(quantity);
|
|
|
64 |
$("#scanNonSerializedModel .modal-body .grnInvoiceNumber>span").text(invoiceNumber);
|
|
|
65 |
$("#scanNonSerializedModel .modal-body .grnProductInfo>span").text(displayName);
|
|
|
66 |
$("#scanNonSerializedModel .invoiceNumber").val(invoiceNumber);
|
|
|
67 |
$("#scanNonSerializedModel .itemId").val(itemId);
|
| 30694 |
amit.gupta |
68 |
$("#grnImeiInformation").empty();
|
| 23343 |
ashik.ali |
69 |
var qty = parseInt(quantity);
|
|
|
70 |
var divCode = '<div class="row">CONTENT</div><p></p>';
|
| 30694 |
amit.gupta |
71 |
var innerDiv = '<div class="col-sm-3">' +
|
|
|
72 |
'<div class="input-group">' +
|
|
|
73 |
'<input type="text" class="form-control">' +
|
|
|
74 |
'</div>' +
|
|
|
75 |
'</div>';
|
|
|
76 |
while (qty != 0) {
|
|
|
77 |
var divText = "";
|
|
|
78 |
if (qty < 4) {
|
| 23343 |
ashik.ali |
79 |
var cp = qty;
|
| 30694 |
amit.gupta |
80 |
for (var i = 0; i < cp; i++) {
|
| 23343 |
ashik.ali |
81 |
divText = divText + innerDiv;
|
|
|
82 |
qty = qty - 1;
|
|
|
83 |
}
|
| 30694 |
amit.gupta |
84 |
} else {
|
|
|
85 |
for (var i = 0; i < 4; i++) {
|
| 23343 |
ashik.ali |
86 |
divText = divText + innerDiv;
|
|
|
87 |
qty = qty - 1;
|
|
|
88 |
}
|
|
|
89 |
}
|
| 30694 |
amit.gupta |
90 |
divText = divCode.replace("CONTENT", divText);
|
| 23343 |
ashik.ali |
91 |
$("#grnImeiInformation")
|
| 30694 |
amit.gupta |
92 |
.append(divText)
|
| 23343 |
ashik.ali |
93 |
}
|
|
|
94 |
});
|
| 30694 |
amit.gupta |
95 |
|
|
|
96 |
$(document).on('click', "#grnSubmitSerialized", function () {
|
| 23343 |
ashik.ali |
97 |
var imeis = [];
|
|
|
98 |
var error = false;
|
|
|
99 |
var errorText = "";
|
| 30694 |
amit.gupta |
100 |
$("#grnImeiInformation :input").each(function () {
|
| 23343 |
ashik.ali |
101 |
var input = $(this).val().trim();
|
| 30694 |
amit.gupta |
102 |
if (imeis.indexOf(input) != -1 || !input) {
|
| 23343 |
ashik.ali |
103 |
error = true;
|
| 30694 |
amit.gupta |
104 |
if (!input) {
|
| 23343 |
ashik.ali |
105 |
$(this).addClass("border-highlight");
|
|
|
106 |
}
|
|
|
107 |
}
|
|
|
108 |
imeis.push(input);
|
| 30694 |
amit.gupta |
109 |
|
| 23343 |
ashik.ali |
110 |
});
|
| 30694 |
amit.gupta |
111 |
if (error) {
|
| 23343 |
ashik.ali |
112 |
return false;
|
|
|
113 |
}
|
|
|
114 |
var invoiceNumber = $("#scanModel .invoiceNumber").val();
|
|
|
115 |
var itemId = $("#scanModel .itemId").val();
|
| 30694 |
amit.gupta |
116 |
var postData = JSON.stringify({
|
|
|
117 |
"itemId": parseInt(itemId),
|
|
|
118 |
"invoiceNumber": invoiceNumber,
|
|
|
119 |
"serialNumbers": imeis
|
|
|
120 |
});
|
|
|
121 |
doPostAjaxRequestWithJsonHandler(context + "/scanSerialized", postData, function (response) {
|
|
|
122 |
bootbox.alert("Purchase booked successfully", function () {
|
|
|
123 |
$('#scanModel').on('hidden.bs.modal', function (event) {
|
| 27534 |
amit.gupta |
124 |
$("#purchase-reference-submit-button").click();
|
|
|
125 |
$(this).off(event);
|
|
|
126 |
});
|
| 27536 |
amit.gupta |
127 |
$('#scanModel').modal('hide');
|
| 27198 |
amit.gupta |
128 |
});
|
| 23343 |
ashik.ali |
129 |
});
|
|
|
130 |
return false;
|
|
|
131 |
});
|
| 30694 |
amit.gupta |
132 |
|
|
|
133 |
$(document).on('click', "#grnNonSerializedSubmit", function () {
|
| 23343 |
ashik.ali |
134 |
var error = false;
|
|
|
135 |
var errorText = "";
|
| 30694 |
amit.gupta |
136 |
if (error) {
|
| 23343 |
ashik.ali |
137 |
return false;
|
|
|
138 |
}
|
|
|
139 |
var invoiceNumber = $("#scanNonSerializedModel .invoiceNumber").val();
|
|
|
140 |
var itemId = $("#scanNonSerializedModel .itemId").val();
|
|
|
141 |
var quantity = $("#scanNonSerializedModel .quantity").val();
|
| 30694 |
amit.gupta |
142 |
var postData = JSON.stringify({
|
|
|
143 |
"itemId": parseInt(itemId),
|
|
|
144 |
"invoiceNumber": invoiceNumber,
|
|
|
145 |
"quantity": parseInt(quantity)
|
|
|
146 |
});
|
|
|
147 |
doPostAjaxRequestWithJsonHandler(context + "/scanNonSerialized", postData, function (response) {
|
|
|
148 |
bootbox.alert("Purchase booked successfully", function () {
|
|
|
149 |
$('#scanNonSerializedModel').on('hidden.bs.modal', function (event) {
|
| 27537 |
amit.gupta |
150 |
$(this).off(event);
|
| 27534 |
amit.gupta |
151 |
$("#purchase-reference-submit-button").click();
|
|
|
152 |
});
|
| 27537 |
amit.gupta |
153 |
$('#scanNonSerializedModel').modal('hide');
|
| 27198 |
amit.gupta |
154 |
});
|
| 23343 |
ashik.ali |
155 |
});
|
|
|
156 |
return false;
|
|
|
157 |
});
|
|
|
158 |
|
| 30694 |
amit.gupta |
159 |
$(document).on('change', "#grnImeiInformation :input", function () {
|
| 23343 |
ashik.ali |
160 |
if ($(this).val().trim() != "") {
|
|
|
161 |
console.log('The text box really changed this time');
|
|
|
162 |
$('#grnImeiInformation :input').removeClass("border-highlight");
|
| 30694 |
amit.gupta |
163 |
if (findDuplicateSerialNumbers($(this).val().trim()) > 0) {
|
|
|
164 |
var inputs = $("#grnImeiInformation :input[value=" + $(this).val().trim() + "]");
|
|
|
165 |
if (inputs.length > 1) {
|
|
|
166 |
inputs.each(function () {
|
|
|
167 |
$(this).addClass("border-highlight")
|
|
|
168 |
});
|
| 23343 |
ashik.ali |
169 |
}
|
|
|
170 |
}
|
|
|
171 |
}
|
|
|
172 |
});
|
| 30694 |
amit.gupta |
173 |
|
|
|
174 |
|
|
|
175 |
$(document).on('paste', "#grnImeiInformation :input", function () {
|
| 23343 |
ashik.ali |
176 |
if ($(this).val().trim() != "") {
|
|
|
177 |
console.log('paste event');
|
|
|
178 |
$(this).next("input .form-control").focus();
|
|
|
179 |
}
|
|
|
180 |
});
|
|
|
181 |
|
| 30694 |
amit.gupta |
182 |
$(document).on("keyup", "#airwayBillOrInvoiceNumberText", function (e) {
|
| 23343 |
ashik.ali |
183 |
var keyCode = e.keyCode || e.which;
|
| 30694 |
amit.gupta |
184 |
if (keyCode == 13) {
|
|
|
185 |
$("#purchase-reference-submit-button").click();
|
|
|
186 |
}
|
| 23343 |
ashik.ali |
187 |
});
|
|
|
188 |
|
| 30694 |
amit.gupta |
189 |
$(document).on('click', "#grn-history-search-button", function () {
|
| 23343 |
ashik.ali |
190 |
grnhistory.searchText = $("#grn-history-search-text").val();
|
|
|
191 |
grnhistory.searchType = "purchaseReference";
|
| 23886 |
amit.gupta |
192 |
grnhistory.startTime = startDate;
|
|
|
193 |
grnhistory.endTime = endDate;
|
| 30694 |
amit.gupta |
194 |
if (typeof (grnhistory.searchText) == "undefined" || !grnhistory.searchText) {
|
| 23343 |
ashik.ali |
195 |
grnhistory.searchText = "";
|
|
|
196 |
}
|
| 30694 |
amit.gupta |
197 |
loadGrnHistorySearchInfo(grnhistory.searchText, grnhistory.searchType, grnhistory.startTime, grnhistory.endTime);
|
|
|
198 |
});
|
|
|
199 |
|
|
|
200 |
$(document).on('click', "#grn-history-download-button", function () {
|
| 26013 |
amit.gupta |
201 |
grnhistory.searchText = $("#grn-history-search-text").val();
|
|
|
202 |
grnhistory.searchType = "purchaseReference";
|
|
|
203 |
grnhistory.startTime = startDate;
|
|
|
204 |
grnhistory.endTime = endDate;
|
| 30694 |
amit.gupta |
205 |
if (typeof (grnhistory.searchText) == "undefined" || !grnhistory.searchText) {
|
| 26013 |
amit.gupta |
206 |
grnhistory.searchText = "";
|
|
|
207 |
}
|
| 30694 |
amit.gupta |
208 |
downloadPurchaseInvoices(grnhistory.searchText, grnhistory.searchType, grnhistory.startTime, grnhistory.endTime);
|
| 26013 |
amit.gupta |
209 |
});
|
| 30694 |
amit.gupta |
210 |
|
|
|
211 |
$(document).on("keyup", "#grn-history-search-text", function (e) {
|
| 23343 |
ashik.ali |
212 |
var keyCode = e.keyCode || e.which;
|
| 30694 |
amit.gupta |
213 |
if (keyCode == 13) {
|
|
|
214 |
$("#grn-history-search-button").click();
|
|
|
215 |
}
|
| 23343 |
ashik.ali |
216 |
});
|
|
|
217 |
|
| 30694 |
amit.gupta |
218 |
$(document).on('click', "#grn-history-paginated .next", function () {
|
| 23629 |
ashik.ali |
219 |
var params = {};
|
|
|
220 |
params['purchaseReference'] = grnhistory.searchText;
|
|
|
221 |
params['searchType'] = grnhistory.searchType;
|
|
|
222 |
params['startTime'] = grnhistory.startTime;
|
|
|
223 |
params['endTime'] = grnhistory.endTime;
|
|
|
224 |
loadPaginatedNextItems('/getPaginatedGrnHistory', params, 'grn-history-paginated', 'grn-history-table', null);
|
|
|
225 |
$(this).blur();
|
| 30694 |
amit.gupta |
226 |
|
|
|
227 |
});
|
|
|
228 |
|
|
|
229 |
$(document).on('click', "#grn-history-paginated .previous", function () {
|
| 23629 |
ashik.ali |
230 |
var params = {};
|
|
|
231 |
params['purchaseReference'] = grnhistory.searchText;
|
|
|
232 |
params['searchType'] = grnhistory.searchType;
|
|
|
233 |
params['startTime'] = grnhistory.startTime;
|
|
|
234 |
params['endTime'] = grnhistory.endTime;
|
|
|
235 |
loadPaginatedPreviousItems('/getPaginatedGrnHistory', params, 'grn-history-paginated', 'grn-history-table', null);
|
|
|
236 |
$(this).blur();
|
| 30694 |
amit.gupta |
237 |
|
|
|
238 |
});
|
|
|
239 |
|
|
|
240 |
$(document).on('click', "#grn-history-date-button", function () {
|
| 23343 |
ashik.ali |
241 |
var dateRange = $('#reportrange span').text();
|
| 30599 |
amit.gupta |
242 |
grnhistory.startTime = getDatesFromPicker($("#grnDateRange")).startDate;
|
|
|
243 |
grnhistory.endTime = getDatesFromPicker($("#grnDateRange")).endDate;
|
| 23343 |
ashik.ali |
244 |
grnhistory.searchType = "dateFilter";
|
|
|
245 |
grnhistory.searchText = "";
|
| 30599 |
amit.gupta |
246 |
loadGrnHistorySearchInfo(grnhistory.searchText, grnhistory.searchType, grnhistory.startTime, grnhistory.endTime);
|
|
|
247 |
});
|
| 23343 |
ashik.ali |
248 |
|
| 30694 |
amit.gupta |
249 |
$(document).on('click', ".grn-details", function () {
|
| 23343 |
ashik.ali |
250 |
var purchaseId = $(this).attr('data');
|
|
|
251 |
console.log(purchaseId);
|
| 30694 |
amit.gupta |
252 |
loadGrnDetails(purchaseId, "grn-details-container");
|
| 23343 |
ashik.ali |
253 |
});
|
| 30694 |
amit.gupta |
254 |
|
|
|
255 |
$(document).on('click', ".pending-grn-details", function () {
|
| 23343 |
ashik.ali |
256 |
console.log("pending-grn-details clicked");
|
|
|
257 |
var orderId = $(this).attr('data');
|
| 30694 |
amit.gupta |
258 |
console.log("orderId : " + orderId);
|
| 23343 |
ashik.ali |
259 |
loadPendingGrnDetails(orderId, "pending-grn-details-container");
|
|
|
260 |
});
|
|
|
261 |
|
| 30694 |
amit.gupta |
262 |
$(document).on('click', ".pending-grn", function () {
|
| 23343 |
ashik.ali |
263 |
var purchaseReference = $(this).attr('data');
|
|
|
264 |
console.log(purchaseReference);
|
| 30694 |
amit.gupta |
265 |
loadPendingGrnDetails(purchaseReference, "main-content");
|
| 23343 |
ashik.ali |
266 |
});
|
|
|
267 |
|
|
|
268 |
});
|
|
|
269 |
|
|
|
270 |
|
| 30466 |
amit.gupta |
271 |
function loadNewGrn(domId, invoiceNumber) {
|
| 23343 |
ashik.ali |
272 |
//var response = doGetAjaxRequest(context+"/purchase");
|
| 30466 |
amit.gupta |
273 |
doGetAjaxRequestHandler(context + "/purchase", function (response) {
|
| 23343 |
ashik.ali |
274 |
$('#' + domId).html(response);
|
| 30466 |
amit.gupta |
275 |
if (invoiceNumber != undefined) {
|
|
|
276 |
$("#airwayBillOrInvoiceNumberText").val(invoiceNumber);
|
|
|
277 |
$("#purchase-reference-submit-button").click();
|
|
|
278 |
}
|
| 23343 |
ashik.ali |
279 |
});
|
| 30466 |
amit.gupta |
280 |
|
| 23343 |
ashik.ali |
281 |
}
|
|
|
282 |
|
| 30694 |
amit.gupta |
283 |
function getPurchaseByInvoiceNumber() {
|
| 23343 |
ashik.ali |
284 |
var airwayBillOrInvoiceNumber = $('#airwayBillOrInvoiceNumberText').val();
|
| 30694 |
amit.gupta |
285 |
doGetAjaxRequestHandler(context + "/purchaseByInvoiceNumber?airwayBillOrInvoiceNumber=" + airwayBillOrInvoiceNumber, function (response) {
|
| 23343 |
ashik.ali |
286 |
$('#main-content').html(response);
|
|
|
287 |
});
|
|
|
288 |
}
|
|
|
289 |
|
| 30694 |
amit.gupta |
290 |
function loadPendingGrn(domId) {
|
|
|
291 |
doGetAjaxRequestHandler(context + "/pendingGrn", function (response) {
|
| 23343 |
ashik.ali |
292 |
$('#' + domId).html(response);
|
|
|
293 |
});
|
|
|
294 |
}
|
|
|
295 |
|
| 30694 |
amit.gupta |
296 |
function loadGrnHistory(domId, purchase_reference, searchType, startTime, endTime) {
|
|
|
297 |
doGetAjaxRequestHandler(context + "/grnHistory?purchaseReference=" + purchase_reference + "&searchType=" + searchType
|
|
|
298 |
+ "&startTime=" + startTime
|
|
|
299 |
+ "&endTime=" + endTime, function (response) {
|
| 23343 |
ashik.ali |
300 |
$('#' + domId).html(response);
|
|
|
301 |
});
|
|
|
302 |
}
|
|
|
303 |
|
| 30694 |
amit.gupta |
304 |
function loadGrnHistorySearchInfo(search_text, searchType, startTime, endTime) {
|
|
|
305 |
loadGrnHistory("main-content", search_text, searchType, startTime, endTime);
|
| 23343 |
ashik.ali |
306 |
}
|
|
|
307 |
|
| 30694 |
amit.gupta |
308 |
function downloadPurchaseInvoice(search_text, searchType, startTime, endTime) {
|
|
|
309 |
purchaseInvoice_url = context + "/grnHistory?purchaseReference=" + purchase_reference + "&searchType=" + searchType
|
|
|
310 |
+ "&startTime=" + startTime + "&endTime=" + endTime;
|
| 26013 |
amit.gupta |
311 |
}
|
|
|
312 |
|
| 30694 |
amit.gupta |
313 |
function findDuplicateSerialNumbers(value) {
|
|
|
314 |
var result = $("#grnImeiInformation :input[value='" + value + "']").length - 1;
|
|
|
315 |
return result;
|
| 23343 |
ashik.ali |
316 |
}
|
|
|
317 |
|
| 30694 |
amit.gupta |
318 |
function loadGrnDetails(purchaseId, domId) {
|
|
|
319 |
doGetAjaxRequestHandler(context + "/grnHistoryDetailByPurchaseId?purchaseId=" + purchaseId, function (response) {
|
| 23343 |
ashik.ali |
320 |
$('#' + domId).html(response);
|
|
|
321 |
window.dispatchEvent(new Event('resize'));
|
| 30694 |
amit.gupta |
322 |
});
|
| 23343 |
ashik.ali |
323 |
}
|
|
|
324 |
|
| 30694 |
amit.gupta |
325 |
function loadPendingGrnDetails(orderId, domId) {
|
|
|
326 |
doGetAjaxRequestHandler(context + "/pendingGrnDetails?orderId=" + orderId, function (response) {
|
| 23343 |
ashik.ali |
327 |
$('#' + domId).html(response);
|
|
|
328 |
window.dispatchEvent(new Event('resize'));
|
|
|
329 |
});
|
| 30694 |
amit.gupta |
330 |
|
| 23343 |
ashik.ali |
331 |
}
|
| 30694 |
amit.gupta |
332 |
|
|
|
333 |
function grnPartial(invoiceNumber) {
|
|
|
334 |
let serialNumbers = $("#all-imeis").tagsinput('items')
|
|
|
335 |
let imeisJson = {
|
|
|
336 |
serialNumbers: serialNumbers,
|
|
|
337 |
invoiceNumber: invoiceNumber
|
|
|
338 |
}
|
|
|
339 |
doPostAjaxRequestWithJsonHandler(`${context}/purchase/grn-imeis`, JSON.stringify(imeisJson), function (data) {
|
|
|
340 |
let response = data.response;
|
|
|
341 |
if (response) {
|
|
|
342 |
alert("Purchase booked successfully");
|
|
|
343 |
$("#purchase-reference-submit-button").click();
|
|
|
344 |
}
|
|
|
345 |
});
|
|
|
346 |
}
|