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
# 160301-2051 - Expanded full name to 25 characters on text display
# 160330-0649 - Fixed issue with names and non-latin setting
#
$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 "
";
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 "