Subversion Repositories SmartDukaan

Rev

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