diff --git a/agc_2-X/trunk/www/vicidial/AST_inbound_daily_report.php b/agc_2-X/trunk/www/vicidial/AST_inbound_daily_report.php
index e40ea21c..591c291f 100644
--- a/agc_2-X/trunk/www/vicidial/AST_inbound_daily_report.php
+++ b/agc_2-X/trunk/www/vicidial/AST_inbound_daily_report.php
@@ -33,6 +33,7 @@
# 170829-0040 - Added screen color settings
# 171012-2015 - Fixed javascript/apache errors with graphs
# 191013-0902 - Fixes for PHP7
+# 200701-1500 - Added option to exclude after-hours from abandons, list ID filtering
#
$startMS = microtime();
@@ -50,6 +51,8 @@ $PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
+if (isset($_GET["list_ids"])) {$list_ids=$_GET["list_ids"];}
+ elseif (isset($_POST["list_ids"])) {$list_ids=$_POST["list_ids"];}
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];}
@@ -64,6 +67,8 @@ if (isset($_GET["show_disposition_statuses"])) {$show_disposition_statuses=$_G
elseif (isset($_POST["show_disposition_statuses"])) {$show_disposition_statuses=$_POST["show_disposition_statuses"];}
if (isset($_GET["ignore_afterhours"])) {$ignore_afterhours=$_GET["ignore_afterhours"];}
elseif (isset($_POST["ignore_afterhours"])) {$ignore_afterhours=$_POST["ignore_afterhours"];}
+if (isset($_GET["exclude_afterhours"])) {$exclude_afterhours=$_GET["exclude_afterhours"];}
+ elseif (isset($_POST["exclude_afterhours"])) {$exclude_afterhours=$_POST["exclude_afterhours"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
@@ -275,6 +280,17 @@ if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL
exit;
}
+$LOGallowed_campaignsSQL='';
+$whereLOGallowed_campaignsSQL='';
+if ( (!preg_match('/\-ALL/i', $LOGallowed_campaigns)) )
+ {
+ $rawLOGallowed_campaignsSQL = preg_replace("/ -/",'',$LOGallowed_campaigns);
+ $rawLOGallowed_campaignsSQL = preg_replace("/ /","','",$rawLOGallowed_campaignsSQL);
+ $LOGallowed_campaignsSQL = "and campaign_id IN('$rawLOGallowed_campaignsSQL')";
+ $whereLOGallowed_campaignsSQL = "where campaign_id IN('$rawLOGallowed_campaignsSQL')";
+ }
+$regexLOGallowed_campaigns = " $LOGallowed_campaigns ";
+
$ag[0]='';
$LOGadmin_viewable_groupsSQL='';
$whereLOGadmin_viewable_groupsSQL='';
@@ -322,8 +338,11 @@ $NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($group)) {$group = array();}
+if (!isset($list_ids)) {$list_ids = array(); $all_lists_selected="selected";}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
if (!isset($end_date)) {$end_date = $NOW_DATE;}
+
+###### INGROUPS ######
$groups_selected = count($group);
$group_name_str="";
$groups_selected_str="";
@@ -367,6 +386,55 @@ while ($i < $groups_to_print)
$groups_selected_str=preg_replace('/, $/', '', $groups_selected_str);
$group_name_str=preg_replace('/, $/', '', $group_name_str);
+######################
+
+###### LISTS #########
+$lists_selected = count($list_ids);
+$list_name_str="";
+$lists_selected_str="";
+$lists_selected_URLstr="";
+
+for ($i=0; $i<$lists_selected; $i++)
+ {
+ $selected_group_URLstr.="&list_ids[]=$list_ids[$i]";
+ if ($list_ids[$i]=="--ALL--")
+ {
+ $list_ids=array("--ALL--");
+ $lists_selected=1;
+ $list_name_str.="-- ALL LISTS --";
+ $all_lists_selected="selected";
+ }
+ else
+ {
+ $lists_selected_str.="'$list_ids[$i]', ";
+ }
+ }
+
+$stmt="select list_id,list_name from vicidial_lists $whereLOGallowed_campaignsSQL order by list_id;";
+$rslt=mysql_to_mysqli($stmt, $link);
+if ($DB) {$MAIN.="$stmt\n";}
+$lists_to_print = mysqli_num_rows($rslt);
+$i=0;
+$lists=array();
+$list_names=array();
+$lists_string='|';
+while ($i < $lists_to_print)
+ {
+ $row=mysqli_fetch_row($rslt);
+ $lists[$i] = $row[0];
+ $list_names[$i] = $row[1];
+ $lists_string .= "$lists[$i]|";
+ for ($j=0; $j<$lists_selected; $j++)
+ {
+ if ($list_ids[$j] && $lists[$i]==$list_ids[$j]) {$list_name_str.="$lists[$i] - $list_names[$i], ";}
+ if ($list_ids[$j]=="--ALL--") {$lists_selected_str.="'$lists[$i]', ";}
+ }
+ $i++;
+ }
+
+$lists_selected_str=preg_replace('/, $/', '', $lists_selected_str);
+$list_name_str=preg_replace('/, $/', '', $list_name_str);
+######################
$stmt="select call_time_id,call_time_name from vicidial_call_times $whereLOGadmin_viewable_call_timesSQL order by call_time_id;";
$rslt=mysql_to_mysqli($stmt, $link);
@@ -448,6 +516,24 @@ $MAIN.="});\n";
$MAIN.="o_cal.a_tpl.yearscroll = false;\n";
$MAIN.="// o_cal.a_tpl.weekstart = 1; // Monday week start\n";
$MAIN.="\n";
+$MAIN.="
"._QXZ("Show hourly results")." "._QXZ("Show disposition statuses")." "._QXZ("Ignore after-hours calls");
+$MAIN.=" "._QXZ("Show hourly results")." "._QXZ("Show disposition statuses")." "._QXZ("Ignore after-hours calls")." "._QXZ("Exclude after-hours from abandons");
if ($archives_available=="Y")
{
$MAIN.=" "._QXZ("Search archived data")."\n";
@@ -709,7 +795,7 @@ else
$status_array=array();
if ($show_disposition_statuses) {
- $dispo_stmt="select distinct status from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id in (" . $groups_selected_str . ") $big_shift_time_SQL_clause order by status;";
+ $dispo_stmt="select distinct status from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id in (" . $groups_selected_str . ") and list_id in (" . $lists_selected_str . ") $status_clause $big_shift_time_SQL_clause order by status;";
#echo $dispo_stmt." ";
$dispo_rslt=mysql_to_mysqli($dispo_stmt, $link);
$dispo_str="";
@@ -879,7 +965,7 @@ else
### GRAB ALL RECORDS WITHIN RANGE FROM THE DATABASE ###
- $stmt="select queue_seconds,UNIX_TIMESTAMP(call_date),length_in_sec,status,term_reason,call_date,user from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id in (" . $groups_selected_str . ");";
+ $stmt="select queue_seconds,UNIX_TIMESTAMP(call_date),length_in_sec,status,term_reason,call_date,user from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id in (" . $groups_selected_str . ") and list_id in (" . $lists_selected_str . ") $status_clause;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {$ASCII_text.="$stmt\n";}
$records_to_grab = mysqli_num_rows($rslt);
@@ -1008,12 +1094,16 @@ else
if ($totCALLSmax < $ls[$i]) {$totCALLSmax = $ls[$i];}
if ($qrtCALLSmax[$j] < $ls[$i]) {$qrtCALLSmax[$j] = $ls[$i];}
- if (preg_match('/ABANDON|NOAGENT|QUEUETIMEOUT|AFTERHOURS|MAXCALLS/', $tr[$i]))
+ $abandons_match_str='ABANDON|NOAGENT|QUEUETIMEOUT|AFTERHOURS|MAXCALLS';
+ if (preg_match("/$abandons_match_str/", $tr[$i]))
{
- $totABANDONSdate[$j]++;
- $totABANDONSsecdate[$j]+=$ls[$i];
- $FtotABANDONS++;
- $FtotABANDONSsec+=$ls[$i];
+ if (!$exclude_afterhours || !preg_match('/AFTERHOURS/', $tr[$i]))
+ {
+ $totABANDONSdate[$j]++;
+ $totABANDONSsecdate[$j]+=$ls[$i];
+ $FtotABANDONS++;
+ $FtotABANDONSsec+=$ls[$i];
+ }
}
else
{
diff --git a/agc_2-X/trunk/www/vicidial/user_stats.php b/agc_2-X/trunk/www/vicidial/user_stats.php
index ba3140f3..46d9952b 100644
--- a/agc_2-X/trunk/www/vicidial/user_stats.php
+++ b/agc_2-X/trunk/www/vicidial/user_stats.php
@@ -61,6 +61,7 @@
# 190310-2206 - Added indication of muted recordings by agent
# 191013-0843 - Fixes for PHP7
# 200501-0811 - Added NVAuser option for NVA recordings user column
+# 200702-1710 - Added ANI to INBOUND/CLOSER records for NVAuser, added secondary check to find lead ID for DIDs
#
$startMS = microtime();
@@ -1161,7 +1162,7 @@ else
$stmt="SELECT call_date,length_in_sec,status,phone_number,campaign_id,queue_seconds,list_id,lead_id,term_reason,closecallid from ".$vicidial_closer_log_table." where user='" . mysqli_real_escape_string($link, $user) . "' and call_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and call_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' $query_call_status order by call_date desc limit 10000;";
if ($did > 0)
{
- $stmt="SELECT start_time,length_in_sec,0,caller_code,0,0,0,extension,0,0 from ".$call_log_table." where channel_group='DID_INBOUND' and number_dialed='" . mysqli_real_escape_string($link, $user) . "' and start_time >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and start_time <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' order by start_time desc limit 10000;";
+ $stmt="SELECT start_time,length_in_sec,0,caller_code,0,0,0,extension,0,0,uniqueid from ".$call_log_table." where channel_group='DID_INBOUND' and number_dialed='" . mysqli_real_escape_string($link, $user) . "' and start_time >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and start_time <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' order by start_time desc limit 10000;";
}
else
{
@@ -1193,7 +1194,16 @@ else
$row[7] = ($row[7] + 0);
}
else
- {$row[7]='0';}
+ {
+ $row[7]='0';
+ $lead_id_stmt="select lead_id from vicidial_closer_log where uniqueid='$row[10]'";
+ $lead_id_rslt=mysql_to_mysqli($lead_id_stmt, $link);
+ if (mysqli_num_rows($lead_id_rslt)>0)
+ {
+ $lead_id_row=mysqli_fetch_row($lead_id_rslt);
+ $row[7]=$lead_id_row[0];
+ }
+ }
}
$TOTALinSECONDS = ($TOTALinSECONDS + $row[1]);
$AGENTseconds = ($row[1] - $row[5]);
@@ -1402,6 +1412,7 @@ else
$mute_column=''; $mute_column_csv='';
$agent_column=''; $agent_column_csv='';
+ $ANI_column=''; $ANI_column_csv='';
if ($SSmute_recordings > 0)
{
$mute_column = ""._QXZ("MUTE")." ";
@@ -1411,12 +1422,14 @@ else
{
$agent_column = ""._QXZ("AGENT")." ";
$agent_column_csv = ",\""._QXZ("AGENT")."\"";
+ $ANI_column = ""._QXZ("ANI")." ";
+ $ANI_column_csv = ",\""._QXZ("ANI")."\"";
}
$MAIN.=""._QXZ("RECORDINGS FOR THIS TIME PERIOD: (10000 record limit)")." ["._QXZ("DOWNLOAD")."] \n";
$MAIN.="\n";
- $MAIN.="# $agent_column "._QXZ("LEAD")." "._QXZ("DATE/TIME")." "._QXZ("SECONDS")." "._QXZ("RECID")." "._QXZ("FILENAME")." "._QXZ("LOCATION")." $mute_column \n";
+ $MAIN.="# $agent_column "._QXZ("LEAD")." $ANI_column"._QXZ("DATE/TIME")." "._QXZ("SECONDS")." "._QXZ("RECID")." "._QXZ("FILENAME")." "._QXZ("LOCATION")." $mute_column \n";
$CSV_text8.="\""._QXZ("RECORDINGS FOR THIS TIME PERIOD: (10000 record limit)")."\"\n";
- $CSV_text8.="\"\",\"#\"$agent_column_csv,\""._QXZ("LEAD")."\",\""._QXZ("DATE/TIME")."\",\""._QXZ("SECONDS")."\",\""._QXZ("RECID")."\",\""._QXZ("FILENAME")."\",\""._QXZ("LOCATION")."\"$mute_column_csv\n";
+ $CSV_text8.="\"\",\"#\"$agent_column_csv,\""._QXZ("LEAD")."\",\"$ANI_column_csv\",\""._QXZ("DATE/TIME")."\",\""._QXZ("SECONDS")."\",\""._QXZ("RECID")."\",\""._QXZ("FILENAME")."\",\""._QXZ("LOCATION")."\"$mute_column_csv\n";
if (strlen($query_call_status) > 5)
{
@@ -1427,6 +1440,7 @@ else
$stmt="SELECT recording_id,channel,server_ip,extension,start_time,start_epoch,end_time,end_epoch,length_in_sec,length_in_min,filename,location,lead_id,user,vicidial_id from ".$recording_log_table." where user='" . mysqli_real_escape_string($link, $user) . "' and start_time >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and start_time <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' $CS_vicidial_id_list_SQL order by recording_id desc limit 10000;";
$rslt=mysql_to_mysqli($stmt, $link);
$logs_to_print = mysqli_num_rows($rslt);
+ if ($DB) {$MAIN.="agent activity|$stmt|";}
$u=0;
while ($logs_to_print > $u)
@@ -1439,6 +1453,7 @@ else
$location = $row[11];
$CSV_location=$row[11];
+ $vicidial_id=$row[14];
if (strlen($location)>2)
{
@@ -1489,6 +1504,17 @@ else
$rowx=mysqli_fetch_row($rsltx);
$agent_user = $rowx[0];
}
+
+ $ANI='';
+ $ANI_stmt="SELECT caller_code from call_log where uniqueid='$vicidial_id' order by event_time;";
+ $ANI_rslt=mysql_to_mysqli($ANI_stmt, $link);
+ $ANI_logs_to_print = mysqli_num_rows($ANI_rslt);
+ if ($ANI_logs_to_print > 0)
+ {
+ $ANI_row=mysqli_fetch_row($ANI_rslt);
+ $ANI = $ANI_row[0];
+ }
+
}
if (strlen($location)>30)
@@ -1515,6 +1541,11 @@ else
$NVAuser_csv_record=",\"$agent_user\"";
}
$MAIN.=" $row[12] ";
+ if ($NVAuser > 0)
+ {
+ $MAIN.=" $ANI \n";
+ $NVAuser_csv_record=",\"$ANI\"";
+ }
$MAIN.=" $row[4] \n";
$MAIN.=" $row[8] \n";
$MAIN.=" $row[0] \n";
@@ -1826,3 +1857,4 @@ $rslt=mysql_to_mysqli($stmt, $link);
exit;
?>
+