| 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 |
|
| 37046 |
aman |
82 |
// Lead-table Search boxes (top DataTables box + bottom mirror below the table/pagination) =
|
|
|
83 |
// GLOBAL partner search: matches ANY lead by name / mobile / outlet / city across ALL statuses
|
|
|
84 |
// and ALL dates (this year, last year, anytime) - not just the loaded date-scoped rows. It
|
|
|
85 |
// searches AS YOU TYPE (debounced) so old partners surface without needing to press Enter;
|
|
|
86 |
// Enter still triggers an immediate search. Results render into #global-search-results above
|
|
|
87 |
// the date-scoped table; the view auto-scrolls there so a search from the bottom box is visible
|
|
|
88 |
// without the user having to scroll back up manually.
|
|
|
89 |
var LEAD_SEARCH_BOXES = "#lead-table_filter input, #lead-table-bottom-filter";
|
| 37021 |
aman |
90 |
var leadGlobalSearchTimer = null;
|
|
|
91 |
|
| 37048 |
ranu |
92 |
function clearInjectedGlobalRows() {
|
|
|
93 |
if ($.fn.dataTable.isDataTable('#lead-table')) {
|
|
|
94 |
$('#lead-table').DataTable()
|
|
|
95 |
.rows('.global-search-row')
|
|
|
96 |
.remove()
|
|
|
97 |
.draw(false);
|
|
|
98 |
}
|
|
|
99 |
}
|
|
|
100 |
|
| 37050 |
ranu |
101 |
// Exposed so handlers outside the $(function () { ... }) scope (e.g. #vrSendBtn) can
|
|
|
102 |
// refresh the search view after they mutate a lead.
|
|
|
103 |
window.runGlobalLeadSearch = function (term) {
|
|
|
104 |
runGlobalLeadSearch(term);
|
|
|
105 |
};
|
|
|
106 |
|
| 37021 |
aman |
107 |
function runGlobalLeadSearch(term) {
|
|
|
108 |
term = $.trim(term || "");
|
|
|
109 |
if (term.length < 2) {
|
|
|
110 |
$('#global-search-results').html("");
|
| 37048 |
ranu |
111 |
clearInjectedGlobalRows();
|
| 37021 |
aman |
112 |
return;
|
|
|
113 |
}
|
|
|
114 |
var safeTerm = $('<div>').text(term).html();
|
|
|
115 |
doGetAjaxRequestHandler(context + "/globalLeadSearch?searchTerm=" + encodeURIComponent(term),
|
|
|
116 |
function (response) {
|
|
|
117 |
$('#global-search-results').html(
|
|
|
118 |
'<h4 style="margin:15px 0 8px;">Search results — all partners, any date '
|
|
|
119 |
+ '<small class="text-muted">(matching "' + safeTerm + '")</small></h4>' + response);
|
| 37046 |
aman |
120 |
var resultsEl = document.getElementById('global-search-results');
|
|
|
121 |
if (resultsEl) {
|
|
|
122 |
resultsEl.scrollIntoView({behavior: 'smooth', block: 'start'});
|
|
|
123 |
}
|
| 37048 |
ranu |
124 |
|
|
|
125 |
// Mirror the hits into the main #lead-table so the same row is findable there too.
|
|
|
126 |
// Rows carry class .global-search-row so we can clear them on the next search.
|
|
|
127 |
clearInjectedGlobalRows();
|
|
|
128 |
var $hiddenRows = $('#global-search-main-rows tbody tr');
|
|
|
129 |
if ($hiddenRows.length && $.fn.dataTable.isDataTable('#lead-table')) {
|
|
|
130 |
var dt = $('#lead-table').DataTable();
|
| 37050 |
ranu |
131 |
// Collect lead ids already in the main table (from the initial date-scoped
|
|
|
132 |
// render) so we don't inject a duplicate row for the same lead.
|
|
|
133 |
var existingIds = {};
|
|
|
134 |
dt.rows().nodes().to$().each(function () {
|
|
|
135 |
var id = $(this).attr('data');
|
|
|
136 |
if (id) existingIds[id] = true;
|
|
|
137 |
});
|
| 37048 |
ranu |
138 |
$hiddenRows.each(function () {
|
| 37050 |
ranu |
139 |
var id = $(this).attr('data');
|
|
|
140 |
if (id && existingIds[id]) return;
|
| 37048 |
ranu |
141 |
dt.row.add(this);
|
|
|
142 |
});
|
|
|
143 |
dt.draw(false);
|
|
|
144 |
}
|
| 37021 |
aman |
145 |
});
|
|
|
146 |
}
|
|
|
147 |
|
| 37046 |
aman |
148 |
$(document).on('keydown', LEAD_SEARCH_BOXES, function (e) {
|
| 36984 |
aman |
149 |
if (e.which === 13) {
|
|
|
150 |
e.preventDefault();
|
| 37021 |
aman |
151 |
clearTimeout(leadGlobalSearchTimer);
|
|
|
152 |
runGlobalLeadSearch($(this).val());
|
| 36984 |
aman |
153 |
}
|
|
|
154 |
});
|
| 34650 |
aman.kumar |
155 |
|
| 37046 |
aman |
156 |
$(document).on('input', LEAD_SEARCH_BOXES, function () {
|
| 37021 |
aman |
157 |
var term = $(this).val();
|
|
|
158 |
clearTimeout(leadGlobalSearchTimer);
|
|
|
159 |
leadGlobalSearchTimer = setTimeout(function () {
|
|
|
160 |
runGlobalLeadSearch(term);
|
|
|
161 |
}, 350);
|
| 36984 |
aman |
162 |
});
|
|
|
163 |
|
| 37046 |
aman |
164 |
// Bottom box isn't a native DataTables filter element, so mirror it into the DataTable's own
|
|
|
165 |
// search + keep both boxes showing the same value regardless of which one the user typed into.
|
|
|
166 |
$(document).on('keyup input', '#lead-table-bottom-filter', function () {
|
|
|
167 |
var term = $(this).val();
|
|
|
168 |
$('#lead-table_filter input').val(term);
|
|
|
169 |
if ($.fn.dataTable.isDataTable('#lead-table')) {
|
|
|
170 |
$('#lead-table').DataTable().search(term).draw();
|
|
|
171 |
}
|
|
|
172 |
});
|
| 36984 |
aman |
173 |
|
| 37046 |
aman |
174 |
$(document).on('keyup input', '#lead-table_filter input', function () {
|
|
|
175 |
$('#lead-table-bottom-filter').val($(this).val());
|
|
|
176 |
});
|
|
|
177 |
|
|
|
178 |
|
| 35548 |
aman |
179 |
$(document).on('click', ".visit-request-plan", function () {
|
| 34650 |
aman.kumar |
180 |
|
| 35548 |
aman |
181 |
doGetAjaxRequestHandler(context + "/visitPlan", function (response) {
|
|
|
182 |
$('#' + 'main-content').html(response);
|
|
|
183 |
});
|
| 34650 |
aman.kumar |
184 |
|
| 35548 |
aman |
185 |
});
|
| 34650 |
aman.kumar |
186 |
|
| 35548 |
aman |
187 |
$(document).on('click', ".visitPlan", function () {
|
| 25980 |
tejbeer |
188 |
|
| 35548 |
aman |
189 |
let dateWisePlan = $("#dateVisitSearch").val();
|
| 31249 |
tejbeer |
190 |
|
| 35548 |
aman |
191 |
doGetAjaxRequestHandler(context + "/visit/getVisitPlan?date=" + dateWisePlan, function (response) {
|
|
|
192 |
$('#' + 'main-content').html(response);
|
|
|
193 |
});
|
| 31249 |
tejbeer |
194 |
|
| 35548 |
aman |
195 |
});
|
| 31249 |
tejbeer |
196 |
|
| 35548 |
aman |
197 |
$(document).on('click', ".lead-close", function () {
|
|
|
198 |
loadClosedLead("main-content");
|
|
|
199 |
});
|
| 31249 |
tejbeer |
200 |
|
| 35548 |
aman |
201 |
$(document).on('click', "#lead-close-paginated .next",
|
|
|
202 |
function () {
|
| 31249 |
tejbeer |
203 |
|
| 35548 |
aman |
204 |
var searchText = $("#authUser").val();
|
|
|
205 |
// var searchTxt=$("#scheme-search-text").val();
|
|
|
206 |
console.log(searchText);
|
|
|
207 |
if (typeof (searchText) == "undefined" || !searchText) {
|
|
|
208 |
searchText = "";
|
|
|
209 |
}
|
| 31249 |
tejbeer |
210 |
|
| 35548 |
aman |
211 |
if ((searchText)) {
|
|
|
212 |
var params = {};
|
|
|
213 |
params['searchTerm'] = searchText;
|
|
|
214 |
loadPaginatedNextItems('/searchLeadPaginated', params,
|
|
|
215 |
'lead-close-paginated', 'close-lead-table',
|
|
|
216 |
'lead-close-container');
|
|
|
217 |
} else {
|
| 31249 |
tejbeer |
218 |
|
| 35548 |
aman |
219 |
loadPaginatedNextItems('/getPaginatedClosedLeads', null,
|
|
|
220 |
'lead-close-paginated', 'close-lead-table',
|
|
|
221 |
'lead-close-container');
|
|
|
222 |
}
|
|
|
223 |
$(this).blur();
|
|
|
224 |
});
|
| 31249 |
tejbeer |
225 |
|
| 35548 |
aman |
226 |
$(document).on('click', "#lead-close-paginated .previous",
|
|
|
227 |
function () {
|
|
|
228 |
var searchText = $("#authUser").val();
|
|
|
229 |
// var searchTxt=$("#scheme-search-text").val();
|
|
|
230 |
console.log(searchText);
|
|
|
231 |
if (typeof (searchText) == "undefined" || !searchText) {
|
|
|
232 |
searchText = "";
|
|
|
233 |
}
|
| 25988 |
tejbeer |
234 |
|
| 35548 |
aman |
235 |
if ((searchText)) {
|
|
|
236 |
var params = {};
|
|
|
237 |
params['searchTerm'] = searchText;
|
|
|
238 |
loadPaginatedPreviousItems('/searchLeadPaginated', params,
|
|
|
239 |
'lead-close-paginated', 'close-lead-table',
|
|
|
240 |
'lead-close-container');
|
|
|
241 |
} else {
|
|
|
242 |
loadPaginatedPreviousItems('/getPaginatedClosedLeads',
|
|
|
243 |
null, 'lead-close-paginated', 'close-lead-table',
|
|
|
244 |
'lead-close-container');
|
|
|
245 |
}
|
|
|
246 |
$(this).blur();
|
|
|
247 |
});
|
| 25988 |
tejbeer |
248 |
|
| 35548 |
aman |
249 |
$(document).on('click', "#close-lead-search-button", function () {
|
|
|
250 |
var searchText = $("#authUser").val();
|
|
|
251 |
if (typeof (searchText) == "undefined" || !searchText) {
|
|
|
252 |
searchText = "";
|
|
|
253 |
}
|
|
|
254 |
loadLeadSearchInfo(searchText);
|
|
|
255 |
});
|
| 25988 |
tejbeer |
256 |
|
| 35548 |
aman |
257 |
$(document).on("keyup", "#authUser", function (e) {
|
|
|
258 |
var keyCode = e.keyCode || e.which;
|
|
|
259 |
if (keyCode == 13) {
|
|
|
260 |
$("#close-lead-search-button").click();
|
|
|
261 |
}
|
|
|
262 |
});
|
|
|
263 |
$(document).on('click', ".view",
|
|
|
264 |
function () {
|
|
|
265 |
var id = $(this).data('requestid');
|
|
|
266 |
console.log(id);
|
|
|
267 |
doGetAjaxRequestHandler(context + "/getLeadActivity?leadId="
|
|
|
268 |
+ id, function (response) {
|
| 25988 |
tejbeer |
269 |
|
| 35548 |
aman |
270 |
console.log(response)
|
| 25988 |
tejbeer |
271 |
|
| 35548 |
aman |
272 |
$('#fetchLeadActivityData .modal-content').html(response);
|
| 25988 |
tejbeer |
273 |
|
| 35548 |
aman |
274 |
});
|
|
|
275 |
});
|
| 25988 |
tejbeer |
276 |
|
| 35548 |
aman |
277 |
$(document).on('click', ".newLead", function () {
|
|
|
278 |
$('#newEntryLeadModal').modal('show');
|
|
|
279 |
$("#scheduleTime").hide();
|
|
|
280 |
});
|
| 25988 |
tejbeer |
281 |
|
| 35548 |
aman |
282 |
$(document).on('click', ".show-lead", function () {
|
|
|
283 |
var status = $("#statusFilter").val();
|
|
|
284 |
doGetAjaxRequestHandler(context + "/getOpenLead?leadStatus=" + status, function (response) {
|
|
|
285 |
$('#' + 'main-content').html(response);
|
|
|
286 |
});
|
|
|
287 |
});
|
| 25980 |
tejbeer |
288 |
|
| 31370 |
tejbeer |
289 |
|
| 35548 |
aman |
290 |
$(document).on('click', ".show-colowise-lead", function () {
|
|
|
291 |
var status = $("#statusFilter").val();
|
|
|
292 |
var color = $("#colorFilter").val();
|
|
|
293 |
doGetAjaxRequestHandler(context + "/getOpenLead?leadStatus=" + status + "&color=" + color, function (response) {
|
|
|
294 |
$('#' + 'main-content').html(response);
|
|
|
295 |
});
|
|
|
296 |
});
|
| 25980 |
tejbeer |
297 |
|
| 35548 |
aman |
298 |
$(document).on('click', "#uploadIvoryLead", function () {
|
| 25980 |
tejbeer |
299 |
|
| 35548 |
aman |
300 |
window.location.href = context + "/downloadIvoryLead";
|
|
|
301 |
});
|
| 25980 |
tejbeer |
302 |
|
| 35548 |
aman |
303 |
$(document).on('click', ".submitLeadGenerate", function () {
|
| 27609 |
tejbeer |
304 |
|
| 35548 |
aman |
305 |
console.log("hello");
|
|
|
306 |
if (confirm('Confirm upload ?')) {
|
|
|
307 |
var fileSelector = $(this)[0];
|
|
|
308 |
if (fileSelector != undefined) {
|
|
|
309 |
var url = `${context}/csvFileAndSetLead`;
|
|
|
310 |
console.log(url);
|
|
|
311 |
var file = $(".fileLeadGenerate")[0].files[0];
|
|
|
312 |
let fileInput = $(this);
|
|
|
313 |
console.log("file" + file);
|
|
|
314 |
console.log("fileInput" + fileInput);
|
|
|
315 |
doAjaxUploadRequestHandler(
|
|
|
316 |
url,
|
|
|
317 |
'POST',
|
|
|
318 |
file, function (response) {
|
| 27642 |
tejbeer |
319 |
|
| 35548 |
aman |
320 |
console.log("reponse" + response);
|
| 31370 |
tejbeer |
321 |
|
| 35548 |
aman |
322 |
if (response == true) {
|
|
|
323 |
alert("successfully uploaded");
|
| 31370 |
tejbeer |
324 |
|
|
|
325 |
|
| 35548 |
aman |
326 |
}
|
|
|
327 |
});
|
| 29598 |
tejbeer |
328 |
|
| 35548 |
aman |
329 |
}
|
|
|
330 |
} else {
|
|
|
331 |
// Do nothing!
|
|
|
332 |
}
|
|
|
333 |
});
|
| 27642 |
tejbeer |
334 |
|
|
|
335 |
|
| 35548 |
aman |
336 |
$(document).on('click', ".lead-request",
|
|
|
337 |
function () {
|
| 29598 |
tejbeer |
338 |
|
| 35548 |
aman |
339 |
var firstName = $('input[name="firstName"]').val();
|
|
|
340 |
var lastName = $('input[name="lastName"]').val();
|
|
|
341 |
var mobile = $('input[name="mobile"]').val();
|
|
|
342 |
var address = $('input[name="address"]').val();
|
|
|
343 |
var status = $("#status").val();
|
|
|
344 |
var city = $('input[name="city"]').val();
|
|
|
345 |
var state = $("#state").val();
|
|
|
346 |
var remark = $("#createRemark").val();
|
|
|
347 |
var assignTo = $("#createAssignTo").val();
|
|
|
348 |
var source = $("#leadSource").val();
|
|
|
349 |
var communicationType = $("#communicationTye").val();
|
| 29427 |
manish |
350 |
|
| 35548 |
aman |
351 |
var conversionprobability = $("#conversionprobabilit").val();
|
| 29598 |
tejbeer |
352 |
|
|
|
353 |
|
| 35548 |
aman |
354 |
var outletName = $('input[name="leadoutletName"]').val();
|
|
|
355 |
var counterSize = $('input[name="leadcounterSize"]').val();
|
|
|
356 |
var table = document.getElementById('brandtable');
|
|
|
357 |
var brandValueJson = [];
|
|
|
358 |
var leadBrands;
|
| 29598 |
tejbeer |
359 |
|
| 35548 |
aman |
360 |
console.log(conversionprobability)
|
| 29598 |
tejbeer |
361 |
|
|
|
362 |
|
| 35548 |
aman |
363 |
if (firstName === "" && lastName === "" && mobile === ""
|
|
|
364 |
&& address === "" && status === "" && city === ""
|
|
|
365 |
&& state === "" && remark === "" && source === "") {
|
|
|
366 |
alert("Field can't be empty");
|
|
|
367 |
return;
|
|
|
368 |
}
|
| 29598 |
tejbeer |
369 |
|
| 25980 |
tejbeer |
370 |
|
| 35548 |
aman |
371 |
if (firstName === "") {
|
|
|
372 |
alert("First Name is required");
|
|
|
373 |
return;
|
|
|
374 |
}
|
|
|
375 |
if (lastName === "") {
|
|
|
376 |
alert("Last Name is required");
|
|
|
377 |
return;
|
|
|
378 |
}
|
|
|
379 |
if (mobile === "") {
|
|
|
380 |
alert("Mobile is required");
|
|
|
381 |
return;
|
|
|
382 |
}
|
|
|
383 |
if (status === "") {
|
|
|
384 |
alert("Status is required");
|
|
|
385 |
return;
|
|
|
386 |
}
|
|
|
387 |
if (address === "") {
|
|
|
388 |
alert("address is required");
|
|
|
389 |
return;
|
|
|
390 |
}
|
|
|
391 |
if (city === "") {
|
|
|
392 |
alert("city is required");
|
|
|
393 |
return;
|
|
|
394 |
}
|
| 32471 |
tejbeer |
395 |
|
| 35548 |
aman |
396 |
if (state === "") {
|
|
|
397 |
alert("state is required");
|
|
|
398 |
return;
|
|
|
399 |
}
|
|
|
400 |
if (source === "") {
|
|
|
401 |
alert("Source is required")
|
|
|
402 |
return;
|
|
|
403 |
}
|
| 32471 |
tejbeer |
404 |
|
| 35548 |
aman |
405 |
if (remark === "") {
|
|
|
406 |
alert("Remark is required");
|
|
|
407 |
return;
|
|
|
408 |
}
|
| 32471 |
tejbeer |
409 |
|
| 35548 |
aman |
410 |
if (conversionprobability === "") {
|
|
|
411 |
alert("Conversion Probability is required");
|
|
|
412 |
return;
|
|
|
413 |
}
|
|
|
414 |
if (status == "followUp" || status == "pending" || status == "finalized") {
|
|
|
415 |
if (outletName === "") {
|
|
|
416 |
alert("Outlet Name is required");
|
|
|
417 |
return;
|
|
|
418 |
}
|
| 25980 |
tejbeer |
419 |
|
| 35548 |
aman |
420 |
if (counterSize === "") {
|
|
|
421 |
alert("Counter Size is required");
|
|
|
422 |
return;
|
|
|
423 |
}
|
| 32464 |
tejbeer |
424 |
|
| 35548 |
aman |
425 |
if (localStorage.getItem("frontph") == "undefined" && localStorage.getItem("frontph") == null) {
|
|
|
426 |
alert("Front Document is required");
|
|
|
427 |
return;
|
|
|
428 |
}
|
| 32464 |
tejbeer |
429 |
|
| 35548 |
aman |
430 |
if (localStorage.getItem("internalMarketh") == "undefined" || localStorage.getItem("internalMarketh") == null) {
|
|
|
431 |
alert("Front With Market Document is required");
|
|
|
432 |
return;
|
|
|
433 |
}
|
| 25980 |
tejbeer |
434 |
|
| 35548 |
aman |
435 |
if (localStorage.getItem("leftShoth") == "undefined" || localStorage.getItem("leftShoth") == null) {
|
|
|
436 |
alert("Internal Left Shot Document is required");
|
|
|
437 |
return;
|
|
|
438 |
}
|
| 32464 |
tejbeer |
439 |
|
| 35548 |
aman |
440 |
if (localStorage.getItem("leftWallh") == "undefined" || localStorage.getItem("leftWallh") == null) {
|
|
|
441 |
alert("Internal Left Wall Document is required");
|
|
|
442 |
return;
|
|
|
443 |
}
|
| 25980 |
tejbeer |
444 |
|
|
|
445 |
|
| 35548 |
aman |
446 |
if (localStorage.getItem("rightWallh") == "undefined" || localStorage.getItem("rightWallh") == null) {
|
|
|
447 |
alert("Internal Right Wall Document is required");
|
|
|
448 |
return;
|
|
|
449 |
}
|
| 25980 |
tejbeer |
450 |
|
| 32464 |
tejbeer |
451 |
|
| 35548 |
aman |
452 |
for (i = 1; i < table.rows.length; i++) {
|
| 32464 |
tejbeer |
453 |
|
| 35548 |
aman |
454 |
var objCells = table.rows[i].cells;
|
| 32464 |
tejbeer |
455 |
|
| 35548 |
aman |
456 |
leadBrands = {
|
|
|
457 |
brand: objCells[0].innerText,
|
|
|
458 |
value: objCells[1].getElementsByTagName('input')[0].value
|
|
|
459 |
}
|
|
|
460 |
brandValueJson.push(leadBrands);
|
|
|
461 |
}
|
| 32464 |
tejbeer |
462 |
|
|
|
463 |
|
| 35548 |
aman |
464 |
}
|
| 32464 |
tejbeer |
465 |
|
|
|
466 |
|
| 35548 |
aman |
467 |
var leaddetailData = {}
|
|
|
468 |
leaddetailData['firstName'] = firstName;
|
|
|
469 |
leaddetailData['lastName'] = lastName
|
|
|
470 |
leaddetailData['mobile'] = mobile
|
|
|
471 |
leaddetailData['address'] = address
|
|
|
472 |
leaddetailData['city'] = city
|
|
|
473 |
leaddetailData['state'] = state
|
|
|
474 |
leaddetailData['status'] = status
|
|
|
475 |
leaddetailData['remark'] = remark
|
|
|
476 |
leaddetailData['assignTo'] = assignTo
|
|
|
477 |
leaddetailData['source'] = source
|
|
|
478 |
leaddetailData['colorCheck'] = conversionprobability
|
| 32464 |
tejbeer |
479 |
|
|
|
480 |
|
| 35548 |
aman |
481 |
if (status == "followUp") {
|
|
|
482 |
leaddetailData['schelduleTimestamp'] = getDatesFromPicker('#scheduleTime').startDate;
|
| 32464 |
tejbeer |
483 |
|
| 35548 |
aman |
484 |
leaddetailData['communicationType'] = communicationType
|
|
|
485 |
}
|
| 32464 |
tejbeer |
486 |
|
|
|
487 |
|
| 35548 |
aman |
488 |
leaddetailData['outletName'] = outletName;
|
| 32464 |
tejbeer |
489 |
|
| 35548 |
aman |
490 |
leaddetailData['counterSize'] = counterSize;
|
| 32464 |
tejbeer |
491 |
|
|
|
492 |
|
| 35548 |
aman |
493 |
leaddetailData['leadBrands'] = brandValueJson;
|
| 32464 |
tejbeer |
494 |
|
| 35548 |
aman |
495 |
console.log(localStorage.getItem("frontp"));
|
| 32464 |
tejbeer |
496 |
|
|
|
497 |
|
| 35548 |
aman |
498 |
leaddetailData['frontp'] = localStorage
|
|
|
499 |
.getItem("frontph");
|
| 31249 |
tejbeer |
500 |
|
| 32464 |
tejbeer |
501 |
|
| 35548 |
aman |
502 |
leaddetailData['frontWithMarket'] = localStorage
|
|
|
503 |
.getItem("internalMarketh");
|
| 32464 |
tejbeer |
504 |
|
|
|
505 |
|
| 35548 |
aman |
506 |
leaddetailData['internalLongShot'] = localStorage
|
|
|
507 |
.getItem("leftShoth");
|
| 32464 |
tejbeer |
508 |
|
|
|
509 |
|
| 35548 |
aman |
510 |
leaddetailData['internalLeftWall'] = localStorage
|
|
|
511 |
.getItem("leftWallh");
|
| 32464 |
tejbeer |
512 |
|
|
|
513 |
|
| 35548 |
aman |
514 |
leaddetailData['internalRightWall'] = localStorage
|
|
|
515 |
.getItem("rightWallh");
|
| 32464 |
tejbeer |
516 |
|
| 35548 |
aman |
517 |
console.log(leaddetailData);
|
| 32464 |
tejbeer |
518 |
|
| 35548 |
aman |
519 |
if (confirm("Are you sure you want to add lead!") == true) {
|
|
|
520 |
doPostAjaxRequestWithJsonHandler(context + "/createLead",
|
|
|
521 |
JSON.stringify(leaddetailData), function (response) {
|
|
|
522 |
if (response == 'true') {
|
|
|
523 |
alert("successfully Add");
|
|
|
524 |
$('#newEntryLeadModal').modal('hide');
|
|
|
525 |
$('.modal-backdrop').remove();
|
|
|
526 |
loadLead("main-content");
|
|
|
527 |
} else {
|
|
|
528 |
alert(response);
|
|
|
529 |
}
|
|
|
530 |
});
|
| 32464 |
tejbeer |
531 |
|
| 35548 |
aman |
532 |
return false;
|
|
|
533 |
}
|
|
|
534 |
});
|
| 36642 |
ranu |
535 |
window.leadId = null;
|
| 35548 |
aman |
536 |
var row = null;
|
| 37003 |
ranu |
537 |
// Turn Assign To into a search-select. We attempt initialisation at 3 points to be
|
|
|
538 |
// robust against ordering / DOM-timing issues:
|
|
|
539 |
// 1. Immediately at load time (element is in DOM per lead.vm)
|
|
|
540 |
// 2. On the modal's shown.bs.modal event (post-transition)
|
|
|
541 |
// 3. As a fallback in the click handler with a small delay
|
|
|
542 |
function initAssignToSelect2() {
|
|
|
543 |
if (!$.fn.select2) {
|
|
|
544 |
console.warn('[lead.js] select2 not loaded — falling back to native <select>');
|
|
|
545 |
return;
|
|
|
546 |
}
|
|
|
547 |
var $assign = $('#assignTo');
|
|
|
548 |
if ($assign.length === 0) return;
|
|
|
549 |
if ($assign.hasClass('select2-hidden-accessible')) return; // already applied
|
|
|
550 |
$assign.select2({
|
|
|
551 |
placeholder: 'Assign To',
|
|
|
552 |
allowClear: true,
|
|
|
553 |
width: '100%',
|
|
|
554 |
dropdownParent: $('#editLeadData'),
|
|
|
555 |
// Hide disabled options — VISIT/TELEPHONIC filter uses .prop('disabled', true).
|
|
|
556 |
matcher: function (params, data) {
|
|
|
557 |
if (data.element && $(data.element).prop('disabled')) return null;
|
|
|
558 |
if (!params.term || $.trim(params.term) === '') return data;
|
|
|
559 |
if (data.text && data.text.toLowerCase().indexOf(params.term.toLowerCase()) > -1) return data;
|
|
|
560 |
return null;
|
|
|
561 |
}
|
|
|
562 |
});
|
|
|
563 |
console.log('[lead.js] select2 applied to #assignTo');
|
|
|
564 |
}
|
|
|
565 |
|
|
|
566 |
initAssignToSelect2();
|
|
|
567 |
$(document).on('shown.bs.modal', '#editLeadData', initAssignToSelect2);
|
|
|
568 |
|
| 35548 |
aman |
569 |
$(document).on('click', ".editLead", function () {
|
|
|
570 |
$('#editLeadData').modal('show');
|
| 37003 |
ranu |
571 |
// Belt-and-braces: also try after the modal transition completes.
|
|
|
572 |
setTimeout(initAssignToSelect2, 300);
|
| 32464 |
tejbeer |
573 |
|
| 35548 |
aman |
574 |
$("#remark").val("");
|
| 37003 |
ranu |
575 |
$("#assignTo").val("").trigger('change');
|
| 35548 |
aman |
576 |
$("#editStatus").val("");
|
|
|
577 |
$("#reason").val("");
|
|
|
578 |
$("#editCity").val("");
|
|
|
579 |
$("#editState").val("");
|
| 35769 |
amit |
580 |
$("#editSource").val("");
|
| 35548 |
aman |
581 |
$("#editScheduleTime").hide();
|
| 32464 |
tejbeer |
582 |
|
|
|
583 |
|
| 35548 |
aman |
584 |
localStorage.removeItem("frontph");
|
|
|
585 |
localStorage.removeItem("leftShoth");
|
|
|
586 |
localStorage.removeItem("rightWallh");
|
|
|
587 |
localStorage.removeItem("leftWallh");
|
|
|
588 |
localStorage.removeItem("internalMarketh");
|
| 32464 |
tejbeer |
589 |
|
| 35548 |
aman |
590 |
row = $(this).closest("tr");
|
|
|
591 |
leadId = $(this).data('leadid');
|
| 32464 |
tejbeer |
592 |
|
| 35548 |
aman |
593 |
doAjaxRequestHandler(
|
|
|
594 |
context + "/getLeadDetailByLeadId?leadId=" + leadId,
|
|
|
595 |
"GET",
|
|
|
596 |
function (response) {
|
| 32464 |
tejbeer |
597 |
|
| 35548 |
aman |
598 |
var data = response.response;
|
|
|
599 |
if (!data) return;
|
|
|
600 |
console.log(data);
|
|
|
601 |
$("#editCity").val(data.city);
|
|
|
602 |
$("#editState").val(data.state);
|
|
|
603 |
$("input[name='outletName']").val(data.outletName);
|
|
|
604 |
$("input[name='counterSize']").val(data.counterSize);
|
|
|
605 |
}
|
|
|
606 |
);
|
|
|
607 |
});
|
| 32464 |
tejbeer |
608 |
|
|
|
609 |
|
| 35548 |
aman |
610 |
$(document).on('click', ".lead-edit-request",
|
|
|
611 |
function () {
|
| 32464 |
tejbeer |
612 |
|
| 36761 |
ranu |
613 |
// Gate the assign/status submit on approved geo. Modal stays open so the
|
|
|
614 |
// user can still work the other sub-forms (lead detail, etc.).
|
|
|
615 |
var clickedBtn = $(this);
|
| 36789 |
ranu |
616 |
// notInterested is a close-out — no geo / no beat / no assignee
|
|
|
617 |
// needed. Skip the geo gate and submit straight through with just
|
|
|
618 |
// the activity (status + reason + remark).
|
|
|
619 |
var currentStatus = $('#editStatus').val();
|
|
|
620 |
if (currentStatus === 'notInterested') {
|
|
|
621 |
submitLeadEdit();
|
|
|
622 |
return;
|
|
|
623 |
}
|
| 36792 |
ranu |
624 |
// Non-sales assignees (BGC / other internal hand-offs) don't need
|
|
|
625 |
// geo or a beat-day — the lead just routes to their queue. Skip the
|
|
|
626 |
// geo gate and submit straight through, same as the legacy flow.
|
|
|
627 |
var assigneeId = parseInt($('#assignTo').val(), 10);
|
|
|
628 |
var isSalesAssignee = !isNaN(assigneeId)
|
|
|
629 |
&& typeof salesUserIds !== 'undefined'
|
|
|
630 |
&& salesUserIds.indexOf(assigneeId) !== -1;
|
|
|
631 |
if (!isSalesAssignee) {
|
|
|
632 |
submitLeadEdit();
|
|
|
633 |
return;
|
|
|
634 |
}
|
| 36761 |
ranu |
635 |
if (clickedBtn.data('geoChecking')) return;
|
|
|
636 |
clickedBtn.data('geoChecking', true);
|
|
|
637 |
doAjaxRequestHandler(
|
|
|
638 |
context + "/lead-geo/check/" + leadId,
|
|
|
639 |
"GET",
|
|
|
640 |
function (response) {
|
|
|
641 |
clickedBtn.removeData('geoChecking');
|
|
|
642 |
var hasGeo = response && response.response && response.response.hasApprovedGeo;
|
|
|
643 |
if (!hasGeo) {
|
|
|
644 |
alert('Live geo-location for this lead has not been approved yet. Please approve the geo-location before assigning / updating status.');
|
|
|
645 |
return;
|
|
|
646 |
}
|
|
|
647 |
submitLeadEdit();
|
|
|
648 |
}
|
|
|
649 |
);
|
|
|
650 |
});
|
| 25980 |
tejbeer |
651 |
|
| 36761 |
ranu |
652 |
function submitLeadEdit() {
|
|
|
653 |
|
| 35548 |
aman |
654 |
console.log(row);
|
|
|
655 |
var remark = $('input[name="remark"]').val();
|
|
|
656 |
var assignTo = $("#assignTo").val();
|
|
|
657 |
var editStatus = $("#editStatus").val();
|
|
|
658 |
var city = $('input[name="editCity"]').val();
|
|
|
659 |
var state = $("#editState").val();
|
|
|
660 |
var reason = $("#reason").val();
|
| 25980 |
tejbeer |
661 |
|
| 35769 |
amit |
662 |
var startDate = $("#startDate").val();
|
|
|
663 |
var endDate = $("#endDate").val();
|
| 35548 |
aman |
664 |
var leadStatus = $("#statusFilter").val();
|
|
|
665 |
var color = $("#colorFilter").val();
|
|
|
666 |
var communicationType = $("#communicationType").val();
|
| 29640 |
tejbeer |
667 |
|
| 35548 |
aman |
668 |
var conversionprobability = $("#conversionprobability").val();
|
| 35769 |
amit |
669 |
var editSource = $("#editSource").val();
|
| 29640 |
tejbeer |
670 |
|
| 35548 |
aman |
671 |
console.log(conversionprobability)
|
| 29640 |
tejbeer |
672 |
|
| 31473 |
tejbeer |
673 |
|
| 35769 |
amit |
674 |
console.log(startDate)
|
| 35548 |
aman |
675 |
console.log(leadStatus)
|
| 31370 |
tejbeer |
676 |
|
| 35548 |
aman |
677 |
console.log(color)
|
|
|
678 |
console.log(reason)
|
| 31370 |
tejbeer |
679 |
|
| 35548 |
aman |
680 |
if (remark === "" && assignTo === "" && editStatus === "") {
|
|
|
681 |
alert("All fields is required");
|
|
|
682 |
return;
|
|
|
683 |
}
|
| 31370 |
tejbeer |
684 |
|
| 36789 |
ranu |
685 |
// For notInterested (close-out) the lead doesn't need an assignee
|
|
|
686 |
// — it's just a status + reason + remark write. Only enforce
|
|
|
687 |
// assignTo for the other statuses where scheduling matters.
|
|
|
688 |
if (assignTo === "" && editStatus !== "notInterested") {
|
| 35548 |
aman |
689 |
alert("assignTo is required");
|
|
|
690 |
return;
|
|
|
691 |
}
|
| 31409 |
tejbeer |
692 |
|
| 35548 |
aman |
693 |
if (remark === "") {
|
|
|
694 |
alert("Remark is required");
|
|
|
695 |
return;
|
|
|
696 |
}
|
| 31370 |
tejbeer |
697 |
|
|
|
698 |
|
| 35548 |
aman |
699 |
if (editStatus === "") {
|
|
|
700 |
alert("status is required");
|
|
|
701 |
return;
|
|
|
702 |
}
|
| 31370 |
tejbeer |
703 |
|
| 35548 |
aman |
704 |
if (editStatus === "notInterested") {
|
| 36789 |
ranu |
705 |
if (reason == null || reason === "") {
|
| 35548 |
aman |
706 |
alert("Reason is required");
|
|
|
707 |
return;
|
|
|
708 |
}
|
|
|
709 |
}
|
|
|
710 |
var leadActivityData = {}
|
|
|
711 |
leadActivityData['id'] = leadId;
|
|
|
712 |
leadActivityData['remark'] = remark;
|
|
|
713 |
leadActivityData['assignTo'] = assignTo
|
|
|
714 |
leadActivityData['status'] = editStatus
|
|
|
715 |
leadActivityData['reason'] = reason
|
| 36741 |
ranu |
716 |
leadActivityData['colorCheck'] = (conversionprobability === "true" || conversionprobability === true)
|
| 35548 |
aman |
717 |
if (city && city.trim() !== "") {
|
|
|
718 |
leadActivityData.city = city;
|
|
|
719 |
}
|
| 25980 |
tejbeer |
720 |
|
| 35548 |
aman |
721 |
if (state && state.trim() !== "") {
|
|
|
722 |
leadActivityData.state = state;
|
|
|
723 |
}
|
| 29473 |
manish |
724 |
|
| 35769 |
amit |
725 |
if (editSource && editSource.trim() !== "") {
|
|
|
726 |
leadActivityData.source = editSource;
|
|
|
727 |
}
|
| 29598 |
tejbeer |
728 |
|
| 35769 |
amit |
729 |
|
| 35548 |
aman |
730 |
if (editStatus == "followUp") {
|
| 36642 |
ranu |
731 |
leadActivityData['communicationType'] = communicationType
|
| 36792 |
ranu |
732 |
var assigneeIdForBeat = parseInt(assignTo, 10);
|
|
|
733 |
var isSalesAssigneeForBeat = !isNaN(assigneeIdForBeat)
|
|
|
734 |
&& typeof salesUserIds !== 'undefined'
|
|
|
735 |
&& salesUserIds.indexOf(assigneeIdForBeat) !== -1;
|
| 36741 |
ranu |
736 |
var beatVal = $('#beatDate').val();
|
| 36792 |
ranu |
737 |
// Beat-day gate only applies to sales assignees. Non-sales
|
|
|
738 |
// (BGC / other) hand-offs are just routed to the user's queue
|
|
|
739 |
// without a beat attachment — same as the legacy flow.
|
|
|
740 |
if (isSalesAssigneeForBeat) {
|
|
|
741 |
if (!beatVal) {
|
|
|
742 |
var hasBadges = $('#beatBadges .beat-badge').length > 0;
|
|
|
743 |
if (!hasBadges) {
|
|
|
744 |
alert('No upcoming beat is available for this assignee. Cannot schedule the lead until they have a beat.');
|
|
|
745 |
} else {
|
|
|
746 |
alert('Please select a beat date for the assignee before submitting.');
|
|
|
747 |
}
|
|
|
748 |
return;
|
| 36761 |
ranu |
749 |
}
|
| 36792 |
ranu |
750 |
var beatDate = beatVal.split('|')[0];
|
|
|
751 |
leadActivityData['scheldule'] = beatDate + 'T12:00:00';
|
|
|
752 |
leadActivityData['beatSelection'] = beatVal;
|
| 37064 |
ranu |
753 |
} else {
|
|
|
754 |
// Non-sales assignee: no beat-day panel. Fall back to the manual
|
|
|
755 |
// #editScheduleTime picker so the user's chosen date/time is still
|
|
|
756 |
// persisted on lead_activity.schedule_timestamp.
|
|
|
757 |
try {
|
|
|
758 |
var picker = $('#editScheduleTime').data('daterangepicker');
|
|
|
759 |
if (picker && picker.startDate) {
|
|
|
760 |
leadActivityData['scheldule'] = picker.startDate.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
|
|
|
761 |
}
|
|
|
762 |
} catch (e) {
|
|
|
763 |
// no picker attached / no date — leave scheldule unset
|
|
|
764 |
}
|
| 36642 |
ranu |
765 |
}
|
| 35548 |
aman |
766 |
}
|
| 29598 |
tejbeer |
767 |
|
| 35548 |
aman |
768 |
console.log(leadActivityData);
|
|
|
769 |
if (confirm("Are you sure you want to add lead!") == true) {
|
|
|
770 |
doPostAjaxRequestWithJsonHandler(context + "/editLead", JSON.stringify(leadActivityData), function (response) {
|
|
|
771 |
console.log(response);
|
|
|
772 |
$('#editLeadData').modal('hide');
|
|
|
773 |
$('.modal-backdrop').remove();
|
| 37050 |
ranu |
774 |
// Inline row replace only works when the row's column layout matches the
|
|
|
775 |
// main #lead-table (that's what edit-lead.vm renders for). The upper
|
|
|
776 |
// search-results table has fewer columns, so let the search re-run
|
|
|
777 |
// repaint it cleanly instead.
|
|
|
778 |
if (row && !row.closest('#global-search-results').length) {
|
|
|
779 |
row.html(response);
|
|
|
780 |
}
|
|
|
781 |
var activeTerm = $.trim($('#lead-table_filter input').val() || $('#lead-table-bottom-filter').val() || "");
|
|
|
782 |
if (activeTerm.length >= 2 && $('#global-search-results').children().length) {
|
|
|
783 |
runGlobalLeadSearch(activeTerm);
|
|
|
784 |
}
|
| 35548 |
aman |
785 |
});
|
|
|
786 |
}
|
| 29598 |
tejbeer |
787 |
|
| 36761 |
ranu |
788 |
}
|
| 32477 |
tejbeer |
789 |
|
|
|
790 |
|
| 35548 |
aman |
791 |
$(document).on('click', ".show-partner-health",
|
|
|
792 |
function () {
|
| 29598 |
tejbeer |
793 |
|
| 35548 |
aman |
794 |
var email = $("#authUserFilter").val();
|
| 25980 |
tejbeer |
795 |
|
| 35548 |
aman |
796 |
console.log(email)
|
|
|
797 |
doGetAjaxRequestHandler(context + "/partnerHealth?email="
|
|
|
798 |
+ email, function (response) {
|
|
|
799 |
console.log(response)
|
|
|
800 |
$('#' + 'main-content').html(response);
|
| 25980 |
tejbeer |
801 |
|
| 35548 |
aman |
802 |
});
|
|
|
803 |
});
|
| 25980 |
tejbeer |
804 |
|
|
|
805 |
|
| 35548 |
aman |
806 |
$(document).on('click', ".lead-detail-entry",
|
|
|
807 |
function () {
|
| 28200 |
tejbeer |
808 |
|
| 35548 |
aman |
809 |
console.log("hello");
|
|
|
810 |
var outletName = $('input[name="outletName"]').val();
|
|
|
811 |
var counterSize = $('input[name="counterSize"]').val();
|
|
|
812 |
var table = document.getElementById('editbrandtable');
|
|
|
813 |
var brandValueJson = [];
|
|
|
814 |
var leadBrands;
|
| 25980 |
tejbeer |
815 |
|
| 35548 |
aman |
816 |
if (outletName === "") {
|
|
|
817 |
alert("Outlet Name is required");
|
|
|
818 |
return;
|
|
|
819 |
}
|
| 29598 |
tejbeer |
820 |
|
| 35548 |
aman |
821 |
if (counterSize === "") {
|
|
|
822 |
alert("Counter Size is required");
|
|
|
823 |
return;
|
|
|
824 |
}
|
| 32471 |
tejbeer |
825 |
|
| 35548 |
aman |
826 |
if (localStorage.getItem("frontph") == "undefined" && localStorage.getItem("frontph") == null) {
|
|
|
827 |
alert("Front Document is required");
|
|
|
828 |
return;
|
|
|
829 |
}
|
| 31249 |
tejbeer |
830 |
|
| 35548 |
aman |
831 |
if (localStorage.getItem("internalMarketh") == "undefined" || localStorage.getItem("internalMarketh") == null) {
|
|
|
832 |
alert("Front With Market Document is required");
|
|
|
833 |
return;
|
|
|
834 |
}
|
| 25980 |
tejbeer |
835 |
|
| 35548 |
aman |
836 |
if (localStorage.getItem("leftShoth") == "undefined" || localStorage.getItem("leftShoth") == null) {
|
|
|
837 |
alert("Internal Left Shot Document is required");
|
|
|
838 |
return;
|
|
|
839 |
}
|
| 27605 |
tejbeer |
840 |
|
| 35548 |
aman |
841 |
if (localStorage.getItem("leftWallh") == "undefined" || localStorage.getItem("leftWallh") == null) {
|
|
|
842 |
alert("Internal Left Wall Document is required");
|
|
|
843 |
return;
|
|
|
844 |
}
|
| 27605 |
tejbeer |
845 |
|
| 30185 |
tejbeer |
846 |
|
| 35548 |
aman |
847 |
if (localStorage.getItem("rightWallh") == "undefined" || localStorage.getItem("rightWallh") == null) {
|
|
|
848 |
alert("Internal Right Wall Document is required");
|
|
|
849 |
return;
|
|
|
850 |
}
|
| 30185 |
tejbeer |
851 |
|
|
|
852 |
|
| 35548 |
aman |
853 |
for (i = 1; i < table.rows.length; i++) {
|
| 30185 |
tejbeer |
854 |
|
| 35548 |
aman |
855 |
var objCells = table.rows[i].cells;
|
| 30185 |
tejbeer |
856 |
|
| 35548 |
aman |
857 |
leadBrands = {
|
|
|
858 |
brand: objCells[0].innerText,
|
|
|
859 |
value: objCells[1].getElementsByTagName('input')[0].value
|
|
|
860 |
}
|
|
|
861 |
brandValueJson.push(leadBrands);
|
|
|
862 |
}
|
| 30185 |
tejbeer |
863 |
|
| 30416 |
tejbeer |
864 |
|
| 35548 |
aman |
865 |
var leadDetailObject = {};
|
| 31402 |
tejbeer |
866 |
|
| 35548 |
aman |
867 |
leadDetailObject['leadId'] = leadId;
|
| 30416 |
tejbeer |
868 |
|
|
|
869 |
|
| 35548 |
aman |
870 |
leadDetailObject['outletName'] = outletName;
|
| 31370 |
tejbeer |
871 |
|
| 35548 |
aman |
872 |
leadDetailObject['counterSize'] = counterSize;
|
| 31370 |
tejbeer |
873 |
|
| 35548 |
aman |
874 |
leadDetailObject['leadBrands'] = brandValueJson;
|
| 31370 |
tejbeer |
875 |
|
| 31402 |
tejbeer |
876 |
|
| 35548 |
aman |
877 |
console.log(localStorage.getItem("frontp"));
|
| 31402 |
tejbeer |
878 |
|
|
|
879 |
|
| 35548 |
aman |
880 |
leadDetailObject['frontp'] = localStorage
|
|
|
881 |
.getItem("frontph");
|
| 31402 |
tejbeer |
882 |
|
|
|
883 |
|
| 35548 |
aman |
884 |
leadDetailObject['frontWithMarket'] = localStorage
|
|
|
885 |
.getItem("internalMarketh");
|
| 31370 |
tejbeer |
886 |
|
|
|
887 |
|
| 35548 |
aman |
888 |
leadDetailObject['internalLongShot'] = localStorage
|
|
|
889 |
.getItem("leftShoth");
|
| 31370 |
tejbeer |
890 |
|
|
|
891 |
|
| 35548 |
aman |
892 |
leadDetailObject['internalLeftWall'] = localStorage
|
|
|
893 |
.getItem("leftWallh");
|
| 31370 |
tejbeer |
894 |
|
|
|
895 |
|
| 35548 |
aman |
896 |
leadDetailObject['internalRightWall'] = localStorage
|
|
|
897 |
.getItem("rightWallh");
|
| 31370 |
tejbeer |
898 |
|
| 35548 |
aman |
899 |
console.log(leadDetailObject);
|
| 31370 |
tejbeer |
900 |
|
| 35548 |
aman |
901 |
if (confirm("Are you sure you want to add lead detail!") == true) {
|
|
|
902 |
doPostAjaxRequestWithJsonHandler(context + "/leadDetail", JSON.stringify(leadDetailObject), function (response) {
|
|
|
903 |
console.log(response);
|
|
|
904 |
if (response == 'true') {
|
|
|
905 |
alert("Submit Successfully");
|
|
|
906 |
}
|
| 31370 |
tejbeer |
907 |
|
| 35548 |
aman |
908 |
});
|
|
|
909 |
}
|
| 31370 |
tejbeer |
910 |
|
| 35548 |
aman |
911 |
});
|
| 31370 |
tejbeer |
912 |
|
|
|
913 |
|
| 35548 |
aman |
914 |
$(document).on('change', '.frontp',
|
|
|
915 |
function () {
|
| 31370 |
tejbeer |
916 |
|
| 35548 |
aman |
917 |
if (confirm('Document has been selected, Do you want to upload ?')) {
|
| 31370 |
tejbeer |
918 |
|
| 35548 |
aman |
919 |
var documentId = uploadImage(this, "frontph");
|
| 31370 |
tejbeer |
920 |
|
|
|
921 |
|
| 35548 |
aman |
922 |
} else {
|
| 31370 |
tejbeer |
923 |
|
| 35548 |
aman |
924 |
}
|
|
|
925 |
});
|
| 31456 |
tejbeer |
926 |
|
| 35548 |
aman |
927 |
$(document).on('change', '.internalMarket',
|
|
|
928 |
function () {
|
| 31456 |
tejbeer |
929 |
|
| 35548 |
aman |
930 |
if (confirm('Document has been selected, Do you want to upload ?')) {
|
| 31456 |
tejbeer |
931 |
|
| 35548 |
aman |
932 |
var documentId = uploadImage(this, "internalMarketh");
|
| 31456 |
tejbeer |
933 |
|
| 35548 |
aman |
934 |
} else {
|
| 31456 |
tejbeer |
935 |
|
| 35548 |
aman |
936 |
}
|
|
|
937 |
});
|
| 31370 |
tejbeer |
938 |
|
| 35548 |
aman |
939 |
$(document).on('change', '.leftShot',
|
| 31370 |
tejbeer |
940 |
|
| 35548 |
aman |
941 |
function () {
|
|
|
942 |
if (confirm('Document has been selected, Do you want to upload ?')) {
|
|
|
943 |
var documentId = uploadImage(this, "leftShoth");
|
|
|
944 |
} else {
|
| 31370 |
tejbeer |
945 |
|
| 35548 |
aman |
946 |
}
|
|
|
947 |
});
|
| 31370 |
tejbeer |
948 |
|
| 35548 |
aman |
949 |
$(document).on('change', '.leftWall',
|
|
|
950 |
function () {
|
|
|
951 |
if (confirm('Document has been selected, Do you want to upload ?')) {
|
|
|
952 |
var documentId = uploadImage(this, "leftWallh");
|
|
|
953 |
} else {
|
| 31370 |
tejbeer |
954 |
|
| 35548 |
aman |
955 |
}
|
|
|
956 |
});
|
| 31370 |
tejbeer |
957 |
|
| 35548 |
aman |
958 |
$(document).on('change', '.rightWall',
|
|
|
959 |
function () {
|
|
|
960 |
if (confirm('Document has been selected, Do you want to upload ?')) {
|
|
|
961 |
var documentId = uploadImage(this, "rightWallh");
|
|
|
962 |
} else {
|
|
|
963 |
}
|
|
|
964 |
});
|
| 31370 |
tejbeer |
965 |
|
|
|
966 |
|
| 25980 |
tejbeer |
967 |
});
|
|
|
968 |
|
| 31404 |
tejbeer |
969 |
function uploadImage(fileSelector, attrName) {
|
| 35548 |
aman |
970 |
var documentId;
|
|
|
971 |
if (fileSelector != undefined
|
|
|
972 |
&& fileSelector.files[0] != undefined) {
|
|
|
973 |
var url = context
|
|
|
974 |
+ '/document-upload';
|
| 31370 |
tejbeer |
975 |
|
| 35548 |
aman |
976 |
console.log(url);
|
|
|
977 |
var file = fileSelector.files[0];
|
| 31370 |
tejbeer |
978 |
|
| 35548 |
aman |
979 |
console.log(file)
|
|
|
980 |
doAjaxUploadRequestHandler(
|
|
|
981 |
url,
|
|
|
982 |
'POST',
|
|
|
983 |
file,
|
|
|
984 |
function (response) {
|
|
|
985 |
console.log(response)
|
|
|
986 |
documentId = response.response.document_id;
|
|
|
987 |
console
|
|
|
988 |
.log("documentId : "
|
|
|
989 |
+ documentId);
|
| 31370 |
tejbeer |
990 |
|
|
|
991 |
|
| 35548 |
aman |
992 |
localStorage
|
|
|
993 |
.setItem(
|
|
|
994 |
attrName,
|
|
|
995 |
documentId);
|
| 31402 |
tejbeer |
996 |
|
| 35548 |
aman |
997 |
});
|
|
|
998 |
return documentId;
|
|
|
999 |
}
|
| 31370 |
tejbeer |
1000 |
|
|
|
1001 |
}
|
|
|
1002 |
|
|
|
1003 |
|
| 25980 |
tejbeer |
1004 |
function loadLead(domId) {
|
| 35548 |
aman |
1005 |
doGetAjaxRequestHandler(context + "/getOpenLead", function (response) {
|
|
|
1006 |
$('#' + domId).html(response);
|
|
|
1007 |
});
|
| 25980 |
tejbeer |
1008 |
}
|
|
|
1009 |
|
| 25988 |
tejbeer |
1010 |
function loadClosedLead(domId, searchTerm) {
|
| 35548 |
aman |
1011 |
doGetAjaxRequestHandler(context + "/getClosedLead", function (response) {
|
|
|
1012 |
$('#' + domId).html(response);
|
|
|
1013 |
})
|
| 25988 |
tejbeer |
1014 |
}
|
|
|
1015 |
|
| 25980 |
tejbeer |
1016 |
function statusAction() {
|
| 35548 |
aman |
1017 |
var val = $('#status').val();
|
|
|
1018 |
if (val == "followUp") {
|
|
|
1019 |
$("#scheduleTime").show();
|
|
|
1020 |
} else {
|
|
|
1021 |
$("#scheduleTime").hide();
|
|
|
1022 |
}
|
| 25980 |
tejbeer |
1023 |
|
|
|
1024 |
}
|
| 27605 |
tejbeer |
1025 |
|
|
|
1026 |
|
|
|
1027 |
function editStatusAction() {
|
| 35548 |
aman |
1028 |
var val = $('#editStatus').val();
|
|
|
1029 |
if (val == "followUp") {
|
| 36642 |
ranu |
1030 |
// Show communication type and schedule date
|
|
|
1031 |
$("#communicationTypeSection").show();
|
| 35548 |
aman |
1032 |
$("#editScheduleTime").show();
|
| 36642 |
ranu |
1033 |
$("#beatDateSelection").hide();
|
|
|
1034 |
|
| 36761 |
ranu |
1035 |
// Reset communication type only; preserve the assignee the user picked.
|
| 36642 |
ranu |
1036 |
$('#communicationType').val('');
|
| 37003 |
ranu |
1037 |
$('#assignTo option').prop('disabled', false);
|
| 36642 |
ranu |
1038 |
|
|
|
1039 |
// Check if lead has approved geolocation to decide VISIT option
|
|
|
1040 |
doAjaxRequestHandler(context + "/lead-geo/check/" + leadId, "GET", function (response) {
|
|
|
1041 |
var hasGeo = response.response.hasApprovedGeo;
|
|
|
1042 |
var commDropdown = $('#communicationType');
|
|
|
1043 |
commDropdown.empty();
|
|
|
1044 |
commDropdown.append('<option value="" disabled selected>Communication Type</option>');
|
|
|
1045 |
commDropdown.append('<option value="TELEPHONIC">TELEPHONIC</option>');
|
|
|
1046 |
if (hasGeo) {
|
|
|
1047 |
commDropdown.append('<option value="VISIT">VISIT</option>');
|
|
|
1048 |
}
|
|
|
1049 |
});
|
| 35548 |
aman |
1050 |
} else {
|
| 36642 |
ranu |
1051 |
$("#communicationTypeSection").hide();
|
| 35548 |
aman |
1052 |
$("#editScheduleTime").hide();
|
| 36642 |
ranu |
1053 |
$("#beatDateSelection").hide();
|
| 37003 |
ranu |
1054 |
$('#assignTo option').prop('disabled', false);
|
| 35548 |
aman |
1055 |
}
|
| 27605 |
tejbeer |
1056 |
|
|
|
1057 |
}
|
|
|
1058 |
|
| 25988 |
tejbeer |
1059 |
function loadLeadSearchInfo(search_text) {
|
| 35548 |
aman |
1060 |
loadSearchLead("main-content", search_text);
|
| 25988 |
tejbeer |
1061 |
}
|
|
|
1062 |
|
| 30185 |
tejbeer |
1063 |
function loadTeamCommitment(domId) {
|
| 35548 |
aman |
1064 |
doGetAjaxRequestHandler(context + "/teamCommitment",
|
|
|
1065 |
function (response) {
|
|
|
1066 |
$('#' + domId).html(response);
|
|
|
1067 |
});
|
| 30185 |
tejbeer |
1068 |
}
|
|
|
1069 |
|
| 31370 |
tejbeer |
1070 |
function loadLeadDetail(domId) {
|
| 35548 |
aman |
1071 |
doGetAjaxRequestHandler(context + "/getLeadDetail",
|
|
|
1072 |
function (response) {
|
|
|
1073 |
$('#' + domId).html(response);
|
|
|
1074 |
});
|
| 31370 |
tejbeer |
1075 |
}
|
|
|
1076 |
|
| 30416 |
tejbeer |
1077 |
function loadPartnerHealth(domId) {
|
| 35548 |
aman |
1078 |
doGetAjaxRequestHandler(context + "/partnerHealth",
|
|
|
1079 |
function (response) {
|
|
|
1080 |
$('#' + domId).html(response);
|
|
|
1081 |
});
|
| 30416 |
tejbeer |
1082 |
}
|
|
|
1083 |
|
| 25988 |
tejbeer |
1084 |
function loadSearchLead(domId, search_text) {
|
| 35548 |
aman |
1085 |
doGetAjaxRequestHandler(context + "/searchLeads?searchTerm=" + search_text,
|
|
|
1086 |
function (response) {
|
|
|
1087 |
$('#' + domId).html(response);
|
|
|
1088 |
});
|
| 25988 |
tejbeer |
1089 |
}
|
| 33917 |
ranu |
1090 |
|
|
|
1091 |
$(document).on('click', ".arr-button-mk",
|
| 35548 |
aman |
1092 |
function () {
|
|
|
1093 |
var startDate = $('.arr-start_date').val();
|
|
|
1094 |
doGetAjaxRequestHandler(context + "/rbmTodayArr?startDate=" + startDate, function (response) {
|
|
|
1095 |
$('#main-content').html(response);
|
| 33917 |
ranu |
1096 |
|
| 35548 |
aman |
1097 |
});
|
|
|
1098 |
});
|
| 33917 |
ranu |
1099 |
|
|
|
1100 |
$(document).on('click', ".rbm-today-arr",
|
| 35548 |
aman |
1101 |
function () {
|
|
|
1102 |
doGetAjaxRequestHandler(context + "/rbmTodayArr", function (response) {
|
|
|
1103 |
$('#main-content').html(response);
|
| 33917 |
ranu |
1104 |
|
| 35548 |
aman |
1105 |
});
|
|
|
1106 |
});
|
|
|
1107 |
$(document).on('click', '.reassign', function () {
|
|
|
1108 |
$('#bulkReassignFile').val(null);
|
|
|
1109 |
$('#bulkReassignFile').click();
|
|
|
1110 |
});
|
|
|
1111 |
|
|
|
1112 |
$(document).on('change', '#bulkReassignFile', function () {
|
|
|
1113 |
|
|
|
1114 |
if (!confirm("Confirm bulk reassign upload?")) {
|
|
|
1115 |
return;
|
|
|
1116 |
}
|
|
|
1117 |
|
|
|
1118 |
var file = this.files[0];
|
|
|
1119 |
if (!file) {
|
|
|
1120 |
alert("No file selected");
|
|
|
1121 |
return;
|
|
|
1122 |
}
|
|
|
1123 |
|
|
|
1124 |
doAjaxUploadRequestHandler(
|
|
|
1125 |
context + "/upload-assign-id",
|
|
|
1126 |
'POST',
|
|
|
1127 |
file,
|
|
|
1128 |
function (response) {
|
|
|
1129 |
alert("Bulk reassignment completed");
|
|
|
1130 |
loadLead("main-content");
|
|
|
1131 |
}
|
|
|
1132 |
);
|
|
|
1133 |
});
|
|
|
1134 |
|
| 36642 |
ranu |
1135 |
// ==================== GEO LOCATION HANDLERS ====================
|
|
|
1136 |
|
|
|
1137 |
// Communication type change: filter assignTo based on type
|
|
|
1138 |
$(document).on('change', '#communicationType', function () {
|
|
|
1139 |
var val = $(this).val();
|
|
|
1140 |
var assignDropdown = $('#assignTo');
|
|
|
1141 |
|
| 36741 |
ranu |
1142 |
// Reset beat + restore manual date input
|
| 36642 |
ranu |
1143 |
$('#beatDate').val('');
|
|
|
1144 |
$('#beatBadges').empty();
|
|
|
1145 |
$("#beatDateSelection").hide();
|
| 36741 |
ranu |
1146 |
$("#editScheduleTime").show();
|
| 36642 |
ranu |
1147 |
|
|
|
1148 |
if (val == 'VISIT') {
|
| 37003 |
ranu |
1149 |
// Filter assignTo to sales users only (no BGC). Uses .prop('disabled', ...)
|
|
|
1150 |
// instead of .hide()/.show() because select2 doesn't respect hidden <option>s
|
|
|
1151 |
// in its dropdown UI. Disabled options are filtered out by our matcher above.
|
| 36642 |
ranu |
1152 |
if (typeof salesUserIds !== 'undefined') {
|
|
|
1153 |
assignDropdown.find('option').each(function () {
|
|
|
1154 |
var optVal = parseInt($(this).val());
|
|
|
1155 |
if (optVal && salesUserIds.indexOf(optVal) === -1) {
|
| 37003 |
ranu |
1156 |
$(this).prop('disabled', true);
|
| 36642 |
ranu |
1157 |
} else {
|
| 37003 |
ranu |
1158 |
$(this).prop('disabled', false);
|
| 36642 |
ranu |
1159 |
}
|
|
|
1160 |
});
|
|
|
1161 |
}
|
|
|
1162 |
} else {
|
| 37003 |
ranu |
1163 |
// TELEPHONIC — enable all users
|
|
|
1164 |
assignDropdown.find('option').prop('disabled', false);
|
| 36642 |
ranu |
1165 |
}
|
| 37003 |
ranu |
1166 |
// Nudge select2 to re-render its dropdown with the new enabled/disabled state.
|
|
|
1167 |
if ($.fn.select2 && assignDropdown.hasClass('select2-hidden-accessible')) {
|
|
|
1168 |
assignDropdown.trigger('change.select2');
|
|
|
1169 |
}
|
| 36741 |
ranu |
1170 |
// Both VISIT and TELEPHONIC offer beat-day slots when an assignee is set
|
|
|
1171 |
// (TELEPHONIC just uses the beat date as the call slot; backend won't
|
|
|
1172 |
// attach a LeadRoute for it). Non-sales assignees simply get an empty list.
|
|
|
1173 |
if (val && assignDropdown.val()) {
|
|
|
1174 |
fetchBeatDates();
|
|
|
1175 |
}
|
| 36642 |
ranu |
1176 |
});
|
|
|
1177 |
|
| 36741 |
ranu |
1178 |
// Fetch beats when assignTo changes (works for both VISIT and TELEPHONIC)
|
|
|
1179 |
$(document).on('change', '#assignTo', function () {
|
| 36642 |
ranu |
1180 |
var commType = $('#communicationType').val();
|
|
|
1181 |
var salesAuthId = $('#assignTo').val();
|
| 36741 |
ranu |
1182 |
if (commType && salesAuthId && leadId) {
|
| 36642 |
ranu |
1183 |
fetchBeatDates();
|
| 36741 |
ranu |
1184 |
} else if (!commType) {
|
| 36642 |
ranu |
1185 |
$("#beatDateSelection").hide();
|
|
|
1186 |
}
|
|
|
1187 |
});
|
|
|
1188 |
|
|
|
1189 |
function fetchBeatDates() {
|
|
|
1190 |
var salesAuthId = $('#assignTo').val();
|
|
|
1191 |
if (!salesAuthId || !leadId) return;
|
|
|
1192 |
|
| 36792 |
ranu |
1193 |
// Beat slots only make sense for sales assignees. BGC / other internal
|
|
|
1194 |
// hand-offs skip the entire beat panel (and the visit-request CTA that
|
|
|
1195 |
// sits inside it). Mirrors the server-side carve-out in /editLead.
|
|
|
1196 |
var assigneeIntId = parseInt(salesAuthId, 10);
|
|
|
1197 |
var isSalesAssigneeFetch = !isNaN(assigneeIntId)
|
|
|
1198 |
&& typeof salesUserIds !== 'undefined'
|
|
|
1199 |
&& salesUserIds.indexOf(assigneeIntId) !== -1;
|
|
|
1200 |
if (!isSalesAssigneeFetch) {
|
|
|
1201 |
$('#beatBadges').empty();
|
|
|
1202 |
$('#beatDate').val('');
|
|
|
1203 |
$('#beatDateSelection').hide();
|
|
|
1204 |
return;
|
|
|
1205 |
}
|
|
|
1206 |
|
| 36642 |
ranu |
1207 |
var badgesDiv = $('#beatBadges');
|
|
|
1208 |
badgesDiv.html('<span style="color:#999; font-size:12px;">Loading beats...</span>');
|
|
|
1209 |
$("#beatDateSelection").show();
|
|
|
1210 |
$('#beatDate').val('');
|
|
|
1211 |
|
|
|
1212 |
var url = context + "/lead-geo/beat-dates?leadId=" + leadId + "&salesAuthId=" + salesAuthId;
|
|
|
1213 |
|
|
|
1214 |
$.ajax({
|
|
|
1215 |
url: url,
|
|
|
1216 |
method: 'GET',
|
|
|
1217 |
success: function (response) {
|
|
|
1218 |
var data = response.response || response;
|
|
|
1219 |
badgesDiv.empty();
|
| 36644 |
ranu |
1220 |
|
| 36741 |
ranu |
1221 |
// Stores within radius of the lead — show count + top 3 inline.
|
|
|
1222 |
var radius = (data && data.radiusKm) ? data.radiusKm : 30;
|
|
|
1223 |
var stores = (data && data.nearestStores) || [];
|
|
|
1224 |
if (stores.length > 0) {
|
|
|
1225 |
var preview = stores.slice(0, 3).map(function (s) {
|
|
|
1226 |
return '<strong>' + s.code + ' - ' + s.name + '</strong> (' + s.distanceKm + ' km)';
|
|
|
1227 |
}).join(', ');
|
|
|
1228 |
var more = stores.length > 3 ? ' +' + (stores.length - 3) + ' more' : '';
|
| 36644 |
ranu |
1229 |
badgesDiv.append('<div style="font-size:12px; color:#333; margin-bottom:6px;">' +
|
| 36741 |
ranu |
1230 |
stores.length + ' partner store(s) within ' + radius + ' km of this lead: ' +
|
|
|
1231 |
preview + more + '</div>');
|
| 36644 |
ranu |
1232 |
}
|
|
|
1233 |
|
| 36741 |
ranu |
1234 |
// All upcoming beat-dates for the assignee that touch any nearby store.
|
| 36642 |
ranu |
1235 |
if (data && data.beats && data.beats.length > 0) {
|
| 36644 |
ranu |
1236 |
badgesDiv.append('<div style="font-weight:bold; font-size:11px; color:#666; margin-bottom:4px;">Available Slots (near this lead):</div>');
|
| 36741 |
ranu |
1237 |
var beats = data.beats;
|
| 36642 |
ranu |
1238 |
for (var i = 0; i < beats.length; i++) {
|
|
|
1239 |
var beat = beats[i];
|
| 36644 |
ranu |
1240 |
var nearTxt = beat.nearStore ? ' · near ' + beat.nearStore : '';
|
| 36642 |
ranu |
1241 |
var badge = $('<span class="beat-badge" style="' +
|
|
|
1242 |
'display:inline-block; background:#337ab7; color:#fff; padding:6px 12px; ' +
|
|
|
1243 |
'margin:4px 6px 4px 0; border-radius:16px; cursor:pointer; font-size:12px; ' +
|
|
|
1244 |
'border:2px solid #337ab7; transition:all 0.2s;">' +
|
| 36644 |
ranu |
1245 |
beat.planDate + ' · ' + beat.beatName + ' (' + beat.stops + ' stops)' + nearTxt +
|
| 36642 |
ranu |
1246 |
'</span>');
|
|
|
1247 |
badge.data('value', beat.planDate + '|' + beat.beatName + '|' + beat.planGroupId);
|
|
|
1248 |
badgesDiv.append(badge);
|
|
|
1249 |
}
|
|
|
1250 |
} else {
|
| 36787 |
ranu |
1251 |
// No beat-days available for this assignee. Surface a CTA so the
|
|
|
1252 |
// user can fire a visit request to the assignee's hierarchy instead
|
|
|
1253 |
// of being stuck. The pre-existing 'beats > 0' branch above is
|
|
|
1254 |
// untouched — this only fires for the empty-beats case.
|
|
|
1255 |
var nearestId = (stores.length > 0 && stores[0].storeId) ? stores[0].storeId : '';
|
|
|
1256 |
badgesDiv.append(
|
|
|
1257 |
'<div style="background:#fff8e1; border:1px solid #f0e0a0; border-radius:6px; padding:8px 10px; margin-top:4px;">'
|
|
|
1258 |
+ '<div style="font-size:12px; color:#7c5a00; margin-bottom:6px;">'
|
|
|
1259 |
+ 'No upcoming beat is available for this assignee.'
|
|
|
1260 |
+ '</div>'
|
|
|
1261 |
+ '<div style="display:flex; gap:8px; align-items:center;">'
|
|
|
1262 |
+ '<label style="font-size:11px; color:#666; margin:0;">Preferred date (optional):</label>'
|
|
|
1263 |
+ '<input type="date" id="vrPreferredDate" class="input-sm" style="font-size:12px; padding:3px 6px;">'
|
|
|
1264 |
+ '<button type="button" id="vrSendBtn" class="btn btn-warning btn-sm" '
|
|
|
1265 |
+ 'data-nearest="' + nearestId + '" style="font-size:12px;">Send Visit Request</button>'
|
|
|
1266 |
+ '</div>'
|
|
|
1267 |
+ '<div style="font-size:11px; color:#888; margin-top:6px;">'
|
|
|
1268 |
+ '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.'
|
|
|
1269 |
+ '</div>'
|
|
|
1270 |
+ '</div>');
|
| 36642 |
ranu |
1271 |
}
|
|
|
1272 |
},
|
|
|
1273 |
error: function () {
|
|
|
1274 |
badgesDiv.html('<span style="color:#d9534f; font-size:12px;">Error loading beats</span>');
|
|
|
1275 |
}
|
|
|
1276 |
});
|
|
|
1277 |
}
|
|
|
1278 |
|
| 36787 |
ranu |
1279 |
// Send Visit Request when no beats are available for the chosen assignee.
|
|
|
1280 |
// Posts to /visitRequest/create. Existing beat-pick + Submit flow is unchanged.
|
|
|
1281 |
$(document).on('click', '#vrSendBtn', function () {
|
|
|
1282 |
var $btn = $(this);
|
|
|
1283 |
var assigneeAuthId = parseInt($('#assignTo').val());
|
|
|
1284 |
var commType = $('#communicationType').val() || null;
|
|
|
1285 |
var nearestStoreId = parseInt($btn.data('nearest'));
|
|
|
1286 |
var preferred = $('#vrPreferredDate').val() || null;
|
| 37050 |
ranu |
1287 |
var selectedStatus = $('#editStatus').val() || null;
|
| 36787 |
ranu |
1288 |
if (!leadId || !assigneeAuthId) {
|
|
|
1289 |
alert('Pick an assignee first.');
|
|
|
1290 |
return;
|
|
|
1291 |
}
|
|
|
1292 |
$btn.prop('disabled', true).text('Sending...');
|
|
|
1293 |
var payload = {
|
|
|
1294 |
leadId: leadId,
|
|
|
1295 |
assigneeAuthId: assigneeAuthId,
|
|
|
1296 |
communicationType: commType,
|
|
|
1297 |
reason: 'No upcoming beats for assignee'
|
|
|
1298 |
};
|
|
|
1299 |
if (!isNaN(nearestStoreId) && nearestStoreId > 0) payload.nearestStoreId = nearestStoreId;
|
|
|
1300 |
if (preferred) payload.requestedDate = preferred;
|
| 37050 |
ranu |
1301 |
// Ship the picked status too — server (VisitRequestController.create) reads
|
|
|
1302 |
// it via parseLeadStatus and updates lead.status through reassignLeadAndLog.
|
|
|
1303 |
// Without it, the visit request is raised but the lead status never moves
|
|
|
1304 |
// off its previous value (e.g. stays notInterested while user picked followUp).
|
|
|
1305 |
if (selectedStatus) payload.status = selectedStatus;
|
| 36787 |
ranu |
1306 |
|
|
|
1307 |
doPostAjaxRequestWithJsonHandler(context + '/visitRequest/create', JSON.stringify(payload),
|
|
|
1308 |
function (response) {
|
|
|
1309 |
$btn.prop('disabled', false).text('Send Visit Request');
|
|
|
1310 |
var data = (response && response.response) || response || {};
|
|
|
1311 |
if (data && data.id) {
|
|
|
1312 |
alert('Visit request sent. The assignee\'s manager has been notified.');
|
|
|
1313 |
$('#editLeadData').modal('hide');
|
|
|
1314 |
$('.modal-backdrop').remove();
|
| 37050 |
ranu |
1315 |
// Repaint the affected rows so the new status is visible without
|
|
|
1316 |
// a manual refresh. If a global search is active, re-run it (this
|
|
|
1317 |
// also refreshes the injected rows in #lead-table).
|
|
|
1318 |
var activeTerm = $.trim($('#lead-table_filter input').val() || $('#lead-table-bottom-filter').val() || "");
|
|
|
1319 |
if (activeTerm.length >= 2 && $('#global-search-results').children().length && typeof window.runGlobalLeadSearch === 'function') {
|
|
|
1320 |
window.runGlobalLeadSearch(activeTerm);
|
|
|
1321 |
}
|
| 36787 |
ranu |
1322 |
} else {
|
|
|
1323 |
var msg = (data && data.message) || (data && data.error) || 'Could not send request.';
|
|
|
1324 |
alert(msg);
|
|
|
1325 |
}
|
|
|
1326 |
});
|
|
|
1327 |
});
|
|
|
1328 |
|
| 36741 |
ranu |
1329 |
// Click on beat badge to select it. A picked beat becomes the schedule
|
|
|
1330 |
// source — the manual date input is hidden (not needed when scheduling by beat).
|
| 36642 |
ranu |
1331 |
$(document).on('click', '.beat-badge', function () {
|
|
|
1332 |
$('.beat-badge').css({'background': '#337ab7', 'border-color': '#337ab7'});
|
|
|
1333 |
$(this).css({'background': '#1a5276', 'border-color': '#f39c12', 'border-width': '2px'});
|
|
|
1334 |
$('#beatDate').val($(this).data('value'));
|
| 36741 |
ranu |
1335 |
$("#editScheduleTime").hide();
|
| 36642 |
ranu |
1336 |
});
|
|
|
1337 |
|
|
|
1338 |
// Generate Geo Link for lead
|
|
|
1339 |
$(document).on('click', '.generateGeoLink', function (e) {
|
|
|
1340 |
e.stopPropagation();
|
|
|
1341 |
var lid = $(this).data('leadid');
|
|
|
1342 |
doAjaxRequestHandler(context + "/lead-geo/generate-link?leadId=" + lid, "GET", function (response) {
|
|
|
1343 |
var url = response.response;
|
|
|
1344 |
if (navigator.clipboard) {
|
|
|
1345 |
navigator.clipboard.writeText(url).then(function () {
|
|
|
1346 |
alert("Link copied to clipboard:\n" + url);
|
|
|
1347 |
});
|
|
|
1348 |
} else {
|
|
|
1349 |
prompt("Share this link with the prospect:", url);
|
|
|
1350 |
}
|
|
|
1351 |
});
|
|
|
1352 |
});
|
|
|
1353 |
|
| 36868 |
ranu |
1354 |
// Manual geo verification — for cases where the prospect refused to tap the
|
|
|
1355 |
// verification link. Team-member confirms lat/lng over phone (or pastes a
|
|
|
1356 |
// Maps URL the prospect shared) and writes it APPROVED directly.
|
|
|
1357 |
function ensureManualVerifyModal() {
|
|
|
1358 |
if ($('#manualVerifyGeoModal').length) return;
|
|
|
1359 |
var html =
|
|
|
1360 |
'<div id="manualVerifyGeoModal" class="modal" role="dialog" tabindex="-1">' +
|
|
|
1361 |
' <div class="modal-dialog modal-lg">' +
|
|
|
1362 |
' <div class="modal-content">' +
|
|
|
1363 |
' <div class="modal-header">' +
|
|
|
1364 |
' <button type="button" class="close" data-dismiss="modal">×</button>' +
|
|
|
1365 |
' <h4 class="modal-title">Verify Lead Location Manually</h4>' +
|
|
|
1366 |
' </div>' +
|
|
|
1367 |
' <div class="modal-body" style="max-height:75vh;overflow-y:auto;">' +
|
|
|
1368 |
' <input type="hidden" id="manualVerifyLeadId">' +
|
|
|
1369 |
' <div class="form-group">' +
|
|
|
1370 |
' <label>Address <small class="text-muted">(include city, state, pincode for best result)</small></label>' +
|
|
|
1371 |
' <div class="input-group">' +
|
|
|
1372 |
' <input type="text" class="form-control" id="manualVerifyAddress" placeholder="e.g. Shop 12, Sector 18, Noida, UP, 201301">' +
|
|
|
1373 |
' <span class="input-group-btn">' +
|
|
|
1374 |
' <button type="button" class="btn btn-default" id="manualVerifyGeocodeBtn">Find on map</button>' +
|
|
|
1375 |
' </span>' +
|
|
|
1376 |
' </div>' +
|
|
|
1377 |
' </div>' +
|
|
|
1378 |
' <div class="form-group">' +
|
|
|
1379 |
' <label>Latitude, Longitude</label>' +
|
|
|
1380 |
' <div class="input-group">' +
|
|
|
1381 |
' <input type="text" class="form-control" id="manualVerifyLatLng" placeholder="28.6139,77.2090">' +
|
|
|
1382 |
' <span class="input-group-btn">' +
|
|
|
1383 |
' <button type="button" class="btn btn-default" id="manualVerifyPreviewBtn">Show on map</button>' +
|
|
|
1384 |
' </span>' +
|
|
|
1385 |
' </div>' +
|
|
|
1386 |
' <small class="text-muted">You can also paste a Google Maps URL containing coords.</small>' +
|
|
|
1387 |
' </div>' +
|
|
|
1388 |
' <div class="form-group" id="manualVerifyMapWrap" style="display:none;">' +
|
|
|
1389 |
' <label>Map preview <small class="text-muted">(confirm the pin is right)</small></label>' +
|
|
|
1390 |
' <div style="border:1px solid #ddd;border-radius:3px;overflow:hidden;">' +
|
|
|
1391 |
' <iframe id="manualVerifyMapFrame" width="100%" height="260" frameborder="0" style="border:0;" allowfullscreen></iframe>' +
|
|
|
1392 |
' </div>' +
|
|
|
1393 |
' <small><a href="#" id="manualVerifyOpenMap" target="_blank">Open in Google Maps</a></small>' +
|
|
|
1394 |
' </div>' +
|
|
|
1395 |
' <div class="form-group">' +
|
|
|
1396 |
' <label>Store-board photo <span class="text-danger">*</span> <small class="text-muted">(required — proves the verification)</small></label>' +
|
|
|
1397 |
' <input type="file" id="manualVerifyPhoto" accept="image/jpeg,image/png" required>' +
|
|
|
1398 |
' <div id="manualVerifyPhotoPreview" style="margin-top:6px;display:none;">' +
|
|
|
1399 |
' <img id="manualVerifyPhotoImg" src="" style="max-height:120px;border:1px solid #ddd;border-radius:3px;padding:2px;">' +
|
|
|
1400 |
' </div>' +
|
|
|
1401 |
' </div>' +
|
|
|
1402 |
' <div class="form-group">' +
|
|
|
1403 |
' <label>Remark <small class="text-muted">(optional)</small></label>' +
|
|
|
1404 |
' <input type="text" class="form-control" id="manualVerifyRemark" placeholder="e.g. Confirmed on call with prospect">' +
|
|
|
1405 |
' </div>' +
|
|
|
1406 |
' <div id="manualVerifyErr" class="text-danger" style="display:none;"></div>' +
|
|
|
1407 |
' </div>' +
|
|
|
1408 |
' <div class="modal-footer">' +
|
|
|
1409 |
' <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>' +
|
|
|
1410 |
' <button type="button" class="btn btn-success" id="manualVerifySaveBtn">Save & Verify</button>' +
|
|
|
1411 |
' </div>' +
|
|
|
1412 |
' </div>' +
|
|
|
1413 |
' </div>' +
|
|
|
1414 |
'</div>';
|
|
|
1415 |
$('body').append(html);
|
|
|
1416 |
}
|
|
|
1417 |
|
|
|
1418 |
function manualVerifyShowMap(lat, lng) {
|
|
|
1419 |
var src = 'https://www.google.com/maps?q=' + lat + ',' + lng + '&z=17&output=embed';
|
|
|
1420 |
$('#manualVerifyMapFrame').attr('src', src);
|
|
|
1421 |
$('#manualVerifyOpenMap').attr('href', 'https://www.google.com/maps?q=' + lat + ',' + lng);
|
|
|
1422 |
$('#manualVerifyMapWrap').show();
|
|
|
1423 |
}
|
|
|
1424 |
|
|
|
1425 |
// Parses raw "lat,lng" or a Google Maps URL containing the coords.
|
|
|
1426 |
// Maps formats covered: /@lat,lng, /maps?q=lat,lng, ?ll=lat,lng, ?destination=lat,lng.
|
|
|
1427 |
function parseLatLngInput(raw) {
|
|
|
1428 |
if (!raw) return null;
|
|
|
1429 |
var s = String(raw).trim();
|
|
|
1430 |
// Strip any leading "lat:" / "lng:" tokens
|
|
|
1431 |
var direct = s.match(/(-?\d{1,3}\.\d+)\s*,\s*(-?\d{1,3}\.\d+)/);
|
|
|
1432 |
if (direct) return {lat: parseFloat(direct[1]), lng: parseFloat(direct[2])};
|
|
|
1433 |
return null;
|
|
|
1434 |
}
|
|
|
1435 |
|
|
|
1436 |
$(document).on('click', '.verifyGeoManual', function (e) {
|
|
|
1437 |
e.stopPropagation();
|
|
|
1438 |
var lid = $(this).data('leadid');
|
|
|
1439 |
ensureManualVerifyModal();
|
|
|
1440 |
$('#manualVerifyLeadId').val(lid);
|
|
|
1441 |
$('#manualVerifyAddress').val('');
|
|
|
1442 |
$('#manualVerifyLatLng').val('');
|
|
|
1443 |
$('#manualVerifyRemark').val('');
|
|
|
1444 |
$('#manualVerifyErr').hide().text('');
|
|
|
1445 |
$('#manualVerifyMapWrap').hide();
|
|
|
1446 |
$('#manualVerifyMapFrame').attr('src', '');
|
|
|
1447 |
$('#manualVerifyPhoto').val('');
|
|
|
1448 |
$('#manualVerifyPhotoImg').attr('src', '');
|
|
|
1449 |
$('#manualVerifyPhotoPreview').hide();
|
|
|
1450 |
$('#manualVerifyGeoModal').modal('show');
|
|
|
1451 |
});
|
|
|
1452 |
|
|
|
1453 |
// Local thumbnail preview as soon as the user picks a file (no upload yet —
|
|
|
1454 |
// upload happens on Save so we don't orphan documents on cancel).
|
|
|
1455 |
$(document).on('change', '#manualVerifyPhoto', function () {
|
|
|
1456 |
var f = this.files && this.files[0];
|
|
|
1457 |
if (!f) {
|
|
|
1458 |
$('#manualVerifyPhotoPreview').hide();
|
|
|
1459 |
return;
|
|
|
1460 |
}
|
|
|
1461 |
var reader = new FileReader();
|
|
|
1462 |
reader.onload = function (ev) {
|
|
|
1463 |
$('#manualVerifyPhotoImg').attr('src', ev.target.result);
|
|
|
1464 |
$('#manualVerifyPhotoPreview').show();
|
|
|
1465 |
};
|
|
|
1466 |
reader.readAsDataURL(f);
|
|
|
1467 |
});
|
|
|
1468 |
|
|
|
1469 |
// Address -> coords via server (uses existing GeocodingService).
|
|
|
1470 |
// On success, fills the lat/lng box and renders the map preview.
|
|
|
1471 |
$(document).on('click', '#manualVerifyGeocodeBtn', function () {
|
|
|
1472 |
var addr = ($('#manualVerifyAddress').val() || '').trim();
|
|
|
1473 |
if (!addr) {
|
|
|
1474 |
$('#manualVerifyErr').text('Enter an address first.').show();
|
|
|
1475 |
return;
|
|
|
1476 |
}
|
|
|
1477 |
$('#manualVerifyErr').hide();
|
|
|
1478 |
var btn = $(this);
|
|
|
1479 |
btn.prop('disabled', true).text('Finding...');
|
|
|
1480 |
$.ajax({
|
|
|
1481 |
url: context + '/lead-geo/geocode-address',
|
|
|
1482 |
type: 'POST',
|
|
|
1483 |
data: {address: addr},
|
|
|
1484 |
success: function (resp) {
|
|
|
1485 |
btn.prop('disabled', false).text('Find on map');
|
|
|
1486 |
var r = resp && resp.response ? resp.response : resp;
|
|
|
1487 |
if (!r || !r.success) {
|
|
|
1488 |
$('#manualVerifyErr').text((r && r.message) || 'Could not geocode that address.').show();
|
|
|
1489 |
return;
|
|
|
1490 |
}
|
|
|
1491 |
$('#manualVerifyLatLng').val(r.latitude + ',' + r.longitude);
|
|
|
1492 |
manualVerifyShowMap(r.latitude, r.longitude);
|
|
|
1493 |
},
|
|
|
1494 |
error: function () {
|
|
|
1495 |
btn.prop('disabled', false).text('Find on map');
|
|
|
1496 |
$('#manualVerifyErr').text('Geocode request failed. Try again.').show();
|
|
|
1497 |
}
|
|
|
1498 |
});
|
|
|
1499 |
});
|
|
|
1500 |
|
|
|
1501 |
// "Show on map" — re-render the iframe from whatever is in the lat/lng input.
|
|
|
1502 |
// Useful after the user nudges the coords manually.
|
|
|
1503 |
$(document).on('click', '#manualVerifyPreviewBtn', function () {
|
|
|
1504 |
var parsed = parseLatLngInput($('#manualVerifyLatLng').val());
|
|
|
1505 |
if (!parsed) {
|
|
|
1506 |
$('#manualVerifyErr').text('Enter latitude,longitude first.').show();
|
|
|
1507 |
return;
|
|
|
1508 |
}
|
|
|
1509 |
$('#manualVerifyErr').hide();
|
|
|
1510 |
manualVerifyShowMap(parsed.lat, parsed.lng);
|
|
|
1511 |
});
|
|
|
1512 |
|
|
|
1513 |
$(document).on('click', '#manualVerifySaveBtn', function () {
|
|
|
1514 |
var lid = $('#manualVerifyLeadId').val();
|
|
|
1515 |
var raw = $('#manualVerifyLatLng').val();
|
|
|
1516 |
var remark = $('#manualVerifyRemark').val() || '';
|
|
|
1517 |
var parsed = parseLatLngInput(raw);
|
|
|
1518 |
if (!parsed) {
|
|
|
1519 |
$('#manualVerifyErr').text('Could not read latitude/longitude. Paste like 28.6139,77.2090').show();
|
|
|
1520 |
return;
|
|
|
1521 |
}
|
|
|
1522 |
if (parsed.lat < -90 || parsed.lat > 90 || parsed.lng < -180 || parsed.lng > 180
|
|
|
1523 |
|| (parsed.lat === 0 && parsed.lng === 0)) {
|
|
|
1524 |
$('#manualVerifyErr').text('Latitude/longitude out of range.').show();
|
|
|
1525 |
return;
|
|
|
1526 |
}
|
|
|
1527 |
var fileInput = document.getElementById('manualVerifyPhoto');
|
|
|
1528 |
var pickedFile = fileInput && fileInput.files && fileInput.files[0];
|
|
|
1529 |
if (!pickedFile) {
|
|
|
1530 |
$('#manualVerifyErr').text('Please attach a store-board photo to verify.').show();
|
|
|
1531 |
return;
|
|
|
1532 |
}
|
|
|
1533 |
$('#manualVerifyErr').hide();
|
|
|
1534 |
var btn = $('#manualVerifySaveBtn');
|
|
|
1535 |
btn.prop('disabled', true).text('Verifying...');
|
|
|
1536 |
|
|
|
1537 |
function callVerify(docId) {
|
|
|
1538 |
$.ajax({
|
|
|
1539 |
url: context + '/lead-geo/manual-verify',
|
|
|
1540 |
type: 'POST',
|
|
|
1541 |
data: {
|
|
|
1542 |
leadId: lid,
|
|
|
1543 |
latitude: parsed.lat,
|
|
|
1544 |
longitude: parsed.lng,
|
|
|
1545 |
remark: remark,
|
|
|
1546 |
imageDocumentId: docId || 0
|
|
|
1547 |
},
|
|
|
1548 |
success: function () {
|
|
|
1549 |
btn.prop('disabled', false).text('Save & Verify');
|
|
|
1550 |
$('#manualVerifyGeoModal').modal('hide');
|
|
|
1551 |
// Replace the cell of this lead row with the Verified badge so
|
|
|
1552 |
// the user sees the result without reloading the whole list.
|
|
|
1553 |
var $cell = $('.verifyGeoManual[data-leadid="' + lid + '"]').closest('td');
|
|
|
1554 |
if ($cell.length) {
|
|
|
1555 |
var photoBtn = docId > 0
|
|
|
1556 |
? ' <a href="' + context + '/open-attachment?documentId=' + docId + '" target="_blank" class="btn btn-xs btn-default" style="margin-bottom:2px;">View Photo</a>'
|
|
|
1557 |
: '';
|
|
|
1558 |
$cell.html(
|
|
|
1559 |
'<div class="btn-group-vertical" style="width:100%">' +
|
|
|
1560 |
' <span class="label label-success" style="margin-bottom:4px;">Verified</span>' +
|
|
|
1561 |
' <a href="https://www.google.com/maps?q=' + parsed.lat + ',' + parsed.lng + '" target="_blank" class="btn btn-xs btn-default" style="margin-bottom:2px;">View Map</a>' +
|
|
|
1562 |
photoBtn +
|
|
|
1563 |
' <button class="btn btn-xs btn-danger reject-geo" data-leadid="' + lid + '">Revoke</button>' +
|
|
|
1564 |
'</div>'
|
|
|
1565 |
);
|
|
|
1566 |
}
|
|
|
1567 |
},
|
|
|
1568 |
error: function (xhr) {
|
|
|
1569 |
btn.prop('disabled', false).text('Save & Verify');
|
|
|
1570 |
var msg = 'Failed to verify. Please try again.';
|
|
|
1571 |
try {
|
|
|
1572 |
var j = xhr.responseJSON || JSON.parse(xhr.responseText || '{}');
|
|
|
1573 |
if (j && j.response) msg = j.response;
|
|
|
1574 |
else if (j && j.message) msg = j.message;
|
|
|
1575 |
} catch (e) {
|
|
|
1576 |
}
|
|
|
1577 |
$('#manualVerifyErr').text(msg).show();
|
|
|
1578 |
}
|
|
|
1579 |
});
|
|
|
1580 |
}
|
|
|
1581 |
|
|
|
1582 |
// Upload first, then verify with the returned document id. Photo is
|
|
|
1583 |
// required (gate at the top of the handler), so we always go through this.
|
|
|
1584 |
btn.text('Uploading photo...');
|
|
|
1585 |
var formData = new FormData();
|
|
|
1586 |
formData.append('file', pickedFile, pickedFile.name || 'store-photo.jpg');
|
|
|
1587 |
$.ajax({
|
|
|
1588 |
url: context + '/lead-geo/upload-image',
|
|
|
1589 |
type: 'POST',
|
|
|
1590 |
data: formData,
|
|
|
1591 |
processData: false,
|
|
|
1592 |
contentType: false,
|
|
|
1593 |
success: function (resp) {
|
|
|
1594 |
var r = resp && resp.response ? resp.response : resp;
|
|
|
1595 |
var docId = r && (r.document_id || r.documentId || r.id);
|
|
|
1596 |
if (!docId) {
|
|
|
1597 |
btn.prop('disabled', false).text('Save & Verify');
|
|
|
1598 |
$('#manualVerifyErr').text('Photo upload failed. Try again or remove the photo.').show();
|
|
|
1599 |
return;
|
|
|
1600 |
}
|
|
|
1601 |
btn.text('Verifying...');
|
|
|
1602 |
callVerify(docId);
|
|
|
1603 |
},
|
|
|
1604 |
error: function () {
|
|
|
1605 |
btn.prop('disabled', false).text('Save & Verify');
|
|
|
1606 |
$('#manualVerifyErr').text('Photo upload failed. Try again or remove the photo.').show();
|
|
|
1607 |
}
|
|
|
1608 |
});
|
|
|
1609 |
});
|
|
|
1610 |
|
| 36642 |
ranu |
1611 |
// Geo Review navigation
|
|
|
1612 |
$(document).on('click', '.geo-review', function () {
|
|
|
1613 |
doGetAjaxRequestHandler(context + "/lead-geo/pending-reviews", function (response) {
|
|
|
1614 |
$('#main-content').html(response);
|
|
|
1615 |
});
|
|
|
1616 |
});
|
|
|
1617 |
|
|
|
1618 |
// Visit Approvals navigation
|
|
|
1619 |
$(document).on('click', '.visit-approvals', function () {
|
|
|
1620 |
doGetAjaxRequestHandler(context + "/visit-approvals", function (response) {
|
|
|
1621 |
$('#main-content').html(response);
|
|
|
1622 |
});
|
|
|
1623 |
});
|
|
|
1624 |
|
| 36650 |
ranu |
1625 |
// Beat Day View — load inline into dashboard
|
|
|
1626 |
$(document).on('click', '.beat-plan-dayview', function (e) {
|
|
|
1627 |
e.preventDefault();
|
|
|
1628 |
doGetAjaxRequestHandler(context + '/beatPlan/dayView', function (response) {
|
|
|
1629 |
$('#main-content').html(response);
|
|
|
1630 |
});
|
|
|
1631 |
});
|
|
|
1632 |
|
| 36655 |
ranu |
1633 |
// Base Location manager — load inline into dashboard
|
|
|
1634 |
$(document).on('click', '.base-location', function (e) {
|
|
|
1635 |
e.preventDefault();
|
|
|
1636 |
doGetAjaxRequestHandler(context + '/beatPlan/baseLocationPage', function (response) {
|
|
|
1637 |
$('#main-content').html(response);
|
|
|
1638 |
});
|
|
|
1639 |
});
|
|
|
1640 |
|
| 36740 |
ranu |
1641 |
// Deferred Partners — load inline into dashboard
|
|
|
1642 |
$(document).on('click', '.beat-plan-deferred', function (e) {
|
|
|
1643 |
e.preventDefault();
|
|
|
1644 |
doGetAjaxRequestHandler(context + '/beatPlan/deferredView', function (response) {
|
|
|
1645 |
$('#main-content').html(response);
|
|
|
1646 |
});
|
|
|
1647 |
});
|
|
|
1648 |
|
| 36642 |
ranu |
1649 |
// Approve geolocation from lead table
|
|
|
1650 |
$(document).on('click', '.approve-geo', function (e) {
|
|
|
1651 |
e.stopPropagation();
|
|
|
1652 |
var lid = $(this).data('leadid');
|
|
|
1653 |
if (!confirm('Approve geolocation for Lead #' + lid + '?')) return;
|
|
|
1654 |
|
|
|
1655 |
var btn = $(this);
|
|
|
1656 |
var cell = btn.closest('td');
|
|
|
1657 |
|
|
|
1658 |
doPostAjaxRequestWithParamsHandler(
|
|
|
1659 |
context + '/lead-geo/review',
|
|
|
1660 |
{leadId: lid, status: 'APPROVED', remark: ''},
|
|
|
1661 |
function (response) {
|
|
|
1662 |
cell.html('<span class="label label-success">Verified</span>');
|
|
|
1663 |
}
|
|
|
1664 |
);
|
|
|
1665 |
});
|
|
|
1666 |
|
|
|
1667 |
// Reject geolocation from lead table
|
|
|
1668 |
$(document).on('click', '.reject-geo', function (e) {
|
|
|
1669 |
e.stopPropagation();
|
|
|
1670 |
var lid = $(this).data('leadid');
|
|
|
1671 |
var reason = prompt('Reason for rejection:');
|
|
|
1672 |
if (reason === null) return;
|
|
|
1673 |
|
|
|
1674 |
var btn = $(this);
|
|
|
1675 |
var cell = btn.closest('td');
|
|
|
1676 |
|
|
|
1677 |
doPostAjaxRequestWithParamsHandler(
|
|
|
1678 |
context + '/lead-geo/review',
|
|
|
1679 |
{leadId: lid, status: 'REJECTED', remark: reason},
|
|
|
1680 |
function (response) {
|
|
|
1681 |
cell.html('<button class="btn btn-xs btn-warning generateGeoLink" data-leadid="' + lid + '">Rejected - Resend</button>');
|
|
|
1682 |
}
|
|
|
1683 |
);
|
|
|
1684 |
});
|
|
|
1685 |
|