Subversion Repositories SmartDukaan

Rev

Rev 23946 | Rev 23966 | 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
	});
23884 amit.gupta 5
	$("button.addPriceDrop").live('click', function() {
6
		if($("#typeaheaditem").val().trim().length == 0){
7
			alert("Please choose Item");
8
			return;
9
		}
10
		var priceDrop = $("#pd").val();
11
		var newTp = $("#newTp").val();
12
		var newMop = $("#newMop").val();
13
		var newNlc = $("#newNlc").val();
14
		var affectedOn = $("#affectedDate").val();
15
		var allColors = $("#allColors").prop('checked');
16
		if(priceDrop.length == 0 || parseFloat(priceDrop) == 0) {
17
			alert("Price Drop should not be empty");
18
			return;
19
		}
20
		if(newTp.length == 0 || parseFloat(newTp) == 0) {
21
			alert("New Tp should not be empty");
22
			return;
23
		}
24
		if(newMop.length == 0 || parseFloat(newMop) == 0) {
25
			alert("New Mop should not be empty");
26
			return;
27
		}
28
		if(newNlc.length == 0 || parseFloat(newNlc) == 0) {
29
			alert("New Nlc should not be empty");
30
			return;
31
		}
32
 
33
		if(affectedOn.length == 0) {
34
			alert("Affected Date Should not be empty");
35
			return;
36
		}
37
		if(confirm("Are you sure?")) {
38
			var obj = {
39
					itemId:currentItem.itemId,
40
					tp:parseFloat(newTp),
41
					pd:parseFloat(priceDrop),
42
					mop:parseFloat(newMop),
43
					nlc:parseFloat(newNlc),
44
					allColors:allColors,
45
					affectedDate:startDate
46
			}
47
			doPostAjaxRequestWithJsonHandler(
48
					context+"/priceDrop", JSON.stringify(obj),
49
					function(response) {
50
						if (response == 'true') {
51
							$('#newPriceDropModal').find('button.close').trigger('click');
52
							setTimeout(() => {
53
								alert("PriceDrop added successfully")
54
								loadPriceDrop("main-content");
55
							}, 500);
56
						} else {
57
							alert("Something went wrong pls try after sometime");
58
						}
59
					}
60
			);
61
		}
62
	});
63
	$('input.downloadtotalIMEI').live('click', function (){
23946 amit.gupta 64
		priceDropId=$(this).closest('tr').data('pricedropid');
23819 govind 65
		console.log(priceDropId);
66
		doAjaxGetDownload(context+"/downloadtotalPriceDropIMEI/"+priceDropId,
67
		"totalPriceDropIMEI"+priceDropId+".xlsx");
68
	});
69
 
23951 amit.gupta 70
	$('button.download-imeis').live('click', function(){
71
		doAjaxGetDownload(context+"/price-drop/imes/download/?affectedDate="+startDate +"&itemId=" + currentItem.itemId, "pricedrop.csv")
72
	});
23819 govind 73
 
23951 amit.gupta 74
 
23819 govind 75
	$('#cashTopartner').live('click', function (){
76
		if (confirm("Are you sure you want to ProcessAmount!") == true) {
77
			priceDropId=$(this).data('cashback');
78
		var processedamount=$("#" +priceDropId).val();
79
		console.log("#" + priceDropId);
23946 amit.gupta 80
		// alert(processedamount);
23819 govind 81
		if(processedamount)
82
			{
83
		console.log(priceDropId);
84
		console.log(processedamount);
85
		loadProcessedamount(priceDropId,processedamount);
86
		}
87
		else
88
			{
89
			console.log(priceDropId);
90
			console.log(processedamount);
91
			alert("ProcessedAmount can't be empty");
92
			}
93
		}
94
	});
95
 
96
});
97
function loadPriceDrop(domId){
98
	doGetAjaxRequestHandler(context+"/getItemDescription", function(response){
99
		$('#' + domId).html(response);
100
	});
101
}
102
function loadProcessedamount(priceDropId,amount){
103
	doPostAjaxRequestHandler(context+"/paymentAgainstPriceDrop/"+priceDropId+"/"+amount,
104
		function(response) {
105
			if (response == 'true') {
106
				alert("PriceDrop sends successfully");
107
				loadPriceDrop("main-content");
108
			}
109
			else
110
				{
111
				alert("No IMEI is Eligible for PriceDrop");
112
				loadPriceDrop("main-content");
113
				}
114
	});
115
 
116
}