Subversion Repositories SmartDukaan

Rev

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