-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.php
316 lines (263 loc) · 8.16 KB
/
index.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
<?php
require_once 'include/config.inc.php';
require_once 'include/functions.inc.php';
// Connect to Database
try {
$dbh = new PDO("$db_type:host=$db_host;port=$db_port;dbname=$db_name", $db_user, $db_pass, $db_options);
}
catch (PDOException $e) {
echo "\nPDO::errorInfo():\n";
print $e->getMessage();
die;
}
// COLUMN 1
// Select data from database and add to array
$query = "SELECT * FROM $db_name.$db_table_name where DATE(calldate) = CURDATE() and CHAR_LENGTH(src) < 5 and src between '400' and '499' order by src, lastapp, disposition";
try {
$sth = $dbh->query($query);
}
catch (PDOException $e) {
print $e->getMessage();
die;
}
if (!$sth) {
echo "\nPDO::errorInfo():\n";
print_r($dbh->errorInfo());
die;
}
//COLUMNS DISPLAYED
//add to array
//$idx=0;
foreach ($sth as $row) {
$Grdata['Grand Total Calls'] += 1 ;
$data[$row['src']]['src'] =$row['src'] ;
$data[$row['src']]['Total Calls'] += 1 ;
$datacal[$row['src']]['Total Dur'] += $row['duration'] ;
// Total time on the phone
$data[$row['src']]['Talk Time'] = gmdate('G:i:s', $datacal[$row['src']]['Total Dur'] );
// Unused columns (uncomment to add them back)
// Average Duration
// data[$row['src']]['AvgDur'] = date('i:s', $datacal[$row['src']]['Total Dur'] / $data[$row['src']]['Total Calls']);
// $data[$row['src']][$row['lastapp']][$row['disposition']]['Total Calls'] += 1 ;
// $datacal[$row['src']][$row['lastapp']][$row['disposition']]['Total Dur'] += $row['duration'] ;
// $data[$row['src']][$row['lastapp']][$row['disposition']]['Avg Dur'] = date('i:s', $datacal[$row['src']][$row['lastapp']][$row['disposition']]['Total Dur'] / $data[$row['src']][$row['lastapp']][$row['disposition']]['Total Calls']);
// Total at bottom
$Grdata[$row['lastapp']][$row['disposition']]['Grand Total Calls'] += 1 ;
}
// Sort the data with Total Calls descending
// Add $data as the last parameter, to sort by the common key
foreach ($data as $key => $row) {
$volume[$key] = $row['Total Calls'];
}
array_multisort($volume, SORT_DESC, SORT_NUMERIC, $data);
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Today's Call Records</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<link rel="stylesheet" href="style/screen.css" type="text/css" media="screen" />
<link rel="stylesheet" href="style/displayBoard.css" type="text/css" media="screen" />
<link rel="shortcut icon" href="templates/images/favicon.ico" />
<link href='https://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
</head>
<body>
<h1 class="pageHeader">Today's Call Records</h1>
<!-- COLUMN 1 -->
<table class="callboard" id="callboard_1">
<?php
foreach($header as $hlastappkey=>$hlastappval){
$colcnt=0;
foreach($hlastappval as $hdispkey=>$hdispval){
$colcnt +=1;
$bothead .='<th>'.$hdispkey.'</th>';
foreach($hdispval as $hdurkey=>$hdurpval){
$colcnt +=1;
$bothead .='<th>'.$hdurkey.'</th>';
}
}
$tophead .='<th colspan='.$colcnt.' class="headers">'.$hlastappkey.' </th>';
}
?>
<!--<tr>
<th>Extension</th>
<th>Total</th>
<th>Avg</th>
<?php //echo $tophead;?>
</tr>
-->
<tr class="tableHeader">
<th class="extention">Extension</th>
<th class="total">Calls</th>
<th class="length">Talk Time</th>
<?php //echo $bothead;?>
</tr>
<?php
foreach($data as $srckey=>$srcval){
if($changebkgr){
$changebkgr= '';
}else{
$changebkgr= 'class="oddRows"';
}
echo '<tr '.$changebkgr.'>
<td>'.$srcval['src'].'</td><td align="right">'.$srcval['Total Calls'].'</td>
<td align="right">'.$srcval['Talk Time'].'</td>';
foreach($srcval as $appkey=>$appval){
foreach($appval as $dispkey=>$dispval){
foreach($dispval as $totkey=>$totpval){
echo '<td align="right">'.$totpval.'</td>';
}
}
}
echo '</tr>';
}
?>
<tr>
<th> </th>
<th align="right">Total: <?php echo $Grdata['Grand Total Calls'];?></th>
<?php
foreach($Grdata as $appkey=>$appval){
foreach($appval as $dispkey=>$dispval){
foreach($dispval as $totkey=>$totpval){
// echo '<th align="right"> </th>';
// echo '<th align="right">'.$totpval.'</th>';
}
}
}
?>
</tr>
</table>
</td>
</tr>
</table>
<!--
END COLUMN 1 --------------------------------------------------------------------
COLUMN 2 ------------------------------------------------------------------ -->
<?php
unset($data); //clears the data from the last table
unset($Grdata); //clears the Total Calls from the last table
unset($volume); //clears something that allows it to be sorted by number of calls (?)
// COLUMN 2
// Select data from database and add to array
$query = "SELECT * FROM $db_name.$db_table_name where DATE(calldate) = CURDATE() and CHAR_LENGTH(src) < 5 and src between '1000' and '2000' order by src, lastapp, disposition";
try {
$sth = $dbh->query($query);
}
catch (PDOException $e) {
print $e->getMessage();
die;
}
if (!$sth) {
echo "\nPDO::errorInfo():\n";
print_r($dbh->errorInfo());
die;
}
//COLUMNS DISPLAYED
//add to array
//$idx=0;
foreach ($sth as $row) {
$Grdata['Grand Total Calls'] += 1 ;
$data[$row['src']]['src'] =$row['src'] ;
$data[$row['src']]['Total Calls'] += 1 ;
$datacal[$row['src']]['Total Dur'] += $row['duration'] ;
// Total time on the phone
$data[$row['src']]['Talk Time'] = gmdate('G:i:s', $datacal[$row['src']]['Total Dur']);
// Unused columns (uncomment to add them back)
// Average Duration
// data[$row['src']]['AvgDur'] = date('i:s', $datacal[$row['src']]['Total Dur'] / $data[$row['src']]['Total Calls']);
// $data[$row['src']][$row['lastapp']][$row['disposition']]['Total Calls'] += 1 ;
// $datacal[$row['src']][$row['lastapp']][$row['disposition']]['Total Dur'] += $row['duration'] ;
// $data[$row['src']][$row['lastapp']][$row['disposition']]['Avg Dur'] = date('i:s', $datacal[$row['src']][$row['lastapp']][$row['disposition']]['Total Dur'] / $data[$row['src']][$row['lastapp']][$row['disposition']]['Total Calls']);
// Total at bottom
$Grdata[$row['lastapp']][$row['disposition']]['Grand Total Calls'] += 1 ;
}
// Sort the data with Total Calls descending
// Add $data as the last parameter, to sort by the common key
foreach ($data as $key => $row) {
$volume[$key] = $row['Total Calls'];
}
array_multisort($volume, SORT_DESC, SORT_NUMERIC, $data);
?>
<!-- COLUMN 2 -->
<table class="callboard" id="callboard_2">
<?php
foreach($header as $hlastappkey=>$hlastappval){
$colcnt=0;
foreach($hlastappval as $hdispkey=>$hdispval){
$colcnt +=1;
$bothead .='<th>'.$hdispkey.'</th>';
foreach($hdispval as $hdurkey=>$hdurpval){
$colcnt +=1;
$bothead .='<th>'.$hdurkey.'</th>';
}
}
$tophead .='<th colspan='.$colcnt.' class="headers">'.$hlastappkey.' </th>';
}
?>
<!--<tr>
<th>Extension</th>
<th>Total</th>
<th>Avg</th>
<?php //echo $tophead;?>
</tr>
-->
<tr class="tableHeader">
<th class="extention">Extension</th>
<th class="total">Calls</th>
<th class="length">Talk Time</th>
<?php //echo $bothead;?>
</tr>
<?php
foreach($data as $srckey=>$srcval){
if($changebkgr){
$changebkgr= '';
}else{
$changebkgr= 'class="oddRows"';
}
echo '<tr '.$changebkgr.'>
<td>'.$srcval['src'].'</td><td align="right">'.$srcval['Total Calls'].'</td>
<td align="right">'.$srcval['Talk Time'].'</td>';
foreach($srcval as $appkey=>$appval){
foreach($appval as $dispkey=>$dispval){
foreach($dispval as $totkey=>$totpval){
echo '<td align="right">'.$totpval.'</td>';
}
}
}
echo '</tr>';
}
?>
<tr>
<th> </th>
<th align="right">Total: <?php echo $Grdata['Grand Total Calls'];?></th>
<?php
foreach($Grdata as $appkey=>$appval){
foreach($appval as $dispkey=>$dispval){
foreach($dispval as $totkey=>$totpval){
// echo '<th align="right"> </th>';
// echo '<th align="right">'.$totpval.'</th>';
}
}
}
?>
</tr>
</table>
</td>
</tr>
</table>
<!--
END COLUMN 1 --------------------------------------------------------------------
<!------------------------------------------- -->
</body>
</html>
<?php
//foreach($data as $k=>$v){
// foreach($v as $l=>$w){
// foreach($w as $q=>$y){
// foreach($y as $z=>$a){
// echo $k . " - " . $l . " - " . $q . " - " . $z . " - " . $a ."<br>";
// }
// }
// }
//}
?>