| 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 |
$(document).on('click', ".customerofferitemupload", function() {
|
|
|
80 |
var id = $(this).data('requestid');
|
|
|
81 |
console.log("id");
|
|
|
82 |
|
|
|
83 |
if (confirm('Confirm upload ?')) {
|
|
|
84 |
var fileSelector = $(this)[0];
|
|
|
85 |
if (fileSelector != undefined) {
|
|
|
86 |
var url = `${context}/customerOfferItem/upload?offerId=` + id;
|
|
|
87 |
console.log(url);
|
|
|
88 |
var file = $("#customerofferitem")[0].files[0];
|
|
|
89 |
let fileInput = $(this);
|
|
|
90 |
console.log("file" + file);
|
|
|
91 |
console.log("fileInput" + fileInput);
|
|
|
92 |
doAjaxUploadRequestHandler(
|
|
|
93 |
url,
|
|
|
94 |
'POST',
|
|
|
95 |
file, function(response) {
|
|
|
96 |
|
|
|
97 |
console.log(response)
|
|
|
98 |
alert("successfully uploaded");
|
|
|
99 |
|
|
|
100 |
});
|
|
|
101 |
|
|
|
102 |
}
|
|
|
103 |
}
|
|
|
104 |
});
|
|
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
|
108 |
$(document).on('click', ".upgrade-approved", function() {
|
|
|
109 |
var id = $(this).data('requestid');
|
|
|
110 |
var row = $(this).closest("tr");
|
|
|
111 |
|
|
|
112 |
if (confirm("Are you sure you want Approve r!") == true) {
|
|
|
113 |
doPostAjaxRequestHandler(context + "/approveSamsungUpgradeOffer?id="
|
|
|
114 |
+ id, function(response) {
|
|
|
115 |
|
|
|
116 |
alert("Successfully Approved");
|
|
|
117 |
|
|
|
118 |
row.html(response);
|
|
|
119 |
|
|
|
120 |
|
|
|
121 |
return false;
|
|
|
122 |
});
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
});
|
|
|
126 |
|
|
|
127 |
|
|
|
128 |
$(document).on('click', ".upgrade-rejected", function() {
|
|
|
129 |
var id = $(this).data('requestid');
|
|
|
130 |
|
|
|
131 |
|
|
|
132 |
if (confirm("Are you sure you want Reject!") == true) {
|
|
|
133 |
doPostAjaxRequestHandler(context + "/rejectSamsungUpgradeOffer?id="
|
|
|
134 |
+ id, function(response) {
|
|
|
135 |
if (response == 'true') {
|
|
|
136 |
alert("Successfully Rejected");
|
|
|
137 |
|
|
|
138 |
loadWalletRequest("main-content");
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
return false;
|
|
|
142 |
});
|
|
|
143 |
}
|
|
|
144 |
});
|
|
|
145 |
|
|
|
146 |
|
|
|
147 |
});
|
|
|
148 |
|
|
|
149 |
function loadCustomerOffer(domId) {
|
|
|
150 |
|
|
|
151 |
doGetAjaxRequestHandler(context + "/getCustomerOffer", function(response) {
|
|
|
152 |
$('#' + domId).html(response);
|
|
|
153 |
});
|
|
|
154 |
}
|
|
|
155 |
|
|
|
156 |
function loadSamsungUpgradeOffer(domId) {
|
|
|
157 |
doGetAjaxRequestHandler(context + "/getSamsungUpgradeOffer", function(response) {
|
|
|
158 |
$('#' + domId).html(response);
|
|
|
159 |
});
|
|
|
160 |
}
|