| 35548 |
aman |
1 |
$(function () {
|
|
|
2 |
$(document).on('click', ".lead", function () {
|
|
|
3 |
loadLead("main-content");
|
|
|
4 |
});
|
| 29598 |
tejbeer |
5 |
|
| 35548 |
aman |
6 |
$(document).on('click', ".team-commitment", function () {
|
|
|
7 |
loadTeamCommitment("main-content");
|
|
|
8 |
});
|
| 30439 |
tejbeer |
9 |
|
|
|
10 |
|
| 35548 |
aman |
11 |
$(document).on('click', ".partner-health", function () {
|
|
|
12 |
loadPartnerHealth("main-content");
|
|
|
13 |
});
|
| 29598 |
tejbeer |
14 |
|
| 35548 |
aman |
15 |
$(document).on('click', ".lead-detail", function () {
|
|
|
16 |
loadLeadDetail("main-content");
|
|
|
17 |
});
|
| 30439 |
tejbeer |
18 |
|
| 31370 |
tejbeer |
19 |
|
| 35548 |
aman |
20 |
$(document).on('click', ".submitCommitment",
|
|
|
21 |
function () {
|
|
|
22 |
var startDateTime = getDatesFromPicker('input[name="commitmentDate"]').startDate;
|
|
|
23 |
doGetAjaxRequestHandler(context + "/getTeamCommitment?date="
|
|
|
24 |
+ startDateTime, function (response) {
|
|
|
25 |
$('.teamcommitmentcontainer').html(response);
|
| 31370 |
tejbeer |
26 |
|
| 35548 |
aman |
27 |
});
|
|
|
28 |
});
|
| 30439 |
tejbeer |
29 |
|
|
|
30 |
|
| 35548 |
aman |
31 |
$(document).on('click', ".submitDateWiseLead", function () {
|
| 30439 |
tejbeer |
32 |
|
| 35769 |
amit |
33 |
var startDate = $("#startDate").val();
|
|
|
34 |
var endDate = $("#endDate").val();
|
| 35548 |
aman |
35 |
var status = $("#statusFilter").val();
|
|
|
36 |
var color = $("#colorFilter").val();
|
| 31370 |
tejbeer |
37 |
|
| 35548 |
aman |
38 |
if (color == null) {
|
|
|
39 |
color = "";
|
|
|
40 |
}
|
| 31370 |
tejbeer |
41 |
|
| 35769 |
amit |
42 |
if (startDate && endDate) {
|
|
|
43 |
var start = new Date(startDate);
|
|
|
44 |
var end = new Date(endDate);
|
|
|
45 |
if (end < start) {
|
|
|
46 |
alert("End date must be after start date");
|
|
|
47 |
return;
|
|
|
48 |
}
|
|
|
49 |
}
|
| 31370 |
tejbeer |
50 |
|
| 35769 |
amit |
51 |
doGetAjaxRequestHandler(context + "/getOpenLead?leadStatus=" + status + "&color=" + color + "&startDate=" + startDate + "&endDate=" + endDate, function (response) {
|
| 35548 |
aman |
52 |
$('#' + 'main-content').html(response);
|
|
|
53 |
});
|
| 29598 |
tejbeer |
54 |
|
|
|
55 |
|
| 35548 |
aman |
56 |
})
|
|
|
57 |
;$(document).on('click', ".downloadDateWiseLead", function () {
|
| 29598 |
tejbeer |
58 |
|
| 35769 |
amit |
59 |
var startDate = $("#startDate").val();
|
|
|
60 |
var endDate = $("#endDate").val();
|
| 35548 |
aman |
61 |
var status = $("#statusFilter").val();
|
|
|
62 |
var color = $("#colorFilter").val();
|
| 29598 |
tejbeer |
63 |
|
| 35548 |
aman |
64 |
if (color == null) {
|
|
|
65 |
color = "";
|
|
|
66 |
}
|
| 29598 |
tejbeer |
67 |
|
| 35769 |
amit |
68 |
if (startDate && endDate) {
|
|
|
69 |
var start = new Date(startDate);
|
|
|
70 |
var end = new Date(endDate);
|
|
|
71 |
if (end < start) {
|
|
|
72 |
alert("End date must be after start date");
|
|
|
73 |
return;
|
|
|
74 |
}
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
let endPoint = `${context}/downloadDateWiseLead?leadStatus=${status}&color=${color}&startDate=${startDate}&endDate=${endDate}`;
|
| 35548 |
aman |
78 |
window.location.href = endPoint;
|
| 31249 |
tejbeer |
79 |
|
| 35548 |
aman |
80 |
});
|
| 34650 |
aman.kumar |
81 |
|
|
|
82 |
|
| 35548 |
aman |
83 |
$(document).on('click', ".visit-request-plan", function () {
|
| 34650 |
aman.kumar |
84 |
|
| 35548 |
aman |
85 |
doGetAjaxRequestHandler(context + "/visitPlan", function (response) {
|
|
|
86 |
$('#' + 'main-content').html(response);
|
|
|
87 |
});
|
| 34650 |
aman.kumar |
88 |
|
| 35548 |
aman |
89 |
});
|
| 34650 |
aman.kumar |
90 |
|
| 35548 |
aman |
91 |
$(document).on('click', ".visitPlan", function () {
|
| 25980 |
tejbeer |
92 |
|
| 35548 |
aman |
93 |
let dateWisePlan = $("#dateVisitSearch").val();
|
| 31249 |
tejbeer |
94 |
|
| 35548 |
aman |
95 |
doGetAjaxRequestHandler(context + "/visit/getVisitPlan?date=" + dateWisePlan, function (response) {
|
|
|
96 |
$('#' + 'main-content').html(response);
|
|
|
97 |
});
|
| 31249 |
tejbeer |
98 |
|
| 35548 |
aman |
99 |
});
|
| 31249 |
tejbeer |
100 |
|
| 35548 |
aman |
101 |
$(document).on('click', ".lead-close", function () {
|
|
|
102 |
loadClosedLead("main-content");
|
|
|
103 |
});
|
| 31249 |
tejbeer |
104 |
|
| 35548 |
aman |
105 |
$(document).on('click', "#lead-close-paginated .next",
|
|
|
106 |
function () {
|
| 31249 |
tejbeer |
107 |
|
| 35548 |
aman |
108 |
var searchText = $("#authUser").val();
|
|
|
109 |
// var searchTxt=$("#scheme-search-text").val();
|
|
|
110 |
console.log(searchText);
|
|
|
111 |
if (typeof (searchText) == "undefined" || !searchText) {
|
|
|
112 |
searchText = "";
|
|
|
113 |
}
|
| 31249 |
tejbeer |
114 |
|
| 35548 |
aman |
115 |
if ((searchText)) {
|
|
|
116 |
var params = {};
|
|
|
117 |
params['searchTerm'] = searchText;
|
|
|
118 |
loadPaginatedNextItems('/searchLeadPaginated', params,
|
|
|
119 |
'lead-close-paginated', 'close-lead-table',
|
|
|
120 |
'lead-close-container');
|
|
|
121 |
} else {
|
| 31249 |
tejbeer |
122 |
|
| 35548 |
aman |
123 |
loadPaginatedNextItems('/getPaginatedClosedLeads', null,
|
|
|
124 |
'lead-close-paginated', 'close-lead-table',
|
|
|
125 |
'lead-close-container');
|
|
|
126 |
}
|
|
|
127 |
$(this).blur();
|
|
|
128 |
});
|
| 31249 |
tejbeer |
129 |
|
| 35548 |
aman |
130 |
$(document).on('click', "#lead-close-paginated .previous",
|
|
|
131 |
function () {
|
|
|
132 |
var searchText = $("#authUser").val();
|
|
|
133 |
// var searchTxt=$("#scheme-search-text").val();
|
|
|
134 |
console.log(searchText);
|
|
|
135 |
if (typeof (searchText) == "undefined" || !searchText) {
|
|
|
136 |
searchText = "";
|
|
|
137 |
}
|
| 25988 |
tejbeer |
138 |
|
| 35548 |
aman |
139 |
if ((searchText)) {
|
|
|
140 |
var params = {};
|
|
|
141 |
params['searchTerm'] = searchText;
|
|
|
142 |
loadPaginatedPreviousItems('/searchLeadPaginated', params,
|
|
|
143 |
'lead-close-paginated', 'close-lead-table',
|
|
|
144 |
'lead-close-container');
|
|
|
145 |
} else {
|
|
|
146 |
loadPaginatedPreviousItems('/getPaginatedClosedLeads',
|
|
|
147 |
null, 'lead-close-paginated', 'close-lead-table',
|
|
|
148 |
'lead-close-container');
|
|
|
149 |
}
|
|
|
150 |
$(this).blur();
|
|
|
151 |
});
|
| 25988 |
tejbeer |
152 |
|
| 35548 |
aman |
153 |
$(document).on('click', "#close-lead-search-button", function () {
|
|
|
154 |
var searchText = $("#authUser").val();
|
|
|
155 |
if (typeof (searchText) == "undefined" || !searchText) {
|
|
|
156 |
searchText = "";
|
|
|
157 |
}
|
|
|
158 |
loadLeadSearchInfo(searchText);
|
|
|
159 |
});
|
| 25988 |
tejbeer |
160 |
|
| 35548 |
aman |
161 |
$(document).on("keyup", "#authUser", function (e) {
|
|
|
162 |
var keyCode = e.keyCode || e.which;
|
|
|
163 |
if (keyCode == 13) {
|
|
|
164 |
$("#close-lead-search-button").click();
|
|
|
165 |
}
|
|
|
166 |
});
|
|
|
167 |
$(document).on('click', ".view",
|
|
|
168 |
function () {
|
|
|
169 |
var id = $(this).data('requestid');
|
|
|
170 |
console.log(id);
|
|
|
171 |
doGetAjaxRequestHandler(context + "/getLeadActivity?leadId="
|
|
|
172 |
+ id, function (response) {
|
| 25988 |
tejbeer |
173 |
|
| 35548 |
aman |
174 |
console.log(response)
|
| 25988 |
tejbeer |
175 |
|
| 35548 |
aman |
176 |
$('#fetchLeadActivityData .modal-content').html(response);
|
| 25988 |
tejbeer |
177 |
|
| 35548 |
aman |
178 |
});
|
|
|
179 |
});
|
| 25988 |
tejbeer |
180 |
|
| 35548 |
aman |
181 |
$(document).on('click', ".newLead", function () {
|
|
|
182 |
$('#newEntryLeadModal').modal('show');
|
|
|
183 |
$("#scheduleTime").hide();
|
|
|
184 |
});
|
| 25988 |
tejbeer |
185 |
|
| 35548 |
aman |
186 |
$(document).on('click', ".show-lead", function () {
|
|
|
187 |
var status = $("#statusFilter").val();
|
|
|
188 |
doGetAjaxRequestHandler(context + "/getOpenLead?leadStatus=" + status, function (response) {
|
|
|
189 |
$('#' + 'main-content').html(response);
|
|
|
190 |
});
|
|
|
191 |
});
|
| 25980 |
tejbeer |
192 |
|
| 31370 |
tejbeer |
193 |
|
| 35548 |
aman |
194 |
$(document).on('click', ".show-colowise-lead", function () {
|
|
|
195 |
var status = $("#statusFilter").val();
|
|
|
196 |
var color = $("#colorFilter").val();
|
|
|
197 |
doGetAjaxRequestHandler(context + "/getOpenLead?leadStatus=" + status + "&color=" + color, function (response) {
|
|
|
198 |
$('#' + 'main-content').html(response);
|
|
|
199 |
});
|
|
|
200 |
});
|
| 25980 |
tejbeer |
201 |
|
| 35548 |
aman |
202 |
$(document).on('click', "#uploadIvoryLead", function () {
|
| 25980 |
tejbeer |
203 |
|
| 35548 |
aman |
204 |
window.location.href = context + "/downloadIvoryLead";
|
|
|
205 |
});
|
| 25980 |
tejbeer |
206 |
|
| 35548 |
aman |
207 |
$(document).on('click', ".submitLeadGenerate", function () {
|
| 27609 |
tejbeer |
208 |
|
| 35548 |
aman |
209 |
console.log("hello");
|
|
|
210 |
if (confirm('Confirm upload ?')) {
|
|
|
211 |
var fileSelector = $(this)[0];
|
|
|
212 |
if (fileSelector != undefined) {
|
|
|
213 |
var url = `${context}/csvFileAndSetLead`;
|
|
|
214 |
console.log(url);
|
|
|
215 |
var file = $(".fileLeadGenerate")[0].files[0];
|
|
|
216 |
let fileInput = $(this);
|
|
|
217 |
console.log("file" + file);
|
|
|
218 |
console.log("fileInput" + fileInput);
|
|
|
219 |
doAjaxUploadRequestHandler(
|
|
|
220 |
url,
|
|
|
221 |
'POST',
|
|
|
222 |
file, function (response) {
|
| 27642 |
tejbeer |
223 |
|
| 35548 |
aman |
224 |
console.log("reponse" + response);
|
| 31370 |
tejbeer |
225 |
|
| 35548 |
aman |
226 |
if (response == true) {
|
|
|
227 |
alert("successfully uploaded");
|
| 31370 |
tejbeer |
228 |
|
|
|
229 |
|
| 35548 |
aman |
230 |
}
|
|
|
231 |
});
|
| 29598 |
tejbeer |
232 |
|
| 35548 |
aman |
233 |
}
|
|
|
234 |
} else {
|
|
|
235 |
// Do nothing!
|
|
|
236 |
}
|
|
|
237 |
});
|
| 27642 |
tejbeer |
238 |
|
|
|
239 |
|
| 35548 |
aman |
240 |
$(document).on('click', ".lead-request",
|
|
|
241 |
function () {
|
| 29598 |
tejbeer |
242 |
|
| 35548 |
aman |
243 |
var firstName = $('input[name="firstName"]').val();
|
|
|
244 |
var lastName = $('input[name="lastName"]').val();
|
|
|
245 |
var mobile = $('input[name="mobile"]').val();
|
|
|
246 |
var address = $('input[name="address"]').val();
|
|
|
247 |
var status = $("#status").val();
|
|
|
248 |
var city = $('input[name="city"]').val();
|
|
|
249 |
var state = $("#state").val();
|
|
|
250 |
var remark = $("#createRemark").val();
|
|
|
251 |
var assignTo = $("#createAssignTo").val();
|
|
|
252 |
var source = $("#leadSource").val();
|
|
|
253 |
var communicationType = $("#communicationTye").val();
|
| 29427 |
manish |
254 |
|
| 35548 |
aman |
255 |
var conversionprobability = $("#conversionprobabilit").val();
|
| 29598 |
tejbeer |
256 |
|
|
|
257 |
|
| 35548 |
aman |
258 |
var outletName = $('input[name="leadoutletName"]').val();
|
|
|
259 |
var counterSize = $('input[name="leadcounterSize"]').val();
|
|
|
260 |
var table = document.getElementById('brandtable');
|
|
|
261 |
var brandValueJson = [];
|
|
|
262 |
var leadBrands;
|
| 29598 |
tejbeer |
263 |
|
| 35548 |
aman |
264 |
console.log(conversionprobability)
|
| 29598 |
tejbeer |
265 |
|
|
|
266 |
|
| 35548 |
aman |
267 |
if (firstName === "" && lastName === "" && mobile === ""
|
|
|
268 |
&& address === "" && status === "" && city === ""
|
|
|
269 |
&& state === "" && remark === "" && source === "") {
|
|
|
270 |
alert("Field can't be empty");
|
|
|
271 |
return;
|
|
|
272 |
}
|
| 29598 |
tejbeer |
273 |
|
| 25980 |
tejbeer |
274 |
|
| 35548 |
aman |
275 |
if (firstName === "") {
|
|
|
276 |
alert("First Name is required");
|
|
|
277 |
return;
|
|
|
278 |
}
|
|
|
279 |
if (lastName === "") {
|
|
|
280 |
alert("Last Name is required");
|
|
|
281 |
return;
|
|
|
282 |
}
|
|
|
283 |
if (mobile === "") {
|
|
|
284 |
alert("Mobile is required");
|
|
|
285 |
return;
|
|
|
286 |
}
|
|
|
287 |
if (status === "") {
|
|
|
288 |
alert("Status is required");
|
|
|
289 |
return;
|
|
|
290 |
}
|
|
|
291 |
if (address === "") {
|
|
|
292 |
alert("address is required");
|
|
|
293 |
return;
|
|
|
294 |
}
|
|
|
295 |
if (city === "") {
|
|
|
296 |
alert("city is required");
|
|
|
297 |
return;
|
|
|
298 |
}
|
| 32471 |
tejbeer |
299 |
|
| 35548 |
aman |
300 |
if (state === "") {
|
|
|
301 |
alert("state is required");
|
|
|
302 |
return;
|
|
|
303 |
}
|
|
|
304 |
if (source === "") {
|
|
|
305 |
alert("Source is required")
|
|
|
306 |
return;
|
|
|
307 |
}
|
| 32471 |
tejbeer |
308 |
|
| 35548 |
aman |
309 |
if (remark === "") {
|
|
|
310 |
alert("Remark is required");
|
|
|
311 |
return;
|
|
|
312 |
}
|
| 32471 |
tejbeer |
313 |
|
| 35548 |
aman |
314 |
if (conversionprobability === "") {
|
|
|
315 |
alert("Conversion Probability is required");
|
|
|
316 |
return;
|
|
|
317 |
}
|
|
|
318 |
if (status == "followUp" || status == "pending" || status == "finalized") {
|
|
|
319 |
if (outletName === "") {
|
|
|
320 |
alert("Outlet Name is required");
|
|
|
321 |
return;
|
|
|
322 |
}
|
| 25980 |
tejbeer |
323 |
|
| 35548 |
aman |
324 |
if (counterSize === "") {
|
|
|
325 |
alert("Counter Size is required");
|
|
|
326 |
return;
|
|
|
327 |
}
|
| 32464 |
tejbeer |
328 |
|
| 35548 |
aman |
329 |
if (localStorage.getItem("frontph") == "undefined" && localStorage.getItem("frontph") == null) {
|
|
|
330 |
alert("Front Document is required");
|
|
|
331 |
return;
|
|
|
332 |
}
|
| 32464 |
tejbeer |
333 |
|
| 35548 |
aman |
334 |
if (localStorage.getItem("internalMarketh") == "undefined" || localStorage.getItem("internalMarketh") == null) {
|
|
|
335 |
alert("Front With Market Document is required");
|
|
|
336 |
return;
|
|
|
337 |
}
|
| 25980 |
tejbeer |
338 |
|
| 35548 |
aman |
339 |
if (localStorage.getItem("leftShoth") == "undefined" || localStorage.getItem("leftShoth") == null) {
|
|
|
340 |
alert("Internal Left Shot Document is required");
|
|
|
341 |
return;
|
|
|
342 |
}
|
| 32464 |
tejbeer |
343 |
|
| 35548 |
aman |
344 |
if (localStorage.getItem("leftWallh") == "undefined" || localStorage.getItem("leftWallh") == null) {
|
|
|
345 |
alert("Internal Left Wall Document is required");
|
|
|
346 |
return;
|
|
|
347 |
}
|
| 25980 |
tejbeer |
348 |
|
|
|
349 |
|
| 35548 |
aman |
350 |
if (localStorage.getItem("rightWallh") == "undefined" || localStorage.getItem("rightWallh") == null) {
|
|
|
351 |
alert("Internal Right Wall Document is required");
|
|
|
352 |
return;
|
|
|
353 |
}
|
| 25980 |
tejbeer |
354 |
|
| 32464 |
tejbeer |
355 |
|
| 35548 |
aman |
356 |
for (i = 1; i < table.rows.length; i++) {
|
| 32464 |
tejbeer |
357 |
|
| 35548 |
aman |
358 |
var objCells = table.rows[i].cells;
|
| 32464 |
tejbeer |
359 |
|
| 35548 |
aman |
360 |
leadBrands = {
|
|
|
361 |
brand: objCells[0].innerText,
|
|
|
362 |
value: objCells[1].getElementsByTagName('input')[0].value
|
|
|
363 |
}
|
|
|
364 |
brandValueJson.push(leadBrands);
|
|
|
365 |
}
|
| 32464 |
tejbeer |
366 |
|
|
|
367 |
|
| 35548 |
aman |
368 |
}
|
| 32464 |
tejbeer |
369 |
|
|
|
370 |
|
| 35548 |
aman |
371 |
var leaddetailData = {}
|
|
|
372 |
leaddetailData['firstName'] = firstName;
|
|
|
373 |
leaddetailData['lastName'] = lastName
|
|
|
374 |
leaddetailData['mobile'] = mobile
|
|
|
375 |
leaddetailData['address'] = address
|
|
|
376 |
leaddetailData['city'] = city
|
|
|
377 |
leaddetailData['state'] = state
|
|
|
378 |
leaddetailData['status'] = status
|
|
|
379 |
leaddetailData['remark'] = remark
|
|
|
380 |
leaddetailData['assignTo'] = assignTo
|
|
|
381 |
leaddetailData['source'] = source
|
|
|
382 |
leaddetailData['colorCheck'] = conversionprobability
|
| 32464 |
tejbeer |
383 |
|
|
|
384 |
|
| 35548 |
aman |
385 |
if (status == "followUp") {
|
|
|
386 |
leaddetailData['schelduleTimestamp'] = getDatesFromPicker('#scheduleTime').startDate;
|
| 32464 |
tejbeer |
387 |
|
| 35548 |
aman |
388 |
leaddetailData['communicationType'] = communicationType
|
|
|
389 |
}
|
| 32464 |
tejbeer |
390 |
|
|
|
391 |
|
| 35548 |
aman |
392 |
leaddetailData['outletName'] = outletName;
|
| 32464 |
tejbeer |
393 |
|
| 35548 |
aman |
394 |
leaddetailData['counterSize'] = counterSize;
|
| 32464 |
tejbeer |
395 |
|
|
|
396 |
|
| 35548 |
aman |
397 |
leaddetailData['leadBrands'] = brandValueJson;
|
| 32464 |
tejbeer |
398 |
|
| 35548 |
aman |
399 |
console.log(localStorage.getItem("frontp"));
|
| 32464 |
tejbeer |
400 |
|
|
|
401 |
|
| 35548 |
aman |
402 |
leaddetailData['frontp'] = localStorage
|
|
|
403 |
.getItem("frontph");
|
| 31249 |
tejbeer |
404 |
|
| 32464 |
tejbeer |
405 |
|
| 35548 |
aman |
406 |
leaddetailData['frontWithMarket'] = localStorage
|
|
|
407 |
.getItem("internalMarketh");
|
| 32464 |
tejbeer |
408 |
|
|
|
409 |
|
| 35548 |
aman |
410 |
leaddetailData['internalLongShot'] = localStorage
|
|
|
411 |
.getItem("leftShoth");
|
| 32464 |
tejbeer |
412 |
|
|
|
413 |
|
| 35548 |
aman |
414 |
leaddetailData['internalLeftWall'] = localStorage
|
|
|
415 |
.getItem("leftWallh");
|
| 32464 |
tejbeer |
416 |
|
|
|
417 |
|
| 35548 |
aman |
418 |
leaddetailData['internalRightWall'] = localStorage
|
|
|
419 |
.getItem("rightWallh");
|
| 32464 |
tejbeer |
420 |
|
| 35548 |
aman |
421 |
console.log(leaddetailData);
|
| 32464 |
tejbeer |
422 |
|
| 35548 |
aman |
423 |
if (confirm("Are you sure you want to add lead!") == true) {
|
|
|
424 |
doPostAjaxRequestWithJsonHandler(context + "/createLead",
|
|
|
425 |
JSON.stringify(leaddetailData), function (response) {
|
|
|
426 |
if (response == 'true') {
|
|
|
427 |
alert("successfully Add");
|
|
|
428 |
$('#newEntryLeadModal').modal('hide');
|
|
|
429 |
$('.modal-backdrop').remove();
|
|
|
430 |
loadLead("main-content");
|
|
|
431 |
} else {
|
|
|
432 |
alert(response);
|
|
|
433 |
}
|
|
|
434 |
});
|
| 32464 |
tejbeer |
435 |
|
| 35548 |
aman |
436 |
return false;
|
|
|
437 |
}
|
|
|
438 |
});
|
| 36642 |
ranu |
439 |
window.leadId = null;
|
| 35548 |
aman |
440 |
var row = null;
|
|
|
441 |
$(document).on('click', ".editLead", function () {
|
|
|
442 |
$('#editLeadData').modal('show');
|
| 32464 |
tejbeer |
443 |
|
| 35548 |
aman |
444 |
$("#remark").val("");
|
|
|
445 |
$("#assignTo").val("");
|
|
|
446 |
$("#editStatus").val("");
|
|
|
447 |
$("#reason").val("");
|
|
|
448 |
$("#editCity").val("");
|
|
|
449 |
$("#editState").val("");
|
| 35769 |
amit |
450 |
$("#editSource").val("");
|
| 35548 |
aman |
451 |
$("#editScheduleTime").hide();
|
| 32464 |
tejbeer |
452 |
|
|
|
453 |
|
| 35548 |
aman |
454 |
localStorage.removeItem("frontph");
|
|
|
455 |
localStorage.removeItem("leftShoth");
|
|
|
456 |
localStorage.removeItem("rightWallh");
|
|
|
457 |
localStorage.removeItem("leftWallh");
|
|
|
458 |
localStorage.removeItem("internalMarketh");
|
| 32464 |
tejbeer |
459 |
|
| 35548 |
aman |
460 |
row = $(this).closest("tr");
|
|
|
461 |
leadId = $(this).data('leadid');
|
| 32464 |
tejbeer |
462 |
|
| 35548 |
aman |
463 |
doAjaxRequestHandler(
|
|
|
464 |
context + "/getLeadDetailByLeadId?leadId=" + leadId,
|
|
|
465 |
"GET",
|
|
|
466 |
function (response) {
|
| 32464 |
tejbeer |
467 |
|
| 35548 |
aman |
468 |
var data = response.response;
|
|
|
469 |
if (!data) return;
|
|
|
470 |
console.log(data);
|
|
|
471 |
$("#editCity").val(data.city);
|
|
|
472 |
$("#editState").val(data.state);
|
|
|
473 |
$("input[name='outletName']").val(data.outletName);
|
|
|
474 |
$("input[name='counterSize']").val(data.counterSize);
|
|
|
475 |
}
|
|
|
476 |
);
|
|
|
477 |
});
|
| 32464 |
tejbeer |
478 |
|
|
|
479 |
|
| 35548 |
aman |
480 |
$(document).on('click', ".lead-edit-request",
|
|
|
481 |
function () {
|
| 32464 |
tejbeer |
482 |
|
| 36761 |
ranu |
483 |
// Gate the assign/status submit on approved geo. Modal stays open so the
|
|
|
484 |
// user can still work the other sub-forms (lead detail, etc.).
|
|
|
485 |
var clickedBtn = $(this);
|
|
|
486 |
if (clickedBtn.data('geoChecking')) return;
|
|
|
487 |
clickedBtn.data('geoChecking', true);
|
|
|
488 |
doAjaxRequestHandler(
|
|
|
489 |
context + "/lead-geo/check/" + leadId,
|
|
|
490 |
"GET",
|
|
|
491 |
function (response) {
|
|
|
492 |
clickedBtn.removeData('geoChecking');
|
|
|
493 |
var hasGeo = response && response.response && response.response.hasApprovedGeo;
|
|
|
494 |
if (!hasGeo) {
|
|
|
495 |
alert('Live geo-location for this lead has not been approved yet. Please approve the geo-location before assigning / updating status.');
|
|
|
496 |
return;
|
|
|
497 |
}
|
|
|
498 |
submitLeadEdit();
|
|
|
499 |
}
|
|
|
500 |
);
|
|
|
501 |
});
|
| 25980 |
tejbeer |
502 |
|
| 36761 |
ranu |
503 |
function submitLeadEdit() {
|
|
|
504 |
|
| 35548 |
aman |
505 |
console.log(row);
|
|
|
506 |
var remark = $('input[name="remark"]').val();
|
|
|
507 |
var assignTo = $("#assignTo").val();
|
|
|
508 |
var editStatus = $("#editStatus").val();
|
|
|
509 |
var city = $('input[name="editCity"]').val();
|
|
|
510 |
var state = $("#editState").val();
|
|
|
511 |
var reason = $("#reason").val();
|
| 25980 |
tejbeer |
512 |
|
| 35769 |
amit |
513 |
var startDate = $("#startDate").val();
|
|
|
514 |
var endDate = $("#endDate").val();
|
| 35548 |
aman |
515 |
var leadStatus = $("#statusFilter").val();
|
|
|
516 |
var color = $("#colorFilter").val();
|
|
|
517 |
var communicationType = $("#communicationType").val();
|
| 29640 |
tejbeer |
518 |
|
| 35548 |
aman |
519 |
var conversionprobability = $("#conversionprobability").val();
|
| 35769 |
amit |
520 |
var editSource = $("#editSource").val();
|
| 29640 |
tejbeer |
521 |
|
| 35548 |
aman |
522 |
console.log(conversionprobability)
|
| 29640 |
tejbeer |
523 |
|
| 31473 |
tejbeer |
524 |
|
| 35769 |
amit |
525 |
console.log(startDate)
|
| 35548 |
aman |
526 |
console.log(leadStatus)
|
| 31370 |
tejbeer |
527 |
|
| 35548 |
aman |
528 |
console.log(color)
|
|
|
529 |
console.log(reason)
|
| 31370 |
tejbeer |
530 |
|
| 35548 |
aman |
531 |
if (remark === "" && assignTo === "" && editStatus === "") {
|
|
|
532 |
alert("All fields is required");
|
|
|
533 |
return;
|
|
|
534 |
}
|
| 31370 |
tejbeer |
535 |
|
| 35548 |
aman |
536 |
if (assignTo === "") {
|
|
|
537 |
alert("assignTo is required");
|
|
|
538 |
return;
|
|
|
539 |
}
|
| 31409 |
tejbeer |
540 |
|
| 35548 |
aman |
541 |
if (remark === "") {
|
|
|
542 |
alert("Remark is required");
|
|
|
543 |
return;
|
|
|
544 |
}
|
| 31370 |
tejbeer |
545 |
|
|
|
546 |
|
| 35548 |
aman |
547 |
if (editStatus === "") {
|
|
|
548 |
alert("status is required");
|
|
|
549 |
return;
|
|
|
550 |
}
|
| 31370 |
tejbeer |
551 |
|
| 35548 |
aman |
552 |
if (editStatus === "notInterested") {
|
|
|
553 |
if (reason == null) {
|
|
|
554 |
alert("Reason is required");
|
|
|
555 |
return;
|
|
|
556 |
}
|
|
|
557 |
}
|
|
|
558 |
var leadActivityData = {}
|
|
|
559 |
leadActivityData['id'] = leadId;
|
|
|
560 |
leadActivityData['remark'] = remark;
|
|
|
561 |
leadActivityData['assignTo'] = assignTo
|
|
|
562 |
leadActivityData['status'] = editStatus
|
|
|
563 |
leadActivityData['reason'] = reason
|
| 36741 |
ranu |
564 |
leadActivityData['colorCheck'] = (conversionprobability === "true" || conversionprobability === true)
|
| 35548 |
aman |
565 |
if (city && city.trim() !== "") {
|
|
|
566 |
leadActivityData.city = city;
|
|
|
567 |
}
|
| 25980 |
tejbeer |
568 |
|
| 35548 |
aman |
569 |
if (state && state.trim() !== "") {
|
|
|
570 |
leadActivityData.state = state;
|
|
|
571 |
}
|
| 29473 |
manish |
572 |
|
| 35769 |
amit |
573 |
if (editSource && editSource.trim() !== "") {
|
|
|
574 |
leadActivityData.source = editSource;
|
|
|
575 |
}
|
| 29598 |
tejbeer |
576 |
|
| 35769 |
amit |
577 |
|
| 35548 |
aman |
578 |
if (editStatus == "followUp") {
|
| 36642 |
ranu |
579 |
leadActivityData['communicationType'] = communicationType
|
| 36741 |
ranu |
580 |
var beatVal = $('#beatDate').val();
|
| 36761 |
ranu |
581 |
// Gate: for followUp, the lead must land on an upcoming beat of the
|
|
|
582 |
// assignee. If no beat is picked (or the assignee has no upcoming
|
|
|
583 |
// beat slots at all), block the submit with a clear message.
|
|
|
584 |
if (!beatVal) {
|
|
|
585 |
var hasBadges = $('#beatBadges .beat-badge').length > 0;
|
|
|
586 |
if (!hasBadges) {
|
|
|
587 |
alert('No upcoming beat is available for this assignee. Cannot schedule the lead until they have a beat.');
|
|
|
588 |
} else {
|
|
|
589 |
alert('Please select a beat date for the assignee before submitting.');
|
|
|
590 |
}
|
|
|
591 |
return;
|
| 36642 |
ranu |
592 |
}
|
| 36761 |
ranu |
593 |
var beatDate = beatVal.split('|')[0];
|
|
|
594 |
leadActivityData['scheldule'] = beatDate + 'T12:00:00';
|
|
|
595 |
leadActivityData['beatSelection'] = beatVal;
|
| 35548 |
aman |
596 |
}
|
| 29598 |
tejbeer |
597 |
|
| 35548 |
aman |
598 |
console.log(leadActivityData);
|
|
|
599 |
if (confirm("Are you sure you want to add lead!") == true) {
|
|
|
600 |
doPostAjaxRequestWithJsonHandler(context + "/editLead", JSON.stringify(leadActivityData), function (response) {
|
|
|
601 |
console.log(response);
|
|
|
602 |
$('#editLeadData').modal('hide');
|
|
|
603 |
$('.modal-backdrop').remove();
|
|
|
604 |
row.html(response);
|
|
|
605 |
});
|
|
|
606 |
}
|
| 29598 |
tejbeer |
607 |
|
| 36761 |
ranu |
608 |
}
|
| 32477 |
tejbeer |
609 |
|
|
|
610 |
|
| 35548 |
aman |
611 |
$(document).on('click', ".show-partner-health",
|
|
|
612 |
function () {
|
| 29598 |
tejbeer |
613 |
|
| 35548 |
aman |
614 |
var email = $("#authUserFilter").val();
|
| 25980 |
tejbeer |
615 |
|
| 35548 |
aman |
616 |
console.log(email)
|
|
|
617 |
doGetAjaxRequestHandler(context + "/partnerHealth?email="
|
|
|
618 |
+ email, function (response) {
|
|
|
619 |
console.log(response)
|
|
|
620 |
$('#' + 'main-content').html(response);
|
| 25980 |
tejbeer |
621 |
|
| 35548 |
aman |
622 |
});
|
|
|
623 |
});
|
| 25980 |
tejbeer |
624 |
|
|
|
625 |
|
| 35548 |
aman |
626 |
$(document).on('click', ".lead-detail-entry",
|
|
|
627 |
function () {
|
| 28200 |
tejbeer |
628 |
|
| 35548 |
aman |
629 |
console.log("hello");
|
|
|
630 |
var outletName = $('input[name="outletName"]').val();
|
|
|
631 |
var counterSize = $('input[name="counterSize"]').val();
|
|
|
632 |
var table = document.getElementById('editbrandtable');
|
|
|
633 |
var brandValueJson = [];
|
|
|
634 |
var leadBrands;
|
| 25980 |
tejbeer |
635 |
|
| 35548 |
aman |
636 |
if (outletName === "") {
|
|
|
637 |
alert("Outlet Name is required");
|
|
|
638 |
return;
|
|
|
639 |
}
|
| 29598 |
tejbeer |
640 |
|
| 35548 |
aman |
641 |
if (counterSize === "") {
|
|
|
642 |
alert("Counter Size is required");
|
|
|
643 |
return;
|
|
|
644 |
}
|
| 32471 |
tejbeer |
645 |
|
| 35548 |
aman |
646 |
if (localStorage.getItem("frontph") == "undefined" && localStorage.getItem("frontph") == null) {
|
|
|
647 |
alert("Front Document is required");
|
|
|
648 |
return;
|
|
|
649 |
}
|
| 31249 |
tejbeer |
650 |
|
| 35548 |
aman |
651 |
if (localStorage.getItem("internalMarketh") == "undefined" || localStorage.getItem("internalMarketh") == null) {
|
|
|
652 |
alert("Front With Market Document is required");
|
|
|
653 |
return;
|
|
|
654 |
}
|
| 25980 |
tejbeer |
655 |
|
| 35548 |
aman |
656 |
if (localStorage.getItem("leftShoth") == "undefined" || localStorage.getItem("leftShoth") == null) {
|
|
|
657 |
alert("Internal Left Shot Document is required");
|
|
|
658 |
return;
|
|
|
659 |
}
|
| 27605 |
tejbeer |
660 |
|
| 35548 |
aman |
661 |
if (localStorage.getItem("leftWallh") == "undefined" || localStorage.getItem("leftWallh") == null) {
|
|
|
662 |
alert("Internal Left Wall Document is required");
|
|
|
663 |
return;
|
|
|
664 |
}
|
| 27605 |
tejbeer |
665 |
|
| 30185 |
tejbeer |
666 |
|
| 35548 |
aman |
667 |
if (localStorage.getItem("rightWallh") == "undefined" || localStorage.getItem("rightWallh") == null) {
|
|
|
668 |
alert("Internal Right Wall Document is required");
|
|
|
669 |
return;
|
|
|
670 |
}
|
| 30185 |
tejbeer |
671 |
|
|
|
672 |
|
| 35548 |
aman |
673 |
for (i = 1; i < table.rows.length; i++) {
|
| 30185 |
tejbeer |
674 |
|
| 35548 |
aman |
675 |
var objCells = table.rows[i].cells;
|
| 30185 |
tejbeer |
676 |
|
| 35548 |
aman |
677 |
leadBrands = {
|
|
|
678 |
brand: objCells[0].innerText,
|
|
|
679 |
value: objCells[1].getElementsByTagName('input')[0].value
|
|
|
680 |
}
|
|
|
681 |
brandValueJson.push(leadBrands);
|
|
|
682 |
}
|
| 30185 |
tejbeer |
683 |
|
| 30416 |
tejbeer |
684 |
|
| 35548 |
aman |
685 |
var leadDetailObject = {};
|
| 31402 |
tejbeer |
686 |
|
| 35548 |
aman |
687 |
leadDetailObject['leadId'] = leadId;
|
| 30416 |
tejbeer |
688 |
|
|
|
689 |
|
| 35548 |
aman |
690 |
leadDetailObject['outletName'] = outletName;
|
| 31370 |
tejbeer |
691 |
|
| 35548 |
aman |
692 |
leadDetailObject['counterSize'] = counterSize;
|
| 31370 |
tejbeer |
693 |
|
| 35548 |
aman |
694 |
leadDetailObject['leadBrands'] = brandValueJson;
|
| 31370 |
tejbeer |
695 |
|
| 31402 |
tejbeer |
696 |
|
| 35548 |
aman |
697 |
console.log(localStorage.getItem("frontp"));
|
| 31402 |
tejbeer |
698 |
|
|
|
699 |
|
| 35548 |
aman |
700 |
leadDetailObject['frontp'] = localStorage
|
|
|
701 |
.getItem("frontph");
|
| 31402 |
tejbeer |
702 |
|
|
|
703 |
|
| 35548 |
aman |
704 |
leadDetailObject['frontWithMarket'] = localStorage
|
|
|
705 |
.getItem("internalMarketh");
|
| 31370 |
tejbeer |
706 |
|
|
|
707 |
|
| 35548 |
aman |
708 |
leadDetailObject['internalLongShot'] = localStorage
|
|
|
709 |
.getItem("leftShoth");
|
| 31370 |
tejbeer |
710 |
|
|
|
711 |
|
| 35548 |
aman |
712 |
leadDetailObject['internalLeftWall'] = localStorage
|
|
|
713 |
.getItem("leftWallh");
|
| 31370 |
tejbeer |
714 |
|
|
|
715 |
|
| 35548 |
aman |
716 |
leadDetailObject['internalRightWall'] = localStorage
|
|
|
717 |
.getItem("rightWallh");
|
| 31370 |
tejbeer |
718 |
|
| 35548 |
aman |
719 |
console.log(leadDetailObject);
|
| 31370 |
tejbeer |
720 |
|
| 35548 |
aman |
721 |
if (confirm("Are you sure you want to add lead detail!") == true) {
|
|
|
722 |
doPostAjaxRequestWithJsonHandler(context + "/leadDetail", JSON.stringify(leadDetailObject), function (response) {
|
|
|
723 |
console.log(response);
|
|
|
724 |
if (response == 'true') {
|
|
|
725 |
alert("Submit Successfully");
|
|
|
726 |
}
|
| 31370 |
tejbeer |
727 |
|
| 35548 |
aman |
728 |
});
|
|
|
729 |
}
|
| 31370 |
tejbeer |
730 |
|
| 35548 |
aman |
731 |
});
|
| 31370 |
tejbeer |
732 |
|
|
|
733 |
|
| 35548 |
aman |
734 |
$(document).on('change', '.frontp',
|
|
|
735 |
function () {
|
| 31370 |
tejbeer |
736 |
|
| 35548 |
aman |
737 |
if (confirm('Document has been selected, Do you want to upload ?')) {
|
| 31370 |
tejbeer |
738 |
|
| 35548 |
aman |
739 |
var documentId = uploadImage(this, "frontph");
|
| 31370 |
tejbeer |
740 |
|
|
|
741 |
|
| 35548 |
aman |
742 |
} else {
|
| 31370 |
tejbeer |
743 |
|
| 35548 |
aman |
744 |
}
|
|
|
745 |
});
|
| 31456 |
tejbeer |
746 |
|
| 35548 |
aman |
747 |
$(document).on('change', '.internalMarket',
|
|
|
748 |
function () {
|
| 31456 |
tejbeer |
749 |
|
| 35548 |
aman |
750 |
if (confirm('Document has been selected, Do you want to upload ?')) {
|
| 31456 |
tejbeer |
751 |
|
| 35548 |
aman |
752 |
var documentId = uploadImage(this, "internalMarketh");
|
| 31456 |
tejbeer |
753 |
|
| 35548 |
aman |
754 |
} else {
|
| 31456 |
tejbeer |
755 |
|
| 35548 |
aman |
756 |
}
|
|
|
757 |
});
|
| 31370 |
tejbeer |
758 |
|
| 35548 |
aman |
759 |
$(document).on('change', '.leftShot',
|
| 31370 |
tejbeer |
760 |
|
| 35548 |
aman |
761 |
function () {
|
|
|
762 |
if (confirm('Document has been selected, Do you want to upload ?')) {
|
|
|
763 |
var documentId = uploadImage(this, "leftShoth");
|
|
|
764 |
} else {
|
| 31370 |
tejbeer |
765 |
|
| 35548 |
aman |
766 |
}
|
|
|
767 |
});
|
| 31370 |
tejbeer |
768 |
|
| 35548 |
aman |
769 |
$(document).on('change', '.leftWall',
|
|
|
770 |
function () {
|
|
|
771 |
if (confirm('Document has been selected, Do you want to upload ?')) {
|
|
|
772 |
var documentId = uploadImage(this, "leftWallh");
|
|
|
773 |
} else {
|
| 31370 |
tejbeer |
774 |
|
| 35548 |
aman |
775 |
}
|
|
|
776 |
});
|
| 31370 |
tejbeer |
777 |
|
| 35548 |
aman |
778 |
$(document).on('change', '.rightWall',
|
|
|
779 |
function () {
|
|
|
780 |
if (confirm('Document has been selected, Do you want to upload ?')) {
|
|
|
781 |
var documentId = uploadImage(this, "rightWallh");
|
|
|
782 |
} else {
|
|
|
783 |
}
|
|
|
784 |
});
|
| 31370 |
tejbeer |
785 |
|
|
|
786 |
|
| 25980 |
tejbeer |
787 |
});
|
|
|
788 |
|
| 31404 |
tejbeer |
789 |
function uploadImage(fileSelector, attrName) {
|
| 35548 |
aman |
790 |
var documentId;
|
|
|
791 |
if (fileSelector != undefined
|
|
|
792 |
&& fileSelector.files[0] != undefined) {
|
|
|
793 |
var url = context
|
|
|
794 |
+ '/document-upload';
|
| 31370 |
tejbeer |
795 |
|
| 35548 |
aman |
796 |
console.log(url);
|
|
|
797 |
var file = fileSelector.files[0];
|
| 31370 |
tejbeer |
798 |
|
| 35548 |
aman |
799 |
console.log(file)
|
|
|
800 |
doAjaxUploadRequestHandler(
|
|
|
801 |
url,
|
|
|
802 |
'POST',
|
|
|
803 |
file,
|
|
|
804 |
function (response) {
|
|
|
805 |
console.log(response)
|
|
|
806 |
documentId = response.response.document_id;
|
|
|
807 |
console
|
|
|
808 |
.log("documentId : "
|
|
|
809 |
+ documentId);
|
| 31370 |
tejbeer |
810 |
|
|
|
811 |
|
| 35548 |
aman |
812 |
localStorage
|
|
|
813 |
.setItem(
|
|
|
814 |
attrName,
|
|
|
815 |
documentId);
|
| 31402 |
tejbeer |
816 |
|
| 35548 |
aman |
817 |
});
|
|
|
818 |
return documentId;
|
|
|
819 |
}
|
| 31370 |
tejbeer |
820 |
|
|
|
821 |
}
|
|
|
822 |
|
|
|
823 |
|
| 25980 |
tejbeer |
824 |
function loadLead(domId) {
|
| 35548 |
aman |
825 |
doGetAjaxRequestHandler(context + "/getOpenLead", function (response) {
|
|
|
826 |
$('#' + domId).html(response);
|
|
|
827 |
});
|
| 25980 |
tejbeer |
828 |
}
|
|
|
829 |
|
| 25988 |
tejbeer |
830 |
function loadClosedLead(domId, searchTerm) {
|
| 35548 |
aman |
831 |
doGetAjaxRequestHandler(context + "/getClosedLead", function (response) {
|
|
|
832 |
$('#' + domId).html(response);
|
|
|
833 |
})
|
| 25988 |
tejbeer |
834 |
}
|
|
|
835 |
|
| 25980 |
tejbeer |
836 |
function statusAction() {
|
| 35548 |
aman |
837 |
var val = $('#status').val();
|
|
|
838 |
if (val == "followUp") {
|
|
|
839 |
$("#scheduleTime").show();
|
|
|
840 |
} else {
|
|
|
841 |
$("#scheduleTime").hide();
|
|
|
842 |
}
|
| 25980 |
tejbeer |
843 |
|
|
|
844 |
}
|
| 27605 |
tejbeer |
845 |
|
|
|
846 |
|
|
|
847 |
function editStatusAction() {
|
| 35548 |
aman |
848 |
var val = $('#editStatus').val();
|
|
|
849 |
if (val == "followUp") {
|
| 36642 |
ranu |
850 |
// Show communication type and schedule date
|
|
|
851 |
$("#communicationTypeSection").show();
|
| 35548 |
aman |
852 |
$("#editScheduleTime").show();
|
| 36642 |
ranu |
853 |
$("#beatDateSelection").hide();
|
|
|
854 |
|
| 36761 |
ranu |
855 |
// Reset communication type only; preserve the assignee the user picked.
|
| 36642 |
ranu |
856 |
$('#communicationType').val('');
|
|
|
857 |
$('#assignTo option').show();
|
|
|
858 |
|
|
|
859 |
// Check if lead has approved geolocation to decide VISIT option
|
|
|
860 |
doAjaxRequestHandler(context + "/lead-geo/check/" + leadId, "GET", function (response) {
|
|
|
861 |
var hasGeo = response.response.hasApprovedGeo;
|
|
|
862 |
var commDropdown = $('#communicationType');
|
|
|
863 |
commDropdown.empty();
|
|
|
864 |
commDropdown.append('<option value="" disabled selected>Communication Type</option>');
|
|
|
865 |
commDropdown.append('<option value="TELEPHONIC">TELEPHONIC</option>');
|
|
|
866 |
if (hasGeo) {
|
|
|
867 |
commDropdown.append('<option value="VISIT">VISIT</option>');
|
|
|
868 |
}
|
|
|
869 |
});
|
| 35548 |
aman |
870 |
} else {
|
| 36642 |
ranu |
871 |
$("#communicationTypeSection").hide();
|
| 35548 |
aman |
872 |
$("#editScheduleTime").hide();
|
| 36642 |
ranu |
873 |
$("#beatDateSelection").hide();
|
|
|
874 |
$('#assignTo option').show();
|
| 35548 |
aman |
875 |
}
|
| 27605 |
tejbeer |
876 |
|
|
|
877 |
}
|
|
|
878 |
|
| 25988 |
tejbeer |
879 |
function loadLeadSearchInfo(search_text) {
|
| 35548 |
aman |
880 |
loadSearchLead("main-content", search_text);
|
| 25988 |
tejbeer |
881 |
}
|
|
|
882 |
|
| 30185 |
tejbeer |
883 |
function loadTeamCommitment(domId) {
|
| 35548 |
aman |
884 |
doGetAjaxRequestHandler(context + "/teamCommitment",
|
|
|
885 |
function (response) {
|
|
|
886 |
$('#' + domId).html(response);
|
|
|
887 |
});
|
| 30185 |
tejbeer |
888 |
}
|
|
|
889 |
|
| 31370 |
tejbeer |
890 |
function loadLeadDetail(domId) {
|
| 35548 |
aman |
891 |
doGetAjaxRequestHandler(context + "/getLeadDetail",
|
|
|
892 |
function (response) {
|
|
|
893 |
$('#' + domId).html(response);
|
|
|
894 |
});
|
| 31370 |
tejbeer |
895 |
}
|
|
|
896 |
|
| 30416 |
tejbeer |
897 |
function loadPartnerHealth(domId) {
|
| 35548 |
aman |
898 |
doGetAjaxRequestHandler(context + "/partnerHealth",
|
|
|
899 |
function (response) {
|
|
|
900 |
$('#' + domId).html(response);
|
|
|
901 |
});
|
| 30416 |
tejbeer |
902 |
}
|
|
|
903 |
|
| 25988 |
tejbeer |
904 |
function loadSearchLead(domId, search_text) {
|
| 35548 |
aman |
905 |
doGetAjaxRequestHandler(context + "/searchLeads?searchTerm=" + search_text,
|
|
|
906 |
function (response) {
|
|
|
907 |
$('#' + domId).html(response);
|
|
|
908 |
});
|
| 25988 |
tejbeer |
909 |
}
|
| 33917 |
ranu |
910 |
|
|
|
911 |
$(document).on('click', ".arr-button-mk",
|
| 35548 |
aman |
912 |
function () {
|
|
|
913 |
var startDate = $('.arr-start_date').val();
|
|
|
914 |
doGetAjaxRequestHandler(context + "/rbmTodayArr?startDate=" + startDate, function (response) {
|
|
|
915 |
$('#main-content').html(response);
|
| 33917 |
ranu |
916 |
|
| 35548 |
aman |
917 |
});
|
|
|
918 |
});
|
| 33917 |
ranu |
919 |
|
|
|
920 |
$(document).on('click', ".rbm-today-arr",
|
| 35548 |
aman |
921 |
function () {
|
|
|
922 |
doGetAjaxRequestHandler(context + "/rbmTodayArr", function (response) {
|
|
|
923 |
$('#main-content').html(response);
|
| 33917 |
ranu |
924 |
|
| 35548 |
aman |
925 |
});
|
|
|
926 |
});
|
|
|
927 |
$(document).on('click', '.reassign', function () {
|
|
|
928 |
$('#bulkReassignFile').val(null);
|
|
|
929 |
$('#bulkReassignFile').click();
|
|
|
930 |
});
|
|
|
931 |
|
|
|
932 |
$(document).on('change', '#bulkReassignFile', function () {
|
|
|
933 |
|
|
|
934 |
if (!confirm("Confirm bulk reassign upload?")) {
|
|
|
935 |
return;
|
|
|
936 |
}
|
|
|
937 |
|
|
|
938 |
var file = this.files[0];
|
|
|
939 |
if (!file) {
|
|
|
940 |
alert("No file selected");
|
|
|
941 |
return;
|
|
|
942 |
}
|
|
|
943 |
|
|
|
944 |
doAjaxUploadRequestHandler(
|
|
|
945 |
context + "/upload-assign-id",
|
|
|
946 |
'POST',
|
|
|
947 |
file,
|
|
|
948 |
function (response) {
|
|
|
949 |
alert("Bulk reassignment completed");
|
|
|
950 |
loadLead("main-content");
|
|
|
951 |
}
|
|
|
952 |
);
|
|
|
953 |
});
|
|
|
954 |
|
| 36642 |
ranu |
955 |
// ==================== GEO LOCATION HANDLERS ====================
|
|
|
956 |
|
|
|
957 |
// Communication type change: filter assignTo based on type
|
|
|
958 |
$(document).on('change', '#communicationType', function () {
|
|
|
959 |
var val = $(this).val();
|
|
|
960 |
var assignDropdown = $('#assignTo');
|
|
|
961 |
|
| 36741 |
ranu |
962 |
// Reset beat + restore manual date input
|
| 36642 |
ranu |
963 |
$('#beatDate').val('');
|
|
|
964 |
$('#beatBadges').empty();
|
|
|
965 |
$("#beatDateSelection").hide();
|
| 36741 |
ranu |
966 |
$("#editScheduleTime").show();
|
| 36642 |
ranu |
967 |
|
|
|
968 |
if (val == 'VISIT') {
|
|
|
969 |
// Filter assignTo to sales users only (no BGC)
|
|
|
970 |
if (typeof salesUserIds !== 'undefined') {
|
|
|
971 |
assignDropdown.find('option').each(function () {
|
|
|
972 |
var optVal = parseInt($(this).val());
|
|
|
973 |
if (optVal && salesUserIds.indexOf(optVal) === -1) {
|
|
|
974 |
$(this).hide();
|
|
|
975 |
} else {
|
|
|
976 |
$(this).show();
|
|
|
977 |
}
|
|
|
978 |
});
|
|
|
979 |
}
|
|
|
980 |
} else {
|
|
|
981 |
// TELEPHONIC — show all users
|
|
|
982 |
assignDropdown.find('option').show();
|
|
|
983 |
}
|
| 36741 |
ranu |
984 |
// Both VISIT and TELEPHONIC offer beat-day slots when an assignee is set
|
|
|
985 |
// (TELEPHONIC just uses the beat date as the call slot; backend won't
|
|
|
986 |
// attach a LeadRoute for it). Non-sales assignees simply get an empty list.
|
|
|
987 |
if (val && assignDropdown.val()) {
|
|
|
988 |
fetchBeatDates();
|
|
|
989 |
}
|
| 36642 |
ranu |
990 |
});
|
|
|
991 |
|
| 36741 |
ranu |
992 |
// Fetch beats when assignTo changes (works for both VISIT and TELEPHONIC)
|
|
|
993 |
$(document).on('change', '#assignTo', function () {
|
| 36642 |
ranu |
994 |
var commType = $('#communicationType').val();
|
|
|
995 |
var salesAuthId = $('#assignTo').val();
|
| 36741 |
ranu |
996 |
if (commType && salesAuthId && leadId) {
|
| 36642 |
ranu |
997 |
fetchBeatDates();
|
| 36741 |
ranu |
998 |
} else if (!commType) {
|
| 36642 |
ranu |
999 |
$("#beatDateSelection").hide();
|
|
|
1000 |
}
|
|
|
1001 |
});
|
|
|
1002 |
|
|
|
1003 |
function fetchBeatDates() {
|
|
|
1004 |
var salesAuthId = $('#assignTo').val();
|
|
|
1005 |
if (!salesAuthId || !leadId) return;
|
|
|
1006 |
|
|
|
1007 |
var badgesDiv = $('#beatBadges');
|
|
|
1008 |
badgesDiv.html('<span style="color:#999; font-size:12px;">Loading beats...</span>');
|
|
|
1009 |
$("#beatDateSelection").show();
|
|
|
1010 |
$('#beatDate').val('');
|
|
|
1011 |
|
|
|
1012 |
var url = context + "/lead-geo/beat-dates?leadId=" + leadId + "&salesAuthId=" + salesAuthId;
|
|
|
1013 |
|
|
|
1014 |
$.ajax({
|
|
|
1015 |
url: url,
|
|
|
1016 |
method: 'GET',
|
|
|
1017 |
success: function (response) {
|
|
|
1018 |
var data = response.response || response;
|
|
|
1019 |
badgesDiv.empty();
|
| 36644 |
ranu |
1020 |
|
| 36741 |
ranu |
1021 |
// Stores within radius of the lead — show count + top 3 inline.
|
|
|
1022 |
var radius = (data && data.radiusKm) ? data.radiusKm : 30;
|
|
|
1023 |
var stores = (data && data.nearestStores) || [];
|
|
|
1024 |
if (stores.length > 0) {
|
|
|
1025 |
var preview = stores.slice(0, 3).map(function (s) {
|
|
|
1026 |
return '<strong>' + s.code + ' - ' + s.name + '</strong> (' + s.distanceKm + ' km)';
|
|
|
1027 |
}).join(', ');
|
|
|
1028 |
var more = stores.length > 3 ? ' +' + (stores.length - 3) + ' more' : '';
|
| 36644 |
ranu |
1029 |
badgesDiv.append('<div style="font-size:12px; color:#333; margin-bottom:6px;">' +
|
| 36741 |
ranu |
1030 |
stores.length + ' partner store(s) within ' + radius + ' km of this lead: ' +
|
|
|
1031 |
preview + more + '</div>');
|
| 36644 |
ranu |
1032 |
}
|
|
|
1033 |
|
| 36741 |
ranu |
1034 |
// All upcoming beat-dates for the assignee that touch any nearby store.
|
| 36642 |
ranu |
1035 |
if (data && data.beats && data.beats.length > 0) {
|
| 36644 |
ranu |
1036 |
badgesDiv.append('<div style="font-weight:bold; font-size:11px; color:#666; margin-bottom:4px;">Available Slots (near this lead):</div>');
|
| 36741 |
ranu |
1037 |
var beats = data.beats;
|
| 36642 |
ranu |
1038 |
for (var i = 0; i < beats.length; i++) {
|
|
|
1039 |
var beat = beats[i];
|
| 36644 |
ranu |
1040 |
var nearTxt = beat.nearStore ? ' · near ' + beat.nearStore : '';
|
| 36642 |
ranu |
1041 |
var badge = $('<span class="beat-badge" style="' +
|
|
|
1042 |
'display:inline-block; background:#337ab7; color:#fff; padding:6px 12px; ' +
|
|
|
1043 |
'margin:4px 6px 4px 0; border-radius:16px; cursor:pointer; font-size:12px; ' +
|
|
|
1044 |
'border:2px solid #337ab7; transition:all 0.2s;">' +
|
| 36644 |
ranu |
1045 |
beat.planDate + ' · ' + beat.beatName + ' (' + beat.stops + ' stops)' + nearTxt +
|
| 36642 |
ranu |
1046 |
'</span>');
|
|
|
1047 |
badge.data('value', beat.planDate + '|' + beat.beatName + '|' + beat.planGroupId);
|
|
|
1048 |
badgesDiv.append(badge);
|
|
|
1049 |
}
|
|
|
1050 |
} else {
|
| 36787 |
ranu |
1051 |
// No beat-days available for this assignee. Surface a CTA so the
|
|
|
1052 |
// user can fire a visit request to the assignee's hierarchy instead
|
|
|
1053 |
// of being stuck. The pre-existing 'beats > 0' branch above is
|
|
|
1054 |
// untouched — this only fires for the empty-beats case.
|
|
|
1055 |
var nearestId = (stores.length > 0 && stores[0].storeId) ? stores[0].storeId : '';
|
|
|
1056 |
badgesDiv.append(
|
|
|
1057 |
'<div style="background:#fff8e1; border:1px solid #f0e0a0; border-radius:6px; padding:8px 10px; margin-top:4px;">'
|
|
|
1058 |
+ '<div style="font-size:12px; color:#7c5a00; margin-bottom:6px;">'
|
|
|
1059 |
+ 'No upcoming beat is available for this assignee.'
|
|
|
1060 |
+ '</div>'
|
|
|
1061 |
+ '<div style="display:flex; gap:8px; align-items:center;">'
|
|
|
1062 |
+ '<label style="font-size:11px; color:#666; margin:0;">Preferred date (optional):</label>'
|
|
|
1063 |
+ '<input type="date" id="vrPreferredDate" class="input-sm" style="font-size:12px; padding:3px 6px;">'
|
|
|
1064 |
+ '<button type="button" id="vrSendBtn" class="btn btn-warning btn-sm" '
|
|
|
1065 |
+ 'data-nearest="' + nearestId + '" style="font-size:12px;">Send Visit Request</button>'
|
|
|
1066 |
+ '</div>'
|
|
|
1067 |
+ '<div style="font-size:11px; color:#888; margin-top:6px;">'
|
|
|
1068 |
+ 'The request goes to the assignee\'s reporting head (and up). Once they approve and pick a beat-day, the lead lands on that beat.'
|
|
|
1069 |
+ '</div>'
|
|
|
1070 |
+ '</div>');
|
| 36642 |
ranu |
1071 |
}
|
|
|
1072 |
},
|
|
|
1073 |
error: function () {
|
|
|
1074 |
badgesDiv.html('<span style="color:#d9534f; font-size:12px;">Error loading beats</span>');
|
|
|
1075 |
}
|
|
|
1076 |
});
|
|
|
1077 |
}
|
|
|
1078 |
|
| 36787 |
ranu |
1079 |
// Send Visit Request when no beats are available for the chosen assignee.
|
|
|
1080 |
// Posts to /visitRequest/create. Existing beat-pick + Submit flow is unchanged.
|
|
|
1081 |
$(document).on('click', '#vrSendBtn', function () {
|
|
|
1082 |
var $btn = $(this);
|
|
|
1083 |
var assigneeAuthId = parseInt($('#assignTo').val());
|
|
|
1084 |
var commType = $('#communicationType').val() || null;
|
|
|
1085 |
var nearestStoreId = parseInt($btn.data('nearest'));
|
|
|
1086 |
var preferred = $('#vrPreferredDate').val() || null;
|
|
|
1087 |
if (!leadId || !assigneeAuthId) {
|
|
|
1088 |
alert('Pick an assignee first.');
|
|
|
1089 |
return;
|
|
|
1090 |
}
|
|
|
1091 |
$btn.prop('disabled', true).text('Sending...');
|
|
|
1092 |
var payload = {
|
|
|
1093 |
leadId: leadId,
|
|
|
1094 |
assigneeAuthId: assigneeAuthId,
|
|
|
1095 |
communicationType: commType,
|
|
|
1096 |
reason: 'No upcoming beats for assignee'
|
|
|
1097 |
};
|
|
|
1098 |
if (!isNaN(nearestStoreId) && nearestStoreId > 0) payload.nearestStoreId = nearestStoreId;
|
|
|
1099 |
if (preferred) payload.requestedDate = preferred;
|
|
|
1100 |
|
|
|
1101 |
doPostAjaxRequestWithJsonHandler(context + '/visitRequest/create', JSON.stringify(payload),
|
|
|
1102 |
function (response) {
|
|
|
1103 |
$btn.prop('disabled', false).text('Send Visit Request');
|
|
|
1104 |
var data = (response && response.response) || response || {};
|
|
|
1105 |
if (data && data.id) {
|
|
|
1106 |
alert('Visit request sent. The assignee\'s manager has been notified.');
|
|
|
1107 |
$('#editLeadData').modal('hide');
|
|
|
1108 |
$('.modal-backdrop').remove();
|
|
|
1109 |
} else {
|
|
|
1110 |
var msg = (data && data.message) || (data && data.error) || 'Could not send request.';
|
|
|
1111 |
alert(msg);
|
|
|
1112 |
}
|
|
|
1113 |
});
|
|
|
1114 |
});
|
|
|
1115 |
|
| 36741 |
ranu |
1116 |
// Click on beat badge to select it. A picked beat becomes the schedule
|
|
|
1117 |
// source — the manual date input is hidden (not needed when scheduling by beat).
|
| 36642 |
ranu |
1118 |
$(document).on('click', '.beat-badge', function () {
|
|
|
1119 |
$('.beat-badge').css({'background': '#337ab7', 'border-color': '#337ab7'});
|
|
|
1120 |
$(this).css({'background': '#1a5276', 'border-color': '#f39c12', 'border-width': '2px'});
|
|
|
1121 |
$('#beatDate').val($(this).data('value'));
|
| 36741 |
ranu |
1122 |
$("#editScheduleTime").hide();
|
| 36642 |
ranu |
1123 |
});
|
|
|
1124 |
|
|
|
1125 |
// Generate Geo Link for lead
|
|
|
1126 |
$(document).on('click', '.generateGeoLink', function (e) {
|
|
|
1127 |
e.stopPropagation();
|
|
|
1128 |
var lid = $(this).data('leadid');
|
|
|
1129 |
doAjaxRequestHandler(context + "/lead-geo/generate-link?leadId=" + lid, "GET", function (response) {
|
|
|
1130 |
var url = response.response;
|
|
|
1131 |
if (navigator.clipboard) {
|
|
|
1132 |
navigator.clipboard.writeText(url).then(function () {
|
|
|
1133 |
alert("Link copied to clipboard:\n" + url);
|
|
|
1134 |
});
|
|
|
1135 |
} else {
|
|
|
1136 |
prompt("Share this link with the prospect:", url);
|
|
|
1137 |
}
|
|
|
1138 |
});
|
|
|
1139 |
});
|
|
|
1140 |
|
|
|
1141 |
// Geo Review navigation
|
|
|
1142 |
$(document).on('click', '.geo-review', function () {
|
|
|
1143 |
doGetAjaxRequestHandler(context + "/lead-geo/pending-reviews", function (response) {
|
|
|
1144 |
$('#main-content').html(response);
|
|
|
1145 |
});
|
|
|
1146 |
});
|
|
|
1147 |
|
|
|
1148 |
// Visit Approvals navigation
|
|
|
1149 |
$(document).on('click', '.visit-approvals', function () {
|
|
|
1150 |
doGetAjaxRequestHandler(context + "/visit-approvals", function (response) {
|
|
|
1151 |
$('#main-content').html(response);
|
|
|
1152 |
});
|
|
|
1153 |
});
|
|
|
1154 |
|
| 36650 |
ranu |
1155 |
// Beat Day View — load inline into dashboard
|
|
|
1156 |
$(document).on('click', '.beat-plan-dayview', function (e) {
|
|
|
1157 |
e.preventDefault();
|
|
|
1158 |
doGetAjaxRequestHandler(context + '/beatPlan/dayView', function (response) {
|
|
|
1159 |
$('#main-content').html(response);
|
|
|
1160 |
});
|
|
|
1161 |
});
|
|
|
1162 |
|
| 36655 |
ranu |
1163 |
// Base Location manager — load inline into dashboard
|
|
|
1164 |
$(document).on('click', '.base-location', function (e) {
|
|
|
1165 |
e.preventDefault();
|
|
|
1166 |
doGetAjaxRequestHandler(context + '/beatPlan/baseLocationPage', function (response) {
|
|
|
1167 |
$('#main-content').html(response);
|
|
|
1168 |
});
|
|
|
1169 |
});
|
|
|
1170 |
|
| 36740 |
ranu |
1171 |
// Deferred Partners — load inline into dashboard
|
|
|
1172 |
$(document).on('click', '.beat-plan-deferred', function (e) {
|
|
|
1173 |
e.preventDefault();
|
|
|
1174 |
doGetAjaxRequestHandler(context + '/beatPlan/deferredView', function (response) {
|
|
|
1175 |
$('#main-content').html(response);
|
|
|
1176 |
});
|
|
|
1177 |
});
|
|
|
1178 |
|
| 36642 |
ranu |
1179 |
// Approve geolocation from lead table
|
|
|
1180 |
$(document).on('click', '.approve-geo', function (e) {
|
|
|
1181 |
e.stopPropagation();
|
|
|
1182 |
var lid = $(this).data('leadid');
|
|
|
1183 |
if (!confirm('Approve geolocation for Lead #' + lid + '?')) return;
|
|
|
1184 |
|
|
|
1185 |
var btn = $(this);
|
|
|
1186 |
var cell = btn.closest('td');
|
|
|
1187 |
|
|
|
1188 |
doPostAjaxRequestWithParamsHandler(
|
|
|
1189 |
context + '/lead-geo/review',
|
|
|
1190 |
{leadId: lid, status: 'APPROVED', remark: ''},
|
|
|
1191 |
function (response) {
|
|
|
1192 |
cell.html('<span class="label label-success">Verified</span>');
|
|
|
1193 |
}
|
|
|
1194 |
);
|
|
|
1195 |
});
|
|
|
1196 |
|
|
|
1197 |
// Reject geolocation from lead table
|
|
|
1198 |
$(document).on('click', '.reject-geo', function (e) {
|
|
|
1199 |
e.stopPropagation();
|
|
|
1200 |
var lid = $(this).data('leadid');
|
|
|
1201 |
var reason = prompt('Reason for rejection:');
|
|
|
1202 |
if (reason === null) return;
|
|
|
1203 |
|
|
|
1204 |
var btn = $(this);
|
|
|
1205 |
var cell = btn.closest('td');
|
|
|
1206 |
|
|
|
1207 |
doPostAjaxRequestWithParamsHandler(
|
|
|
1208 |
context + '/lead-geo/review',
|
|
|
1209 |
{leadId: lid, status: 'REJECTED', remark: reason},
|
|
|
1210 |
function (response) {
|
|
|
1211 |
cell.html('<button class="btn btn-xs btn-warning generateGeoLink" data-leadid="' + lid + '">Rejected - Resend</button>');
|
|
|
1212 |
}
|
|
|
1213 |
);
|
|
|
1214 |
});
|
|
|
1215 |
|