2 $monLibrary = dirname(__FILE__) .
"/../library";
3 $sharedLibrary = dirname(__FILE__) .
"/../../shared/library";
4 require_once(
"$monLibrary/cu_top.i");
5 require_once(
"$monLibrary/ck_hticket.i");
6 require_once(
"$monLibrary/cu_pass.i");
7 require_once(
"$sharedLibrary/cu_flagconst.i");
21 $dms_ok=array(
"Flang"=>
"string",
"action"=>
"string",
22 "cu"=>
"string",
"reportstartdate"=>
"string",
"reportenddate"=>
"string",
23 "dnid"=>
"string",
"livebatch"=>
"string",
"liveserver"=>
"string",
24 "ahdropdays"=>
"string",
"lhdropdays"=>
"string",
"byDNID" =>
"string",
25 "retrylimit"=>
"digits",
"histdays"=>
"digits",
28 dms_import_v2($gNameSpace,
"POST", $dms_ok);
30 $action = $gNameSpace[
"POST"][
"action"];
31 $cu = $gNameSpace[
"POST"][
"cu"];
32 $byDNID = $gNameSpace[
"POST"][
"byDNID"];
33 $byDNID = isset($byDNID) && $byDNID ==
"Y";
34 $self= $_SERVER[
'PHP_SELF'];
35 $cuName = strtoupper( $cu );
36 $cuLower = strtolower( $cu );
38 $reportStartDate = $gNameSpace[
"POST"][
"reportstartdate"];
39 if ( empty( $reportStartDate ) )
40 $reportStartDate = date(
"m/01/Y" );
41 $reportEndDate = $gNameSpace[
"POST"][
"reportenddate"];
42 if ( empty( $reportEndDate ) )
43 $reportEndDate = date(
"m/t/Y" );
46 $aDNIDColumn = $byDNID ?
", ivr_call.call_dnid" :
"";
48 $callTime =
"(coalesce(Extract(epoch from ev.evend)::integer, 0) - Extract(epoch from ev.evstart)::integer)";
50 $where =
"(b.event_date >= date '" . dms_escape_string($reportStartDate) .
"' 51 AND b.event_date < date '" . dms_escape_string($reportEndDate) .
"' + interval '1 day')";
54 ivr_call.call_cu $aDNIDColumn, 55 count(ivr_call.call_id) as calls_count, 56 coalesce(avg(CASE WHEN ev.evstart = ev.evend THEN NULL WHEN $callTime <= 0 THEN NULL ELSE $callTime END), 0) as calls_average 59 SELECT a.call_id, MIN(b.event_date), MAX(a.event_date) 61 INNER JOIN ivr_event b ON a.call_id = b.call_id AND b.event_code = 'A' 64 ) as ev(call_id, evstart, evend) ON ivr_call.call_id = ev.call_id 65 WHERE coalesce(Extract(epoch from ev.evend)::integer, 0) > 0 AND ivr_call.call_cu IS NOT NULL";
67 if ( strlen( $cu ) > 0 ) {
68 $sql .=
" AND ivr_call.call_cu = '$cu'";
71 $sql .=
" GROUP BY call_cu $aDNIDColumn 72 ORDER BY call_cu $aDNIDColumn";
74 $sthCalls = db_query($sql, $dbh);
76 $displayData = array();
83 while ( $row = db_fetch_array($sthCalls, $rowCnt++ ) ) {
84 $callCU = $row[
"call_cu"];
85 $callCount = $row[
'calls_count'];
86 $callAvg = number_format( $row[
'calls_average'], 1 );
87 $callTotal = $callCount * $row[
'calls_average'];
89 $callDNID = $byDNID ? intval($row[
"call_dnid"]) : 0;
92 $callTotalHours = floor( $callTotal / 60 );
93 $sumTotalMinutes += $callTotalHours;
95 $callTotalStr =
"$callTotalHours";
97 $callAvgHours = floor( ( $callAvg / 3600 ) );
98 $callAvgMinutes = floor( ( ( $callAvg - $callAvgHours * 3600 ) / 60 ) );
99 $callAvgSeconds = round( $callAvg - $callAvgMinutes * 60 - $callAvgHours * 3660 );
101 $callAvgStr =
"$callAvgHours:$callAvgMinutes:$callAvgSeconds";
103 $displayData[] = array(
"callCU" => $callCU,
104 "callDNID" => $callDNID,
105 "callCount" => $callCount,
106 "callTotal" => $callTotalStr,
107 "callAvg" => $callAvgStr );
110 $totalCalls += $callCount;
111 $totalSeconds += $callTotal;
114 $callTotalStr =
"$sumTotalMinutes";
116 if ( $totalCalls > 0 ) {
117 $totalAvg = number_format( $totalSeconds / $totalCalls, 1 );
122 $callAvgHours = floor( ( $totalAvg / 3600 ) );
123 $callAvgMinutes = floor( ( ( $totalAvg - $callAvgHours * 3600 ) / 60 ) );
124 $callAvgSeconds = round( $totalAvg - $callAvgMinutes * 60 - $callAvgHours * 3660 );
126 $totalAvgStr =
"$callAvgHours:$callAvgMinutes:$callAvgSeconds";
128 if ( $gNameSpace[
"POST"][
"rv"] ==
"RAW" ) {
133 $totalInfo = Array(0, 0, 0, 0);
136 $outString .=
"CU," . ($byDNID ?
"DNID," :
"") .
"Number Calls,Total Call Time (minutes),Average Call Time\r\n";
138 for ( $i = 0; $i < count( $displayData ); $i++ ) {
139 $outString .=
"{$displayData[$i]['callCU']}," . ($byDNID ? $displayData[$i][
"callDNID"] .
"," :
"") .
"{$displayData[$i]['callCount']}," .
140 "{$displayData[$i]['callTotal']},{$displayData[$i]['callAvg']}\r\n";
143 $outString .=
"T," . ($byDNID ?
"," :
"") .
"$totalCalls,$callTotalStr,$totalAvgStr\r\n";
145 header(
"Content-length: " . strlen($outString) );
146 header(
"Content-type: application/octetstream" );
147 header(
"Content-disposition: inline; filename=\"download.csv\"" );
157 cu_header(
"Credit Union IVR Report");
160 <link href=
"https://<?php echo $cloudfrontDomainName; ?>/homecu/css/KendoUI/<?php echo $homecuKendoVersion; ?>/kendo.common.min.css" rel=
"stylesheet">
161 <link href=
"https://<?php echo $cloudfrontDomainName; ?>/homecu/css/KendoUI/<?php echo $homecuKendoVersion; ?>/kendo.default.min.css" rel=
"stylesheet">
162 <link href=
"https://<?php echo $cloudfrontDomainName; ?>/homecu/css/kendo.homecucustom.4492.min.css" type=
"text/css" rel=
"stylesheet">
163 <script type=
"text/javascript" src=
"https://<?php echo $cloudfrontDomainName; ?>/jquery/js/jquery-1.9.1.min.js"></script>
164 <script src=
"https://<?php echo $cloudfrontDomainName; ?>/homecu/js/KendoUI/<?php echo $homecuKendoVersion; ?>/kendo.core.min.js"></script>
165 <script src=
"https://<?php echo $cloudfrontDomainName ?>/homecu/js/KendoUI/<?php echo $homecuKendoVersion ?>/kendo.custom.min.js.gz"></script>
167 $(document).ready(
function() {
169 $(
"#reportStartDate").kendoDatePicker();
171 $(
"#reportEndDate").kendoDatePicker();
174 <form name=
"inputs" action=
"<?php echo $self?>" method=
"post">
175 <table
class=
"dmsbg" style=
"border-radius:5px;">
177 <td colspan=
"4" class=
"bartitle" style=
"text-align:center;">IVR Call Report</td>
180 <td colspan=
"4" style=
"background-color:white;">
181 <a href=
"<?php echo "$produrl/monitor/mindex.html
" ?>">Return to Monitor</a>
187 $setDNID = ($byDNID ?
"CHECKED" :
"");
189 <tr><td
class=
'hdr' align=right>Data Range: </td>
190 <td
class=
'dtl'><input type=
"text" id=
"reportStartDate" name=
"reportstartdate" value=
"$reportStartDate" style=
'color:black;'></td>
191 <td
class=
'dtl'><input type=
"text" id=
"reportEndDate" name=
"reportenddate" value=
"$reportEndDate" style=
'color:black;'></td>
192 <td
class=
'dtl'> </td>
195 <tr><td
class=
'hdr' align=right> </td>
196 <td
class=
'dtl'><input type=
"checkbox" name=
"byDNID" value=
"Y" $setDNID>Show Long Code?</td>
197 <td
class=
'dtl' colspan=
'2'> </td>
202 $sql =
"SELECT DISTINCT call_cu 204 WHERE call_cu IS NOT NULL 206 $sth = db_query($sql, $dbh);
211 <tr><td
class=
'hdr' align=right>Credit Union Filter: </td>
212 <td
class=
'dtl'><select name=
"cu" size=
"1">
213 <option value=
"">Show All</option>
216 while ( $row = db_fetch_array($sth, $rowCnt++) ) {
217 $thisCU = trim( $row[
"call_cu"] );
218 printf(
"\n<option value=\"%s\" %s>%s</option>", $thisCU, (strlen( $cu ) && $thisCU == $cu) ?
"SELECTED" :
"", $thisCU);
223 <td
class=
'dtl'> </td>
224 <td
class=
'dtl'> </td>
230 <tr><td colspan=
"4"><input type=
"submit" value=
"Submit"></td></tr>
233 $aDNIDDisplayTop = $byDNID ?
"<th class='hdrc'>Long Code</th>" :
"";
234 $aDNIDDisplayColspan = $byDNID ?
"colspan='2'" :
"";
238 <th
class=
'hdrc'>CU</th>
240 <th
class=
'hdrc'>Number Calls</th>
241 <th
class=
'hdrc'>Total Call Time (minutes)</th>
242 <th
class=
'hdrc'>Average Call Time</th>\n
246 for ( $i = 0; $i < count( $displayData ); $i++ ) {
248 <td class='dtl $RGB'> {$displayData[$i]['callCU']} </td>" 249 . ($byDNID ?
"<td class='dtl $RGB'> {$displayData[$i]['callDNID']} </td>" :
"") .
" 250 <td class='dtl $RGB'> {$displayData[$i]['callCount']} </td> 251 <td class='dtl $RGB'> {$displayData[$i]['callTotal']} </td> 252 <td class='dtl $RGB'> {$displayData[$i]['callAvg']} </td> 255 $RGB = ($RGB ==
"odd" ?
"even" :
"odd");
258 print
"<tr style='color:white; font-weight:bold;'> 259 <td $aDNIDDisplayColspan> Totals: </td> 260 <td> $totalCalls </td> 261 <td> $callTotalStr </td> 262 <td> $totalAvgStr </td> 265 print
"Error reading call log tables";
273 function dms_escape_string($value, $len=0, $ignore_mq=0) {
287 if ($ignore_mq == 0) {
289 if (get_magic_quotes_gpc())
290 $value = stripslashes($value);
292 $value = trim($value);
297 $value = substr($value, 0, $len);
301 $ret_value = pg_escape_string($value);