From 8be49547d2a9158e5ecbbe97a95158a13ffc05ec Mon Sep 17 00:00:00 2001 From: mattf Date: Sun, 19 Aug 2012 05:35:03 +0000 Subject: [PATCH] Added Callback User Transfer page formatting changes to inbound daily report git-svn-id: svn://192.168.202.10@1851 3d104415-ff17-0410-8863-d5cf3c621b8a --- UPGRADE | 2 + www/vicidial/AST_inbound_daily_report.php | 129 ++++++---- www/vicidial/admin.php | 1 + www/vicidial/callbacks_bulk_change.php | 285 ++++++++++++++++++++++ 4 files changed, 374 insertions(+), 43 deletions(-) create mode 100644 www/vicidial/callbacks_bulk_change.php diff --git a/UPGRADE b/UPGRADE index bbdecf12..4baaddf2 100644 --- a/UPGRADE +++ b/UPGRADE @@ -84,6 +84,8 @@ OTHER CHANGES: 11. Added System Settings option to disable list counts in admin web screens +12. Added callback user transfer page, linked from Admin Utilities in Reports + diff --git a/www/vicidial/AST_inbound_daily_report.php b/www/vicidial/AST_inbound_daily_report.php index bb63f41b..23ea23b5 100644 --- a/www/vicidial/AST_inbound_daily_report.php +++ b/www/vicidial/AST_inbound_daily_report.php @@ -10,9 +10,16 @@ # 120224-0910 - Added HTML display option with bar graphs # 120601-2235 - Added group name to header, added status breakdown counts to page and CSV with option to display them # 120611-2200 - Added ability to filter output by call time +# 120819-0118 - Formatting changes +# require("dbconnect.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']; @@ -30,6 +37,8 @@ if (isset($_GET["hourly_breakdown"])) {$hourly_breakdown=$_GET["hourly_breakdo elseif (isset($_POST["hourly_breakdown"])) {$hourly_breakdown=$_POST["hourly_breakdown"];} if (isset($_GET["show_disposition_statuses"])) {$show_disposition_statuses=$_GET["show_disposition_statuses"];} elseif (isset($_POST["show_disposition_statuses"])) {$show_disposition_statuses=$_POST["show_disposition_statuses"];} +if (isset($_GET["ignore_afterhours"])) {$ignore_afterhours=$_GET["ignore_afterhours"];} + elseif (isset($_POST["ignore_afterhours"])) {$ignore_afterhours=$_POST["ignore_afterhours"];} if (isset($_GET["submit"])) {$submit=$_GET["submit"];} elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} @@ -47,6 +56,8 @@ if (strlen($shift)<2) {$shift='ALL';} $report_name = 'Inbound Daily Report'; $db_source = 'M'; +if ($ignore_afterhours=="checked") {$status_clause=" and status!='AFTHRS'";} + ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### $stmt = "SELECT use_non_latin,outbound_autodial_active,slave_db_server,reports_use_slave_db FROM system_settings;"; @@ -127,14 +138,34 @@ if ( (!eregi("--ALL--",$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewabl $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; } -$LOGadmin_viewable_call_timesSQL=''; -$whereLOGadmin_viewable_call_timesSQL=''; -if ( (!eregi("--ALL--",$LOGadmin_viewable_call_times)) and (strlen($LOGadmin_viewable_call_times) > 3) ) +if ($IDR_calltime_available==1) { - $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')"; + $LOGadmin_viewable_call_timesSQL=''; + $whereLOGadmin_viewable_call_timesSQL=''; + if ( (!eregi("--ALL--",$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')"; + } + + $stmt="select call_time_id,call_time_name from vicidial_call_times $whereLOGadmin_viewable_call_timesSQL order by call_time_id;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {$MAIN.="$stmt\n";} + $times_to_print = mysql_num_rows($rslt); + $i=0; + while ($i < $times_to_print) + { + $row=mysql_fetch_row($rslt); + $call_times[$i] = $row[0]; + $call_time_names[$i] = $row[1]; + $i++; + } + } +else + { + $shift="24hours"; } $NOW_DATE = date("Y-m-d"); @@ -242,18 +273,24 @@ $MAIN.="  "; $MAIN.="  "; -$MAIN.="\n"; + $MAIN.="\n"; + $o=0; + while ($times_to_print > $o) + { + if ($call_times[$o] == $shift) {$MAIN.="\n";} + else {$MAIN.="\n";} + $o++; + } + $MAIN.="\n"; } -$MAIN.="\n"; + $MAIN.="\n"; -$MAIN.="Show hourly results
Show disposition statuses
DOWNLOAD | MODIFY | REPORTS\n"; +$MAIN.="Show hourly results
Show disposition statuses
Ignore after-hours calls
DOWNLOAD | MODIFY | REPORTS\n"; $MAIN.=""; $MAIN.="
\n\n";
 
@@ -454,13 +491,17 @@ else
 
 	$MAIN.="Inbound Daily Report                      $NOW_TIME\n";
 	$MAIN.="Selected in-group: $group - $group_name\n";
-	if ($shift) {$MAIN.="Selected shift: $shift\n";}
-	$MAIN.="Time range $DURATIONday days: $query_date_BEGIN to $query_date_END for $shift shift\n\n";
+	if ($shift && $IDR_calltime_available) {$MAIN.="Selected shift: $shift\n";}
+	$MAIN.="Time range $DURATIONday days: $query_date_BEGIN to $query_date_END";
+	if ($shift && $IDR_calltime_available) {$MAIN.="for $shift shift";}
+	$MAIN.="\n\n";
 	#echo "Time range day sec: $SQsec - $EQsec   Day range in epoch: $SQepoch - $EQepoch   Start: $SQepochDAY\n";
 	$CSV_text.="\"Inbound Daily Report\",\"$NOW_TIME\"\n";
 	$CSV_text.="Selected in-group: $group - $group_name\n";
-	if ($shift) {$CSV_text.="Selected shift: $shift\n";}
-	$CSV_text.="\"Time range $DURATIONday days:\",\"$query_date_BEGIN to $query_date_END for $shift shift\"\n\n";
+	if ($shift && $IDR_calltime_available) {$CSV_text.="Selected shift: $shift\n";}
+	$CSV_text.="\"Time range $DURATIONday days:\",\"$query_date_BEGIN to $query_date_END\"";
+	if ($shift && $IDR_calltime_available) {$CSV_text.="for $shift shift";}
+	$CSV_text.="\n\n";
 
 	if ($show_disposition_statuses) {
 		$dispo_stmt="select distinct status from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and  campaign_id='" . mysql_real_escape_string($group) . "' $big_shift_time_SQL_clause order by status;";
@@ -490,7 +531,7 @@ else
 	$d=0; $q=0; $hr=0; $shift_hrs=0;
 	while ($d < $DURATIONday)
 		{
-		$dSQepoch = ($SQepoch + ($d * 86400) + ($hr * 3600) );
+		$dSQepoch = ($SQepoch + ($d * 86400) + ($hr * 3600));
 		
 		if ($shift && $shift!="ALL" && $RECALC==1) 
 			{
@@ -514,7 +555,7 @@ else
 			}
 			else
 			{
-			$dEQepoch = ($SQepochDAY + ($EQsec + ($d * 86400) + ($hr * 3600) ) );
+			$dEQepoch = ($SQepochDAY + ($EQsec + ($d * 86400) + ($hr * 3600)) );
 			if ($EQsec < $SQsec)
 				{
 				$dEQepoch = ($dEQepoch + 86400);
@@ -525,7 +566,6 @@ else
 		$daySTART[$q] = date("Y-m-d H:i:s", $dSQepoch);
 		$dayEND[$q] = date("Y-m-d H:i:s", $dEQepoch);
 
-	#  || $time_END<=date("H:i:s", $dEQepoch)
 		if ($hr>=($hpd-1) || !$hourly_breakdown) 
 			{
 			$d++;
@@ -806,10 +846,13 @@ else
 
 	for ($s=0; $sCarrier Log Report\n";
 		echo "
  • Hangup Cause Report\n"; echo "
  • Bulk Phone Insert Page\n"; + echo "
  • Callbacks Transferral Page\n"; echo "
  • Send a Call With Custom CID Page\n"; echo "
  • Speech Voice Lab Page\n"; echo "
  • Webphone Only Page\n"; diff --git a/www/vicidial/callbacks_bulk_change.php b/www/vicidial/callbacks_bulk_change.php new file mode 100644 index 00000000..67f056a0 --- /dev/null +++ b/www/vicidial/callbacks_bulk_change.php @@ -0,0 +1,285 @@ + LICENSE: AGPLv2 +# +# CHANGES +# 120819-0119 - First build +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["old_user"])) {$old_user=$_GET["old_user"];} + elseif (isset($_POST["old_user"])) {$old_user=$_POST["old_user"];} +if (isset($_GET["new_user"])) {$new_user=$_GET["new_user"];} + elseif (isset($_POST["new_user"])) {$new_user=$_POST["new_user"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["confirm_transfer"])) {$confirm_transfer=$_GET["confirm_transfer"];} + elseif (isset($_POST["confirm_transfer"])) {$confirm_transfer=$_POST["confirm_transfer"];} +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"];} + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,webroot_writable,outbound_autodial_active FROM system_settings;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysql_num_rows($rslt); +$i=0; +while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $webroot_writable = $row[1]; + $SSoutbound_autodial_active = $row[2]; + $i++; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$StarTtimE = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$ip = getenv("REMOTE_ADDR"); + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7 and view_reports='1';"; +if ($non_latin > 0) { $rslt=mysql_query("SET NAMES 'UTF8'");} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + +if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } +else + { + if($auth>0) + { + $stmt="SELECT full_name,change_agent_campaign,modify_timeclock_log,user_group,user_level from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname = $row[0]; + $change_agent_campaign = $row[1]; + $modify_timeclock_log = $row[2]; + $LOGuser_group = $row[3]; + $user_level=$row[4]; + if ($user_level==9) + { + $ul_clause="where user_level<=9"; + } else { + $ul_clause="where user_level<$user_level"; + } + if ($webroot_writable > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|XXXX|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($webroot_writable > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|XXXX|$ip|$browser|\n"); + fclose($fp); + } + exit; + } + } + +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; +if ($DB) {$HTML_text.="|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; + +$LOGadmin_viewable_groupsSQL=''; +$whereLOGadmin_viewable_groupsSQL=''; +if ( (!eregi("--ALL--",$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')"; + } + +$stmt="SELECT user_group,group_name from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group desc;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] = $row[0]; + $group_names[$i] = $row[1]; + $i++; + } + +if ($SUBMIT && $old_user && $new_user && $confirm_transfer) { + $upd_stmt="update vicidial_callbacks set user='$new_user' where recipient='USERONLY' and status!='INACTIVE' and user='$old_user' $LOGadmin_viewable_groupsSQL"; + $upd_rslt=mysql_query($upd_stmt, $link); + if ($DB) {echo "$upd_stmt\n";} +} +?> + + + +ADMINISTRATION: USERONLY Callbacks Transfer +<?php + +##### BEGIN Set variables to make header show properly ##### +$ADD = '311111'; +$hh = 'usergroups'; +$LOGast_admin_access = '1'; +$ADMIN = 'admin.php'; +$page_width='770'; +$section_width='750'; +$header_font_size='3'; +$subheader_font_size='2'; +$subcamp_font_size='2'; +$header_selected_bold='<b>'; +$header_nonselected_bold=''; +$usergroups_color = '#FFFF99'; +$usergroups_font = 'BLACK'; +$usergroups_color = '#E6E6E6'; +$subcamp_color = '#C6C6C6'; +##### END Set variables to make header show properly ##### + +require("admin_header.php"); + +?> + +<CENTER> +<TABLE WIDTH=620 BGCOLOR=#D9E6FE cellpadding=2 cellspacing=0><TR BGCOLOR=#015B91><TD ALIGN=LEFT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B>   USERONLY Callback Transfer</TD><TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B>   </TD></TR> + + + + +<?php + +echo "<TR BGCOLOR=\"#F0F5FE\"><TD ALIGN=center COLSPAN=2><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=3><B>   \n"; + +### callbacks change form +echo "<form action=$PHP_SELF method=POST>\n"; +echo "<input type=hidden name=DB value=\"$DB\">\n"; +if ($SUBMIT && $old_user && $new_user && !$confirm_transfer) + { + $stmt="select count(*) as ct from vicidial_callbacks where recipient='USERONLY' and status!='INACTIVE' and user='$old_user' $LOGadmin_viewable_groupsSQL"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_array($rslt); + $callback_ct=$row["ct"]; + + $user_stmt="select full_name from vicidial_users $ul_clause and user='$old_user' $LOGadmin_viewable_groupsSQL"; + $user_rslt=mysql_query($user_stmt, $link); + $user_row=mysql_fetch_array($user_rslt); + $old_user_name=$user_row["full_name"]; + + $user_stmt="select full_name from vicidial_users $ul_clause and user='$new_user' $LOGadmin_viewable_groupsSQL "; + $user_rslt=mysql_query($user_stmt, $link); + $user_row=mysql_fetch_array($user_rslt); + $new_user_name=$user_row["full_name"]; + + echo "<input type=hidden name=old_user value=\"$old_user\">\n"; + echo "<input type=hidden name=new_user value=\"$new_user\">\n"; + echo "You are about to transfer $callback_ct callbacks<BR>\n"; + echo "from user $old_user - $old_user_name<BR>\n"; + echo "to user $new_user - $new_user_name<BR><BR><BR>\n"; + echo "<a href='$PHP_SELF?DB=$DB&old_user=$old_user&new_user=$new_user&confirm_transfer=1&SUBMIT=1'>CLICK TO CONFIRM</a><BR><BR>"; + echo "<a href='$PHP_SELF?DB=$DB'>CLICK TO CANCEL</a><BR><BR>"; + } +else + { + $stmt="select user, count(*) as ct from vicidial_callbacks where recipient='USERONLY' and status!='INACTIVE' $LOGadmin_viewable_groupsSQL group by user order by user"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + # <tr><td align='right'> + echo "Agents with callbacks:<BR><select name='old_user' size=5>\n"; + if (mysql_num_rows($rslt)>0) + { + while ($row=mysql_fetch_array($rslt)) + { + $user_stmt="select full_name from vicidial_users $ul_clause and user='$row[user]' $LOGadmin_viewable_groupsSQL"; + $user_rslt=mysql_query($user_stmt, $link); + if (mysql_num_rows($user_rslt)>0) + { + $user_row=mysql_fetch_array($user_rslt); + echo "\t<option value='$row[user]'>$row[user] - $user_row[full_name] - ($row[ct] callbacks)</option>\n"; + } + } + } + else + { + echo "\t<option value=''>**NO CALLBACKS**</option>\n"; + } + echo "</select>"; + echo "<BR/><BR/><input type='submit' name='SUBMIT' value=' TRANSFER TO '><BR/><BR/>"; + + $stmt="select user, full_name from vicidial_users $ul_clause $LOGadmin_viewable_groupsSQL order by user asc"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + echo "<select name='new_user' size=5>\n"; + while ($row=mysql_fetch_array($rslt)) + { + echo "\t<option value='$row[user]'>$row[user] - $row[full_name]</option>\n"; + } + echo "</select>\n"; + } +echo "</form>\n"; + +echo "\n<BR><BR><BR>"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $StarTtimE); + +echo "\n\n\n<br><br><br>\n\n"; + + +echo "<font size=0>\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds</font>"; + +echo "|$stage|$group|"; + +?> + + +</TD></TR><TABLE> +</body> +</html> + +<?php + +exit; + + +?>