From d9e139ae8d5f17052ef67f989b595412386e32bb Mon Sep 17 00:00:00 2001 From: mattf Date: Thu, 18 Apr 2024 23:12:31 +0000 Subject: [PATCH] Added Agent Time-Off Interface admin utility page git-svn-id: svn://192.168.202.10@3823 3d104415-ff17-0410-8863-d5cf3c621b8a --- extras/MySQL_AST_CREATE_tables.sql | 18 +- extras/upgrade_2.14.sql | 19 + www/vicidial/admin.php | 6 +- www/vicidial/agent_timeoff_interface.php | 1113 ++++++++++++++++++++++ 4 files changed, 1153 insertions(+), 3 deletions(-) create mode 100644 www/vicidial/agent_timeoff_interface.php diff --git a/extras/MySQL_AST_CREATE_tables.sql b/extras/MySQL_AST_CREATE_tables.sql index baa07a79..e5a0bfe6 100644 --- a/extras/MySQL_AST_CREATE_tables.sql +++ b/extras/MySQL_AST_CREATE_tables.sql @@ -5260,6 +5260,21 @@ notes TEXT, KEY pending_ar_key (user,start_datetime) ) ENGINE=MyISAM; +CREATE TABLE vicidial_timeoff_log ( +vtl_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +user VARCHAR(20) DEFAULT NULL, +full_name VARCHAR(100) DEFAULT NULL, +timeoff_month CHAR(7) DEFAULT NULL, +timeoff_type VARCHAR(10) DEFAULT NULL, +hours DECIMAL(5,2) unsigned DEFAULT NULL, +entry_date DATETIME DEFAULT NULL, +modify_date TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), +entered_by VARCHAR(20) DEFAULT NULL, +last_modified_by VARCHAR(20) DEFAULT NULL, +PRIMARY KEY (vtl_id), +UNIQUE KEY vicidial_timeoff_log_agent_month_key (user,timeoff_month,timeoff_type) +); + ALTER TABLE vicidial_email_list MODIFY message text character set utf8; @@ -5652,6 +5667,7 @@ INSERT INTO vicidial_settings_containers(container_id,container_notes,container_ INSERT INTO vicidial_settings_containers(container_id,container_notes,container_type,user_group,container_entry) VALUES ('EXAMPLE_LIST_WEEKDAY_RESETS','Example Weekday List Resets Container settings','LIST_WEEKDAY_RESETS','---ALL---','; weekday => reset-times in 24-hour time separated by dashes\r\nmonday => 0830-1230-1800\r\ntuesday => 0900-1400-1830\r\nwednesday => 0930-1200-1730-1900\r\nthursday => 1030-1330-1900\r\nfriday => 0800-1300-1530\r\nsaturday => 0930-1100\r\nsunday => 1000'); INSERT INTO vicidial_settings_containers(container_id,container_notes,container_type,user_group,container_entry) VALUES ('EXAMPLE_VID_PROMPT_SPECIAL','Example Call Menu VID Special Container settings','CM_VIDPROMPT_SPECIAL','---ALL---','list_ingroup => 102,TEST_IN2\r\nlist_ingroup => 103,TEST_IN3\r\nlist_ingroup => 104,TEST_IN4\r\ndefault_ingroup => TEST_IN5\r\nnot_found_action => new_lead\r\nnew_lead_ingroup => TEST_IN'); INSERT INTO `vicidial_settings_containers` VALUES ('VERM_STATUS_NAMES_OVERRIDE','Override dialer status names in enhanced reporting','OTHER','---ALL---','; For each status name you want overridden, type the status followed by\r\n; a pipe, then the new status name\r\n; Ex:\r\n; NZ|Taumatawhakatangihangakoauauotamateaturipukakapikimaungahoronukupoka\r\n201214|Request To Cancel\r\n210200|No Answer-Incomplete Call\r\n210201|Contact Established\r\n210202|Provider Review - HB\r\n210203|Promise to Pay\r\n210204|Setup Payment Plan\r\n210205|Research-Inquiry\r\n210206|Voice Mail Left - HB\r\n210207|Do Not Call\r\n210208|Appeal Verification\r\n210209|Bad Phone\r\n210210|Bad Address\r\n210211|Direct Pay Verification\r\n210213|Provider Approved\r\n210215|Update Notes Only\r\n210216|Voicemail-No Status Change\r\n210217|Sent Letter Request - HB\r\n210218|Auto VoiceMail Left - HB\r\n210219|Auto VoiceMail-No Status Change\r\n210302|Provider Review - LB\r\n210306|Voice Mail Left - LB\r\n210317|Sent Letter Request - LB\r\n210318|Auto VoiceMail Left - LB\r\n211503|Provider - COVID-19\r\n211603|Transferred Call to MLA\r\n'), ('VERM_REPORT_OPTIONS','Container for customizing VERM report output','OTHER','---ALL---','; This is the report queue used if none is chosen by the user\r\n; It\'s preloaded in some forms as well\r\nVERM_default_report_queue => ALL\r\n\r\n; If there are statuses to exclude from reports, list them here\r\n; Separate with commas. Default is AFTHRS\r\nexc_addtl_statuses => AFTHRS\r\n\r\n; Set the below value to 1 (or anything non-blank/non-zero) in order to \r\n; show the agents ID in addition to their full name in the report results\r\nshow_full_agent_info => 1\r\n\r\n; Some reports count \"lost\" calls - which are defined by the below variable\r\n; listing what you define as \"lost\" dispos. Separate with commas.\r\nlost_statuses => LOST,210208,DISPO\r\n\r\n; You can create a detailed IVR survey report for ingroups by defining\r\n; \"ivr_survey_ingroups_detail\" and \"ivr_survey_ingroups_voicemails.\"\r\n; For \"details\", supply an ingroup used as a tracking group on call menus.\r\n; Then, add a pipe and after that list all call menus that use the ingroup\r\n; as the tracking group, separating each with a comma\r\n; To track whether the calls went to voicemail, list every call menu/option\r\n; combination that goes to voicemail, separating the call menu from the \r\n; option with a pipe. One callmenu/option combo per line.\r\nivr_survey_ingroups_detail => 521205|561401,561402,561403,561404,561505\r\nivr_survey_ingroups_voicemails => 561505|t\r\n\r\n; #####################################################\r\n; # ALL of the below are used in the wallboard report #\r\n; #####################################################\r\nVERM_default_outb_widget_queue => ALL_OUT\r\nVERM_default_inb_widget_queue1 => 514915v_USA_Shared\r\nVERM_default_inb_widget_queue2 => 515915v_MLA_Shared\r\n\r\n; Used specifically for the SLA widget\r\n; Uses ingroups - separate multiple ingroups by commas\r\n; Comment out or leave blank to count all ingroups\r\nSLA_LEVEL_PCT_ingroups => 514915v,515915v\r\n\r\n; This removes remote agents from the wallboard reports\r\n; Comment out to include remote agents (or set to zero)\r\nomit_remote_agents => 1\r\n\r\n\r\n; #### AUTO DOWNLOAD ####\r\n; If the "total calls" value on any report requested exceeds the below \r\n; limit, automatically download the three "DETAILS" reports instead\r\n; of attempting to display that many records on-screen\r\nauto_download_limit => 50000\r\n\r\n; #### OUTCOMES report overrides ####\r\n; Use "outcome_lagged_status_overrides" for conditions where the call \r\n; record in the vicidial_log or vicidial_closer_log table has no uniqueid\r\n; value despite having a status/outcome, which can indicate a call \r\n; affected by network lag for certain statuses. This will change the call \r\n; status to "LAGGED". Separate statuses with commas. Default is the \r\n; automatic "PU" status.\r\noutcome_lagged_status_overrides => PU\r\n\r\n; Use "unknown_network_statuses" to change call statuses to read "Network/\r\n; LAGGED" on the OUTCOMES report. Separate statuses with commas.\r\n; IMPORTANT: if you are using the outcome_lagged_status_overrides option \r\n; above, make sure "LAGGED" is one of the unknown_network_statuses here\r\n; unknown_network_statuses => LAGGED\r\n\r\n; Use "outcome_status_overrides" to change one status to another on the \r\n; OUTCOMES report. Overrides are comma-separated pairs of dispositions \r\n; where the first disposition is the disposition to change, and the second\r\n; is the disposition to change to. Separate pairs with a pipe character as\r\n; in the below example. Off by default.\r\n; outcome_status_overrides => CBHOLD,DISPO|XFER,AL'); +INSERT INTO vicidial_settings_containers VALUES ('VICIDIAL_TIMEOFF_SETTINGS','Settings for time-off admin utility','OTHER','---ALL---','; Comma-delimited time-off codes - MANDATORY, must have at least one defined. \r\n; Default is \'VAC\' for vacation\r\ntimeoff_types => VAC\r\n\r\n; optional, if set to \'1\' will show all viewable agents, even ones with no \r\n; time off for month. Default is 0\r\ndisplay_all_agents => 0\r\n\r\n; optional, used to filter users displayed, in addition to user_group \r\n; permissions\r\nuser_filter_SQL => \r\n\r\n; optional, uses columns from vicidial_users table. Defaults to \r\n; full_name asc, user asc if commented out or non-existent\r\n; sort_SQL => full_name asc, user asc\r\n\r\n; include custom coding for misc download coding where \"custom_download\" \r\n; marked in agent_timeoff_script.php - DO NOT USE WITHOUT CODING KNOWLEDGE\r\n; set to \'1\' to activate\r\ncustom_download => 0'); INSERT INTO `wallboard_widgets` VALUES ('queues_widget_1','AGENTS_AND_QUEUES','queues','','TEXT',5,'N',1,'Queue Information','','',NULL,'','',NULL,2),('queues_widget_0','AGENTS_AND_QUEUES','queues','','LOGO',2,'N',1,NULL,'','',NULL,'','',NULL,1),('queues_widget_2','AGENTS_AND_QUEUES','queues','SLA Level %','SLA_LEVEL_PCT',1,'N',1,NULL,'','>60',NULL,'','',NULL,3),('queues_widget_3','AGENTS_AND_QUEUES','queues','Outbound calls','LIVE_QUEUE_INFO',1,'N',1,'','201201','','','','','yellow_alarm,|red_alarm,',4),('queues_widget_4','AGENTS_AND_QUEUES','queues','USA Ded Inbound','LIVE_QUEUE_INFO',1,'N',1,'','ALL_IN','','','','','yellow_alarm,|red_alarm,',5),('queues_widget_5','AGENTS_AND_QUEUES','queues','MLA Ded Inbound','LIVE_QUEUE_INFO',1,'N',1,'','514911','','','','','yellow_alarm,|red_alarm,',6),('queues_widget_6','AGENTS_AND_QUEUES','queues','N Waiting Calls','N_WAITING_CALLS',1,'N',1,NULL,'','',NULL,'','',NULL,7),('queues_widget_7','AGENTS_AND_QUEUES','queues','Offered Calls','OFFERED_CALLS',1,'N',1,NULL,'','',NULL,'','',NULL,8),('queues_widget_8','AGENTS_AND_QUEUES','queues','Answered Calls','ANSWERED_CALLS',1,'N',1,NULL,'','',NULL,'','',NULL,9),('queues_widget_9','AGENTS_AND_QUEUES','queues','Lost Calls','LOST_CALLS',1,'N',1,NULL,'','',NULL,'','',NULL,10),('queues_widget_10','AGENTS_AND_QUEUES','queues','Longest Wait','LONGEST_WAIT',1,'N',1,NULL,'','',NULL,'','',NULL,11),('queues_widget_11','AGENTS_AND_QUEUES','queues','Live Queues','LIVE_QUEUES',1,'Y',1,NULL,'','',NULL,'','',NULL,12),('queues_widget_12','AGENTS_AND_QUEUES','queues','Live Calls','LIVE_CALLS',1,'Y',2,NULL,'','',NULL,'','',NULL,13),('agent_widget_0','AGENTS_AND_QUEUES','agents','','LOGO',2,'N',1,NULL,'','',NULL,'','',NULL,1),('agent_widget_1','AGENTS_AND_QUEUES','agents','N Waiting Calls','N_WAITING_CALLS',1,'N',1,NULL,'','',NULL,'','',NULL,2),('agent_widget_2','AGENTS_AND_QUEUES','agents','Agents Ready','AGENTS_READY',1,'N',1,NULL,'','',NULL,'','',NULL,3),('agent_widget_3','AGENTS_AND_QUEUES','agents','Agents On Call','N_AGENTS_ON_CALL',1,'N',1,NULL,'','',NULL,'','',NULL,4),('agent_widget_4','AGENTS_AND_QUEUES','agents','N Answered Calls','N_ANSWERED_CALLS',1,'N',1,NULL,'','',NULL,'','',NULL,5),('agent_widget_5','AGENTS_AND_QUEUES','agents','Clock','CLOCK',1,'N',1,NULL,'','',NULL,'','',NULL,6),('agent_widget_6','AGENTS_AND_QUEUES','agents','Live Agents','LIVE_AGENTS',1,'Y',3,NULL,'','',NULL,'','',NULL,7); @@ -5659,4 +5675,4 @@ INSERT INTO `wallboard_reports` VALUES ('AGENTS_AND_QUEUES','Agents and Queues', UPDATE system_settings set vdc_agent_api_active='1'; -UPDATE system_settings SET db_schema_version='1712',db_schema_update_date=NOW(),reload_timestamp=NOW(); +UPDATE system_settings SET db_schema_version='1713',db_schema_update_date=NOW(),reload_timestamp=NOW(); diff --git a/extras/upgrade_2.14.sql b/extras/upgrade_2.14.sql index 5ecbff79..59bf76c9 100644 --- a/extras/upgrade_2.14.sql +++ b/extras/upgrade_2.14.sql @@ -2701,3 +2701,22 @@ UPDATE system_settings SET db_schema_version='1711',db_schema_update_date=NOW() ALTER TABLE vicidial_campaigns ADD script_tab_height SMALLINT(5) default '0'; UPDATE system_settings SET db_schema_version='1712',db_schema_update_date=NOW() where db_schema_version < 1712; + +CREATE TABLE vicidial_timeoff_log ( +vtl_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +user VARCHAR(20) DEFAULT NULL, +full_name VARCHAR(100) DEFAULT NULL, +timeoff_month CHAR(7) DEFAULT NULL, +timeoff_type VARCHAR(10) DEFAULT NULL, +hours DECIMAL(5,2) unsigned DEFAULT NULL, +entry_date DATETIME DEFAULT NULL, +modify_date TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), +entered_by VARCHAR(20) DEFAULT NULL, +last_modified_by VARCHAR(20) DEFAULT NULL, +PRIMARY KEY (vtl_id), +UNIQUE KEY vicidial_timeoff_log_agent_month_key (user,timeoff_month,timeoff_type) +); + +INSERT INTO vicidial_settings_containers VALUES ('VICIDIAL_TIMEOFF_SETTINGS','Settings for time-off admin utility','OTHER','---ALL---','; Comma-delimited time-off codes - MANDATORY, must have at least one defined. \r\n; Default is \'VAC\' for vacation\r\ntimeoff_types => VAC\r\n\r\n; optional, if set to \'1\' will show all viewable agents, even ones with no \r\n; time off for month. Default is 0\r\ndisplay_all_agents => 0\r\n\r\n; optional, used to filter users displayed, in addition to user_group \r\n; permissions\r\nuser_filter_SQL => \r\n\r\n; optional, uses columns from vicidial_users table. Defaults to \r\n; full_name asc, user asc if commented out or non-existent\r\n; sort_SQL => full_name asc, user asc\r\n\r\n; include custom coding for misc download coding where \"custom_download\" \r\n; marked in agent_timeoff_script.php - DO NOT USE WITHOUT CODING KNOWLEDGE\r\n; set to \'1\' to activate\r\ncustom_download => 0'); + +UPDATE system_settings SET db_schema_version='1713',db_schema_update_date=NOW() where db_schema_version < 1713; diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index 013ad806..f4b98bf9 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -6143,12 +6143,13 @@ if ($SSscript_remove_js > 0) # 240322-0942 - Added input filtering # 240325-2313 - Fix for new user daily limits # 240415-1858 - Added script_tab_height campaign option +# 240418-0836 - Added link to Agent Time-Off Interface in Admin Utilities page # # 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-914a'; -$build = '240415-1858'; +$admin_version = '2.14-915a'; +$build = '240418-0836'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -50747,6 +50748,7 @@ if ($ADD==999994) echo "
  • "._QXZ("Real-Time Monitoring Log Report")."\n"; echo "
  • "._QXZ("Agent Parked Call Report")."\n"; echo "
  • "._QXZ("Agent-Manager Chat Log")."\n"; + echo "
  • "._QXZ("Agent Time-Off Interface")."\n"; echo "
  • "._QXZ("API Log Report")."\n"; echo "
  • "._QXZ("Recording Access Log")."\n"; echo "
  • "._QXZ("Admin Report Log Viewer")."\n"; diff --git a/www/vicidial/agent_timeoff_interface.php b/www/vicidial/agent_timeoff_interface.php new file mode 100644 index 00000000..d4c3e475 --- /dev/null +++ b/www/vicidial/agent_timeoff_interface.php @@ -0,0 +1,1113 @@ +, Joe Johnson LICENSE: AGPLv2 +# +# Admin utility for applying hours off for agents, to be used in reports +# +# 240415-1730 - First build +# + +$startMS = microtime(); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + +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']; +$PHP_SELF = preg_replace('/\.php.*/i','.php',$PHP_SELF); +$QUERY_STRING = getenv("QUERY_STRING"); +$startMS = microtime(); + +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["action"])) {$action=$_GET["action"];} + elseif (isset($_POST["action"])) {$action=$_POST["action"];} +if (isset($_GET["add_user"])) {$add_user=$_GET["add_user"];} + elseif (isset($_POST["add_user"])) {$add_user=$_POST["add_user"];} +if (isset($_GET["submit_time_off"])) {$submit_time_off=$_GET["submit_time_off"];} + elseif (isset($_POST["submit_time_off"])) {$submit_time_off=$_POST["submit_time_off"];} +if (isset($_GET["month_to_display"])) {$month_to_display=$_GET["month_to_display"];} + elseif (isset($_POST["month_to_display"])) {$month_to_display=$_POST["month_to_display"];} +if (isset($_GET["rpt_month"])) {$rpt_month=$_GET["rpt_month"];} + elseif (isset($_POST["rpt_month"])) {$rpt_month=$_POST["rpt_month"];} +if (isset($_GET["update_month"])) {$update_month=$_GET["update_month"];} + elseif (isset($_POST["update_month"])) {$update_month=$_POST["update_month"];} +if (isset($_GET["new_agent"])) {$new_agent=$_GET["new_agent"];} + elseif (isset($_POST["new_agent"])) {$new_agent=$_POST["new_agent"];} +if (isset($_GET["new_timeoff_type"])) {$new_timeoff_type=$_GET["new_timeoff_type"];} + elseif (isset($_POST["new_timeoff_type"])) {$new_timeoff_type=$_POST["new_timeoff_type"];} +if (isset($_GET["new_hours"])) {$new_hours=$_GET["new_hours"];} + elseif (isset($_POST["new_hours"])) {$new_hours=$_POST["new_hours"];} +if (isset($_GET["new_month"])) {$new_month=$_GET["new_month"];} + elseif (isset($_POST["new_month"])) {$new_month=$_POST["new_month"];} +if (isset($_GET["to_types"])) {$to_types=$_GET["to_types"];} + elseif (isset($_POST["to_types"])) {$to_types=$_POST["to_types"];} +if (isset($_GET["update_user"])) {$update_user=$_GET["update_user"];} + elseif (isset($_POST["update_user"])) {$update_user=$_POST["update_user"];} +if (isset($_GET["download_month"])) {$download_month=$_GET["download_month"];} + elseif (isset($_POST["download_month"])) {$download_month=$_POST["download_month"];} + +if (file_exists('options.php')) + { + require('options.php'); + } + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,outbound_autodial_active,slave_db_server,reports_use_slave_db,user_territories_active,webroot_writable,allow_emails,level_8_disable_add,enable_languages,language_method,log_recording_access,admin_screen_colors,mute_recordings,sounds_web_server,sounds_web_directory,admin_web_directory,allow_web_debug 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]; + $SSoutbound_autodial_active = $row[1]; + $slave_db_server = $row[2]; + $reports_use_slave_db = $row[3]; + $user_territories_active = $row[4]; + $webroot_writable = $row[5]; + $allow_emails = $row[6]; + $SSlevel_8_disable_add = $row[7]; + $SSenable_languages = $row[8]; + $SSlanguage_method = $row[9]; + $log_recording_access = $row[10]; + $SSadmin_screen_colors = $row[11]; + $SSmute_recordings = $row[12]; + $sounds_web_server = $row[13]; + $sounds_web_directory = $row[14]; + $admin_web_dir = $row[15]; + $SSallow_web_debug = $row[16]; + } + +if (!preg_match('/^http/', $sounds_web_server)) {$http_prefix="http://";} else {$http_prefix="";} +if ($SSallow_web_debug < 1) {$DB=0;} +##### END SETTINGS LOOKUP ##### +########################################### + +$DB=preg_replace("/[^0-9a-zA-Z]/","",$DB); +if (preg_match('/^\-/', $new_hours)) {$hoff=-1;} else {$hoff=1;} +$new_hours = preg_replace('/[^0-9\.]/', '', $new_hours); +$month_to_display=preg_replace("/[^-0-9]/",'',$month_to_display); +$download_month=preg_replace("/[^-0-9]/",'',$download_month); +$update_month=preg_replace("/[^-0-9]/",'',$update_month); +$new_month=preg_replace("/[^-0-9]/",'',$new_month); +$rpt_month=preg_replace("/[^-0-9]/",'',$rpt_month); + +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); + $action = preg_replace('/[^-_0-9a-zA-Z]/', '', $action); + $add_user=preg_replace("/[^-_0-9a-zA-Z]/",'',$add_user); + $update_user=preg_replace("/[^-_0-9a-zA-Z]/",'',$update_user); + $user=preg_replace("/[^-_0-9a-zA-Z]/",'',$user); + $new_agent=preg_replace("/[^-_0-9a-zA-Z]/",'',$new_agent); + $submit_time_off=preg_replace("/[^-_0-9a-zA-Z]/",'',$submit_time_off); + $new_timeoff_type=preg_replace("/[^_0-9a-zA-Z]/",'',$new_timeoff_type); + $to_types=preg_replace("/[^_\,\.\-0-9a-zA-Z]/",'',$to_types); + } +else + { + $PHP_AUTH_USER = preg_replace('/[^\-_0-9\p{L}]/u', '', $PHP_AUTH_USER); + $PHP_AUTH_PW = preg_replace('/[^\-_0-9\p{L}]/u', '', $PHP_AUTH_PW); + $action = preg_replace('/[^\-_0-9\p{L}]/u', '', $action); + $add_user = preg_replace('/[^-_0-9\p{L}]/u','',$add_user); + $update_user = preg_replace('/[^-_0-9\p{L}]/u','',$update_user); + $user = preg_replace('/[^-_0-9\p{L}]/u','',$user); + $new_agent = preg_replace('/[^-_0-9\p{L}]/u','',$new_agent); + $submit_time_off = preg_replace('/[^-_0-9\p{L}]/u','',$submit_time_off); + $new_timeoff_type=preg_replace("/[^_0-9\p{L}]/u",'',$new_timeoff_type); + $to_types=preg_replace("/[^_\,\.\-0-9\p{L}]/u",'',$to_types); + } + +$user_auth=0; +$auth=0; +$reports_auth=0; +$qc_auth=0; +$auth_message = user_authorization($PHP_AUTH_USER,$PHP_AUTH_PW,'QC',1,0); +if ($auth_message == 'GOOD') + {$user_auth=1;} +if ($user_auth > 0) + { + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 7 and api_only_user != '1';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $auth=$row[0]; + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 6 and view_reports='1' and api_only_user != '1';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $reports_auth=$row[0]; + + $stmt="SELECT count(*) user_level,modify_users from vicidial_users where user='$PHP_AUTH_USER' and modify_users='1';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $users_auth=$row[0]; + + $stmt="select user_level, user_group from vicidial_users where user='$PHP_AUTH_USER'"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $user_level=$row[0]; + $user_group=$row[1]; + + $reports_only_user=0; + $qc_only_user=0; + if ( ($reports_auth > 0) and ($auth < 1) ) + { + $ADD=999999; + $reports_only_user=1; + } + if ( ($reports_auth < 1) and ($auth < 1) ) + { + if ( ($ADD != '881') and ($ADD != '100000000000000') ) + { + $ADD=100000000000000; + } + $qc_only_user=1; + } + if ( ($reports_auth < 1) and ($auth < 1) ) + { + $VDdisplayMESSAGE = _QXZ("You do not have permission to be here"); + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + if ($users_auth < 1) + { + $VDdisplayMESSAGE = _QXZ("You do not have permissions to modify users"); + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + if ( (strlen($VUuser_admin_redirect_url) > 5) and ($SSuser_admin_redirect > 0) ) + { + Header('Location: '.$VUuser_admin_redirect_url); + echo""._QXZ("Admin Redirect")."\n"; + echo"\n"; + echo"\n"; + echo"\n"; + echo"\n"; + echo""._QXZ("click here to continue").". . .\n"; + exit; + } + } +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; + } + if ($auth_message == 'IPBLOCK') + { + $VDdisplayMESSAGE = _QXZ("Your IP Address is not allowed") . ": $ip"; + 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; + } + +$container_stmt="select container_entry from vicidial_settings_containers where container_id='VICIDIAL_TIMEOFF_SETTINGS'"; +$container_rslt=mysql_to_mysqli($container_stmt, $link); +$timeoff_types=array(); +$time_column_SQL=""; +$user_filter_SQL=""; +if (mysqli_num_rows($container_rslt)==0) {echo "ERROR: no VICIDIAL_TIMEOFF_SETTINGS settings container defined"; exit;} +while ($container_row=mysqli_fetch_row($container_rslt)) + { + $to_settings=explode("\n", $container_row[0]); + for ($i=0; $i/', $to_settings[$i])) + { + $setting=explode("=>", $to_settings[$i]); + if (preg_match('/^display_all_agents/', $setting[0])) + { + $display_all_agents=$setting[1]; + } + if (preg_match('/^timeoff_types/', $setting[0])) + { + $setting[1]=preg_replace("/[^_0-9a-zA-Z,]/", "", $setting[1]); + $timeoff_types=explode(",", $setting[1]); + } + if (preg_match('/^user_filter_SQL/', $setting[0])) + { + $user_filter_SQL=preg_replace("/[^\s\'\(\)_0-9a-zA-Z,]/", "", $setting[1]); + } + if (preg_match('/^sort_SQL/', $setting[0])) + { + $sort_SQL=preg_replace("/[^\s\'\(\)_0-9a-zA-Z,]/", "", $setting[1]); + } + if (preg_match('/^custom_download/', $setting[0])) + { + $custom_download=preg_replace("/[^0-9]/", "", $setting[1]); + } + } + } + } +if (!$sort_SQL) {$sort_SQL="full_name asc, user asc";} + +$vug_stmt="select admin_viewable_groups from vicidial_user_groups where user_group='$user_group'"; +$vug_rslt=mysql_to_mysqli($vug_stmt, $link); +while($vug_row=mysqli_fetch_row($vug_rslt)) + { + $admin_viewable_groups=trim($vug_row[0]); + if(!preg_match('/\-\-\-ALL\-\-\-/', $admin_viewable_groups)) + { + $admin_viewable_groups_andSQL="and user_group in ('".preg_replace('/\s/', "', '", $admin_viewable_groups)."')"; + $admin_viewable_groups_whereSQL="where user_group in ('".preg_replace('/\s/', "', '", $admin_viewable_groups)."')"; + } + else + { + $admin_viewable_groups_andSQL=""; + $admin_viewable_groups_whereSQL=""; + } + } + +$all_users_stmt="select user, user_location, full_name from vicidial_users"; +$all_users_rslt=mysql_to_mysqli($all_users_stmt, $link); +$master_users=array(); +while($au_row=mysqli_fetch_array($all_users_rslt)) + { + $master_users["$au_row[user]"]="$au_row[full_name]"; + } + +for ($t=0; $t0 && $update_month) + { + $span_update_str=""; + for ($i=0; $i0) + { + $span_id="span_".$update_user."_".$data[0]; + $span_update_str.="\n$span_id|".($data[1]*$hoff); + } + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$upd_stmt|"; + $SQL_log = preg_replace('/;/', '', $SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='USERS', event_type='MODIFY', record_id='$update_user', event_code='USER TIME OFF LOGGED', event_sql=\"$SQL_log\", event_notes='USER: $new_agent TIME OFF UPDATED';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + } + echo $PHP_AUTH_USER." - ".$master_users["$PHP_AUTH_USER"]."\n".date("Y-m-d H:i:s").$span_update_str; + exit; + } + +if ($action=="display_past_month" && $month_to_display) + { + echo "\n"; + + echo "\n"; + echo "\t\n"; + echo "\t\n"; + echo "\n"; + + + + echo "\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + if (count($timeoff_types)<1) + { + echo "\n"; + echo ""; + echo "\n"; + } + else + { + echo "\n"; + for ($t=0; $t".$timeoff_types[$t].""; + } + echo "\n"; + } + + $i=0; + $btn_class="blue_btn"; + $agent_dropdown=""; + + $stmt="select user, user_location, full_name from vicidial_users where active='Y' $admin_viewable_groups_andSQL $user_filter_SQL order by $sort_SQL"; + $rslt=mysql_to_mysqli($stmt, $link); + while($row=mysqli_fetch_array($rslt)) + { + $agent_dropdown.="\n"; + + $location=$row["user_location"]; + + $user_stmt="select DATE_FORMAT(concat(timeoff_month, '-01'), '%b-%y') as display_month, max(modify_date) as last_modify_date".$time_column_SQL." From vicidial_timeoff_log where timeoff_month='$month_to_display' AND user='$row[user]'"; + $user_rslt=mysql_to_mysqli($user_stmt, $link); + $user_row=mysqli_fetch_array($user_rslt); + if ($user_row["display_month"]) + { + $i++; + if ($i%2==0) + { + $bgcolor="FFFFFF"; + } + else + { + $bgcolor="E6E6E6"; + } + + $lmb_stmt="select last_modified_by from vicidial_timeoff_log where user='$row[user]' and modify_date='$user_row[last_modify_date]' limit 1"; + $lmb_rslt=mysql_to_mysqli($lmb_stmt, $link); + $lmb_row=mysqli_fetch_row($lmb_rslt); + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + for ($t=0; $t".($user_row["$timeoff_types[$t]"]+0)."\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo ""; + } + else if ($display_all_agents>0) + { + $i++; + if ($i%2==0) + { + $bgcolor="FFFFFF"; + } + else + { + $bgcolor="E6E6E6"; + } + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + for ($t=0; $t0\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo ""; + } + } + + if (!$display_all_agents || $display_all_agents==0) + { + echo "\n"; + echo "\n"; + echo "\n"; + } + + + if ($custom_download && file_exists("agent_timeoff_interface_download.inc")) + { + include("agent_timeoff_interface_download.inc"); + } + + echo "
    CURRENT MONTH DISPLAYED: "; + echo ""; + echo "[DOWNLOAD]
    AgentLocationMonthPlanned HoursSaved/Updated DateUpdated By 
     
    $row[user] - $row[full_name]$location$user_row[display_month]$user_row[last_modify_date]".$lmb_row[0]." - ".$master_users["$lmb_row[0]"]."
    $row[user] - $row[full_name]$location$default_month_text----
    \n"; + echo "
    \n"; + echo "\n"; + echo "\t\n"; + echo "\t\t\n"; + echo "\n"; + echo ""; + + echo ""; + + echo "\n"; + + #echo "\n"; + + echo "\n"; + echo "\t\t\n"; + echo "\t
    ADD TIMEOFF DATA:Select an agent to add:
    Select timeoff type:"; + for ($t=0; $t$timeoff_types[$t]
    "; # onClick=\"javascript:document.getElementById('submit_timeoff_type').value=this.value\" + } + echo "
    Hours to add:PTO hours:
    \n"; + echo "
    "; + echo "
    \n"; + exit; + } + +if ($action=="download_csv" && $download_month) + { + $report_name="VICIDIAL TIME OFF"; + + ##### 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"); + $LOGbrowser=preg_replace("/\'|\"|\\\\/","",$LOGbrowser); + $LOGrequest_uri=preg_replace("/\'|\"|\\\\/","",$LOGrequest_uri); + $LOGhttp_referer=preg_replace("/\'|\"|\\\\/","",$LOGhttp_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 |Month downloaded: $download_month', 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 ##### + + + + $CSV_output="\"Agent\",\"Location\",\"Month\""; + for ($t=0; $t0) + { + $CSV_output.="\"$row[user] - $row[full_name]\","; + $CSV_output.="\"$location\","; + $CSV_output.="\"$download_month\""; + for ($t=0; $t\n"; +$HEADER.="\n"; + +$HEADER.="\n"; + +$HEADER.="\n"; +$HEADER.="\n"; + +$HEADER.="\n"; + +$HEADER.="\n"; +$HEADER.="Agent time-off interface\n"; + +header ("Content-type: text/html; charset=utf-8"); +echo $HEADER; +?> + +"; +echo "\n"; + + + +echo "\n"; +echo "\t
    \n"; +# echo $holiday_stmt."
    "; +echo "Agent time-off interface

    "; +echo "
     
    \n"; + + +# SHOW CURRENT MONTH SUPERVISOR ENTRIES +# $stmt="select * from vicidial_timeoff_log where timeoff_month>=DATE_FORMAT(now(), '%Y-%m-01') and timeoff_month\n"; +echo "\n"; +echo "\n"; +echo "\t\n"; +echo "\t\n"; +echo "\n"; + + +echo "\n"; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo "\n"; + +if (count($timeoff_types)<1) + { + echo "\n"; + echo ""; + echo "\n"; + } +else + { + echo "\n"; + for ($t=0; $t".$timeoff_types[$t].""; + } + echo "\n"; + } + +$agent_dropdown=""; +$stmt="select user, user_location, full_name from vicidial_users where active='Y' $admin_viewable_groups_andSQL $user_filter_SQL order by $sort_SQL"; +$rslt=mysql_to_mysqli($stmt, $link); + + +while($row=mysqli_fetch_array($rslt)) + { + $agent_dropdown.="\n"; + + if ($i%2==0) + { + $bgcolor="FFFFFF"; + $btn_class="blue_btn"; + } + else + { + $bgcolor="E6E6E6"; + $btn_class="blue_btn"; + } + + $location=$row["user_location"]; + + $user_stmt="select DATE_FORMAT(concat(timeoff_month, '-01'), '%b-%y') as display_month, max(modify_date) as last_modify_date".$time_column_SQL." From vicidial_timeoff_log where timeoff_month=DATE_FORMAT($month_to_display, '%Y-%m') AND user='$row[user]'"; + $user_rslt=mysql_to_mysqli($user_stmt, $link); + $user_row=mysqli_fetch_array($user_rslt); + if ($user_row["display_month"]) + { + $lmb_stmt="select last_modified_by from vicidial_timeoff_log where user='$row[user]' and modify_date='$user_row[last_modify_date]' limit 1"; + $lmb_rslt=mysql_to_mysqli($lmb_stmt, $link); + $lmb_row=mysqli_fetch_row($lmb_rslt); + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + for ($t=0; $t".($user_row["$timeoff_types[$t]"]+0)."\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo ""; + + } + else if ($display_all_agents>0) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + for ($t=0; $t0\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo ""; + } + + $i++; + } + +if (!$display_all_agents || $display_all_agents==0) + { + echo "\n"; + echo "\n"; + echo "\n"; + } + +if ($custom_download && file_exists("agent_timeoff_interface_download.inc")) + { + include("agent_timeoff_interface_download.inc"); + } + +echo "
    CURRENT MONTH DISPLAYED: "; +echo ""; +echo "[DOWNLOAD]
    AgentLocationMonthPlanned HoursSaved/Updated DateUpdated By 
     
    $row[user] - $row[full_name]$location$user_row[display_month]$user_row[last_modify_date]".$lmb_row[0]." - ".$master_users["$lmb_row[0]"]."
    $row[user] - $row[full_name]$location".date("M-y")."----
    \n"; + echo "
    \n"; + echo "\n"; + echo "\t\n"; + echo "\t\t\n"; + echo "\n"; + echo ""; + + echo ""; + + echo "\n"; + + #echo "\n"; + + echo "\n"; + echo "\t\t\n"; + echo "\t
    ADD TIMEOFF DATA:Select an agent to add:
    Select timeoff type:"; + for ($t=0; $t$timeoff_types[$t]
    "; # onClick=\"javascript:document.getElementById('submit_timeoff_type').value=this.value\" + } + echo "
    Hours to add:PTO hours:
    \n"; + echo "
    "; + echo "
    \n"; +echo "\n"; + +# SHOW PAST MONTH LOG ENTRIES +/* +echo "


    \n"; + +echo "\n"; +echo "\n\t\n"; +echo "\t\n"; +echo "\n\t\n"; +echo "
    PAST MONTH TIME OFF:Select a past month to display:
    \n"; +echo "
    \n"; +echo "\n"; + +*/ +?> + + +

    \n\n"; + + +echo "\n\n\n


    \n"._QXZ("script runtime").": $RUNtime "._QXZ("seconds")."|$db_source
    "; + +# print_r($location_array); + +echo "
    "; +echo ""; +echo ""; + +# header ("Content-type: text/html; charset=utf-8"); +# echo $HEADER; +# require("admin_header.php"); +# echo $MAIN; + +?>