| Line 989... |
Line 989... |
| 989 |
url: url,
|
989 |
url: url,
|
| 990 |
method: 'GET',
|
990 |
method: 'GET',
|
| 991 |
success: function (response) {
|
991 |
success: function (response) {
|
| 992 |
var data = response.response || response;
|
992 |
var data = response.response || response;
|
| 993 |
badgesDiv.empty();
|
993 |
badgesDiv.empty();
|
| - |
|
994 |
|
| - |
|
995 |
// Show the nearest store to the lead's geo location
|
| - |
|
996 |
if (data && data.nearestStore) {
|
| - |
|
997 |
var ns = data.nearestStore;
|
| - |
|
998 |
badgesDiv.append('<div style="font-size:12px; color:#333; margin-bottom:6px;">' +
|
| - |
|
999 |
'Lead is nearest to: <strong>' + ns.code + ' - ' + ns.name + '</strong> ' +
|
| - |
|
1000 |
'<span style="color:#e67e22;">(' + ns.distanceKm + ' km)</span></div>');
|
| - |
|
1001 |
}
|
| - |
|
1002 |
|
| - |
|
1003 |
// Show beat slots — these are dates the sales person visits the nearest store
|
| 994 |
if (data && data.beats && data.beats.length > 0) {
|
1004 |
if (data && data.beats && data.beats.length > 0) {
|
| - |
|
1005 |
badgesDiv.append('<div style="font-weight:bold; font-size:11px; color:#666; margin-bottom:4px;">Available Slots (near this lead):</div>');
|
| 995 |
var beats = data.beats.slice(0, 3); // show max 3
|
1006 |
var beats = data.beats.slice(0, 5);
|
| 996 |
for (var i = 0; i < beats.length; i++) {
|
1007 |
for (var i = 0; i < beats.length; i++) {
|
| 997 |
var beat = beats[i];
|
1008 |
var beat = beats[i];
|
| - |
|
1009 |
var nearTxt = beat.nearStore ? ' · near ' + beat.nearStore : '';
|
| 998 |
var badge = $('<span class="beat-badge" style="' +
|
1010 |
var badge = $('<span class="beat-badge" style="' +
|
| 999 |
'display:inline-block; background:#337ab7; color:#fff; padding:6px 12px; ' +
|
1011 |
'display:inline-block; background:#337ab7; color:#fff; padding:6px 12px; ' +
|
| 1000 |
'margin:4px 6px 4px 0; border-radius:16px; cursor:pointer; font-size:12px; ' +
|
1012 |
'margin:4px 6px 4px 0; border-radius:16px; cursor:pointer; font-size:12px; ' +
|
| 1001 |
'border:2px solid #337ab7; transition:all 0.2s;">' +
|
1013 |
'border:2px solid #337ab7; transition:all 0.2s;">' +
|
| 1002 |
beat.planDate + ' · ' + beat.beatName + ' (' + beat.stops + ' stops)' +
|
1014 |
beat.planDate + ' · ' + beat.beatName + ' (' + beat.stops + ' stops)' + nearTxt +
|
| 1003 |
'</span>');
|
1015 |
'</span>');
|
| 1004 |
badge.data('value', beat.planDate + '|' + beat.beatName + '|' + beat.planGroupId);
|
1016 |
badge.data('value', beat.planDate + '|' + beat.beatName + '|' + beat.planGroupId);
|
| 1005 |
badgesDiv.append(badge);
|
1017 |
badgesDiv.append(badge);
|
| 1006 |
}
|
1018 |
}
|
| 1007 |
} else {
|
1019 |
} else {
|
| 1008 |
badgesDiv.html('<span style="color:#999; font-size:12px;">No beats available for this person</span>');
|
1020 |
badgesDiv.append('<span style="color:#999; font-size:12px;">No upcoming beats available for this person</span>');
|
| 1009 |
}
|
1021 |
}
|
| 1010 |
},
|
1022 |
},
|
| 1011 |
error: function () {
|
1023 |
error: function () {
|
| 1012 |
badgesDiv.html('<span style="color:#d9534f; font-size:12px;">Error loading beats</span>');
|
1024 |
badgesDiv.html('<span style="color:#d9534f; font-size:12px;">Error loading beats</span>');
|
| 1013 |
}
|
1025 |
}
|