Subversion Repositories SmartDukaan

Rev

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

Rev 30609 Rev 32012
Line 1... Line 1...
1
		
1
$(document).on('change', "#selectPriceDropStatus", function () {
2
  $(document).on('change', "#selectPriceDropStatus", function() {
2
    var status = this.value;
3
  	var  status = this.value;
3
    if (status == 'rejected') {
4
  	if(status=='rejected') {
4
        $('.mk_rejection_reason').val('').show();
5
  		$('.mk_rejection_reason').val('').show();
5
    } else {
6
  	} else {
6
        $('.mk_rejection_reason').val('').hide();
7
  		$('.mk_rejection_reason').val('').hide();
7
    }
8
	}  	
8
});
9
  });
9
$(document).on('click', "#processPDButton", function () {
10
  $(document).on('click', "#processPDButton", function() {
10
    var status = $("#selectPriceDropStatus").val();
11
  	var  status = $("#selectPriceDropStatus").val();
11
    updatePriceDropImeis(status);
12
  	updatePriceDropImeis(status);
12
});
13
  });
13
 
14
 
14
$(document).on('click', "button.processPayout", function () {
15
	$(document).on('click', "button.processPayout", function() {
15
    if ($(".mk_pending")) {
16
		if($(".mk_pending")) {
16
 
17
			
17
    }
18
		}
18
});
19
	}); 
19
 
20
 
20
$(document).on('click', "button.add-pricing", function () {
21
	$(document).on('click', "button.add-pricing", function() {
21
    if ($("#typeaheaditem1").val().trim().length == 0) {
22
		if($("#typeaheaditem1").val().trim().length == 0){
22
        alert("Please choose Item");
23
			alert("Please choose Item");
23
        return;
24
			return;
24
    }
25
		}
25
    var mop = $("#mop").val();
26
		var mop = $("#mop").val();
26
    var dp = $("#dp").val();
27
		var dp = $("#dp").val();
27
    var mrp = $("#mrp").val();
28
		var mrp = $("#mrp").val();
28
    var tp = $("#tp").val();
29
		var tp = $("#tp").val();
29
    if (isNaN(dp) || isNaN(mop) || isNaN(mrp)) {
30
		if(isNaN(dp) || isNaN(mop) || isNaN(mrp)) {
30
        alert("DP/MOP/MRP should be a number");
31
			alert("DP/MOP/MRP should be a number");
31
        return;
32
			return;
32
    }
33
		}
33
    mop = parseFloat(mop),
34
		mop = parseFloat(mop),
34
        dp = parseFloat(dp),
35
		dp = parseFloat(dp),
35
        mrp = parseFloat(mrp)
36
		mrp = parseFloat(mrp)
36
    if (mrp != 0 && (mrp < mop || mrp < dp || mrp < tp)) {
37
		if(mrp !=0 && (mrp < mop || mrp < dp || mrp < tp)) {
37
        bootbox.alert("DP/MOP/TP should be lower than MRP");
38
			bootbox.alert("DP/MOP/TP should be lower than MRP");
38
        return;
39
			return;
39
    }
40
		}
40
    getColorsForItems(0, currentItem.itemId, "Update prices for " + currentItem.itemDescription, function (itemIds) {
41
		getColorsForItems(0, currentItem.itemId, "Update prices for " + currentItem.itemDescription, function(itemIds){
41
        console.log(itemIds);
42
			console.log(itemIds);
42
 
43
			
43
        if (itemIds != null) {
44
			if(itemIds!=null) {
44
            dataList = [];
45
				dataList = [];
45
            coloredItems.forEach(function (item) {
46
				coloredItems.forEach(function(item){
46
                console.log(item);
47
					console.log(item);
47
                console.log(itemIds.indexOf(String(item.id)));
48
					console.log(itemIds.indexOf(String(item.id)));
48
                if (itemIds.indexOf(String(item.id)) >= 0) {
49
					if(itemIds.indexOf(String(item.id)) >= 0) {
49
                    dataList.push(
50
						dataList.push(
50
                        {
51
						{
51
                            id: item.id,
52
							id:item.id,
52
                            mop: mop,
53
							mop:mop,
53
                            dp: dp,
54
							dp:dp,
54
                            mrp: mrp,
55
							mrp:mrp,
55
                            tp: tp
56
							tp:tp
56
                        });
57
						});
57
                }
58
					}
58
            });
59
				});
59
            bootbox.confirm("Confirm Update " + currentItem.itemDescription + "?", function (result) {
60
				bootbox.confirm("Confirm Update " + currentItem.itemDescription + "?", function(result){
60
                if (result) {
61
					if(result) {
61
                    doPostAjaxRequestWithJsonHandler(
62
						doPostAjaxRequestWithJsonHandler(
62
                        context + "/add-pricing", JSON.stringify(dataList),
63
								context+"/add-pricing", JSON.stringify(dataList),
63
                        function (response) {
64
								function(response) {
64
                            if (response == 'true') {
65
									if (response == 'true') {
65
                                bootbox.alert("Prices Successfully Updated");
66
										bootbox.alert("Prices Successfully Updated" );
66
                            } else {
67
									} else {
67
                                bootbox.alert("Something went wrong pls try after sometime");
68
										bootbox.alert("Something went wrong pls try after sometime");
68
                            }
69
									}
69
                        }
70
								}
70
                    );
71
						);
71
                }
72
					}
72
            });
73
				});
73
        }
74
			}
74
    });
75
		});
75
 
76
		
76
});
77
	});
77
$(document).on('click', "button.addPriceDrop", function () {
78
	$(document).on('click', "button.addPriceDrop", function() {
78
    if ($("#typeaheaditem").val().trim().length == 0) {
79
		if($("#typeaheaditem").val().trim().length == 0){
79
        alert("Please choose Item");
80
			alert("Please choose Item");
80
        return;
81
			return;
81
    }
82
		}
82
    var newDp = $("#newDp").val();
83
		var newDp = $("#newDp").val();
83
    var newTp = $("#newTp").val();
84
		var newTp = $("#newTp").val();
84
    var newMop = $("#newMop").val();
85
		var newMop = $("#newMop").val();
85
    var affectedOn = $("#affectedDate").val();
86
		var affectedOn = $("#affectedDate").val();
86
    var allColors = $("#allColors").prop('checked');
87
		var allColors = $("#allColors").prop('checked');
87
 
88
 
88
    if (newDp.length == 0 || parseFloat(newDp) == 0) {
89
		if(newDp.length == 0 || parseFloat(newDp) == 0) {
89
        alert("New Tp should not be empty");
90
			alert("New Tp should not be empty");
90
        return;
91
			return;
91
    }
92
		}
92
    if (newTp.length == 0 || parseFloat(newTp) == 0) {
93
		if(newTp.length == 0 || parseFloat(newTp) == 0) {
93
        alert("New Tp should not be empty");
94
			alert("New Tp should not be empty");
94
        return;
95
			return;
95
    }
96
		}
96
    if (newMop.length == 0 || parseFloat(newMop) == 0) {
97
		if(newMop.length == 0 || parseFloat(newMop) == 0) {
97
        alert("New Mop should not be empty");
98
			alert("New Mop should not be empty");
98
        return;
99
			return;
99
    }
100
		}
100
 
101
 
101
    if (affectedOn.length == 0) {
102
		if(affectedOn.length == 0) {
102
        alert("Affected Date Should not be empty");
103
			alert("Affected Date Should not be empty");
103
        return;
104
			return;
104
    }
105
		}
105
    // as of now allColors is set to true. This means that all colors are
106
		// as of now allColors is set to true. This means that all colors are
106
    // eligible for price drop
107
		// eligible for price drop
107
    if (confirm("Are you sure?")) {
108
		if(confirm("Are you sure?")) {
108
        var obj = {
109
			var obj = {
109
            itemId: currentItem.itemId,
110
					itemId:currentItem.itemId,
110
            dp: parseFloat(newDp),
111
					dp:parseFloat(newDp),
111
            tp: parseFloat(newTp),
112
					tp:parseFloat(newTp),
112
            mop: parseFloat(newMop),
113
					mop:parseFloat(newMop),
113
            allColors: true,
114
					allColors:true,
114
            affectedDate: getDatesFromPicker($('#affectedDate')).startDate
115
					affectedDate: getDatesFromPicker($('#affectedDate')).startDate
115
        }
116
			}
116
        doPostAjaxRequestWithJsonHandler(
117
			doPostAjaxRequestWithJsonHandler(
117
            context + "/priceDrop", JSON.stringify(obj),
118
					context+"/priceDrop", JSON.stringify(obj),
118
            function (response) {
119
					function(response) {
119
                if (response == 'true') {
120
						if (response == 'true') {
120
                    $('#newPriceDropModal').find('button.close').trigger('click');
121
							$('#newPriceDropModal').find('button.close').trigger('click');
121
                    setTimeout(() => {
122
							setTimeout(() => {
122
                        alert("PriceDrop added successfully from " + $("#typeaheaditem").val());
123
								alert("PriceDrop added successfully from " + $("#typeaheaditem").val());
123
                        loadPriceDrop("main-content");
124
								loadPriceDrop("main-content");
124
                    }, 500);
125
							}, 500);
125
                } else {
126
						} else {
126
                    alert("Invalid values provided could not update");
127
							alert("Invalid values provided could not update");
127
                }
128
						}
128
            }
129
					}
129
        );
130
			);
130
    }
131
		}
131
});
132
	});
132
$(document).on('click', 'input.downloadtotalIMEI', function () {
133
	$(document).on('click', 'input.downloadtotalIMEI', function (){
133
    var priceDropId = $(this).closest('tr').data('pricedropid');
134
		var priceDropId=$(this).closest('tr').data('pricedropid');
134
    doAjaxGetDownload(context + "/downloadtotalPriceDropIMEI/" + priceDropId,
135
		doAjaxGetDownload(context+"/downloadtotalPriceDropIMEI/"+priceDropId,
135
        "totalPriceDropIMEI" + priceDropId + ".csv");
136
		"totalPriceDropIMEI"+priceDropId+".csv");
136
});
137
	});
137
 
138
	
138
$(document).on('click', 'button.download-imeis', function () {
139
	$(document).on('click', 'button.download-imeis', function(){
139
    let affectedDate = getDatesFromPicker('#affectedDate').startDate;
140
		let affectedDate = getDatesFromPicker('#affectedDate').startDate;
140
    doAjaxGetDownload(context + "/price-drop/imes/download/?affectedDate=" + affectedDate + "&itemId=" + currentItem.itemId, "pricedrop.csv")
141
		doAjaxGetDownload(context + "/price-drop/imes/download/?affectedDate=" + affectedDate + "&itemId=" + currentItem.itemId, "pricedrop.csv")
141
});
142
	});
142
 
143
	
143
$(document).on('click', 'button.mk_download_pricing', function () {
144
	$(document).on('click', 'button.mk_download_pricing', function(){
144
    doAjaxGetDownload(context + "/tagListing/download/4", "pricing.xlsx")
145
		doAjaxGetDownload(context+"/tagListing/download/4", "pricing.xlsx")
145
});
146
	});
146
 
147
	
147
$(document).on('click', '.mk_auto_process', function () {
148
	$(document).on('click', '.mk_auto_process', function (){
148
    var trElement = $(this).closest('tr');
149
		var trElement=$(this).closest('tr');
149
    var payout = trElement.find('input.partner-payout').val();
150
		var payout = trElement.find('input.partner-payout').val();
150
    if (isNaN(parseInt(payout)) || parseInt(payout) <= 0) {
151
		if(isNaN(parseInt(payout)) || parseInt(payout) <=0) {
151
        alert("Invalid payout amount");
152
			alert("Invalid payout amount");
152
    }
153
		}
153
    if (confirm("Are you sure you want to Process Payout?")) {
154
		if (confirm("Are you sure you want to Process Payout?")) {
154
        clickedPriceDrop = $(this);
155
			clickedPriceDrop = $(this);
155
        var priceDropId = trElement.data('pricedropid');
156
			var priceDropId = trElement.data('pricedropid');
156
        autoProcess({priceDropId: priceDropId, partnerPayout: payout, activatedOnly: $(this).data('activatedonly')})
157
			autoProcess({priceDropId:priceDropId, partnerPayout:payout, activatedOnly:$(this).data('activatedonly')})
157
    }
158
		}
158
});
159
	});
159
 
160
	
160
function priceDropImeis(priceDropId) {
161
	function priceDropImeis(priceDropId){
161
 
162
		
162
 
163
		
163
    doAjaxRequestWithJsonHandler(context + "/priceDropImeis/" + priceDropId, 'GET', null, function (response) {
164
		doAjaxRequestWithJsonHandler(context+"/priceDropImeis/"+ priceDropId, 'GET', null, function(response) {
164
        response = JSON.parse(response);
165
			response = JSON.parse(response);
165
        holdArr = [];
166
			holdArr=[];
166
        response.holdImeis.forEach(function (val, index) {
167
			response.holdImeis.forEach(function(val,index){
167
            holdArr.push('<option>' + val + '</option>')
168
				holdArr.push('<option>' +  val + '</option>')
168
        });
169
			});
169
        $('select.mk_hold').html(holdArr.join('')).find('option');
170
			$('select.mk_hold').html(holdArr.join('')).find('option');
170
        $('span.mk_hold_count').html(holdArr.length);
171
			$('span.mk_hold_count').html(holdArr.length);
171
 
172
			
172
 
173
			
173
        pendingArr = [];
174
			pendingArr=[];
174
        response.pendingImeis.forEach(function (val, index) {
175
			response.pendingImeis.forEach(function(val,index){
175
            pendingArr.push('<option>' + val + '</option>')
176
				pendingArr.push('<option>' +  val + '</option>')
176
        });
177
			});
177
        $('select.mk_pending').html(pendingArr.join('')).find('option');
178
			$('select.mk_pending').html(pendingArr.join('')).find('option');
178
        $('span.mk_pending_count').html(pendingArr.length);
179
			$('span.mk_pending_count').html(pendingArr.length);
179
 
180
			
180
        approvedArr = [];
181
			approvedArr=[];
181
        response.approvedImeis.forEach(function (val, index) {
182
			response.approvedImeis.forEach(function(val,index){
182
            approvedArr.push('<option>' + val + '</option>')
183
				approvedArr.push('<option>' +  val + '</option>')
183
        });
184
			});
184
        $('select.mk_approved').html(approvedArr.join(''));
185
			$('select.mk_approved').html(approvedArr.join(''));
185
        $('span.mk_approved_count').html(approvedArr.length);
186
			$('span.mk_approved_count').html(approvedArr.length);
186
 
187
			
187
        rejectedArr = [];
188
			rejectedArr=[];
188
        response.rejectedImeis.forEach(function (val, index) {
189
			response.rejectedImeis.forEach(function(val,index){
189
            rejectedArr.push('<option>' + val + '</option>')
190
				rejectedArr.push('<option>' +  val + '</option>')
190
        });
191
			});
191
        $('span.mk_rejected_count').html(rejectedArr.length);
192
			$('span.mk_rejected_count').html(rejectedArr.length);
192
        $('select.mk_rejected').html(rejectedArr.join(''));
193
			$('select.mk_rejected').html(rejectedArr.join(''));
193
        // if(rejected) {}
194
			// if(rejected) {}
194
    });
195
		});
195
 
196
		
196
}
197
	}
197
 
198
 
198
$(document).on('click', '.mk_view_imeis', function () {
199
	$(document).on('click', '.mk_view_imeis', function (){
199
    clickedPriceDrop = $(this);
200
		clickedPriceDrop = $(this);
200
    var trElement = $(this).closest('tr');
201
		var trElement=$(this).closest('tr');
201
    var priceDropId = trElement.data('pricedropid');
202
		var priceDropId = trElement.data('pricedropid');
202
    priceDropImeis(priceDropId);
203
		priceDropImeis(priceDropId);
203
 
204
		
204
});
205
	});
205
 
206
 
206
$(document).on('click', '.mk_add_payout', function () {
207
	$(document).on('click', '.mk_add_payout', function (){
207
    if (confirm("Are you sure you want to add price Drop?")) {
208
		if (confirm("Are you sure you want to add price Drop?")) {
208
        var trElement = $(this).closest('tr');
209
			var trElement=$(this).closest('tr');
209
        var priceDropId = trElement.data('pricedropid');
210
			var priceDropId = trElement.data('pricedropid');
210
        var partnerPayout = trElement.find('.partner-payout').val();
211
			var partnerPayout = trElement.find('.partner-payout').val();
211
        var priceDropIn = trElement.find('.price-drop-in').val();
212
			var priceDropIn = trElement.find('.price-drop-in').val();
212
 
213
	
213
        if (isNaN(partnerPayout) || partnerPayout == 0) {
214
			if(isNaN(partnerPayout) || partnerPayout == 0) {
214
            alert("Partner Payout can't be 0");
215
				alert("Partner Payout can't be 0");
215
            return false;
216
				return false;
216
        } else if (isNaN(priceDropIn) || priceDropIn == 0) {
217
			} else if (isNaN(priceDropIn) || priceDropIn == 0) {
217
            alert("Price Drop can't be 0");
218
				alert("Price Drop can't be 0");
218
            return false;
219
				return false;
219
        } else {
220
			}
220
            let priceDropObj = {
221
			else {
221
                priceDropIn: parseFloat(priceDropIn),
222
				let priceDropObj = {
222
                partnerPayout: parseFloat(partnerPayout),
223
						priceDropIn:parseFloat(priceDropIn), 
223
                priceDropId: parseInt(priceDropId)
224
						partnerPayout: parseFloat(partnerPayout), 
224
            };
225
						priceDropId:parseInt(priceDropId)
225
            addPayout(priceDropObj);
226
				};
226
        }
227
				addPayout(priceDropObj); 
227
    } else {
228
			}
228
        return false;
229
		}
229
    }
230
		else {
230
});
231
			return false;
231
 
232
		}
232
function addPayout(priceDropProcessObj) {
233
	});
233
    doPostAjaxRequestWithJsonHandler(context + "/price-drop/addPayout", JSON.stringify(priceDropProcessObj), function (response) {
234
function addPayout(priceDropProcessObj){
234
        if (response == 'true') {
235
	doPostAjaxRequestWithJsonHandler(context+"/price-drop/addPayout", JSON.stringify(priceDropProcessObj), function(response) {
235
            alert("Payout added");
236
		if (response == 'true') {
236
            loadPriceDrop("main-content");
237
			alert("Payout added");
237
        } else {
238
			loadPriceDrop("main-content");
238
            alert("Some error occurred while adding payout.");
239
		}
239
        }
240
		else {
240
    });
241
			alert("Some error occurred while adding payout.");
-
 
242
		}
-
 
243
	});
-
 
244
}
241
}
245
 
242
 
246
function autoProcess(priceDropObj){
243
function autoProcess(priceDropObj) {
247
	doPostAjaxRequestWithJsonHandler(context+"/processPriceDrop", JSON.stringify(priceDropObj), function(response) {
244
    doPostAjaxRequestWithJsonHandler(context + "/processPriceDrop", JSON.stringify(priceDropObj), function (response) {
248
		if (response == 'true') {
245
        if (response == 'true') {
249
			alert("PriceDrop sends successfully");
246
            alert("PriceDrop sends successfully");
250
			loadPriceDrop("main-content");
247
            loadPriceDrop("main-content");
251
		}
-
 
252
		else {
248
        } else {
253
			alert("No IMEI is Eligible for PriceDrop");
249
            alert("No IMEI is Eligible for PriceDrop");
254
			loadPriceDrop("main-content");
250
            loadPriceDrop("main-content");
255
		}
251
        }
256
	});
252
    });
257
}
253
}
258
 
254
 
259
 
255
 
-
 
256
function updatePriceDropImeis(status) {
-
 
257
    var imeisInText = [];
-
 
258
    $('input.mk_imeis_text').val().trim().split(',').forEach(function (imei, i) {
-
 
259
        if (imei.trim() !== '') {
-
 
260
            imeisInText.push(imei.trim());
-
 
261
        }
-
 
262
    });
-
 
263
 
-
 
264
    var pendingArr = new Array();
-
 
265
    $('select.mk_pending option').each(function () {
-
 
266
        pendingArr.push($(this).val());
-
 
267
    });
-
 
268
    var rejectedArr = new Array();
-
 
269
    $('select.mk_rejected option').each(function () {
-
 
270
        rejectedArr.push($(this).val());
-
 
271
    });
-
 
272
    var approvedArr = new Array();
-
 
273
    $('select.mk_approved option').each(function () {
-
 
274
        approvedArr.push($(this).val());
-
 
275
    });
-
 
276
    var allImeisToUpdate;
-
 
277
 
-
 
278
    if (status === 'rejected') {
-
 
279
        if ($("#statusForm .mk_rejection_reason").val().trim() === "") {
-
 
280
            alert("Please enter rejection reason");
-
 
281
            return;
-
 
282
        }
-
 
283
        allImeisToUpdate = $('select.mk_pending').val();
-
 
284
        for (const imeiInText of imeisInText) {
-
 
285
            if (pendingArr.includes(imeiInText)) {
-
 
286
                allImeisToUpdate.push(imeiInText);
-
 
287
            } else {
-
 
288
                alert("All IMEIs Should be present in pending Status");
-
 
289
                return;
-
 
290
            }
-
 
291
        }
-
 
292
    } else if (status === 'approved') {
-
 
293
        allImeisToUpdate = $('select.mk_pending').val();
-
 
294
        for (const imeiInText of imeisInText) {
-
 
295
            if (pendingArr.includes(imeiInText)) {
-
 
296
                allImeisToUpdate.push(imeiInText);
-
 
297
            } else {
-
 
298
                alert("All IMEIs Should be present in pending Status");
-
 
299
                return;
-
 
300
            }
-
 
301
        }
-
 
302
    } else {
-
 
303
        allImeisToUpdate = $('select.mk_rejected').val();
-
 
304
        for (const imeiInText of imeisInText) {
-
 
305
            if (rejectedArr.includes(imeiInText)) {
-
 
306
                allImeisToUpdate.push(imeiInText);
-
 
307
            } else {
-
 
308
                alert("All IMEIs Should be present in Rejected Status");
-
 
309
                return;
-
 
310
            }
-
 
311
        }
-
 
312
    }
-
 
313
 
-
 
314
    if (allImeisToUpdate.length === 0) {
-
 
315
        alert('Please choose imeis');
-
 
316
        return;
-
 
317
    }
-
 
318
 
-
 
319
    if (!confirm("Move selected imeis to " + status + "?")) {
-
 
320
        return;
-
 
321
    }
-
 
322
    var trElement = clickedPriceDrop.closest('tr');
-
 
323
    var priceDropId = trElement.data('pricedropid');
-
 
324
 
-
 
325
    priceDropImeisObj = {
-
 
326
        priceDropId: priceDropId,
-
 
327
        updatedStatus: status,
-
 
328
        updatedImeis: allImeisToUpdate
-
 
329
    };
-
 
330
    doPostAjaxRequestWithJsonHandler(context + "/updatePriceDropImeis", JSON.stringify(priceDropImeisObj), function (response) {
-
 
331
        if (response == 'true') {
-
 
332
            alert('Imeis updated and processed successfully');
-
 
333
            priceDropImeis(priceDropId);
-
 
334
        } else {
-
 
335
            alert("Error occurred while updating.");
-
 
336
        }
-
 
337
    });
-
 
338
 
260
 
339
 
261
function updatePriceDropImeis(status){
-
 
262
	debugger;
-
 
263
	var imeis1 = $('input.mk_imeis_text').val().trim().split(',');
-
 
264
	var imeis = [];
-
 
265
	imeis1.forEach(function(imei,i) {
-
 
266
		if(imei.trim()!='') {
-
 
267
			imeis.push(imei.trim()); 
-
 
268
		}
-
 
269
	});
-
 
270
	
-
 
271
	console.log("imeis"+imeis);
-
 
272
	console.log("imeis"+imeis.length);
-
 
273
	
-
 
274
	var arr = new Array();
-
 
275
	$('#pendingList option').each(function(){
-
 
276
	arr.push($(this).val());
-
 
277
	});
-
 
278
	console.log("arr"+arr);
-
 
279
	var holdarr = new Array();
-
 
280
	$('#holdList option').each(function(){
-
 
281
	holdarr.push($(this).val());
-
 
282
	});
-
 
283
	console.log("holdarr"+holdarr);;
-
 
284
	var lenArray = [];
-
 
285
	
-
 
286
	if(status=='rejected') {
-
 
287
		
-
 
288
		if($("#statusForm .mk_rejection_reason").val().trim()=="") {
-
 
289
			alert("Please enter rejection reason");
-
 
290
			return;
-
 
291
		}
-
 
292
		for ( const item of imeis)
-
 
293
		{ 
-
 
294
		if(arr.includes(item)){ 
-
 
295
			
-
 
296
			imeis = imeis.concat($('select.mk_rejected').val());
-
 
297
			lenArray=lenArray.concat(item);
-
 
298
		}
-
 
299
		else
-
 
300
		{
-
 
301
			imeis=[];
-
 
302
			lenArray=lenArray.concat(1);	
-
 
303
			if(imeis=="")
-
 
304
			{alert("All IMEIs Should be present in pending Status");}
-
 
305
					break;
-
 
306
		}
-
 
307
		}
-
 
308
		
-
 
309
	}
-
 
310
	
-
 
311
	else if(status=='approved') {
-
 
312
			for ( const item of imeis)
-
 
313
		{ 
-
 
314
		if(arr.includes(item)){
-
 
315
			imeis = imeis.concat($('select.mk_approved').val());
-
 
316
			
-
 
317
			lenArray=lenArray.concat(item);
-
 
318
			
-
 
319
		}
-
 
320
		else
-
 
321
		{
-
 
322
			imeis=[];
-
 
323
			lenArray=lenArray.concat(1);
-
 
324
			if(imeis=="")
-
 
325
			{alert("All IMEIs Should be present in pending Status");}
-
 
326
					break;
-
 
327
		}
-
 
328
		}
-
 
329
	}
-
 
330
   else if(status=='pending') {
-
 
331
	   for ( const item of imeis)
-
 
332
		{ 
-
 
333
		if(holdarr.includes(item)){
-
 
334
			imeis = imeis.concat($('select.mk_pending').val());
-
 
335
			lenArray=lenArray.concat(item);
-
 
336
		}
-
 
337
		else
-
 
338
		{
-
 
339
			imeis=[];
-
 
340
			if(imeis=="")
-
 
341
				lenArray=lenArray.concat(1);	
-
 
342
			{alert("All IMEIs Should be present in Hold Status");}
-
 
343
					break;
-
 
344
		}
-
 
345
		}
-
 
346
	  
-
 
347
	} 
-
 
348
	
-
 
349
	else{
-
 
350
		
-
 
351
		for ( const item of imeis)
-
 
352
		{ 
-
 
353
		if(arr.includes(item)){
-
 
354
			imeis = imeis.concat($('select.mk_hold').val());
-
 
355
		
-
 
356
			lenArray=lenArray.concat(item);
-
 
357
		}
-
 
358
		else
-
 
359
		{
-
 
360
			imeis=[];
-
 
361
			lenArray=lenArray.concat(1);
-
 
362
			if(imeis=="")
-
 
363
			{alert("All IMEIs Should be present in pending Status");}
-
 
364
					break;
-
 
365
		}
-
 
366
		}
-
 
367
		
-
 
368
	}
-
 
369
 
-
 
370
	if(imeis.length == 0)  {
-
 
371
		
-
 
372
 
-
 
373
		if(lenArray.length != 0){
-
 
374
			return;
-
 
375
		}
-
 
376
		else{
-
 
377
		alert('Please choose imeis');
-
 
378
		return;
-
 
379
		
-
 
380
	}
-
 
381
	}
-
 
382
 
-
 
383
	if(!confirm("Move selected imeis to " + status + "?")) {
-
 
384
		return;
-
 
385
	}
-
 
386
	var trElement=clickedPriceDrop.closest('tr');
-
 
387
	var priceDropId = trElement.data('pricedropid');
-
 
388
	
-
 
389
	console.log("trElement"+trElement+"priceDropId"+priceDropId);
-
 
390
	priceDropImeisObj = {
-
 
391
			priceDropId: priceDropId,
-
 
392
			updatedStatus : status,
-
 
393
			
-
 
394
			updatedImeis : imeis
-
 
395
	};
-
 
396
	doPostAjaxRequestWithJsonHandler(context+"/updatePriceDropImeis", JSON.stringify(priceDropImeisObj), function(response) {
-
 
397
		if (response == 'true') {
-
 
398
			alert('Imeis updated and processed successfully');
-
 
399
			priceDropImeis(priceDropId);
-
 
400
		}
-
 
401
		else {
-
 
402
			alert("Error occurred while updating.");
-
 
403
		}
-
 
404
	});
-
 
405
	
-
 
406
	
-
 
407
	
-
 
408
	
-
 
409
	
-
 
410
}
340
}
411
341