From e4d45959dfbc5bc5ba8cad99b5c75f72062d48e5 Mon Sep 17 00:00:00 2001 From: mattf Date: Sat, 27 Aug 2016 13:52:30 +0000 Subject: [PATCH] Added User Group Hourly Report Fixed several reporting bugs git-svn-id: svn://192.168.202.10@2582 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/UPGRADE | 2 + .../www/vicidial/AST_CLOSER_service_level.php | 3 +- .../trunk/www/vicidial/AST_CLOSERstats.php | 48 +- .../trunk/www/vicidial/AST_CLOSERstats_v2.php | 40 +- agc_2-X/trunk/www/vicidial/AST_DIDstats.php | 3 +- agc_2-X/trunk/www/vicidial/AST_VDADstats.php | 44 +- .../www/vicidial/AST_inbound_daily_report.php | 26 +- .../vicidial/AST_user_group_hourly_detail.php | 718 ++++++++++++++++++ agc_2-X/trunk/www/vicidial/admin.php | 11 +- 9 files changed, 833 insertions(+), 62 deletions(-) create mode 100644 agc_2-X/trunk/www/vicidial/AST_user_group_hourly_detail.php diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE index 4f78af3a..7daf319d 100644 --- a/agc_2-X/trunk/UPGRADE +++ b/agc_2-X/trunk/UPGRADE @@ -289,6 +289,8 @@ OTHER CHANGES: 79. Added customer chat options for logo/colors and a survey link after chat is completed. +80. Added the User Group Hourly Report + diff --git a/agc_2-X/trunk/www/vicidial/AST_CLOSER_service_level.php b/agc_2-X/trunk/www/vicidial/AST_CLOSER_service_level.php index 023cbec0..dd00a308 100644 --- a/agc_2-X/trunk/www/vicidial/AST_CLOSER_service_level.php +++ b/agc_2-X/trunk/www/vicidial/AST_CLOSER_service_level.php @@ -33,6 +33,7 @@ # 151125-1627 - Added search archive option # 160227-1153 - Uniform form format # 160714-2348 - Added and tested ChartJS features for more aesthetically appealing graphs +# 160819-0054 - Fixed chart bugs caused by DST # $startMS = microtime(); @@ -1039,7 +1040,7 @@ while ($k <= 22) } -$ASCII_text.="+-------------+-----------------------+-------+-------+ +-----------------------+-------+-------+\n"; +$ASCII_text="+-------------+-----------------------+-------+-------+ +-----------------------+-------+-------+\n"; $ASCII_text.="| "._QXZ("TIME",11)." | "._QXZ("AVG HOLD TIME (sec)",21)." | "._QXZ("(in seconds)",13)." | | "._QXZ("CALLS HANDLED",21)." | | |\n"; $ASCII_text.="| "._QXZ("15 MIN INT",11)." |$hold_scale| "._QXZ("AVG",5)." | "._QXZ("MAX",5)." | |$call_scale| "._QXZ("DROPS",5)." | "._QXZ("TOTAL",5)." |\n"; $ASCII_text.="+-------------+-----------------------+-------+-------+ +-----------------------+-------+-------+\n"; diff --git a/agc_2-X/trunk/www/vicidial/AST_CLOSERstats.php b/agc_2-X/trunk/www/vicidial/AST_CLOSERstats.php index 7840ee2a..af781897 100644 --- a/agc_2-X/trunk/www/vicidial/AST_CLOSERstats.php +++ b/agc_2-X/trunk/www/vicidial/AST_CLOSERstats.php @@ -53,6 +53,7 @@ # 151125-1633 - Added search archive option # 160227-1129 - Uniform form format # 160714-2348 - Added and tested ChartJS features for more aesthetically appealing graphs +# 160819-0054 - Fixed chart bugs # $startMS = microtime(); @@ -1306,7 +1307,7 @@ if ($DID=='Y') $stmt="select count(*),queue_seconds from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and uniqueid IN($unid_SQL) and status IN('DROP','XDROP') group by queue_seconds;"; } $rslt=mysql_to_mysqli($stmt, $link); -if ($DB) {$ASCII_text.="$stmt\n";} +if ($DB) {$ASCII_text.="$stmt\n"; $GRAPH_text.=$stmt."\n";} $reasons_to_print = mysqli_num_rows($rslt); $i=0; $dd_0=0; $dd_5=0; $dd10=0; $dd15=0; $dd20=0; $dd25=0; $dd30=0; $dd35=0; $dd40=0; $dd45=0; $dd50=0; $dd55=0; $dd60=0; $dd90=0; $dd99=0; @@ -1360,6 +1361,7 @@ $ASCII_text.="+----------------------------------------------------------------- $CSV_text2.="\"\",\"$dd_0\",\"$dd_5\",\"$dd10\",\"$dd15\",\"$dd20\",\"$dd25\",\"$dd30\",\"$dd35\",\"$dd40\",\"$dd45\",\"$dd50\",\"$dd55\",\"$dd60\",\"$dd90\",\"$dd99\",\"$BDdropCALLS\"\n"; if ($report_display_type=="HTML") { + $graph_stats=array(); $stmt="select count(*),round(queue_seconds) as rd_sec from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and status IN('DROP','XDROP') group by rd_sec order by rd_sec asc;"; $ms_stmt="select queue_seconds from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and status IN('DROP','XDROP') order by queue_seconds desc limit 1;"; $mc_stmt="select count(*) as ct from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and status IN('DROP','XDROP') group by queue_seconds order by ct desc limit 1;"; @@ -1369,7 +1371,8 @@ if ($report_display_type=="HTML") { $ms_stmt="select queue_seconds from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and uniqueid IN($unid_SQL) and status IN('DROP','XDROP') order by queue_seconds desc limit 1;"; $mc_stmt="select count(*) as ct from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and uniqueid IN($unid_SQL) and status IN('DROP','XDROP') group by queue_seconds order by ct desc limit 1;"; } - if ($DB) {$GRAPH_text.=$stmt."\n";} + if ($DB) {$MAIN.="$stmt\n$ms_stmt\n$mc_stmt\n";} + $ms_rslt=mysql_to_mysqli($ms_stmt, $link); $ms_row=mysqli_fetch_row($ms_rslt); $max_seconds=$ms_row[0]; @@ -1730,6 +1733,7 @@ $CSV_text2.="\""._QXZ("CUM")." %\",\"$pCad_0\",\"$pCad_5\",\"$pCad10\",\"$pCad15 $CSV_text2.="\""._QXZ("CUM ANS")." %\",\"$ApCad_0\",\"$ApCad_5\",\"$ApCad10\",\"$ApCad15\",\"$ApCad20\",\"$ApCad25\",\"$ApCad30\",\"$ApCad35\",\"$ApCad40\",\"$ApCad45\",\"$ApCad50\",\"$ApCad55\",\"$ApCad60\",\"$ApCad90\",\"$ApCad99\"\n"; if ($report_display_type=="HTML") { + $graph_stats=array(); $stmt="select count(*),round(queue_seconds) as rd_sec from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND','MAXCAL') group by rd_sec order by rd_sec asc;"; $ms_stmt="select queue_seconds from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND','MAXCAL') order by queue_seconds desc limit 1;"; $mc_stmt="select count(*) as ct from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND','MAXCAL') group by queue_seconds order by ct desc limit 1;"; @@ -2460,6 +2464,7 @@ $CSV_text6.="\"\",\"$qp_1\",\"$qp_2\",\"$qp_3\",\"$qp_4\",\"$qp_5\",\"$qp_6\",\" if ($report_display_type=="HTML") { + $graph_stats=array(); $stmt="select count(*),queue_position as qp from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) group by qp order by qp asc;"; $ms_stmt="select queue_position from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) order by queue_position desc limit 1;"; $mc_stmt="select count(*) as ct from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) group by queue_position order by ct desc limit 1;"; @@ -2469,22 +2474,24 @@ if ($report_display_type=="HTML") $ms_stmt="select queue_position from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and uniqueid IN($unid_SQL) order by queue_position desc limit 1;"; $mc_stmt="select count(*) as ct from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and uniqueid IN($unid_SQL) group by queue_position order by ct desc limit 1;"; } - if ($DB) {$GRAPH_text.=$stmt."\n";} + if ($DB) {$MAIN.="$stmt\n$ms_stmt\n$mc_stmt\n";} $ms_rslt=mysql_to_mysqli($ms_stmt, $link); $ms_row=mysqli_fetch_row($ms_rslt); $max_position=$ms_row[0]; - if ($max_position>25) {$max_position=26;} - for ($i=1; $i<=$max_position; $i++) { - $sec_ary[$i]=0; + $max_position=26; + for ($i=0; $i<=$max_position; $i++) { + $queue_position[$i]=0; } $mc_rslt=mysql_to_mysqli($mc_stmt, $link); $mc_row=mysqli_fetch_row($mc_rslt); $max_calls=$ms_row[0]; - if ($max_calls<=10) { + if ($max_calls<26) {$max_calls=26;} +# if ($max_calls<=30) { while ($maxcalls%5!=0) { $maxcalls++; } +/* } else if ($max_calls<=100) { while ($maxcalls%10!=0) { $maxcalls++; @@ -2498,16 +2505,27 @@ if ($report_display_type=="HTML") $maxcalls++; } } +*/ $rslt=mysql_to_mysqli($stmt, $link); - - for ($i=0; $i<=$max_seconds; $i++) { - if ($i<=90) { + + $over25=0; + while ($row=mysqli_fetch_row($rslt)) { + if ($row[1]<=25) { + $queue_position[$row[1]]=$row[0]; + } else { + $over25+=$row[0]; + } + } + $queue_position[26]=$over25; + + for ($i=0; $i<=$max_calls; $i++) { + if ($i<=25) { if ($i%5==0) {$int=$i;} else {$int="";} - $graph_stats[$i][0]=$sec_ary[$i]; + $graph_stats[$i][0]=$queue_position[$i]; $graph_stats[$i][1]=$i; } else { - $graph_stats[$i][0]=$sec_ary[$i]; - $graph_stats[$i][1]=91; + $graph_stats[$i][0]=$queue_position[$i]; + $graph_stats[$i][1]=26; } } @@ -2589,7 +2607,7 @@ if ($report_display_type=="HTML") } $graph_count=count($graph_array); - $graph_title=_QXZ("DID Summary"); + $graph_title=_QXZ("CALL INITIAL QUEUE POSITION BREAKDOWN"); include("graphcanvas.inc"); $GRAPH_text.=$graphCanvas."
";
 
@@ -2879,7 +2897,7 @@ while ($i <= 96)
 
 $hour_multiplier = MathZDC(100, $hi_hour_count);
 
-$ASCII_text.="\n";
+$ASCII_text="\n";
 $ASCII_text.=_QXZ("GRAPH IN 15 MINUTE INCREMENTS OF TOTAL")." $rpt_type_verbiages "._QXZ("TAKEN INTO THIS IN-GROUP")."\n";
 
 
diff --git a/agc_2-X/trunk/www/vicidial/AST_CLOSERstats_v2.php b/agc_2-X/trunk/www/vicidial/AST_CLOSERstats_v2.php
index 8589bb77..7a297e8c 100644
--- a/agc_2-X/trunk/www/vicidial/AST_CLOSERstats_v2.php
+++ b/agc_2-X/trunk/www/vicidial/AST_CLOSERstats_v2.php
@@ -56,6 +56,7 @@
 # 151219-1702 - Some text changes for more efficient dynamic language function
 # 160227-1101 - Uniform form format
 # 160714-2348 - Added and tested ChartJS features for more aesthetically appealing graphs
+# 160819-0054 - Fixed chart bugs
 #
 
 $startMS = microtime();
@@ -1705,6 +1706,7 @@ $ASCII_text.="+-----------------------------------------------------------------
 $CSV_text2.="\"\",\"$dd_0\",\"$dd_5\",\"$dd10\",\"$dd15\",\"$dd20\",\"$dd25\",\"$dd30\",\"$dd35\",\"$dd40\",\"$dd45\",\"$dd50\",\"$dd55\",\"$dd60\",\"$dd90\",\"$dd99\",\"$BDdropCALLS\"\n";
 
 if ($report_display_type=="HTML") {
+	$graph_stats=array();
 	$stmt="select count(*),round(queue_seconds) as rd_sec from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $calldate_call_time_clause and campaign_id IN($group_SQL) and status IN('DROP','XDROP') group by rd_sec order by rd_sec asc;";
 	$ms_stmt="select queue_seconds from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $calldate_call_time_clause and campaign_id IN($group_SQL) and status IN('DROP','XDROP') order by queue_seconds desc limit 1;"; 
 	$mc_stmt="select count(*) as ct from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $calldate_call_time_clause and  campaign_id IN($group_SQL) and status IN('DROP','XDROP') group by queue_seconds order by ct desc limit 1;";
@@ -2074,6 +2076,7 @@ $CSV_text2.="\""._QXZ("CUM")." %\",\"$pCad_0\",\"$pCad_5\",\"$pCad10\",\"$pCad15
 $CSV_text2.="\""._QXZ("CUM ANS")." %\",\"$ApCad_0\",\"$ApCad_5\",\"$ApCad10\",\"$ApCad15\",\"$ApCad20\",\"$ApCad25\",\"$ApCad30\",\"$ApCad35\",\"$ApCad40\",\"$ApCad45\",\"$ApCad50\",\"$ApCad55\",\"$ApCad60\",\"$ApCad90\",\"$ApCad99\"\n";
 
 if ($report_display_type=="HTML") {
+	$graph_stats=array();
 	$stmt="select count(*),round(queue_seconds) as rd_sec from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $calldate_call_time_clause and campaign_id IN($group_SQL) and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND','MAXCAL') group by rd_sec order by rd_sec asc;";
 	$ms_stmt="select queue_seconds from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $calldate_call_time_clause and campaign_id IN($group_SQL) and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND','MAXCAL') order by queue_seconds desc limit 1;"; 
 	$mc_stmt="select count(*) as ct from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $calldate_call_time_clause and  campaign_id IN($group_SQL) and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND','MAXCAL') group by queue_seconds order by ct desc limit 1;";
@@ -2803,6 +2806,7 @@ $CSV_text6.="\"\",\"$qp_1\",\"$qp_2\",\"$qp_3\",\"$qp_4\",\"$qp_5\",\"$qp_6\",\"
 
 if ($report_display_type=="HTML") 
 	{
+	$graph_stats=array();
 	$stmt="select count(*),queue_position as qp from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $calldate_call_time_clause and campaign_id IN($group_SQL) group by qp order by qp asc;";
 	$ms_stmt="select queue_position from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $calldate_call_time_clause and campaign_id IN($group_SQL) order by queue_position desc limit 1;"; 
 	$mc_stmt="select count(*) as ct from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $calldate_call_time_clause and campaign_id IN($group_SQL) group by queue_position order by ct desc limit 1;";
@@ -2816,18 +2820,20 @@ if ($report_display_type=="HTML")
 	$ms_rslt=mysql_to_mysqli($ms_stmt, $link);
 	$ms_row=mysqli_fetch_row($ms_rslt);
 	$max_position=$ms_row[0];
-	if ($max_position>25) {$max_position=26;}
-	for ($i=1; $i<=$max_position; $i++) {
-		$sec_ary[$i]=0;
+	$max_position=26;
+	for ($i=0; $i<=$max_position; $i++) {
+		$queue_position[$i]=0;
 	}
 
 	$mc_rslt=mysql_to_mysqli($mc_stmt, $link);
 	$mc_row=mysqli_fetch_row($mc_rslt);
 	$max_calls=$ms_row[0];
-	if ($max_calls<=10) {
+	if ($max_calls<26) {$max_calls=26;}
+#	if ($max_calls<=10) {
 		while ($maxcalls%5!=0) {
 			$maxcalls++;
 		}
+/*
 	} else if ($max_calls<=100) {
 		while ($maxcalls%10!=0) {
 			$maxcalls++;
@@ -2841,19 +2847,31 @@ if ($report_display_type=="HTML")
 			$maxcalls++;
 		}
 	}
+*/
 	$rslt=mysql_to_mysqli($stmt, $link);
+
+	$over25=0;
+	while ($row=mysqli_fetch_row($rslt)) {
+		if ($row[1]<=25) {
+			$queue_position[$row[1]]=$row[0];
+		} else {
+			$over25+=$row[0];
+		}
+	}
+	$queue_position[26]=$over25;
 	
-	for ($i=0; $i<=$max_seconds; $i++) {
-		if ($i<=90) {
+	for ($i=0; $i<=$max_calls; $i++) {
+		if ($i<=25) {
 			if ($i%5==0) {$int=$i;} else {$int="";}
-			$graph_stats[$i][0]=$sec_ary[$i];
+			$graph_stats[$i][0]=$queue_position[$i];
 			$graph_stats[$i][1]=$i;
 		} else {
-			$graph_stats[$i][0]=$sec_ary[$i];
-			$graph_stats[$i][1]=91;
+			$graph_stats[$i][0]=$queue_position[$i];
+			$graph_stats[$i][1]=26;
 		}
 	}
 
+print_r($graph_stats);
 	$GRAPH_text="";	
 	#########
 	$graph_array=array("ACS_CATBdata||CALL INITIAL QUEUE POSITION BREAKDOWN|integer|");
@@ -2932,7 +2950,7 @@ if ($report_display_type=="HTML")
 	}
 
 	$graph_count=count($graph_array);
-	$graph_title=_QXZ("DID Summary");
+	$graph_title=_QXZ("CALL INITIAL QUEUE POSITION BREAKDOWN");
 	include("graphcanvas.inc");
 	$GRAPH_text.=$graphCanvas."
";
 
@@ -3221,7 +3239,7 @@ while ($i <= 96)
 
 $hour_multiplier = MathZDC(100, $hi_hour_count);
 
-$ASCII_text.="\n";
+$ASCII_text="\n";
 $ASCII_text.=_QXZ("GRAPH IN 15 MINUTE INCREMENTS OF TOTAL")." $rpt_type_verbiages "._QXZ("TAKEN INTO THIS IN-GROUP")."\n";
 
 
diff --git a/agc_2-X/trunk/www/vicidial/AST_DIDstats.php b/agc_2-X/trunk/www/vicidial/AST_DIDstats.php
index dd931279..f9298329 100644
--- a/agc_2-X/trunk/www/vicidial/AST_DIDstats.php
+++ b/agc_2-X/trunk/www/vicidial/AST_DIDstats.php
@@ -29,6 +29,7 @@
 # 151125-1614 - Added search archive option
 # 160227-1150 - Uniform form format
 # 160714-2348 - Added and tested ChartJS features for more aesthetically appealing graphs
+# 160819-0054 - Fixed bug causing TEXT report to repeat data
 #
 
 $startMS = microtime();
@@ -1196,7 +1197,7 @@ else
 	#########  HOLD TIME, CALL AND DROP STATS 15-MINUTE INCREMENTS ####
 
 	$MAIN.="\n";
-	$ASCII_text.="---------- "._QXZ("HOLD TIME, CALL AND DROP STATS")."\n";
+	$ASCII_text="---------- "._QXZ("HOLD TIME, CALL AND DROP STATS")."\n";
 
 	$CSV_text1.="\n\""._QXZ("HOLD TIME, CALL AND DROP STATS")."\"\n";
 
diff --git a/agc_2-X/trunk/www/vicidial/AST_VDADstats.php b/agc_2-X/trunk/www/vicidial/AST_VDADstats.php
index 3ab47837..f5ef26a5 100644
--- a/agc_2-X/trunk/www/vicidial/AST_VDADstats.php
+++ b/agc_2-X/trunk/www/vicidial/AST_VDADstats.php
@@ -1235,9 +1235,9 @@ else
 	$ASCII_text .= "+--------+----------------------+----------------------+------------+------------+----------+----------+----------+\n";
 
 	######## GRAPHING #########
-	$GRAPH="

"; - $GRAPH.=""; - $GRAPH.="
"._QXZ("CALLS").""._QXZ("TOTAL TIME").""._QXZ("AVG TIME").""._QXZ("CALLS/HR").""._QXZ("AGENT CALLS/HR")."

 


"; +# $GRAPH="

"; +# $GRAPH.=""; +# $GRAPH.="
"._QXZ("CALLS").""._QXZ("TOTAL TIME").""._QXZ("AVG TIME").""._QXZ("CALLS/HR").""._QXZ("AGENT CALLS/HR")."

 


"; $graph_stats=array(); $max_calls=1; $max_total_time=1; @@ -1512,12 +1512,12 @@ else $ASCII_text .= "| "._QXZ("LIST",40)." | "._QXZ("CALLS",10)." |\n"; $ASCII_text .= "+------------------------------------------+------------+\n"; - $GRAPH="
\n"; - $GRAPH.=""; - $GRAPH.="\n"; - $GRAPH.="\n"; - $GRAPH.="\n"; - $GRAPH.="\n"; +# $GRAPH="
"._QXZ("LIST ID STATS")."
"._QXZ("LIST").""._QXZ("CALLS")."
\n"; +# $GRAPH.=""; +# $GRAPH.="\n"; +# $GRAPH.="\n"; +# $GRAPH.="\n"; +# $GRAPH.="\n"; $stmt="select count(*),list_id from ".$vicidial_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $group_SQLand $list_id_SQLand group by list_id;"; if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);} @@ -1708,12 +1708,12 @@ else $ASCII_text .= "| "._QXZ("PRESET NAME",40)." | "._QXZ("CALLS",10)." |\n"; $ASCII_text .= "+------------------------------------------+------------+\n"; - $GRAPH="
"._QXZ("LIST ID STATS")."
"._QXZ("LIST").""._QXZ("CALLS")."
\n"; - $GRAPH.=""; - $GRAPH.="\n"; - $GRAPH.="\n"; - $GRAPH.="\n"; - $GRAPH.="\n"; + #$GRAPH="
"._QXZ("AGENT PRESET DIALS")."
"._QXZ("PRESET NAME").""._QXZ("CALLS")."
\n"; + #$GRAPH.=""; + #$GRAPH.="\n"; + #$GRAPH.="\n"; + #$GRAPH.="\n"; + #$GRAPH.="\n"; $max_calls=1; $graph_stats=array(); ## get counts and time totals for all statuses in this campaign @@ -1837,12 +1837,12 @@ else $ASCII_text .= "| "._QXZ("CATEGORY",20)." | "._QXZ("CALLS",10)." | "._QXZ("DESCRIPTION",30)." |\n"; $ASCII_text .= "+----------------------+------------+--------------------------------+\n"; - $GRAPH="
"._QXZ("AGENT PRESET DIALS")."
"._QXZ("PRESET NAME").""._QXZ("CALLS")."
\n"; - $GRAPH.=""; - $GRAPH.="\n"; - $GRAPH.="\n"; - $GRAPH.="\n"; - $GRAPH.="\n"; +# $GRAPH="
"._QXZ("CUSTOM STATUS CATEGORY STATS")."
"._QXZ("CATEGORY").""._QXZ("CALLS")."
\n"; +# $GRAPH.=""; +# $GRAPH.="\n"; +# $GRAPH.="\n"; +# $GRAPH.="\n"; +# $GRAPH.="\n"; $max_calls=1; $graph_stats=array(); $TOTCATcalls=0; @@ -2177,6 +2177,8 @@ else include("graphcanvas.inc"); $GRAPH_text.=$graphCanvas; + $GRAPH_text.=""; + if ($costformat > 0) { $stmt="select campaign_id,phone_number,length_in_sec from ".$vicidial_log_table.",vicidial_users where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $group_SQLand $list_id_SQLand and ".$vicidial_log_table.".user=vicidial_users.user;"; 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 418958cb..afb168a8 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 @@ -27,6 +27,7 @@ # 151125-1629 - Added search archive option # 160227-1142 - Uniform form format # 160714-2348 - Added and tested ChartJS features for more aesthetically appealing graphs +# 160819-0054 - Fixed chart bugs caused by DST # $startMS = microtime(); @@ -1296,7 +1297,8 @@ else if (round(MathZDC($totANSWERSsecmtd, $totANSWERSmtd))>$max_mtd_avgtalktime) {$max_mtd_avgtalktime=round(MathZDC($totANSWERSsecmtd, $totANSWERSmtd));} if (trim($totANSWERSsecmtd)>$max_mtd_totaltalktime) {$max_mtd_totaltalktime=trim($totANSWERSsecmtd);} if (trim($totANSWERSsecmtd+($totANSWERSmtd*15))>$max_mtd_totalcalltime) {$max_mtd_totalcalltime=trim($totANSWERSsecmtd+($totANSWERSmtd*15));} - $month=date("F", strtotime($dayEND[$d-1])); + # print $dayEND[$d-1]."\n"; + $month=date("F", strtotime($dayEND[$d-1])-3600); ## ACCOUNT FOR DST IN LABELING $year=substr($dayEND[$d-1], 0, 4); $mtd_graph_stats[$ma][0]="$month $year"; $mtd_graph_stats[$ma][1]=trim($totCALLSmtd); @@ -1716,8 +1718,11 @@ else if (trim($totANSWERSsecmtd)>$max_mtd_totaltalktime) {$max_mtd_totaltalktime=trim($totANSWERSsecmtd);} if (trim($totANSWERSsecmtd+($totANSWERSmtd*15))>$max_mtd_totalcalltime) {$max_mtd_totalcalltime=trim($totANSWERSsecmtd+($totANSWERSmtd*15));} - $month=date("F", strtotime($dayEND[$d-1])); - $year=substr($dayEND[$d-1], 0, 4); + $lastindex=count($dayEND)-1; + $month=date("F", strtotime($dayEND[$lastindex])); + #print_r($mtd_graph_stats); + #echo "$month - $d - ".strtotime($daySTART[$d-1])."\n"; + $year=substr($dayEND[$lastindex], 0, 4); $mtd_graph_stats[$ma][0]="$month $year"; $mtd_graph_stats[$ma][1]=trim($totCALLSmtd); $mtd_graph_stats[$ma][2]=trim($totANSWERSmtd); @@ -1866,12 +1871,14 @@ else if (trim($totANSWERSsecqtd)>$max_qtd_totaltalktime) {$max_qtd_totaltalktime=trim($totANSWERSsecqtd);} if (trim($totANSWERSsecqtd+($totANSWERSqtd*15))>$max_qtd_totalcalltime) {$max_qtd_totalcalltime=trim($totANSWERSsecqtd+($totANSWERSqtd*15));} - $month=date("m", strtotime($dayEND[$d-1])); - $year=substr($dayEND[$d-1], 0, 4); - $qtr1=array(01,02,03); - $qtr2=array(04,05,06); - $qtr3=array(07,08,09); - $qtr4=array(10,11,12); + $lastindex=count($dayEND)-1; + $month=date("m", strtotime($dayEND[$lastindex])-3600); ## ACCOUNT FOR DST IN LABELING + $year=substr($dayEND[$lastindex], 0, 4); + + $qtr1=array("01","02","03"); + $qtr2=array("04","05","06"); + $qtr3=array("07","08","09"); + $qtr4=array("10","11","12"); if(in_array($month,$qtr1)) { $qtr=_QXZ("1st"); } else if(in_array($month,$qtr2)) { @@ -1881,6 +1888,7 @@ else } else if(in_array($month,$qtr4)) { $qtr=_QXZ("4th"); } + $qtd_graph_stats[$qa][0]="$qtr "._QXZ("quarter").", $year"; $qtd_graph_stats[$qa][1]=trim($totCALLSqtd); $qtd_graph_stats[$qa][2]=trim($totANSWERSqtd); diff --git a/agc_2-X/trunk/www/vicidial/AST_user_group_hourly_detail.php b/agc_2-X/trunk/www/vicidial/AST_user_group_hourly_detail.php new file mode 100644 index 00000000..8a635032 --- /dev/null +++ b/agc_2-X/trunk/www/vicidial/AST_user_group_hourly_detail.php @@ -0,0 +1,718 @@ + LICENSE: AGPLv2 +# +# Gives hourly count of distinct agents per user group, with totals. +# For single days only +# +# CHANGES +# 160826-0054 - First build +# + +$startMS = microtime(); + +require("dbconnect_mysqli.php"); +require("functions.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["start_hour"])) {$start_hour=$_GET["start_hour"];} + elseif (isset($_POST["start_hour"])) {$start_hour=$_POST["start_hour"];} +if (isset($_GET["end_hour"])) {$end_hour=$_GET["end_hour"];} + elseif (isset($_POST["end_hour"])) {$end_hour=$_POST["end_hour"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_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["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +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["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["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';} + +$report_name = 'User Group Hourly Report'; +$db_source = 'M'; + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,outbound_autodial_active,slave_db_server,reports_use_slave_db,enable_languages,language_method,report_default_format FROM system_settings;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysqli_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $non_latin = $row[0]; + $outbound_autodial_active = $row[1]; + $slave_db_server = $row[2]; + $reports_use_slave_db = $row[3]; + $SSenable_languages = $row[4]; + $SSlanguage_method = $row[5]; + $SSreport_default_format = $row[6]; + } +##### END SETTINGS LOOKUP ##### + +########################################### +if (strlen($report_display_type)<2) {$report_display_type = $SSreport_default_format;} + +### ARCHIVED DATA CHECK CONFIGURATION +$archives_available="N"; +$log_tables_array=array("vicidial_agent_log"); +for ($t=0; $t 0) + { + $row=mysqli_fetch_row($rslt); + $VUselected_language = $row[0]; + } + +$auth=0; +$reports_auth=0; +$admin_auth=0; +$auth_message = user_authorization($PHP_AUTH_USER,$PHP_AUTH_PW,'REPORTS',1); +if ($auth_message == 'GOOD') + {$auth=1;} + +if ($auth > 0) + { + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 7 and view_reports='1';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $admin_auth=$row[0]; + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 6 and view_reports='1';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $reports_auth=$row[0]; + + if ($reports_auth < 1) + { + $VDdisplayMESSAGE = _QXZ("You are not allowed to view reports"); + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + if ( ($reports_auth > 0) and ($admin_auth < 1) ) + { + $ADD=999999; + $reports_only_user=1; + } + } +else + { + $VDdisplayMESSAGE = _QXZ("Login incorrect, please try again"); + if ($auth_message == 'LOCK') + { + $VDdisplayMESSAGE = _QXZ("Too many login attempts, try again in 15 minutes"); + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$PHP_AUTH_PW|$auth_message|\n"; + exit; + } + +##### BEGIN log visit to the vicidial_report_log table ##### +$LOGip = getenv("REMOTE_ADDR"); +$LOGbrowser = getenv("HTTP_USER_AGENT"); +$LOGscript_name = getenv("SCRIPT_NAME"); +$LOGserver_name = getenv("SERVER_NAME"); +$LOGserver_port = getenv("SERVER_PORT"); +$LOGrequest_uri = getenv("REQUEST_URI"); +$LOGhttp_referer = getenv("HTTP_REFERER"); +if (preg_match("/443/i",$LOGserver_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($LOGserver_port == '80') or ($LOGserver_port == '443') ) {$LOGserver_port='';} +else {$LOGserver_port = ":$LOGserver_port";} +$LOGfull_url = "$HTTPprotocol$LOGserver_name$LOGserver_port$LOGrequest_uri"; + +$LOGhostname = php_uname('n'); +if (strlen($LOGhostname)<1) {$LOGhostname='X';} +if (strlen($LOGserver_name)<1) {$LOGserver_name='X';} + +$stmt="SELECT webserver_id FROM vicidial_webservers where webserver='$LOGserver_name' and hostname='$LOGhostname' LIMIT 1;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {echo "$stmt\n";} +$webserver_id_ct = mysqli_num_rows($rslt); +if ($webserver_id_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $webserver_id = $row[0]; + } +else + { + ##### insert webserver entry + $stmt="INSERT INTO vicidial_webservers (webserver,hostname) values('$LOGserver_name','$LOGhostname');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $affected_rows = mysqli_affected_rows($link); + $webserver_id = mysqli_insert_id($link); + } + +$stmt="INSERT INTO vicidial_report_log set event_date=NOW(), user='$PHP_AUTH_USER', ip_address='$LOGip', report_name='$report_name', browser='$LOGbrowser', referer='$LOGhttp_referer', notes='$LOGserver_name:$LOGserver_port $LOGscript_name |$group[0], $query_date, $end_date, $shift, $file_download, $report_display_type|', url='$LOGfull_url', webserver='$webserver_id';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$report_log_id = mysqli_insert_id($link); +##### END log visit to the vicidial_report_log table ##### + +if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) + { + mysqli_close($link); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect_mysqli.php"); + echo "\n"; + } + +$stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); +$LOGuser_group = $row[0]; + +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; + +if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) + { + Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\""); + Header("HTTP/1.0 401 Unauthorized"); + echo _QXZ("You are not allowed to view this report").": |$PHP_AUTH_USER|$report_name|\n"; + 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 "; + +$LOGadmin_viewable_groupsSQL=''; +$vuLOGadmin_viewable_groupsSQL=''; +$whereLOGadmin_viewable_groupsSQL=''; +if ( (!preg_match('/\-\-ALL\-\-/i',$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $vuLOGadmin_viewable_groupsSQL = "and vicidial_users.user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + +$LOGadmin_viewable_call_timesSQL=''; +$whereLOGadmin_viewable_call_timesSQL=''; +if ( (!preg_match('/\-\-ALL\-\-/i', $LOGadmin_viewable_call_times)) and (strlen($LOGadmin_viewable_call_times) > 3) ) + { + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ -/",'',$LOGadmin_viewable_call_times); + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_call_timesSQL); + $LOGadmin_viewable_call_timesSQL = "and call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + $whereLOGadmin_viewable_call_timesSQL = "where call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + } + +$MT[0]=''; +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} +if (!isset($start_hour)) {$start_hour = date("H");} +if (!isset($end_hour)) {$end_hour = date("H");} + + +$stmt="select user_group from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {$HTML_text.="$stmt\n";} +$user_groups_to_print = mysqli_num_rows($rslt); +$i=0; +while ($i < $user_groups_to_print) + { + $row=mysqli_fetch_row($rslt); + $user_groups[$i] =$row[0]; + $i++; + } + +$i=0; +$user_group_string='|'; +$user_group_ct = count($user_group); +while($i < $user_group_ct) + { + $user_group_string .= "$user_group[$i]|"; + $user_group_SQL .= "'$user_group[$i]',"; + $user_groupQS .= "&user_group[]=$user_group[$i]"; + $i++; + } +if ( (preg_match("/--ALL--/",$user_group_string) ) or ($user_group_ct < 1) ) + {$user_group_SQL = "";} +else + { + $user_group_SQL = preg_replace("/,\$/",'',$user_group_SQL); + $user_group_SQL_str=$user_group_SQL; + $user_group_SQL = "and user_group IN($user_group_SQL)"; + } + + + +$stmt="SELECT campaign_id from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {$HTML_text.="$stmt\n";} +$campaigns_to_print = mysqli_num_rows($rslt); +$i=0; +while ($i < $campaigns_to_print) + { + $row=mysqli_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + +$i=0; +$group_string='|'; +$group_ct = count($group); +while($i < $group_ct) + { + if ( (preg_match("/ $group[$i] /",$regexLOGallowed_campaigns)) or (preg_match("/-ALL/",$LOGallowed_campaigns)) ) + { + $group_string .= "$group[$i]|"; + $group_SQL .= "'$group[$i]',"; + $groupQS .= "&group[]=$group[$i]"; + } + $i++; + } + +if ( (preg_match("/--ALL--/",$group_string) ) or ($group_ct < 1) ) + {$group_SQL = "";} +else + { + $group_SQL = preg_replace("/,\$/",'',$group_SQL); + $group_SQL_str=$group_SQL; + $group_SQL = "and campaign_id IN($group_SQL)"; + } + + + +$LINKbase = "$PHP_SELF?query_date=$query_date&end_date=$end_date&shift=$shift&DB=$DB&user=$user$groupQS&search_archived_data=$search_archived_data&report_display_type=$report_display_type"; + +$NWB = "   \"HELP\""; + +if ($file_download < 1) + { + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + # require("chart_button.php"); + # echo "\n"; + # echo "\n"; + + echo "\n"; + echo ""._QXZ("$report_name")."\n"; + echo ""; + + $short_header=1; + + require("admin_header.php"); + + echo "\n"; + echo "\n"; + echo ""._QXZ("$report_name")."\n"; + echo "
";
+	}
+
+/*
+if (strlen($group[0]) < 1)
+	{
+	echo "";
+	echo _QXZ("PLEASE SELECT A USER AND DATE-TIME BELOW AND CLICK SUBMIT")."\n";
+	echo " "._QXZ("NOTE: stats taken from shift specified")."\n";
+	}
+else
+	{
+	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";}
+		}
+	$query_date_BEGIN = "$query_date $time_BEGIN";   
+
+	if (strlen($group[0]) < 1)
+		{
+		echo "";
+		echo _QXZ("PLEASE SELECT A DATE-HOUR AND USER GROUP BELOW AND CLICK SUBMIT")."\n";
+		echo " "._QXZ("NOTE: stats taken from shift specified")."\n";
+		}
+	else
+		{
+		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";}
+			}
+		$query_date_BEGIN = "$query_date $time_BEGIN";   
+		$query_date_END = "$query_date $time_END";
+
+		if ($file_download < 1)
+			{
+			$ASCII_text.=_QXZ("Agent Days Status Report",24).": $user                     $NOW_TIME ($db_source)\n";
+			$ASCII_text.=_QXZ("Time range").": $query_date_BEGIN "._QXZ("to")." $query_date_END\n\n";
+			}
+		else
+			{
+			$file_output .= _QXZ("Agent Days Status Report",24).": $user                     $NOW_TIME ($db_source)\n";
+			$file_output .= _QXZ("Time range").": $query_date_BEGIN "._QXZ("to")." $query_date_END\n\n";
+			}
+
+		$statuses='-';
+		$statusesTXT='';
+		$statusesHEAD='';
+		$statusesHTML='';
+		$statusesFILE='';
+		$statusesARY[0]='';
+		$j=0;
+		$dates='-';
+		$datesARY[0]='';
+		$date_namesARY[0]='';
+		$k=0;
+		}
+	}
+*/
+
+if ($SUBMIT && $query_date && $start_hour && $end_hour) {
+
+	$CSV_text .= "\""._QXZ("$report_name",24).":  $NOW_TIME ($db_source)\"\n\n";
+	$CSV_text .= "\""._QXZ("Time range").": $query_date $start_hour:00:00 "._QXZ("to")." $query_date $end_hour:59:59\"\n";
+	$CSV_text .= "\""._QXZ("User groups").": ".implode(', ', $user_group)."\"\n";
+	$CSV_text .= "\""._QXZ("Campaigns").": ".implode(', ', $group)."\"\n\n";
+
+	$ASCII_text .= _QXZ("$report_name",24).": $user                     $NOW_TIME ($db_source)\n\n";
+	$ASCII_text .= _QXZ("Time range").": $query_date $start_hour:00:00 "._QXZ("to")." $query_date $end_hour:59:59\n";
+	$ASCII_text .= _QXZ("User groups").": ".implode(', ', $user_group)."\n";
+	$ASCII_text .= _QXZ("Campaigns").": ".implode(', ', $group)."\n\n";
+
+	$stmt="select user_group, substr(event_time, 12,2) as hour, count(distinct user) as ct from ".$vicidial_agent_log_table." where event_time>='$query_date $start_hour:00:00' and event_time<='$query_date $end_hour:59:59' $group_SQL $user_group_SQL group by user_group, hour order by user_group, hour";
+	$rslt=mysql_to_mysqli($stmt, $link);
+
+	# select user_group, substr(event_time, 12,2) as hour, count(distinct user) as ct from ".$vicidial_agent_log_table." where ((event_time>='$query_date $start_hour:00:00' and event_time<='$query_date $end_hour:59:59') or  (event_time+INTERVAL (pause_sec+wait_sec+talk_sec+dispo_sec) SECOND>='$query_date $start_hour:00:00' and event_time+INTERVAL (pause_sec+wait_sec+talk_sec+dispo_sec) SECOND<='$query_date $end_hour:59:59')) $group_SQL $user_group_SQL group by user_group, hour order by user_group, hour
+
+	$user_group_array=array();
+	$hour_array=array();
+	$hour_total_array=array();
+	while($row=mysqli_fetch_array($rslt)) {
+		$user_group_array[$row["user_group"]]+=$row["ct"];
+		$hour_array[$row["hour"]]+=$row["ct"];
+		$hour_total_array[$row["user_group"]][$row["hour"]]+=$row["ct"];  # For ASCII/CSV output
+		$usergroup_total_array[$row["hour"]][$row["user_group"]]+=$row["ct"]; # For GRAPH output
+	}
+
+	$total_stmt="select user_group, count(distinct user) as ct from ".$vicidial_agent_log_table." where event_time>='$query_date $start_hour:00:00' and event_time<='$query_date $end_hour:59:59' $group_SQL $user_group_SQL group by user_group order by user_group";
+	$total_rslt=mysql_to_mysqli($total_stmt, $link);
+	$total_array=array();
+	while ($total_row=mysqli_fetch_array($total_rslt)) {
+		$total_array[$total_row["user_group"]]+=$total_row["ct"];
+	}
+
+	$grand_total_stmt="select distinct user from ".$vicidial_agent_log_table." where event_time>='$query_date $start_hour:00:00' and event_time<='$query_date $end_hour:59:59' $group_SQL $user_group_SQL";
+	$grand_total_rslt=mysql_to_mysqli($grand_total_stmt, $link);
+	$grand_total=mysqli_num_rows($grand_total_rslt);
+
+	$ASCII_header ="+----------------------+--------+";
+	$ASCII_title .="| "._QXZ("USER GROUP", 20)." | "._QXZ("AGENTS", 6)." |";
+	$ASCII_total .="|               "._QXZ("TOTALS", 6)." | ".sprintf("%6s", $grand_total)." |";
+
+	$CSV_text.="\""._QXZ("USER GROUP")."\",\""._QXZ("AGENTS")."\"";
+	$CSV_total.="\""._QXZ("TOTALS")."\",\"$grand_total\"";
+
+	while (list($key, $val)=each($hour_array)) {	
+		$ASCII_title.=" ".date("ha", strtotime("$key:00"))." to ";
+		$key1=$key+1;
+		$ASCII_title.=date("ha", strtotime("$key1:00"))." |";
+		$ASCII_header.="--------------+";
+		$ASCII_total.=" ".sprintf("%12s", ($hour_array[$key]+0))." |";
+
+		$CSV_text.=",\"".date("ha", strtotime("$key:00"))." to ".date("ha", strtotime("$key1:00"))."\"";
+		$CSV_total.=",\"".($hour_array[$key]+0)."\"";
+	}
+	reset($hour_array);
+	reset($user_group_array);
+
+	# print_r($user_group_array);
+	# print_r($hour_array);
+	# print_r($total_array);
+
+	$ASCII_text.=$ASCII_header."\n";
+	$ASCII_text.=$ASCII_title."\n";
+	$ASCII_text.=$ASCII_header."\n";
+
+	$CSV_text.="\n";
+
+	while (list($key, $val)=each($user_group_array)) {
+		$ASCII_text.="| ".sprintf("%20s", $key)." | ".sprintf("%6s", $total_array[$key])." |";
+		$CSV_text.="\"$key\",\"".$total_array[$key]."\"";
+		while (list($key2, $val2)=each($hour_array)) {	
+			$ASCII_text.=" ".sprintf("%12s", ($hour_total_array[$key][$key2]+0))." |";
+			$CSV_text.=",\"".($hour_total_array[$key][$key2]+0)."\"";
+		}
+		reset($hour_array);
+		$CSV_text.="\n";
+		$ASCII_text.="\n";
+
+	}
+
+	$ASCII_text.=$ASCII_header."\n";
+	$ASCII_text.=$ASCII_total."\n";
+	$ASCII_text.=$ASCII_header."\n";
+
+	$CSV_text.=$CSV_total."\n";
+}
+
+
+if ($file_download > 0)
+	{
+	$US='_';
+	$FILE_TIME = date("Ymd-His");
+	$CSVfilename = "USER_GROUP_HOURLY_DETAIL_$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 "$CSV_text";
+
+	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;
+	}
+
+
+echo "
"; +echo "
"._QXZ("CUSTOM STATUS CATEGORY STATS")."
"._QXZ("CATEGORY").""._QXZ("CALLS")."
\n"; + +echo ""; +echo ""; +echo "
"._QXZ("Date").":
"; +echo "\n"; +echo ""; +?> + + + + "._QXZ("Campaigns").":
"; +echo "\n"; + +echo "
"._QXZ("Teams/User Groups").":
"; +echo "\n"; +echo "
\n"; +#echo "Display as:
"; +#echo "\n

"; + +if ($archives_available=="Y") + { + echo ""._QXZ("Search archived data")."\n"; + } + +echo "

\n"; +echo "
        "; + +echo "          \n"; +echo ""._QXZ("DOWNLOAD")." |"; +echo " "._QXZ("REPORTS")." \n"; +echo "\n"; +echo "
"._QXZ("Start time").": :00:00"; + +echo "
"._QXZ("End time").": :59:59"; +echo "
"; + +echo ""; + +if ($report_display_type=="HTML") + { + echo $GRAPH_text; + echo $JS_text; + } +else + { + echo $ASCII_text; + } + + +echo "\n"; +?> diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index 9bbf6684..7c52ea6d 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -118,9 +118,9 @@ $PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; $PHP_SELF=$_SERVER['PHP_SELF']; $QUERY_STRING = getenv("QUERY_STRING"); -$Vreports = 'NONE, Real-Time Main Report, Real-Time Campaign Summary, Inbound Report, Inbound Service Level Report, Inbound Summary Hourly Report, Inbound Daily Report, Inbound DID Report, Inbound IVR Report, Outbound Calling Report, Outbound Summary Interval Report, Outbound IVR Report, Fronter - Closer Report, Lists Campaign Statuses Report, Lists Statuses Report, Campaign Status List Report, Export Calls Report, Export Leads Report, Agent Time Detail, Agent Status Detail, Agent Performance Detail, Team Performance Detail, Performance Comparison Report, Single Agent Daily, Single Agent Daily Time, User Group Login Report, User Timeclock Report, User Group Timeclock Status Report, User Timeclock Detail Report, Server Performance Report, Administration Change Log, List Update Stats, User Stats, User Time Sheet, Download List, Dialer Inventory Report, Maximum System Stats, Maximum Stats Detail, Search Leads Logs, Email Log Report, Carrier Log Report, Campaign Debug, Asterisk Debug, Hangup Cause Report, Lists Pass Report, Called Counts List IDs Report, Agent Debug Log Report, Agent-Manager Chat Log, Recording Access Log Report, API Log Report'; +$Vreports = 'NONE, Real-Time Main Report, Real-Time Campaign Summary, Inbound Report, Inbound Service Level Report, Inbound Summary Hourly Report, Inbound Daily Report, Inbound DID Report, Inbound IVR Report, Outbound Calling Report, Outbound Summary Interval Report, Outbound IVR Report, Fronter - Closer Report, Lists Campaign Statuses Report, Lists Statuses Report, Campaign Status List Report, Export Calls Report, Export Leads Report, Agent Time Detail, Agent Status Detail, Agent Performance Detail, Team Performance Detail, Performance Comparison Report, Single Agent Daily, Single Agent Daily Time, User Group Login Report, User Group Hourly Report, User Timeclock Report, User Group Timeclock Status Report, User Timeclock Detail Report, Server Performance Report, Administration Change Log, List Update Stats, User Stats, User Time Sheet, Download List, Dialer Inventory Report, Maximum System Stats, Maximum Stats Detail, Search Leads Logs, Email Log Report, Carrier Log Report, Campaign Debug, Asterisk Debug, Hangup Cause Report, Lists Pass Report, Called Counts List IDs Report, Agent Debug Log Report, Agent-Manager Chat Log, Recording Access Log Report, API Log Report'; -$UGreports = 'ALL REPORTS, NONE, Real-Time Main Report, Real-Time Campaign Summary, Inbound Report, Inbound Report by DID, Inbound Service Level Report, Inbound Summary Hourly Report, Inbound Daily Report, Inbound DID Report, Inbound Email Report, Inbound Chat Report, Inbound IVR Report, Outbound Calling Report, Outbound Summary Interval Report, Outbound IVR Report, Fronter - Closer Report, Lists Campaign Statuses Report, Lists Statuses Report, Campaign Status List Report, Export Calls Report, Export Leads Report, Agent Time Detail, Agent Status Detail, Agent Performance Detail, Team Performance Detail, Performance Comparison Report, Single Agent Daily, Single Agent Daily Time, User Group Login Report, User Timeclock Report, User Group Timeclock Status Report, User Timeclock Detail Report, Server Performance Report, Administration Change Log, List Update Stats, User Stats, User Time Sheet, Download List, Dialer Inventory Report, Custom Reports Links, CallCard Search, Maximum System Stats, Maximum Stats Detail, Search Leads Logs, Email Log Report, Lists Pass Report, Called Counts List IDs Report, Front Page System Summary, Report Page Servers Summary, Admin Utilities Page, Agent Debug Log Report, Agent-Manager Chat Log, Recording Access Log Report, API Log Report'; +$UGreports = 'ALL REPORTS, NONE, Real-Time Main Report, Real-Time Campaign Summary, Inbound Report, Inbound Report by DID, Inbound Service Level Report, Inbound Summary Hourly Report, Inbound Daily Report, Inbound DID Report, Inbound Email Report, Inbound Chat Report, Inbound IVR Report, Outbound Calling Report, Outbound Summary Interval Report, Outbound IVR Report, Fronter - Closer Report, Lists Campaign Statuses Report, Lists Statuses Report, Campaign Status List Report, Export Calls Report, Export Leads Report, Agent Time Detail, Agent Status Detail, Agent Performance Detail, Team Performance Detail, Performance Comparison Report, Single Agent Daily, Single Agent Daily Time, User Group Login Report, User Group Hourly Report, User Timeclock Report, User Group Timeclock Status Report, User Timeclock Detail Report, Server Performance Report, Administration Change Log, List Update Stats, User Stats, User Time Sheet, Download List, Dialer Inventory Report, Custom Reports Links, CallCard Search, Maximum System Stats, Maximum Stats Detail, Search Leads Logs, Email Log Report, Lists Pass Report, Called Counts List IDs Report, Front Page System Summary, Report Page Servers Summary, Admin Utilities Page, Agent Debug Log Report, Agent-Manager Chat Log, Recording Access Log Report, API Log Report'; $Vtables = 'NONE,log_noanswer,did_agent_log,contact_information'; @@ -3861,12 +3861,13 @@ else # 160801-2119 - Added Admin Bulk Tools page link from Admin Utilities page # 160809-1339 - Added customer_chat_screen_colors, customer_chat_survey_link/text as Chat Groups options # 160816-2113 - Added trim to transfer-conf numbers so they don't retain spaces at the beginning or end of the number +# 160827-0917 - Added the User Group Hourly Report # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 9 to access this page the first time -$admin_version = '2.12-564a'; -$build = '160809-1339'; +$admin_version = '2.12-565a'; +$build = '160827-0917'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -36606,6 +36607,8 @@ if ($ADD==999999) {echo " - "._QXZ("Time")."\n";} if ( (preg_match("/User Group Login Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) {echo "
  • "._QXZ("User Group Login Report")."\n";} + if ( (preg_match("/User Group Hourly Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) + {echo "
  • "._QXZ("User Group Hourly Report")."\n";} if ( (preg_match("/User Stats/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) {echo "
  • "._QXZ("User Stats")."\n";} if ( (preg_match("/User Time Sheet/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )