Subversion Repositories SmartDukaan

Rev

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