Subversion Repositories SmartDukaan

Rev

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

Rev 27754 Rev 28568
Line 88... Line 88...
88
 
88
 
89
		if(affectedOn.length == 0) {
89
		if(affectedOn.length == 0) {
90
			alert("Affected Date Should not be empty");
90
			alert("Affected Date Should not be empty");
91
			return;
91
			return;
92
		}
92
		}
93
		//as of now allColors is set to true. This means that all colors are eligible for price drop
93
		// as of now allColors is set to true. This means that all colors are
-
 
94
		// eligible for price drop
94
		if(confirm("Are you sure?")) {
95
		if(confirm("Are you sure?")) {
95
			var obj = {
96
			var obj = {
96
					itemId:currentItem.itemId,
97
					itemId:currentItem.itemId,
97
					dp:parseFloat(newDp),
98
					dp:parseFloat(newDp),
98
					tp:parseFloat(newTp),
99
					tp:parseFloat(newTp),
Line 140... Line 141...
140
			clickedPriceDrop = $(this);
141
			clickedPriceDrop = $(this);
141
			var priceDropId = trElement.data('pricedropid');
142
			var priceDropId = trElement.data('pricedropid');
142
			autoProcess({priceDropId:priceDropId, partnerPayout:payout, activatedOnly:$(this).data('activatedonly')})
143
			autoProcess({priceDropId:priceDropId, partnerPayout:payout, activatedOnly:$(this).data('activatedonly')})
143
		}
144
		}
144
	});
145
	});
145
 
146
	
146
	$(document).on('click', '.mk_view_imeis', function (){
-
 
147
		clickedPriceDrop = $(this);
-
 
148
		var trElement=$(this).closest('tr');
-
 
149
		var priceDropId = trElement.data('pricedropid');
147
	function priceDropImeis(priceDropId){
-
 
148
		
150
		
149
		
151
		doAjaxRequestWithJsonHandler(context+"/priceDropImeis/"+ priceDropId, 'GET', null, function(response) {
150
		doAjaxRequestWithJsonHandler(context+"/priceDropImeis/"+ priceDropId, 'GET', null, function(response) {
152
			response = JSON.parse(response);
151
			response = JSON.parse(response);
-
 
152
			holdArr=[];
-
 
153
			response.holdImeis.forEach(function(val,index){
-
 
154
				holdArr.push('<option>' +  val + '</option>')
-
 
155
			});
-
 
156
			$('select.mk_hold').html(holdArr.join('')).find('option');
-
 
157
			$('span.mk_hold_count').html(holdArr.length);
-
 
158
			
-
 
159
			
153
			pendingArr=[];
160
			pendingArr=[];
154
			response.pendingImeis.forEach(function(val,index){
161
			response.pendingImeis.forEach(function(val,index){
155
				pendingArr.push('<option disabled>' +  val + '</option>')
162
				pendingArr.push('<option>' +  val + '</option>')
156
			});
163
			});
157
			$('select.mk_pending').html(pendingArr.join('')).find('option');
164
			$('select.mk_pending').html(pendingArr.join('')).find('option');
158
			$('span.mk_pending_count').html(pendingArr.length);
165
			$('span.mk_pending_count').html(pendingArr.length);
159
			
166
			
160
			approvedArr=[];
167
			approvedArr=[];
Line 168... Line 175...
168
			response.rejectedImeis.forEach(function(val,index){
175
			response.rejectedImeis.forEach(function(val,index){
169
				rejectedArr.push('<option>' +  val + '</option>')
176
				rejectedArr.push('<option>' +  val + '</option>')
170
			});
177
			});
171
			$('span.mk_rejected_count').html(rejectedArr.length);
178
			$('span.mk_rejected_count').html(rejectedArr.length);
172
			$('select.mk_rejected').html(rejectedArr.join(''));
179
			$('select.mk_rejected').html(rejectedArr.join(''));
173
			//if(rejected) {}
180
			// if(rejected) {}
174
		});
181
		});
-
 
182
		
-
 
183
	}
-
 
184
 
-
 
185
	$(document).on('click', '.mk_view_imeis', function (){
-
 
186
		clickedPriceDrop = $(this);
-
 
187
		var trElement=$(this).closest('tr');
-
 
188
		var priceDropId = trElement.data('pricedropid');
-
 
189
		priceDropImeis(priceDropId);
-
 
190
		
175
	});
191
	});
176
 
192
 
177
	$(document).on('click', '.mk_add_payout', function (){
193
	$(document).on('click', '.mk_add_payout', function (){
178
		if (confirm("Are you sure you want to add price Drop?")) {
194
		if (confirm("Are you sure you want to add price Drop?")) {
179
			var trElement=$(this).closest('tr');
195
			var trElement=$(this).closest('tr');
Line 224... Line 240...
224
			loadPriceDrop("main-content");
240
			loadPriceDrop("main-content");
225
		}
241
		}
226
	});
242
	});
227
}
243
}
228
 
244
 
-
 
245
 
-
 
246
 
229
function updatePriceDropImeis(status){
247
function updatePriceDropImeis(status){
230
	var imeis1 = $('input.mk_imeis_text').val().trim().split(',');
248
	var imeis1 = $('input.mk_imeis_text').val().trim().split(',');
231
	var imeis = [];
249
	var imeis = [];
232
	imeis1.forEach(function(imei,i) {
250
	imeis1.forEach(function(imei,i) {
233
		if(imei.trim()!='') {
251
		if(imei.trim()!='') {
234
			imeis.push(imei.trim()); 
252
			imeis.push(imei.trim()); 
235
		}
253
		}
236
	});
254
	});
-
 
255
	
-
 
256
	console.log("imeis"+imeis);
-
 
257
	console.log("imeis"+imeis.length);
-
 
258
	
-
 
259
	var arr = new Array();
-
 
260
	$('#pendingList option').each(function(){
-
 
261
	arr.push($(this).val());
-
 
262
	});
-
 
263
	console.log("arr"+arr);
-
 
264
	var holdarr = new Array();
-
 
265
	$('#holdList option').each(function(){
-
 
266
	holdarr.push($(this).val());
-
 
267
	});
-
 
268
	console.log("holdarr"+holdarr);;
-
 
269
	var lenArray = [];
-
 
270
	
237
	if(status=='rejected') {
271
	if(status=='rejected') {
-
 
272
		
238
		if($("#statusForm .mk_rejection_reason").val().trim()=="") {
273
		if($("#statusForm .mk_rejection_reason").val().trim()=="") {
239
			alert("Please enter rejection reason");
274
			alert("Please enter rejection reason");
240
			return;
275
			return;
241
		}
276
		}
-
 
277
		for ( const item of imeis)
-
 
278
		{ 
-
 
279
		if(arr.includes(item)){ 
-
 
280
			
242
		imeis = imeis.concat($('select.mk_approved').val());
281
			imeis = imeis.concat($('select.mk_rejected').val());
-
 
282
			lenArray=lenArray.concat(item);
-
 
283
		}
243
	} else {
284
		else
-
 
285
		{
-
 
286
			imeis=[];
-
 
287
			lenArray=lenArray.concat(1);	
-
 
288
			if(imeis=="")
-
 
289
			{alert("All IMEIs Should be present in pending Status");}
-
 
290
					break;
-
 
291
		}
-
 
292
		}
-
 
293
		
-
 
294
	}
-
 
295
	
-
 
296
	else if(status=='approved') {
-
 
297
			for ( const item of imeis)
-
 
298
		{ 
-
 
299
		if(arr.includes(item)){
244
		if($("#statusForm .mk_rejection_reason").val().trim()!="") {
300
			imeis = imeis.concat($('select.mk_approved').val());
-
 
301
			
-
 
302
			lenArray=lenArray.concat(item);
-
 
303
			
-
 
304
		}
-
 
305
		else
-
 
306
		{
-
 
307
			imeis=[];
-
 
308
			lenArray=lenArray.concat(1);
-
 
309
			if(imeis=="")
245
			alert("Rejection reason should be empty during approval.");
310
			{alert("All IMEIs Should be present in pending Status");}
246
			return;
311
					break;
-
 
312
		}
247
		}
313
		}
-
 
314
	}
-
 
315
   else if(status=='pending') {
-
 
316
	   for ( const item of imeis)
-
 
317
		{ 
-
 
318
		if(holdarr.includes(item)){
248
		imeis = imeis.concat($('select.mk_rejected').val());
319
			imeis = imeis.concat($('select.mk_pending').val());
-
 
320
			lenArray=lenArray.concat(item);
-
 
321
		}
-
 
322
		else
-
 
323
		{
-
 
324
			imeis=[];
-
 
325
			if(imeis=="")
-
 
326
				lenArray=lenArray.concat(1);	
-
 
327
			{alert("All IMEIs Should be present in Hold Status");}
-
 
328
					break;
-
 
329
		}
-
 
330
		}
-
 
331
	  
-
 
332
	} 
-
 
333
	
-
 
334
	else{
-
 
335
		
-
 
336
		for ( const item of imeis)
-
 
337
		{ 
-
 
338
		if(arr.includes(item)){
-
 
339
			imeis = imeis.concat($('select.mk_hold').val());
-
 
340
		
-
 
341
			lenArray=lenArray.concat(item);
-
 
342
		}
-
 
343
		else
-
 
344
		{
-
 
345
			imeis=[];
-
 
346
			lenArray=lenArray.concat(1);
-
 
347
			if(imeis=="")
-
 
348
			{alert("All IMEIs Should be present in pending Status");}
-
 
349
					break;
-
 
350
		}
-
 
351
		}
-
 
352
		
249
	}
353
	}
250
 
354
 
251
	if(imeis.length == 0) {
355
	if(imeis.length == 0)  {
-
 
356
		
-
 
357
 
-
 
358
		if(lenArray.length != 0){
-
 
359
			return;
-
 
360
		}
-
 
361
		else{
252
		alert('Please choose imeis');
362
		alert('Please choose imeis');
253
		return;
363
		return;
-
 
364
		
-
 
365
	}
254
	}
366
	}
255
 
367
 
256
	if(!confirm("Move selected imeis to " + status + "?")) {
368
	if(!confirm("Move selected imeis to " + status + "?")) {
257
		return;
369
		return;
258
	}
370
	}
259
	var trElement=clickedPriceDrop.closest('tr');
371
	var trElement=clickedPriceDrop.closest('tr');
260
	var priceDropId = trElement.data('pricedropid');
372
	var priceDropId = trElement.data('pricedropid');
261
	
373
	
-
 
374
	console.log("trElement"+trElement+"priceDropId"+priceDropId);
262
	priceDropImeisObj = {
375
	priceDropImeisObj = {
263
			priceDropId: priceDropId,
376
			priceDropId: priceDropId,
264
			updatedStatus : status,
377
			updatedStatus : status,
-
 
378
			
265
			updatedImeis : imeis
379
			updatedImeis : imeis
266
	};
380
	};
267
	doPostAjaxRequestWithJsonHandler(context+"/updatePriceDropImeis", JSON.stringify(priceDropImeisObj), function(response) {
381
	doPostAjaxRequestWithJsonHandler(context+"/updatePriceDropImeis", JSON.stringify(priceDropImeisObj), function(response) {
268
		if (response == 'true') {
382
		if (response == 'true') {
269
			alert('Imeis updated and processed successfully');
383
			alert('Imeis updated and processed successfully');
270
			clickedPriceDrop.click();
384
			priceDropImeis(priceDropId);
271
		}
385
		}
272
		else {
386
		else {
273
			alert("Error occurred while updating.");
387
			alert("Error occurred while updating.");
274
		}
388
		}
275
	});
389
	});
276
	
390
	
-
 
391
	
-
 
392
	
-
 
393
	
-
 
394
	
277
}
395
}
278
396