Added in-group name to IVR report select list
git-svn-id: svn://192.168.202.10@1258 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
+395
-398
@@ -10,6 +10,7 @@
|
||||
# 81108-0922 - Added no-callerID and unique caller counts
|
||||
# 90310-2056 - Admin header
|
||||
# 90508-0644 - Changed to PHP long tags
|
||||
# 91112-0719 - Added in-group names to select list
|
||||
#
|
||||
|
||||
require("dbconnect.php");
|
||||
@@ -61,7 +62,7 @@ $row=mysql_fetch_row($rslt);
|
||||
$auth=$row[0];
|
||||
|
||||
|
||||
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
|
||||
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
|
||||
{
|
||||
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
|
||||
Header("HTTP/1.0 401 Unauthorized");
|
||||
@@ -76,20 +77,23 @@ if (!isset($group)) {$group = '';}
|
||||
if (!isset($query_date)) {$query_date = "$NOW_DATE 00:00:00";}
|
||||
if (!isset($end_date)) {$end_date = "$NOW_DATE 23:23:59";}
|
||||
|
||||
$stmt="select group_id from vicidial_inbound_groups;";
|
||||
$stmt="select group_id,group_name from vicidial_inbound_groups;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$groups_to_print = mysql_num_rows($rslt);
|
||||
$i=0;
|
||||
$LISTgroups[$i]='CALLMENU';
|
||||
$LISTgroups_names[$i]='IVR';
|
||||
$i++;
|
||||
$LISTgroups[$i]='XMLPULL';
|
||||
$LISTgroups_names[$i]='Dynamic Application';
|
||||
$i++;
|
||||
$groups_to_print++;
|
||||
while ($i < $groups_to_print)
|
||||
{
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$LISTgroups[$i] =$row[0];
|
||||
$LISTgroups[$i] = $row[0];
|
||||
$LISTgroups_names[$i] = $row[1];
|
||||
$i++;
|
||||
}
|
||||
|
||||
@@ -205,14 +209,14 @@ echo "</TD><TD ROWSPAN=2 VALIGN=TOP>\n";
|
||||
echo "Inbound Groups: \n";
|
||||
echo "</TD><TD ROWSPAN=2 VALIGN=TOP>\n";
|
||||
echo "<SELECT SIZE=5 NAME=group[] multiple>\n";
|
||||
$o=0;
|
||||
$o=0;
|
||||
while ($groups_to_print > $o)
|
||||
{
|
||||
if (ereg("\|$LISTgroups[$o]\|",$group_string))
|
||||
{echo "<option selected value=\"$LISTgroups[$o]\">$LISTgroups[$o]</option>\n";}
|
||||
else
|
||||
{echo "<option value=\"$LISTgroups[$o]\">$LISTgroups[$o]</option>\n";}
|
||||
$o++;
|
||||
if (ereg("\|$LISTgroups[$o]\|",$group_string))
|
||||
{echo "<option selected value=\"$LISTgroups[$o]\">$LISTgroups[$o] - $LISTgroups_names[$o]</option>\n";}
|
||||
else
|
||||
{echo "<option value=\"$LISTgroups[$o]\">$LISTgroups[$o] - $LISTgroups_names[$o]</option>\n";}
|
||||
$o++;
|
||||
}
|
||||
echo "</SELECT>\n";
|
||||
echo "</TD><TD ROWSPAN=2 VALIGN=TOP>\n";
|
||||
@@ -250,434 +254,427 @@ echo "<PRE><FONT SIZE=2>\n\n";
|
||||
|
||||
|
||||
if ($groups_to_print < 1)
|
||||
{
|
||||
echo "\n\n";
|
||||
echo "PLEASE SELECT AN IN-GROUP AND DATE RANGE ABOVE AND CLICK SUBMIT\n";
|
||||
}
|
||||
{
|
||||
echo "\n\n";
|
||||
echo "PLEASE SELECT AN IN-GROUP AND DATE RANGE ABOVE AND CLICK SUBMIT\n";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
echo "IVR Stats Report: $group_string $NOW_TIME\n";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$TOTALcalls=0;
|
||||
$NOCALLERIDcalls=0;
|
||||
$UNIQUEcallers=0;
|
||||
$totFLOWivr_time=0;
|
||||
$totFLOWtotal_time=0;
|
||||
|
||||
##### Grab all records for the IVR for the specified time period
|
||||
$stmt="select uniqueid,extension,start_time,comment_a,comment_b,comment_d,UNIX_TIMESTAMP(start_time),phone_ext from live_inbound_log where start_time >= '$query_date_BEGIN' and start_time <= '$query_date_END' and comment_a IN($group_SQL) order by uniqueid,start_time;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$logs_to_print = mysql_num_rows($rslt);
|
||||
$p=0;
|
||||
while ($p < $logs_to_print)
|
||||
{
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$uniqueid[$p] = $row[0];
|
||||
$extension[$p] = $row[1];
|
||||
$start_time[$p] = $row[2];
|
||||
$comment_a[$p] = $row[3];
|
||||
$comment_b[$p] = $row[4];
|
||||
$comment_d[$p] = $row[5];
|
||||
$epoch[$p] = $row[6];
|
||||
$phone_ext[$p] = $row[7];
|
||||
$p++;
|
||||
}
|
||||
|
||||
### create the call flow of all calls by uniqueid
|
||||
$last_uniqueid='';
|
||||
$first_epoch='';
|
||||
$last_epoch='';
|
||||
$p=0;
|
||||
$r=-1;
|
||||
while ($p < $logs_to_print)
|
||||
{
|
||||
if ($DB > 0) {echo "$p|$uniqueid[$p]|$comment_b[$p]";}
|
||||
if ($last_uniqueid === "$uniqueid[$p]")
|
||||
{
|
||||
$unique_calls[$r] .= "----------$comment_b[$p]";
|
||||
if ($DB > 0) {echo " $r|$unique_calls[$r]\n";}
|
||||
$last_epoch[$r]=$epoch[$p];
|
||||
}
|
||||
else
|
||||
{
|
||||
$r++;
|
||||
$caller_id[$r]=$phone_ext[$p];
|
||||
if (strlen($phone_ext[$p])<2)
|
||||
{$NOCALLERIDcalls++;}
|
||||
else
|
||||
{
|
||||
if (!ereg("_$phone_ext[$p]_",$unique_callerIDs))
|
||||
{
|
||||
$unique_callerIDs .= "_$phone_ext[$p]_";
|
||||
$UNIQUEcallers++;
|
||||
}
|
||||
}
|
||||
$first_epoch[$r]=$epoch[$p];
|
||||
$last_epoch[$r]=$epoch[$p];
|
||||
$unique_calls[$r] = $comment_b[$p];
|
||||
$FLOWuniqueid[$r] = "$uniqueid[$p]";
|
||||
$last_uniqueid = "$uniqueid[$p]";
|
||||
if ($DB > 0) {echo " $r|$unique_calls[$r]\n";}
|
||||
}
|
||||
$p++;
|
||||
}
|
||||
|
||||
### sort call flows for counting
|
||||
$RAWunique_calls = $unique_calls;
|
||||
if ($logs_to_print > 0)
|
||||
{sort($unique_calls);}
|
||||
|
||||
|
||||
### count each unique call flow
|
||||
$last_Suniqueid='';
|
||||
$p=-1;
|
||||
$s=0;
|
||||
while ($s <= $r)
|
||||
{
|
||||
if ($DB > 0) {echo "$s|$unique_calls[$s]\n";}
|
||||
if ($last_Suniqueid === "$unique_calls[$s]")
|
||||
{
|
||||
$STunique_calls_count[$p]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$p++;
|
||||
$STunique_calls[$p] = $unique_calls[$s];
|
||||
$last_Suniqueid = "$unique_calls[$s]";
|
||||
$STunique_calls_count[$p]=1;
|
||||
}
|
||||
$s++;
|
||||
}
|
||||
|
||||
|
||||
### put call flows and counts together for sorting again
|
||||
$TOTALcalls=0;
|
||||
$s=0;
|
||||
while ($s <= $p)
|
||||
{
|
||||
$TOTALcalls = ($TOTALcalls + $STunique_calls_count[$s]);
|
||||
$STunique_calls_count[$s] = sprintf("%07s", $STunique_calls_count[$s]);
|
||||
$FLOWunique_calls[$s] = "$STunique_calls_count[$s]__________$STunique_calls[$s]";
|
||||
$s++;
|
||||
}
|
||||
|
||||
#### PRINT TOTAL CALLS INTO THIS IVR
|
||||
echo "\n";
|
||||
echo "Calls taken into this IVR: $TOTALcalls\n";
|
||||
echo "Calls with no CallerID: $NOCALLERIDcalls\n";
|
||||
echo "Unique Callers: $UNIQUEcallers\n";
|
||||
echo "\n";
|
||||
|
||||
### sort call flows for counting
|
||||
if ($p > 0)
|
||||
{rsort($FLOWunique_calls);}
|
||||
|
||||
|
||||
### put call flows and counts together for sorting again
|
||||
$RUC_ct = count($RAWunique_calls);
|
||||
$s=0;
|
||||
while ($s <= $p)
|
||||
{
|
||||
$FLOWsummary = explode('__________',$FLOWunique_calls[$s]);
|
||||
$FLOWsummary[0] = ($FLOWsummary[0] + 0);
|
||||
|
||||
$t=0;
|
||||
while ($t < $RUC_ct)
|
||||
{
|
||||
if ($FLOWsummary[1] === "$RAWunique_calls[$t]")
|
||||
{
|
||||
$FLOWunique_calls_list[$s] .= "'$FLOWuniqueid[$t]',";
|
||||
if ($last_epoch[$t] <= $first_epoch[$t]) {$last_epoch[$t] = ($first_epoch[$t] + 5);}
|
||||
else {$last_epoch[$t] = ($last_epoch[$t] + 10);}
|
||||
$FLOWivr_time[$s] = ($FLOWivr_time[$s] + ($last_epoch[$t] - $first_epoch[$t]));
|
||||
}
|
||||
$t++;
|
||||
}
|
||||
|
||||
$s++;
|
||||
}
|
||||
|
||||
|
||||
### put call flows and counts together for sorting again
|
||||
$s=0;
|
||||
|
||||
echo "+--------+--------+--------+--------+------+------+\n";
|
||||
echo "| | | QUEUE | QUEUE | IVR | TOTAL|\n";
|
||||
echo "| IVR | QUEUE | DROP | DROP | AVG | AVG |\n";
|
||||
echo "| CALLS | CALLS | CALLS | PERCENT| TIME | TIME | CALL PATH\n";
|
||||
echo "+--------+--------+--------+--------+------+------+------------\n";
|
||||
|
||||
while ($s <= $p)
|
||||
{
|
||||
$vcl_statuses = $MT;
|
||||
$FLOWdrop[$s]=0;
|
||||
$FLOWtotal[$s]=0;
|
||||
$FLOWdropPCT[$s]=0;
|
||||
$FLOWsummary = explode('__________',$FLOWunique_calls[$s]);
|
||||
$FLOWsummary[0] = ($FLOWsummary[0] + 0);
|
||||
|
||||
$FLOWunique_calls_list[$s] = preg_replace("/,$/","",$FLOWunique_calls_list[$s]);
|
||||
echo "IVR Stats Report: $group_string $NOW_TIME\n";
|
||||
|
||||
$TOTALcalls=0;
|
||||
$NOCALLERIDcalls=0;
|
||||
$UNIQUEcallers=0;
|
||||
$totFLOWivr_time=0;
|
||||
$totFLOWtotal_time=0;
|
||||
|
||||
##### Grab all records for the IVR for the specified time period
|
||||
$stmt="select status,length_in_sec from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and uniqueid IN($FLOWunique_calls_list[$s]);";
|
||||
$stmt="select uniqueid,extension,start_time,comment_a,comment_b,comment_d,UNIX_TIMESTAMP(start_time),phone_ext from live_inbound_log where start_time >= '$query_date_BEGIN' and start_time <= '$query_date_END' and comment_a IN($group_SQL) order by uniqueid,start_time;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$vcl_statuses_to_print = mysql_num_rows($rslt);
|
||||
$w=0;
|
||||
while ($w < $vcl_statuses_to_print)
|
||||
$logs_to_print = mysql_num_rows($rslt);
|
||||
$p=0;
|
||||
while ($p < $logs_to_print)
|
||||
{
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$vcl_statuses[$w] = $row[0];
|
||||
if ( (ereg("DROP",$vcl_statuses[$w])) or (ereg("XDROP",$vcl_statuses[$w])) )
|
||||
{$FLOWdrop[$s]++;}
|
||||
$FLOWclose_time[$s] = ($FLOWclose_time[$s] + $row[1]);
|
||||
$FLOWtotal[$s]++;
|
||||
$w++;
|
||||
$uniqueid[$p] = $row[0];
|
||||
$extension[$p] = $row[1];
|
||||
$start_time[$p] = $row[2];
|
||||
$comment_a[$p] = $row[3];
|
||||
$comment_b[$p] = $row[4];
|
||||
$comment_d[$p] = $row[5];
|
||||
$epoch[$p] = $row[6];
|
||||
$phone_ext[$p] = $row[7];
|
||||
$p++;
|
||||
}
|
||||
if ( ($FLOWtotal[$s] > 0) and ($FLOWdrop[$s] > 0) )
|
||||
|
||||
### create the call flow of all calls by uniqueid
|
||||
$last_uniqueid='';
|
||||
$first_epoch='';
|
||||
$last_epoch='';
|
||||
$p=0;
|
||||
$r=-1;
|
||||
while ($p < $logs_to_print)
|
||||
{
|
||||
$FLOWdropPCT[$s] = ( ($FLOWdrop[$s] / $FLOWtotal[$s]) * 100);
|
||||
$FLOWdropPCT[$s] = round($FLOWdropPCT[$s], 2);
|
||||
}
|
||||
$FLOWsummary[0] = sprintf("%6s", $FLOWsummary[0]);
|
||||
$FLOWtotal[$s] = sprintf("%6s", $FLOWtotal[$s]);
|
||||
$FLOWdrop[$s] = sprintf("%6s", $FLOWdrop[$s]);
|
||||
$FLOWdropPCT[$s] = sprintf("%6s", $FLOWdropPCT[$s]);
|
||||
$FLOWsummary[1] = ereg_replace('----------',' / ',$FLOWsummary[1]);
|
||||
$FLOWtotal_time[$s] = ($FLOWivr_time[$s] + $FLOWclose_time[$s]);
|
||||
|
||||
$avgFLOWivr_time[$s] = ($FLOWivr_time[$s] / $FLOWsummary[0]);
|
||||
$avgFLOWivr_time[$s] = round($avgFLOWivr_time[$s], 0);
|
||||
$avgFLOWivr_time[$s] = sprintf("%4s", $avgFLOWivr_time[$s]);
|
||||
$avgFLOWtotal_time[$s] = ($FLOWtotal_time[$s] / $FLOWsummary[0]);
|
||||
$avgFLOWtotal_time[$s] = round($avgFLOWtotal_time[$s], 0);
|
||||
$avgFLOWtotal_time[$s] = sprintf("%4s", $avgFLOWtotal_time[$s]);
|
||||
|
||||
$totFLOWtotal_time = ($totFLOWtotal_time + $FLOWtotal_time[$s]);
|
||||
$totFLOWivr_time = ($totFLOWivr_time + $FLOWivr_time[$s]);
|
||||
$totFLOWtotal = ($totFLOWtotal + $FLOWtotal[$s]);
|
||||
$totFLOWdrop = ($totFLOWdrop + $FLOWdrop[$s]);
|
||||
|
||||
echo "| $FLOWsummary[0] | $FLOWtotal[$s] | $FLOWdrop[$s] | $FLOWdropPCT[$s]%| $avgFLOWivr_time[$s] | $avgFLOWtotal_time[$s] | $FLOWsummary[1]\n";
|
||||
|
||||
$s++;
|
||||
}
|
||||
$TOTALcalls = sprintf("%6s", $TOTALcalls);
|
||||
$totFLOWtotal = sprintf("%6s", $totFLOWtotal);
|
||||
$totFLOWdrop = sprintf("%6s", $totFLOWdrop);
|
||||
if ( ($totFLOWivr_time > 0) and ($TOTALcalls > 0) )
|
||||
{$TavgFLOWivr_time = ($totFLOWivr_time / $TOTALcalls);}
|
||||
$TavgFLOWivr_time = round($TavgFLOWivr_time, 0);
|
||||
$TavgFLOWivr_time = sprintf("%4s", $TavgFLOWivr_time);
|
||||
if ( ($totFLOWtotal_time > 0) and ($TOTALcalls > 0) )
|
||||
{$TavgFLOWtotal_time = ($totFLOWtotal_time / $TOTALcalls);}
|
||||
$TavgFLOWtotal_time = round($TavgFLOWtotal_time, 0);
|
||||
$TavgFLOWtotal_time = sprintf("%4s", $TavgFLOWtotal_time);
|
||||
if ( ($totFLOWtotal < 1) or ($totFLOWdrop < 1) )
|
||||
{$totFLOWdropPCT = '0';}
|
||||
else
|
||||
{
|
||||
$totFLOWdropPCT = (($totFLOWdrop / $totFLOWtotal) * 100);
|
||||
$totFLOWdropPCT = round($totFLOWdropPCT, 0);
|
||||
}
|
||||
$totFLOWdropPCT = sprintf("%5s", $totFLOWdropPCT);
|
||||
|
||||
echo "+--------+--------+--------+--------+------+------+------------\n";
|
||||
echo "| $TOTALcalls | $totFLOWtotal | $totFLOWdrop | $totFLOWdropPCT% | $TavgFLOWivr_time | $TavgFLOWtotal_time |\n";
|
||||
echo "+--------+--------+--------+--------+------+------+\n";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
##############################
|
||||
######### TIME STATS
|
||||
|
||||
echo "\n";
|
||||
echo "---------- TIME STATS\n";
|
||||
|
||||
echo "<FONT SIZE=0>\n";
|
||||
|
||||
$hi_hour_count=0;
|
||||
$last_full_record=0;
|
||||
$i=0;
|
||||
$h=0;
|
||||
while ($i <= 96)
|
||||
{
|
||||
$stmt="select count(*) from live_inbound_log where start_time >= '$query_date $h:00:00' and start_time <= '$query_date $h:14:59' and comment_a IN($group_SQL) and comment_b='START';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$i++;
|
||||
|
||||
|
||||
$stmt="select count(*) from live_inbound_log where start_time >= '$query_date $h:15:00' and start_time <= '$query_date $h:29:59' and comment_a IN($group_SQL) and comment_b='START';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$i++;
|
||||
|
||||
$stmt="select count(*) from live_inbound_log where start_time >= '$query_date $h:30:00' and start_time <= '$query_date $h:44:59' and comment_a IN($group_SQL) and comment_b='START';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$i++;
|
||||
|
||||
$stmt="select count(*) from live_inbound_log where start_time >= '$query_date $h:45:00' and start_time <= '$query_date $h:59:59' and comment_a IN($group_SQL) and comment_b='START';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$i++;
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($hi_hour_count < 1)
|
||||
{$hour_multiplier = 0;}
|
||||
else
|
||||
{
|
||||
$hour_multiplier = (100 / $hi_hour_count);
|
||||
#$hour_multiplier = round($hour_multiplier, 0);
|
||||
}
|
||||
|
||||
echo "<!-- HICOUNT: $hi_hour_count|$hour_multiplier -->\n";
|
||||
echo "GRAPH IN 15 MINUTE INCREMENTS OF TOTAL CALLS TAKEN INTO THIS IVR\n";
|
||||
|
||||
$k=1;
|
||||
$Mk=0;
|
||||
$call_scale = '0';
|
||||
while ($k <= 102)
|
||||
{
|
||||
if ($Mk >= 5)
|
||||
{
|
||||
$Mk=0;
|
||||
if ( ($k < 1) or ($hour_multiplier <= 0) )
|
||||
{$scale_num = 100;}
|
||||
if ($DB > 0) {echo "$p|$uniqueid[$p]|$comment_b[$p]";}
|
||||
if ($last_uniqueid === "$uniqueid[$p]")
|
||||
{
|
||||
$unique_calls[$r] .= "----------$comment_b[$p]";
|
||||
if ($DB > 0) {echo " $r|$unique_calls[$r]\n";}
|
||||
$last_epoch[$r]=$epoch[$p];
|
||||
}
|
||||
else
|
||||
{
|
||||
$scale_num=($k / $hour_multiplier);
|
||||
$scale_num = round($scale_num, 0);
|
||||
$r++;
|
||||
$caller_id[$r]=$phone_ext[$p];
|
||||
if (strlen($phone_ext[$p])<2)
|
||||
{$NOCALLERIDcalls++;}
|
||||
else
|
||||
{
|
||||
if (!ereg("_$phone_ext[$p]_",$unique_callerIDs))
|
||||
{
|
||||
$unique_callerIDs .= "_$phone_ext[$p]_";
|
||||
$UNIQUEcallers++;
|
||||
}
|
||||
}
|
||||
$first_epoch[$r]=$epoch[$p];
|
||||
$last_epoch[$r]=$epoch[$p];
|
||||
$unique_calls[$r] = $comment_b[$p];
|
||||
$FLOWuniqueid[$r] = "$uniqueid[$p]";
|
||||
$last_uniqueid = "$uniqueid[$p]";
|
||||
if ($DB > 0) {echo " $r|$unique_calls[$r]\n";}
|
||||
}
|
||||
$LENscale_num = (strlen($scale_num));
|
||||
$k = ($k + $LENscale_num);
|
||||
$call_scale .= "$scale_num";
|
||||
$p++;
|
||||
}
|
||||
|
||||
### sort call flows for counting
|
||||
$RAWunique_calls = $unique_calls;
|
||||
if ($logs_to_print > 0)
|
||||
{sort($unique_calls);}
|
||||
|
||||
|
||||
### count each unique call flow
|
||||
$last_Suniqueid='';
|
||||
$p=-1;
|
||||
$s=0;
|
||||
while ($s <= $r)
|
||||
{
|
||||
if ($DB > 0) {echo "$s|$unique_calls[$s]\n";}
|
||||
if ($last_Suniqueid === "$unique_calls[$s]")
|
||||
{
|
||||
$STunique_calls_count[$p]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$p++;
|
||||
$STunique_calls[$p] = $unique_calls[$s];
|
||||
$last_Suniqueid = "$unique_calls[$s]";
|
||||
$STunique_calls_count[$p]=1;
|
||||
}
|
||||
$s++;
|
||||
}
|
||||
|
||||
|
||||
### put call flows and counts together for sorting again
|
||||
$TOTALcalls=0;
|
||||
$s=0;
|
||||
while ($s <= $p)
|
||||
{
|
||||
$TOTALcalls = ($TOTALcalls + $STunique_calls_count[$s]);
|
||||
$STunique_calls_count[$s] = sprintf("%07s", $STunique_calls_count[$s]);
|
||||
$FLOWunique_calls[$s] = "$STunique_calls_count[$s]__________$STunique_calls[$s]";
|
||||
$s++;
|
||||
}
|
||||
|
||||
#### PRINT TOTAL CALLS INTO THIS IVR
|
||||
echo "\n";
|
||||
echo "Calls taken into this IVR: $TOTALcalls\n";
|
||||
echo "Calls with no CallerID: $NOCALLERIDcalls\n";
|
||||
echo "Unique Callers: $UNIQUEcallers\n";
|
||||
echo "\n";
|
||||
|
||||
### sort call flows for counting
|
||||
if ($p > 0)
|
||||
{rsort($FLOWunique_calls);}
|
||||
|
||||
|
||||
### put call flows and counts together for sorting again
|
||||
$RUC_ct = count($RAWunique_calls);
|
||||
$s=0;
|
||||
while ($s <= $p)
|
||||
{
|
||||
$FLOWsummary = explode('__________',$FLOWunique_calls[$s]);
|
||||
$FLOWsummary[0] = ($FLOWsummary[0] + 0);
|
||||
|
||||
$t=0;
|
||||
while ($t < $RUC_ct)
|
||||
{
|
||||
if ($FLOWsummary[1] === "$RAWunique_calls[$t]")
|
||||
{
|
||||
$FLOWunique_calls_list[$s] .= "'$FLOWuniqueid[$t]',";
|
||||
if ($last_epoch[$t] <= $first_epoch[$t]) {$last_epoch[$t] = ($first_epoch[$t] + 5);}
|
||||
else {$last_epoch[$t] = ($last_epoch[$t] + 10);}
|
||||
$FLOWivr_time[$s] = ($FLOWivr_time[$s] + ($last_epoch[$t] - $first_epoch[$t]));
|
||||
}
|
||||
$t++;
|
||||
}
|
||||
|
||||
$s++;
|
||||
}
|
||||
|
||||
|
||||
### put call flows and counts together for sorting again
|
||||
$s=0;
|
||||
|
||||
echo "+--------+--------+--------+--------+------+------+\n";
|
||||
echo "| | | QUEUE | QUEUE | IVR | TOTAL|\n";
|
||||
echo "| IVR | QUEUE | DROP | DROP | AVG | AVG |\n";
|
||||
echo "| CALLS | CALLS | CALLS | PERCENT| TIME | TIME | CALL PATH\n";
|
||||
echo "+--------+--------+--------+--------+------+------+------------\n";
|
||||
|
||||
while ($s <= $p)
|
||||
{
|
||||
$vcl_statuses = $MT;
|
||||
$FLOWdrop[$s]=0;
|
||||
$FLOWtotal[$s]=0;
|
||||
$FLOWdropPCT[$s]=0;
|
||||
$FLOWsummary = explode('__________',$FLOWunique_calls[$s]);
|
||||
$FLOWsummary[0] = ($FLOWsummary[0] + 0);
|
||||
|
||||
$FLOWunique_calls_list[$s] = preg_replace("/,$/","",$FLOWunique_calls_list[$s]);
|
||||
|
||||
|
||||
##### Grab all records for the IVR for the specified time period
|
||||
$stmt="select status,length_in_sec from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and uniqueid IN($FLOWunique_calls_list[$s]);";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$vcl_statuses_to_print = mysql_num_rows($rslt);
|
||||
$w=0;
|
||||
while ($w < $vcl_statuses_to_print)
|
||||
{
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$vcl_statuses[$w] = $row[0];
|
||||
if ( (ereg("DROP",$vcl_statuses[$w])) or (ereg("XDROP",$vcl_statuses[$w])) )
|
||||
{$FLOWdrop[$s]++;}
|
||||
$FLOWclose_time[$s] = ($FLOWclose_time[$s] + $row[1]);
|
||||
$FLOWtotal[$s]++;
|
||||
$w++;
|
||||
}
|
||||
if ( ($FLOWtotal[$s] > 0) and ($FLOWdrop[$s] > 0) )
|
||||
{
|
||||
$FLOWdropPCT[$s] = ( ($FLOWdrop[$s] / $FLOWtotal[$s]) * 100);
|
||||
$FLOWdropPCT[$s] = round($FLOWdropPCT[$s], 2);
|
||||
}
|
||||
$FLOWsummary[0] = sprintf("%6s", $FLOWsummary[0]);
|
||||
$FLOWtotal[$s] = sprintf("%6s", $FLOWtotal[$s]);
|
||||
$FLOWdrop[$s] = sprintf("%6s", $FLOWdrop[$s]);
|
||||
$FLOWdropPCT[$s] = sprintf("%6s", $FLOWdropPCT[$s]);
|
||||
$FLOWsummary[1] = ereg_replace('----------',' / ',$FLOWsummary[1]);
|
||||
$FLOWtotal_time[$s] = ($FLOWivr_time[$s] + $FLOWclose_time[$s]);
|
||||
|
||||
$avgFLOWivr_time[$s] = ($FLOWivr_time[$s] / $FLOWsummary[0]);
|
||||
$avgFLOWivr_time[$s] = round($avgFLOWivr_time[$s], 0);
|
||||
$avgFLOWivr_time[$s] = sprintf("%4s", $avgFLOWivr_time[$s]);
|
||||
$avgFLOWtotal_time[$s] = ($FLOWtotal_time[$s] / $FLOWsummary[0]);
|
||||
$avgFLOWtotal_time[$s] = round($avgFLOWtotal_time[$s], 0);
|
||||
$avgFLOWtotal_time[$s] = sprintf("%4s", $avgFLOWtotal_time[$s]);
|
||||
|
||||
$totFLOWtotal_time = ($totFLOWtotal_time + $FLOWtotal_time[$s]);
|
||||
$totFLOWivr_time = ($totFLOWivr_time + $FLOWivr_time[$s]);
|
||||
$totFLOWtotal = ($totFLOWtotal + $FLOWtotal[$s]);
|
||||
$totFLOWdrop = ($totFLOWdrop + $FLOWdrop[$s]);
|
||||
|
||||
echo "| $FLOWsummary[0] | $FLOWtotal[$s] | $FLOWdrop[$s] | $FLOWdropPCT[$s]%| $avgFLOWivr_time[$s] | $avgFLOWtotal_time[$s] | $FLOWsummary[1]\n";
|
||||
|
||||
$s++;
|
||||
}
|
||||
$TOTALcalls = sprintf("%6s", $TOTALcalls);
|
||||
$totFLOWtotal = sprintf("%6s", $totFLOWtotal);
|
||||
$totFLOWdrop = sprintf("%6s", $totFLOWdrop);
|
||||
if ( ($totFLOWivr_time > 0) and ($TOTALcalls > 0) )
|
||||
{$TavgFLOWivr_time = ($totFLOWivr_time / $TOTALcalls);}
|
||||
$TavgFLOWivr_time = round($TavgFLOWivr_time, 0);
|
||||
$TavgFLOWivr_time = sprintf("%4s", $TavgFLOWivr_time);
|
||||
if ( ($totFLOWtotal_time > 0) and ($TOTALcalls > 0) )
|
||||
{$TavgFLOWtotal_time = ($totFLOWtotal_time / $TOTALcalls);}
|
||||
$TavgFLOWtotal_time = round($TavgFLOWtotal_time, 0);
|
||||
$TavgFLOWtotal_time = sprintf("%4s", $TavgFLOWtotal_time);
|
||||
if ( ($totFLOWtotal < 1) or ($totFLOWdrop < 1) )
|
||||
{$totFLOWdropPCT = '0';}
|
||||
else
|
||||
{
|
||||
$call_scale .= " ";
|
||||
$k++; $Mk++;
|
||||
$totFLOWdropPCT = (($totFLOWdrop / $totFLOWtotal) * 100);
|
||||
$totFLOWdropPCT = round($totFLOWdropPCT, 0);
|
||||
}
|
||||
}
|
||||
$totFLOWdropPCT = sprintf("%5s", $totFLOWdropPCT);
|
||||
|
||||
echo "+--------+--------+--------+--------+------+------+------------\n";
|
||||
echo "| $TOTALcalls | $totFLOWtotal | $totFLOWdrop | $totFLOWdropPCT% | $TavgFLOWivr_time | $TavgFLOWtotal_time |\n";
|
||||
echo "+--------+--------+--------+--------+------+------+\n";
|
||||
|
||||
|
||||
echo "+------+-------------------------------------------------------------------------------------------------------+-------+\n";
|
||||
#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP | TOTAL |\n";
|
||||
echo "| HOUR |$call_scale| TOTAL |\n";
|
||||
echo "+------+-------------------------------------------------------------------------------------------------------+-------+\n";
|
||||
|
||||
$ZZ = '00';
|
||||
$i=0;
|
||||
$h=4;
|
||||
$hour= -1;
|
||||
$no_lines_yet=1;
|
||||
|
||||
while ($i <= 96)
|
||||
{
|
||||
$char_counter=0;
|
||||
$time = ' ';
|
||||
if ($h >= 4)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
##############################
|
||||
######### TIME STATS
|
||||
|
||||
echo "\n";
|
||||
echo "---------- TIME STATS\n";
|
||||
|
||||
echo "<FONT SIZE=0>\n";
|
||||
|
||||
$hi_hour_count=0;
|
||||
$last_full_record=0;
|
||||
$i=0;
|
||||
$h=0;
|
||||
while ($i <= 96)
|
||||
{
|
||||
$hour++;
|
||||
$h=0;
|
||||
if ($hour < 10) {$hour = "0$hour";}
|
||||
$time = "+$hour$ZZ+";
|
||||
$stmt="select count(*) from live_inbound_log where start_time >= '$query_date $h:00:00' and start_time <= '$query_date $h:14:59' and comment_a IN($group_SQL) and comment_b='START';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$i++;
|
||||
|
||||
|
||||
$stmt="select count(*) from live_inbound_log where start_time >= '$query_date $h:15:00' and start_time <= '$query_date $h:29:59' and comment_a IN($group_SQL) and comment_b='START';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$i++;
|
||||
|
||||
$stmt="select count(*) from live_inbound_log where start_time >= '$query_date $h:30:00' and start_time <= '$query_date $h:44:59' and comment_a IN($group_SQL) and comment_b='START';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$i++;
|
||||
|
||||
$stmt="select count(*) from live_inbound_log where start_time >= '$query_date $h:45:00' and start_time <= '$query_date $h:59:59' and comment_a IN($group_SQL) and comment_b='START';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$i++;
|
||||
$h++;
|
||||
}
|
||||
if ($h == 1) {$time = " 15 ";}
|
||||
if ($h == 2) {$time = " 30 ";}
|
||||
if ($h == 3) {$time = " 45 ";}
|
||||
$Ghour_count = $hour_count[$i];
|
||||
if ($Ghour_count < 1)
|
||||
|
||||
if ($hi_hour_count < 1)
|
||||
{$hour_multiplier = 0;}
|
||||
else
|
||||
{
|
||||
if ( ($no_lines_yet) or ($i > $last_full_record) )
|
||||
$hour_multiplier = (100 / $hi_hour_count);
|
||||
#$hour_multiplier = round($hour_multiplier, 0);
|
||||
}
|
||||
|
||||
echo "<!-- HICOUNT: $hi_hour_count|$hour_multiplier -->\n";
|
||||
echo "GRAPH IN 15 MINUTE INCREMENTS OF TOTAL CALLS TAKEN INTO THIS IVR\n";
|
||||
|
||||
$k=1;
|
||||
$Mk=0;
|
||||
$call_scale = '0';
|
||||
while ($k <= 102)
|
||||
{
|
||||
if ($Mk >= 5)
|
||||
{
|
||||
$do_nothing=1;
|
||||
$Mk=0;
|
||||
if ( ($k < 1) or ($hour_multiplier <= 0) )
|
||||
{$scale_num = 100;}
|
||||
else
|
||||
{
|
||||
$scale_num=($k / $hour_multiplier);
|
||||
$scale_num = round($scale_num, 0);
|
||||
}
|
||||
$LENscale_num = (strlen($scale_num));
|
||||
$k = ($k + $LENscale_num);
|
||||
$call_scale .= "$scale_num";
|
||||
}
|
||||
else
|
||||
{
|
||||
$call_scale .= " ";
|
||||
$k++; $Mk++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo "+------+-------------------------------------------------------------------------------------------------------+-------+\n";
|
||||
#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP | TOTAL |\n";
|
||||
echo "| HOUR |$call_scale| TOTAL |\n";
|
||||
echo "+------+-------------------------------------------------------------------------------------------------------+-------+\n";
|
||||
|
||||
$ZZ = '00';
|
||||
$i=0;
|
||||
$h=4;
|
||||
$hour= -1;
|
||||
$no_lines_yet=1;
|
||||
|
||||
while ($i <= 96)
|
||||
{
|
||||
$char_counter=0;
|
||||
$time = ' ';
|
||||
if ($h >= 4)
|
||||
{
|
||||
$hour++;
|
||||
$h=0;
|
||||
if ($hour < 10) {$hour = "0$hour";}
|
||||
$time = "+$hour$ZZ+";
|
||||
}
|
||||
if ($h == 1) {$time = " 15 ";}
|
||||
if ($h == 2) {$time = " 30 ";}
|
||||
if ($h == 3) {$time = " 45 ";}
|
||||
$Ghour_count = $hour_count[$i];
|
||||
if ($Ghour_count < 1)
|
||||
{
|
||||
if ( ($no_lines_yet) or ($i > $last_full_record) )
|
||||
{
|
||||
$do_nothing=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
|
||||
echo "|$time|";
|
||||
$k=0; while ($k <= 102) {echo " "; $k++;}
|
||||
echo "| $hour_count[$i] |\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$no_lines_yet=0;
|
||||
$Xhour_count = ($Ghour_count * $hour_multiplier);
|
||||
$Yhour_count = (99 - $Xhour_count);
|
||||
|
||||
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
|
||||
echo "|$time|";
|
||||
$k=0; while ($k <= 102) {echo " "; $k++;}
|
||||
|
||||
echo "|$time|<SPAN class=\"green\">";
|
||||
$k=0; while ($k <= $Xhour_count) {echo "*"; $k++; $char_counter++;}
|
||||
echo "*X</SPAN>"; $char_counter++;
|
||||
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
|
||||
while ($char_counter <= 101) {echo " "; $char_counter++;}
|
||||
echo "| $hour_count[$i] |\n";
|
||||
}
|
||||
|
||||
|
||||
$i++;
|
||||
$h++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$no_lines_yet=0;
|
||||
$Xhour_count = ($Ghour_count * $hour_multiplier);
|
||||
$Yhour_count = (99 - $Xhour_count);
|
||||
|
||||
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
|
||||
|
||||
echo "|$time|<SPAN class=\"green\">";
|
||||
$k=0; while ($k <= $Xhour_count) {echo "*"; $k++; $char_counter++;}
|
||||
echo "*X</SPAN>"; $char_counter++;
|
||||
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
|
||||
while ($char_counter <= 101) {echo " "; $char_counter++;}
|
||||
echo "| $hour_count[$i] |\n";
|
||||
}
|
||||
|
||||
|
||||
$i++;
|
||||
$h++;
|
||||
echo "+------+-------------------------------------------------------------------------------------------------------+-------+\n\n";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$ENDtime = date("U");
|
||||
$RUNtime = ($ENDtime - $STARTtime);
|
||||
echo "\nRun Time: $RUNtime seconds\n";
|
||||
}
|
||||
|
||||
|
||||
echo "+------+-------------------------------------------------------------------------------------------------------+-------+\n\n";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$ENDtime = date("U");
|
||||
$RUNtime = ($ENDtime - $STARTtime);
|
||||
echo "\nRun Time: $RUNtime seconds\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
</PRE>
|
||||
|
||||
Reference in New Issue
Block a user