Subversion Repositories SmartDukaan

Rev

Rev 24753 | Rev 24950 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 24753 Rev 24917
Line 5... Line 5...
5
 
5
 
6
	$(".catalog").live('click', function() {
6
	$(".catalog").live('click', function() {
7
		loadCatalog("main-content", "");
7
		loadCatalog("main-content", "");
8
	});
8
	});
9
 
9
 
-
 
10
	var cancelOrderId;
-
 
11
	var cancelSatus;
10
	$(".review_order").live('click', function() {
12
	$(".review_order").live('click', function() {
11
		loadOrder("main-content");
13
		loadOrder("main-content");
12
	});
14
	});
13
 
15
 
14
	$(".keep-a-tab").live('click', function() {
16
	$(".keep-a-tab").live('click', function() {
15
		loadtabOrder("main-content");
17
		loadtabOrder("main-content");
16
	});
18
	});
-
 
19
	
-
 
20
	$(".notify_order").live('click', function() {
-
 
21
		loadnotifyOrder("main-content");
-
 
22
	});
-
 
23
	
17
	$(".item_aging").live('click', function() {
24
	$(".item_aging").live('click', function() {
18
		getInventoryItemAgingByInterval("main-content", "");
25
		getInventoryItemAgingByInterval("main-content", "");
19
	});
26
	});
20
 
27
 
21
	$("#item-aging-search-button").live('click', function() {
28
	$("#item-aging-search-button").live('click', function() {
Line 150... Line 157...
150
		var keyCode = e.keyCode || e.which;
157
		var keyCode = e.keyCode || e.which;
151
		if (keyCode == 13) {
158
		if (keyCode == 13) {
152
			$("#catalog-search-button").click();
159
			$("#catalog-search-button").click();
153
		}
160
		}
154
	});
161
	});
155
	
162
 
156
	$(".cancellation").live("click", function(e) {
163
	$(".cancellation").live("click", function(e) {
157
		orderid = $(this).data('orderid');
164
		orderid = $(this).data('orderid');
158
        cancelOrder(orderid, "CANCELLED_DUE_TO_LOW_INVENTORY")
165
		cancelOrder(orderid, "CANCELLED_DUE_TO_LOW_INVENTORY")
-
 
166
	});
-
 
167
	
-
 
168
	$(".order-request-submit").live("click", function(e) {
-
 
169
		requestcancelOrder();
159
	});
170
	});
160
 
-
 
161
	$(".keepatab").live("click", function(e) {
171
	$(".keepatab").live("click", function(e) {
162
		orderid = $(this).data('orderid');
172
		orderid = $(this).data('orderid');
163
		cancelOrder(orderid, "KEEP_A_TAB")
173
		cancelOrder(orderid, "KEEP_A_TAB")
164
		
174
 
165
	});
175
	});
166
	
176
	
-
 
177
	 
-
 
178
	  $(".request-cancel").live('click',
-
 
179
			     function(){
-
 
180
		  loadOrder("main-content");
-
 
181
				   
-
 
182
				 });
-
 
183
	
167
	$(".closeOrder").live("click", function(e) {
184
	$(".mk_button").on("click", function(){
-
 
185
		 
-
 
186
		});
-
 
187
 
-
 
188
	$(".closeOrder")
-
 
189
			.live(
-
 
190
					"click",
-
 
191
					function(e) {
168
		orderid = $(this).data('orderid');
192
						orderid = $(this).data('orderid');
169
		if (confirm("Are you sure you want to close the order") == true) {
193
						if (confirm("Are you sure you want to close the order") == true) {
-
 
194
 
-
 
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
						}
170
 
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
 
171
			doPostAjaxRequestHandler(context + "/closeOrder?orderId="
305
							doPostAjaxRequestWithJsonHandler(context
-
 
306
									+ "/notifyOrder", JSON
172
					+ orderd, function(response) {
307
									.stringify(jsonObject), function(response) {
173
				if (response == 'true') {
308
								if (response == 'true') {
174
					alert("successfully close");
309
									alert("successfully Add");
175
					loadtabOrder("main-content");
310
									loadOrder("main-content");
176
				}
311
								}
177
			});
312
							});
178
		}
313
						}
179
		
314
 
180
	});
315
					});
181
 
316
 
182
});
317
});
183
 
318
 
-
 
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
 
184
function loadGoodInventory(domId, search_text) {
328
function loadGoodInventory(domId, search_text) {
185
	doGetAjaxRequestHandler(context
329
	doGetAjaxRequestHandler(context
186
			+ "/getCurrentInventorySnapshot?searchTerm=" + search_text,
330
			+ "/getCurrentInventorySnapshot?searchTerm=" + search_text,
187
			function(response) {
331
			function(response) {
188
				$('#' + domId).html(response);
332
				$('#' + domId).html(response);
Line 202... Line 346...
202
		$('#' + domId).html(response);
346
		$('#' + domId).html(response);
203
	});
347
	});
204
 
348
 
205
}
349
}
206
 
350
 
207
function loadtabOrder(domId){
351
function loadtabOrder(domId) {
208
	doGetAjaxRequestHandler(context + "/getKeepInTabOrder", function(response) {
352
	doGetAjaxRequestHandler(context + "/getKeepInTabOrder", function(response) {
209
		$('#' + domId).html(response);
353
		$('#' + domId).html(response);
210
	});
354
	});
211
 
355
 
212
}
356
}
213
 
357
 
-
 
358
function loadnotifyOrder(domId){
-
 
359
	doGetAjaxRequestHandler(context + "/getAllNotifyOrder", function(response) {
-
 
360
		$('#' + domId).html(response);
-
 
361
	});
-
 
362
 
-
 
363
}
-
 
364
 
-
 
365
 
214
 
366
 
215
function getInventoryItemAgingByInterval(domId, searchContent) {
367
function getInventoryItemAgingByInterval(domId, searchContent) {
216
	doPostAjaxRequestWithJsonHandler(
368
	doPostAjaxRequestWithJsonHandler(
217
			context + "/getInventoryItemAgingByInterval?searchContent="
369
			context + "/getInventoryItemAgingByInterval?searchContent="
218
					+ searchContent, JSON.stringify([ 5, 15, 30, 45 ]),
370
					+ searchContent, JSON.stringify([ 5, 15, 30, 45 ]),
Line 273... Line 425...
273
			response) {
425
			response) {
274
		$('#' + domId).html(response);
426
		$('#' + domId).html(response);
275
	});
427
	});
276
}
428
}
277
 
429
 
278
function cancelOrder(orderId,status) {
430
function cancelOrder(orderId, status) {
279
	console.log(orderId);
-
 
280
	
431
	
-
 
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
	 }
281
	
448
	
282
	var dialog = bootbox
-
 
283
	.dialog({
449
}
284
		title : "Are you sure want to cancel the order",
450
function requestcancelOrder(){
285
		message : "<div class=form-inline'>"
-
 
286
				+ "<label for='reason'>Reason:</label>"
451
val=$('#selectreason').val();
287
				+ "<textarea class='form-control' rows='1' id='reason'></textarea>"
-
 
288
				+ "</div>",
-
 
289
		buttons : {
-
 
290
			cancel : {
-
 
291
				label : "cancel",
452
 if(val=="other"){
292
				className : 'btn-danger',
-
 
293
				callback : function() {
-
 
294
					loadOrder("main-content");
453
	 reason = $('#textreason').val(); 
295
				}
454
 }
296
			},
455
 else{
-
 
456
reason = $('#textreason').val();
297
			ok : {
457
 }
298
				label : "ok",
458
console.log(reason);
299
				className : 'btn-info',
459
console.log(selectreason);
300
				callback : function() {
460
console.log(cancelSatus);
301
					reason = $('#reason').val();
461
console.log(cancelOrderId);
302
					console.log(reason);
462
orderId = cancelOrderId;
303
					if (reason == ""
463
status = cancelSatus;
304
							|| reason == null
464
if (reason == "" || reason == null
305
							|| reason == undefined) {
465
		|| reason == undefined) {
306
						alert("reason field can't be empty");
466
	alert("reason field can't be empty");
307
						return false;
467
	return false;
308
					}
468
}
309
						
469
 
310
					doPostAjaxRequestHandler(context + "/cancelOrder?orderId="
470
doPostAjaxRequestHandler(context
-
 
471
		+ "/cancelOrder?orderId=" + orderId
311
							+ orderId + "&reason=" + reason+ "&orderStatus=" + status, function(response) {
472
		+ "&reason=" + reason + "&orderStatus="
-
 
473
		+ status, function(response) {
312
						if (response == 'true') {
474
	if (response == 'true') {
313
							alert("successfully cancel");
475
		alert("successfully cancel");
314
 
-
 
315
							loadOrder("main-content");
-
 
316
						}
-
 
317
					});
-
 
318
 
-
 
319
 
-
 
320
				}
-
 
321
			}
-
 
322
		}
-
 
323
	});
-
 
324
 
476
 
-
 
477
		loadOrder("main-content");
-
 
478
	}
-
 
479
});
325
}
480
}
-
 
481