Subversion Repositories SmartDukaan

Rev

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

Rev 24066 Rev 24083
Line 46... Line 46...
46
		var mrp = $("#mrp").val();
46
		var mrp = $("#mrp").val();
47
		if(isNaN(dp) || isNaN(mop) || isNaN(mrp)) {
47
		if(isNaN(dp) || isNaN(mop) || isNaN(mrp)) {
48
			alert("DP/MOP/MRP should be a number");
48
			alert("DP/MOP/MRP should be a number");
49
			return;
49
			return;
50
		}
50
		}
-
 
51
		mop = parseFloat(mop),
-
 
52
		dp = parseFloat(dp),
-
 
53
		mrp = parseFloat(mrp)
51
		if(mrp < mop || mrp < dp) {
54
		if(mrp < mop || mrp < dp) {
52
			alert("DP/MOP should be lower than MRP");
55
			alert("DP/MOP should be lower than MRP");
53
			return;
56
			return;
54
		}
57
		}
55
		if(confirm("Are you sure?")) {
58
		if(confirm("Are you sure?")) {
56
			var obj = {
59
			var obj = {
57
					itemId:currentItem1.itemId,
60
					itemId:currentItem1.itemId,
58
					mop:parseFloat(mop),
61
					mop:mop,
59
					dp:parseFloat(dp),
62
					dp:dp,
60
					mrp:parseFloat(mrp)
63
					mrp:mrp
61
			}
64
			}
62
			doPostAjaxRequestWithJsonHandler(
65
			doPostAjaxRequestWithJsonHandler(
63
					context+"/add-pricing", JSON.stringify(obj),
66
					context+"/add-pricing", JSON.stringify(obj),
64
					function(response) {
67
					function(response) {
65
						if (response == 'true') {
68
						if (response == 'true') {
Line 147... Line 150...
147
	
150
	
148
	$('button.mk_download_pricing').live('click', function(){
151
	$('button.mk_download_pricing').live('click', function(){
149
		doAjaxGetDownload(context+"/tagListing/download/4", "pricing.xlsx")
152
		doAjaxGetDownload(context+"/tagListing/download/4", "pricing.xlsx")
150
	});
153
	});
151
	
154
	
-
 
155
	$('.mk_view_imeis').live('click', function (){
-
 
156
		clickedPriceDrop = $(this);
-
 
157
		var trElement=$(this).closest('tr');
-
 
158
		var priceDropId = trElement.data('pricedropid');
-
 
159
		
-
 
160
		doAjaxRequestWithJsonHandler(context+"/priceDropImeis/"+ priceDropId, 'GET', null, function(response) {
-
 
161
			response = JSON.parse(response);
-
 
162
			pendingArr=[];
-
 
163
			response.pendingImeis.forEach(function(val,index){
-
 
164
				pendingArr.push('<option>' +  val + '</option>')
-
 
165
			});
-
 
166
			$('select.mk_pending').html(pendingArr.join(''));
-
 
167
			
-
 
168
			approvedArr=[];
-
 
169
			response.approvedImeis.forEach(function(val,index){
-
 
170
				approvedArr.push('<option disabled>' +  val + '</option>')
-
 
171
			});
-
 
172
			$('select.mk_approved').html(approvedArr.join(''));
-
 
173
			
-
 
174
			rejectedArr=[];
-
 
175
			response.rejectedImeis.forEach(function(val,index){
-
 
176
				rejectedArr.push('<option>' +  val + '</option>')
-
 
177
			});
-
 
178
			$('select.mk_rejected').html(rejectedArr.join(''));
-
 
179
		});
-
 
180
	});
152
	
181
	
153
	$('.mk_process_price_drop').live('click', function (){
182
	$('.mk_process_price_drop').live('click', function (){
-
 
183
		if (confirm("Are you sure you want to Update Payout?")) {
-
 
184
			processPayout(priceDropProcessObj)
-
 
185
		}
-
 
186
	});
-
 
187
 
-
 
188
	$('.mk_add_payout').live('click', function (){
154
		if (confirm("Are you sure you want to Process price Drop?")) {
189
		if (confirm("Are you sure you want to add price Drop?")) {
155
			var trElement=$(this).closest('tr');
190
			var trElement=$(this).closest('tr');
156
			var priceDropId = trElement.data('pricedropid');
191
			var priceDropId = trElement.data('pricedropid');
157
			var partnerPayout = trElement.find('.partner-payout').val();
192
			var partnerPayout = trElement.find('.partner-payout').val();
158
			var priceDropIn = trElement.find('.price-drop-in').val();
193
			var priceDropIn = trElement.find('.price-drop-in').val();
159
	
194
	
Line 168... Line 203...
168
				let priceDropObj = {
203
				let priceDropObj = {
169
						priceDropIn:parseFloat(priceDropIn), 
204
						priceDropIn:parseFloat(priceDropIn), 
170
						partnerPayout: parseFloat(partnerPayout), 
205
						partnerPayout: parseFloat(partnerPayout), 
171
						priceDropId:parseInt(priceDropId)
206
						priceDropId:parseInt(priceDropId)
172
				};
207
				};
173
				processPayout(priceDropObj); 
208
				addPayout(priceDropObj); 
174
			}
209
			}
175
		}
210
		}
176
		else {
211
		else {
177
			return false;
212
			return false;
178
		}
213
		}
179
	});
214
	});
180
});
215
});
-
 
216
function addPayout(priceDropProcessObj){
-
 
217
	doPostAjaxRequestWithJsonHandler(context+"/price-drop/addPayout", JSON.stringify(priceDropProcessObj), function(response) {
-
 
218
		if (response == 'true') {
-
 
219
			alert("Payout added");
-
 
220
			loadPriceDrop("main-content");
-
 
221
		}
-
 
222
		else {
-
 
223
			alert("Some error occurred while adding payout.");
-
 
224
		}
-
 
225
	});
181
 
226
}
182
function loadPriceDrop(domId){
227
function loadPriceDrop(domId){
183
	doGetAjaxRequestHandler(context+"/getItemDescription", function(response){
228
	doGetAjaxRequestHandler(context+"/getItemDescription", function(response){
184
		$('#' + domId).html(response);
229
		$('#' + domId).html(response);
185
	});
230
	});
186
}
231
}
Line 195... Line 240...
195
			loadPriceDrop("main-content");
240
			loadPriceDrop("main-content");
196
		}
241
		}
197
	});
242
	});
198
}
243
}
199
 
244
 
-
 
245
function updatePriceDropImeis(status){
-
 
246
	var imeis1 = $('input.mk_imeis_text').val().trim().split(',');
-
 
247
	var imeis = [];
-
 
248
	imeis1.forEach(function(imei,i) {
-
 
249
		if(imei.trim()!='') {
-
 
250
			imeis.push(imei.trim()); 
-
 
251
		}
-
 
252
	});
-
 
253
	imeis = imeis.concat($('select.mk_pending').val())
-
 
254
	.concat($('select.mk_approved').val())
-
 
255
	.concat($('select.mk_rejected').val());
-
 
256
	
-
 
257
	if(imeis.length < 0) {
-
 
258
		alert('Please choose imeis');
-
 
259
	}
-
 
260
	
-
 
261
	var trElement=clickedPriceDrop.closest('tr');
-
 
262
	var priceDropId = trElement.data('pricedropid');
-
 
263
	
-
 
264
	priceDropImeisObj = {
-
 
265
			priceDropId: priceDropId,
-
 
266
			updatedStatus : status,
-
 
267
			updatedImeis : imeis
-
 
268
	};
-
 
269
	doPostAjaxRequestWithJsonHandler(context+"/updatePriceDropImeis", JSON.stringify(priceDropImeisObj), function(response) {
-
 
270
		if (response == 'true') {
-
 
271
			alert('Imeis updated and processed successfully');
-
 
272
			clickedPriceDrop.click();
-
 
273
		}
-
 
274
		else {
-
 
275
			alert("Error occurred while updating.");
-
 
276
		}
-
 
277
	});
-
 
278
	
-
 
279
}
200
280