Subversion Repositories SmartDukaan

Rev

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