LICENSE: AGPLv2
#
# CHANGES
# 90522-0723 - First build
# 90908-1103 - Added DEAD time stats
# 100203-1147 - Added CUSTOMER time statistics
# 100214-1421 - Sort menu alphabetically
# 100216-0042 - Added popup date selector
# 100712-1324 - Added system setting slave server option
# 100802-2347 - Added User Group Allowed Reports option validation
# 100914-1326 - Added lookup for user_level 7 users to set to reports only which will remove other admin links
# 101207-1634 - Changed limits on seconds to 65000 from 30000 in vicidial_agent_log
# 101207-1719 - Fixed download file formatting bugs(issue 394)
# 101208-0320 - Fixed issue 404
# 110307-1057 - Added user_case setting in options.php
# 110623-0728 - Fixed user group selection bug
# 110708-1727 - Added options.php setting for time precision
# 111104-1248 - Added user_group restrictions for selecting in-groups
# 120224-0910 - Added HTML display option with bar graphs
# 121130-0957 - Fix for user group permissions issue #588
# 130414-0137 - Added report logging
# 220414-2111 - Added counts on parked(hold) calls
# 130610-0849 - Finalized changing of all ereg instances to preg
# 130621-0821 - Added filtering of input to prevent SQL injection attacks and new user auth
# 130704-0945 - Fixed issue #675
# 130829-2012 - Changed to mysqli PHP functions
# 131122-0657 - Added options.php atdr_login_logout_user_link option
# 131129-1020 - Fixed division by zero bug in HTML mode
# 140108-0708 - Added webserver and hostname to report logging
# 140314-0852 - Fixed several division by zero bugs
# 140328-0005 - Converted division calculations to use MathZDC function
# 141113-1124 - Finalized adding QXZ translation to all admin files
# 141125-0950 - Changed AGENT TIME to LOGIN TIME for uniform headers with other reports, issue #427
# 141204-0548 - Fix for download headers, issue #805
# 141230-0929 - Added code for on-the-fly language translations display
# 150210-1356 - Added option to show time in seconds
# 150422-1643 - Added two new shift options
# 150516-1311 - Fixed Javascript element problem, Issue #857
# 150529-1921 - Sub statuses are now sorted in alphabetical order
# 151110-1612 - Changed download function to always export time with hours
# 151112-1335 - Added option to search archived tables
# 160121-2037 - Added report title header, default report format, cleaned up formatting
#
$startMS = microtime();
require("dbconnect_mysqli.php");
require("functions.php");
$atdr_login_logout_user_link=0;
if (file_exists('options.php'))
{
require('options.php');
}
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
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"];}
elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];}
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["user_group"])) {$user_group=$_GET["user_group"];}
elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];}
if (isset($_GET["shift"])) {$shift=$_GET["shift"];}
elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];}
if (isset($_GET["stage"])) {$stage=$_GET["stage"];}
elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];}
if (isset($_GET["file_download"])) {$file_download=$_GET["file_download"];}
elseif (isset($_POST["file_download"])) {$file_download=$_POST["file_download"];}
if (isset($_GET["show_parks"])) {$show_parks=$_GET["show_parks"];}
elseif (isset($_POST["show_parks"])) {$show_parks=$_POST["show_parks"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
if (isset($_GET["report_display_type"])) {$report_display_type=$_GET["report_display_type"];}
elseif (isset($_POST["report_display_type"])) {$report_display_type=$_POST["report_display_type"];}
if (isset($_GET["time_in_sec"])) {$time_in_sec=$_GET["time_in_sec"];}
elseif (isset($_POST["time_in_sec"])) {$time_in_sec=$_POST["time_in_sec"];}
if (isset($_GET["search_archived_data"])) {$search_archived_data=$_GET["search_archived_data"];}
elseif (isset($_POST["search_archived_data"])) {$search_archived_data=$_POST["search_archived_data"];}
if (strlen($shift)<2) {$shift='ALL';}
if (strlen($stage)<2) {$stage='NAME';}
if ($search_archived_data=="checked")
{
$agent_log_table="vicidial_agent_log_archive";
$table_check_stmt="show tables like 'vicidial_timeclock_log_archive'";
$table_check_rslt=mysql_to_mysqli($table_check_stmt, $link);
if (mysqli_num_rows($table_check_rslt)>0)
{
$timeclock_log_table="vicidial_timeclock_log_archive";
}
else
{
$timeclock_log_table="vicidial_timeclock_log";
}
}
else
{
$agent_log_table="vicidial_agent_log";
$timeclock_log_table="vicidial_timeclock_log";
}
$report_name = 'Agent Time Detail';
$db_source = 'M';
$JS_text="\n";
echo " \n";
echo " \n";
echo " \n";
echo "
\n";
echo ""._QXZ("$report_name")." $NWB#agent_time_detail$NWE\n";
echo "";
}
if ( (strlen($group[0]) < 1) or (strlen($user_group[0]) < 1) )
{
# echo "\n";
echo _QXZ("PLEASE SELECT A CAMPAIGN OR USER GROUP AND DATE-TIME BELOW AND CLICK SUBMIT")."\n";
echo _QXZ(" NOTE: stats taken from shift specified")."\n";
}
else
{
if ($shift == 'TEST')
{
$time_BEGIN = "09:45:00";
$time_END = "10:00:00";
}
if ($shift == 'AM')
{
$time_BEGIN=$AM_shift_BEGIN;
$time_END=$AM_shift_END;
if (strlen($time_BEGIN) < 6) {$time_BEGIN = "03:45:00";}
if (strlen($time_END) < 6) {$time_END = "15:14:59";}
}
if ($shift == 'PM')
{
$time_BEGIN=$PM_shift_BEGIN;
$time_END=$PM_shift_END;
if (strlen($time_BEGIN) < 6) {$time_BEGIN = "15:15:00";}
if (strlen($time_END) < 6) {$time_END = "23:15:00";}
}
if ($shift == 'ALL')
{
if (strlen($time_BEGIN) < 6) {$time_BEGIN = "00:00:00";}
if (strlen($time_END) < 6) {$time_END = "23:59:59";}
}
if ($shift == '9AM-5PM')
{
$time_BEGIN = "09:00:00";
$time_END = "16:59:59";
}
if ($shift == '5PM-MIDNIGHT')
{
$time_BEGIN = "17:00:00";
$time_END = "23:59:59";
}
$query_date_BEGIN = "$query_date $time_BEGIN";
$query_date_END = "$end_date $time_END";
if ($file_download < 1)
{
$ASCII_text.=""._QXZ("$report_name",40)." $NOW_TIME ($db_source)\n";
$ASCII_text.=_QXZ("Time range").": $query_date_BEGIN to $query_date_END\n\n";
$GRAPH.=_QXZ("$report_name",40)." $NOW_TIME\n";
$GRAPH.=_QXZ("Time range").": $query_date_BEGIN to $query_date_END\n\n";
}
else
{
$file_output .= _QXZ("$report_name",40)." $NOW_TIME\n";
$file_output .= _QXZ("Time range").": $query_date_BEGIN to $query_date_END\n\n";
}
############################################################################
##### BEGIN gathering information from the database section
############################################################################
### BEGIN gather user IDs and names for matching up later
$stmt="select full_name,$userSQL from vicidial_users $whereLOGadmin_viewable_groupsSQL order by user limit 100000;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$users_to_print = mysqli_num_rows($rslt);
$i=0;
$graph_stats=array();
$max_calls=1;
$max_timeclock=1;
$max_agenttime=1;
$max_wait=1;
$max_talk=1;
$max_dispo=1;
$max_pause=1;
$max_dead=1;
$max_customer=1;
$GRAPH.="";
$GRAPH2=""._QXZ("CALLS")." "._QXZ("TIME CLOCK")." "._QXZ("LOGIN TIME")." ";
if ($show_parks) {
$GRAPH2.=""._QXZ("PARKS")." "._QXZ("PARKTIME")." "._QXZ("AVGPARK")." "._QXZ("PARKS/CALL")." ";
}
$GRAPH2.=""._QXZ("WAIT")." "._QXZ("WAIT")." % "._QXZ("TALK")." "._QXZ("TALKTIME")."% "._QXZ("DISPO")." "._QXZ("DISPOTIME")."% "._QXZ("PAUSE")." "._QXZ("PAUSETIME")."% "._QXZ("DEAD")." "._QXZ("DEADTIME")."% "._QXZ("CUSTOMER")." ";
$graph_header=""._QXZ("AGENT TIME BREAKDOWN")." STATUS ";
$CALLS_graph=$graph_header.""._QXZ("CALLS")." ";
$TIMECLOCK_graph=$graph_header.""._QXZ("TIME CLOCK")." ";
$AGENTTIME_graph=$graph_header.""._QXZ("LOGIN TIME")." ";
$WAIT_graph=$graph_header.""._QXZ("WAIT")." ";
$WAITPCT_graph=$graph_header.""._QXZ("WAIT")." % ";
$TALK_graph=$graph_header.""._QXZ("TALK")." ";
$TALKPCT_graph=$graph_header.""._QXZ("TALK TIME")." % ";
$DISPO_graph=$graph_header.""._QXZ("DISPO")." ";
$DISPOPCT_graph=$graph_header.""._QXZ("DISPO TIME")." % ";
$PAUSE_graph=$graph_header.""._QXZ("PAUSE")." ";
$PAUSEPCT_graph=$graph_header.""._QXZ("PAUSE TIME")." % ";
$DEAD_graph=$graph_header.""._QXZ("DEAD")." ";
$DEADPCT_graph=$graph_header.""._QXZ("DEAD TIME")." % ";
$CUSTOMER_graph=$graph_header.""._QXZ("CUSTOMER")." ";
$PARKS_graph=$graph_header.""._QXZ("PARKS")." ";
$PARKTIME_graph=$graph_header.""._QXZ("PARKTIME")." ";
$AVGPARK_graph=$graph_header.""._QXZ("AVGPARK")." ";
$PARKSCALL_graph=$graph_header.""._QXZ("PARKSCALL")." ";
while ($i < $users_to_print)
{
$row=mysqli_fetch_row($rslt);
$ULname[$i] = $row[0];
$ULuser[$i] = $row[1];
$i++;
}
### END gather user IDs and names for matching up later
### BEGIN gather timeclock records per agent
$stmt="select $userSQL,sum(login_sec) from ".$timeclock_log_table." where event IN('LOGIN','START') and event_date >= '$query_date_BEGIN' and event_date <= '$query_date_END' $TCuser_group_SQL group by user limit 10000000;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$punches_to_print = mysqli_num_rows($rslt);
$i=0;
while ($i < $punches_to_print)
{
$row=mysqli_fetch_row($rslt);
$TCuser[$i] = $row[0];
$TCtime[$i] = $row[1];
$i++;
}
### END gather timeclock records per agent
### BEGIN gather pause code information by user IDs
$sub_statuses='-';
$sub_statusesTXT='';
$sub_statusesHEAD='';
$sub_statusesHTML='';
$sub_statusesFILE='';
$sub_statusesARY=$MT;
$sub_status_count=0;
$PCusers='-';
$PCusersARY=$MT;
$PCuser_namesARY=$MT;
$user_count=0;
if ($show_parks)
{
$park_HEADER=" "._QXZ("PARKS",8)." | "._QXZ("PARK TIME",10)." | "._QXZ("AVG PARK",10)." | "._QXZ("PARKS/CALL",10)." |";
$park_HEADER_DIV="+----------+------------+------------+------------";
$park_HEADER_CSV=",PARKS,PARK TIME,AVG PARK,PARKS/CALL";
}
# Displays park info - need to run regardless so HTML view will populate
$park_array=array();
$park_stmt="select user, count(*), sum(parked_sec) From park_log where parked_time <= '$query_date_END' and parked_time >= '$query_date_BEGIN' $park_log_SQL group by user";
if ($DB) {$ASCII_text.= "$park_stmt\n";}
$park_rslt=mysql_to_mysqli($park_stmt, $link);
while ($park_row=mysqli_fetch_row($park_rslt))
{
$park_array[$park_row[0]][0]=$park_row[1];
$park_array[$park_row[0]][1]=$park_row[2];
}
# Grab a list of sub_statuses sorted in order so they will appear in order in the resulting report - otherwise they could appear in any order
$ss_stmt="select distinct sub_status from ".$agent_log_table." where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and pause_sec > 0 and pause_sec < 65000 $group_SQL $user_group_SQL order by sub_status asc limit 10000000;";
$ss_rslt=mysql_to_mysqli($ss_stmt, $link);
$j=0;
while($ss_row=mysqli_fetch_row($ss_rslt)) {
$current_ss=$ss_row[0];
$stmt="select $userSQL,sum(pause_sec),sub_status from ".$agent_log_table." where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and pause_sec > 0 and pause_sec < 65000 and sub_status='$current_ss' $group_SQL $user_group_SQL group by user,sub_status order by user,sub_status desc limit 10000000;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {$ASCII_text.= "$stmt\n";}
$sub_subs_to_print = mysqli_num_rows($rslt);
$subs_to_print+=$sub_subs_to_print;
$i=0;
while ($i < $sub_subs_to_print)
{
$row=mysqli_fetch_row($rslt);
$PCuser[$j] = $row[0];
$PCpause_sec[$j] = $row[1];
$sub_status[$j] = $row[2];
if (!preg_match("/\-$sub_status[$j]\-/i", $sub_statuses))
{
$sub_statusesTXT = sprintf("%10s", $sub_status[$j]);
$sub_statusesHEAD .= "------------+";
$sub_statusesHTML .= " $sub_statusesTXT |";
$sub_statusesFILE .= ",$sub_status[$j]";
$sub_statuses .= "$sub_status[$j]-";
$sub_statusesARY[$sub_status_count] = $sub_status[$j];
$sub_status_count++;
$max_varname="max_".$sub_status[$j];
$$max_varname=1;
}
if (!preg_match("/\-$PCuser[$j]\-/i", $PCusers))
{
$PCusers .= "$PCuser[$j]-";
$PCusersARY[$user_count] = $PCuser[$j];
$user_count++;
}
$i++;
$j++;
}
}
### END gather pause code information by user IDs
##### BEGIN Gather all agent time records and parse through them in PHP to save on DB load
$stmt="select $userSQL,wait_sec,talk_sec,dispo_sec,pause_sec,lead_id,status,dead_sec from ".$agent_log_table." where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' $group_SQL $user_group_SQL limit 10000000;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {$ASCII_text.= "$stmt\n";}
$rows_to_print = mysqli_num_rows($rslt);
$i=0;
$j=0;
$k=0;
$uc=0;
while ($i < $rows_to_print)
{
$row=mysqli_fetch_row($rslt);
$user = $row[0];
$wait = $row[1];
$talk = $row[2];
$dispo = $row[3];
$pause = $row[4];
$lead = $row[5];
$status = $row[6];
$dead = $row[7];
if ($wait > 65000) {$wait=0;}
if ($talk > 65000) {$talk=0;}
if ($dispo > 65000) {$dispo=0;}
if ($pause > 65000) {$pause=0;}
if ($dead > 65000) {$dead=0;}
$customer = ($talk - $dead);
if ($customer < 1)
{$customer=0;}
$TOTwait = ($TOTwait + $wait);
$TOTtalk = ($TOTtalk + $talk);
$TOTdispo = ($TOTdispo + $dispo);
$TOTpause = ($TOTpause + $pause);
$TOTdead = ($TOTdead + $dead);
$TOTcustomer = ($TOTcustomer + $customer);
$TOTALtime = ($TOTALtime + $pause + $dispo + $talk + $wait);
if ( ($lead > 0) and ((!preg_match("/NULL/i",$status)) and (strlen($status) > 0)) ) {$TOTcalls++;}
$user_found=0;
if ($uc < 1)
{
$Suser[$uc] = $user;
$uc++;
}
$m=0;
while ( ($m < $uc) and ($m < 50000) )
{
if ($user == "$Suser[$m]")
{
$user_found++;
$Swait[$m] = ($Swait[$m] + $wait);
$Stalk[$m] = ($Stalk[$m] + $talk);
$Sdispo[$m] = ($Sdispo[$m] + $dispo);
$Spause[$m] = ($Spause[$m] + $pause);
$Sdead[$m] = ($Sdead[$m] + $dead);
$Scustomer[$m] = ($Scustomer[$m] + $customer);
if ( ($lead > 0) and ((!preg_match("/NULL/i",$status)) and (strlen($status) > 0)) ) {$Scalls[$m]++;}
}
$m++;
}
if ($user_found < 1)
{
$Scalls[$uc] = 0;
$Suser[$uc] = $user;
$Swait[$uc] = $wait;
$Stalk[$uc] = $talk;
$Sdispo[$uc] = $dispo;
$Spause[$uc] = $pause;
$Sdead[$uc] = $dead;
$Scustomer[$uc] = $customer;
if ($lead > 0) {$Scalls[$uc]++;}
$uc++;
}
$i++;
}
if ($DB) {echo "Done gathering $i records, analyzing... \n";}
##### END Gather all agent time records and parse through them in PHP to save on DB load
############################################################################
##### END gathering information from the database section
############################################################################
##### BEGIN print the output to screen or put into file output variable
if ($file_download < 1)
{
$ASCII_text.=_QXZ("AGENT TIME BREAKDOWN").":\n";
$ASCII_text.="+-----------------+----------+----------+------------+------------$park_HEADER_DIV+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n";
$ASCII_text.="| "._QXZ("USER NAME",15)." | "._QXZ("ID",8)." | "._QXZ("CALLS",8)." | "._QXZ("TIME CLOCK",10)." | "._QXZ("LOGIN TIME",10)." |$park_HEADER "._QXZ("WAIT",10)." | "._QXZ("WAIT",8)." % | "._QXZ("TALK",10)." | "._QXZ("TALK TIME",9)." %| "._QXZ("DISPO",10)." | "._QXZ("DISPOTIME",9)." %| "._QXZ("PAUSE",10)." | "._QXZ("PAUSETIME",9)." %| "._QXZ("DEAD",10)." | "._QXZ("DEAD TIME",9)." %| "._QXZ("CUSTOMER",10)." | |$sub_statusesHTML\n";
$ASCII_text.="+-----------------+----------+----------+------------+------------$park_HEADER_DIV+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n";
}
else
{
$file_output .= _QXZ("USER").","._QXZ("ID").","._QXZ("CALLS").","._QXZ("TIME CLOCK").","._QXZ("LOGIN TIME").","._QXZ("WAIT").","._QXZ("WAIT %").","._QXZ("TALK").","._QXZ("TALK TIME %").","._QXZ("DISPO").","._QXZ("DISPOTIME %").","._QXZ("PAUSE").","._QXZ("PAUSETIME %").","._QXZ("DEAD").","._QXZ("DEAD TIME %").","._QXZ("CUSTOMER")."$park_HEADER_CSV$sub_statusesFILE\n";
}
##### END print the output to screen or put into file output variable
############################################################################
##### BEGIN formatting data for output section
############################################################################
##### BEGIN loop through each user formatting data for output
$AUTOLOGOUTflag=0;
$m=0;
while ( ($m < $uc) and ($m < 50000) )
{
$SstatusesHTML='';
$SstatusesFILE='';
$Stime[$m] = ($Swait[$m] + $Stalk[$m] + $Sdispo[$m] + $Spause[$m]);
$Swaitpct[$m]=MathZDC(100*$Swait[$m], $Stime[$m]);
$Stalkpct[$m]=MathZDC(100*$Stalk[$m], $Stime[$m]);
$Sdispopct[$m]=MathZDC(100*$Sdispo[$m], $Stime[$m]);
$Spausepct[$m]=MathZDC(100*$Spause[$m], $Stime[$m]);
$Sdeadpct[$m]=MathZDC(100*$Sdead[$m], $Stime[$m]);
$RAWuser = $Suser[$m];
$RAWcalls = $Scalls[$m];
$RAWtimeSEC = $Stime[$m];
if (trim($Scalls[$m])>$max_calls) {$max_calls=trim($Scalls[$m]);}
if (trim($Stime[$m])>$max_agenttime) {$max_agenttime=trim($Stime[$m]);}
if (trim($Swait[$m])>$max_wait) {$max_wait=trim($Swait[$m]);}
if (trim($Stalk[$m])>$max_talk) {$max_talk=trim($Stalk[$m]);}
if (trim($Sdispo[$m])>$max_dispo) {$max_dispo=trim($Sdispo[$m]);}
if (trim($Spause[$m])>$max_pause) {$max_pause=trim($Spause[$m]);}
if (trim($Sdead[$m])>$max_dead) {$max_dead=trim($Sdead[$m]);}
if (trim($Scustomer[$m])>$max_customer) {$max_customer=trim($Scustomer[$m]);}
if (trim($Swaitpct[$m])>$max_waitpct) {$max_waitpct=trim($Swaitpct[$m]);}
if (trim($Stalkpct[$m])>$max_talkpct) {$max_talkpct=trim($Stalkpct[$m]);}
if (trim($Sdispopct[$m])>$max_dispopct) {$max_dispopct=trim($Sdispopct[$m]);}
if (trim($Spausepct[$m])>$max_pausepct) {$max_pausepct=trim($Spausepct[$m]);}
if (trim($Sdeadpct[$m])>$max_deadpct) {$max_deadpct=trim($Sdeadpct[$m]);}
$graph_stats[$m][1]=trim($Scalls[$m]);
$graph_stats[$m][3]=trim($Stime[$m]);
$graph_stats[$m][4]=trim($Swait[$m]);
$graph_stats[$m][5]=trim($Stalk[$m]);
$graph_stats[$m][6]=trim($Sdispo[$m]);
$graph_stats[$m][7]=trim($Spause[$m]);
$graph_stats[$m][8]=trim($Sdead[$m]);
$graph_stats[$m][9]=trim($Scustomer[$m]);
$graph_stats[$m][10]=trim(sprintf("%01.2f", $Stalkpct[$m]));
$graph_stats[$m][11]=trim(sprintf("%01.2f", $Sdispopct[$m]));
$graph_stats[$m][12]=trim(sprintf("%01.2f", $Spausepct[$m]));
$graph_stats[$m][13]=trim(sprintf("%01.2f", $Sdeadpct[$m]));
$graph_stats[$m][14]=trim(sprintf("%01.2f", $Swaitpct[$m]));
$Swaitpct[$m]= sprintf("%01.2f", $Swaitpct[$m]);
$Stalkpct[$m]= sprintf("%01.2f", $Stalkpct[$m]);
$Sdispopct[$m]= sprintf("%01.2f", $Sdispopct[$m]);
$Spausepct[$m]= sprintf("%01.2f", $Spausepct[$m]);
$Sdeadpct[$m]= sprintf("%01.2f", $Sdeadpct[$m]);
$Swait[$m]= sec_convert($Swait[$m],$TIME_agenttimedetail);
$Stalk[$m]= sec_convert($Stalk[$m],$TIME_agenttimedetail);
$Sdispo[$m]= sec_convert($Sdispo[$m],$TIME_agenttimedetail);
$Spause[$m]= sec_convert($Spause[$m],$TIME_agenttimedetail);
$Sdead[$m]= sec_convert($Sdead[$m],$TIME_agenttimedetail);
$Scustomer[$m]= sec_convert($Scustomer[$m],$TIME_agenttimedetail);
$Stime[$m]= sec_convert($Stime[$m],$TIME_agenttimedetail);
$RAWtime = $Stime[$m];
$RAWwait = $Swait[$m];
$RAWtalk = $Stalk[$m];
$RAWdispo = $Sdispo[$m];
$RAWpause = $Spause[$m];
$RAWdead = $Sdead[$m];
$RAWcustomer = $Scustomer[$m];
$RAWwaitpct = $Swaitpct[$m];
$RAWtalkpct = $Stalkpct[$m];
$RAWdispopct = $Sdispopct[$m];
$RAWpausepct = $Spausepct[$m];
$RAWdeadpct = $Sdeadpct[$m];
$n=0;
$user_name_found=0;
while ($n < $users_to_print)
{
if ($Suser[$m] == "$ULuser[$n]")
{
$user_name_found++;
$RAWname = $ULname[$n];
$Sname[$m] = $ULname[$n];
}
$n++;
}
if ($user_name_found < 1)
{
$RAWname = "NOT IN SYSTEM";
$Sname[$m] = $RAWname;
}
$n=0;
$punches_found=0;
while ($n < $punches_to_print)
{
if ($Suser[$m] == "$TCuser[$n]")
{
$punches_found++;
$RAWtimeTCsec = $TCtime[$n];
$TOTtimeTC = ($TOTtimeTC + $TCtime[$n]);
if (trim($RAWtimeTCsec)>$max_timeclock) {$max_timeclock=trim($RAWtimeTCsec);}
$graph_stats[$m][2]=trim($RAWtimeTCsec);
$StimeTC[$m]= sec_convert($TCtime[$n],$TIME_agenttimedetail);
$RAWtimeTC = $StimeTC[$m];
$StimeTC[$m] = sprintf("%10s", $StimeTC[$m]);
}
$n++;
}
if ($punches_found < 1)
{
$RAWtimeTCsec = "0";
$graph_stats[$m][2]=0;
$StimeTC[$m] = "0:00";
if ($TIME_agenttimedetail == 'HF')
{$StimeTC[$m] = "0:00:00";}
if ($TIME_agenttimedetail == 'S')
{$StimeTC[$m] = "0";}
$RAWtimeTC = $StimeTC[$m];
$StimeTC[$m] = sprintf("%10s", $StimeTC[$m]);
}
### Check if the user had an AUTOLOGOUT timeclock event during the time period
$TCuserAUTOLOGOUT = ' ';
$stmt="select count(*) from ".$timeclock_log_table." where event='AUTOLOGOUT' and user='$Suser[$m]' and event_date >= '$query_date_BEGIN' and event_date <= '$query_date_END';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$autologout_results = mysqli_num_rows($rslt);
if ($autologout_results > 0)
{
$row=mysqli_fetch_row($rslt);
if ($row[0] > 0)
{
$TCuserAUTOLOGOUT = '*';
$AUTOLOGOUTflag++;
}
}
### BEGIN loop through each status ###
$n=0;
while ($n < $sub_status_count)
{
$Sstatus=$sub_statusesARY[$n];
$SstatusTXT='';
$varname=$Sstatus."_graph";
$$varname=$graph_header."$Sstatus ";
$max_varname="max_".$Sstatus;
### BEGIN loop through each stat line ###
$i=0; $status_found=0;
while ( ($i < $subs_to_print) and ($status_found < 1) )
{
if ( ($Suser[$m]=="$PCuser[$i]") and ($Sstatus=="$sub_status[$i]") )
{
$USERcodePAUSE_MS = sec_convert($PCpause_sec[$i],$TIME_agenttimedetail);
if (strlen($USERcodePAUSE_MS)<1) {$USERcodePAUSE_MS='0';}
$pfUSERcodePAUSE_MS = sprintf("%10s", $USERcodePAUSE_MS);
if ($PCpause_sec[$i]>$$max_varname) {$$max_varname=$PCpause_sec[$i];}
$graph_stats_sub[$m][$n]=$PCpause_sec[$i];
$SstatusTXT = sprintf("%10s", $pfUSERcodePAUSE_MS);
$SstatusesHTML .= " $SstatusTXT |";
$SstatusesFILE .= ",$USERcodePAUSE_MS";
$status_found++;
}
$i++;
}
if ($status_found < 1)
{
if ($TIME_agenttimedetail == 'HF')
{
$SstatusesHTML .= " 0:00:00 |";
$SstatusesFILE .= ",0:00:00";
}
else
{
if ($TIME_agenttimedetail == 'S')
{
$SstatusesHTML .= " 0 |";
$SstatusesFILE .= ",0";
}
else
{
$SstatusesHTML .= " 0:00 |";
$SstatusesFILE .= ",0:00";
}
}
}
### END loop through each stat line ###
$n++;
}
### END loop through each status ###
$Swaitpct[$m]= sprintf("%9s", $Swaitpct[$m])."%";
$Stalkpct[$m]= sprintf("%9s", $Stalkpct[$m])."%";
$Sdispopct[$m]= sprintf("%9s", $Sdispopct[$m])."%";
$Spausepct[$m]= sprintf("%9s", $Spausepct[$m])."%";
$Sdeadpct[$m]= sprintf("%9s", $Sdeadpct[$m])."%";
$Swait[$m]= sprintf("%10s", $Swait[$m]);
$Stalk[$m]= sprintf("%10s", $Stalk[$m]);
$Sdispo[$m]= sprintf("%10s", $Sdispo[$m]);
$Spause[$m]= sprintf("%10s", $Spause[$m]);
$Sdead[$m]= sprintf("%10s", $Sdead[$m]);
$Scustomer[$m]= sprintf("%10s", $Scustomer[$m]);
$Scalls[$m]= sprintf("%8s", $Scalls[$m]);
$Stime[$m]= sprintf("%10s", $Stime[$m]);
# PARK INFO
if ($show_parks)
{
$user_holds=$park_array[$Suser[$m]][0]+0;
$total_hold_time=$park_array[$Suser[$m]][1]+0;
$TOTuser_holds+=$park_array[$Suser[$m]][0];
$TOTtotal_hold_time+=$park_array[$Suser[$m]][1];
$avg_hold_time=round(MathZDC($total_hold_time, $user_holds));
$user_hpc=sprintf("%.2f", MathZDC($user_holds, $Scalls[$m]));
$total_hold_time=sec_convert($total_hold_time,$TIME_agenttimedetail);
$avg_hold_time=sec_convert($avg_hold_time,$TIME_agenttimedetail);
$user_holds= sprintf("%8s", $user_holds);
$total_hold_time= sprintf("%10s", $total_hold_time);
$avg_hold_time= sprintf("%10s", $avg_hold_time);
$user_hpc= sprintf("%10s", $user_hpc);
$park_AGENT_INFO=" $user_holds | $total_hold_time | $avg_hold_time | $user_hpc |";
$park_AGENT_INFO_CSV="$user_holds,$total_hold_time,$avg_hold_time,$user_hpc,";
}
if (trim($user_holds)>$max_user_holds) {$max_user_holds=trim($user_holds);}
if (trim($park_array[$Suser[$m]][1]+0)>$max_total_hold_time) {$max_total_hold_time=trim($park_array[$Suser[$m]][1]+0);}
if (trim(round(MathZDC(($park_array[$Suser[$m]][1]+0), $user_holds)))>$max_avg_hold_time) {$max_avg_hold_time=trim(round(MathZDC(($park_array[$Suser[$m]][1]+0), $user_holds)));}
if (trim($user_hpc)>$max_user_hpc) {$max_user_hpc=trim($user_hpc);}
$graph_stats[$m][15]=trim($user_holds);
$graph_stats[$m][16]=trim($park_array[$Suser[$m]][1]+0);
$graph_stats[$m][17]=trim(round(MathZDC(($park_array[$Suser[$m]][1]+0), $user_holds)));
$graph_stats[$m][18]=trim($user_hpc);
if ($non_latin < 1)
{
$Sname[$m]= sprintf("%-15s", $Sname[$m]);
while(strlen($Sname[$m])>15) {$Sname[$m] = substr("$Sname[$m]", 0, -1);}
$Suser[$m] = sprintf("%-8s", $Suser[$m]);
while(strlen($Suser[$m])>8) {$Suser[$m] = substr("$Suser[$m]", 0, -1);}
}
else
{
$Sname[$m]= sprintf("%-45s", $Sname[$m]);
while(mb_strlen($Sname[$m],'utf-8')>15) {$Sname[$m] = mb_substr("$Sname[$m]", 0, -1,'utf-8');}
$Suser[$m] = sprintf("%-24s", $Suser[$m]);
while(mb_strlen($Suser[$m],'utf-8')>8) {$Suser[$m] = mb_substr("$Suser[$m]", 0, -1,'utf-8');}
}
if ($file_download < 1)
{
if ($atdr_login_logout_user_link > 0)
{
$Toutput = "| $Sname[$m] | $Suser[$m] | $Scalls[$m] | $StimeTC[$m]$TCuserAUTOLOGOUT| $Stime[$m] |$park_AGENT_INFO $Swait[$m] | $Swaitpct[$m] | $Stalk[$m] | $Stalkpct[$m] | $Sdispo[$m] | $Sdispopct[$m] | $Spause[$m] | $Spausepct[$m] | $Sdead[$m] | $Sdeadpct[$m] | $Scustomer[$m] | |$SstatusesHTML\n";
}
else
{
$Toutput = "| $Sname[$m] | $Suser[$m] | $Scalls[$m] | $StimeTC[$m]$TCuserAUTOLOGOUT| $Stime[$m] |$park_AGENT_INFO $Swait[$m] | $Swaitpct[$m] | $Stalk[$m] | $Stalkpct[$m] | $Sdispo[$m] | $Sdispopct[$m] | $Spause[$m] | $Spausepct[$m] | $Sdead[$m] | $Sdeadpct[$m] | $Scustomer[$m] | |$SstatusesHTML\n";
}
$graph_stats[$m][0]=trim("$Suser[$m] - $Sname[$m]");
$user_IDs[$m]=$Suser[$m];
}
else
{
if (strlen($RAWtime)<1) {$RAWtime='0';}
if (strlen($RAWwait)<1) {$RAWwait='0';}
if (strlen($RAWwaitpct)<0) {$RAWwaitpct='0.0%';}
if (strlen($RAWtalk)<1) {$RAWtalk='0';}
if (strlen($RAWtalkpct)<0) {$RAWtalkpct='0.0%';}
if (strlen($RAWdispo)<1) {$RAWdispo='0';}
if (strlen($RAWdispopct)<0) {$RAWdispopct='0.0%';}
if (strlen($RAWpause)<1) {$RAWpause='0';}
if (strlen($RAWpausepct)<0) {$RAWpausepct='0.0%';}
if (strlen($RAWdead)<1) {$RAWdead='0';}
if (strlen($RAWdeadpct)<0) {$RAWdeadpct='0.0%';}
if (strlen($RAWcustomer)<1) {$RAWcustomer='0';}
$user_holds=trim($user_holds);
$total_hold_time=trim($total_hold_time);
$avg_hold_time=trim($avg_hold_time);
$user_hpc=trim($user_hpc);
$fileToutput = "$RAWname,$RAWuser,$RAWcalls,$RAWtimeTC,$RAWtime,$park_AGENT_INFO_CSV$RAWwait,$RAWwaitpct %,$RAWtalk,$RAWtalkpct %,$RAWdispo,$RAWdispopct %,$RAWpause,$RAWpausepct %,$RAWdead,$RAWdeadpct %,$RAWcustomer$SstatusesFILE\n";
}
$TOPsorted_output[$m] = $Toutput;
$TOPsorted_outputFILE[$m] = $fileToutput;
if ($stage == 'NAME')
{
$TOPsort[$m] = '' . sprintf("%020s", $RAWname) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
$TOPsortTALLY[$m]=$RAWcalls;
}
if ($stage == 'ID')
{
$TOPsort[$m] = '' . sprintf("%08s", $RAWuser) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
$TOPsortTALLY[$m]=$RAWcalls;
}
if ($stage == 'LEADS')
{
$TOPsort[$m] = '' . sprintf("%08s", $RAWcalls) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
$TOPsortTALLY[$m]=$RAWcalls;
}
if ($stage == 'TIME')
{
$TOPsort[$m] = '' . sprintf("%010s", $RAWtimeSEC) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
$TOPsortTALLY[$m]=$RAWtimeSEC;
}
if ($stage == 'TCLOCK')
{
$TOPsort[$m] = '' . sprintf("%010s", $RAWtimeTCsec) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
$TOPsortTALLY[$m]=$RAWtimeTCsec;
}
if (!preg_match('/NAME|ID|TIME|LEADS|TCLOCK/',$stage))
if ($file_download < 1)
{$ASCII_text.="$Toutput";}
else
{$file_output .= "$fileToutput";}
if ($TOPsortMAX < $TOPsortTALLY[$m]) {$TOPsortMAX = $TOPsortTALLY[$m];}
# echo "$Suser[$m]|$Sname[$m]|$Swait[$m]|$Stalk[$m]|$Sdispo[$m]|$Spause[$m]|$Scalls[$m]\n";
$m++;
}
##### END loop through each user formatting data for output
$TOT_AGENTS = $m;
$hTOT_AGENTS = sprintf("%5s", $TOT_AGENTS);
$k=$m;
if ($DB) {echo "Done analyzing... $TOTwait|$TOTtalk|$TOTdispo|$TOTpause|$TOTdead|$TOTcustomer|$TOTALtime|$TOTcalls|$uc| \n";}
### BEGIN sort through output to display properly ###
if ( ($TOT_AGENTS > 0) and (preg_match('/NAME|ID|TIME|LEADS|TCLOCK/',$stage)) )
{
if (preg_match('/ID/',$stage))
{sort($TOPsort, SORT_NUMERIC);}
if (preg_match('/TIME|LEADS|TCLOCK/',$stage))
{rsort($TOPsort, SORT_NUMERIC);}
if (preg_match('/NAME/',$stage))
{rsort($TOPsort, SORT_STRING);}
$m=0;
while ($m < $k)
{
$sort_split = explode("-----",$TOPsort[$m]);
$i = $sort_split[1];
$sort_order[$m] = "$i";
if ($file_download < 1)
{$ASCII_text.="$TOPsorted_output[$i]";}
else
{$file_output .= "$TOPsorted_outputFILE[$i]";}
$m++;
}
}
### END sort through output to display properly ###
############################################################################
##### END formatting data for output section
############################################################################
############################################################################
##### BEGIN last line totals output section
############################################################################
$SUMstatusesHTML='';
$SUMstatusesFILE='';
$TOTtotPAUSE=0;
$n=0;
while ($n < $sub_status_count)
{
$Scalls=0;
$Sstatus=$sub_statusesARY[$n];
$SUMstatusTXT='';
$total_var=$Sstatus."_total";
### BEGIN loop through each stat line ###
$i=0; $status_found=0;
while ($i < $subs_to_print)
{
if ($Sstatus=="$sub_status[$i]")
{
$Scalls = ($Scalls + $PCpause_sec[$i]);
$status_found++;
}
$i++;
}
### END loop through each stat line ###
if ($status_found < 1)
{
$SUMstatusesHTML .= " 0 |";
$$total_var="0";
}
else
{
$TOTtotPAUSE = ($TOTtotPAUSE + $Scalls);
$USERsumstatPAUSE_MS = sec_convert($Scalls,$TIME_agenttimedetail);
$pfUSERsumstatPAUSE_MS = sprintf("%11s", $USERsumstatPAUSE_MS);
$$total_var="$pfUSERsumstatPAUSE_MS";
$SUMstatusTXT = sprintf("%10s", $pfUSERsumstatPAUSE_MS);
$SUMstatusesHTML .= "$SUMstatusTXT |";
$SUMstatusesFILE .= ",$USERsumstatPAUSE_MS";
}
$n++;
}
### END loop through each status ###
### call function to calculate and print dialable leads
$TOTwaitpct=sprintf("%01.2f", MathZDC(100*$TOTwait, $TOTALtime));
$TOTtalkpct=sprintf("%01.2f", MathZDC(100*$TOTtalk, $TOTALtime));
$TOTdispopct=sprintf("%01.2f", MathZDC(100*$TOTdispo, $TOTALtime));
$TOTpausepct=sprintf("%01.2f", MathZDC(100*$TOTpause, $TOTALtime));
$TOTdeadpct=sprintf("%01.2f", MathZDC(100*$TOTdead, $TOTALtime));
$TOTwait = sec_convert($TOTwait,$TIME_agenttimedetail);
$TOTtalk = sec_convert($TOTtalk,$TIME_agenttimedetail);
$TOTdispo = sec_convert($TOTdispo,$TIME_agenttimedetail);
$TOTpause = sec_convert($TOTpause,$TIME_agenttimedetail);
$TOTdead = sec_convert($TOTdead,$TIME_agenttimedetail);
$TOTcustomer = sec_convert($TOTcustomer,$TIME_agenttimedetail);
$TOTALtime = sec_convert($TOTALtime,$TIME_agenttimedetail);
$TOTtimeTC = sec_convert($TOTtimeTC,$TIME_agenttimedetail);
if ($show_parks)
{
$TOTavg_hold_time=round(MathZDC($TOTtotal_hold_time, $TOTuser_holds));
$TOTuser_hpc=sprintf("%.2f", MathZDC($TOTuser_holds, $TOTcalls));
$TOTtotal_hold_time=sec_convert($TOTtotal_hold_time,$TIME_agenttimedetail);
$TOTavg_hold_time=sec_convert($TOTavg_hold_time,$TIME_agenttimedetail);
$hTOTuser_holds= sprintf("%8s", $TOTuser_holds);
$hTOTtotal_hold_time= sprintf("%10s", $TOTtotal_hold_time);
$hTOTavg_hold_time= sprintf("%10s", $TOTavg_hold_time);
$hTOTuser_hpc= sprintf("%10s", $TOTuser_hpc);
$park_TOTALS=" $hTOTuser_holds | $hTOTtotal_hold_time | $hTOTavg_hold_time | $hTOTuser_hpc |";
$park_TOTALS_CSV="$TOTuser_holds,$TOTtotal_hold_time,$TOTavg_hold_time,$TOTuser_hpc,";
}
$hTOTwaitpct = sprintf("%10s", $TOTwaitpct)."%";
$hTOTtalkpct = sprintf("%10s", $TOTtalkpct)."%";
$hTOTdispopct = sprintf("%10s", $TOTdispopct)."%";
$hTOTpausepct = sprintf("%10s", $TOTpausepct)."%";
$hTOTdeadpct = sprintf("%10s", $TOTdeadpct)."%";
$hTOTcalls = sprintf("%8s", $TOTcalls);
$hTOTwait = sprintf("%11s", $TOTwait);
$hTOTtalk = sprintf("%11s", $TOTtalk);
$hTOTdispo = sprintf("%11s", $TOTdispo);
$hTOTpause = sprintf("%11s", $TOTpause);
$hTOTdead = sprintf("%11s", $TOTdead);
$hTOTcustomer = sprintf("%11s", $TOTcustomer);
$hTOTALtime = sprintf("%11s", $TOTALtime);
$hTOTtimeTC = sprintf("%11s", $TOTtimeTC);
###### END LAST LINE TOTALS FORMATTING ##########
if ($file_download < 1)
{
$ASCII_text.="+-----------------+----------+----------+------------+------------$park_HEADER_DIV+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n";
$ASCII_text.="| "._QXZ("TOTALS",10)." "._QXZ("AGENTS",9,"r").":$hTOT_AGENTS | $hTOTcalls |$hTOTtimeTC |$hTOTALtime |$park_TOTALS$hTOTwait |$hTOTwaitpct |$hTOTtalk |$hTOTtalkpct |$hTOTdispo |$hTOTdispopct |$hTOTpause |$hTOTpausepct |$hTOTdead |$hTOTdeadpct |$hTOTcustomer | |$SUMstatusesHTML\n";
$ASCII_text.="+----------------------------+----------+------------+------------$park_HEADER_DIV+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n";
if ($AUTOLOGOUTflag > 0)
{
$ASCII_text.= " * "._QXZ("denotes AUTOLOGOUT from timeclock")."\n";
$HTML_text.= " * "._QXZ("denotes AUTOLOGOUT from timeclock")."\n";
}
$ASCII_text.="\n\n";
for ($e=0; $e$SstatusTXT ";
}
for ($d=0; $d 0)
{
$CALLS_graph.=" ".$graph_stats[$d][0]." ".$graph_stats[$d][1]." ";
}
else
{
$CALLS_graph.=" ".$graph_stats[$d][0]." ".$graph_stats[$d][1]." ";
}
$TIMECLOCK_graph.=" ".$graph_stats[$d][0]." ".sec_convert($graph_stats[$d][2], 'HF')." ";
$AGENTTIME_graph.=" ".$graph_stats[$d][0]." ".sec_convert($graph_stats[$d][3], 'HF')." ";
$WAIT_graph.=" ".$graph_stats[$d][0]." ".sec_convert($graph_stats[$d][4], 'HF')." ";
$TALK_graph.=" ".$graph_stats[$d][0]." ".sec_convert($graph_stats[$d][5], 'HF')." ";
$DISPO_graph.=" ".$graph_stats[$d][0]." ".sec_convert($graph_stats[$d][6], 'HF')." ";
$PAUSE_graph.=" ".$graph_stats[$d][0]." ".sec_convert($graph_stats[$d][7], 'HF')." ";
$DEAD_graph.=" ".$graph_stats[$d][0]." ".sec_convert($graph_stats[$d][8], 'HF')." ";
$CUSTOMER_graph.=" ".$graph_stats[$d][0]." ".sec_convert($graph_stats[$d][9], 'HF')." ";
$TALKPCT_graph.=" ".$graph_stats[$d][0]." ".$graph_stats[$d][10]." % ";
$DISPOPCT_graph.=" ".$graph_stats[$d][0]." ".$graph_stats[$d][11]." % ";
$PAUSEPCT_graph.=" ".$graph_stats[$d][0]." ".$graph_stats[$d][12]." % ";
$DEADPCT_graph.=" ".$graph_stats[$d][0]." ".$graph_stats[$d][13]." % ";
$WAITPCT_graph.=" ".$graph_stats[$d][0]." ".$graph_stats[$d][14]." % ";
$PARKS_graph.=" ".$graph_stats[$d][0]." ".$graph_stats[$d][15]." ";
$PARKTIME_graph.=" ".$graph_stats[$d][0]." ".sec_convert($graph_stats[$d][16],'HF')." ";
$AVGPARK_graph.=" ".$graph_stats[$d][0]." ".sec_convert($graph_stats[$d][17],'HF')." ";
$PARKSCALL_graph.=" ".$graph_stats[$d][0]." ".$graph_stats[$d][18]." ";
for ($e=0; $e ".$$max_varname." //-->\n";
$$varname.=" ".$graph_stats[$d][0]." ".sec_convert($graph_stats_sub[$d][$e], 'HF')." ";
}
}
$CALLS_graph.=""._QXZ("TOTAL").": ".trim($hTOTcalls)."
";
$TIMECLOCK_graph.=""._QXZ("TOTAL").": ".trim($hTOTtimeTC)."
";
$AGENTTIME_graph.=""._QXZ("TOTAL").": ".trim($hTOTALtime)." ";
$WAIT_graph.=""._QXZ("TOTAL").": ".trim($hTOTwait)." ";
$TALK_graph.=""._QXZ("TOTAL").": ".trim($hTOTtalk)." ";
$DISPO_graph.=""._QXZ("TOTAL").": ".trim($hTOTdispo)." ";
$PAUSE_graph.=""._QXZ("TOTAL").": ".trim($hTOTpause)." ";
$DEAD_graph.=""._QXZ("TOTAL").": ".trim($hTOTdead)." ";
$CUSTOMER_graph.=""._QXZ("TOTAL").": ".trim($hTOTcustomer)." ";
$WAITPCT_graph.=""._QXZ("AVERAGE").": ".trim($hTOTwaitpct)." ";
$TALKPCT_graph.=""._QXZ("AVERAGE").": ".trim($hTOTtalkpct)." ";
$DISPOPCT_graph.=""._QXZ("AVERAGE").": ".trim($hTOTdispopct)." ";
$PAUSEPCT_graph.=""._QXZ("AVERAGE").": ".trim($hTOTpausepct)." ";
$DEADPCT_graph.=""._QXZ("AVERAGE").": ".trim($hTOTdeadpct)." ";
$PARKS_graph.=""._QXZ("TOTAL").": ".trim($hTOTuser_holds)." ";
$PARKTIME_graph.=""._QXZ("TOTAL").": ".trim($hTOTtotal_hold_time)." ";
$AVGPARK_graph.=""._QXZ("AVERAGE").": ".trim($hTOTavg_hold_time)." ";
$PARKSCALL_graph.=""._QXZ("AVERAGE").": ".trim($hTOTuser_hpc)." ";
for ($e=0; $e"._QXZ("TOTAL").": ".trim($$total_var)." ";
# $JS_text.="var ".$Sstatus."_graph=\"".$$graph_var."\";\n";
}
$JS_onload.="\tDrawGraph('CALLS', '1');\n";
$JS_text.="function DrawGraph(graph, th_id) {\n";
$JS_text.=" var CALLS_graph=\"$CALLS_graph\";\n";
$JS_text.=" var TIMECLOCK_graph=\"$TIMECLOCK_graph\";\n";
$JS_text.=" var AGENTTIME_graph=\"$AGENTTIME_graph\";\n";
$JS_text.=" var WAIT_graph=\"$WAIT_graph\";\n";
$JS_text.=" var TALK_graph=\"$TALK_graph\";\n";
$JS_text.=" var DISPO_graph=\"$DISPO_graph\";\n";
$JS_text.=" var PAUSE_graph=\"$PAUSE_graph\";\n";
$JS_text.=" var DEAD_graph=\"$DEAD_graph\";\n";
$JS_text.=" var CUSTOMER_graph=\"$CUSTOMER_graph\";\n";
$JS_text.=" var WAITPCT_graph=\"$WAITPCT_graph\";\n";
$JS_text.=" var TALKPCT_graph=\"$TALKPCT_graph\";\n";
$JS_text.=" var DISPOPCT_graph=\"$DISPOPCT_graph\";\n";
$JS_text.=" var PAUSEPCT_graph=\"$PAUSEPCT_graph\";\n";
$JS_text.=" var DEADPCT_graph=\"$DEADPCT_graph\";\n";
$JS_text.=" var PARKS_graph=\"$PARKS_graph\";\n";
$JS_text.=" var PARKTIME_graph=\"$PARKTIME_graph\";\n";
$JS_text.=" var AVGPARK_graph=\"$AVGPARK_graph\";\n";
$JS_text.=" var PARKSCALL_graph=\"$PARKSCALL_graph\";\n";
for ($e=0; $e ";
# echo $GRAPH.$GRAPH2.$GRAPH3.$max;
}
else
{
$file_output .= _QXZ("TOTALS").",$TOT_AGENTS,$TOTcalls,$TOTtimeTC,$TOTALtime,$park_TOTALS_CSV$TOTwait,$TOTwaitpct %,$TOTtalk,$TOTtalkpct %,$TOTdispo,$TOTpause,$TOTdead,$TOTcustomer$SUMstatusesFILE\n";
}
}
############################################################################
##### END formatting data for output section
############################################################################
if ($file_download > 0)
{
$FILE_TIME = date("Ymd-His");
$CSVfilename = "AGENT_TIME$US$FILE_TIME.csv";
// We'll be outputting a TXT file
header('Content-type: application/octet-stream');
// It will be called LIST_101_20090209-121212.txt
header("Content-Disposition: attachment; filename=\"$CSVfilename\"");
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
ob_clean();
flush();
echo "$file_output";
if ($db_source == 'S')
{
mysqli_close($link);
$use_slave_server=0;
$db_source = 'M';
require("dbconnect_mysqli.php");
}
$endMS = microtime();
$startMSary = explode(" ",$startMS);
$endMSary = explode(" ",$endMS);
$runS = ($endMSary[0] - $startMSary[0]);
$runM = ($endMSary[1] - $startMSary[1]);
$TOTALrun = ($runS + $runM);
$stmt="UPDATE vicidial_report_log set run_time='$TOTALrun' where report_log_id='$report_log_id';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
exit;
}
############################################################################
##### BEGIN HTML form section
############################################################################
$JS_onload.="}\n";
if ($report_display_type=='HTML') {$JS_text.=$JS_onload;}
$JS_text.="\n";
echo "";
############################################################################
##### END HTML form section
############################################################################
if ($report_display_type=="HTML")
{
echo $JS_text;
echo $GRAPH.$GRAPH2.$GRAPH3.$max;
}
else
{
echo $ASCII_text;
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "$RUNtime \n";
##### BEGIN horizontal yellow transparent bar graph overlay on top of agent stats
echo " \n";
echo "