Subversion Repositories SmartDukaan

Rev

Rev 24753 | Rev 24950 | 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
	});
24917 tejbeer 19
 
20
	$(".notify_order").live('click', function() {
21
		loadnotifyOrder("main-content");
22
	});
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
	});
24917 tejbeer 167
 
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
	});
176
 
24917 tejbeer 177
 
178
	  $(".request-cancel").live('click',
179
			     function(){
180
		  loadOrder("main-content");
181
 
182
				 });
183
 
184
	$(".mk_button").on("click", function(){
185
 
186
		});
23343 ashik.ali 187
 
24917 tejbeer 188
	$(".closeOrder")
189
			.live(
190
					"click",
191
					function(e) {
192
						orderid = $(this).data('orderid');
193
						if (confirm("Are you sure you want to close the order") == true) {
24739 tejbeer 194
 
24917 tejbeer 195
							doPostAjaxRequestHandler(context
196
									+ "/closeOrder?orderId=" + orderd,
197
									function(response) {
198
										if (response == 'true') {
199
											alert("successfully close");
200
											loadtabOrder("main-content");
201
										}
202
									});
203
						}
204
 
205
					});
206
 
207
	$(".notify-submit")
208
			.live(
209
					"click",
210
					function(e) {
211
 
212
						var jsonObject = {};
213
						var orderIdsJSon = [];
214
						var ItemIdsJson = [];
215
						var itemIds;
216
						var orderIds;
217
 
218
						var itemchecked = $("input[name='itemCheck']:checked").length;
219
 
220
						if (!itemchecked) {
221
							alert("You must check at least one item.");
222
							return false;
223
						}
224
						var partnerchecked = $("input[name='partnerCheck']:checked").length;
225
 
226
						if (!partnerchecked) {
227
							alert("You must check at least one partner.");
228
							return false;
229
						}
230
 
231
						$('#notify-table')
232
								.find('tr')
233
								.each(
234
										function() {
235
											var row = $(this);
236
 
237
											console.log(row);
238
											if (row.find(
239
													'input[name="itemCheck"]')
240
													.is(':checked')) {
241
												var currentRow = $(this)
242
														.closest("tr");
243
 
244
												var col1 = currentRow
245
														.find(
246
																"td:eq(0) input[type='checkbox']")
247
														.val(); // get current
248
												// row 1st TD
249
												// value
250
												var col2 = currentRow
251
														.find(
252
																"td:eq(1) input[name='responseTime']")
253
														.data('daterangepicker').startDate
254
														.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);// get
255
												// current
256
												// row 2nd TD
257
												var col3 = currentRow
258
														.find(
259
																"td:eq(2) input[name='procuredDate']")
260
														.data('daterangepicker').startDate
261
														.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
262
												; // get current
263
												// row 3rd TD
264
 
265
												itemIds = {
266
													"itemId" : col1,
267
													"responseTime" : col2,
268
													"procuredTime" : col3
269
 
270
												}
271
												ItemIdsJson.push(itemIds);
272
											}
273
 
274
										});
275
 
276
						$('#notify-order-table').find('tr').each(
277
								function() {
278
									var row = $(this);
279
 
280
									console.log(row);
281
									if (row.find('input[name="partnerCheck"]')
282
											.is(':checked')) {
283
										var currentRow = $(this).closest("tr");
284
 
285
										var col5 = currentRow.find("td:eq(2)")
286
												.html();
287
										var col6 = currentRow.find("td:eq(1)")
288
												.html();
289
 
290
										orderIds = {
291
											"orderId" : col5,
292
											"olditemId" : col6
293
										}
294
										orderIdsJSon.push(orderIds)
295
									}
296
								});
297
 
298
						jsonObject['itemIds'] = ItemIdsJson;
299
						jsonObject['orderIds'] = orderIdsJSon;
300
 
301
						console.log(jsonObject)
302
 
303
						if (confirm("Are you sure you want to notify the order") == true) {
304
 
305
							doPostAjaxRequestWithJsonHandler(context
306
									+ "/notifyOrder", JSON
307
									.stringify(jsonObject), function(response) {
308
								if (response == 'true') {
309
									alert("successfully Add");
310
									loadOrder("main-content");
311
								}
312
							});
313
						}
314
 
315
					});
316
 
24739 tejbeer 317
});
318
 
24917 tejbeer 319
function getItemColor(catalogId, itemId) {
320
	console.log(catalogId);
321
 
322
	doGetAjaxRequestHandler(context + "/getNotifyItemColor?catalogItemId="
323
			+ catalogId + "&itemId=" + itemId, function(response) {
324
		$('.notify-container .modal-content').html(response);
325
	});
326
}
327
 
24739 tejbeer 328
function loadGoodInventory(domId, search_text) {
329
	doGetAjaxRequestHandler(context
330
			+ "/getCurrentInventorySnapshot?searchTerm=" + search_text,
331
			function(response) {
332
				$('#' + domId).html(response);
333
			});
23343 ashik.ali 334
}
335
 
24739 tejbeer 336
function loadCatalog(domId, search_text) {
337
	doGetAjaxRequestHandler(context + "/getCatalog?searchTerm=" + search_text,
338
			function(response) {
339
				$('#' + domId).html(response);
340
			});
341
 
23343 ashik.ali 342
}
343
 
24739 tejbeer 344
function loadOrder(domId) {
345
	doGetAjaxRequestHandler(context + "/getInProcessOrder", function(response) {
24658 tejbeer 346
		$('#' + domId).html(response);
347
	});
24739 tejbeer 348
 
24658 tejbeer 349
}
350
 
24917 tejbeer 351
function loadtabOrder(domId) {
24739 tejbeer 352
	doGetAjaxRequestHandler(context + "/getKeepInTabOrder", function(response) {
23343 ashik.ali 353
		$('#' + domId).html(response);
354
	});
24739 tejbeer 355
 
23343 ashik.ali 356
}
357
 
24917 tejbeer 358
function loadnotifyOrder(domId){
359
	doGetAjaxRequestHandler(context + "/getAllNotifyOrder", function(response) {
360
		$('#' + domId).html(response);
361
	});
23343 ashik.ali 362
 
24917 tejbeer 363
}
364
 
365
 
366
 
24739 tejbeer 367
function getInventoryItemAgingByInterval(domId, searchContent) {
368
	doPostAjaxRequestWithJsonHandler(
369
			context + "/getInventoryItemAgingByInterval?searchContent="
370
					+ searchContent, JSON.stringify([ 5, 15, 30, 45 ]),
371
			function(response) {
372
				$('#' + domId).html(response);
373
			});
23343 ashik.ali 374
}
375
 
24739 tejbeer 376
function downloadAgingReport() {
377
	data = JSON.stringify([ 5, 15, 30, 45 ]), doAjaxPostDownload(context
378
			+ "/downloadInventoryItemAgingByInterval", data,
379
			"InventoryItemAging.xlsx");
380
 
381
}
382
 
383
function downloadReports() {
384
	doGetAjaxRequestHandler(context + "/reports", function(response) {
23637 amit.gupta 385
		$('#main-content').html(response);
386
	});
387
}
388
 
24739 tejbeer 389
function downloadItemLedgerReport() {
23343 ashik.ali 390
	console.log("downloadItemLedgerReport Button clicked")
24221 amit.gupta 391
	var dateWise = $("#dateWise").get(0).checked;
24739 tejbeer 392
	doAjaxGetDownload(context + "/itemLedger/complete/download?startDateTime="
393
			+ startDate + "&endDateTime=" + endDate + "&dateWise=" + dateWise,
23343 ashik.ali 394
			"ItemCompleteLedegerReport.xlsx");
395
}
396
 
24739 tejbeer 397
function getItemAgingNextPreviousItems(offset, searchContent) {
23343 ashik.ali 398
	console.log("getItemAgingNextPreviousItems() called");
24739 tejbeer 399
	doPostAjaxRequestWithJsonHandler(context
400
			+ "/getInventoryItemAgingByInterval?offset=" + offset
401
			+ "&searchContent=" + searchContent, JSON
402
			.stringify([ 5, 15, 30, 45 ]), function(response) {
23343 ashik.ali 403
		$('#main-content').html(response);
404
	});
24739 tejbeer 405
 
23343 ashik.ali 406
}
407
 
24739 tejbeer 408
function loadBadInventory(domId, search_text) {
409
	doGetAjaxRequestHandler(context + "/getBadInventorySnapshot?searchTerm="
410
			+ search_text, function(response) {
23343 ashik.ali 411
		$('#' + domId).html(response);
412
	});
413
}
414
 
24739 tejbeer 415
function loadGoodInventorySearchInfo(search_text) {
416
	loadGoodInventory("main-content", search_text);
23343 ashik.ali 417
}
418
 
24739 tejbeer 419
function loadCatalogSearchInfo(search_text) {
420
	loadCatalog("main-content", search_text);
23343 ashik.ali 421
}
422
 
24739 tejbeer 423
function loadItemLedgerReportDownloadPage(domId) {
424
	doGetAjaxRequestHandler(context + "/itemLedger/downloadPage", function(
425
			response) {
23343 ashik.ali 426
		$('#' + domId).html(response);
427
	});
24739 tejbeer 428
}
429
 
24917 tejbeer 430
function cancelOrder(orderId, status) {
24753 tejbeer 431
 
24917 tejbeer 432
	cancelOrderId=orderId;
433
	cancelSatus=status;
434
	console.log(cancelOrderId)
435
	console.log(cancelSatus)
436
	$('#orderCancelModal').modal('show');
437
	$("#textreason").hide();
438
}
439
 
440
function myFunction() {
441
     var val = $("#selectreason").val();
442
	    console.log(val);
443
	 if(val=="other"){
444
	     $("#textreason").show();
445
	 } else {
446
	     $("#textreason").hide();
447
	 }
24753 tejbeer 448
 
24917 tejbeer 449
}
450
function requestcancelOrder(){
451
val=$('#selectreason').val();
452
 if(val=="other"){
453
	 reason = $('#textreason').val(); 
454
 }
455
 else{
456
reason = $('#textreason').val();
457
 }
458
console.log(reason);
459
console.log(selectreason);
460
console.log(cancelSatus);
461
console.log(cancelOrderId);
462
orderId = cancelOrderId;
463
status = cancelSatus;
464
if (reason == "" || reason == null
465
		|| reason == undefined) {
466
	alert("reason field can't be empty");
467
	return false;
468
}
24739 tejbeer 469
 
24917 tejbeer 470
doPostAjaxRequestHandler(context
471
		+ "/cancelOrder?orderId=" + orderId
472
		+ "&reason=" + reason + "&orderStatus="
473
		+ status, function(response) {
474
	if (response == 'true') {
475
		alert("successfully cancel");
24739 tejbeer 476
 
24917 tejbeer 477
		loadOrder("main-content");
478
	}
479
});
480
}
24739 tejbeer 481