Subversion Repositories SmartDukaan

Rev

Rev 25146 | Rev 25698 | 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
 
223
	$('#overridemessage').live('change', function() {
224
		if ($(this).is(':checked')) {
225
			$('#textnotifymessage').show();
226
			$('#textnotifymessage').focus();
227
		} else {
228
			$('#textnotifymessage').hide();
229
		}
230
	});
231
 
24917 tejbeer 232
	$(".notify-submit")
233
			.live(
234
					"click",
235
					function(e) {
236
 
237
						var jsonObject = {};
238
						var orderIdsJSon = [];
239
						var ItemIdsJson = [];
240
						var itemIds;
241
						var orderIds;
25066 tejbeer 242
						var message;
24917 tejbeer 243
 
25066 tejbeer 244
						if ($('#overridemessage').is(':checked')) {
245
							message = $('#textnotifymessage').val();
246
						} else {
247
							message = $('#notifymessage').text();
248
						}
249
 
250
						console.log(message);
24917 tejbeer 251
						var itemchecked = $("input[name='itemCheck']:checked").length;
252
 
253
						if (!itemchecked) {
254
							alert("You must check at least one item.");
255
							return false;
256
						}
257
						var partnerchecked = $("input[name='partnerCheck']:checked").length;
258
 
259
						if (!partnerchecked) {
260
							alert("You must check at least one partner.");
261
							return false;
262
						}
25640 tejbeer 263
 
264
						if (message === "") {
25066 tejbeer 265
							alert("message is required");
266
							return false;
267
						}
24917 tejbeer 268
 
269
						$('#notify-table')
270
								.find('tr')
271
								.each(
272
										function() {
273
											var row = $(this);
274
 
275
											console.log(row);
276
											if (row.find(
277
													'input[name="itemCheck"]')
278
													.is(':checked')) {
279
												var currentRow = $(this)
280
														.closest("tr");
281
 
282
												var col1 = currentRow
283
														.find(
284
																"td:eq(0) input[type='checkbox']")
285
														.val(); // get current
286
												// row 1st TD
287
												// value
288
												var col2 = currentRow
289
														.find(
290
																"td:eq(1) input[name='responseTime']")
291
														.data('daterangepicker').startDate
292
														.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);// get
293
												// current
294
												// row 2nd TD
295
												var col3 = currentRow
296
														.find(
297
																"td:eq(2) input[name='procuredDate']")
298
														.data('daterangepicker').startDate
299
														.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
300
												; // get current
301
												// row 3rd TD
302
 
303
												itemIds = {
304
													"itemId" : col1,
305
													"responseTime" : col2,
306
													"procuredTime" : col3
307
 
308
												}
309
												ItemIdsJson.push(itemIds);
310
											}
311
 
312
										});
313
 
314
						$('#notify-order-table').find('tr').each(
315
								function() {
316
									var row = $(this);
317
 
318
									console.log(row);
319
									if (row.find('input[name="partnerCheck"]')
320
											.is(':checked')) {
321
										var currentRow = $(this).closest("tr");
322
 
323
										var col5 = currentRow.find("td:eq(2)")
324
												.html();
325
										var col6 = currentRow.find("td:eq(1)")
326
												.html();
327
 
328
										orderIds = {
329
											"orderId" : col5,
330
											"olditemId" : col6
331
										}
332
										orderIdsJSon.push(orderIds)
333
									}
334
								});
335
 
336
						jsonObject['itemIds'] = ItemIdsJson;
337
						jsonObject['orderIds'] = orderIdsJSon;
25066 tejbeer 338
						jsonObject['message'] = message;
24917 tejbeer 339
 
340
						console.log(jsonObject)
341
 
342
						if (confirm("Are you sure you want to notify the order") == true) {
343
 
344
							doPostAjaxRequestWithJsonHandler(context
345
									+ "/notifyOrder", JSON
346
									.stringify(jsonObject), function(response) {
347
								if (response == 'true') {
348
									alert("successfully Add");
25640 tejbeer 349
									$('#notifyOrder').modal('hide');
350
									$('.modal-backdrop').remove();
24917 tejbeer 351
									loadOrder("main-content");
352
								}
353
							});
354
						}
355
 
356
					});
357
 
24739 tejbeer 358
});
359
 
24917 tejbeer 360
function getItemColor(catalogId, itemId) {
361
	console.log(catalogId);
362
 
363
	doGetAjaxRequestHandler(context + "/getNotifyItemColor?catalogItemId="
364
			+ catalogId + "&itemId=" + itemId, function(response) {
365
		$('.notify-container .modal-content').html(response);
25066 tejbeer 366
		$('#textnotifymessage').hide();
24917 tejbeer 367
	});
368
}
369
 
24739 tejbeer 370
function loadGoodInventory(domId, search_text) {
371
	doGetAjaxRequestHandler(context
372
			+ "/getCurrentInventorySnapshot?searchTerm=" + search_text,
373
			function(response) {
374
				$('#' + domId).html(response);
375
			});
23343 ashik.ali 376
}
377
 
24739 tejbeer 378
function loadCatalog(domId, search_text) {
379
	doGetAjaxRequestHandler(context + "/getCatalog?searchTerm=" + search_text,
380
			function(response) {
381
				$('#' + domId).html(response);
382
			});
383
 
23343 ashik.ali 384
}
385
 
24739 tejbeer 386
function loadOrder(domId) {
387
	doGetAjaxRequestHandler(context + "/getInProcessOrder", function(response) {
24658 tejbeer 388
		$('#' + domId).html(response);
389
	});
24739 tejbeer 390
 
24658 tejbeer 391
}
392
 
24917 tejbeer 393
function loadtabOrder(domId) {
24739 tejbeer 394
	doGetAjaxRequestHandler(context + "/getKeepInTabOrder", function(response) {
23343 ashik.ali 395
		$('#' + domId).html(response);
396
	});
24739 tejbeer 397
 
23343 ashik.ali 398
}
399
 
25066 tejbeer 400
function loadnotifyOrder(domId) {
24917 tejbeer 401
	doGetAjaxRequestHandler(context + "/getAllNotifyOrder", function(response) {
402
		$('#' + domId).html(response);
403
	});
23343 ashik.ali 404
 
24917 tejbeer 405
}
406
 
24739 tejbeer 407
function getInventoryItemAgingByInterval(domId, searchContent) {
408
	doPostAjaxRequestWithJsonHandler(
409
			context + "/getInventoryItemAgingByInterval?searchContent="
410
					+ searchContent, JSON.stringify([ 5, 15, 30, 45 ]),
411
			function(response) {
412
				$('#' + domId).html(response);
413
			});
23343 ashik.ali 414
}
415
 
24739 tejbeer 416
function downloadAgingReport() {
417
	data = JSON.stringify([ 5, 15, 30, 45 ]), doAjaxPostDownload(context
418
			+ "/downloadInventoryItemAgingByInterval", data,
419
			"InventoryItemAging.xlsx");
420
 
421
}
422
 
423
function downloadReports() {
424
	doGetAjaxRequestHandler(context + "/reports", function(response) {
23637 amit.gupta 425
		$('#main-content').html(response);
426
	});
427
}
428
 
24739 tejbeer 429
function downloadItemLedgerReport() {
23343 ashik.ali 430
	console.log("downloadItemLedgerReport Button clicked")
24221 amit.gupta 431
	var dateWise = $("#dateWise").get(0).checked;
24739 tejbeer 432
	doAjaxGetDownload(context + "/itemLedger/complete/download?startDateTime="
433
			+ startDate + "&endDateTime=" + endDate + "&dateWise=" + dateWise,
23343 ashik.ali 434
			"ItemCompleteLedegerReport.xlsx");
435
}
436
 
24739 tejbeer 437
function getItemAgingNextPreviousItems(offset, searchContent) {
23343 ashik.ali 438
	console.log("getItemAgingNextPreviousItems() called");
24739 tejbeer 439
	doPostAjaxRequestWithJsonHandler(context
440
			+ "/getInventoryItemAgingByInterval?offset=" + offset
441
			+ "&searchContent=" + searchContent, JSON
442
			.stringify([ 5, 15, 30, 45 ]), function(response) {
23343 ashik.ali 443
		$('#main-content').html(response);
444
	});
24739 tejbeer 445
 
23343 ashik.ali 446
}
447
 
24739 tejbeer 448
function loadBadInventory(domId, search_text) {
449
	doGetAjaxRequestHandler(context + "/getBadInventorySnapshot?searchTerm="
450
			+ search_text, function(response) {
23343 ashik.ali 451
		$('#' + domId).html(response);
452
	});
453
}
454
 
24739 tejbeer 455
function loadGoodInventorySearchInfo(search_text) {
456
	loadGoodInventory("main-content", search_text);
23343 ashik.ali 457
}
458
 
24739 tejbeer 459
function loadCatalogSearchInfo(search_text) {
460
	loadCatalog("main-content", search_text);
23343 ashik.ali 461
}
462
 
24739 tejbeer 463
function loadItemLedgerReportDownloadPage(domId) {
464
	doGetAjaxRequestHandler(context + "/itemLedger/downloadPage", function(
465
			response) {
23343 ashik.ali 466
		$('#' + domId).html(response);
467
	});
24739 tejbeer 468
}
24917 tejbeer 469
function myFunction() {
25066 tejbeer 470
	var val = $("#selectreason").val();
471
	console.log(val);
472
	if (val == "other") {
473
		$("#textreason").show();
474
	} else {
475
		$("#textreason").hide();
476
	}
477
 
24917 tejbeer 478
}
25066 tejbeer 479
function requestcancelOrder() {
25640 tejbeer 480
	var jsonObject = {};
481
	var orderIdsJson = [];
482
	var orderIds;
25066 tejbeer 483
	val = $('#selectreason').val();
484
	if (val == "other") {
485
		reason = $('#textreason').val();
486
	} else {
25146 tejbeer 487
		reason = val;
25066 tejbeer 488
	}
489
	console.log(reason);
25640 tejbeer 490
 
25066 tejbeer 491
	if (reason == "" || reason == null || reason == undefined) {
492
		alert("reason field can't be empty");
493
		return false;
494
	}
24739 tejbeer 495
 
25640 tejbeer 496
	var partnerOrderCheck = $("input[name='partnerOrderCheck']:checked").length;
24739 tejbeer 497
 
25640 tejbeer 498
	if (!partnerOrderCheck) {
499
		alert("You must check at least one order.");
500
		return false;
501
	}
502
 
503
	$('#cancel-order-table').find('tr').each(function() {
504
		var row = $(this);
505
 
506
		console.log(row);
507
		if (row.find('input[name="partnerOrderCheck"]').is(':checked')) {
508
			var currentRow = $(this).closest("tr");
509
 
510
			var orderId = currentRow.find("td:eq(2)").html();
511
 
512
			orderIdsJson.push(orderId)
513
		}
514
	});
515
 
516
	jsonObject['orderIds'] = orderIdsJson;
517
	jsonObject['reason'] = reason;
518
 
519
	console.log(jsonObject)
520
	if (confirm("Are you sure you want to cancel the order") == true) {
521
 
522
		doPostAjaxRequestWithJsonHandler(context + "/cancelOrder", JSON
523
				.stringify(jsonObject), function(response) {
524
			if (response == 'true') {
525
				alert("successfully cancel");
526
				$('#cancelOrder').modal('hide');
527
				$('.modal-backdrop').remove();
528
				loadOrder("main-content");
529
			}
530
		});
531
	}
24917 tejbeer 532
}