Subversion Repositories SmartDukaan

Rev

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

Rev 25146 Rev 25640
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;
-
 
12
	$(".review_order").live('click', function() {
10
	$(".review_order").live('click', function() {
13
		loadOrder("main-content");
11
		loadOrder("main-content");
14
	});
12
	});
15
 
13
 
16
	$(".keep-a-tab").live('click', function() {
14
	$(".keep-a-tab").live('click', function() {
Line 158... Line 156...
158
		if (keyCode == 13) {
156
		if (keyCode == 13) {
159
			$("#catalog-search-button").click();
157
			$("#catalog-search-button").click();
160
		}
158
		}
161
	});
159
	});
162
 
160
 
163
	$(".cancellation").live("click", function(e) {
161
	$(".cancellation").live(
-
 
162
			"click",
-
 
163
			function(e) {
164
		orderid = $(this).data('orderid');
164
				orderid = $(this).data('orderid');
-
 
165
				itemId = $(this).data('itemid');
-
 
166
 
-
 
167
				doGetAjaxRequestHandler(context
-
 
168
						+ "/getcancelOrderItems?itemId=" + itemId, function(
-
 
169
						response) {
165
		cancelOrder(orderid, "CANCELLED_DUE_TO_LOW_INVENTORY")
170
					$('.cancel-order-container .modal-content').html(response);
-
 
171
					$("#textreason").hide();
-
 
172
				});
166
	});
173
			});
167
 
174
 
168
	$(".order-request-submit").live("click", function(e) {
175
	$(".cancel-order-submit").live("click", function(e) {
169
		requestcancelOrder();
176
		requestcancelOrder();
170
	});
177
	});
171
	$(".keepatab").live("click", function(e) {
178
	$(".keepatab").live("click", function(e) {
172
		orderid = $(this).data('orderid');
179
		orderid = $(this).data('orderid');
173
		cancelOrder(orderid, "KEEP_A_TAB")
180
		cancelOrder(orderid, "KEEP_A_TAB")
Line 251... Line 258...
251
 
258
 
252
						if (!partnerchecked) {
259
						if (!partnerchecked) {
253
							alert("You must check at least one partner.");
260
							alert("You must check at least one partner.");
254
							return false;
261
							return false;
255
						}
262
						}
256
						
263
 
257
						if(message === ""){
264
						if (message === "") {
258
							alert("message is required");
265
							alert("message is required");
259
							return false;
266
							return false;
260
						}
267
						}
261
						
-
 
262
 
268
 
263
						$('#notify-table')
269
						$('#notify-table')
264
								.find('tr')
270
								.find('tr')
265
								.each(
271
								.each(
266
										function() {
272
										function() {
Line 338... Line 344...
338
							doPostAjaxRequestWithJsonHandler(context
344
							doPostAjaxRequestWithJsonHandler(context
339
									+ "/notifyOrder", JSON
345
									+ "/notifyOrder", JSON
340
									.stringify(jsonObject), function(response) {
346
									.stringify(jsonObject), function(response) {
341
								if (response == 'true') {
347
								if (response == 'true') {
342
									alert("successfully Add");
348
									alert("successfully Add");
-
 
349
									$('#notifyOrder').modal('hide');
-
 
350
									$('.modal-backdrop').remove();
343
									loadOrder("main-content");
351
									loadOrder("main-content");
344
								}
352
								}
345
							});
353
							});
346
						}
354
						}
347
 
355
 
Line 456... Line 464...
456
	doGetAjaxRequestHandler(context + "/itemLedger/downloadPage", function(
464
	doGetAjaxRequestHandler(context + "/itemLedger/downloadPage", function(
457
			response) {
465
			response) {
458
		$('#' + domId).html(response);
466
		$('#' + domId).html(response);
459
	});
467
	});
460
}
468
}
461
 
-
 
462
function cancelOrder(orderId, status) {
-
 
463
 
-
 
464
	cancelOrderId = orderId;
-
 
465
	cancelSatus = status;
-
 
466
	console.log(cancelOrderId)
-
 
467
	console.log(cancelSatus)
-
 
468
	$('#orderCancelModal').modal('show');
-
 
469
	$("#textreason").hide();
-
 
470
}
-
 
471
 
-
 
472
function myFunction() {
469
function myFunction() {
473
	var val = $("#selectreason").val();
470
	var val = $("#selectreason").val();
474
	console.log(val);
471
	console.log(val);
475
	if (val == "other") {
472
	if (val == "other") {
476
		$("#textreason").show();
473
		$("#textreason").show();
Line 478... Line 475...
478
		$("#textreason").hide();
475
		$("#textreason").hide();
479
	}
476
	}
480
 
477
 
481
}
478
}
482
function requestcancelOrder() {
479
function requestcancelOrder() {
-
 
480
	var jsonObject = {};
-
 
481
	var orderIdsJson = [];
-
 
482
	var orderIds;
483
	val = $('#selectreason').val();
483
	val = $('#selectreason').val();
484
	if (val == "other") {
484
	if (val == "other") {
485
		reason = $('#textreason').val();
485
		reason = $('#textreason').val();
486
	} else {
486
	} else {
487
		reason = val;
487
		reason = val;
488
	}
488
	}
489
	console.log(reason);
489
	console.log(reason);
490
	console.log(cancelSatus);
-
 
491
	console.log(cancelOrderId);
-
 
492
	orderId = cancelOrderId;
-
 
493
	status = cancelSatus;
-
 
-
 
490
 
494
	if (reason == "" || reason == null || reason == undefined) {
491
	if (reason == "" || reason == null || reason == undefined) {
495
		alert("reason field can't be empty");
492
		alert("reason field can't be empty");
496
		return false;
493
		return false;
497
	}
494
	}
498
 
495
 
499
	doPostAjaxRequestHandler(context + "/cancelOrder?orderId=" + orderId
496
	var partnerOrderCheck = $("input[name='partnerOrderCheck']:checked").length;
500
			+ "&reason=" + reason + "&orderStatus=" + status,
-
 
501
			function(response) {
-
 
502
				if (response == 'true') {
-
 
503
					alert("successfully cancel");
-
 
504
 
497
 
-
 
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();
505
					loadOrder("main-content");
528
				loadOrder("main-content");
506
				}
529
			}
507
			});
530
		});
-
 
531
	}
508
}
532
}