Subversion Repositories SmartDukaan

Rev

Rev 29849 | Rev 30599 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
29707 tejbeer 1
$(function() {
2
	$(document).on('click', ".customer-offer", function() {
3
		loadCustomerOffer("main-content");
4
	});
5
 
6
 
7
	$(document).on('click', ".samsung-upgrade-offer", function() {
8
		loadSamsungUpgradeOffer("main-content");
9
	});
10
 
11
	$(document).on('click', ".createoffer", function() {
12
 
13
 
14
		var offerName = $("#offername").val();
15
 
16
		if (offerName === "") {
17
			alert("Offer Name is required");
18
			return;
19
		}
20
 
21
		var params = {
22
			"offerName": offerName,
23
			"startDate": startDate,
24
			"endDate": endDate,
25
 
26
		}
27
		if (confirm("Are you sure you want to create offer!") == true) {
28
			doPostAjaxRequestWithParamsHandler(context
29
				+ "/createCustomerOffer", params, function(response) {
30
					if (response = true) {
31
 
32
 
33
						alert("create  successfully");
34
						loadCustomerOffer("main-content");
35
					}
36
				});
37
		}
38
 
39
 
40
	});
41
 
42
	$(document).on('click', "#downloadCustomerOfferTemplate", function() {
43
 
44
		window.location.href = context + "/customerOffer/downloadTemplate";
45
	});
46
 
47
 
48
	$(document).on('click', ".downloadOffer", function() {
49
		var id = $(this).data('requestid');
50
 
51
		window.location.href = context + "/customerOfferItem/download?offerId=" + id;
52
	});
53
 
54
 
55
 
56
	$(document).on('click', ".extendeDate-button", function() {
57
		var id = $(this).data('requestid');
58
 
59
 
60
		var row = $(this).closest("tr");
61
 
62
		var params = {
63
			"id": id,
64
			"endDate": startDate,
65
 
66
 
67
		}
68
 
69
		if (confirm("Are you sure you want extend the offer") == true) {
70
			doPostAjaxRequestWithParamsHandler(context
71
				+ "/extendCustomerOffer", params, function(response) {
72
					row.html(response);
73
				});
74
		}
75
 
76
	});
77
 
78
 
79
 
29851 tejbeer 80
	$(document).on('input', 'table#offer-customer-table input[type=file]', function() {
29707 tejbeer 81
 
82
 
83
 
29851 tejbeer 84
		var row = $(this).closest("tr");
85
		console.log(row);
29707 tejbeer 86
 
87
 
29851 tejbeer 88
		var id = $(row).find("td:eq(0)").text();
89
		if (confirm('Confirm upload ?')) {
29707 tejbeer 90
 
91
 
29851 tejbeer 92
			var fileSelector = $(this)[0];
93
			if (fileSelector != undefined
94
				&& fileSelector.files[0] != undefined) {
95
				var url = `${context}/customerOfferItem/upload?offerId=` + id;
96
				console.log(url);
97
				var file = this.files[0];
98
				console.log("file" + file);
99
				let fileInput = $(this);
100
				console.log("fileInput" + file);
29707 tejbeer 101
 
102
 
29851 tejbeer 103
				doAjaxUploadRequestHandler(
104
					url,
105
					'POST',
106
					file, function(response) {
29707 tejbeer 107
 
29851 tejbeer 108
						console.log(response)
109
						alert("successfully uploaded");
29707 tejbeer 110
 
29851 tejbeer 111
					});
29707 tejbeer 112
 
29849 tejbeer 113
			}
29851 tejbeer 114
		}
115
	});
29707 tejbeer 116
 
117
 
118
 
29851 tejbeer 119
	$(document).on('click', ".upgrade-approved", function() {
120
		var id = $(this).data('requestid');
121
		var row = $(this).closest("tr");
29707 tejbeer 122
 
29851 tejbeer 123
		if (confirm("Are you sure you want Approve r!") == true) {
124
			doPostAjaxRequestHandler(context + "/approveSamsungUpgradeOffer?id="
125
				+ id, function(response) {
29707 tejbeer 126
 
29851 tejbeer 127
					alert("Successfully Approved");
29707 tejbeer 128
 
29851 tejbeer 129
					row.html(response);
29707 tejbeer 130
 
131
 
29851 tejbeer 132
					return false;
133
				});
134
		}
29707 tejbeer 135
 
136
	});
137
 
29849 tejbeer 138
 
29851 tejbeer 139
	$(document).on('click', ".upgrade-rejected", function() {
140
		var id = $(this).data('requestid');
29849 tejbeer 141
 
29851 tejbeer 142
 
143
		if (confirm("Are you sure you want Reject!") == true) {
144
			doPostAjaxRequestHandler(context + "/rejectSamsungUpgradeOffer?id="
145
				+ id, function(response) {
146
					if (response == 'true') {
147
						alert("Successfully Rejected");
148
 
149
						loadWalletRequest("main-content");
150
					}
151
 
152
					return false;
153
				});
154
		}
155
	});
156
 
157
 
158
});
159
 
160
function loadCustomerOffer(domId) {
161
 
162
	doGetAjaxRequestHandler(context + "/getCustomerOffer", function(response) {
163
		$('#' + domId).html(response);
164
	});
165
}
166
 
167
function loadSamsungUpgradeOffer(domId) {
168
	doGetAjaxRequestHandler(context + "/getSamsungUpgradeOffer", function(response) {
169
		$('#' + domId).html(response);
170
	});
171
}