From 0f776c083cc98dd4bc1168e2d2fd942f09935d2d Mon Sep 17 00:00:00 2001 From: mattf Date: Tue, 16 May 2017 10:46:39 +0000 Subject: [PATCH] Added logging of Real-Time report monitoring, and report in Admin Utilities git-svn-id: svn://192.168.202.10@2756 3d104415-ff17-0410-8863-d5cf3c621b8a --- UPGRADE | 2 + www/vicidial/AST_rt_monitor_log_report.php | 781 +++++++++++++++++++++ www/vicidial/admin.php | 10 +- www/vicidial/help.php | 22 + 4 files changed, 811 insertions(+), 4 deletions(-) create mode 100644 www/vicidial/AST_rt_monitor_log_report.php diff --git a/UPGRADE b/UPGRADE index ab454f5d..b56c5522 100644 --- a/UPGRADE +++ b/UPGRADE @@ -158,6 +158,8 @@ OTHER CHANGES: 33. Added start call URL feature support for manual dial calls +34. Added logging of Real-Time report monitoring, and report in Admin Utilities + diff --git a/www/vicidial/AST_rt_monitor_log_report.php b/www/vicidial/AST_rt_monitor_log_report.php new file mode 100644 index 00000000..8f8d25f2 --- /dev/null +++ b/www/vicidial/AST_rt_monitor_log_report.php @@ -0,0 +1,781 @@ +, Joe Johnson LICENSE: AGPLv2 +# +# CHANGES +# +# 170513-0040 - First build +# + +$startMS = microtime(); + +require("dbconnect_mysqli.php"); +require("functions.php"); + +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["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["users"])) {$users=$_GET["users"];} + elseif (isset($_POST["users"])) {$users=$_POST["users"];} +if (isset($_GET["managers"])) {$managers=$_GET["managers"];} + elseif (isset($_POST["managers"])) {$managers=$_POST["managers"];} +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["shift"])) {$shift=$_GET["shift"];} + elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];} +if (isset($_GET["order_by"])) {$order_by=$_GET["order_by"];} + elseif (isset($_POST["order_by"])) {$order_by=$_POST["order_by"];} +if (isset($_GET["agent"])) {$agent=$_GET["agent"];} + elseif (isset($_POST["agent"])) {$agent=$_POST["agent"];} +if (isset($_GET["file_download"])) {$file_download=$_GET["file_download"];} + elseif (isset($_POST["file_download"])) {$file_download=$_POST["file_download"];} +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["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +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 (strlen($shift)<2) {$shift='ALL';} + +$report_name = 'Real-Time Monitoring Log 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 FROM system_settings;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {$MAIN.="$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]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +if ($non_latin < 1) + { + $PHP_AUTH_USER = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_USER); + $PHP_AUTH_PW = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_PW); + } +else + { + $PHP_AUTH_PW = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_PW); + $PHP_AUTH_USER = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_USER); + } + +$stmt="SELECT selected_language from vicidial_users where user='$PHP_AUTH_USER';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$sl_ct = mysqli_num_rows($rslt); +if ($sl_ct > 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,0); +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 = "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; + } + +$stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER';"; +if ($DB) {$MAIN.="|$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) {$MAIN.="|$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=''; +$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')"; + } + +$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')"; + } + + +##### 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"); + $MAIN.="\n"; + } + +$stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER';"; +if ($DB) {$MAIN.="|$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) {$MAIN.="|$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; + } + +$stmt="SELECT campaign_id from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;"; +if ($DB) {$MAIN.="$stmt\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$campaigns_to_print = mysqli_num_rows($rslt); +$i=0; +$campaigns_string='|'; +$campaigns_selected=count($campaign); +while ($i < $campaigns_to_print) + { + $row=mysqli_fetch_row($rslt); + $campaigns[$i] = $row[0]; + $campaigns_string .= "$campaigns[$i]|"; + for ($j=0; $j<$campaigns_selected; $j++) { + if ($campaign[$j] && $campaigns[$i]==$campaign[$j]) {$campaign_name_str.="$campaigns[$i] - $campaign_names[$i], ";} + if ($campaign[$j]=="--ALL--") {$campaigns_selected_str.="'$campaigns[$i]', ";} + } + $i++; + } + + +$i=0; +$users_string='|'; +$users_ct = count($users); +while($i < $users_ct) + { + $users_string .= "$users[$i]|"; + $i++; + } + +$stmt="SELECT user, full_name from vicidial_users $whereLOGadmin_viewable_groupsSQL order by user"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {$MAIN.="$stmt\n";} +$users_to_print = mysqli_num_rows($rslt); +$i=0; +$user_array=array(); # For quick full-name reference +while ($i < $users_to_print) + { + $row=mysqli_fetch_row($rslt); + $user_list[$i]=$row[0]; + $user_names[$i]=$row[1]; + $user_array["$row[0]"]=$row[1]; + if ($all_users) {$user_list[$i]=$row[0];} + $i++; + } + + +$i=0; +$managers_string='|'; +$managers_ct = count($managers); +while($i < $managers_ct) + { + $managers_string .= "$managers[$i]|"; + $i++; + } + +$stmt="SELECT user, full_name from vicidial_users where user_level>=8 $LOGadmin_viewable_groupsSQL order by user"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {$MAIN.="$stmt\n";} +$managers_to_print = mysqli_num_rows($rslt); +$i=0; +$manager_array=array(); # For quick full-name reference +while ($i < $managers_to_print) + { + $row=mysqli_fetch_row($rslt); + $manager_list[$i]=$row[0]; + $manager_names[$i]=$row[1]; + $manager_array["$row[0]"]=$row[1]; + if ($all_managers) {$manager_list[$i]=$row[0];} + $i++; + } + +$MT[0]=''; +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($campaign)) {$campaign = array();} +if (!isset($managers)) {$managers = array();} +if (!isset($users)) {$users = array();} +if (!isset($report_display_type)) {$report_display_type = "HTML";} +if (!isset($query_date)) {$query_date = $NOW_DATE;} +if (!isset($end_date)) {$end_date = $NOW_DATE;} +if (!isset($order_by)) {$order_by="monitor_start_time-asc";} + +$i=0; +$campaign_string='|'; +$campaign_ct = count($campaign); +while($i < $campaign_ct) + { + if (in_array("--ALL--", $campaign)) + { + $campaign_string = "--ALL--"; + $campaign_SQL .= "'$campaign[$i]',"; + $campaignQS = "&campaign[]=--ALL--"; + } + else if ( (strlen($campaign[$i]) > 0) and (preg_match("/\|$campaign[$i]\|/",$campaigns_string)) ) + { + $campaign_string .= "$campaign[$i]|"; + $campaign_SQL .= "'$campaign[$i]',"; + $campaignQS .= "&campaign[]=$campaign[$i]"; + } + $i++; + } +if ( (preg_match('/\-\-ALL\-\-/',$campaign_string) ) or ($campaign_ct < 1) ) + { + $campaign_SQL = ""; + } +else + { + $campaign_SQL = preg_replace('/,$/i', '',$campaign_SQL); + $WHEREcampaign_SQL=" where campaign_id in ($campaign_SQL) "; + $campaign_SQL=" and campaign_id in ($campaign_SQL) "; + } +if (strlen($campaign_SQL)<3) + { + $campaign_SQL=""; + } + +$i=0; +$users_string='|'; +$user_ct = count($users); +while($i < $user_ct) + { + if (in_array("--ALL--", $users)) + { + $users_string = "--ALL--"; + $user_SQL .= "'$users[$i]',"; + $userQS = "&users[]=--ALL--"; + } + else if ( (strlen($users[$i]) > 0) and (!preg_match("/\|$users[$i]\|/",$users_string)) ) + { + $users_string .= "$users[$i]|"; + $user_SQL .= "'$users[$i]',"; + $userQS .= "&users[]=$users[$i]"; + } + $i++; + } +if ( (preg_match('/\-\-ALL\-\-/',$users_string) ) or ($user_ct < 1) ) + { + $user_SQL = ""; + } +else + { + $user_SQL = preg_replace('/,$/i', '',$user_SQL); + $user_SQL = "and agent_user IN($user_SQL)"; + } +if (strlen($user_SQL)<3) {$user_SQL="";} + + + +$i=0; +$manager_string='|'; +$manager_ct = count($managers); +while($i < $manager_ct) + { + $manager_string .= "$managers[$i]|"; + $manager_SQL .= "'$managers[$i]',"; + $managerQS .= "&managers[]=$managers[$i]"; + $i++; + } +if ( (preg_match('/\-\-ALL\-\-/',$manager_string) ) or ($manager_ct < 1) ) + {$manager_SQL = "";} +else + { + $manager_SQL = preg_replace('/,$/i', '',$manager_SQL); + $manager_SQL = "and manager_user IN($manager_SQL)"; + } + +$NWB = "   \"HELP\""; + +$rerun_rpt_URL="$PHP_SELF?query_date=$query_date&end_date=$end_date&report_display_type=$report_display_type$campaignQS$userQS$managerQS&SUBMIT=$SUBMIT"; + +$HEADER.="\n"; +$HEADER.="\n"; +$HEADER.="\n"; +$HEADER.="\n"; +$HEADER.="\n"; +$HEADER.="\n"; +# $HEADER.="\n"; +$HEADER.="\n"; +$HEADER.="\n"; +$HEADER.="\n"; +$HEADER.=""._QXZ("$report_name")."\n"; + +$short_header=1; + +$MAIN.="
\n"; +$MAIN.=""._QXZ("$report_name")." $NWB#rt_monitor_log_report$NWE\n"; + +#$MAIN.="\n"; +$MAIN.="\n"; + +$MAIN.="\n"; + +$MAIN.="\n"; + +$MAIN.="\n"; + +$MAIN.="
"._QXZ("Dates").":
"; +$MAIN.="\n"; + + +$MAIN.=""; + +$MAIN.="\n"; + +$MAIN.="
"._QXZ("to")."
"; + +$MAIN.="\n"; +$MAIN.="
"._QXZ("Campaigns").":
"; +$MAIN.="\n"; +$MAIN.="
"._QXZ("Managers").":
"; +$MAIN.="\n"; +$MAIN.="
"._QXZ("Users").":
"; +$MAIN.="\n"; +$MAIN.="
"; +$MAIN.="Display as:
  "; +$MAIN.="



"._QXZ("DOWNLOAD")." | "._QXZ("MODIFY")." | "._QXZ("REPORTS")."
\n"; +# $MAIN.=""; +$MAIN.="
\n\n";
+
+if ($agents_selected==0 && $campaigns_selected==0)
+	{
+	$MAIN.="\n\n";
+	$MAIN.=_QXZ("PLEASE SELECT AN IN-GROUP AND DATE RANGE ABOVE AND CLICK SUBMIT")."\n";
+	echo "$HEADER";
+	require("admin_header.php");
+	echo "$MAIN";
+	}
+else
+	{
+	$campaign_group_stmt="select closer_campaigns from vicidial_campaigns $WHEREcampaign_SQL";
+	if ($DB) {echo "|$campaign_group_stmt|\n";}
+	$campaign_group_rslt=mysql_to_mysqli($campaign_group_stmt, $link);
+	$campaign_group_SQL="";
+	while ($cg_row=mysqli_fetch_row($campaign_group_rslt)) {
+		if (strlen(trim($cg_row[0]))>0) {
+			$cg_row[0]=preg_replace("/^\s+|\s\-/", "", $cg_row[0]);
+			$campaign_group_SQL.="'".preg_replace("/\s/", "','", $cg_row[0])."',";
+		}		
+	}
+	$campaign_group_SQL=$group_SQL.",".$campaign_group_SQL;
+	$campaign_group_SQL=preg_replace("/^,|,$/", "", $campaign_group_SQL);
+
+	$campaign_string=preg_replace("/^\||\|$/", "", $campaign_string);
+	$users_string=preg_replace("/^\||\|$/", "", $users_string);
+	$manager_string=preg_replace("/^\||\|$/", "", $manager_string);
+
+	$MAIN.=" Date range :  $query_date to $end_date\n";
+	$MAIN.=" Campaigns  :  ".preg_replace("/\|/", ", ", $campaign_string)."\n";
+	$MAIN.=" Managers   :  ".preg_replace("/\|/", ", ", $manager_string)."\n";
+	$MAIN.=" Agents     :  ".preg_replace("/\|/", ", ", $users_string)."\n\n";
+
+	$CSV_text.="\"Date range:\",\"$query_date to $end_date\"\n";
+	$CSV_text.="\"Campaigns:\",\"".preg_replace("/\|/", ", ", $campaign_string)."\"\n";
+	$CSV_text.="\"Managers:\",\"".preg_replace("/\|/", ", ", $manager_string)."\"\n";
+	$CSV_text.="\"Agents:\",\"".preg_replace("/\|/", ", ", $users_string)."\"\n\n";
+
+	$order_by=preg_replace('/\-/', ' ', $order_by);
+
+	$log_stmt="select * from vicidial_rt_monitor_log where monitor_start_time>='$query_date 00:00:00' and monitor_start_time<='$end_date 23:59:59' $campaign_SQL $manager_SQL $user_SQL order by $order_by";
+	$log_rslt=mysql_to_mysqli($log_stmt, $link);
+	if ($DB) {$MAIN.=$log_stmt."\n";}
+
+	if (mysqli_num_rows($log_rslt)>0) {
+
+		$ASCII_header="+---------------------+--------------------------------+-----------------+---------------+-----------------+--------------------------------+-----------------+--------------+---------------+---------+----------+---------------------+----------+---------+\n";
+		$ASCII_text2="| "._QXZ("START TIME", 19)." | "._QXZ("MANAGER", 30)." | "._QXZ("MANAGER SERVER", 15)." | "._QXZ("MANAGER PHONE", 13)." | "._QXZ("MANAGER IP", 15)." | "._QXZ("AGENT MONITORED", 30)." | "._QXZ("AGENT SERVER", 15)." | "._QXZ("AGENT STATUS", 12)." | "._QXZ("AGENT SESSION", 13)." | "._QXZ("LEAD ID", 7)." | "._QXZ("CAMPAIGN", 8)." | "._QXZ("END TIME", 19)." | "._QXZ("LENGTH", 8)." | "._QXZ("TYPE", 7)." |\n";
+
+		$CSV_text.="\"START TIME\",\"MANAGER\",\"MANAGER SERVER\",\"MANAGER PHONE\",\"MANAGER IP\",\"AGENT MONITORED\",\"AGENT SERVER\",\"AGENT STATUS\",\"AGENT SESSION\",\"LEAD ID\",\"CAMPAIGN\",\"END TIME\",\"LENGTH\",\"TYPE\"\n";
+
+		$ASCII_text=$ASCII_header.$ASCII_text2.$ASCII_header;
+
+		$HTML_text ="";
+		$HTML_text.="\n";
+		$HTML_text.="\n";
+		$HTML_text.="\n";
+		$HTML_text.="\n";
+		$HTML_text.="\n";
+		$HTML_text.="\n";
+		$HTML_text.="\n";
+		$HTML_text.="\n";
+		$HTML_text.="\n";
+		$HTML_text.="\n";
+		$HTML_text.="\n";
+		$HTML_text.="\n";
+		$HTML_text.="\n";
+		$HTML_text.="\n";
+		$HTML_text.="\n";
+		$HTML_text.="\n";
+
+		$q=0;
+		while ($log_row=mysqli_fetch_array($log_rslt)) {
+			if ($q%2==0) {$tdclass="records_list_x";} else {$tdclass="records_list_y";}
+			$HTML_text.="\n";
+			$HTML_text.="\n";
+			$HTML_text.="\n";
+			$HTML_text.="\n";
+			$HTML_text.="\n";
+			$HTML_text.="\n";
+			$HTML_text.="\n";
+			$HTML_text.="\n";
+			$HTML_text.="\n";
+			$HTML_text.="\n";
+			$HTML_text.="\n";
+			$HTML_text.="\n";
+			$HTML_text.="\n";
+			$HTML_text.="\n";
+			$HTML_text.="\n";
+			$HTML_text.="\n";
+			$q++;
+
+			$ASCII_text.="| ".sprintf("%-19s", $log_row["monitor_start_time"])." ";
+			$ASCII_text.="| ".sprintf("%-30s", substr($log_row["manager_user"]." - ".$manager_array["$log_row[manager_user]"], 0, 30))." ";
+			$ASCII_text.="| ".sprintf("%-15s", $log_row["manager_server_ip"])." ";
+			$ASCII_text.="| ".sprintf("%-13s", $log_row["manager_phone"])." ";
+			$ASCII_text.="| ".sprintf("%-15s", $log_row["manager_ip"])." ";
+			$ASCII_text.="| ".sprintf("%-30s", substr($log_row["agent_user"]." - ".$user_array["$log_row[agent_user]"], 0, 30))." ";
+			$ASCII_text.="| ".sprintf("%-15s", $log_row["agent_server_ip"])." ";
+			$ASCII_text.="| ".sprintf("%-12s", $log_row["agent_status"])." ";
+			$ASCII_text.="| ".sprintf("%-13s", $log_row["agent_session"])." ";
+			$ASCII_text.="| ".sprintf("%-7s", $log_row["lead_id"])." ";
+			$ASCII_text.="| ".sprintf("%-8s", $log_row["campaign_id"])." ";
+			$ASCII_text.="| ".sprintf("%-19s", $log_row["monitor_end_time"])." ";
+			$ASCII_text.="| ".sprintf("%-8s", $log_row["monitor_sec"])." ";
+			$ASCII_text.="| ".sprintf("%-7s", $log_row["monitor_type"])." |\n";
+
+			$CSV_text.="\"".$log_row["monitor_start_time"]."\",";
+			$CSV_text.="\"".substr($log_row["manager_user"]." - ".$manager_array["$log_row[manager_user]"], 0, 30)."\",";
+			$CSV_text.="\"".$log_row["manager_server_ip"]."\",";
+			$CSV_text.="\"".$log_row["manager_phone"]."\",";
+			$CSV_text.="\"".$log_row["manager_ip"]."\",";
+			$CSV_text.="\"".substr($log_row["agent_user"]." - ".$user_array["$log_row[agent_user]"], 0, 30)."\",";
+			$CSV_text.="\"".$log_row["agent_server_ip"]."\",";
+			$CSV_text.="\"".$log_row["agent_status"]."\",";
+			$CSV_text.="\"".$log_row["agent_session"]."\",";
+			$CSV_text.="\"".$log_row["lead_id"]."\",";
+			$CSV_text.="\"".$log_row["campaign_id"]."\",";
+			$CSV_text.="\"".$log_row["monitor_end_time"]."\",";
+			$CSV_text.="\"".$log_row["monitor_sec"]."\",";
+			$CSV_text.="\"".$log_row["monitor_type"]."\"\n";
+
+		}
+
+		$HTML_text.="
"._QXZ("START TIME").""._QXZ("MANAGER").""._QXZ("MANAGER SERVER").""._QXZ("MANAGER PHONE").""._QXZ("MANAGER IP").""._QXZ("AGENT MONITORED").""._QXZ("AGENT SERVER").""._QXZ("AGENT STATUS").""._QXZ("AGENT SESSION").""._QXZ("LEAD ID").""._QXZ("CAMPAIGN").""._QXZ("END TIME").""._QXZ("LENGTH").""._QXZ("TYPE")."
".$log_row["monitor_start_time"]."".$log_row["manager_user"]." - ".$manager_array["$log_row[manager_user]"]."".$log_row["manager_server_ip"]."".$log_row["manager_phone"]."".$log_row["manager_ip"]."".$log_row["agent_user"]." - ".$user_array["$log_row[agent_user]"]."".$log_row["agent_server_ip"]."".$log_row["agent_status"]."".$log_row["agent_session"]."".$log_row["lead_id"]."".$log_row["campaign_id"]."".$log_row["monitor_end_time"]."".$log_row["monitor_sec"]."".$log_row["monitor_type"]."
\n"; + + $ASCII_text.=$ASCII_header; + } else { + $msg.=" *** NO RECORDS FOUND ***"; + $MAIN.=$msg; + } + + if ($report_display_type=="HTML") + { + $MAIN.=$HTML_text.$HTML_text2; + } + else + { + $MAIN.=$ASCII_text; + } + + $MAIN.="
"; + + $MAIN.="
"; + + if ($file_download>0) + { + $FILE_TIME = date("Ymd-His"); + $CSVfilename = "AST_RT_monitor_log_report_$US$FILE_TIME.csv"; + $CSV_text=preg_replace('/\n +,/', ',', $CSV_text); + $CSV_text=preg_replace('/ +\"/', '"', $CSV_text); + $CSV_text=preg_replace('/\" +/', '"', $CSV_text); + + // 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"; + } + else + { + header("Content-type: text/html; charset=utf-8"); + + echo "$HEADER"; + require("admin_header.php"); + echo "$MAIN"; + flush(); + } + + } + +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); + + +?> + + diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index 64e9a821..a8a26c5f 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -120,9 +120,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 Report by DID, Inbound Service Level Report, Inbound Summary Hourly Report, Inbound Daily Report, Inbound DID Report, Agent DID Report, Inbound IVR Report, Inbound Forecasting Report, Advanced Forecasting Report, Outbound Calling Report, Outbound Summary Interval Report, Outbound IVR Report, Fronter - Closer Report, Fronter - Closer Detail 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 Parked Call 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 Report by DID, Inbound Service Level Report, Inbound Summary Hourly Report, Inbound Daily Report, Inbound DID Report, Agent DID Report, Inbound IVR Report, Inbound Forecasting Report, Advanced Forecasting Report, Outbound Calling Report, Outbound Summary Interval Report, Outbound IVR Report, Fronter - Closer Report, Fronter - Closer Detail 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 Parked Call Report, Agent-Manager Chat Log, Recording Access Log Report, API Log Report, Real-Time Monitoring 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, Agent DID Report, Inbound Email Report, Inbound Chat Report, Inbound IVR Report, Inbound Forecasting Report, Advanced Forecasting Report, Outbound Calling Report, Outbound Summary Interval Report, Outbound IVR Report, Fronter - Closer Report, Fronter - Closer Detail 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 Parked Call 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, Agent DID Report, Inbound Email Report, Inbound Chat Report, Inbound IVR Report, Inbound Forecasting Report, Advanced Forecasting Report, Outbound Calling Report, Outbound Summary Interval Report, Outbound IVR Report, Fronter - Closer Report, Fronter - Closer Detail 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 Parked Call Report, Agent-Manager Chat Log, Recording Access Log Report, API Log Report, Real-Time Monitoring Log Report'; $Vtables = 'NONE,log_noanswer,did_agent_log,contact_information'; @@ -4122,12 +4122,13 @@ else # 170428-1958 - Added Inbound and Advanced Forecasting Reports # 170429-0807 - Added campaign setting callback_display_days # 170430-1001 - Added three_way_record_stop and hangup_xfer_record_start campaign settings +# 170516-0632 - Added Real-Time Monitoring Log 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.14-614a'; -$build = '170430-1001'; +$admin_version = '2.14-615a'; +$build = '170516-0632'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -39712,6 +39713,7 @@ if ($ADD==999994) echo "
  • "._QXZ("Agent LAGGED Report")."\n"; echo "
  • "._QXZ("User Group Login Report")."\n"; echo "
  • "._QXZ("Agent Debug Log Report")."\n"; + echo "
  • "._QXZ("Real-Time Monitoring Log Report")."\n"; echo "
  • "._QXZ("Agent Parked Call Report")."\n"; echo "
  • "._QXZ("Agent-Manager Chat Log")."\n"; echo "
  • "._QXZ("API Log Report")."\n"; diff --git a/www/vicidial/help.php b/www/vicidial/help.php index 5c383872..aa339153 100644 --- a/www/vicidial/help.php +++ b/www/vicidial/help.php @@ -126,6 +126,7 @@ # 170428-1959 - Added Inbound and Advanced Forecasting Reports # 170429-0810 - Added callback_display_days entry # 170430-0957 - Added three_way_record_stop and hangup_xfer_record_start entries +# 170516-0628 - Added rt_monitor_log_report entry # @@ -6643,6 +6644,27 @@ if ($SSqc_features_active > 0) TOTAL COST = Total cost, gotten by multiplying the agent rate by the number of agents (estimated, if an -actual agent- value is not given)"); ?>
    MARGIN = The difference between the total revenue and the total cost"); ?>
    + +



    + +
    + -

    +START TIME = The time the manager started monitoring an agent"); ?>
    +MANAGER = The manager who initiated the monitoring session"); ?>
    +MANAGER SERVER = The IP address of the server the manager was monitoring from"); ?>
    +MANAGER PHONE = The phone login the manager used to monitor the agent"); ?>
    +MANAGER IP = The IP address of the computer the manager was monitoring from"); ?>
    +AGENT MONITORED = The agent ID and name of the agent being monitored"); ?>
    +AGENT SERVER = The IP address of the server the agent phone was operating from"); ?>
    +AGENT STATUS = The dialer status of the agent at the time the monitoring session was initiated"); ?>
    +AGENT SESSION = The session ID of the agent at the time the monitoring session was initiated"); ?>
    +LEAD ID = The lead ID the agent was speaking to at the time the monitoring session was initiated. If the agent was not in a call at the time the manager started monitoring them, this value will be -0-"); ?>
    +CAMPAIGN = The campaign ID the agent being monitored was placing calls from at the time they started being monitored"); ?>
    +END TIME = The time the manager stopped monitoring the agent, ending the monitoring session"); ?>
    +LENGTH = The total length in seconds of the monitoring session"); ?>
    +TYPE = The type of monitoring session that the manager was running"); ?>
    + +