Subversion Repositories SmartDukaan

Rev

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

Rev 24406 Rev 24409
Line 34... Line 34...
34
			doPostAjaxRequestWithJsonHandler(
34
			doPostAjaxRequestWithJsonHandler(
35
					context+"/add-pricing", JSON.stringify(obj),
35
					context+"/add-pricing", JSON.stringify(obj),
36
					function(response) {
36
					function(response) {
37
						if (response == 'true') {
37
						if (response == 'true') {
38
							//$('#addPriceModal').find('button.close').trigger('click');
38
							//$('#addPriceModal').find('button.close').trigger('click');
39
							setTimeout(() => {
-
 
40
								alert("Prices Successfully Updated for " + $("#typeaheaditem1").val());
39
							alert("Prices Successfully Updated for " + $("#typeaheaditem1").val());
41
								//loadPriceDrop("main-content");
-
 
42
							}, 500);
-
 
43
						} else {
40
						} else {
44
							alert("Something went wrong pls try after sometime");
41
							alert("Something went wrong pls try after sometime");
45
						}
42
						}
46
					}
43
					}
47
			);
44
			);
Line 51... Line 48...
51
	$("button.addPriceDrop").live('click', function() {
48
	$("button.addPriceDrop").live('click', function() {
52
		if($("#typeaheaditem").val().trim().length == 0){
49
		if($("#typeaheaditem").val().trim().length == 0){
53
			alert("Please choose Item");
50
			alert("Please choose Item");
54
			return;
51
			return;
55
		}
52
		}
56
 
-
 
57
		var priceDrop = $("#pd").val();
53
		var newDp = $("#newDp").val();
58
		var newTp = $("#newTp").val();
54
		var newTp = $("#newTp").val();
59
		var newMop = $("#newMop").val();
55
		var newMop = $("#newMop").val();
60
		var newNlc = $("#newNlc").val();
-
 
61
		var affectedOn = $("#affectedDate").val();
56
		var affectedOn = $("#affectedDate").val();
62
		var allColors = $("#allColors").prop('checked');
57
		var allColors = $("#allColors").prop('checked');
-
 
58
 
63
		if(priceDrop.length == 0 || parseFloat(priceDrop) == 0) {
59
		if(newDp.length == 0 || parseFloat(newDp) == 0) {
64
			alert("Price Drop should not be empty");
60
			alert("New Tp should not be empty");
65
			return;
61
			return;
66
		}
62
		}
67
		if(newTp.length == 0 || parseFloat(newTp) == 0) {
63
		if(newTp.length == 0 || parseFloat(newTp) == 0) {
68
			alert("New Tp should not be empty");
64
			alert("New Tp should not be empty");
69
			return;
65
			return;
70
		}
66
		}
71
		if(newMop.length == 0 || parseFloat(newMop) == 0) {
67
		if(newMop.length == 0 || parseFloat(newMop) == 0) {
72
			alert("New Mop should not be empty");
68
			alert("New Mop should not be empty");
73
			return;
69
			return;
74
		}
70
		}
75
		if(newNlc.length == 0 || parseFloat(newNlc) == 0) {
-
 
76
			alert("New Nlc should not be empty");
-
 
77
			return;
-
 
78
		}
-
 
79
 
71
 
80
		if(affectedOn.length == 0) {
72
		if(affectedOn.length == 0) {
81
			alert("Affected Date Should not be empty");
73
			alert("Affected Date Should not be empty");
82
			return;
74
			return;
83
		}
75
		}
-
 
76
		//as of now allColors is set to true. This means that all colors are eligible for price drop
84
		if(confirm("Are you sure?")) {
77
		if(confirm("Are you sure?")) {
85
			var obj = {
78
			var obj = {
86
					itemId:currentItem.itemId,
79
					itemId:currentItem.itemId,
-
 
80
					dp:parseFloat(newDp),
87
					tp:parseFloat(newTp),
81
					tp:parseFloat(newTp),
88
					pd:parseFloat(priceDrop),
-
 
89
					mop:parseFloat(newMop),
82
					mop:parseFloat(newMop),
90
					nlc:parseFloat(newNlc),
-
 
91
					allColors:allColors,
83
					allColors:true,
92
					affectedDate:startDate
84
					affectedDate:startDate
93
			}
85
			}
94
			doPostAjaxRequestWithJsonHandler(
86
			doPostAjaxRequestWithJsonHandler(
95
					context+"/priceDrop", JSON.stringify(obj),
87
					context+"/priceDrop", JSON.stringify(obj),
96
					function(response) {
88
					function(response) {
97
						if (response == 'true') {
89
						if (response == 'true') {
98
							//$('#newPriceDropModal').find('button.close').trigger('click');
90
							$('#newPriceDropModal').find('button.close').trigger('click');
99
							setTimeout(() => {
91
							setTimeout(() => {
100
								alert("PriceDrop added successfully from " + $("#typeaheaditem").val());
92
								alert("PriceDrop added successfully from " + $("#typeaheaditem").val());
101
								loadPriceDrop("main-content");
93
								loadPriceDrop("main-content");
102
							}, 500);
94
							}, 500);
103
						} else {
95
						} else {
Line 258... Line 250...
258
  
250
  
259
  	getItemAheadOptions($("#typeaheaditem"),function(selectedItem){
251
  	getItemAheadOptions($("#typeaheaditem"),function(selectedItem){
260
		currentItem = selectedItem;
252
		currentItem = selectedItem;
261
		doGetAjaxRequestHandler(context+"/item-pricing/"+currentItem.itemId, function(response){
253
		doGetAjaxRequestHandler(context+"/item-pricing/"+currentItem.itemId, function(response){
262
			response = JSON.parse(response);
254
			response = JSON.parse(response);
263
			$('#currentDp').val(response.dp);
255
			$('#oldDp').html(response.dp);
264
			$('#oldMop').html(response.mop);
256
			$('#oldMop').html(response.mop);
265
			$('#oldTp').html(response.tp);
257
			$('#oldTp').html(response.tp);
266
			$('#oldNlc').html(response.nlc);
258
			$('#oldNlc').html(response.nlc);
267
		});
259
		});
268
	});
260
	});