Subversion Repositories SmartDukaan

Rev

Rev 23819 | Rev 23946 | 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
	});
23819 govind 63
	$('#download').live('click', function (){
64
		if (confirm("Are you sure you want to Download!") == true) {
65
			priceDropId=$(this).data('download');
66
		console.log(priceDropId);
67
		doAjaxGetDownload(context+"/downloadPriceDropIMEI/"+priceDropId,
68
		"priceDrop"+priceDropId+".xlsx");
69
		}
70
	});
23884 amit.gupta 71
	$('input.downloadtotalIMEI').live('click', function (){
23819 govind 72
		if (confirm("Are you sure you want to Download!") == true) {
23884 amit.gupta 73
		priceDropId=$(this).closest('tr').data('priceDropId');
23819 govind 74
		console.log(priceDropId);
75
		doAjaxGetDownload(context+"/downloadtotalPriceDropIMEI/"+priceDropId,
76
		"totalPriceDropIMEI"+priceDropId+".xlsx");
77
		}
78
	});
79
 
80
 
81
	$('#cashTopartner').live('click', function (){
82
		if (confirm("Are you sure you want to ProcessAmount!") == true) {
83
			priceDropId=$(this).data('cashback');
84
		var processedamount=$("#" +priceDropId).val();
85
		console.log("#" + priceDropId);
86
		//alert(processedamount);
87
		if(processedamount)
88
			{
89
		console.log(priceDropId);
90
		console.log(processedamount);
91
		loadProcessedamount(priceDropId,processedamount);
92
		}
93
		else
94
			{
95
			console.log(priceDropId);
96
			console.log(processedamount);
97
			alert("ProcessedAmount can't be empty");
98
			}
99
		}
100
	});
101
 
102
});
103
function loadPriceDrop(domId){
104
	doGetAjaxRequestHandler(context+"/getItemDescription", function(response){
105
		$('#' + domId).html(response);
106
	});
107
}
108
function loadProcessedamount(priceDropId,amount){
109
	doPostAjaxRequestHandler(context+"/paymentAgainstPriceDrop/"+priceDropId+"/"+amount,
110
		function(response) {
111
			if (response == 'true') {
112
				alert("PriceDrop sends successfully");
113
				loadPriceDrop("main-content");
114
			}
115
			else
116
				{
117
				alert("No IMEI is Eligible for PriceDrop");
118
				loadPriceDrop("main-content");
119
				}
120
	});
121
 
122
}