Subversion Repositories SmartDukaan

Rev

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