-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard.php
326 lines (288 loc) · 10.5 KB
/
dashboard.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
<?php include('inc_meta_header.php'); ?>
<title>Dashboard <?php include('inc_page_title.php'); ?></title>
<?php include('inc_head.php'); ?>
<?php
$DATEDG = '';
if (isset($_POST['srchfilter'])) //submit button name
{
$srch_DATEFROM = $_POST['DATEFROM'];
$srch_DATETO = $_POST['DATETO'];
//Get previous Date From-----------------------
if ($srch_DATEFROM) {
$srch_DATEFROM = strtotime($srch_DATEFROM);
//$srch_DATEFROM = strtotime('-1 day', $srch_DATEFROM);
$srch_DATEFROM = date('Y-m-d', $srch_DATEFROM);
} else {
$srch_DATEFROM = '';
}
//----------------------------------------------
//Get previous Date To-----------------------
if ($srch_DATETO) {
$srch_DATETO = strtotime($srch_DATETO);
$srch_DATETO = strtotime('+1 day', $srch_DATETO);
$srch_DATETO = date('Y-m-d', $srch_DATETO);
} else {
$srch_DATETO = '';
}
//----------------------------------------------
if (!empty($srch_DATEFROM != NULL && $srch_DATETO != NULL)) {
$DATEDG = "AND DATE(DATED) BETWEEN '$srch_DATEFROM' AND '$srch_DATETO'";
}
if (!empty($srch_DATEFROM != NULL && $srch_DATETO != NULL)) {
$DATEDG_other = "AND DATE(calls_start_time) BETWEEN '$srch_DATEFROM' AND '$srch_DATETO'";
}
$dataPoints1 = array(
array("label" => "Ali Ali", "y" => 36.12),
array("label" => "", "y" => 34.87),
array("label" => "New", "y" => 40.30),
array("label" => "personal hai", "y" => 35.30),
array("label" => "dishu dishu", "y" => 39.50),
array("label" => "cancel", "y" => 50.82),
array("label" => "hello melo", "y" => 74.70)
);
$dataPoints2 = array(
array("label" => "Ali Ali", "y" => 64.61),
array("label" => "", "y" => 70.55),
array("label" => "New", "y" => 72.50),
array("label" => "personal hai", "y" => 81.30),
array("label" => "dishu dishu", "y" => 63.60),
array("label" => "cancel", "y" => 69.38),
array("label" => "hello melo", "y" => 98.70)
);
?>
<script>
window.onload = function() {
var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
theme: "light1", // "light1", "light2", "dark1", "dark2"
title: {
text: "Number of Calls"
},
axisY: {
title: "" //Numbers
},
data: [{
type: "column",
dataPoints: <?php $result_ticki = mysqli_query($link, "SELECT count(ID) AS ID, USERID FROM `calling_comments_call` WHERE calls_start_time!='' $DATEDG_other GROUP BY USERID ");
$num_rows_ticki = mysqli_num_rows($result_ticki);
$ctr = 0;
echo '[';
while ($row_ticki = mysqli_fetch_array($result_ticki)) {
$ctr++;
echo '{"label":"';
$result_users_IO = mysqli_query($link, "SELECT `PERSON_NAME` FROM `calling_lead_agents` WHERE ID='$row_ticki[USERID]' AND STATUS=1");
while ($row_users_IO = mysqli_fetch_array($result_users_IO)) {
echo $row_users_IO['PERSON_NAME'] . ' - ' . $row_ticki['ID'];
}
echo '","y":';
echo $row_ticki['ID'];
echo '}';
if ($ctr != $num_rows_ticki) {
echo ' , ';
} else {
echo ']';
}
}
?>
}]
});
chart.render();
//Multi Chart
var chart_multi = new CanvasJS.Chart("chartContainer_multi", {
animationEnabled: true,
theme: "light2",
title: {
text: "Targets"
},
axisY: {
includeZero: true
},
legend: {
cursor: "pointer",
verticalAlign: "center",
horizontalAlign: "right",
itemclick: toggleDataSeries
},
data: [{
type: "column",
name: "Profile Completed",
indexLabel: "{y}",
yValueFormatString: "#,###.##", //$#0.##
showInLegend: true,
dataPoints: <?php $resultsssfor_Profile_Completed = mysqli_query($link, "SELECT USERID, COUNT(LEAD_STATUS) as LEAD_STATUSi FROM `calling_lead_comments` WHERE LEAD_STATUS='11' AND LEAD_STS_INVALID='0' AND STATUS='0' $DATEDG AND USERID > 0 GROUP by USERID ORDER BY USERID ASC");
$rowi = mysqli_num_rows($resultsssfor_Profile_Completed);
$ctr_PC = 0;
echo '[';
while ($row = mysqli_fetch_array($resultsssfor_Profile_Completed)) {
$ctr_PC++;
echo '{"label":"';
//echo $row['USERID'];
$result_users_IOi = mysqli_query($link, "SELECT `PERSON_NAME` FROM `calling_lead_agents` WHERE ID='$row[USERID]' AND STATUS='1'");
while ($row_users_IOi = mysqli_fetch_array($result_users_IOi)) {
echo $USERNAME = $row_users_IOi['PERSON_NAME'];
}
echo '","y":';
echo $row['LEAD_STATUSi']; //$num_rows_ticki_PC;
echo '}';
if ($ctr_PC != $rowi) {
echo ', ';
} else {
echo ']';
}
} ?>
}, {
type: "column",
name: "Lead Converted",
indexLabel: "{y}",
yValueFormatString: "#,###.##", //$#0.##
showInLegend: true,
dataPoints: <?php $resultsssfor_Profile_Completedi = mysqli_query($link, "SELECT USERID, COUNT(LEAD_STATUS) as LEAD_STATUSi FROM `calling_lead_comments` WHERE LEAD_STATUS='12' AND LEAD_STS_INVALID='0' AND STATUS='0' $DATEDG AND USERID > 0 GROUP by USERID ORDER BY USERID ASC");
$rowii = mysqli_num_rows($resultsssfor_Profile_Completedi);
$ctr_PCi = 0;
echo '[';
while ($rowi = mysqli_fetch_array($resultsssfor_Profile_Completedi)) {
$ctr_PCi++;
echo '{"label":"';
//echo $rowi['USERID'];
$result_users_IOii = mysqli_query($link, "SELECT `PERSON_NAME` FROM `calling_lead_agents` WHERE ID='$rowi[USERID]' AND STATUS='1'");
while ($row_users_IOii = mysqli_fetch_array($result_users_IOii)) {
echo $USERNAMEi = $row_users_IOii['PERSON_NAME'];
}
echo '","y":';
echo $rowi['LEAD_STATUSi']; //$num_rows_ticki_PC;
echo '}';
if ($ctr_PCi != $rowii) {
echo ', ';
} else {
echo ']';
}
} ?>
}]
});
chart_multi.render();
function toggleDataSeries(e) {
if (typeof(e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
e.dataSeries.visible = false;
} else {
e.dataSeries.visible = true;
}
chart_multi.render();
}
}
</script>
<?php
}
?>
<body class="nav-md">
<div class="container body">
<div class="main_container">
<div class="col-md-3 left_col">
<?php include('inc_nav.php'); ?>
</div>
<?php include('inc_header.php'); ?>
<!-- breadcrumb -->
<div class="breadcrumb_content">
<div class="breadcrumb_text">Dashboard / <!--<a href="dashboard.php">Dashboard</a> / -->
</div>
</div>
<!-- /breadcrumb -->
<!-- page content -->
<div class="right_col bg_fff" role="main">
<div class="container" style="margin-bottom: 20px;">
<form action="" method="post" id="import-logs">
<div class="col-lg-12 mt-2">
<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12 col-lg-offset-1">
<h3>Import 3cx Call Logs</h3>
<div class="form-group al-right" style="padding-top: 7px;">
<div class="col-lg-9 text-left">
<label class="radio-inline">
<input type="radio" name="import_date" id="inlineRadio1" value="Yesterday">Import yesterday Call Cogs
</label>
<label class="radio-inline">
<input type="radio" name="import_date" id="inlineRadio2" value="Today">Import Today Call Cogs
</label>
</div>
<div class="col-lg-3">
<button type="button" data-loading-text="Loading..." name="start_import" id="start-import" class="btn btn-success rounded"><i class="fa fa-cloud-download"></i>Start Import</button>
</div>
</div>
</div>
</div>
</form>
<div class="progress " style="margin: 10px">
<div class="progress-bar progress-bar-striped" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 0%;">
<span class="sr-only">0% Complete</span>
</div>
</div>
</div>
<div class="container">
<form action="" method="post">
<div class="col-lg-12">
<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12 col-lg-offset-1">
<div class="form-group al-right" style="padding-top: 7px;">
<div class="col-lg-9">
<div class="input-daterange input-group">
<input type="date" class="form-control input-date-picker datepicker-dropdown" id="DATEFROM" name="DATEFROM" placeholder="Start Date" autocomplete="off" value="<?php if ($srch_DATEFROM != NULL) {
echo $_POST['DATEFROM'];
} ?>" />
<span class="input-group-addon"><i class="fa fa-angle-left"></i> From DATE To <i class="fa fa-angle-right"></i></span>
<input type="date" class="form-control input-date-picker" id="DATETO" name="DATETO" placeholder="End Date" autocomplete="off" value="<?php if ($srch_DATETO != NULL) {
echo $_POST['DATETO'];
} ?>" />
</div>
</div>
<div class="col-lg-3">
<button type="submit" name="srchfilter" class="btn btn-success"><i class="fa fa-search"></i> Search</button>
</div>
</div>
</div>
</div>
</form>
</div>
<div class="container">
<div id="chartContainer_multi" style="height: 400px; width: 100%;"></div>
<div id="chartContainer" style="height: 400px; width: 100%;"></div>
</div>
</div>
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<!-- /page content -->
<?php include('inc_footer.php'); ?>
</div>
</div>
<script>
$("#start-import").on('click', function() {
if ($('#import-logs').serialize() == '') {
alert('Please select Import Date');
exit();
}
var $btn = $(this);
console.log($('#import-logs').serialize());
$.ajax({
type: "POST",
url: "three_cx_call_logs.php",
data: $('#import-logs').serialize(),
cache: false,
beforeSend: function() {
$btn.button('loading');
var progressBar = $('.progress-bar');
var progressWidth = 1;
var interval = setInterval(function() {
progressWidth += 1;
if (progressWidth >= 100) {
clearInterval(interval);
} else {
progressBar.css('width', progressWidth + '%').attr('aria-valuenow', progressWidth).text(progressWidth + '%');
}
}, 20000);
},
success: function(data) {
},
complete: function() {
$btn.button('reset');
$('.progress').addClass('hidden');
alert('Well done! You successfully Imported call logs.');
}
});
})
</script>
<?php include('inc_foot.php'); ?>