Subversion Repositories SmartDukaan

Rev

Rev 24060 | Rev 24066 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
23819 govind 1
$(function() {
2
	$(".price_drop").live('click', function() {
3
		loadPriceDrop("main-content");
4
	});
24019 amit.gupta 5
	$("button.update-mop").live('click', function() {
6
		if($("#typeaheaditem").val().trim().length == 0){
7
			alert("Please choose Item");
8
			return;
9
		}
10
		var newMop = $("#newMop").val();
11
		var allColors = $("#allColors").prop('checked');
12
 
13
		if(newMop.length == 0 || parseFloat(newMop) == 0) {
14
			alert("New Mop should not be empty");
15
			return;
16
		}
17
		if(confirm("Are you sure?")) {
18
			var obj = {
19
					itemId:currentItem.itemId,
20
					mop:parseFloat(newMop),
21
					allColors:allColors,
22
			}
23
			doPostAjaxRequestWithJsonHandler(
24
					context+"/updateMop", JSON.stringify(obj),
25
					function(response) {
26
						if (response == 'true') {
27
							$('#newPriceDropModal').find('button.close').trigger('click');
28
							setTimeout(() => {
24062 amit.gupta 29
								alert("Pricing added successfully")
24019 amit.gupta 30
								loadPriceDrop("main-content");
31
							}, 500);
32
						} else {
33
							alert("Something went wrong pls try after sometime");
34
						}
35
					}
36
			);
37
		}
38
	});
24052 amit.gupta 39
	$("button.add-pricing").live('click', function() {
40
		if($("#typeaheaditem1").val().trim().length == 0){
41
			alert("Please choose Item");
42
			return;
43
		}
44
		var mop = $("#mop").val();
45
		var dp = $("#dp").val();
46
		var mrp = $("#mrp").val();
24058 amit.gupta 47
		if(isNaN(dp) || isNaN(mop) || isNaN(mrp)) {
24052 amit.gupta 48
			alert("DP/MOP/MRP should be a number");
24058 amit.gupta 49
			return;
24052 amit.gupta 50
		}
24056 amit.gupta 51
		if(mrp < mop || mrp < dp) {
52
			alert("DP/MOP should be lower than MRP");
24058 amit.gupta 53
			return;
24056 amit.gupta 54
		}
24052 amit.gupta 55
		if(confirm("Are you sure?")) {
56
			var obj = {
57
					itemId:currentItem1.itemId,
58
					mop:parseFloat(mop),
59
					dp:parseFloat(dp),
60
					mrp:parseFloat(mrp)
61
			}
62
			doPostAjaxRequestWithJsonHandler(
63
					context+"/add-pricing", JSON.stringify(obj),
64
					function(response) {
65
						if (response == 'true') {
66
							$('#newPriceDropModal').find('button.close').trigger('click');
67
							setTimeout(() => {
68
								alert("PriceDrop added successfully")
69
								loadPriceDrop("main-content");
70
							}, 500);
71
						} else {
72
							alert("Something went wrong pls try after sometime");
73
						}
74
					}
75
			);
76
		}
77
 
78
	});
23884 amit.gupta 79
	$("button.addPriceDrop").live('click', function() {
80
		if($("#typeaheaditem").val().trim().length == 0){
81
			alert("Please choose Item");
82
			return;
83
		}
24052 amit.gupta 84
 
23884 amit.gupta 85
		var priceDrop = $("#pd").val();
86
		var newTp = $("#newTp").val();
87
		var newMop = $("#newMop").val();
88
		var newNlc = $("#newNlc").val();
89
		var affectedOn = $("#affectedDate").val();
90
		var allColors = $("#allColors").prop('checked');
91
		if(priceDrop.length == 0 || parseFloat(priceDrop) == 0) {
92
			alert("Price Drop should not be empty");
93
			return;
94
		}
95
		if(newTp.length == 0 || parseFloat(newTp) == 0) {
96
			alert("New Tp should not be empty");
97
			return;
98
		}
99
		if(newMop.length == 0 || parseFloat(newMop) == 0) {
100
			alert("New Mop should not be empty");
101
			return;
102
		}
103
		if(newNlc.length == 0 || parseFloat(newNlc) == 0) {
104
			alert("New Nlc should not be empty");
105
			return;
106
		}
107
 
108
		if(affectedOn.length == 0) {
109
			alert("Affected Date Should not be empty");
110
			return;
111
		}
112
		if(confirm("Are you sure?")) {
113
			var obj = {
114
					itemId:currentItem.itemId,
115
					tp:parseFloat(newTp),
116
					pd:parseFloat(priceDrop),
117
					mop:parseFloat(newMop),
118
					nlc:parseFloat(newNlc),
119
					allColors:allColors,
120
					affectedDate:startDate
121
			}
122
			doPostAjaxRequestWithJsonHandler(
123
					context+"/priceDrop", JSON.stringify(obj),
124
					function(response) {
125
						if (response == 'true') {
126
							$('#newPriceDropModal').find('button.close').trigger('click');
127
							setTimeout(() => {
128
								alert("PriceDrop added successfully")
129
								loadPriceDrop("main-content");
130
							}, 500);
131
						} else {
132
							alert("Something went wrong pls try after sometime");
133
						}
134
					}
135
			);
136
		}
137
	});
138
	$('input.downloadtotalIMEI').live('click', function (){
23966 amit.gupta 139
		var priceDropId=$(this).closest('tr').data('pricedropid');
23819 govind 140
		doAjaxGetDownload(context+"/downloadtotalPriceDropIMEI/"+priceDropId,
23971 amit.gupta 141
		"totalPriceDropIMEI"+priceDropId+".csv");
23819 govind 142
	});
143
 
23951 amit.gupta 144
	$('button.download-imeis').live('click', function(){
145
		doAjaxGetDownload(context+"/price-drop/imes/download/?affectedDate="+startDate +"&itemId=" + currentItem.itemId, "pricedrop.csv")
146
	});
23819 govind 147
 
24060 amit.gupta 148
	$('button.mk_download_pricing').live('click', function(){
149
		doAjaxGetDownload(context+"/tagListing/download/4", "pricing.xlsx")
150
	});
23951 amit.gupta 151
 
24060 amit.gupta 152
 
23966 amit.gupta 153
	$('.mk_process_price_drop').live('click', function (){
154
		if (confirm("Are you sure you want to Process price Drop?")) {
155
			var trElement=$(this).closest('tr');
156
			var priceDropId = trElement.data('pricedropid');
23968 amit.gupta 157
			var partnerPayout = trElement.find('.partner-payout').val();
158
			var priceDropIn = trElement.find('.price-drop-in').val();
23966 amit.gupta 159
 
160
			if(isNaN(partnerPayout) || partnerPayout == 0) {
161
				alert("Partner Payout can't be 0");
162
				return false;
163
			} else if (isNaN(priceDropIn) || priceDropIn == 0) {
164
				alert("Price Drop can't be 0");
165
				return false;
23819 govind 166
			}
23966 amit.gupta 167
			else {
168
				let priceDropObj = {
169
						priceDropIn:parseFloat(priceDropIn), 
170
						partnerPayout: parseFloat(partnerPayout), 
171
						priceDropId:parseInt(priceDropId)
172
				};
173
				processPayout(priceDropObj); 
174
			}
23819 govind 175
		}
23966 amit.gupta 176
		else {
177
			return false;
178
		}
23819 govind 179
	});
180
});
23966 amit.gupta 181
 
23819 govind 182
function loadPriceDrop(domId){
183
	doGetAjaxRequestHandler(context+"/getItemDescription", function(response){
184
		$('#' + domId).html(response);
185
	});
186
}
23966 amit.gupta 187
function processPayout(priceDropProcessObj){
23968 amit.gupta 188
	doPostAjaxRequestWithJsonHandler(context+"/processPriceDrop", JSON.stringify(priceDropProcessObj), function(response) {
23966 amit.gupta 189
		if (response == 'true') {
190
			alert("PriceDrop sends successfully");
191
			loadPriceDrop("main-content");
192
		}
193
		else {
194
			alert("No IMEI is Eligible for PriceDrop");
195
			loadPriceDrop("main-content");
196
		}
23819 govind 197
	});
23966 amit.gupta 198
}
23819 govind 199