| 36670 |
ranu |
1 |
<section class="wrapper">
|
|
|
2 |
<div class="row">
|
|
|
3 |
<div class="col-lg-12">
|
|
|
4 |
<h3 class="page-header"><i class="icon_calendar"></i> Scheduled Lead Visits</h3>
|
|
|
5 |
<ol class="breadcrumb">
|
|
|
6 |
<li><i class="fa fa-home"></i><a href="${rc.contextPath}/dashboard">Home</a></li>
|
|
|
7 |
<li><i class="icon_group"></i> Partner Acquisition</li>
|
|
|
8 |
<li><i class="icon_calendar"></i> Lead Visits</li>
|
|
|
9 |
</ol>
|
|
|
10 |
</div>
|
|
|
11 |
</div>
|
|
|
12 |
|
|
|
13 |
#if($leadRoutes.isEmpty())
|
|
|
14 |
<div class="alert alert-info">No scheduled lead visits.</div>
|
|
|
15 |
#else
|
|
|
16 |
<div class="table-responsive">
|
|
|
17 |
<table class="table table-bordered table-striped table-hover">
|
|
|
18 |
<thead>
|
|
|
19 |
<tr>
|
|
|
20 |
<th>Lead ID</th>
|
|
|
21 |
<th>Partner Name</th>
|
|
|
22 |
<th>Mobile</th>
|
|
|
23 |
<th>City</th>
|
|
|
24 |
<th>Beat</th>
|
|
|
25 |
<th>Schedule Date</th>
|
|
|
26 |
<th>Stop #</th>
|
|
|
27 |
<th>Scheduled By</th>
|
|
|
28 |
<th>Created On</th>
|
|
|
29 |
<th>Action</th>
|
|
|
30 |
</tr>
|
|
|
31 |
</thead>
|
|
|
32 |
<tbody>
|
|
|
33 |
#foreach($lr in $leadRoutes)
|
|
|
34 |
#set($lead = $leadMap.get($lr.getLeadId()))
|
|
|
35 |
#set($beat = $beatMap.get($lr.getBeatId()))
|
|
|
36 |
#set($requester = $authUserMap.get($lr.getRequestedBy()))
|
|
|
37 |
<tr>
|
|
|
38 |
<td>$lr.getLeadId()</td>
|
|
|
39 |
<td>#if($lead) $!lead.getFirstName() $!lead.getLastName() #else - #end</td>
|
|
|
40 |
<td>#if($lead) $!lead.getLeadMobile() #end</td>
|
|
|
41 |
<td>#if($lead) $!lead.getCity() #end</td>
|
|
|
42 |
<td>
|
|
|
43 |
#if($beat)
|
|
|
44 |
<a href="javascript:;" class="view-beat-on-map"
|
|
|
45 |
data-assignedto="$beat.getAuthUserId()"
|
|
|
46 |
data-beatdate="$!lr.getScheduleDate()"
|
|
|
47 |
data-beatname="$!beat.getName()" style="text-decoration:none;">
|
|
|
48 |
<span class="label label-primary" style="font-size:12px;">$!beat.getName()</span>
|
|
|
49 |
</a>
|
|
|
50 |
<br>
|
|
|
51 |
<a href="${rc.contextPath}/beatPlanWindow?authUserId=$beat.getAuthUserId()"
|
|
|
52 |
target="_blank"
|
|
|
53 |
class="btn btn-xs btn-default" style="margin-top:3px;">View All Beats</a>
|
|
|
54 |
#else
|
|
|
55 |
-
|
|
|
56 |
#end
|
|
|
57 |
</td>
|
|
|
58 |
<td><span class="label label-info" style="font-size:12px;">$!lr.getScheduleDate()</span></td>
|
|
|
59 |
<td>#if($lr.getSequenceOrder()) #set($stopNum = $lr.getSequenceOrder() + 1) $stopNum #else
|
|
|
60 |
- #end</td>
|
|
|
61 |
<td>#if($requester) $!requester.getFirstName() $!requester.getLastName() #end</td>
|
|
|
62 |
<td style="font-size:11px;">$!lr.getCreatedTimestamp()</td>
|
|
|
63 |
<td>
|
|
|
64 |
<span class="label label-success">Scheduled</span>
|
|
|
65 |
</td>
|
|
|
66 |
</tr>
|
|
|
67 |
#end
|
|
|
68 |
</tbody>
|
|
|
69 |
</table>
|
|
|
70 |
</div>
|
|
|
71 |
#end
|
|
|
72 |
</section>
|
|
|
73 |
|
|
|
74 |
<!-- Beat Route Map Modal -->
|
|
|
75 |
<div class="modal fade" id="beatMapModal" tabindex="-1" style="overflow-y:auto;">
|
|
|
76 |
<div class="modal-dialog" style="width:90%; max-width:1200px; margin-top:30px;">
|
|
|
77 |
<div class="modal-content">
|
|
|
78 |
<div class="modal-header">
|
|
|
79 |
<button type="button" class="close" data-dismiss="modal">×</button>
|
|
|
80 |
<h4 class="modal-title" id="beatMapTitle">Beat Route</h4>
|
|
|
81 |
</div>
|
|
|
82 |
<div class="modal-body" style="padding:10px;">
|
|
|
83 |
<div class="row">
|
|
|
84 |
<div class="col-md-4" style="max-height:500px; overflow-y:auto;">
|
|
|
85 |
<div id="beatStopsList"></div>
|
|
|
86 |
</div>
|
|
|
87 |
<div class="col-md-8">
|
|
|
88 |
<div id="beatMapContainer" style="width:100%; height:500px; border-radius:8px;"></div>
|
|
|
89 |
</div>
|
|
|
90 |
</div>
|
|
|
91 |
</div>
|
|
|
92 |
</div>
|
|
|
93 |
</div>
|
|
|
94 |
</div>
|
|
|
95 |
|
|
|
96 |
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAckO0y4Z6WhBOuMjNjioWLSYZDhGEvGBc&libraries=places&v=weekly"></script>
|
|
|
97 |
<script>
|
|
|
98 |
var beatMap, beatMarkers = [], beatPolyline;
|
|
|
99 |
|
|
|
100 |
function showBeatRoute(authUserId, planDate, title) {
|
|
|
101 |
$('#beatMapTitle').text(title);
|
|
|
102 |
$('#beatMapModal').modal('show');
|
|
|
103 |
|
|
|
104 |
setTimeout(function () {
|
|
|
105 |
if (!beatMap) {
|
|
|
106 |
beatMap = new google.maps.Map(document.getElementById('beatMapContainer'), {
|
|
|
107 |
zoom: 10, center: {lat: 20.5937, lng: 78.9629}
|
|
|
108 |
});
|
|
|
109 |
}
|
|
|
110 |
beatMarkers.forEach(function (m) {
|
|
|
111 |
m.setMap(null);
|
|
|
112 |
});
|
|
|
113 |
beatMarkers = [];
|
|
|
114 |
if (beatPolyline) beatPolyline.setMap(null);
|
|
|
115 |
|
|
|
116 |
$.ajax({
|
|
|
117 |
url: context + '/visit-approvals/beat-route?authUserId=' + authUserId + '&planDate=' + planDate,
|
|
|
118 |
method: 'GET',
|
|
|
119 |
success: function (response) {
|
|
|
120 |
var stops = response.response || response;
|
|
|
121 |
var bounds = new google.maps.LatLngBounds();
|
|
|
122 |
var path = [];
|
|
|
123 |
var listHtml = '<table class="table table-condensed table-bordered" style="font-size:12px;"><thead><tr><th>#</th><th>Name</th><th>Type</th></tr></thead><tbody>';
|
|
|
124 |
|
|
|
125 |
for (var i = 0; i < stops.length; i++) {
|
|
|
126 |
var stop = stops[i];
|
|
|
127 |
var isLead = stop.type === 'lead';
|
|
|
128 |
listHtml += '<tr style="' + (isLead ? 'background:#fff3cd; font-weight:bold;' : '') + '">'
|
|
|
129 |
+ '<td>' + (stop.sequence + 1) + '</td>'
|
|
|
130 |
+ '<td>' + (stop.name || '-') + '</td>'
|
|
|
131 |
+ '<td>' + (isLead ? '<span class="label label-warning">LEAD</span>' : '<span class="label label-info">Partner</span>') + '</td>'
|
|
|
132 |
+ '</tr>';
|
|
|
133 |
|
|
|
134 |
if (stop.lat && stop.lng) {
|
|
|
135 |
var pos = {lat: parseFloat(stop.lat), lng: parseFloat(stop.lng)};
|
|
|
136 |
path.push(pos);
|
|
|
137 |
bounds.extend(pos);
|
|
|
138 |
var marker = new google.maps.Marker({
|
|
|
139 |
position: pos, map: beatMap,
|
|
|
140 |
label: {text: '' + (stop.sequence + 1), color: '#fff', fontWeight: 'bold'},
|
|
|
141 |
icon: {
|
|
|
142 |
path: google.maps.SymbolPath.CIRCLE, scale: 14,
|
|
|
143 |
fillColor: isLead ? '#e67e22' : '#3498db',
|
|
|
144 |
fillOpacity: 1, strokeColor: '#fff', strokeWeight: 2
|
|
|
145 |
},
|
|
|
146 |
title: (stop.sequence + 1) + '. ' + (stop.name || '')
|
|
|
147 |
});
|
|
|
148 |
beatMarkers.push(marker);
|
|
|
149 |
}
|
|
|
150 |
}
|
|
|
151 |
listHtml += '</tbody></table>';
|
|
|
152 |
$('#beatStopsList').html(listHtml);
|
|
|
153 |
|
|
|
154 |
if (path.length > 1) {
|
|
|
155 |
beatPolyline = new google.maps.Polyline({
|
|
|
156 |
path: path, geodesic: true,
|
|
|
157 |
strokeColor: '#3498db', strokeOpacity: 0.8, strokeWeight: 3, map: beatMap
|
|
|
158 |
});
|
|
|
159 |
}
|
|
|
160 |
if (path.length > 0) beatMap.fitBounds(bounds);
|
|
|
161 |
}
|
|
|
162 |
});
|
|
|
163 |
}, 300);
|
|
|
164 |
}
|
|
|
165 |
|
|
|
166 |
$(document).on('click', '.view-beat-on-map', function () {
|
|
|
167 |
var authUserId = $(this).data('assignedto');
|
|
|
168 |
var beatDate = $(this).data('beatdate');
|
|
|
169 |
var beatName = $(this).data('beatname');
|
|
|
170 |
showBeatRoute(authUserId, beatDate, beatName + ' - ' + beatDate);
|
|
|
171 |
});
|
|
|
172 |
</script>
|