| 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);
|
| 36789 |
ranu |
486 |
// notInterested is a close-out — no geo / no beat / no assignee
|
|
|
487 |
// needed. Skip the geo gate and submit straight through with just
|
|
|
488 |
// the activity (status + reason + remark).
|
|
|
489 |
var currentStatus = $('#editStatus').val();
|
|
|
490 |
if (currentStatus === 'notInterested') {
|
|
|
491 |
submitLeadEdit();
|
|
|
492 |
return;
|
|
|
493 |
}
|
| 36761 |
ranu |
494 |
if (clickedBtn.data('geoChecking')) return;
|
|
|
495 |
clickedBtn.data('geoChecking', true);
|
|
|
496 |
doAjaxRequestHandler(
|
|
|
497 |
context + "/lead-geo/check/" + leadId,
|
|
|
498 |
"GET",
|
|
|
499 |
function (response) {
|
|
|
500 |
clickedBtn.removeData('geoChecking');
|
|
|
501 |
var hasGeo = response && response.response && response.response.hasApprovedGeo;
|
|
|
502 |
if (!hasGeo) {
|
|
|
503 |
alert('Live geo-location for this lead has not been approved yet. Please approve the geo-location before assigning / updating status.');
|
|
|
504 |
return;
|
|
|
505 |
}
|
|
|
506 |
submitLeadEdit();
|
|
|
507 |
}
|
|
|
508 |
);
|
|
|
509 |
});
|
| 25980 |
tejbeer |
510 |
|
| 36761 |
ranu |
511 |
function submitLeadEdit() {
|
|
|
512 |
|
| 35548 |
aman |
513 |
console.log(row);
|
|
|
514 |
var remark = $('input[name="remark"]').val();
|
|
|
515 |
var assignTo = $("#assignTo").val();
|
|
|
516 |
var editStatus = $("#editStatus").val();
|
|
|
517 |
var city = $('input[name="editCity"]').val();
|
|
|
518 |
var state = $("#editState").val();
|
|
|
519 |
var reason = $("#reason").val();
|
| 25980 |
tejbeer |
520 |
|
| 35769 |
amit |
521 |
var startDate = $("#startDate").val();
|
|
|
522 |
var endDate = $("#endDate").val();
|
| 35548 |
aman |
523 |
var leadStatus = $("#statusFilter").val();
|
|
|
524 |
var color = $("#colorFilter").val();
|
|
|
525 |
var communicationType = $("#communicationType").val();
|
| 29640 |
tejbeer |
526 |
|
| 35548 |
aman |
527 |
var conversionprobability = $("#conversionprobability").val();
|
| 35769 |
amit |
528 |
var editSource = $("#editSource").val();
|
| 29640 |
tejbeer |
529 |
|
| 35548 |
aman |
530 |
console.log(conversionprobability)
|
| 29640 |
tejbeer |
531 |
|
| 31473 |
tejbeer |
532 |
|
| 35769 |
amit |
533 |
console.log(startDate)
|
| 35548 |
aman |
534 |
console.log(leadStatus)
|
| 31370 |
tejbeer |
535 |
|
| 35548 |
aman |
536 |
console.log(color)
|
|
|
537 |
console.log(reason)
|
| 31370 |
tejbeer |
538 |
|
| 35548 |
aman |
539 |
if (remark === "" && assignTo === "" && editStatus === "") {
|
|
|
540 |
alert("All fields is required");
|
|
|
541 |
return;
|
|
|
542 |
}
|
| 31370 |
tejbeer |
543 |
|
| 36789 |
ranu |
544 |
// For notInterested (close-out) the lead doesn't need an assignee
|
|
|
545 |
// — it's just a status + reason + remark write. Only enforce
|
|
|
546 |
// assignTo for the other statuses where scheduling matters.
|
|
|
547 |
if (assignTo === "" && editStatus !== "notInterested") {
|
| 35548 |
aman |
548 |
alert("assignTo is required");
|
|
|
549 |
return;
|
|
|
550 |
}
|
| 31409 |
tejbeer |
551 |
|
| 35548 |
aman |
552 |
if (remark === "") {
|
|
|
553 |
alert("Remark is required");
|
|
|
554 |
return;
|
|
|
555 |
}
|
| 31370 |
tejbeer |
556 |
|
|
|
557 |
|
| 35548 |
aman |
558 |
if (editStatus === "") {
|
|
|
559 |
alert("status is required");
|
|
|
560 |
return;
|
|
|
561 |
}
|
| 31370 |
tejbeer |
562 |
|
| 35548 |
aman |
563 |
if (editStatus === "notInterested") {
|
| 36789 |
ranu |
564 |
if (reason == null || reason === "") {
|
| 35548 |
aman |
565 |
alert("Reason is required");
|
|
|
566 |
return;
|
|
|
567 |
}
|
|
|
568 |
}
|
|
|
569 |
var leadActivityData = {}
|
|
|
570 |
leadActivityData['id'] = leadId;
|
|
|
571 |
leadActivityData['remark'] = remark;
|
|
|
572 |
leadActivityData['assignTo'] = assignTo
|
|
|
573 |
leadActivityData['status'] = editStatus
|
|
|
574 |
leadActivityData['reason'] = reason
|
| 36741 |
ranu |
575 |
leadActivityData['colorCheck'] = (conversionprobability === "true" || conversionprobability === true)
|
| 35548 |
aman |
576 |
if (city && city.trim() !== "") {
|
|
|
577 |
leadActivityData.city = city;
|
|
|
578 |
}
|
| 25980 |
tejbeer |
579 |
|
| 35548 |
aman |
580 |
if (state && state.trim() !== "") {
|
|
|
581 |
leadActivityData.state = state;
|
|
|
582 |
}
|
| 29473 |
manish |
583 |
|
| 35769 |
amit |
584 |
if (editSource && editSource.trim() !== "") {
|
|
|
585 |
leadActivityData.source = editSource;
|
|
|
586 |
}
|
| 29598 |
tejbeer |
587 |
|
| 35769 |
amit |
588 |
|
| 35548 |
aman |
589 |
if (editStatus == "followUp") {
|
| 36642 |
ranu |
590 |
leadActivityData['communicationType'] = communicationType
|
| 36741 |
ranu |
591 |
var beatVal = $('#beatDate').val();
|
| 36761 |
ranu |
592 |
// Gate: for followUp, the lead must land on an upcoming beat of the
|
|
|
593 |
// assignee. If no beat is picked (or the assignee has no upcoming
|
|
|
594 |
// beat slots at all), block the submit with a clear message.
|
|
|
595 |
if (!beatVal) {
|
|
|
596 |
var hasBadges = $('#beatBadges .beat-badge').length > 0;
|
|
|
597 |
if (!hasBadges) {
|
|
|
598 |
alert('No upcoming beat is available for this assignee. Cannot schedule the lead until they have a beat.');
|
|
|
599 |
} else {
|
|
|
600 |
alert('Please select a beat date for the assignee before submitting.');
|
|
|
601 |
}
|
|
|
602 |
return;
|
| 36642 |
ranu |
603 |
}
|
| 36761 |
ranu |
604 |
var beatDate = beatVal.split('|')[0];
|
|
|
605 |
leadActivityData['scheldule'] = beatDate + 'T12:00:00';
|
|
|
606 |
leadActivityData['beatSelection'] = beatVal;
|
| 35548 |
aman |
607 |
}
|
| 29598 |
tejbeer |
608 |
|
| 35548 |
aman |
609 |
console.log(leadActivityData);
|
|
|
610 |
if (confirm("Are you sure you want to add lead!") == true) {
|
|
|
611 |
doPostAjaxRequestWithJsonHandler(context + "/editLead", JSON.stringify(leadActivityData), function (response) {
|
|
|
612 |
console.log(response);
|
|
|
613 |
$('#editLeadData').modal('hide');
|
|
|
614 |
$('.modal-backdrop').remove();
|
|
|
615 |
row.html(response);
|
|
|
616 |
});
|
|
|
617 |
}
|
| 29598 |
tejbeer |
618 |
|
| 36761 |
ranu |
619 |
}
|
| 32477 |
tejbeer |
620 |
|
|
|
621 |
|
| 35548 |
aman |
622 |
$(document).on('click', ".show-partner-health",
|
|
|
623 |
function () {
|
| 29598 |
tejbeer |
624 |
|
| 35548 |
aman |
625 |
var email = $("#authUserFilter").val();
|
| 25980 |
tejbeer |
626 |
|
| 35548 |
aman |
627 |
console.log(email)
|
|
|
628 |
doGetAjaxRequestHandler(context + "/partnerHealth?email="
|
|
|
629 |
+ email, function (response) {
|
|
|
630 |
console.log(response)
|
|
|
631 |
$('#' + 'main-content').html(response);
|
| 25980 |
tejbeer |
632 |
|
| 35548 |
aman |
633 |
});
|
|
|
634 |
});
|
| 25980 |
tejbeer |
635 |
|
|
|
636 |
|
| 35548 |
aman |
637 |
$(document).on('click', ".lead-detail-entry",
|
|
|
638 |
function () {
|
| 28200 |
tejbeer |
639 |
|
| 35548 |
aman |
640 |
console.log("hello");
|
|
|
641 |
var outletName = $('input[name="outletName"]').val();
|
|
|
642 |
var counterSize = $('input[name="counterSize"]').val();
|
|
|
643 |
var table = document.getElementById('editbrandtable');
|
|
|
644 |
var brandValueJson = [];
|
|
|
645 |
var leadBrands;
|
| 25980 |
tejbeer |
646 |
|
| 35548 |
aman |
647 |
if (outletName === "") {
|
|
|
648 |
alert("Outlet Name is required");
|
|
|
649 |
return;
|
|
|
650 |
}
|
| 29598 |
tejbeer |
651 |
|
| 35548 |
aman |
652 |
if (counterSize === "") {
|
|
|
653 |
alert("Counter Size is required");
|
|
|
654 |
return;
|
|
|
655 |
}
|
| 32471 |
tejbeer |
656 |
|
| 35548 |
aman |
657 |
if (localStorage.getItem("frontph") == "undefined" && localStorage.getItem("frontph") == null) {
|
|
|
658 |
alert("Front Document is required");
|
|
|
659 |
return;
|
|
|
660 |
}
|
| 31249 |
tejbeer |
661 |
|
| 35548 |
aman |
662 |
if (localStorage.getItem("internalMarketh") == "undefined" || localStorage.getItem("internalMarketh") == null) {
|
|
|
663 |
alert("Front With Market Document is required");
|
|
|
664 |
return;
|
|
|
665 |
}
|
| 25980 |
tejbeer |
666 |
|
| 35548 |
aman |
667 |
if (localStorage.getItem("leftShoth") == "undefined" || localStorage.getItem("leftShoth") == null) {
|
|
|
668 |
alert("Internal Left Shot Document is required");
|
|
|
669 |
return;
|
|
|
670 |
}
|
| 27605 |
tejbeer |
671 |
|
| 35548 |
aman |
672 |
if (localStorage.getItem("leftWallh") == "undefined" || localStorage.getItem("leftWallh") == null) {
|
|
|
673 |
alert("Internal Left Wall Document is required");
|
|
|
674 |
return;
|
|
|
675 |
}
|
| 27605 |
tejbeer |
676 |
|
| 30185 |
tejbeer |
677 |
|
| 35548 |
aman |
678 |
if (localStorage.getItem("rightWallh") == "undefined" || localStorage.getItem("rightWallh") == null) {
|
|
|
679 |
alert("Internal Right Wall Document is required");
|
|
|
680 |
return;
|
|
|
681 |
}
|
| 30185 |
tejbeer |
682 |
|
|
|
683 |
|
| 35548 |
aman |
684 |
for (i = 1; i < table.rows.length; i++) {
|
| 30185 |
tejbeer |
685 |
|
| 35548 |
aman |
686 |
var objCells = table.rows[i].cells;
|
| 30185 |
tejbeer |
687 |
|
| 35548 |
aman |
688 |
leadBrands = {
|
|
|
689 |
brand: objCells[0].innerText,
|
|
|
690 |
value: objCells[1].getElementsByTagName('input')[0].value
|
|
|
691 |
}
|
|
|
692 |
brandValueJson.push(leadBrands);
|
|
|
693 |
}
|
| 30185 |
tejbeer |
694 |
|
| 30416 |
tejbeer |
695 |
|
| 35548 |
aman |
696 |
var leadDetailObject = {};
|
| 31402 |
tejbeer |
697 |
|
| 35548 |
aman |
698 |
leadDetailObject['leadId'] = leadId;
|
| 30416 |
tejbeer |
699 |
|
|
|
700 |
|
| 35548 |
aman |
701 |
leadDetailObject['outletName'] = outletName;
|
| 31370 |
tejbeer |
702 |
|
| 35548 |
aman |
703 |
leadDetailObject['counterSize'] = counterSize;
|
| 31370 |
tejbeer |
704 |
|
| 35548 |
aman |
705 |
leadDetailObject['leadBrands'] = brandValueJson;
|
| 31370 |
tejbeer |
706 |
|
| 31402 |
tejbeer |
707 |
|
| 35548 |
aman |
708 |
console.log(localStorage.getItem("frontp"));
|
| 31402 |
tejbeer |
709 |
|
|
|
710 |
|
| 35548 |
aman |
711 |
leadDetailObject['frontp'] = localStorage
|
|
|
712 |
.getItem("frontph");
|
| 31402 |
tejbeer |
713 |
|
|
|
714 |
|
| 35548 |
aman |
715 |
leadDetailObject['frontWithMarket'] = localStorage
|
|
|
716 |
.getItem("internalMarketh");
|
| 31370 |
tejbeer |
717 |
|
|
|
718 |
|
| 35548 |
aman |
719 |
leadDetailObject['internalLongShot'] = localStorage
|
|
|
720 |
.getItem("leftShoth");
|
| 31370 |
tejbeer |
721 |
|
|
|
722 |
|
| 35548 |
aman |
723 |
leadDetailObject['internalLeftWall'] = localStorage
|
|
|
724 |
.getItem("leftWallh");
|
| 31370 |
tejbeer |
725 |
|
|
|
726 |
|
| 35548 |
aman |
727 |
leadDetailObject['internalRightWall'] = localStorage
|
|
|
728 |
.getItem("rightWallh");
|
| 31370 |
tejbeer |
729 |
|
| 35548 |
aman |
730 |
console.log(leadDetailObject);
|
| 31370 |
tejbeer |
731 |
|
| 35548 |
aman |
732 |
if (confirm("Are you sure you want to add lead detail!") == true) {
|
|
|
733 |
doPostAjaxRequestWithJsonHandler(context + "/leadDetail", JSON.stringify(leadDetailObject), function (response) {
|
|
|
734 |
console.log(response);
|
|
|
735 |
if (response == 'true') {
|
|
|
736 |
alert("Submit Successfully");
|
|
|
737 |
}
|
| 31370 |
tejbeer |
738 |
|
| 35548 |
aman |
739 |
});
|
|
|
740 |
}
|
| 31370 |
tejbeer |
741 |
|
| 35548 |
aman |
742 |
});
|
| 31370 |
tejbeer |
743 |
|
|
|
744 |
|
| 35548 |
aman |
745 |
$(document).on('change', '.frontp',
|
|
|
746 |
function () {
|
| 31370 |
tejbeer |
747 |
|
| 35548 |
aman |
748 |
if (confirm('Document has been selected, Do you want to upload ?')) {
|
| 31370 |
tejbeer |
749 |
|
| 35548 |
aman |
750 |
var documentId = uploadImage(this, "frontph");
|
| 31370 |
tejbeer |
751 |
|
|
|
752 |
|
| 35548 |
aman |
753 |
} else {
|
| 31370 |
tejbeer |
754 |
|
| 35548 |
aman |
755 |
}
|
|
|
756 |
});
|
| 31456 |
tejbeer |
757 |
|
| 35548 |
aman |
758 |
$(document).on('change', '.internalMarket',
|
|
|
759 |
function () {
|
| 31456 |
tejbeer |
760 |
|
| 35548 |
aman |
761 |
if (confirm('Document has been selected, Do you want to upload ?')) {
|
| 31456 |
tejbeer |
762 |
|
| 35548 |
aman |
763 |
var documentId = uploadImage(this, "internalMarketh");
|
| 31456 |
tejbeer |
764 |
|
| 35548 |
aman |
765 |
} else {
|
| 31456 |
tejbeer |
766 |
|
| 35548 |
aman |
767 |
}
|
|
|
768 |
});
|
| 31370 |
tejbeer |
769 |
|
| 35548 |
aman |
770 |
$(document).on('change', '.leftShot',
|
| 31370 |
tejbeer |
771 |
|
| 35548 |
aman |
772 |
function () {
|
|
|
773 |
if (confirm('Document has been selected, Do you want to upload ?')) {
|
|
|
774 |
var documentId = uploadImage(this, "leftShoth");
|
|
|
775 |
} else {
|
| 31370 |
tejbeer |
776 |
|
| 35548 |
aman |
777 |
}
|
|
|
778 |
});
|
| 31370 |
tejbeer |
779 |
|
| 35548 |
aman |
780 |
$(document).on('change', '.leftWall',
|
|
|
781 |
function () {
|
|
|
782 |
if (confirm('Document has been selected, Do you want to upload ?')) {
|
|
|
783 |
var documentId = uploadImage(this, "leftWallh");
|
|
|
784 |
} else {
|
| 31370 |
tejbeer |
785 |
|
| 35548 |
aman |
786 |
}
|
|
|
787 |
});
|
| 31370 |
tejbeer |
788 |
|
| 35548 |
aman |
789 |
$(document).on('change', '.rightWall',
|
|
|
790 |
function () {
|
|
|
791 |
if (confirm('Document has been selected, Do you want to upload ?')) {
|
|
|
792 |
var documentId = uploadImage(this, "rightWallh");
|
|
|
793 |
} else {
|
|
|
794 |
}
|
|
|
795 |
});
|
| 31370 |
tejbeer |
796 |
|
|
|
797 |
|
| 25980 |
tejbeer |
798 |
});
|
|
|
799 |
|
| 31404 |
tejbeer |
800 |
function uploadImage(fileSelector, attrName) {
|
| 35548 |
aman |
801 |
var documentId;
|
|
|
802 |
if (fileSelector != undefined
|
|
|
803 |
&& fileSelector.files[0] != undefined) {
|
|
|
804 |
var url = context
|
|
|
805 |
+ '/document-upload';
|
| 31370 |
tejbeer |
806 |
|
| 35548 |
aman |
807 |
console.log(url);
|
|
|
808 |
var file = fileSelector.files[0];
|
| 31370 |
tejbeer |
809 |
|
| 35548 |
aman |
810 |
console.log(file)
|
|
|
811 |
doAjaxUploadRequestHandler(
|
|
|
812 |
url,
|
|
|
813 |
'POST',
|
|
|
814 |
file,
|
|
|
815 |
function (response) {
|
|
|
816 |
console.log(response)
|
|
|
817 |
documentId = response.response.document_id;
|
|
|
818 |
console
|
|
|
819 |
.log("documentId : "
|
|
|
820 |
+ documentId);
|
| 31370 |
tejbeer |
821 |
|
|
|
822 |
|
| 35548 |
aman |
823 |
localStorage
|
|
|
824 |
.setItem(
|
|
|
825 |
attrName,
|
|
|
826 |
documentId);
|
| 31402 |
tejbeer |
827 |
|
| 35548 |
aman |
828 |
});
|
|
|
829 |
return documentId;
|
|
|
830 |
}
|
| 31370 |
tejbeer |
831 |
|
|
|
832 |
}
|
|
|
833 |
|
|
|
834 |
|
| 25980 |
tejbeer |
835 |
function loadLead(domId) {
|
| 35548 |
aman |
836 |
doGetAjaxRequestHandler(context + "/getOpenLead", function (response) {
|
|
|
837 |
$('#' + domId).html(response);
|
|
|
838 |
});
|
| 25980 |
tejbeer |
839 |
}
|
|
|
840 |
|
| 25988 |
tejbeer |
841 |
function loadClosedLead(domId, searchTerm) {
|
| 35548 |
aman |
842 |
doGetAjaxRequestHandler(context + "/getClosedLead", function (response) {
|
|
|
843 |
$('#' + domId).html(response);
|
|
|
844 |
})
|
| 25988 |
tejbeer |
845 |
}
|
|
|
846 |
|
| 25980 |
tejbeer |
847 |
function statusAction() {
|
| 35548 |
aman |
848 |
var val = $('#status').val();
|
|
|
849 |
if (val == "followUp") {
|
|
|
850 |
$("#scheduleTime").show();
|
|
|
851 |
} else {
|
|
|
852 |
$("#scheduleTime").hide();
|
|
|
853 |
}
|
| 25980 |
tejbeer |
854 |
|
|
|
855 |
}
|
| 27605 |
tejbeer |
856 |
|
|
|
857 |
|
|
|
858 |
function editStatusAction() {
|
| 35548 |
aman |
859 |
var val = $('#editStatus').val();
|
|
|
860 |
if (val == "followUp") {
|
| 36642 |
ranu |
861 |
// Show communication type and schedule date
|
|
|
862 |
$("#communicationTypeSection").show();
|
| 35548 |
aman |
863 |
$("#editScheduleTime").show();
|
| 36642 |
ranu |
864 |
$("#beatDateSelection").hide();
|
|
|
865 |
|
| 36761 |
ranu |
866 |
// Reset communication type only; preserve the assignee the user picked.
|
| 36642 |
ranu |
867 |
$('#communicationType').val('');
|
|
|
868 |
$('#assignTo option').show();
|
|
|
869 |
|
|
|
870 |
// Check if lead has approved geolocation to decide VISIT option
|
|
|
871 |
doAjaxRequestHandler(context + "/lead-geo/check/" + leadId, "GET", function (response) {
|
|
|
872 |
var hasGeo = response.response.hasApprovedGeo;
|
|
|
873 |
var commDropdown = $('#communicationType');
|
|
|
874 |
commDropdown.empty();
|
|
|
875 |
commDropdown.append('<option value="" disabled selected>Communication Type</option>');
|
|
|
876 |
commDropdown.append('<option value="TELEPHONIC">TELEPHONIC</option>');
|
|
|
877 |
if (hasGeo) {
|
|
|
878 |
commDropdown.append('<option value="VISIT">VISIT</option>');
|
|
|
879 |
}
|
|
|
880 |
});
|
| 35548 |
aman |
881 |
} else {
|
| 36642 |
ranu |
882 |
$("#communicationTypeSection").hide();
|
| 35548 |
aman |
883 |
$("#editScheduleTime").hide();
|
| 36642 |
ranu |
884 |
$("#beatDateSelection").hide();
|
|
|
885 |
$('#assignTo option').show();
|
| 35548 |
aman |
886 |
}
|
| 27605 |
tejbeer |
887 |
|
|
|
888 |
}
|
|
|
889 |
|
| 25988 |
tejbeer |
890 |
function loadLeadSearchInfo(search_text) {
|
| 35548 |
aman |
891 |
loadSearchLead("main-content", search_text);
|
| 25988 |
tejbeer |
892 |
}
|
|
|
893 |
|
| 30185 |
tejbeer |
894 |
function loadTeamCommitment(domId) {
|
| 35548 |
aman |
895 |
doGetAjaxRequestHandler(context + "/teamCommitment",
|
|
|
896 |
function (response) {
|
|
|
897 |
$('#' + domId).html(response);
|
|
|
898 |
});
|
| 30185 |
tejbeer |
899 |
}
|
|
|
900 |
|
| 31370 |
tejbeer |
901 |
function loadLeadDetail(domId) {
|
| 35548 |
aman |
902 |
doGetAjaxRequestHandler(context + "/getLeadDetail",
|
|
|
903 |
function (response) {
|
|
|
904 |
$('#' + domId).html(response);
|
|
|
905 |
});
|
| 31370 |
tejbeer |
906 |
}
|
|
|
907 |
|
| 30416 |
tejbeer |
908 |
function loadPartnerHealth(domId) {
|
| 35548 |
aman |
909 |
doGetAjaxRequestHandler(context + "/partnerHealth",
|
|
|
910 |
function (response) {
|
|
|
911 |
$('#' + domId).html(response);
|
|
|
912 |
});
|
| 30416 |
tejbeer |
913 |
}
|
|
|
914 |
|
| 25988 |
tejbeer |
915 |
function loadSearchLead(domId, search_text) {
|
| 35548 |
aman |
916 |
doGetAjaxRequestHandler(context + "/searchLeads?searchTerm=" + search_text,
|
|
|
917 |
function (response) {
|
|
|
918 |
$('#' + domId).html(response);
|
|
|
919 |
});
|
| 25988 |
tejbeer |
920 |
}
|
| 33917 |
ranu |
921 |
|
|
|
922 |
$(document).on('click', ".arr-button-mk",
|
| 35548 |
aman |
923 |
function () {
|
|
|
924 |
var startDate = $('.arr-start_date').val();
|
|
|
925 |
doGetAjaxRequestHandler(context + "/rbmTodayArr?startDate=" + startDate, function (response) {
|
|
|
926 |
$('#main-content').html(response);
|
| 33917 |
ranu |
927 |
|
| 35548 |
aman |
928 |
});
|
|
|
929 |
});
|
| 33917 |
ranu |
930 |
|
|
|
931 |
$(document).on('click', ".rbm-today-arr",
|
| 35548 |
aman |
932 |
function () {
|
|
|
933 |
doGetAjaxRequestHandler(context + "/rbmTodayArr", function (response) {
|
|
|
934 |
$('#main-content').html(response);
|
| 33917 |
ranu |
935 |
|
| 35548 |
aman |
936 |
});
|
|
|
937 |
});
|
|
|
938 |
$(document).on('click', '.reassign', function () {
|
|
|
939 |
$('#bulkReassignFile').val(null);
|
|
|
940 |
$('#bulkReassignFile').click();
|
|
|
941 |
});
|
|
|
942 |
|
|
|
943 |
$(document).on('change', '#bulkReassignFile', function () {
|
|
|
944 |
|
|
|
945 |
if (!confirm("Confirm bulk reassign upload?")) {
|
|
|
946 |
return;
|
|
|
947 |
}
|
|
|
948 |
|
|
|
949 |
var file = this.files[0];
|
|
|
950 |
if (!file) {
|
|
|
951 |
alert("No file selected");
|
|
|
952 |
return;
|
|
|
953 |
}
|
|
|
954 |
|
|
|
955 |
doAjaxUploadRequestHandler(
|
|
|
956 |
context + "/upload-assign-id",
|
|
|
957 |
'POST',
|
|
|
958 |
file,
|
|
|
959 |
function (response) {
|
|
|
960 |
alert("Bulk reassignment completed");
|
|
|
961 |
loadLead("main-content");
|
|
|
962 |
}
|
|
|
963 |
);
|
|
|
964 |
});
|
|
|
965 |
|
| 36642 |
ranu |
966 |
// ==================== GEO LOCATION HANDLERS ====================
|
|
|
967 |
|
|
|
968 |
// Communication type change: filter assignTo based on type
|
|
|
969 |
$(document).on('change', '#communicationType', function () {
|
|
|
970 |
var val = $(this).val();
|
|
|
971 |
var assignDropdown = $('#assignTo');
|
|
|
972 |
|
| 36741 |
ranu |
973 |
// Reset beat + restore manual date input
|
| 36642 |
ranu |
974 |
$('#beatDate').val('');
|
|
|
975 |
$('#beatBadges').empty();
|
|
|
976 |
$("#beatDateSelection").hide();
|
| 36741 |
ranu |
977 |
$("#editScheduleTime").show();
|
| 36642 |
ranu |
978 |
|
|
|
979 |
if (val == 'VISIT') {
|
|
|
980 |
// Filter assignTo to sales users only (no BGC)
|
|
|
981 |
if (typeof salesUserIds !== 'undefined') {
|
|
|
982 |
assignDropdown.find('option').each(function () {
|
|
|
983 |
var optVal = parseInt($(this).val());
|
|
|
984 |
if (optVal && salesUserIds.indexOf(optVal) === -1) {
|
|
|
985 |
$(this).hide();
|
|
|
986 |
} else {
|
|
|
987 |
$(this).show();
|
|
|
988 |
}
|
|
|
989 |
});
|
|
|
990 |
}
|
|
|
991 |
} else {
|
|
|
992 |
// TELEPHONIC — show all users
|
|
|
993 |
assignDropdown.find('option').show();
|
|
|
994 |
}
|
| 36741 |
ranu |
995 |
// Both VISIT and TELEPHONIC offer beat-day slots when an assignee is set
|
|
|
996 |
// (TELEPHONIC just uses the beat date as the call slot; backend won't
|
|
|
997 |
// attach a LeadRoute for it). Non-sales assignees simply get an empty list.
|
|
|
998 |
if (val && assignDropdown.val()) {
|
|
|
999 |
fetchBeatDates();
|
|
|
1000 |
}
|
| 36642 |
ranu |
1001 |
});
|
|
|
1002 |
|
| 36741 |
ranu |
1003 |
// Fetch beats when assignTo changes (works for both VISIT and TELEPHONIC)
|
|
|
1004 |
$(document).on('change', '#assignTo', function () {
|
| 36642 |
ranu |
1005 |
var commType = $('#communicationType').val();
|
|
|
1006 |
var salesAuthId = $('#assignTo').val();
|
| 36741 |
ranu |
1007 |
if (commType && salesAuthId && leadId) {
|
| 36642 |
ranu |
1008 |
fetchBeatDates();
|
| 36741 |
ranu |
1009 |
} else if (!commType) {
|
| 36642 |
ranu |
1010 |
$("#beatDateSelection").hide();
|
|
|
1011 |
}
|
|
|
1012 |
});
|
|
|
1013 |
|
|
|
1014 |
function fetchBeatDates() {
|
|
|
1015 |
var salesAuthId = $('#assignTo').val();
|
|
|
1016 |
if (!salesAuthId || !leadId) return;
|
|
|
1017 |
|
|
|
1018 |
var badgesDiv = $('#beatBadges');
|
|
|
1019 |
badgesDiv.html('<span style="color:#999; font-size:12px;">Loading beats...</span>');
|
|
|
1020 |
$("#beatDateSelection").show();
|
|
|
1021 |
$('#beatDate').val('');
|
|
|
1022 |
|
|
|
1023 |
var url = context + "/lead-geo/beat-dates?leadId=" + leadId + "&salesAuthId=" + salesAuthId;
|
|
|
1024 |
|
|
|
1025 |
$.ajax({
|
|
|
1026 |
url: url,
|
|
|
1027 |
method: 'GET',
|
|
|
1028 |
success: function (response) {
|
|
|
1029 |
var data = response.response || response;
|
|
|
1030 |
badgesDiv.empty();
|
| 36644 |
ranu |
1031 |
|
| 36741 |
ranu |
1032 |
// Stores within radius of the lead — show count + top 3 inline.
|
|
|
1033 |
var radius = (data && data.radiusKm) ? data.radiusKm : 30;
|
|
|
1034 |
var stores = (data && data.nearestStores) || [];
|
|
|
1035 |
if (stores.length > 0) {
|
|
|
1036 |
var preview = stores.slice(0, 3).map(function (s) {
|
|
|
1037 |
return '<strong>' + s.code + ' - ' + s.name + '</strong> (' + s.distanceKm + ' km)';
|
|
|
1038 |
}).join(', ');
|
|
|
1039 |
var more = stores.length > 3 ? ' +' + (stores.length - 3) + ' more' : '';
|
| 36644 |
ranu |
1040 |
badgesDiv.append('<div style="font-size:12px; color:#333; margin-bottom:6px;">' +
|
| 36741 |
ranu |
1041 |
stores.length + ' partner store(s) within ' + radius + ' km of this lead: ' +
|
|
|
1042 |
preview + more + '</div>');
|
| 36644 |
ranu |
1043 |
}
|
|
|
1044 |
|
| 36741 |
ranu |
1045 |
// All upcoming beat-dates for the assignee that touch any nearby store.
|
| 36642 |
ranu |
1046 |
if (data && data.beats && data.beats.length > 0) {
|
| 36644 |
ranu |
1047 |
badgesDiv.append('<div style="font-weight:bold; font-size:11px; color:#666; margin-bottom:4px;">Available Slots (near this lead):</div>');
|
| 36741 |
ranu |
1048 |
var beats = data.beats;
|
| 36642 |
ranu |
1049 |
for (var i = 0; i < beats.length; i++) {
|
|
|
1050 |
var beat = beats[i];
|
| 36644 |
ranu |
1051 |
var nearTxt = beat.nearStore ? ' · near ' + beat.nearStore : '';
|
| 36642 |
ranu |
1052 |
var badge = $('<span class="beat-badge" style="' +
|
|
|
1053 |
'display:inline-block; background:#337ab7; color:#fff; padding:6px 12px; ' +
|
|
|
1054 |
'margin:4px 6px 4px 0; border-radius:16px; cursor:pointer; font-size:12px; ' +
|
|
|
1055 |
'border:2px solid #337ab7; transition:all 0.2s;">' +
|
| 36644 |
ranu |
1056 |
beat.planDate + ' · ' + beat.beatName + ' (' + beat.stops + ' stops)' + nearTxt +
|
| 36642 |
ranu |
1057 |
'</span>');
|
|
|
1058 |
badge.data('value', beat.planDate + '|' + beat.beatName + '|' + beat.planGroupId);
|
|
|
1059 |
badgesDiv.append(badge);
|
|
|
1060 |
}
|
|
|
1061 |
} else {
|
| 36787 |
ranu |
1062 |
// No beat-days available for this assignee. Surface a CTA so the
|
|
|
1063 |
// user can fire a visit request to the assignee's hierarchy instead
|
|
|
1064 |
// of being stuck. The pre-existing 'beats > 0' branch above is
|
|
|
1065 |
// untouched — this only fires for the empty-beats case.
|
|
|
1066 |
var nearestId = (stores.length > 0 && stores[0].storeId) ? stores[0].storeId : '';
|
|
|
1067 |
badgesDiv.append(
|
|
|
1068 |
'<div style="background:#fff8e1; border:1px solid #f0e0a0; border-radius:6px; padding:8px 10px; margin-top:4px;">'
|
|
|
1069 |
+ '<div style="font-size:12px; color:#7c5a00; margin-bottom:6px;">'
|
|
|
1070 |
+ 'No upcoming beat is available for this assignee.'
|
|
|
1071 |
+ '</div>'
|
|
|
1072 |
+ '<div style="display:flex; gap:8px; align-items:center;">'
|
|
|
1073 |
+ '<label style="font-size:11px; color:#666; margin:0;">Preferred date (optional):</label>'
|
|
|
1074 |
+ '<input type="date" id="vrPreferredDate" class="input-sm" style="font-size:12px; padding:3px 6px;">'
|
|
|
1075 |
+ '<button type="button" id="vrSendBtn" class="btn btn-warning btn-sm" '
|
|
|
1076 |
+ 'data-nearest="' + nearestId + '" style="font-size:12px;">Send Visit Request</button>'
|
|
|
1077 |
+ '</div>'
|
|
|
1078 |
+ '<div style="font-size:11px; color:#888; margin-top:6px;">'
|
|
|
1079 |
+ '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.'
|
|
|
1080 |
+ '</div>'
|
|
|
1081 |
+ '</div>');
|
| 36642 |
ranu |
1082 |
}
|
|
|
1083 |
},
|
|
|
1084 |
error: function () {
|
|
|
1085 |
badgesDiv.html('<span style="color:#d9534f; font-size:12px;">Error loading beats</span>');
|
|
|
1086 |
}
|
|
|
1087 |
});
|
|
|
1088 |
}
|
|
|
1089 |
|
| 36787 |
ranu |
1090 |
// Send Visit Request when no beats are available for the chosen assignee.
|
|
|
1091 |
// Posts to /visitRequest/create. Existing beat-pick + Submit flow is unchanged.
|
|
|
1092 |
$(document).on('click', '#vrSendBtn', function () {
|
|
|
1093 |
var $btn = $(this);
|
|
|
1094 |
var assigneeAuthId = parseInt($('#assignTo').val());
|
|
|
1095 |
var commType = $('#communicationType').val() || null;
|
|
|
1096 |
var nearestStoreId = parseInt($btn.data('nearest'));
|
|
|
1097 |
var preferred = $('#vrPreferredDate').val() || null;
|
|
|
1098 |
if (!leadId || !assigneeAuthId) {
|
|
|
1099 |
alert('Pick an assignee first.');
|
|
|
1100 |
return;
|
|
|
1101 |
}
|
|
|
1102 |
$btn.prop('disabled', true).text('Sending...');
|
|
|
1103 |
var payload = {
|
|
|
1104 |
leadId: leadId,
|
|
|
1105 |
assigneeAuthId: assigneeAuthId,
|
|
|
1106 |
communicationType: commType,
|
|
|
1107 |
reason: 'No upcoming beats for assignee'
|
|
|
1108 |
};
|
|
|
1109 |
if (!isNaN(nearestStoreId) && nearestStoreId > 0) payload.nearestStoreId = nearestStoreId;
|
|
|
1110 |
if (preferred) payload.requestedDate = preferred;
|
|
|
1111 |
|
|
|
1112 |
doPostAjaxRequestWithJsonHandler(context + '/visitRequest/create', JSON.stringify(payload),
|
|
|
1113 |
function (response) {
|
|
|
1114 |
$btn.prop('disabled', false).text('Send Visit Request');
|
|
|
1115 |
var data = (response && response.response) || response || {};
|
|
|
1116 |
if (data && data.id) {
|
|
|
1117 |
alert('Visit request sent. The assignee\'s manager has been notified.');
|
|
|
1118 |
$('#editLeadData').modal('hide');
|
|
|
1119 |
$('.modal-backdrop').remove();
|
|
|
1120 |
} else {
|
|
|
1121 |
var msg = (data && data.message) || (data && data.error) || 'Could not send request.';
|
|
|
1122 |
alert(msg);
|
|
|
1123 |
}
|
|
|
1124 |
});
|
|
|
1125 |
});
|
|
|
1126 |
|
| 36741 |
ranu |
1127 |
// Click on beat badge to select it. A picked beat becomes the schedule
|
|
|
1128 |
// source — the manual date input is hidden (not needed when scheduling by beat).
|
| 36642 |
ranu |
1129 |
$(document).on('click', '.beat-badge', function () {
|
|
|
1130 |
$('.beat-badge').css({'background': '#337ab7', 'border-color': '#337ab7'});
|
|
|
1131 |
$(this).css({'background': '#1a5276', 'border-color': '#f39c12', 'border-width': '2px'});
|
|
|
1132 |
$('#beatDate').val($(this).data('value'));
|
| 36741 |
ranu |
1133 |
$("#editScheduleTime").hide();
|
| 36642 |
ranu |
1134 |
});
|
|
|
1135 |
|
|
|
1136 |
// Generate Geo Link for lead
|
|
|
1137 |
$(document).on('click', '.generateGeoLink', function (e) {
|
|
|
1138 |
e.stopPropagation();
|
|
|
1139 |
var lid = $(this).data('leadid');
|
|
|
1140 |
doAjaxRequestHandler(context + "/lead-geo/generate-link?leadId=" + lid, "GET", function (response) {
|
|
|
1141 |
var url = response.response;
|
|
|
1142 |
if (navigator.clipboard) {
|
|
|
1143 |
navigator.clipboard.writeText(url).then(function () {
|
|
|
1144 |
alert("Link copied to clipboard:\n" + url);
|
|
|
1145 |
});
|
|
|
1146 |
} else {
|
|
|
1147 |
prompt("Share this link with the prospect:", url);
|
|
|
1148 |
}
|
|
|
1149 |
});
|
|
|
1150 |
});
|
|
|
1151 |
|
|
|
1152 |
// Geo Review navigation
|
|
|
1153 |
$(document).on('click', '.geo-review', function () {
|
|
|
1154 |
doGetAjaxRequestHandler(context + "/lead-geo/pending-reviews", function (response) {
|
|
|
1155 |
$('#main-content').html(response);
|
|
|
1156 |
});
|
|
|
1157 |
});
|
|
|
1158 |
|
|
|
1159 |
// Visit Approvals navigation
|
|
|
1160 |
$(document).on('click', '.visit-approvals', function () {
|
|
|
1161 |
doGetAjaxRequestHandler(context + "/visit-approvals", function (response) {
|
|
|
1162 |
$('#main-content').html(response);
|
|
|
1163 |
});
|
|
|
1164 |
});
|
|
|
1165 |
|
| 36650 |
ranu |
1166 |
// Beat Day View — load inline into dashboard
|
|
|
1167 |
$(document).on('click', '.beat-plan-dayview', function (e) {
|
|
|
1168 |
e.preventDefault();
|
|
|
1169 |
doGetAjaxRequestHandler(context + '/beatPlan/dayView', function (response) {
|
|
|
1170 |
$('#main-content').html(response);
|
|
|
1171 |
});
|
|
|
1172 |
});
|
|
|
1173 |
|
| 36655 |
ranu |
1174 |
// Base Location manager — load inline into dashboard
|
|
|
1175 |
$(document).on('click', '.base-location', function (e) {
|
|
|
1176 |
e.preventDefault();
|
|
|
1177 |
doGetAjaxRequestHandler(context + '/beatPlan/baseLocationPage', function (response) {
|
|
|
1178 |
$('#main-content').html(response);
|
|
|
1179 |
});
|
|
|
1180 |
});
|
|
|
1181 |
|
| 36740 |
ranu |
1182 |
// Deferred Partners — load inline into dashboard
|
|
|
1183 |
$(document).on('click', '.beat-plan-deferred', function (e) {
|
|
|
1184 |
e.preventDefault();
|
|
|
1185 |
doGetAjaxRequestHandler(context + '/beatPlan/deferredView', function (response) {
|
|
|
1186 |
$('#main-content').html(response);
|
|
|
1187 |
});
|
|
|
1188 |
});
|
|
|
1189 |
|
| 36642 |
ranu |
1190 |
// Approve geolocation from lead table
|
|
|
1191 |
$(document).on('click', '.approve-geo', function (e) {
|
|
|
1192 |
e.stopPropagation();
|
|
|
1193 |
var lid = $(this).data('leadid');
|
|
|
1194 |
if (!confirm('Approve geolocation for Lead #' + lid + '?')) return;
|
|
|
1195 |
|
|
|
1196 |
var btn = $(this);
|
|
|
1197 |
var cell = btn.closest('td');
|
|
|
1198 |
|
|
|
1199 |
doPostAjaxRequestWithParamsHandler(
|
|
|
1200 |
context + '/lead-geo/review',
|
|
|
1201 |
{leadId: lid, status: 'APPROVED', remark: ''},
|
|
|
1202 |
function (response) {
|
|
|
1203 |
cell.html('<span class="label label-success">Verified</span>');
|
|
|
1204 |
}
|
|
|
1205 |
);
|
|
|
1206 |
});
|
|
|
1207 |
|
|
|
1208 |
// Reject geolocation from lead table
|
|
|
1209 |
$(document).on('click', '.reject-geo', function (e) {
|
|
|
1210 |
e.stopPropagation();
|
|
|
1211 |
var lid = $(this).data('leadid');
|
|
|
1212 |
var reason = prompt('Reason for rejection:');
|
|
|
1213 |
if (reason === null) return;
|
|
|
1214 |
|
|
|
1215 |
var btn = $(this);
|
|
|
1216 |
var cell = btn.closest('td');
|
|
|
1217 |
|
|
|
1218 |
doPostAjaxRequestWithParamsHandler(
|
|
|
1219 |
context + '/lead-geo/review',
|
|
|
1220 |
{leadId: lid, status: 'REJECTED', remark: reason},
|
|
|
1221 |
function (response) {
|
|
|
1222 |
cell.html('<button class="btn btn-xs btn-warning generateGeoLink" data-leadid="' + lid + '">Rejected - Resend</button>');
|
|
|
1223 |
}
|
|
|
1224 |
);
|
|
|
1225 |
});
|
|
|
1226 |
|