From 94a2d35f746ba087b8742292ef523acbdb13ef3a Mon Sep 17 00:00:00 2001 From: mattf Date: Wed, 25 Jan 2012 17:38:50 +0000 Subject: [PATCH] Added System max Stats report and permissions for both max stats reports git-svn-id: svn://192.168.202.10@1778 3d104415-ff17-0410-8863-d5cf3c621b8a --- www/vicidial/admin.php | 159 ++++++++++++++++++++++++++----------- www/vicidial/functions.php | 16 +++- 2 files changed, 128 insertions(+), 47 deletions(-) diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index c2283e57..0112b8f9 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -105,9 +105,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, Campaign Status List Report, Export Calls Report, Export Leads Report , Agent Time Detail, Agent Status Detail, Agent Performance Detail, Team Performance Detail, Single Agent Daily , 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'; +$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, Campaign Status List Report, Export Calls Report, Export Leads Report , Agent Time Detail, Agent Status Detail, Agent Performance Detail, Team Performance Detail, Single Agent Daily , 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'; -$UGreports = 'ALL REPORTS, 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, Campaign Status List Report, Export Calls Report , Export Leads Report , Agent Time Detail, Agent Status Detail, Agent Performance Detail, Team Performance Detail, Single Agent Daily , 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'; +$UGreports = 'ALL REPORTS, 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, Campaign Status List Report, Export Calls Report , Export Leads Report , Agent Time Detail, Agent Status Detail, Agent Performance Detail, Team Performance Detail, Single Agent Daily , 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'; $Vtables = 'NONE,log_noanswer,did_agent_log,contact_information'; @@ -3025,12 +3025,13 @@ else # 120102-2125 - Added Dialer Inventory Report # 120104-2024 - Changed copyright dates, other small fixes # 120118-2113 - Fixed bugs in phone alias and conf template updates +# 120125-1234 - Added Maximum System Stats report and permissions for it and Max Stats Detail report # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time -$admin_version = '2.4-355a'; -$build = '120118-2113'; +$admin_version = '2.4-356a'; +$build = '120125-1234'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -3646,6 +3647,7 @@ if ($ADD==999996) {$hh='reports'; echo "INITIAL INSTALL WELCOME";} if ($ADD==999995) {$hh='reports'; echo "COPYRIGHT TRADEMARK LICENSE";} if ($ADD==999994) {$hh='reports'; echo "ADMIN UTILITIES";} if ($ADD==999993) {$hh='reports'; echo "SUMMARY STATS";} +if ($ADD==999992) {$hh='reports'; echo "SYSTEM SUMMARY STATS";} if ( ($ADD>9) and ($ADD < 99998) ) @@ -32262,6 +32264,9 @@ if ($ADD==999999) if ( (preg_match("/Server Performance Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) {echo "
  • Server Performance Report\n";} + if ( (preg_match("/Maximum System Stats/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) + {echo "
  • Maximum System Stats\n";} + if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) ) { echo "
  • Administration Change Log\n"; @@ -32699,59 +32704,123 @@ if ($ADD==999993) echo "
    \n"; echo ""; - if ($stage == 'in-group') + if ( (preg_match("/Maximum Stats Detail/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) { - $in_out = 'in-group'; - $max_type = 'max_inbound'; - $modify_link = ""; - $stmt="SELECT group_name from vicidial_inbound_groups where group_id='$campaign_id' $LOGadmin_viewable_groupsSQL;"; - $rslt=mysql_query($stmt, $link); - $rows_to_print = mysql_num_rows($rslt); - if ($rows_to_print > 0) + if ($stage == 'in-group') { - $rowx=mysql_fetch_row($rslt); - $campaign_name = $rowx[0]; + $in_out = 'in-group'; + $max_type = 'max_inbound'; + $modify_link = ""; + $stmt="SELECT group_name from vicidial_inbound_groups where group_id='$campaign_id' $LOGadmin_viewable_groupsSQL;"; + $rslt=mysql_query($stmt, $link); + $rows_to_print = mysql_num_rows($rslt); + if ($rows_to_print > 0) + { + $rowx=mysql_fetch_row($rslt); + $campaign_name = $rowx[0]; + } + else + {echo "Not found"; exit;} } else - {echo "Not found"; exit;} + { + $in_out = 'campaign'; + $max_type = 'max_outbound'; + $modify_link = ""; + $stmt="SELECT campaign_name from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; + $rslt=mysql_query($stmt, $link); + $rows_to_print = mysql_num_rows($rslt); + if ($rows_to_print > 0) + { + $rowx=mysql_fetch_row($rslt); + $campaign_name = $rowx[0]; + } + else + {echo "Not found"; exit;} + } + + echo "
    Administration: Maximum Stats Detail for $stage $modify_link$campaign_id
    - $campaign_name

    \n"; + echo "
    \n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; } else - { - $in_out = 'campaign'; - $max_type = 'max_outbound'; - $modify_link = ""; - $stmt="SELECT campaign_name from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; - $rslt=mysql_query($stmt, $link); - $rows_to_print = mysql_num_rows($rslt); - if ($rows_to_print > 0) - { - $rowx=mysql_fetch_row($rslt); - $campaign_name = $rowx[0]; - } - else - {echo "Not found"; exit;} - } - - echo "
    Administration: Max Stats Detail for $stage $modify_link$campaign_id
    - $campaign_name

    \n"; - echo "
    \n"; + horizontal_bar_chart($campaign_id,'30',$in_out,$link,'total_calls','call count',0); + echo "
    \n"; + horizontal_bar_chart($campaign_id,'30',$in_out,$link,$max_type,'most concurrent calls',0); + echo "
    \n"; + horizontal_bar_chart($campaign_id,'30',$in_out,$link,'max_agents','most concurrent agents',0); + echo "
    \n"; - - echo "\n"; - - echo "\n"; - - echo "\n"; + {echo "You do not have permission to view this page";} echo "
    \n"; - horizontal_bar_chart($campaign_id,'30',$in_out,$link,'total_calls','call count',0); - echo "
    \n"; - horizontal_bar_chart($campaign_id,'30',$in_out,$link,$max_type,'most concurrent calls',0); - echo "
    \n"; - horizontal_bar_chart($campaign_id,'30',$in_out,$link,'max_agents','most concurrent agents',0); - echo "
    \n"; } ##### END max stats detail report ##### +###################### +# ADD=999992 - max system stats report +###################### +if ($ADD==999992) + { + echo "
    \n"; + echo ""; + + echo "
    Administration: Maximum System Stats

    \n"; + echo "
    \n"; + + if ( (preg_match("/Maximum System Stats/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) + { + $stmt="SELECT sum(total_calls) from vicidial_daily_max_stats where campaign_id!='' and stats_flag='OPEN';"; + $rslt=mysql_query($stmt, $link); + $rows_to_print = mysql_num_rows($rslt); + if ($rows_to_print > 0) + { + $rowx=mysql_fetch_row($rslt); + $ALLtotal_calls = $rowx[0]; + + $stmt="UPDATE vicidial_daily_max_stats SET total_calls='$ALLtotal_calls' where campaign_id='' and stats_flag='OPEN' and stats_type='TOTAL';"; + $rslt=mysql_query($stmt, $link); + } + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + } + else + {echo "You do not have permission to view this page";} + echo "
    \n"; + horizontal_bar_chart($campaign_id,'30','system',$link,'total_calls','total call count in and out',0); + echo "
    \n"; + horizontal_bar_chart($campaign_id,'30','system',$link,'total_calls_inbound_all','total inbound call count',0); + echo "
    \n"; + horizontal_bar_chart($campaign_id,'30','system',$link,'total_calls_outbound_all','total outbound call count',0); + echo "
    \n"; + horizontal_bar_chart($campaign_id,'30','system',$link,'(max_inbound + max_outbound)','most concurrent calls in and out',0); + echo "
    \n"; + horizontal_bar_chart($campaign_id,'30','system',$link,'max_inbound','most concurrent calls inbound total',0); + echo "
    \n"; + horizontal_bar_chart($campaign_id,'30','system',$link,'max_outbound','most concurrent calls outbound total',0); + echo "
    \n"; + horizontal_bar_chart($campaign_id,'30','system',$link,'max_agents','most concurrent agents',0); + echo "
    \n"; + } +##### END max system stats report ##### + diff --git a/www/vicidial/functions.php b/www/vicidial/functions.php index 7cf9e509..25c8af0b 100644 --- a/www/vicidial/functions.php +++ b/www/vicidial/functions.php @@ -4,13 +4,14 @@ # # functions for administrative scripts and reports # -# Copyright (C) 2011 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2012 Matt Florell LICENSE: AGPLv2 # # # CHANGES: # 90524-1503 - First Build # 110708-1723 - Added HF precision option # 111222-2124 - Added max stats bar chart function +# 120125-1235 - Small changes to max stats function to allow for total system stats # ##### reformat seconds into HH:MM:SS or MM:SS ##### @@ -111,8 +112,13 @@ function horizontal_bar_chart($campaign_id,$days_graph,$title,$link,$metric,$met $NWB = "   \"HELP\""; + ### get stats for last X days $stmt="SELECT stats_date,$metric from vicidial_daily_max_stats where campaign_id='$campaign_id' and stats_flag='OPEN';"; + if ($metric=='total_calls_inbound_all') + {$stmt="SELECT stats_date,sum(total_calls) from vicidial_daily_max_stats where stats_type='INGROUP' and stats_flag='OPEN' group by stats_date;";} + if ($metric=='total_calls_outbound_all') + {$stmt="SELECT stats_date,sum(total_calls) from vicidial_daily_max_stats where stats_type='CAMPAIGN' and stats_flag='OPEN' group by stats_date;";} $rslt=mysql_query($stmt, $link); $Xstats_to_print = mysql_num_rows($rslt); if ($Xstats_to_print > 0) @@ -131,6 +137,10 @@ function horizontal_bar_chart($campaign_id,$days_graph,$title,$link,$metric,$met $Bstats_date[$i] = date("Y-m-d", $stats_start_time); $Btotal_calls[$i]=0; $stmt="SELECT stats_date,$metric from vicidial_daily_max_stats where campaign_id='$campaign_id' and stats_date='$Bstats_date[$i]';"; + if ($metric=='total_calls_inbound_all') + {$stmt="SELECT stats_date,sum(total_calls) from vicidial_daily_max_stats where stats_date='$Bstats_date[$i]' and stats_type='INGROUP' group by stats_date;";} + if ($metric=='total_calls_outbound_all') + {$stmt="SELECT stats_date,sum(total_calls) from vicidial_daily_max_stats where stats_date='$Bstats_date[$i]' and stats_type='CAMPAIGN' group by stats_date;";} $rslt=mysql_query($stmt, $link); $Ystats_to_print = mysql_num_rows($rslt); if ($Ystats_to_print > 0) @@ -144,9 +154,11 @@ function horizontal_bar_chart($campaign_id,$days_graph,$title,$link,$metric,$met {echo "";} else { + if ($title=='campaign') {$out_in_type=' outbound';} + if ($title=='in-group') {$out_in_type=' inbound';} if ($more_link > 0) {$link_text = "more summary stats...";} echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; echo "\n"; echo "\n";
    $days_graph Day $metric_name for this $title   $link_text   $NWB#vicidial_campaigns-max_stats$NWE
    $days_graph Day $out_in_type $metric_name for this $title   $link_text   $NWB#vicidial_campaigns-max_stats$NWE
    date $metric_name