Subversion Repositories SmartDukaan

Rev

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

Rev 24176 Rev 24406
Line 1... Line 1...
1
$(
1
 
2
		() =>{
-
 
3
	$("button.processPayout").live('click', function() {
2
	$("button.processPayout").live('click', function() {
4
		if($(".mk_pending")) {
3
		if($(".mk_pending")) {
5
			
4
			
6
		}
5
		}
7
	}); 
6
	}); 
8
	$(".price_drop").live('click', function() {
-
 
9
		loadPriceDrop("main-content");
-
 
10
	});
-
 
11
	$("button.update-mop").live('click', function() {
-
 
12
		if($("#typeaheaditem").val().trim().length == 0){
-
 
13
			alert("Please choose Item");
-
 
14
			return;
-
 
15
		}
-
 
16
		var newMop = $("#newMop").val();
-
 
17
		var allColors = $("#allColors").prop('checked');
-
 
18
 
7
 
19
		if(newMop.length == 0 || parseFloat(newMop) == 0) {
-
 
20
			alert("New Mop should not be empty");
-
 
21
			return;
-
 
22
		}
-
 
23
		if(confirm("Are you sure?")) {
-
 
24
			var obj = {
-
 
25
					itemId:currentItem.itemId,
-
 
26
					mop:parseFloat(newMop),
-
 
27
					allColors:allColors,
-
 
28
			}
-
 
29
			doPostAjaxRequestWithJsonHandler(
-
 
30
					context+"/updateMop", JSON.stringify(obj),
-
 
31
					function(response) {
-
 
32
						if (response == 'true') {
-
 
33
							$('#newPriceDropModal').find('button.close').trigger('click');
-
 
34
							setTimeout(() => {
-
 
35
								alert("Pricing added successfully")
-
 
36
								loadPriceDrop("main-content");
-
 
37
							}, 500);
-
 
38
						} else {
-
 
39
							alert("Something went wrong pls try after sometime");
-
 
40
						}
-
 
41
					}
-
 
42
			);
-
 
43
		}
-
 
44
	});
-
 
45
	$("button.add-pricing").live('click', function() {
8
	$("button.add-pricing").live('click', function() {
46
		if($("#typeaheaditem1").val().trim().length == 0){
9
		if($("#typeaheaditem1").val().trim().length == 0){
47
			alert("Please choose Item");
10
			alert("Please choose Item");
48
			return;
11
			return;
49
		}
12
		}
Line 70... Line 33...
70
			}
33
			}
71
			doPostAjaxRequestWithJsonHandler(
34
			doPostAjaxRequestWithJsonHandler(
72
					context+"/add-pricing", JSON.stringify(obj),
35
					context+"/add-pricing", JSON.stringify(obj),
73
					function(response) {
36
					function(response) {
74
						if (response == 'true') {
37
						if (response == 'true') {
75
							$('#addPriceModal').find('button.close').trigger('click');
38
							//$('#addPriceModal').find('button.close').trigger('click');
76
							setTimeout(() => {
39
							setTimeout(() => {
77
								alert("PriceDrop added successfully")
40
								alert("Prices Successfully Updated for " + $("#typeaheaditem1").val());
78
								loadPriceDrop("main-content");
41
								//loadPriceDrop("main-content");
79
							}, 500);
42
							}, 500);
80
						} else {
43
						} else {
81
							alert("Something went wrong pls try after sometime");
44
							alert("Something went wrong pls try after sometime");
82
						}
45
						}
83
					}
46
					}
Line 130... Line 93...
130
			}
93
			}
131
			doPostAjaxRequestWithJsonHandler(
94
			doPostAjaxRequestWithJsonHandler(
132
					context+"/priceDrop", JSON.stringify(obj),
95
					context+"/priceDrop", JSON.stringify(obj),
133
					function(response) {
96
					function(response) {
134
						if (response == 'true') {
97
						if (response == 'true') {
135
							$('#newPriceDropModal').find('button.close').trigger('click');
98
							//$('#newPriceDropModal').find('button.close').trigger('click');
136
							setTimeout(() => {
99
							setTimeout(() => {
137
								alert("PriceDrop added successfully")
100
								alert("PriceDrop added successfully from " + $("#typeaheaditem").val());
138
								loadPriceDrop("main-content");
101
								loadPriceDrop("main-content");
139
							}, 500);
102
							}, 500);
140
						} else {
103
						} else {
141
							alert("Something went wrong pls try after sometime");
104
							alert("Something went wrong pls try after sometime");
142
						}
105
						}
Line 217... Line 180...
217
		}
180
		}
218
		else {
181
		else {
219
			return false;
182
			return false;
220
		}
183
		}
221
	});
184
	});
222
});
-
 
223
function addPayout(priceDropProcessObj){
185
function addPayout(priceDropProcessObj){
224
	doPostAjaxRequestWithJsonHandler(context+"/price-drop/addPayout", JSON.stringify(priceDropProcessObj), function(response) {
186
	doPostAjaxRequestWithJsonHandler(context+"/price-drop/addPayout", JSON.stringify(priceDropProcessObj), function(response) {
225
		if (response == 'true') {
187
		if (response == 'true') {
226
			alert("Payout added");
188
			alert("Payout added");
227
			loadPriceDrop("main-content");
189
			loadPriceDrop("main-content");
Line 229... Line 191...
229
		else {
191
		else {
230
			alert("Some error occurred while adding payout.");
192
			alert("Some error occurred while adding payout.");
231
		}
193
		}
232
	});
194
	});
233
}
195
}
234
function loadPriceDrop(domId){
-
 
235
	doGetAjaxRequestHandler(context+"/getItemDescription", function(response){
-
 
236
		$('#' + domId).html(response);
-
 
237
	});
-
 
238
}
196
 
239
function processPayout(priceDropProcessObj){
197
function processPayout(priceDropProcessObj){
240
	doPostAjaxRequestWithJsonHandler(context+"/processPriceDrop", JSON.stringify(priceDropProcessObj), function(response) {
198
	doPostAjaxRequestWithJsonHandler(context+"/processPriceDrop", JSON.stringify(priceDropProcessObj), function(response) {
241
		if (response == 'true') {
199
		if (response == 'true') {
242
			alert("PriceDrop sends successfully");
200
			alert("PriceDrop sends successfully");
243
			loadPriceDrop("main-content");
201
			loadPriceDrop("main-content");
Line 284... Line 242...
284
		else {
242
		else {
285
			alert("Error occurred while updating.");
243
			alert("Error occurred while updating.");
286
		}
244
		}
287
	});
245
	});
288
	
246
	
289
}
-
 
290
247
}
-
 
248
 
-
 
249
$(document).ready(function() {
-
 
250
	var start = moment().subtract(29, 'days');
-
 
251
	var end = moment();
-
 
252
	
-
 
253
  	priceDropTable = $('#priceDrop').find('table').DataTable({
-
 
254
  		pageLength: 20,
-
 
255
  		order:[[ 5, 'desc' ]]
-
 
256
	});
-
 
257
  
-
 
258
  
-
 
259
  	getItemAheadOptions($("#typeaheaditem"),function(selectedItem){
-
 
260
		currentItem = selectedItem;
-
 
261
		doGetAjaxRequestHandler(context+"/item-pricing/"+currentItem.itemId, function(response){
-
 
262
			response = JSON.parse(response);
-
 
263
			$('#currentDp').val(response.dp);
-
 
264
			$('#oldMop').html(response.mop);
-
 
265
			$('#oldTp').html(response.tp);
-
 
266
			$('#oldNlc').html(response.nlc);
-
 
267
		});
-
 
268
	});
-
 
269
	getItemAheadOptions($("#typeaheaditem1"), function(selectedItem){
-
 
270
		currentItem = selectedItem;
-
 
271
		doGetAjaxRequestHandler(context+"/item-pricing/"+currentItem.itemId, function(response){
-
 
272
			response = JSON.parse(response);
-
 
273
			
-
 
274
			$("#mop").val(response.mop);
-
 
275
			$("#mrp").val(response.mrp);
-
 
276
			$("#dp").val(response.dp);
-
 
277
			$('#dpValue').html("DP -" + response.dp);
-
 
278
			$('#mopValue').html("MOP -" + response.mop);
-
 
279
			$('#mrpValue').html("MRP -"+ response.mrp);
-
 
280
		});
-
 
281
	});
-
 
282
});
-
 
283
291
284