Subversion Repositories SmartDukaan

Rev

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

Rev 30694 Rev 30701
Line 28... Line 28...
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
		doGetAjaxRequestHandler(`/purchase/get-imeis?invoiceNumber=${invoiceNumber}&itemId=${itemId}`, function (data) {
34
			'<div class="input-group">' +
34
			let response = data.response;
35
			'<input type="text" class="form-control">' +
-
 
36
			'</div>' +
35
			let index = 0;
37
			'</div>';
-
 
38
		while (qty != 0) {
36
			while (index < response.length) {
-
 
37
				let currentRow = response.length - index < 4 ? response.length - index : 4;
39
			var divText = "";
38
				let rowArr = [];
40
			if (qty < 4) {
39
				for (let i = 0; i < currentRow; i++) {
41
				var cp = qty;
40
					let checkedDiv =
42
				for (var i = 0; i < cp; i++) {
41
						`<div class="col-sm-3">
43
					divText = divText + innerDiv;
42
						<label class="checkbox-inline">
44
					qty = qty - 1;
43
							<input type="checkbox" value="${response[index]}"> ${response[index]}
45
				}
44
						</label>
46
			} else {
45
					</div>`;
47
				for (var i = 0; i < 4; i++) {
-
 
48
					divText = divText + innerDiv;
46
					rowArr.push(checkedDiv);
49
					qty = qty - 1;
47
					index++;
50
				}
48
				}
-
 
49
				$("#grnImeiInformation").append(divCode.replace("CONTENT", rowArr.join("")));
51
			}
50
			}
52
			divText = divCode.replace("CONTENT", divText);
-
 
53
			$("#grnImeiInformation")
-
 
54
				.append(divText)
-
 
55
		}
51
		});
56
	});
52
	});
-
 
53
});
57
 
54
 
58
	$(document).on('click', "td.startGrnNonSerialized", function () {
55
$(document).on('click', "td.startGrnNonSerialized", function () {
59
		var invoiceNumber = $(this).attr('invoiceNumber');
56
	var invoiceNumber = $(this).attr('invoiceNumber');
60
		var quantity = $(this).attr('quantity');
57
	var quantity = $(this).attr('quantity');
61
		var displayName = $(this).attr('displayName');
58
	var displayName = $(this).attr('displayName');
62
		var itemId = $(this).attr('itemId');
59
	var itemId = $(this).attr('itemId');
63
		console.log(quantity);
60
	console.log(quantity);
64
		$("#scanNonSerializedModel .modal-body .grnInvoiceNumber>span").text(invoiceNumber);
61
	$("#scanNonSerializedModel .modal-body .grnInvoiceNumber>span").text(invoiceNumber);
65
		$("#scanNonSerializedModel .modal-body .grnProductInfo>span").text(displayName);
62
	$("#scanNonSerializedModel .modal-body .grnProductInfo>span").text(displayName);
66
		$("#scanNonSerializedModel .invoiceNumber").val(invoiceNumber);
63
	$("#scanNonSerializedModel .invoiceNumber").val(invoiceNumber);
67
		$("#scanNonSerializedModel .itemId").val(itemId);
64
	$("#scanNonSerializedModel .itemId").val(itemId);
68
		$("#grnImeiInformation").empty();
65
	$("#grnImeiInformation").empty();
69
		var qty = parseInt(quantity);
66
	var qty = parseInt(quantity);
70
		var divCode = '<div class="row">CONTENT</div><p></p>';
67
	var divCode = '<div class="row">CONTENT</div><p></p>';
71
		var innerDiv = '<div class="col-sm-3">' +
68
	var innerDiv = '<div class="col-sm-3">' +
72
			'<div class="input-group">' +
69
		'<div class="input-group">' +
73
			'<input type="text" class="form-control">' +
70
		'<input type="text" class="form-control">' +
74
			'</div>' +
71
		'</div>' +
75
			'</div>';
72
		'</div>';
76
		while (qty != 0) {
73
	while (qty != 0) {
77
			var divText = "";
74
		var divText = "";
78
			if (qty < 4) {
75
		if (qty < 4) {
79
				var cp = qty;
76
			var cp = qty;
80
				for (var i = 0; i < cp; i++) {
77
			for (var i = 0; i < cp; i++) {
81
					divText = divText + innerDiv;
78
				divText = divText + innerDiv;
82
					qty = qty - 1;
79
				qty = qty - 1;
83
				}
80
			}
84
			} else {
81
		} else {
85
				for (var i = 0; i < 4; i++) {
82
			for (var i = 0; i < 4; i++) {
86
					divText = divText + innerDiv;
83
				divText = divText + innerDiv;
87
					qty = qty - 1;
84
				qty = qty - 1;
88
				}
-
 
89
			}
85
			}
90
			divText = divCode.replace("CONTENT", divText);
-
 
91
			$("#grnImeiInformation")
-
 
92
				.append(divText)
-
 
93
		}
86
		}
-
 
87
		divText = divCode.replace("CONTENT", divText);
-
 
88
		$("#grnImeiInformation")
-
 
89
			.append(divText)
-
 
90
	}
94
	});
91
});
95
 
92
 
96
	$(document).on('click', "#grnSubmitSerialized", function () {
93
$(document).on('click', "#grnSubmitSerialized", function () {
97
		var imeis = [];
94
	var imeis = [];
98
		var error = false;
95
	var error = false;
99
		var errorText = "";
96
	var errorText = "";
100
		$("#grnImeiInformation :input").each(function () {
97
	$("#grnImeiInformation :input").each(function () {
101
			var input = $(this).val().trim();
98
		var input = $(this).val().trim();
102
			if (imeis.indexOf(input) != -1 || !input) {
99
		if (imeis.indexOf(input) != -1 || !input) {
103
				error = true;
100
			error = true;
104
				if (!input) {
101
			if (!input) {
105
					$(this).addClass("border-highlight");
102
				$(this).addClass("border-highlight");
106
				}
-
 
107
			}
103
			}
108
			imeis.push(input);
-
 
109
 
-
 
110
		});
-
 
111
		if (error) {
-
 
112
			return false;
-
 
113
		}
104
		}
-
 
105
		imeis.push(input);
-
 
106
 
-
 
107
	});
-
 
108
	if (error) {
-
 
109
		return false;
-
 
110
	}
114
		var invoiceNumber = $("#scanModel .invoiceNumber").val();
111
	var invoiceNumber = $("#scanModel .invoiceNumber").val();
115
		var itemId = $("#scanModel .itemId").val();
112
	var itemId = $("#scanModel .itemId").val();
116
		var postData = JSON.stringify({
113
	var postData = JSON.stringify({
117
			"itemId": parseInt(itemId),
114
		"itemId": parseInt(itemId),
118
			"invoiceNumber": invoiceNumber,
115
		"invoiceNumber": invoiceNumber,
119
			"serialNumbers": imeis
116
		"serialNumbers": imeis
120
		});
117
	});
121
		doPostAjaxRequestWithJsonHandler(context + "/scanSerialized", postData, function (response) {
118
	doPostAjaxRequestWithJsonHandler(context + "/scanSerialized", postData, function (response) {
122
			bootbox.alert("Purchase booked successfully", function () {
119
		bootbox.alert("Purchase booked successfully", function () {
123
				$('#scanModel').on('hidden.bs.modal', function (event) {
120
			$('#scanModel').on('hidden.bs.modal', function (event) {
124
					$("#purchase-reference-submit-button").click();
121
				$("#purchase-reference-submit-button").click();
125
					$(this).off(event);
122
				$(this).off(event);
126
				});
-
 
127
				$('#scanModel').modal('hide');
-
 
128
			});
123
			});
-
 
124
			$('#scanModel').modal('hide');
129
		});
125
		});
130
		return false;
-
 
131
	});
126
	});
-
 
127
	return false;
-
 
128
});
132
 
129
 
133
	$(document).on('click', "#grnNonSerializedSubmit", function () {
130
$(document).on('click', "#grnNonSerializedSubmit", function () {
134
		var error = false;
131
	var error = false;
135
		var errorText = "";
132
	var errorText = "";
136
		if (error) {
133
	if (error) {
137
			return false;
134
		return false;
138
		}
135
	}
139
		var invoiceNumber = $("#scanNonSerializedModel .invoiceNumber").val();
136
	var invoiceNumber = $("#scanNonSerializedModel .invoiceNumber").val();
140
		var itemId = $("#scanNonSerializedModel .itemId").val();
137
	var itemId = $("#scanNonSerializedModel .itemId").val();
141
		var quantity = $("#scanNonSerializedModel .quantity").val();
138
	var quantity = $("#scanNonSerializedModel .quantity").val();
142
		var postData = JSON.stringify({
139
	var postData = JSON.stringify({
143
			"itemId": parseInt(itemId),
140
		"itemId": parseInt(itemId),
144
			"invoiceNumber": invoiceNumber,
141
		"invoiceNumber": invoiceNumber,
145
			"quantity": parseInt(quantity)
142
		"quantity": parseInt(quantity)
146
		});
143
	});
147
		doPostAjaxRequestWithJsonHandler(context + "/scanNonSerialized", postData, function (response) {
144
	doPostAjaxRequestWithJsonHandler(context + "/scanNonSerialized", postData, function (response) {
148
			bootbox.alert("Purchase booked successfully", function () {
145
		bootbox.alert("Purchase booked successfully", function () {
149
				$('#scanNonSerializedModel').on('hidden.bs.modal', function (event) {
146
			$('#scanNonSerializedModel').on('hidden.bs.modal', function (event) {
150
					$(this).off(event);
147
				$(this).off(event);
151
					$("#purchase-reference-submit-button").click();
148
				$("#purchase-reference-submit-button").click();
152
				});
-
 
153
				$('#scanNonSerializedModel').modal('hide');
-
 
154
			});
149
			});
-
 
150
			$('#scanNonSerializedModel').modal('hide');
155
		});
151
		});
156
		return false;
-
 
157
	});
152
	});
-
 
153
	return false;
-
 
154
});
158
 
155
 
159
	$(document).on('change', "#grnImeiInformation :input", function () {
156
$(document).on('change', "#grnImeiInformation :input", function () {
160
		if ($(this).val().trim() != "") {
157
	if ($(this).val().trim() != "") {
161
			console.log('The text box really changed this time');
158
		console.log('The text box really changed this time');
162
			$('#grnImeiInformation :input').removeClass("border-highlight");
159
		$('#grnImeiInformation :input').removeClass("border-highlight");
163
			if (findDuplicateSerialNumbers($(this).val().trim()) > 0) {
160
		if (findDuplicateSerialNumbers($(this).val().trim()) > 0) {
164
				var inputs = $("#grnImeiInformation :input[value=" + $(this).val().trim() + "]");
161
			var inputs = $("#grnImeiInformation :input[value=" + $(this).val().trim() + "]");
165
				if (inputs.length > 1) {
162
			if (inputs.length > 1) {
166
					inputs.each(function () {
163
				inputs.each(function () {
167
						$(this).addClass("border-highlight")
164
					$(this).addClass("border-highlight")
168
					});
165
				});
169
				}
-
 
170
			}
166
			}
171
		}
167
		}
172
	});
168
	}
173
 
169
});
174
 
170
 
175
	$(document).on('paste', "#grnImeiInformation :input", function () {
-
 
176
		if ($(this).val().trim() != "") {
-
 
177
			console.log('paste event');
-
 
178
			$(this).next("input .form-control").focus();
-
 
179
		}
-
 
180
	});
-
 
181
 
171
 
182
	$(document).on("keyup", "#airwayBillOrInvoiceNumberText", function (e) {
172
$(document).on('paste', "#grnImeiInformation :input", function () {
183
		var keyCode = e.keyCode || e.which;
173
	if ($(this).val().trim() != "") {
184
		if (keyCode == 13) {
174
		console.log('paste event');
185
			$("#purchase-reference-submit-button").click();
175
		$(this).next("input .form-control").focus();
186
		}
176
	}
187
	});
177
});
188
 
178
 
189
	$(document).on('click', "#grn-history-search-button", function () {
179
$(document).on("keyup", "#airwayBillOrInvoiceNumberText", function (e) {
190
		grnhistory.searchText = $("#grn-history-search-text").val();
-
 
191
		grnhistory.searchType = "purchaseReference";
-
 
192
		grnhistory.startTime = startDate;
180
	var keyCode = e.keyCode || e.which;
193
		grnhistory.endTime = endDate;
181
	if (keyCode == 13) {
194
		if (typeof (grnhistory.searchText) == "undefined" || !grnhistory.searchText) {
-
 
195
			grnhistory.searchText = "";
182
		$("#purchase-reference-submit-button").click();
196
		}
183
	}
197
		loadGrnHistorySearchInfo(grnhistory.searchText, grnhistory.searchType, grnhistory.startTime, grnhistory.endTime);
-
 
198
	});
184
});
199
 
185
 
200
	$(document).on('click', "#grn-history-download-button", function () {
186
$(document).on('click', "#grn-history-search-button", function () {
201
		grnhistory.searchText = $("#grn-history-search-text").val();
187
	grnhistory.searchText = $("#grn-history-search-text").val();
202
		grnhistory.searchType = "purchaseReference";
188
	grnhistory.searchType = "purchaseReference";
203
		grnhistory.startTime = startDate;
189
	grnhistory.startTime = startDate;
204
		grnhistory.endTime = endDate;
190
	grnhistory.endTime = endDate;
205
		if (typeof (grnhistory.searchText) == "undefined" || !grnhistory.searchText) {
191
	if (typeof (grnhistory.searchText) == "undefined" || !grnhistory.searchText) {
206
			grnhistory.searchText = "";
192
		grnhistory.searchText = "";
207
		}
193
	}
208
		downloadPurchaseInvoices(grnhistory.searchText, grnhistory.searchType, grnhistory.startTime, grnhistory.endTime);
194
	loadGrnHistorySearchInfo(grnhistory.searchText, grnhistory.searchType, grnhistory.startTime, grnhistory.endTime);
209
	});
195
});
210
 
196
 
211
	$(document).on("keyup", "#grn-history-search-text", function (e) {
197
$(document).on('click', "#grn-history-download-button", function () {
-
 
198
	grnhistory.searchText = $("#grn-history-search-text").val();
212
		var keyCode = e.keyCode || e.which;
199
	grnhistory.searchType = "purchaseReference";
-
 
200
	grnhistory.startTime = startDate;
213
		if (keyCode == 13) {
201
	grnhistory.endTime = endDate;
-
 
202
	if (typeof (grnhistory.searchText) == "undefined" || !grnhistory.searchText) {
214
			$("#grn-history-search-button").click();
203
		grnhistory.searchText = "";
215
		}
204
	}
-
 
205
	downloadPurchaseInvoices(grnhistory.searchText, grnhistory.searchType, grnhistory.startTime, grnhistory.endTime);
216
	});
206
});
217
 
207
 
218
	$(document).on('click', "#grn-history-paginated .next", function () {
208
$(document).on("keyup", "#grn-history-search-text", function (e) {
219
		var params = {};
-
 
220
		params['purchaseReference'] = grnhistory.searchText;
-
 
221
		params['searchType'] = grnhistory.searchType;
209
	var keyCode = e.keyCode || e.which;
222
		params['startTime'] = grnhistory.startTime;
210
	if (keyCode == 13) {
223
		params['endTime'] = grnhistory.endTime;
211
		$("#grn-history-search-button").click();
224
		loadPaginatedNextItems('/getPaginatedGrnHistory', params, 'grn-history-paginated', 'grn-history-table', null);
-
 
-
 
212
	}
225
		$(this).blur();
213
});
226
 
214
 
-
 
215
$(document).on('click', "#grn-history-paginated .next", function () {
-
 
216
	var params = {};
-
 
217
	params['purchaseReference'] = grnhistory.searchText;
-
 
218
	params['searchType'] = grnhistory.searchType;
-
 
219
	params['startTime'] = grnhistory.startTime;
-
 
220
	params['endTime'] = grnhistory.endTime;
-
 
221
	loadPaginatedNextItems('/getPaginatedGrnHistory', params, 'grn-history-paginated', 'grn-history-table', null);
227
	});
222
	$(this).blur();
228
 
223
 
229
	$(document).on('click', "#grn-history-paginated .previous", function () {
-
 
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();
224
});
237
 
225
 
-
 
226
$(document).on('click', "#grn-history-paginated .previous", function () {
-
 
227
	var params = {};
-
 
228
	params['purchaseReference'] = grnhistory.searchText;
-
 
229
	params['searchType'] = grnhistory.searchType;
-
 
230
	params['startTime'] = grnhistory.startTime;
-
 
231
	params['endTime'] = grnhistory.endTime;
-
 
232
	loadPaginatedPreviousItems('/getPaginatedGrnHistory', params, 'grn-history-paginated', 'grn-history-table', null);
238
	});
233
	$(this).blur();
239
 
234
 
240
	$(document).on('click', "#grn-history-date-button", function () {
-
 
241
		var dateRange = $('#reportrange span').text();
-
 
242
		grnhistory.startTime = getDatesFromPicker($("#grnDateRange")).startDate;
-
 
243
		grnhistory.endTime = getDatesFromPicker($("#grnDateRange")).endDate;
-
 
244
		grnhistory.searchType = "dateFilter";
-
 
245
		grnhistory.searchText = "";
-
 
246
		loadGrnHistorySearchInfo(grnhistory.searchText, grnhistory.searchType, grnhistory.startTime, grnhistory.endTime);
-
 
247
	});
235
});
248
 
236
 
249
	$(document).on('click', ".grn-details", function () {
237
$(document).on('click', "#grn-history-date-button", function () {
250
		var purchaseId = $(this).attr('data');
238
	var dateRange = $('#reportrange span').text();
-
 
239
	grnhistory.startTime = getDatesFromPicker($("#grnDateRange")).startDate;
-
 
240
	grnhistory.endTime = getDatesFromPicker($("#grnDateRange")).endDate;
-
 
241
	grnhistory.searchType = "dateFilter";
251
		console.log(purchaseId);
242
	grnhistory.searchText = "";
252
		loadGrnDetails(purchaseId, "grn-details-container");
243
	loadGrnHistorySearchInfo(grnhistory.searchText, grnhistory.searchType, grnhistory.startTime, grnhistory.endTime);
253
	});
244
});
254
 
245
 
255
	$(document).on('click', ".pending-grn-details", function () {
246
$(document).on('click', ".grn-details", function () {
256
		console.log("pending-grn-details clicked");
-
 
257
		var orderId = $(this).attr('data');
247
	var purchaseId = $(this).attr('data');
258
		console.log("orderId : " + orderId);
248
	console.log(purchaseId);
259
		loadPendingGrnDetails(orderId, "pending-grn-details-container");
249
	loadGrnDetails(purchaseId, "grn-details-container");
260
	});
250
});
261
 
251
 
262
	$(document).on('click', ".pending-grn", function () {
252
$(document).on('click', ".pending-grn-details", function () {
-
 
253
	console.log("pending-grn-details clicked");
263
		var purchaseReference = $(this).attr('data');
254
	var orderId = $(this).attr('data');
264
		console.log(purchaseReference);
255
	console.log("orderId : " + orderId);
265
		loadPendingGrnDetails(purchaseReference, "main-content");
256
	loadPendingGrnDetails(orderId, "pending-grn-details-container");
266
	});
257
});
267
 
258
 
-
 
259
$(document).on('click', ".pending-grn", function () {
-
 
260
	var purchaseReference = $(this).attr('data');
-
 
261
	console.log(purchaseReference);
-
 
262
	loadPendingGrnDetails(purchaseReference, "main-content");
268
});
263
});
269
 
264
 
270
 
265
 
271
function loadNewGrn(domId, invoiceNumber) {
266
function loadNewGrn(domId, invoiceNumber) {
272
	//var response = doGetAjaxRequest(context+"/purchase");
267
	//var response = doGetAjaxRequest(context+"/purchase");