Subversion Repositories SmartDukaan

Rev

Rev 24950 | Rev 25146 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
23343 ashik.ali 1
$(function() {
2
	$(".good_inventory").live('click', function() {
24739 tejbeer 3
		loadGoodInventory("main-content", "");
23343 ashik.ali 4
	});
24739 tejbeer 5
 
23343 ashik.ali 6
	$(".catalog").live('click', function() {
24739 tejbeer 7
		loadCatalog("main-content", "");
23343 ashik.ali 8
	});
24739 tejbeer 9
 
24917 tejbeer 10
	var cancelOrderId;
11
	var cancelSatus;
24658 tejbeer 12
	$(".review_order").live('click', function() {
13
		loadOrder("main-content");
14
	});
24739 tejbeer 15
 
16
	$(".keep-a-tab").live('click', function() {
17
		loadtabOrder("main-content");
18
	});
25066 tejbeer 19
 
24917 tejbeer 20
	$(".notify_order").live('click', function() {
21
		loadnotifyOrder("main-content");
22
	});
25066 tejbeer 23
 
23343 ashik.ali 24
	$(".item_aging").live('click', function() {
25
		getInventoryItemAgingByInterval("main-content", "");
26
	});
24739 tejbeer 27
 
23343 ashik.ali 28
	$("#item-aging-search-button").live('click', function() {
29
		searchContent = $("#item-aging-search-text").val();
24739 tejbeer 30
		if (typeof (searchContent) == "undefined" || !searchContent) {
23343 ashik.ali 31
			searchContent = "";
32
		}
33
		getInventoryItemAgingByInterval("main-content", searchContent);
24739 tejbeer 34
	});
35
 
23343 ashik.ali 36
	$("#item-aging-search-text").live("keyup", function(e) {
37
		var keyCode = e.keyCode || e.which;
24739 tejbeer 38
		if (keyCode == 13) {
39
			$("#item-aging-search-button").click();
40
		}
23343 ashik.ali 41
	});
24739 tejbeer 42
 
23629 ashik.ali 43
	$("#item-aging-paginated .next").live('click', function() {
24739 tejbeer 44
		var end = $("#item-aging-paginated .end").text();
23629 ashik.ali 45
		getItemAgingNextPreviousItems(end, "");
46
		$("#item-aging-paginated .next").blur();
24739 tejbeer 47
	});
48
 
23343 ashik.ali 49
	$("#item-aging-paginated .previous").live('click', function() {
24739 tejbeer 50
		var start = $("#item-aging-paginated .start").text();
23343 ashik.ali 51
		getItemAgingNextPreviousItems(start - 11, "");
52
		$("#item-aging-paginated .previous").blur();
24739 tejbeer 53
	});
54
 
23343 ashik.ali 55
	$(".download_aging_report").live('click', function() {
56
		downloadAgingReport();
57
	});
24739 tejbeer 58
 
23637 amit.gupta 59
	$(".download_reports").live('click', function() {
60
		downloadReports();
61
	});
24739 tejbeer 62
 
23343 ashik.ali 63
	$(".item-ledger-report-download-page").live('click', function() {
64
		loadItemLedgerReportDownloadPage("main-content");
65
	});
24739 tejbeer 66
 
23343 ashik.ali 67
	$(".bad_inventory").live('click', function() {
24739 tejbeer 68
		loadBadInventory("main-content", "");
23343 ashik.ali 69
	});
24739 tejbeer 70
 
71
	$("#good-inventory-paginated .next").live(
72
			'click',
73
			function() {
74
				var searchText = $("#good-inventory-search-text").val();
75
				if (typeof (searchText) == "undefined" || !searchText) {
76
					searchText = "";
77
 
78
				}
79
				var params = {};
80
				params['searchTerm'] = searchText;
81
				loadPaginatedNextItems('/getPaginatedCurrentInventorySnapshot',
82
						params, 'good-inventory-paginated',
83
						'good-inventory-table', null);
84
				$(this).blur();
85
			});
86
 
87
	$("#good-inventory-paginated .previous").live(
88
			'click',
89
			function() {
90
				var searchText = $("#good-inventory-search-text").val();
91
				if (typeof (searchText) == "undefined" || !searchText) {
92
					searchText = "";
93
				}
94
				var params = {};
95
				params['searchTerm'] = searchText;
96
				loadPaginatedPreviousItems(
97
						'/getPaginatedCurrentInventorySnapshot', params,
98
						'good-inventory-paginated', 'good-inventory-table',
99
						null);
100
				$(this).blur();
101
			});
102
 
23343 ashik.ali 103
	$("#good-inventory-search-button").live('click', function() {
104
		var searchText = $("#good-inventory-search-text").val();
24739 tejbeer 105
		if (typeof (searchText) == "undefined" || !searchText) {
23343 ashik.ali 106
			searchText = "";
107
		}
108
		loadGoodInventorySearchInfo(searchText);
24739 tejbeer 109
	});
110
 
23343 ashik.ali 111
	$("#good-inventory-search-text").live("keyup", function(e) {
112
		var keyCode = e.keyCode || e.which;
24739 tejbeer 113
		if (keyCode == 13) {
114
			$("#good-inventory-search-button").click();
115
		}
23343 ashik.ali 116
	});
24739 tejbeer 117
 
118
	$("#catalog-paginated .next").live(
119
			'click',
120
			function() {
121
				var searchText = $("#catalog-search-text").val();
122
				if (typeof (searchText) == "undefined" || !searchText) {
123
					searchText = "";
124
				}
125
 
126
				var params = {};
127
				params['searchTerm'] = searchText;
128
				loadPaginatedNextItems('/getPaginatedCatalog', params,
129
						'catalog-paginated', 'catalog-table', null);
130
				$(this).blur();
131
			});
132
 
133
	$("#catalog-paginated .previous").live(
134
			'click',
135
			function() {
136
				var searchText = $("#catalog-search-text").val();
137
				if (typeof (searchText) == "undefined" || !searchText) {
138
					searchText = "";
139
				}
140
 
141
				var params = {};
142
				params['searchTerm'] = searchText;
143
				loadPaginatedPreviousItems('/getPaginatedCatalog', params,
144
						'catalog-paginated', 'catalog-table', null);
145
				$(this).blur();
146
			});
147
 
23343 ashik.ali 148
	$("#catalog-search-button").live('click', function() {
149
		var searchText = $("#catalog-search-text").val();
24739 tejbeer 150
		if (typeof (searchText) == "undefined" || !searchText) {
23343 ashik.ali 151
			searchText = "";
152
		}
153
		loadCatalogSearchInfo(searchText);
24739 tejbeer 154
	});
155
 
23343 ashik.ali 156
	$("#catalog-search-text").live("keyup", function(e) {
157
		var keyCode = e.keyCode || e.which;
24739 tejbeer 158
		if (keyCode == 13) {
159
			$("#catalog-search-button").click();
160
		}
23343 ashik.ali 161
	});
24917 tejbeer 162
 
24739 tejbeer 163
	$(".cancellation").live("click", function(e) {
164
		orderid = $(this).data('orderid');
24917 tejbeer 165
		cancelOrder(orderid, "CANCELLED_DUE_TO_LOW_INVENTORY")
24739 tejbeer 166
	});
25066 tejbeer 167
 
24917 tejbeer 168
	$(".order-request-submit").live("click", function(e) {
169
		requestcancelOrder();
170
	});
24739 tejbeer 171
	$(".keepatab").live("click", function(e) {
172
		orderid = $(this).data('orderid');
173
		cancelOrder(orderid, "KEEP_A_TAB")
24917 tejbeer 174
 
24739 tejbeer 175
	});
23343 ashik.ali 176
 
25066 tejbeer 177
	$(".request-cancel").live('click', function() {
178
 
179
	});
180
 
181
	$(".mk_button").on("click", function() {
182
 
183
	});
184
 
24917 tejbeer 185
	$(".closeOrder")
186
			.live(
187
					"click",
188
					function(e) {
189
						orderid = $(this).data('orderid');
190
						if (confirm("Are you sure you want to close the order") == true) {
24739 tejbeer 191
 
24917 tejbeer 192
							doPostAjaxRequestHandler(context
193
									+ "/closeOrder?orderId=" + orderd,
194
									function(response) {
195
										if (response == 'true') {
196
											alert("successfully close");
197
											loadtabOrder("main-content");
198
										}
199
									});
200
						}
201
 
202
					});
25066 tejbeer 203
	$('#notify-table').find(':checkbox').live('change', function(e) {
204
		var colormessage = [];
205
		$("#notify-table input[type=checkbox]:checked").each(function() {
24917 tejbeer 206
 
25066 tejbeer 207
			var row = $(this).closest("tr")[0];
208
			colormessage.push(row.cells[0].innerText);
209
 
210
			console.log(colormessage)
211
		});
212
 
213
		$("#colorValue").text(colormessage);
214
	});
215
 
216
	$('#overridemessage').live('change', function() {
217
		if ($(this).is(':checked')) {
218
			$('#textnotifymessage').show();
219
			$('#textnotifymessage').focus();
220
		} else {
221
			$('#textnotifymessage').hide();
222
		}
223
	});
224
 
24917 tejbeer 225
	$(".notify-submit")
226
			.live(
227
					"click",
228
					function(e) {
229
 
230
						var jsonObject = {};
231
						var orderIdsJSon = [];
232
						var ItemIdsJson = [];
233
						var itemIds;
234
						var orderIds;
25066 tejbeer 235
						var message;
24917 tejbeer 236
 
25066 tejbeer 237
						if ($('#overridemessage').is(':checked')) {
238
							message = $('#textnotifymessage').val();
239
						} else {
240
							message = $('#notifymessage').text();
241
						}
242
 
243
						console.log(message);
24917 tejbeer 244
						var itemchecked = $("input[name='itemCheck']:checked").length;
245
 
246
						if (!itemchecked) {
247
							alert("You must check at least one item.");
248
							return false;
249
						}
250
						var partnerchecked = $("input[name='partnerCheck']:checked").length;
251
 
252
						if (!partnerchecked) {
253
							alert("You must check at least one partner.");
254
							return false;
255
						}
25066 tejbeer 256
 
257
						if(message === ""){
258
							alert("message is required");
259
							return false;
260
						}
261
 
24917 tejbeer 262
 
263
						$('#notify-table')
264
								.find('tr')
265
								.each(
266
										function() {
267
											var row = $(this);
268
 
269
											console.log(row);
270
											if (row.find(
271
													'input[name="itemCheck"]')
272
													.is(':checked')) {
273
												var currentRow = $(this)
274
														.closest("tr");
275
 
276
												var col1 = currentRow
277
														.find(
278
																"td:eq(0) input[type='checkbox']")
279
														.val(); // get current
280
												// row 1st TD
281
												// value
282
												var col2 = currentRow
283
														.find(
284
																"td:eq(1) input[name='responseTime']")
285
														.data('daterangepicker').startDate
286
														.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);// get
287
												// current
288
												// row 2nd TD
289
												var col3 = currentRow
290
														.find(
291
																"td:eq(2) input[name='procuredDate']")
292
														.data('daterangepicker').startDate
293
														.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
294
												; // get current
295
												// row 3rd TD
296
 
297
												itemIds = {
298
													"itemId" : col1,
299
													"responseTime" : col2,
300
													"procuredTime" : col3
301
 
302
												}
303
												ItemIdsJson.push(itemIds);
304
											}
305
 
306
										});
307
 
308
						$('#notify-order-table').find('tr').each(
309
								function() {
310
									var row = $(this);
311
 
312
									console.log(row);
313
									if (row.find('input[name="partnerCheck"]')
314
											.is(':checked')) {
315
										var currentRow = $(this).closest("tr");
316
 
317
										var col5 = currentRow.find("td:eq(2)")
318
												.html();
319
										var col6 = currentRow.find("td:eq(1)")
320
												.html();
321
 
322
										orderIds = {
323
											"orderId" : col5,
324
											"olditemId" : col6
325
										}
326
										orderIdsJSon.push(orderIds)
327
									}
328
								});
329
 
330
						jsonObject['itemIds'] = ItemIdsJson;
331
						jsonObject['orderIds'] = orderIdsJSon;
25066 tejbeer 332
						jsonObject['message'] = message;
24917 tejbeer 333
 
334
						console.log(jsonObject)
335
 
336
						if (confirm("Are you sure you want to notify the order") == true) {
337
 
338
							doPostAjaxRequestWithJsonHandler(context
339
									+ "/notifyOrder", JSON
340
									.stringify(jsonObject), function(response) {
341
								if (response == 'true') {
342
									alert("successfully Add");
343
									loadOrder("main-content");
344
								}
345
							});
346
						}
347
 
348
					});
349
 
24739 tejbeer 350
});
351
 
24917 tejbeer 352
function getItemColor(catalogId, itemId) {
353
	console.log(catalogId);
354
 
355
	doGetAjaxRequestHandler(context + "/getNotifyItemColor?catalogItemId="
356
			+ catalogId + "&itemId=" + itemId, function(response) {
357
		$('.notify-container .modal-content').html(response);
25066 tejbeer 358
		$('#textnotifymessage').hide();
24917 tejbeer 359
	});
360
}
361
 
24739 tejbeer 362
function loadGoodInventory(domId, search_text) {
363
	doGetAjaxRequestHandler(context
364
			+ "/getCurrentInventorySnapshot?searchTerm=" + search_text,
365
			function(response) {
366
				$('#' + domId).html(response);
367
			});
23343 ashik.ali 368
}
369
 
24739 tejbeer 370
function loadCatalog(domId, search_text) {
371
	doGetAjaxRequestHandler(context + "/getCatalog?searchTerm=" + search_text,
372
			function(response) {
373
				$('#' + domId).html(response);
374
			});
375
 
23343 ashik.ali 376
}
377
 
24739 tejbeer 378
function loadOrder(domId) {
379
	doGetAjaxRequestHandler(context + "/getInProcessOrder", function(response) {
24658 tejbeer 380
		$('#' + domId).html(response);
381
	});
24739 tejbeer 382
 
24658 tejbeer 383
}
384
 
24917 tejbeer 385
function loadtabOrder(domId) {
24739 tejbeer 386
	doGetAjaxRequestHandler(context + "/getKeepInTabOrder", function(response) {
23343 ashik.ali 387
		$('#' + domId).html(response);
388
	});
24739 tejbeer 389
 
23343 ashik.ali 390
}
391
 
25066 tejbeer 392
function loadnotifyOrder(domId) {
24917 tejbeer 393
	doGetAjaxRequestHandler(context + "/getAllNotifyOrder", function(response) {
394
		$('#' + domId).html(response);
395
	});
23343 ashik.ali 396
 
24917 tejbeer 397
}
398
 
24739 tejbeer 399
function getInventoryItemAgingByInterval(domId, searchContent) {
400
	doPostAjaxRequestWithJsonHandler(
401
			context + "/getInventoryItemAgingByInterval?searchContent="
402
					+ searchContent, JSON.stringify([ 5, 15, 30, 45 ]),
403
			function(response) {
404
				$('#' + domId).html(response);
405
			});
23343 ashik.ali 406
}
407
 
24739 tejbeer 408
function downloadAgingReport() {
409
	data = JSON.stringify([ 5, 15, 30, 45 ]), doAjaxPostDownload(context
410
			+ "/downloadInventoryItemAgingByInterval", data,
411
			"InventoryItemAging.xlsx");
412
 
413
}
414
 
415
function downloadReports() {
416
	doGetAjaxRequestHandler(context + "/reports", function(response) {
23637 amit.gupta 417
		$('#main-content').html(response);
418
	});
419
}
420
 
24739 tejbeer 421
function downloadItemLedgerReport() {
23343 ashik.ali 422
	console.log("downloadItemLedgerReport Button clicked")
24221 amit.gupta 423
	var dateWise = $("#dateWise").get(0).checked;
24739 tejbeer 424
	doAjaxGetDownload(context + "/itemLedger/complete/download?startDateTime="
425
			+ startDate + "&endDateTime=" + endDate + "&dateWise=" + dateWise,
23343 ashik.ali 426
			"ItemCompleteLedegerReport.xlsx");
427
}
428
 
24739 tejbeer 429
function getItemAgingNextPreviousItems(offset, searchContent) {
23343 ashik.ali 430
	console.log("getItemAgingNextPreviousItems() called");
24739 tejbeer 431
	doPostAjaxRequestWithJsonHandler(context
432
			+ "/getInventoryItemAgingByInterval?offset=" + offset
433
			+ "&searchContent=" + searchContent, JSON
434
			.stringify([ 5, 15, 30, 45 ]), function(response) {
23343 ashik.ali 435
		$('#main-content').html(response);
436
	});
24739 tejbeer 437
 
23343 ashik.ali 438
}
439
 
24739 tejbeer 440
function loadBadInventory(domId, search_text) {
441
	doGetAjaxRequestHandler(context + "/getBadInventorySnapshot?searchTerm="
442
			+ search_text, function(response) {
23343 ashik.ali 443
		$('#' + domId).html(response);
444
	});
445
}
446
 
24739 tejbeer 447
function loadGoodInventorySearchInfo(search_text) {
448
	loadGoodInventory("main-content", search_text);
23343 ashik.ali 449
}
450
 
24739 tejbeer 451
function loadCatalogSearchInfo(search_text) {
452
	loadCatalog("main-content", search_text);
23343 ashik.ali 453
}
454
 
24739 tejbeer 455
function loadItemLedgerReportDownloadPage(domId) {
456
	doGetAjaxRequestHandler(context + "/itemLedger/downloadPage", function(
457
			response) {
23343 ashik.ali 458
		$('#' + domId).html(response);
459
	});
24739 tejbeer 460
}
461
 
24917 tejbeer 462
function cancelOrder(orderId, status) {
25066 tejbeer 463
 
464
	cancelOrderId = orderId;
465
	cancelSatus = status;
24917 tejbeer 466
	console.log(cancelOrderId)
467
	console.log(cancelSatus)
468
	$('#orderCancelModal').modal('show');
469
	$("#textreason").hide();
470
}
471
 
472
function myFunction() {
25066 tejbeer 473
	var val = $("#selectreason").val();
474
	console.log(val);
475
	if (val == "other") {
476
		$("#textreason").show();
477
	} else {
478
		$("#textreason").hide();
479
	}
480
 
24917 tejbeer 481
}
25066 tejbeer 482
function requestcancelOrder() {
483
	val = $('#selectreason').val();
484
	if (val == "other") {
485
		reason = $('#textreason').val();
486
	} else {
487
		reason = $('#textreason').val();
488
	}
489
	console.log(reason);
490
	console.log(selectreason);
491
	console.log(cancelSatus);
492
	console.log(cancelOrderId);
493
	orderId = cancelOrderId;
494
	status = cancelSatus;
495
	if (reason == "" || reason == null || reason == undefined) {
496
		alert("reason field can't be empty");
497
		return false;
498
	}
24739 tejbeer 499
 
25066 tejbeer 500
	doPostAjaxRequestHandler(context + "/cancelOrder?orderId=" + orderId
501
			+ "&reason=" + reason + "&orderStatus=" + status,
502
			function(response) {
503
				if (response == 'true') {
504
					alert("successfully cancel");
24739 tejbeer 505
 
25066 tejbeer 506
					loadOrder("main-content");
507
				}
508
			});
24917 tejbeer 509
}