Subversion Repositories SmartDukaan

Rev

Rev 29851 | Rev 30757 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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