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