| 30757 |
tejbeer |
1 |
$(function() {
|
|
|
2 |
$(document).on('click', ".customer-offer", function() {
|
| 29707 |
tejbeer |
3 |
loadCustomerOffer("main-content");
|
|
|
4 |
});
|
|
|
5 |
|
|
|
6 |
|
| 30757 |
tejbeer |
7 |
$(document).on('click', ".samsung-upgrade-offer", function() {
|
| 29707 |
tejbeer |
8 |
loadSamsungUpgradeOffer("main-content");
|
|
|
9 |
});
|
|
|
10 |
|
| 30757 |
tejbeer |
11 |
$(document).on('click', ".createoffer", function() {
|
| 29707 |
tejbeer |
12 |
|
|
|
13 |
|
|
|
14 |
var offerName = $("#offername").val();
|
|
|
15 |
|
|
|
16 |
if (offerName === "") {
|
|
|
17 |
alert("Offer Name is required");
|
|
|
18 |
return;
|
|
|
19 |
}
|
|
|
20 |
|
| 31147 |
tejbeer |
21 |
let customerOfferModel = {};
|
|
|
22 |
customerOfferModel['offerName'] = offerName;
|
|
|
23 |
customerOfferModel['startDate'] = getDatesFromPicker('input[name="dateRange"]').startDate,
|
|
|
24 |
customerOfferModel['endDate'] = getDatesFromPicker('input[name="dateRange"]').endDate,
|
|
|
25 |
customerOfferModel['partnerCriteria'] = {};
|
|
|
26 |
customerOfferModel['partnerCriteria']['fofoIds'] = ($("#partners").val() || []).map(Number);
|
|
|
27 |
customerOfferModel['partnerCriteria']['excludeFofoIds'] = [];
|
|
|
28 |
let excludeFofoIdChecked = $('input.excludeFofoId').is(':checked');
|
|
|
29 |
if (excludeFofoIdChecked) {
|
|
|
30 |
customerOfferModel['partnerCriteria']['excludeFofoIds'] = customerOfferModel['partnerCriteria']['fofoIds'];
|
|
|
31 |
customerOfferModel['partnerCriteria']['fofoIds'] = [];
|
|
|
32 |
}
|
| 29707 |
tejbeer |
33 |
|
| 31147 |
tejbeer |
34 |
customerOfferModel['partnerCriteria']['partnerTypes'] = [];
|
|
|
35 |
|
|
|
36 |
customerOfferModel['partnerCriteria']['regionIds'] = ($("select.criteria-warehouseregion").val() || []).map(Number);
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
| 29707 |
tejbeer |
40 |
if (confirm("Are you sure you want to create offer!") == true) {
|
| 31147 |
tejbeer |
41 |
doPostAjaxRequestWithJsonHandler(context
|
|
|
42 |
+ "/createCustomerOffer", JSON.stringify(customerOfferModel), function(response) {
|
| 30757 |
tejbeer |
43 |
if (response = true) {
|
|
|
44 |
alert("create successfully");
|
|
|
45 |
loadCustomerOffer("main-content");
|
|
|
46 |
}
|
|
|
47 |
});
|
| 29707 |
tejbeer |
48 |
}
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
});
|
|
|
52 |
|
| 30757 |
tejbeer |
53 |
$(document).on('click', "#downloadCustomerOfferTemplate", function() {
|
| 29707 |
tejbeer |
54 |
|
|
|
55 |
window.location.href = context + "/customerOffer/downloadTemplate";
|
|
|
56 |
});
|
|
|
57 |
|
|
|
58 |
|
| 31147 |
tejbeer |
59 |
$(document).on('click', "#offer-item-search-button", function() {
|
|
|
60 |
var searchText = $("#offer-item-search-text").val();
|
|
|
61 |
var date = $(".schemes-date").val();
|
|
|
62 |
if (typeof (searchText) == "undefined" || !searchText) {
|
|
|
63 |
searchText = "";
|
|
|
64 |
alert("please select item");
|
|
|
65 |
return;
|
|
|
66 |
}
|
|
|
67 |
if (typeof currentItem != "undefined") {
|
|
|
68 |
console.log(currentItem);
|
|
|
69 |
|
|
|
70 |
doGetAjaxRequestHandler(`${context}/getCustomerOffer?searchModel=` + currentItem, function(response) {
|
|
|
71 |
$('#' + "main-content").html(response);
|
|
|
72 |
});
|
|
|
73 |
} else {
|
|
|
74 |
console.log("reeffff")
|
|
|
75 |
alert("Data No Found")
|
|
|
76 |
}
|
|
|
77 |
});
|
|
|
78 |
|
| 30757 |
tejbeer |
79 |
$(document).on('click', ".downloadOffer", function() {
|
| 29707 |
tejbeer |
80 |
var id = $(this).data('requestid');
|
|
|
81 |
|
|
|
82 |
window.location.href = context + "/customerOfferItem/download?offerId=" + id;
|
|
|
83 |
});
|
|
|
84 |
|
|
|
85 |
|
| 30757 |
tejbeer |
86 |
$(document).on('click', ".extendeDate-button", function() {
|
| 30599 |
amit.gupta |
87 |
let id = $(this).data('requestid');
|
|
|
88 |
let row = $(this).closest("tr");
|
| 30757 |
tejbeer |
89 |
let pickerElement = row.find("input[name = 'extendEndDate']");
|
| 31147 |
tejbeer |
90 |
|
|
|
91 |
|
| 30599 |
amit.gupta |
92 |
let params = {
|
| 29707 |
tejbeer |
93 |
"id": id,
|
| 31147 |
tejbeer |
94 |
"endDate": getDatesFromPicker(pickerElement).endDate
|
| 29707 |
tejbeer |
95 |
}
|
| 30757 |
tejbeer |
96 |
|
|
|
97 |
console.log(params)
|
| 29707 |
tejbeer |
98 |
if (confirm("Are you sure you want extend the offer") == true) {
|
|
|
99 |
doPostAjaxRequestWithParamsHandler(context
|
| 30757 |
tejbeer |
100 |
+ "/extendCustomerOffer", params, function(response) {
|
|
|
101 |
row.html(response);
|
|
|
102 |
});
|
| 29707 |
tejbeer |
103 |
}
|
|
|
104 |
|
|
|
105 |
});
|
|
|
106 |
|
|
|
107 |
|
| 30757 |
tejbeer |
108 |
$(document).on('input', 'table#offer-customer-table input[type=file]', function() {
|
| 29851 |
tejbeer |
109 |
var row = $(this).closest("tr");
|
|
|
110 |
var id = $(row).find("td:eq(0)").text();
|
|
|
111 |
if (confirm('Confirm upload ?')) {
|
|
|
112 |
var fileSelector = $(this)[0];
|
|
|
113 |
if (fileSelector != undefined
|
|
|
114 |
&& fileSelector.files[0] != undefined) {
|
|
|
115 |
var url = `${context}/customerOfferItem/upload?offerId=` + id;
|
|
|
116 |
console.log(url);
|
|
|
117 |
var file = this.files[0];
|
|
|
118 |
console.log("file" + file);
|
|
|
119 |
let fileInput = $(this);
|
|
|
120 |
console.log("fileInput" + file);
|
| 30757 |
tejbeer |
121 |
doAjaxUploadRequestHandler(url, 'POST', file, function(response) {
|
| 30599 |
amit.gupta |
122 |
console.log(response)
|
|
|
123 |
alert("successfully uploaded");
|
|
|
124 |
});
|
| 29849 |
tejbeer |
125 |
}
|
| 29851 |
tejbeer |
126 |
}
|
|
|
127 |
});
|
| 29707 |
tejbeer |
128 |
|
|
|
129 |
|
| 30757 |
tejbeer |
130 |
$(document).on('click', ".upgrade-approved", function() {
|
| 29851 |
tejbeer |
131 |
var id = $(this).data('requestid');
|
|
|
132 |
var row = $(this).closest("tr");
|
| 29707 |
tejbeer |
133 |
|
| 29851 |
tejbeer |
134 |
if (confirm("Are you sure you want Approve r!") == true) {
|
| 30757 |
tejbeer |
135 |
doPostAjaxRequestHandler(`${context}/approveSamsungUpgradeOffer?id=${id}`, function(response) {
|
| 30599 |
amit.gupta |
136 |
alert("Successfully Approved");
|
|
|
137 |
row.html(response);
|
|
|
138 |
return false;
|
|
|
139 |
});
|
| 29851 |
tejbeer |
140 |
}
|
| 29707 |
tejbeer |
141 |
|
|
|
142 |
});
|
|
|
143 |
|
| 30757 |
tejbeer |
144 |
$(document).on('click', ".upgrade-rejected", function() {
|
| 30599 |
amit.gupta |
145 |
let id = $(this).data('requestid');
|
| 29851 |
tejbeer |
146 |
if (confirm("Are you sure you want Reject!") == true) {
|
| 30757 |
tejbeer |
147 |
doPostAjaxRequestHandler(`${context}/rejectSamsungUpgradeOffer?id=${id}`, function(response) {
|
| 30599 |
amit.gupta |
148 |
if (response == 'true') {
|
|
|
149 |
alert("Successfully Rejected");
|
|
|
150 |
loadWalletRequest("main-content");
|
|
|
151 |
}
|
|
|
152 |
return false;
|
|
|
153 |
});
|
| 29851 |
tejbeer |
154 |
}
|
|
|
155 |
});
|
|
|
156 |
|
| 31147 |
tejbeer |
157 |
$(document).on('click', ".customerOfferItems", function() {
|
| 29851 |
tejbeer |
158 |
|
| 31147 |
tejbeer |
159 |
var currentRow = $(this).closest("tr");
|
|
|
160 |
|
|
|
161 |
var offerId = currentRow.find("td:eq(0)").text();
|
|
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
|
165 |
doGetAjaxRequestHandler(context + "/getCustomerOfferItem?offerId="
|
|
|
166 |
+ offerId, function(response) {
|
|
|
167 |
|
|
|
168 |
console.log(response)
|
|
|
169 |
$('#customerOfferItemdetail .modal-content').html(response);
|
|
|
170 |
|
|
|
171 |
});
|
|
|
172 |
|
|
|
173 |
});
|
|
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
|
177 |
$(document).on('click', ".expired-date-button", function() {
|
|
|
178 |
let id = $(this).data('requestid');
|
|
|
179 |
let row = $(this).closest("tr");
|
|
|
180 |
let pickerElement = row.find("input[name = 'expiredEndDate']");
|
|
|
181 |
let params = {
|
|
|
182 |
"id": id,
|
|
|
183 |
"endDate": getDatesFromPicker(pickerElement).startDate
|
|
|
184 |
}
|
|
|
185 |
|
|
|
186 |
console.log(params)
|
|
|
187 |
if (confirm("Are you sure you want expired the offer") == true) {
|
|
|
188 |
doPostAjaxRequestWithParamsHandler(context
|
|
|
189 |
+ "/expiredCustomerOfferItem", params, function(response) {
|
|
|
190 |
row.html(response);
|
|
|
191 |
});
|
|
|
192 |
}
|
|
|
193 |
|
|
|
194 |
});
|
|
|
195 |
|
|
|
196 |
|
|
|
197 |
$(document).on('click', ".addOfferItem", function() {
|
|
|
198 |
|
|
|
199 |
let offerId = $(this).data('offerid');
|
|
|
200 |
|
|
|
201 |
var dealerPayout = $("#dealerPayout").val();
|
|
|
202 |
|
|
|
203 |
var schemePayout = $("#schemePayout").val();
|
|
|
204 |
|
|
|
205 |
|
|
|
206 |
if (dealerPayout === "") {
|
|
|
207 |
alert("Dealer Payout is required");
|
|
|
208 |
return;
|
|
|
209 |
}
|
|
|
210 |
|
|
|
211 |
if (schemePayout === "") {
|
|
|
212 |
alert("Scheme Payout is required");
|
|
|
213 |
return;
|
|
|
214 |
}
|
|
|
215 |
|
|
|
216 |
var json = {
|
|
|
217 |
|
|
|
218 |
"catalogId": currentItem,
|
|
|
219 |
"dealerPayout": dealerPayout,
|
|
|
220 |
"schemePayout": schemePayout,
|
|
|
221 |
"startDate": getDatesFromPicker('input[name="offerItemDuration"]').startDate,
|
|
|
222 |
"endDate": getDatesFromPicker('input[name="offerItemDuration"]').endDate,
|
|
|
223 |
"offerId": offerId
|
|
|
224 |
|
|
|
225 |
}
|
|
|
226 |
|
|
|
227 |
|
|
|
228 |
|
|
|
229 |
if (confirm("Are you sure you want to create offer!") == true) {
|
|
|
230 |
doPostAjaxRequestWithJsonHandler(context
|
|
|
231 |
+ "/addCustomerOfferItem", JSON.stringify(json), function(response) {
|
|
|
232 |
if (response = true) {
|
|
|
233 |
alert("create successfully");
|
|
|
234 |
$('#customerOfferItemdetail').modal('hide');
|
|
|
235 |
$('.modal-backdrop').remove();
|
|
|
236 |
loadCustomerOffer("main-content");
|
|
|
237 |
}
|
|
|
238 |
});
|
|
|
239 |
}
|
|
|
240 |
|
|
|
241 |
|
|
|
242 |
});
|
|
|
243 |
|
| 29851 |
tejbeer |
244 |
});
|
|
|
245 |
|
|
|
246 |
function loadCustomerOffer(domId) {
|
|
|
247 |
|
| 30757 |
tejbeer |
248 |
doGetAjaxRequestHandler(`${context}/getCustomerOffer`, function(response) {
|
| 29851 |
tejbeer |
249 |
$('#' + domId).html(response);
|
|
|
250 |
});
|
|
|
251 |
}
|
|
|
252 |
|
|
|
253 |
function loadSamsungUpgradeOffer(domId) {
|
| 30757 |
tejbeer |
254 |
doGetAjaxRequestHandler(context + "/getSamsungUpgradeOffer", function(response) {
|
| 29851 |
tejbeer |
255 |
$('#' + domId).html(response);
|
|
|
256 |
});
|
| 31147 |
tejbeer |
257 |
}
|
|
|
258 |
|