Subversion Repositories SmartDukaan

Rev

Rev 30599 | Rev 30701 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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