Subversion Repositories SmartDukaan

Rev

Rev 35459 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 35459 Rev 36961
Line 787... Line 787...
787
	jsonObject['reason'] = reason;
787
	jsonObject['reason'] = reason;
788
 
788
 
789
	console.log(jsonObject)
789
	console.log(jsonObject)
790
 
790
 
791
	if (confirm("Are you sure you want to cancel the order") == true) {
791
	if (confirm("Are you sure you want to cancel the order") == true) {
792
 
-
 
793
		doPostAjaxRequestWithJsonHandler(context + "/cancelOrder", JSON
-
 
794
			.stringify(jsonObject), function(response) {
-
 
795
			if (response == 'true') {
-
 
796
				alert("successfully cancel");
-
 
797
				$('#cancelOrder').modal('hide');
792
		submitCancelOrder(jsonObject, false);
798
				$('.modal-backdrop').remove();
-
 
799
				loadOrder("main-content");
-
 
800
			}
-
 
801
		});
-
 
802
	}
793
	}
803
 
794
 
804
}
795
}
805
 
796
 
-
 
797
function submitCancelOrder(jsonObject, confirmed) {
-
 
798
	var url = context + "/cancelOrder" + (confirmed ? "?confirmed=true" : "");
-
 
799
	doPostAjaxRequestWithJsonHandler(url, JSON.stringify(jsonObject), function(response) {
-
 
800
		var data = null;
-
 
801
		try { data = (typeof response === 'string') ? JSON.parse(response) : response; } catch(e) {}
-
 
802
 
-
 
803
		if (data && data.confirmationRequired) {
-
 
804
			var items = data.linkedMainOrders.map(function(o) {
-
 
805
				return o.itemDescription + " (" + o.quantity + " pcs)";
-
 
806
			}).join("\n");
-
 
807
			if (confirm("This item is part of a combo. Cancelling it will also cancel the linked main product(s):\n" + items + "\n\nConfirm?")) {
-
 
808
				submitCancelOrder(jsonObject, true);
-
 
809
			}
-
 
810
		} else if (response == 'true' || (data && data.response1 === true)) {
-
 
811
			alert("successfully cancel");
-
 
812
			$('#cancelOrder').modal('hide');
-
 
813
			$('.modal-backdrop').remove();
-
 
814
			loadOrder("main-content");
-
 
815
		}
-
 
816
	});
-
 
817
}
-
 
818
 
806
function loadNotifyCancelOrder(domId) {
819
function loadNotifyCancelOrder(domId) {
807
	doGetAjaxRequestHandler(context + "/getNotifiedCancelOrder", function(
820
	doGetAjaxRequestHandler(context + "/getNotifiedCancelOrder", function(
808
		response) {
821
		response) {
809
		$('#' + domId).html(response);
822
		$('#' + domId).html(response);
810
	});
823
	});