| 36662 |
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 Beats - Day View</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> Beat Day View</li>
|
|
|
9 |
</ol>
|
|
|
10 |
</div>
|
|
|
11 |
</div>
|
|
|
12 |
|
|
|
13 |
<div class="row" style="margin-bottom:10px;">
|
|
|
14 |
<div class="col-lg-12" style="display:flex; gap:10px; align-items:center; flex-wrap:wrap;">
|
|
|
15 |
<label style="margin:0;">From:</label>
|
|
|
16 |
<input type="date" id="dayViewStart" class="form-control input-sm" style="width:160px;">
|
|
|
17 |
<label style="margin:0;">To:</label>
|
|
|
18 |
<input type="date" id="dayViewEnd" class="form-control input-sm" style="width:160px;">
|
|
|
19 |
<button class="btn btn-primary btn-sm" id="dayViewLoad">Load</button>
|
|
|
20 |
<span id="dayViewSummary" style="color:#777; font-size:12px; margin-left:10px;"></span>
|
|
|
21 |
</div>
|
|
|
22 |
</div>
|
|
|
23 |
|
|
|
24 |
<div class="row">
|
|
|
25 |
<div class="col-lg-12">
|
|
|
26 |
<div class="table-responsive">
|
|
|
27 |
<table class="table table-bordered table-striped table-hover" id="dayViewTable">
|
|
|
28 |
<thead>
|
|
|
29 |
<tr>
|
|
|
30 |
<th>User</th>
|
|
|
31 |
<th>Date</th>
|
|
|
32 |
<th>Beat</th>
|
|
|
33 |
<th>Day</th>
|
|
|
34 |
<th>Partners</th>
|
|
|
35 |
<th>Leads</th>
|
|
|
36 |
<th>Total Visits</th>
|
|
|
37 |
<th>Action</th>
|
|
|
38 |
</tr>
|
|
|
39 |
</thead>
|
|
|
40 |
<tbody id="dayViewRows">
|
|
|
41 |
<tr>
|
|
|
42 |
<td colspan="8" style="text-align:center; color:#999;">Pick a date range and click Load.</td>
|
|
|
43 |
</tr>
|
|
|
44 |
</tbody>
|
|
|
45 |
</table>
|
|
|
46 |
</div>
|
|
|
47 |
</div>
|
|
|
48 |
</div>
|
|
|
49 |
</section>
|
|
|
50 |
|
|
|
51 |
|
|
|
52 |
<script>
|
|
|
53 |
(function () {
|
|
|
54 |
// Default: today → today + 7 days
|
|
|
55 |
var today = new Date();
|
|
|
56 |
var week = new Date();
|
|
|
57 |
week.setDate(today.getDate() + 7);
|
|
|
58 |
|
|
|
59 |
function fmt(d) {
|
|
|
60 |
return d.getFullYear() + '-' + ('0' + (d.getMonth() + 1)).slice(-2) + '-' + ('0' + d.getDate()).slice(-2);
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
$('#dayViewStart').val(fmt(today));
|
|
|
64 |
$('#dayViewEnd').val(fmt(week));
|
|
|
65 |
loadDayView();
|
|
|
66 |
})();
|
|
|
67 |
|
|
|
68 |
$(document).on('click', '#dayViewLoad', function () {
|
|
|
69 |
loadDayView();
|
|
|
70 |
});
|
|
|
71 |
|
|
|
72 |
function loadDayView() {
|
|
|
73 |
var s = $('#dayViewStart').val();
|
|
|
74 |
var e = $('#dayViewEnd').val();
|
|
|
75 |
if (!s || !e) {
|
|
|
76 |
alert('Pick a date range');
|
|
|
77 |
return;
|
|
|
78 |
}
|
|
|
79 |
$('#dayViewRows').html('<tr><td colspan="8" style="text-align:center;">Loading...</td></tr>');
|
|
|
80 |
$('#dayViewSummary').text('');
|
|
|
81 |
$.get(context + '/beatPlan/scheduledList', {startDate: s, endDate: e}).done(function (r) {
|
|
|
82 |
var data = r.response || r;
|
|
|
83 |
renderDayViewRows(data.rows || []);
|
|
|
84 |
$('#dayViewSummary').text(data.rows.length + ' beats scheduled between ' + data.startDate + ' and ' + data.endDate);
|
|
|
85 |
}).fail(function (xhr) {
|
|
|
86 |
$('#dayViewRows').html('<tr><td colspan="8" style="color:#d9534f; text-align:center;">Error: ' + (xhr.responseText || xhr.statusText) + '</td></tr>');
|
|
|
87 |
});
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
function renderDayViewRows(rows) {
|
|
|
91 |
if (!rows || rows.length === 0) {
|
|
|
92 |
$('#dayViewRows').html('<tr><td colspan="8" style="text-align:center; color:#999;">No beats scheduled in this range.</td></tr>');
|
|
|
93 |
return;
|
|
|
94 |
}
|
|
|
95 |
var html = '';
|
|
|
96 |
rows.forEach(function (r) {
|
|
|
97 |
html += '<tr>'
|
|
|
98 |
+ '<td>' + r.userName + '</td>'
|
|
|
99 |
+ '<td><span class="label label-primary">' + r.scheduleDate + '</span></td>'
|
|
|
100 |
+ '<td><span style="display:inline-block;width:10px;height:10px;border-radius:2px;background:' + (r.beatColor || '#3498db') + ';margin-right:6px;"></span>' + r.beatName + '</td>'
|
|
|
101 |
+ '<td>' + r.dayNumber + '</td>'
|
|
|
102 |
+ '<td>' + r.partnerCount + '</td>'
|
|
|
103 |
+ '<td>' + (r.leadCount > 0 ? '<span class="label label-warning">' + r.leadCount + '</span>' : '0') + '</td>'
|
|
|
104 |
+ '<td><strong>' + r.visitCount + '</strong></td>'
|
|
|
105 |
+ '<td>'
|
|
|
106 |
+ '<button class="btn btn-xs btn-info view-user-calendar" data-userid="' + r.authUserId + '" data-username="' + r.userName + '">View Calendar</button> '
|
|
|
107 |
+ '<button class="btn btn-xs btn-warning edit-beat-on-date" '
|
|
|
108 |
+ 'data-userid="' + r.authUserId + '" data-username="' + r.userName + '" '
|
|
|
109 |
+ 'data-beatid="' + r.beatId + '" data-date="' + r.scheduleDate + '">Edit</button>'
|
|
|
110 |
+ '</td>'
|
|
|
111 |
+ '</tr>';
|
|
|
112 |
});
|
|
|
113 |
$('#dayViewRows').html(html);
|
|
|
114 |
}
|
|
|
115 |
|
|
|
116 |
// View -> open user's calendar inside the dashboard in a modal iframe (pre-selected)
|
|
|
117 |
$(document).on('click', '.view-user-calendar', function () {
|
|
|
118 |
var userId = $(this).data('userid');
|
|
|
119 |
var userName = $(this).data('username') || '';
|
|
|
120 |
var url = context + '/beatPlanWindow?autoUserId=' + userId
|
|
|
121 |
+ '&autoUserName=' + encodeURIComponent(userName);
|
|
|
122 |
$('#userCalendarTitle').text('Calendar - ' + userName);
|
|
|
123 |
$('#userCalendarFrame').attr('src', url);
|
|
|
124 |
$('#userCalendarModal').modal('show');
|
|
|
125 |
});
|
|
|
126 |
|
|
|
127 |
// Edit a beat on a specific date — opens beatPlanWindow in edit mode for that run
|
|
|
128 |
$(document).on('click', '.edit-beat-on-date', function () {
|
|
|
129 |
var userId = $(this).data('userid');
|
|
|
130 |
var userName = $(this).data('username') || '';
|
|
|
131 |
var beatId = $(this).data('beatid');
|
|
|
132 |
var date = $(this).data('date');
|
|
|
133 |
var url = context + '/beatPlanWindow?autoUserId=' + userId
|
|
|
134 |
+ '&autoUserName=' + encodeURIComponent(userName)
|
|
|
135 |
+ '&editBeatId=' + beatId + '&editDate=' + date;
|
|
|
136 |
$('#userCalendarTitle').text('Edit Beat - ' + userName + ' on ' + date);
|
|
|
137 |
$('#userCalendarFrame').attr('src', url);
|
|
|
138 |
$('#userCalendarModal').modal('show');
|
|
|
139 |
});
|
|
|
140 |
</script>
|
|
|
141 |
|
|
|
142 |
<!-- Calendar modal (iframe loads /beatPlanWindow with auto-selected user) -->
|
|
|
143 |
<div class="modal fade" id="userCalendarModal" tabindex="-1" style="overflow-y:auto;">
|
|
|
144 |
<div class="modal-dialog" style="width:95%; max-width:1300px; margin-top:20px;">
|
|
|
145 |
<div class="modal-content">
|
|
|
146 |
<div class="modal-header">
|
|
|
147 |
<button type="button" class="close" data-dismiss="modal"
|
|
|
148 |
onclick="$('#userCalendarFrame').attr('src','');">×
|
|
|
149 |
</button>
|
|
|
150 |
<h4 class="modal-title" id="userCalendarTitle">Calendar</h4>
|
|
|
151 |
</div>
|
|
|
152 |
<div class="modal-body" style="padding:0;">
|
|
|
153 |
<iframe id="userCalendarFrame" style="width:100%; height:80vh; border:none;"></iframe>
|
|
|
154 |
</div>
|
|
|
155 |
</div>
|
|
|
156 |
</div>
|
|
|
157 |
</div>
|