<?php
# admin.php - VICIDIAL administration page
#
# Copyright (C) 2025  Matt Florell <vicidial@gmail.com>    LICENSE: AGPLv2
# 

$startMS = microtime();
$php_script='admin.php';

require("dbconnect_mysqli.php");
require("functions.php");

######################################################################################################
######################################################################################################
#######   static variable settings for display options
######################################################################################################
######################################################################################################

$page_width='870';
$section_width='850';
$header_font_size='12';
$subheader_font_size='11';
$subcamp_font_size='11';
$header_selected_bold='<b>';
$header_nonselected_bold='';
$users_color =		'#FFFF99';
$campaigns_color =	'#FFCC99';
$lists_color =		'#FFCCCC';
$ingroups_color =	'#CC99FF';
$remoteagent_color ='#CCFFCC';
$usergroups_color =	'#CCFFFF';
$scripts_color =	'#99FFCC';
$filters_color =	'#CCCCCC';
$admin_color =		'#FF99FF';
$reports_color =	'#99FF33';
	$times_color =		'#FF33FF';
	$shifts_color =		'#FF33FF';
	$phones_color =		'#FF33FF';
	$conference_color =	'#FF33FF';
	$server_color =		'#FF33FF';
	$templates_color =	'#FF33FF';
	$carriers_color =	'#FF33FF';
	$settings_color = 	'#FF33FF';
	$label_color =		'#FF33FF';
	$status_color = 	'#FF33FF';
	$moh_color = 		'#FF33FF';
	$vm_color = 		'#FF33FF';
	$tts_color = 		'#FF33FF';
	$cc_color = 		'#FF33FF';
	$cts_color = 		'#FF33FF';
$subcamp_color =	'#FF9933';
$users_font =		'BLACK';
$campaigns_font =	'BLACK';
$lists_font =		'BLACK';
$ingroups_font =	'BLACK';
$remoteagent_font =	'BLACK';
$usergroups_font =	'BLACK';
$scripts_font =		'BLACK';
$filters_font =		'BLACK';
$admin_font =		'BLACK';
$qc_font =			'BLACK';
$reports_font =		'BLACK';
	$times_font =		'BLACK';
	$phones_font =		'BLACK';
	$conference_font =	'BLACK';
	$server_font =		'BLACK';
	$settings_font = 	'BLACK';
	$label_font = 	'BLACK';
	$status_font = 	'BLACK';
	$moh_font = 	'BLACK';
	$vm_font = 		'BLACK';
	$tts_font = 	'BLACK';
	$cc_font =		'BLACK';
	$cts_font = 	'BLACK';
$subcamp_font =		'BLACK';

### comment this section out for colorful section headings
$users_color =		'#E6E6E6';
$campaigns_color =	'#E6E6E6';
$lists_color =		'#E6E6E6';
$ingroups_color =	'#E6E6E6';
$remoteagent_color ='#E6E6E6';
$usergroups_color =	'#E6E6E6';
$scripts_color =	'#E6E6E6';
$filters_color =	'#E6E6E6';
$admin_color =		'#E6E6E6';
$qc_color =			'#E6E6E6';
$reports_color =	'#E6E6E6';
	$times_color =		'#C6C6C6';
	$shifts_color =		'#C6C6C6';
	$phones_color =		'#C6C6C6';
	$conference_color =	'#C6C6C6';
	$server_color =		'#C6C6C6';
	$templates_color =	'#C6C6C6';
	$carriers_color =	'#C6C6C6';
	$settings_color = 	'#C6C6C6';
	$label_color =		'#C6C6C6';
	$colors_color =		'#C6C6C6';
	$status_color = 	'#C6C6C6';
	$moh_color = 		'#C6C6C6';
	$vm_color = 		'#C6C6C6';
	$tts_color = 		'#C6C6C6';
	$cc_color = 		'#C6C6C6';
	$cts_color = 		'#C6C6C6';
	$sc_color = 		'#C6C6C6';
	$sg_color = 		'#C6C6C6';
	$ar_color = 		'#C6C6C6';
	$il_color = 		'#C6C6C6';
	$cg_color = 		'#C6C6C6';
	$vmmg_color = 		'#C6C6C6';
$subcamp_color =	'#C6C6C6';

$Msubhead_color =	'#E6E6E6';
$Mselected_color =	'#C6C6C6';
$Mhead_color =		'#A3C3D6';
$Mmain_bgcolor =	'#015B91';

###


$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");
$groups=array();

$Vreports = 'NONE, Real-Time Main Report, Real-Time Campaign Summary, Real-Time Whiteboard Report, VERM Reports, Inbound Report, Inbound Report by DID, Inbound Service Level Report, Inbound Summary Hourly Report, Inbound Daily Report, Inbound DID Report, Inbound DID Summary Report, Agent DID Report, Inbound DID Detail Report, Inbound IVR Report, Inbound Forecasting Report, Advanced Forecasting Report, Outbound Calling Report, Outbound Summary Interval Report, Outbound IVR Report, Callmenu Survey Report, Outbound Lead Source 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 Inbound Status Summary, 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 Group Detail 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, Shared 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, AMD Log Report, 3-Way Press Log Report, SIP Event Report, Caller ID Log Report, Quality Control Report, Settings Compare, Phone Stats, Hopper List Report, In-Group User List, Webserver-URL Report, VDAD Debug Log Report, URL Log Report, Medialog Inventory Report, Asterisk Debug, SPH Report, Shared Debug, Process Report, Group Alias Report, Hangup Cause Report, IVR Filter Report, LAGGED Agent Log Report, LAGGED Agent Log Summary Report, Agent Latency Report, Latency Gaps Report, Agent Disposition Report, Agent Performance Report, Carrier Log Report, Dial Log Report, Inbound Extension Stats, Agents Time On Calls, Callbacks Export, User Logins Report, Demographic Quotas Report, DB Schema Compare Utility, Khomp Quick Stats Report';

$UGreports = 'ALL REPORTS, NONE, Real-Time Main Report, Real-Time Campaign Summary, Real-Time Whiteboard Report, VERM Reports, Inbound Report, Inbound Report by DID, Inbound Service Level Report, Inbound Summary Hourly Report, Inbound Daily Report, Inbound DID Report, Inbound DID Summary Report, Agent DID Report, Inbound DID Detail 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, Callmenu Survey Report, Outbound Lead Source 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 Inbound Status Summary, 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 Group Detail 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, AMD Log Report, 3-Way Press Log Report, SIP Event Report, Caller ID Log Report, Quality Control Report, Settings Compare, Phone Stats, Hopper List Report, In-Group User List, Webserver-URL Report, VDAD Debug Log Report, URL Log Report, Medialog Inventory Report, Asterisk Debug, SPH Report, Shared Debug, Process Report, Group Alias Report, Hangup Cause Report, IVR Filter Report, LAGGED Agent Log Report, LAGGED Agent Log Summary Report, Agent Latency Report, Latency Gaps Report, Agent Disposition Report, Agent Performance Report, Carrier Log Report, Dial Log Report, Inbound Extension Stats, Agents Time On Calls, Callbacks Export, User Logins Report, Demographic Quotas Report, VERM QA Links, DB Schema Compare Utility, Khomp Quick Stats Report';

$Vtables = 'NONE,log_noanswer,did_agent_log,contact_information';

$APIfunctions = 'ALL_FUNCTIONS add_group_alias add_lead add_list add_phone add_phone_alias add_user agent_ingroup_info agent_stats_export agent_status audio_playback blind_monitor call_agent callid_info change_ingroups check_phone_number copy_user did_log_export external_add_lead external_dial external_hangup external_pause external_status in_group_status logout moh_list ingroup_list campaigns_list callmenu_list hopper_list hopper_bulk_insert call_dispo_report agent_campaigns park_call pause_code preview_dial_action ra_call_control recording stereo_recording recording_lookup send_dtmf server_refresh set_timer_action sounds_list st_get_agent_active_lead st_login_log transfer_conference update_fields update_lead batch_update_lead update_list list_info list_custom_fields update_log_entry update_phone update_phone_alias update_user user_group_status vm_list vm_message webphone_url webserver logged_in_agents update_campaign update_alt_url update_presets add_did copy_did update_did lead_field_info lead_all_info lead_callback_info phone_number_log switch_lead ccc_lead_info lead_status_search lead_search lead_dearchive call_status_stats calls_in_queue_count force_fronter_leave_3way force_fronter_audio_stop update_cid_group_entry add_dnc_phone delete_dnc_phone add_fpg_phone send_notification refresh_panel update_remote_agent user_details';

$browser_alert_sounds_list = 'bark_dog,beep_double,beep_five,beep_up,bell_double,bell_school,bird,blaster1,blaster2,buzz1,buzz2,cash_register,chat_alert,click_single,click_double,click_quiet,close_encounter,confirmation,ding,droplet,droplet_double,elephant,email_alert,hold_tone,horn_bike,horn_car,horn_car_triple,horn_clown,horn_double,horn_train,meow_cat,scream_wilhelm,silence_quick,siren,slide_down,slide_up,swish,teleport1,teleport2,ticking_two,ticking_four,ticking_six,whip,whistle_up,whistle_two,whistle_three,whoosh,xylophone1,xylophone2,xylophone3,xylophone4,20Hz_tone';

$HTMLcolors = 'IndianRed,CD5C5C|LightCoral,F08080|Salmon,FA8072|DarkSalmon,E9967A|LightSalmon,FFA07A|Crimson,DC143C|Red,FF0000|FireBrick,B22222|DarkRed,8B0000|Pink,FFC0CB|LightPink,FFB6C1|HotPink,FF69B4|DeepPink,FF1493|MediumVioletRed,C71585|PaleVioletRed,DB7093|LightSalmon,FFA07A|Coral,FF7F50|Tomato,FF6347|OrangeRed,FF4500|DarkOrange,FF8C00|Orange,FFA500|Gold,FFD700|Yellow,FFFF00|LightYellow,FFFFE0|LemonChiffon,FFFACD|LightGoldenrodYellow,FAFAD2|PapayaWhip,FFEFD5|Moccasin,FFE4B5|PeachPuff,FFDAB9|PaleGoldenrod,EEE8AA|Khaki,F0E68C|DarkKhaki,BDB76B|Lavender,E6E6FA|Thistle,D8BFD8|Plum,DDA0DD|Violet,EE82EE|Orchid,DA70D6|Fuchsia,FF00FF|Magenta,FF00FF|MediumOrchid,BA55D3|MediumPurple,9370DB|RebeccaPurple,663399|BlueViolet,8A2BE2|DarkViolet,9400D3|DarkOrchid,9932CC|DarkMagenta,8B008B|Purple,800080|Indigo,4B0082|SlateBlue,6A5ACD|DarkSlateBlue,483D8B|MediumSlateBlue,7B68EE|GreenYellow,ADFF2F|Chartreuse,7FFF00|LawnGreen,7CFC00|Lime,00FF00|LimeGreen,32CD32|PaleGreen,98FB98|LightGreen,90EE90|MediumSpringGreen,00FA9A|SpringGreen,00FF7F|MediumSeaGreen,3CB371|SeaGreen,2E8B57|ForestGreen,228B22|Green,008000|DarkGreen,006400|YellowGreen,9ACD32|OliveDrab,6B8E23|Olive,808000|DarkOliveGreen,556B2F|MediumAquamarine,66CDAA|DarkSeaGreen,8FBC8B|LightSeaGreen,20B2AA|DarkCyan,008B8B|Teal,008080|Aqua,00FFFF|Cyan,00FFFF|LightCyan,E0FFFF|PaleTurquoise,AFEEEE|Aquamarine,7FFFD4|Turquoise,40E0D0|MediumTurquoise,48D1CC|DarkTurquoise,00CED1|CadetBlue,5F9EA0|SteelBlue,4682B4|LightSteelBlue,B0C4DE|PowderBlue,B0E0E6|LightBlue,ADD8E6|SkyBlue,87CEEB|LightSkyBlue,87CEFA|DeepSkyBlue,00BFFF|DodgerBlue,1E90FF|CornflowerBlue,6495ED|MediumSlateBlue,7B68EE|RoyalBlue,4169E1|Blue,0000FF|MediumBlue,0000CD|DarkBlue,00008B|Navy,000080|MidnightBlue,191970|Cornsilk,FFF8DC|BlanchedAlmond,FFEBCD|Bisque,FFE4C4|NavajoWhite,FFDEAD|Wheat,F5DEB3|BurlyWood,DEB887|Tan,D2B48C|RosyBrown,BC8F8F|SandyBrown,F4A460|Goldenrod,DAA520|DarkGoldenrod,B8860B|Peru,CD853F|Chocolate,D2691E|SaddleBrown,8B4513|Sienna,A0522D|Brown,A52A2A|Maroon,800000|White,FFFFFF|Snow,FFFAFA|HoneyDew,F0FFF0|MintCream,F5FFFA|Azure,F0FFFF|AliceBlue,F0F8FF|GhostWhite,F8F8FF|WhiteSmoke,F5F5F5|SeaShell,FFF5EE|Beige,F5F5DC|OldLace,FDF5E6|FloralWhite,FFFAF0|Ivory,FFFFF0|AntiqueWhite,FAEBD7|Linen,FAF0E6|LavenderBlush,FFF0F5|MistyRose,FFE4E1|Gainsboro,DCDCDC|LightGray,D3D3D3|Silver,C0C0C0|DarkGray,A9A9A9|Gray,808080|DimGray,696969|LightSlateGray,778899|SlateGray,708090|DarkSlateGray,2F4F4F|Black,000000';

### BEGIN housecleaning of old static report files, if not done before ###
if (!file_exists('old_clear'))
	{
	array_map('unlink', glob("./*.csv"));
	array_map('unlink', glob("./*.xls"));
	array_map('unlink', glob("./ploticus/*"));
	unlink('project_auth_entries.txt');

	$clear_file=fopen('old_clear', "w");
	fwrite($clear_file, '1');
	fclose($clear_file);
	}
if (file_exists('project_auth_entries.txt'))
	{
	unlink('project_auth_entries.txt');
	}
### END housecleaning of old static report files ###


######################################################################################################
######################################################################################################
#######   Form variable declaration
######################################################################################################
######################################################################################################

if (isset($_GET["DB"]))				{$DB=$_GET["DB"];}
	elseif (isset($_POST["DB"]))	{$DB=$_POST["DB"];}
if (isset($_GET["access_recordings"]))			{$access_recordings=$_GET["access_recordings"];}
	elseif (isset($_POST["access_recordings"]))	{$access_recordings=$_POST["access_recordings"];}
if (isset($_GET["active"]))				{$active=$_GET["active"];}
	elseif (isset($_POST["active"]))	{$active=$_POST["active"];}
if (isset($_GET["adaptive_dl_diff_target"]))			{$adaptive_dl_diff_target=$_GET["adaptive_dl_diff_target"];}
	elseif (isset($_POST["adaptive_dl_diff_target"]))	{$adaptive_dl_diff_target=$_POST["adaptive_dl_diff_target"];}
if (isset($_GET["adaptive_dropped_percentage"]))		{$adaptive_dropped_percentage=$_GET["adaptive_dropped_percentage"];}
	elseif (isset($_POST["adaptive_dropped_percentage"])){$adaptive_dropped_percentage=$_POST["adaptive_dropped_percentage"];}
if (isset($_GET["adaptive_intensity"]))	{$adaptive_intensity=$_GET["adaptive_intensity"];}
	elseif (isset($_POST["adaptive_intensity"]))	{$adaptive_intensity=$_POST["adaptive_intensity"];}
if (isset($_GET["adaptive_latest_server_time"]))	{$adaptive_latest_server_time=$_GET["adaptive_latest_server_time"];}
	elseif (isset($_POST["adaptive_latest_server_time"])){$adaptive_latest_server_time=$_POST["adaptive_latest_server_time"];}
if (isset($_GET["adaptive_maximum_level"]))	{$adaptive_maximum_level=$_GET["adaptive_maximum_level"];}
	elseif (isset($_POST["adaptive_maximum_level"]))	{$adaptive_maximum_level=$_POST["adaptive_maximum_level"];}
if (isset($_GET["SUB"]))			{$SUB=$_GET["SUB"];}
	elseif (isset($_POST["SUB"]))	{$SUB=$_POST["SUB"];}
if (isset($_GET["ADD"]))			{$ADD=$_GET["ADD"];}
	elseif (isset($_POST["ADD"]))	{$ADD=$_POST["ADD"];}
if (isset($_GET["admin_hangup_enabled"]))	{$admin_hangup_enabled=$_GET["admin_hangup_enabled"];}
	elseif (isset($_POST["admin_hangup_enabled"]))	{$admin_hangup_enabled=$_POST["admin_hangup_enabled"];}
if (isset($_GET["admin_hijack_enabled"]))	{$admin_hijack_enabled=$_GET["admin_hijack_enabled"];}
	elseif (isset($_POST["admin_hijack_enabled"]))	{$admin_hijack_enabled=$_POST["admin_hijack_enabled"];}
if (isset($_GET["admin_monitor_enabled"]))	{$admin_monitor_enabled=$_GET["admin_monitor_enabled"];}
	elseif (isset($_POST["admin_monitor_enabled"]))	{$admin_monitor_enabled=$_POST["admin_monitor_enabled"];}
if (isset($_GET["AFLogging_enabled"]))	{$AFLogging_enabled=$_GET["AFLogging_enabled"];}
	elseif (isset($_POST["AFLogging_enabled"]))	{$AFLogging_enabled=$_POST["AFLogging_enabled"];}
if (isset($_GET["agent_choose_ingroups"]))	{$agent_choose_ingroups=$_GET["agent_choose_ingroups"];}
	elseif (isset($_POST["agent_choose_ingroups"]))	{$agent_choose_ingroups=$_POST["agent_choose_ingroups"];}
if (isset($_GET["agentcall_manual"]))	{$agentcall_manual=$_GET["agentcall_manual"];}
	elseif (isset($_POST["agentcall_manual"]))	{$agentcall_manual=$_POST["agentcall_manual"];}
if (isset($_GET["agentonly_callbacks"]))	{$agentonly_callbacks=$_GET["agentonly_callbacks"];}
	elseif (isset($_POST["agentonly_callbacks"]))	{$agentonly_callbacks=$_POST["agentonly_callbacks"];}
if (isset($_GET["AGI_call_logging_enabled"]))	{$AGI_call_logging_enabled=$_GET["AGI_call_logging_enabled"];}
	elseif (isset($_POST["AGI_call_logging_enabled"]))	{$AGI_call_logging_enabled=$_POST["AGI_call_logging_enabled"];}
if (isset($_GET["agi_output"]))	{$agi_output=$_GET["agi_output"];}
	elseif (isset($_POST["agi_output"]))	{$agi_output=$_POST["agi_output"];}
if (isset($_GET["allcalls_delay"]))	{$allcalls_delay=$_GET["allcalls_delay"];}
	elseif (isset($_POST["allcalls_delay"]))	{$allcalls_delay=$_POST["allcalls_delay"];}
if (isset($_GET["allow_closers"]))	{$allow_closers=$_GET["allow_closers"];}
	elseif (isset($_POST["allow_closers"]))	{$allow_closers=$_POST["allow_closers"];}
if (isset($_GET["alt_number_dialing"]))	{$alt_number_dialing=$_GET["alt_number_dialing"];}
	elseif (isset($_POST["alt_number_dialing"]))	{$alt_number_dialing=$_POST["alt_number_dialing"];}
if (isset($_GET["alter_agent_interface_options"]))	{$alter_agent_interface_options=$_GET["alter_agent_interface_options"];}
	elseif (isset($_POST["alter_agent_interface_options"]))	{$alter_agent_interface_options=$_POST["alter_agent_interface_options"];}
if (isset($_GET["am_message_exten"]))	{$am_message_exten=$_GET["am_message_exten"];}
	elseif (isset($_POST["am_message_exten"]))	{$am_message_exten=$_POST["am_message_exten"];}
if (isset($_GET["amd_send_to_vmx"]))	{$amd_send_to_vmx=$_GET["amd_send_to_vmx"];}
	elseif (isset($_POST["amd_send_to_vmx"]))	{$amd_send_to_vmx=$_POST["amd_send_to_vmx"];}
if (isset($_GET["answer_transfer_agent"]))	{$answer_transfer_agent=$_GET["answer_transfer_agent"];}
	elseif (isset($_POST["answer_transfer_agent"]))	{$answer_transfer_agent=$_POST["answer_transfer_agent"];}
if (isset($_GET["ast_admin_access"]))	{$ast_admin_access=$_GET["ast_admin_access"];}
	elseif (isset($_POST["ast_admin_access"]))	{$ast_admin_access=$_POST["ast_admin_access"];}
if (isset($_GET["ast_delete_phones"]))	{$ast_delete_phones=$_GET["ast_delete_phones"];}
	elseif (isset($_POST["ast_delete_phones"]))	{$ast_delete_phones=$_POST["ast_delete_phones"];}
if (isset($_GET["asterisk_version"]))	{$asterisk_version=$_GET["asterisk_version"];}
	elseif (isset($_POST["asterisk_version"]))	{$asterisk_version=$_POST["asterisk_version"];}
if (isset($_GET["ASTmgrSECRET"]))	{$ASTmgrSECRET=$_GET["ASTmgrSECRET"];}
	elseif (isset($_POST["ASTmgrSECRET"]))	{$ASTmgrSECRET=$_POST["ASTmgrSECRET"];}
if (isset($_GET["ASTmgrUSERNAME"]))	{$ASTmgrUSERNAME=$_GET["ASTmgrUSERNAME"];}
	elseif (isset($_POST["ASTmgrUSERNAME"]))	{$ASTmgrUSERNAME=$_POST["ASTmgrUSERNAME"];}
if (isset($_GET["ASTmgrUSERNAMElisten"]))	{$ASTmgrUSERNAMElisten=$_GET["ASTmgrUSERNAMElisten"];}
	elseif (isset($_POST["ASTmgrUSERNAMElisten"]))	{$ASTmgrUSERNAMElisten=$_POST["ASTmgrUSERNAMElisten"];}
if (isset($_GET["ASTmgrUSERNAMEsend"]))	{$ASTmgrUSERNAMEsend=$_GET["ASTmgrUSERNAMEsend"];}
	elseif (isset($_POST["ASTmgrUSERNAMEsend"]))	{$ASTmgrUSERNAMEsend=$_POST["ASTmgrUSERNAMEsend"];}
if (isset($_GET["ASTmgrUSERNAMEupdate"]))	{$ASTmgrUSERNAMEupdate=$_GET["ASTmgrUSERNAMEupdate"];}
	elseif (isset($_POST["ASTmgrUSERNAMEupdate"]))	{$ASTmgrUSERNAMEupdate=$_POST["ASTmgrUSERNAMEupdate"];}
if (isset($_GET["attempt_delay"]))	{$attempt_delay=$_GET["attempt_delay"];}
	elseif (isset($_POST["attempt_delay"]))	{$attempt_delay=$_POST["attempt_delay"];}
if (isset($_GET["attempt_maximum"]))	{$attempt_maximum=$_GET["attempt_maximum"];}
	elseif (isset($_POST["attempt_maximum"]))	{$attempt_maximum=$_POST["attempt_maximum"];}
if (isset($_GET["auto_dial_level"]))	{$auto_dial_level=$_GET["auto_dial_level"];}
	elseif (isset($_POST["auto_dial_level"]))	{$auto_dial_level=$_POST["auto_dial_level"];}
if (isset($_GET["auto_dial_next_number"]))	{$auto_dial_next_number=$_GET["auto_dial_next_number"];}
	elseif (isset($_POST["auto_dial_next_number"]))	{$auto_dial_next_number=$_POST["auto_dial_next_number"];}
if (isset($_GET["available_only_ratio_tally"]))	{$available_only_ratio_tally=$_GET["available_only_ratio_tally"];}
	elseif (isset($_POST["available_only_ratio_tally"])){$available_only_ratio_tally=$_POST["available_only_ratio_tally"];}
if (isset($_GET["call_out_number_group"]))	{$call_out_number_group=$_GET["call_out_number_group"];}
	elseif (isset($_POST["call_out_number_group"]))	{$call_out_number_group=$_POST["call_out_number_group"];}
if (isset($_GET["call_parking_enabled"]))	{$call_parking_enabled=$_GET["call_parking_enabled"];}
	elseif (isset($_POST["call_parking_enabled"]))	{$call_parking_enabled=$_POST["call_parking_enabled"];}
if (isset($_GET["call_time_comments"]))	{$call_time_comments=$_GET["call_time_comments"];}
	elseif (isset($_POST["call_time_comments"]))	{$call_time_comments=$_POST["call_time_comments"];}
if (isset($_GET["call_time_id"]))	{$call_time_id=$_GET["call_time_id"];}
	elseif (isset($_POST["call_time_id"]))	{$call_time_id=$_POST["call_time_id"];}
if (isset($_GET["call_time_name"]))	{$call_time_name=$_GET["call_time_name"];}
	elseif (isset($_POST["call_time_name"]))	{$call_time_name=$_POST["call_time_name"];}
if (isset($_GET["CallerID_popup_enabled"]))	{$CallerID_popup_enabled=$_GET["CallerID_popup_enabled"];}
	elseif (isset($_POST["CallerID_popup_enabled"]))	{$CallerID_popup_enabled=$_POST["CallerID_popup_enabled"];}
if (isset($_GET["campaign_cid"]))	{$campaign_cid=$_GET["campaign_cid"];}
	elseif (isset($_POST["campaign_cid"]))	{$campaign_cid=$_POST["campaign_cid"];}
if (isset($_GET["campaign_detail"]))	{$campaign_detail=$_GET["campaign_detail"];}
	elseif (isset($_POST["campaign_detail"]))	{$campaign_detail=$_POST["campaign_detail"];}
if (isset($_GET["campaign_id"]))	{$campaign_id=$_GET["campaign_id"];}
	elseif (isset($_POST["campaign_id"]))	{$campaign_id=$_POST["campaign_id"];}
if (isset($_GET["campaign_name"]))	{$campaign_name=$_GET["campaign_name"];}
	elseif (isset($_POST["campaign_name"]))	{$campaign_name=$_POST["campaign_name"];}
if (isset($_GET["campaign_rec_exten"]))	{$campaign_rec_exten=$_GET["campaign_rec_exten"];}
	elseif (isset($_POST["campaign_rec_exten"]))	{$campaign_rec_exten=$_POST["campaign_rec_exten"];}
if (isset($_GET["campaign_rec_filename"]))	{$campaign_rec_filename=$_GET["campaign_rec_filename"];}
	elseif (isset($_POST["campaign_rec_filename"]))	{$campaign_rec_filename=$_POST["campaign_rec_filename"];}
if (isset($_GET["ingroup_rec_filename"]))	{$ingroup_rec_filename=$_GET["ingroup_rec_filename"];}
	elseif (isset($_POST["ingroup_rec_filename"]))	{$ingroup_rec_filename=$_POST["ingroup_rec_filename"];}
if (isset($_GET["campaign_recording"]))	{$campaign_recording=$_GET["campaign_recording"];}
	elseif (isset($_POST["campaign_recording"]))	{$campaign_recording=$_POST["campaign_recording"];}
if (isset($_GET["campaign_vdad_exten"]))	{$campaign_vdad_exten=$_GET["campaign_vdad_exten"];}
	elseif (isset($_POST["campaign_vdad_exten"]))	{$campaign_vdad_exten=$_POST["campaign_vdad_exten"];}
if (isset($_GET["change_agent_campaign"]))	{$change_agent_campaign=$_GET["change_agent_campaign"];}
	elseif (isset($_POST["change_agent_campaign"]))	{$change_agent_campaign=$_POST["change_agent_campaign"];}
if (isset($_GET["client_browser"]))	{$client_browser=$_GET["client_browser"];}
	elseif (isset($_POST["client_browser"]))	{$client_browser=$_POST["client_browser"];}
if (isset($_GET["closer_default_blended"]))	{$closer_default_blended=$_GET["closer_default_blended"];}
	elseif (isset($_POST["closer_default_blended"]))	{$closer_default_blended=$_POST["closer_default_blended"];}
if (isset($_GET["company"]))	{$company=$_GET["company"];}
	elseif (isset($_POST["company"]))	{$company=$_POST["company"];}
if (isset($_GET["computer_ip"]))	{$computer_ip=$_GET["computer_ip"];}
	elseif (isset($_POST["computer_ip"]))	{$computer_ip=$_POST["computer_ip"];}
if (isset($_GET["conf_exten"]))	{$conf_exten=$_GET["conf_exten"];}
	elseif (isset($_POST["conf_exten"]))	{$conf_exten=$_POST["conf_exten"];}
if (isset($_GET["conf_on_extension"]))	{$conf_on_extension=$_GET["conf_on_extension"];}
	elseif (isset($_POST["conf_on_extension"]))	{$conf_on_extension=$_POST["conf_on_extension"];}
if (isset($_GET["conferencing_enabled"]))	{$conferencing_enabled=$_GET["conferencing_enabled"];}
	elseif (isset($_POST["conferencing_enabled"]))	{$conferencing_enabled=$_POST["conferencing_enabled"];}
if (isset($_GET["CoNfIrM"]))	{$CoNfIrM=$_GET["CoNfIrM"];}
	elseif (isset($_POST["CoNfIrM"]))	{$CoNfIrM=$_POST["CoNfIrM"];}
if (isset($_GET["ct_default_start"]))	{$ct_default_start=$_GET["ct_default_start"];}
	elseif (isset($_POST["ct_default_start"]))	{$ct_default_start=$_POST["ct_default_start"];}
if (isset($_GET["ct_default_stop"]))	{$ct_default_stop=$_GET["ct_default_stop"];}
	elseif (isset($_POST["ct_default_stop"]))	{$ct_default_stop=$_POST["ct_default_stop"];}
if (isset($_GET["ct_friday_start"]))	{$ct_friday_start=$_GET["ct_friday_start"];}
	elseif (isset($_POST["ct_friday_start"]))	{$ct_friday_start=$_POST["ct_friday_start"];}
if (isset($_GET["ct_friday_stop"]))	{$ct_friday_stop=$_GET["ct_friday_stop"];}
	elseif (isset($_POST["ct_friday_stop"]))	{$ct_friday_stop=$_POST["ct_friday_stop"];}
if (isset($_GET["ct_monday_start"]))	{$ct_monday_start=$_GET["ct_monday_start"];}
	elseif (isset($_POST["ct_monday_start"]))	{$ct_monday_start=$_POST["ct_monday_start"];}
if (isset($_GET["ct_monday_stop"]))	{$ct_monday_stop=$_GET["ct_monday_stop"];}
	elseif (isset($_POST["ct_monday_stop"]))	{$ct_monday_stop=$_POST["ct_monday_stop"];}
if (isset($_GET["ct_saturday_start"]))	{$ct_saturday_start=$_GET["ct_saturday_start"];}
	elseif (isset($_POST["ct_saturday_start"]))	{$ct_saturday_start=$_POST["ct_saturday_start"];}
if (isset($_GET["ct_saturday_stop"]))	{$ct_saturday_stop=$_GET["ct_saturday_stop"];}
	elseif (isset($_POST["ct_saturday_stop"]))	{$ct_saturday_stop=$_POST["ct_saturday_stop"];}
if (isset($_GET["ct_sunday_start"]))	{$ct_sunday_start=$_GET["ct_sunday_start"];}
	elseif (isset($_POST["ct_sunday_start"]))	{$ct_sunday_start=$_POST["ct_sunday_start"];}
if (isset($_GET["ct_sunday_stop"]))	{$ct_sunday_stop=$_GET["ct_sunday_stop"];}
	elseif (isset($_POST["ct_sunday_stop"]))	{$ct_sunday_stop=$_POST["ct_sunday_stop"];}
if (isset($_GET["ct_thursday_start"]))	{$ct_thursday_start=$_GET["ct_thursday_start"];}
	elseif (isset($_POST["ct_thursday_start"]))	{$ct_thursday_start=$_POST["ct_thursday_start"];}
if (isset($_GET["ct_thursday_stop"]))	{$ct_thursday_stop=$_GET["ct_thursday_stop"];}
	elseif (isset($_POST["ct_thursday_stop"]))	{$ct_thursday_stop=$_POST["ct_thursday_stop"];}
if (isset($_GET["ct_tuesday_start"]))	{$ct_tuesday_start=$_GET["ct_tuesday_start"];}
	elseif (isset($_POST["ct_tuesday_start"]))	{$ct_tuesday_start=$_POST["ct_tuesday_start"];}
if (isset($_GET["ct_tuesday_stop"]))	{$ct_tuesday_stop=$_GET["ct_tuesday_stop"];}
	elseif (isset($_POST["ct_tuesday_stop"]))	{$ct_tuesday_stop=$_POST["ct_tuesday_stop"];}
if (isset($_GET["ct_wednesday_start"]))	{$ct_wednesday_start=$_GET["ct_wednesday_start"];}
	elseif (isset($_POST["ct_wednesday_start"]))	{$ct_wednesday_start=$_POST["ct_wednesday_start"];}
if (isset($_GET["ct_wednesday_stop"]))	{$ct_wednesday_stop=$_GET["ct_wednesday_stop"];}
	elseif (isset($_POST["ct_wednesday_stop"]))	{$ct_wednesday_stop=$_POST["ct_wednesday_stop"];}
if (isset($_GET["DBX_database"]))	{$DBX_database=$_GET["DBX_database"];}
	elseif (isset($_POST["DBX_database"]))	{$DBX_database=$_POST["DBX_database"];}
if (isset($_GET["DBX_pass"]))	{$DBX_pass=$_GET["DBX_pass"];}
	elseif (isset($_POST["DBX_pass"]))	{$DBX_pass=$_POST["DBX_pass"];}
if (isset($_GET["DBX_port"]))	{$DBX_port=$_GET["DBX_port"];}
	elseif (isset($_POST["DBX_port"]))	{$DBX_port=$_POST["DBX_port"];}
if (isset($_GET["DBX_server"]))	{$DBX_server=$_GET["DBX_server"];}
	elseif (isset($_POST["DBX_server"]))	{$DBX_server=$_POST["DBX_server"];}
if (isset($_GET["DBX_user"]))	{$DBX_user=$_GET["DBX_user"];}
	elseif (isset($_POST["DBX_user"]))	{$DBX_user=$_POST["DBX_user"];}
if (isset($_GET["DBY_database"]))	{$DBY_database=$_GET["DBY_database"];}
	elseif (isset($_POST["DBY_database"]))	{$DBY_database=$_POST["DBY_database"];}
if (isset($_GET["DBY_pass"]))	{$DBY_pass=$_GET["DBY_pass"];}
	elseif (isset($_POST["DBY_pass"]))	{$DBY_pass=$_POST["DBY_pass"];}
if (isset($_GET["DBY_port"]))	{$DBY_port=$_GET["DBY_port"];}
	elseif (isset($_POST["DBY_port"]))	{$DBY_port=$_POST["DBY_port"];}
if (isset($_GET["DBY_server"]))	{$DBY_server=$_GET["DBY_server"];}
	elseif (isset($_POST["DBY_server"]))	{$DBY_server=$_POST["DBY_server"];}
if (isset($_GET["DBY_user"]))	{$DBY_user=$_GET["DBY_user"];}
	elseif (isset($_POST["DBY_user"]))	{$DBY_user=$_POST["DBY_user"];}
if (isset($_GET["delete_call_times"]))	{$delete_call_times=$_GET["delete_call_times"];}
	elseif (isset($_POST["delete_call_times"]))	{$delete_call_times=$_POST["delete_call_times"];}
if (isset($_GET["delete_campaigns"]))	{$delete_campaigns=$_GET["delete_campaigns"];}
	elseif (isset($_POST["delete_campaigns"]))	{$delete_campaigns=$_POST["delete_campaigns"];}
if (isset($_GET["delete_filters"]))	{$delete_filters=$_GET["delete_filters"];}
	elseif (isset($_POST["delete_filters"]))	{$delete_filters=$_POST["delete_filters"];}
if (isset($_GET["delete_ingroups"]))	{$delete_ingroups=$_GET["delete_ingroups"];}
	elseif (isset($_POST["delete_ingroups"]))	{$delete_ingroups=$_POST["delete_ingroups"];}
if (isset($_GET["delete_lists"]))	{$delete_lists=$_GET["delete_lists"];}
	elseif (isset($_POST["delete_lists"]))	{$delete_lists=$_POST["delete_lists"];}
if (isset($_GET["delete_remote_agents"]))	{$delete_remote_agents=$_GET["delete_remote_agents"];}
	elseif (isset($_POST["delete_remote_agents"]))	{$delete_remote_agents=$_POST["delete_remote_agents"];}
if (isset($_GET["delete_scripts"]))	{$delete_scripts=$_GET["delete_scripts"];}
	elseif (isset($_POST["delete_scripts"]))	{$delete_scripts=$_POST["delete_scripts"];}
if (isset($_GET["delete_user_groups"]))	{$delete_user_groups=$_GET["delete_user_groups"];}
	elseif (isset($_POST["delete_user_groups"]))	{$delete_user_groups=$_POST["delete_user_groups"];}
if (isset($_GET["delete_users"]))	{$delete_users=$_GET["delete_users"];}
	elseif (isset($_POST["delete_users"]))	{$delete_users=$_POST["delete_users"];}
if (isset($_GET["dial_method"]))	{$dial_method=$_GET["dial_method"];}
	elseif (isset($_POST["dial_method"]))	{$dial_method=$_POST["dial_method"];}
if (isset($_GET["dial_prefix"]))	{$dial_prefix=$_GET["dial_prefix"];}
	elseif (isset($_POST["dial_prefix"]))	{$dial_prefix=$_POST["dial_prefix"];}
if (isset($_GET["dial_status_a"]))	{$dial_status_a=$_GET["dial_status_a"];}
	elseif (isset($_POST["dial_status_a"]))	{$dial_status_a=$_POST["dial_status_a"];}
if (isset($_GET["dial_status_b"]))	{$dial_status_b=$_GET["dial_status_b"];}
	elseif (isset($_POST["dial_status_b"]))	{$dial_status_b=$_POST["dial_status_b"];}
if (isset($_GET["dial_status_c"]))	{$dial_status_c=$_GET["dial_status_c"];}
	elseif (isset($_POST["dial_status_c"]))	{$dial_status_c=$_POST["dial_status_c"];}
if (isset($_GET["dial_status_d"]))	{$dial_status_d=$_GET["dial_status_d"];}
	elseif (isset($_POST["dial_status_d"]))	{$dial_status_d=$_POST["dial_status_d"];}
if (isset($_GET["dial_status_e"]))	{$dial_status_e=$_GET["dial_status_e"];}
	elseif (isset($_POST["dial_status_e"]))	{$dial_status_e=$_POST["dial_status_e"];}
if (isset($_GET["dial_timeout"]))	{$dial_timeout=$_GET["dial_timeout"];}
	elseif (isset($_POST["dial_timeout"]))	{$dial_timeout=$_POST["dial_timeout"];}
if (isset($_GET["dialplan_number"]))	{$dialplan_number=$_GET["dialplan_number"];}
	elseif (isset($_POST["dialplan_number"]))	{$dialplan_number=$_POST["dialplan_number"];}
if (isset($_GET["drop_call_seconds"]))	{$drop_call_seconds=$_GET["drop_call_seconds"];}
	elseif (isset($_POST["drop_call_seconds"]))	{$drop_call_seconds=$_POST["drop_call_seconds"];}
if (isset($_GET["drop_exten"]))	{$drop_exten=$_GET["drop_exten"];}
	elseif (isset($_POST["drop_exten"]))	{$drop_exten=$_POST["drop_exten"];}
if (isset($_GET["drop_action"]))	{$drop_action=$_GET["drop_action"];}
	elseif (isset($_POST["drop_action"]))	{$drop_action=$_POST["drop_action"];}
if (isset($_GET["dtmf_send_extension"]))	{$dtmf_send_extension=$_GET["dtmf_send_extension"];}
	elseif (isset($_POST["dtmf_send_extension"]))	{$dtmf_send_extension=$_POST["dtmf_send_extension"];}
if (isset($_GET["enable_fast_refresh"]))	{$enable_fast_refresh=$_GET["enable_fast_refresh"];}
	elseif (isset($_POST["enable_fast_refresh"]))	{$enable_fast_refresh=$_POST["enable_fast_refresh"];}
if (isset($_GET["enable_persistant_mysql"]))	{$enable_persistant_mysql=$_GET["enable_persistant_mysql"];}
	elseif (isset($_POST["enable_persistant_mysql"]))	{$enable_persistant_mysql=$_POST["enable_persistant_mysql"];}
if (isset($_GET["ext_context"]))	{$ext_context=$_GET["ext_context"];}
	elseif (isset($_POST["ext_context"]))	{$ext_context=$_POST["ext_context"];}
if (isset($_GET["extension"]))	{$extension=$_GET["extension"];}
	elseif (isset($_POST["extension"]))	{$extension=$_POST["extension"];}
if (isset($_GET["fast_refresh_rate"]))	{$fast_refresh_rate=$_GET["fast_refresh_rate"];}
	elseif (isset($_POST["fast_refresh_rate"]))	{$fast_refresh_rate=$_POST["fast_refresh_rate"];}
if (isset($_GET["force_logout"]))	{$force_logout=$_GET["force_logout"];}
	elseif (isset($_POST["force_logout"]))	{$force_logout=$_POST["force_logout"];}
if (isset($_GET["fronter_display"]))	{$fronter_display=$_GET["fronter_display"];}
	elseif (isset($_POST["fronter_display"]))	{$fronter_display=$_POST["fronter_display"];}
if (isset($_GET["full_name"]))	{$full_name=$_GET["full_name"];}
	elseif (isset($_POST["full_name"]))	{$full_name=$_POST["full_name"];}
if (isset($_GET["fullname"]))	{$fullname=$_GET["fullname"];}
	elseif (isset($_POST["fullname"]))	{$fullname=$_POST["fullname"];}
if (isset($_GET["get_call_launch"]))	{$get_call_launch=$_GET["get_call_launch"];}
	elseif (isset($_POST["get_call_launch"]))	{$get_call_launch=$_POST["get_call_launch"];}
if (isset($_GET["group_color"]))	{$group_color=$_GET["group_color"];}
	elseif (isset($_POST["group_color"]))	{$group_color=$_POST["group_color"];}
if (isset($_GET["group_id"]))	{$group_id=$_GET["group_id"];}
	elseif (isset($_POST["group_id"]))	{$group_id=$_POST["group_id"];}
if (isset($_GET["group_name"]))	{$group_name=$_GET["group_name"];}
	elseif (isset($_POST["group_name"]))	{$group_name=$_POST["group_name"];}
if (isset($_GET["groups"]))	{$groups=$_GET["groups"];}
	elseif (isset($_POST["groups"]))	{$groups=$_POST["groups"];}
if (isset($_GET["XFERgroups"]))	{$XFERgroups=$_GET["XFERgroups"];}
	elseif (isset($_POST["XFERgroups"]))	{$XFERgroups=$_POST["XFERgroups"];}
if (isset($_GET["HKstatus"]))	{$HKstatus=$_GET["HKstatus"];}
	elseif (isset($_POST["HKstatus"]))	{$HKstatus=$_POST["HKstatus"];}
if (isset($_GET["hopper_level"]))	{$hopper_level=$_GET["hopper_level"];}
	elseif (isset($_POST["hopper_level"]))	{$hopper_level=$_POST["hopper_level"];}
if (isset($_GET["hotkey"]))	{$hotkey=$_GET["hotkey"];}
	elseif (isset($_POST["hotkey"]))	{$hotkey=$_POST["hotkey"];}
if (isset($_GET["hotkeys_active"]))	{$hotkeys_active=$_GET["hotkeys_active"];}
	elseif (isset($_POST["hotkeys_active"]))	{$hotkeys_active=$_POST["hotkeys_active"];}
if (isset($_GET["install_directory"]))	{$install_directory=$_GET["install_directory"];}
	elseif (isset($_POST["install_directory"]))	{$install_directory=$_POST["install_directory"];}
if (isset($_GET["lead_filter_comments"]))	{$lead_filter_comments=$_GET["lead_filter_comments"];}
	elseif (isset($_POST["lead_filter_comments"]))	{$lead_filter_comments=$_POST["lead_filter_comments"];}
if (isset($_GET["lead_filter_id"]))	{$lead_filter_id=$_GET["lead_filter_id"];}
	elseif (isset($_POST["lead_filter_id"]))	{$lead_filter_id=$_POST["lead_filter_id"];}
if (isset($_GET["lead_filter_name"]))	{$lead_filter_name=$_GET["lead_filter_name"];}
	elseif (isset($_POST["lead_filter_name"]))	{$lead_filter_name=$_POST["lead_filter_name"];}
if (isset($_GET["lead_filter_sql"]))	{$lead_filter_sql=$_GET["lead_filter_sql"];}
	elseif (isset($_POST["lead_filter_sql"]))	{$lead_filter_sql=$_POST["lead_filter_sql"];}
if (isset($_GET["lead_order"]))	{$lead_order=$_GET["lead_order"];}
	elseif (isset($_POST["lead_order"]))	{$lead_order=$_POST["lead_order"];}
if (isset($_GET["list_id"]))	{$list_id=$_GET["list_id"];}
	elseif (isset($_POST["list_id"]))	{$list_id=$_POST["list_id"];}
if (isset($_GET["list_name"]))	{$list_name=$_GET["list_name"];}
	elseif (isset($_POST["list_name"]))	{$list_name=$_POST["list_name"];}
if (isset($_GET["load_leads"]))	{$load_leads=$_GET["load_leads"];}
	elseif (isset($_POST["load_leads"]))	{$load_leads=$_POST["load_leads"];}
if (isset($_GET["local_call_time"]))	{$local_call_time=$_GET["local_call_time"];}
	elseif (isset($_POST["local_call_time"]))	{$local_call_time=$_POST["local_call_time"];}
if (isset($_GET["local_gmt"]))	{$local_gmt=$_GET["local_gmt"];}
	elseif (isset($_POST["local_gmt"]))	{$local_gmt=$_POST["local_gmt"];}
if (isset($_GET["local_web_callerID_URL"]))	{$local_web_callerID_URL=$_GET["local_web_callerID_URL"];}
	elseif (isset($_POST["local_web_callerID_URL"]))	{$local_web_callerID_URL=$_POST["local_web_callerID_URL"];}
if (isset($_GET["login"]))	{$login=$_GET["login"];}
	elseif (isset($_POST["login"]))	{$login=$_POST["login"];}
if (isset($_GET["login_campaign"]))	{$login_campaign=$_GET["login_campaign"];}
	elseif (isset($_POST["login_campaign"]))	{$login_campaign=$_POST["login_campaign"];}
if (isset($_GET["login_pass"]))	{$login_pass=$_GET["login_pass"];}
	elseif (isset($_POST["login_pass"]))	{$login_pass=$_POST["login_pass"];}
if (isset($_GET["login_user"]))	{$login_user=$_GET["login_user"];}
	elseif (isset($_POST["login_user"]))	{$login_user=$_POST["login_user"];}
if (isset($_GET["log_recording_access"]))	{$log_recording_access=$_GET["log_recording_access"];}
	elseif (isset($_POST["log_recording_access"]))	{$log_recording_access=$_POST["log_recording_access"];}
if (isset($_GET["max_vicidial_trunks"]))	{$max_vicidial_trunks=$_GET["max_vicidial_trunks"];}
	elseif (isset($_POST["max_vicidial_trunks"]))	{$max_vicidial_trunks=$_POST["max_vicidial_trunks"];}
if (isset($_GET["modify_call_times"]))	{$modify_call_times=$_GET["modify_call_times"];}
	elseif (isset($_POST["modify_call_times"]))	{$modify_call_times=$_POST["modify_call_times"];}
if (isset($_GET["modify_leads"]))	{$modify_leads=$_GET["modify_leads"];}
	elseif (isset($_POST["modify_leads"]))	{$modify_leads=$_POST["modify_leads"];}
if (isset($_GET["export_gdpr_leads"]))	{$export_gdpr_leads=$_GET["export_gdpr_leads"];}
	elseif (isset($_POST["export_gdpr_leads"]))	{$export_gdpr_leads=$_POST["export_gdpr_leads"];}
if (isset($_GET["monitor_prefix"]))	{$monitor_prefix=$_GET["monitor_prefix"];}
	elseif (isset($_POST["monitor_prefix"]))	{$monitor_prefix=$_POST["monitor_prefix"];}
if (isset($_GET["new_extension"]))	{$new_extension=$_GET["new_extension"];}
	elseif (isset($_POST["new_extension"]))	{$new_extension=$_POST["new_extension"];}
if (isset($_GET["new_dialplan_number"]))	{$new_dialplan_number=$_GET["new_dialplan_number"];}
	elseif (isset($_POST["new_dialplan_number"]))	{$new_dialplan_number=$_POST["new_dialplan_number"];}
if (isset($_GET["new_voicemail_id"]))	{$new_voicemail_id=$_GET["new_voicemail_id"];}
	elseif (isset($_POST["new_voicemail_id"]))	{$new_voicemail_id=$_POST["new_voicemail_id"];}
if (isset($_GET["new_outbound_cid"]))	{$new_outbound_cid=$_GET["new_outbound_cid"];}
	elseif (isset($_POST["new_outbound_cid"]))	{$new_outbound_cid=$_POST["new_outbound_cid"];}
if (isset($_GET["new_server_ip"]))	{$new_server_ip=$_GET["new_server_ip"];}
	elseif (isset($_POST["new_server_ip"]))	{$new_server_ip=$_POST["new_server_ip"];}
if (isset($_GET["new_login"]))	{$new_login=$_GET["new_login"];}
	elseif (isset($_POST["new_login"]))	{$new_login=$_POST["new_login"];}
if (isset($_GET["new_pass"]))	{$new_pass=$_GET["new_pass"];}
	elseif (isset($_POST["new_pass"]))	{$new_pass=$_POST["new_pass"];}
if (isset($_GET["new_conf_secret"]))	{$new_conf_secret=$_GET["new_conf_secret"];}
	elseif (isset($_POST["new_conf_secret"]))	{$new_conf_secret=$_POST["new_conf_secret"];}
if (isset($_GET["new_fullname"]))	{$new_fullname=$_GET["new_fullname"];}
	elseif (isset($_POST["new_fullname"]))	{$new_fullname=$_POST["new_fullname"];}
if (isset($_GET["next_agent_call"]))	{$next_agent_call=$_GET["next_agent_call"];}
	elseif (isset($_POST["next_agent_call"]))	{$next_agent_call=$_POST["next_agent_call"];}
if (isset($_GET["number_of_lines"]))	{$number_of_lines=$_GET["number_of_lines"];}
	elseif (isset($_POST["number_of_lines"]))	{$number_of_lines=$_POST["number_of_lines"];}
if (isset($_GET["old_campaign_id"]))	{$old_campaign_id=$_GET["old_campaign_id"];}
	elseif (isset($_POST["old_campaign_id"]))	{$old_campaign_id=$_POST["old_campaign_id"];}
if (isset($_GET["old_conf_exten"]))	{$old_conf_exten=$_GET["old_conf_exten"];}
	elseif (isset($_POST["old_conf_exten"]))	{$old_conf_exten=$_POST["old_conf_exten"];}
if (isset($_GET["old_extension"]))	{$old_extension=$_GET["old_extension"];}
	elseif (isset($_POST["old_extension"]))	{$old_extension=$_POST["old_extension"];}
if (isset($_GET["old_server_id"]))	{$old_server_id=$_GET["old_server_id"];}
	elseif (isset($_POST["old_server_id"]))	{$old_server_id=$_POST["old_server_id"];}
if (isset($_GET["old_server_ip"]))	{$old_server_ip=$_GET["old_server_ip"];}
	elseif (isset($_POST["old_server_ip"]))	{$old_server_ip=$_POST["old_server_ip"];}
if (isset($_GET["OLDuser_group"]))	{$OLDuser_group=$_GET["OLDuser_group"];}
	elseif (isset($_POST["OLDuser_group"]))	{$OLDuser_group=$_POST["OLDuser_group"];}
if (isset($_GET["omit_phone_code"]))	{$omit_phone_code=$_GET["omit_phone_code"];}
	elseif (isset($_POST["omit_phone_code"]))	{$omit_phone_code=$_POST["omit_phone_code"];}
if (isset($_GET["outbound_cid"]))	{$outbound_cid=$_GET["outbound_cid"];}
	elseif (isset($_POST["outbound_cid"]))	{$outbound_cid=$_POST["outbound_cid"];}
if (isset($_GET["park_ext"]))	{$park_ext=$_GET["park_ext"];}
	elseif (isset($_POST["park_ext"]))	{$park_ext=$_POST["park_ext"];}
if (isset($_GET["park_file_name"]))	{$park_file_name=$_GET["park_file_name"];}
	elseif (isset($_POST["park_file_name"]))	{$park_file_name=$_POST["park_file_name"];}
if (isset($_GET["park_on_extension"]))	{$park_on_extension=$_GET["park_on_extension"];}
	elseif (isset($_POST["park_on_extension"]))	{$park_on_extension=$_POST["park_on_extension"];}
if (isset($_GET["pass"]))	{$pass=$_GET["pass"];}
	elseif (isset($_POST["pass"]))	{$pass=$_POST["pass"];}
if (isset($_GET["phone_defaults_container"]))	{$phone_defaults_container=$_GET["phone_defaults_container"];}
	elseif (isset($_POST["phone_defaults_container"]))	{$phone_defaults_container=$_POST["phone_defaults_container"];}
if (isset($_GET["phone_ip"]))	{$phone_ip=$_GET["phone_ip"];}
	elseif (isset($_POST["phone_ip"]))	{$phone_ip=$_POST["phone_ip"];}
if (isset($_GET["phone_login"]))	{$phone_login=$_GET["phone_login"];}
	elseif (isset($_POST["phone_login"]))	{$phone_login=$_POST["phone_login"];}
if (isset($_GET["phone_number"]))	{$phone_number=$_GET["phone_number"];}
	elseif (isset($_POST["phone_number"]))	{$phone_number=$_POST["phone_number"];}
if (isset($_GET["phone_pass"]))	{$phone_pass=$_GET["phone_pass"];}
	elseif (isset($_POST["phone_pass"]))	{$phone_pass=$_POST["phone_pass"];}
if (isset($_GET["phone_type"]))	{$phone_type=$_GET["phone_type"];}
	elseif (isset($_POST["phone_type"]))	{$phone_type=$_POST["phone_type"];}
if (isset($_GET["picture"]))	{$picture=$_GET["picture"];}
	elseif (isset($_POST["picture"]))	{$picture=$_POST["picture"];}
if (isset($_GET["protocol"]))	{$protocol=$_GET["protocol"];}
	elseif (isset($_POST["protocol"]))	{$protocol=$_POST["protocol"];}
if (isset($_GET["QUEUE_ACTION_enabled"]))	{$QUEUE_ACTION_enabled=$_GET["QUEUE_ACTION_enabled"];}
	elseif (isset($_POST["QUEUE_ACTION_enabled"]))	{$QUEUE_ACTION_enabled=$_POST["QUEUE_ACTION_enabled"];}
if (isset($_GET["recording_exten"]))	{$recording_exten=$_GET["recording_exten"];}
	elseif (isset($_POST["recording_exten"]))	{$recording_exten=$_POST["recording_exten"];}
if (isset($_GET["remote_agent_id"]))	{$remote_agent_id=$_GET["remote_agent_id"];}
	elseif (isset($_POST["remote_agent_id"]))	{$remote_agent_id=$_POST["remote_agent_id"];}
if (isset($_GET["reset_hopper"]))	{$reset_hopper=$_GET["reset_hopper"];}
	elseif (isset($_POST["reset_hopper"]))	{$reset_hopper=$_POST["reset_hopper"];}
if (isset($_GET["reset_list"]))	{$reset_list=$_GET["reset_list"];}
	elseif (isset($_POST["reset_list"]))	{$reset_list=$_POST["reset_list"];}
if (isset($_GET["safe_harbor_exten"]))	{$safe_harbor_exten=$_GET["safe_harbor_exten"];}
	elseif (isset($_POST["safe_harbor_exten"]))	{$safe_harbor_exten=$_POST["safe_harbor_exten"];}
if (isset($_GET["scheduled_callbacks"]))	{$scheduled_callbacks=$_GET["scheduled_callbacks"];}
	elseif (isset($_POST["scheduled_callbacks"]))	{$scheduled_callbacks=$_POST["scheduled_callbacks"];}
if (isset($_GET["script_comments"]))	{$script_comments=$_GET["script_comments"];}
	elseif (isset($_POST["script_comments"]))	{$script_comments=$_POST["script_comments"];}
if (isset($_GET["script_id"]))	{$script_id=$_GET["script_id"];}
	elseif (isset($_POST["script_id"]))	{$script_id=$_POST["script_id"];}
if (isset($_GET["script_name"]))	{$script_name=$_GET["script_name"];}
	elseif (isset($_POST["script_name"]))	{$script_name=$_POST["script_name"];}
if (isset($_GET["script_text"]))	{$script_text=$_GET["script_text"];}
	elseif (isset($_POST["script_text"]))	{$script_text=$_POST["script_text"];}
if (isset($_GET["selectable"]))	{$selectable=$_GET["selectable"];}
	elseif (isset($_POST["selectable"]))	{$selectable=$_POST["selectable"];}
if (isset($_GET["server_description"]))	{$server_description=$_GET["server_description"];}
	elseif (isset($_POST["server_description"]))	{$server_description=$_POST["server_description"];}
if (isset($_GET["server_id"]))	{$server_id=$_GET["server_id"];}
	elseif (isset($_POST["server_id"]))	{$server_id=$_POST["server_id"];}
if (isset($_GET["server_ip"]))	{$server_ip=$_GET["server_ip"];}
	elseif (isset($_POST["server_ip"]))	{$server_ip=$_POST["server_ip"];}
if (isset($_GET["source_phone"]))	{$source_phone=$_GET["source_phone"];}
	elseif (isset($_POST["source_phone"]))	{$source_phone=$_POST["source_phone"];}
if (isset($_GET["stage"]))	{$stage=$_GET["stage"];}
	elseif (isset($_POST["stage"]))	{$stage=$_POST["stage"];}
if (isset($_GET["state_call_time_state"]))	{$state_call_time_state=$_GET["state_call_time_state"];}
	elseif (isset($_POST["state_call_time_state"]))	{$state_call_time_state=$_POST["state_call_time_state"];}
if (isset($_GET["state_rule"]))	{$state_rule=$_GET["state_rule"];}
	elseif (isset($_POST["state_rule"]))	{$state_rule=$_POST["state_rule"];}
if (isset($_GET["status"]))	{$status=$_GET["status"];}
	elseif (isset($_POST["status"]))	{$status=$_POST["status"];}
if (isset($_GET["status_id"]))	{$status_id=$_GET["status_id"];}
	elseif (isset($_POST["status_id"]))	{$status_id=$_POST["status_id"];}
if (isset($_GET["status_name"]))	{$status_name=$_GET["status_name"];}
	elseif (isset($_POST["status_name"]))	{$status_name=$_POST["status_name"];}
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["sys_perf_log"]))	{$sys_perf_log=$_GET["sys_perf_log"];}
	elseif (isset($_POST["sys_perf_log"]))	{$sys_perf_log=$_POST["sys_perf_log"];}
if (isset($_GET["telnet_host"]))	{$telnet_host=$_GET["telnet_host"];}
	elseif (isset($_POST["telnet_host"]))	{$telnet_host=$_POST["telnet_host"];}
if (isset($_GET["telnet_port"]))	{$telnet_port=$_GET["telnet_port"];}
	elseif (isset($_POST["telnet_port"]))	{$telnet_port=$_POST["telnet_port"];}
if (isset($_GET["updater_check_enabled"]))	{$updater_check_enabled=$_GET["updater_check_enabled"];}
	elseif (isset($_POST["updater_check_enabled"]))	{$updater_check_enabled=$_POST["updater_check_enabled"];}
if (isset($_GET["use_internal_dnc"]))	{$use_internal_dnc=$_GET["use_internal_dnc"];}
	elseif (isset($_POST["use_internal_dnc"]))	{$use_internal_dnc=$_POST["use_internal_dnc"];}
if (isset($_GET["use_campaign_dnc"]))	{$use_campaign_dnc=$_GET["use_campaign_dnc"];}
	elseif (isset($_POST["use_campaign_dnc"]))	{$use_campaign_dnc=$_POST["use_campaign_dnc"];}
if (isset($_GET["user"]))	{$user=$_GET["user"];}
	elseif (isset($_POST["user"]))	{$user=$_POST["user"];}
if (isset($_GET["user_group"]))	{$user_group=$_GET["user_group"];}
	elseif (isset($_POST["user_group"]))	{$user_group=$_POST["user_group"];}
if (isset($_GET["user_level"]))	{$user_level=$_GET["user_level"];}
	elseif (isset($_POST["user_level"]))	{$user_level=$_POST["user_level"];}
if (isset($_GET["user_start"]))	{$user_start=$_GET["user_start"];}
	elseif (isset($_POST["user_start"]))	{$user_start=$_POST["user_start"];}
if (isset($_GET["user_switching_enabled"]))	{$user_switching_enabled=$_GET["user_switching_enabled"];}
	elseif (isset($_POST["user_switching_enabled"]))	{$user_switching_enabled=$_POST["user_switching_enabled"];}
if (isset($_GET["vd_server_logs"]))	{$vd_server_logs=$_GET["vd_server_logs"];}
	elseif (isset($_POST["vd_server_logs"]))	{$vd_server_logs=$_POST["vd_server_logs"];}
if (isset($_GET["VDstop_rec_after_each_call"]))	{$VDstop_rec_after_each_call=$_GET["VDstop_rec_after_each_call"];}
	elseif (isset($_POST["VDstop_rec_after_each_call"]))	{$VDstop_rec_after_each_call=$_POST["VDstop_rec_after_each_call"];}
if (isset($_GET["VICIDIAL_park_on_extension"]))	{$VICIDIAL_park_on_extension=$_GET["VICIDIAL_park_on_extension"];}
	elseif (isset($_POST["VICIDIAL_park_on_extension"]))	{$VICIDIAL_park_on_extension=$_POST["VICIDIAL_park_on_extension"];}
if (isset($_GET["VICIDIAL_park_on_filename"]))	{$VICIDIAL_park_on_filename=$_GET["VICIDIAL_park_on_filename"];}
	elseif (isset($_POST["VICIDIAL_park_on_filename"]))	{$VICIDIAL_park_on_filename=$_POST["VICIDIAL_park_on_filename"];}
if (isset($_GET["vicidial_recording"]))	{$vicidial_recording=$_GET["vicidial_recording"];}
	elseif (isset($_POST["vicidial_recording"]))	{$vicidial_recording=$_POST["vicidial_recording"];}
if (isset($_GET["vicidial_transfers"]))	{$vicidial_transfers=$_GET["vicidial_transfers"];}
	elseif (isset($_POST["vicidial_transfers"]))	{$vicidial_transfers=$_POST["vicidial_transfers"];}
if (isset($_GET["VICIDIAL_web_URL"]))	{$VICIDIAL_web_URL=$_GET["VICIDIAL_web_URL"];}
	elseif (isset($_POST["VICIDIAL_web_URL"]))	{$VICIDIAL_web_URL=$_POST["VICIDIAL_web_URL"];}
if (isset($_GET["voicemail_button_enabled"]))	{$voicemail_button_enabled=$_GET["voicemail_button_enabled"];}
	elseif (isset($_POST["voicemail_button_enabled"]))	{$voicemail_button_enabled=$_POST["voicemail_button_enabled"];}
if (isset($_GET["voicemail_dump_exten"]))	{$voicemail_dump_exten=$_GET["voicemail_dump_exten"];}
	elseif (isset($_POST["voicemail_dump_exten"]))	{$voicemail_dump_exten=$_POST["voicemail_dump_exten"];}
if (isset($_GET["voicemail_ext"]))	{$voicemail_ext=$_GET["voicemail_ext"];}
	elseif (isset($_POST["voicemail_ext"]))	{$voicemail_ext=$_POST["voicemail_ext"];}
if (isset($_GET["voicemail_exten"]))	{$voicemail_exten=$_GET["voicemail_exten"];}
	elseif (isset($_POST["voicemail_exten"]))	{$voicemail_exten=$_POST["voicemail_exten"];}
if (isset($_GET["voicemail_id"]))	{$voicemail_id=$_GET["voicemail_id"];}
	elseif (isset($_POST["voicemail_id"]))	{$voicemail_id=$_POST["voicemail_id"];}
if (isset($_GET["web_form_address"]))	{$web_form_address=$_GET["web_form_address"];}
	elseif (isset($_POST["web_form_address"]))	{$web_form_address=$_POST["web_form_address"];}
if (isset($_GET["wrapup_message"]))	{$wrapup_message=$_GET["wrapup_message"];}
	elseif (isset($_POST["wrapup_message"]))	{$wrapup_message=$_POST["wrapup_message"];}
if (isset($_GET["wrapup_seconds"]))	{$wrapup_seconds=$_GET["wrapup_seconds"];}
	elseif (isset($_POST["wrapup_seconds"]))	{$wrapup_seconds=$_POST["wrapup_seconds"];}
if (isset($_GET["xferconf_a_dtmf"]))	{$xferconf_a_dtmf=$_GET["xferconf_a_dtmf"];}
	elseif (isset($_POST["xferconf_a_dtmf"]))	{$xferconf_a_dtmf=$_POST["xferconf_a_dtmf"];}
if (isset($_GET["xferconf_a_number"]))	{$xferconf_a_number=$_GET["xferconf_a_number"];}
	elseif (isset($_POST["xferconf_a_number"]))	{$xferconf_a_number=$_POST["xferconf_a_number"];}
if (isset($_GET["xferconf_b_dtmf"]))	{$xferconf_b_dtmf=$_GET["xferconf_b_dtmf"];}
	elseif (isset($_POST["xferconf_b_dtmf"]))	{$xferconf_b_dtmf=$_POST["xferconf_b_dtmf"];}
if (isset($_GET["xferconf_b_number"]))	{$xferconf_b_number=$_GET["xferconf_b_number"];}
	elseif (isset($_POST["xferconf_b_number"]))	{$xferconf_b_number=$_POST["xferconf_b_number"];}
if (isset($_GET["vicidial_balance_active"]))	{$vicidial_balance_active=$_GET["vicidial_balance_active"];}
	elseif (isset($_POST["vicidial_balance_active"]))	{$vicidial_balance_active=$_POST["vicidial_balance_active"];}
if (isset($_GET["balance_trunks_offlimits"]))	{$balance_trunks_offlimits=$_GET["balance_trunks_offlimits"];}
	elseif (isset($_POST["balance_trunks_offlimits"]))	{$balance_trunks_offlimits=$_POST["balance_trunks_offlimits"];}
if (isset($_GET["dedicated_trunks"]))	{$dedicated_trunks=$_GET["dedicated_trunks"];}
	elseif (isset($_POST["dedicated_trunks"]))	{$dedicated_trunks=$_POST["dedicated_trunks"];}
if (isset($_GET["trunk_restriction"]))	{$trunk_restriction=$_GET["trunk_restriction"];}
	elseif (isset($_POST["trunk_restriction"]))	{$trunk_restriction=$_POST["trunk_restriction"];}
if (isset($_GET["campaigns"]))						{$campaigns=$_GET["campaigns"];}
	elseif (isset($_POST["campaigns"]))				{$campaigns=$_POST["campaigns"];}
if (isset($_GET["dial_level_override"]))			{$dial_level_override=$_GET["dial_level_override"];}
	elseif (isset($_POST["dial_level_override"]))	{$dial_level_override=$_POST["dial_level_override"];}
if (isset($_GET["concurrent_transfers"]))			{$concurrent_transfers=$_GET["concurrent_transfers"];}
	elseif (isset($_POST["concurrent_transfers"]))	{$concurrent_transfers=$_POST["concurrent_transfers"];}
if (isset($_GET["auto_alt_dial"]))			{$auto_alt_dial=$_GET["auto_alt_dial"];}
	elseif (isset($_POST["auto_alt_dial"]))	{$auto_alt_dial=$_POST["auto_alt_dial"];}
if (isset($_GET["modify_users"]))				{$modify_users=$_GET["modify_users"];}
	elseif (isset($_POST["modify_users"]))		{$modify_users=$_POST["modify_users"];}
if (isset($_GET["modify_campaigns"]))			{$modify_campaigns=$_GET["modify_campaigns"];}
	elseif (isset($_POST["modify_campaigns"]))	{$modify_campaigns=$_POST["modify_campaigns"];}
if (isset($_GET["modify_lists"]))				{$modify_lists=$_GET["modify_lists"];}
	elseif (isset($_POST["modify_lists"]))		{$modify_lists=$_POST["modify_lists"];}
if (isset($_GET["modify_scripts"]))				{$modify_scripts=$_GET["modify_scripts"];}
	elseif (isset($_POST["modify_scripts"]))	{$modify_scripts=$_POST["modify_scripts"];}
if (isset($_GET["modify_filters"]))				{$modify_filters=$_GET["modify_filters"];}
	elseif (isset($_POST["modify_filters"]))	{$modify_filters=$_POST["modify_filters"];}
if (isset($_GET["modify_ingroups"]))			{$modify_ingroups=$_GET["modify_ingroups"];}
	elseif (isset($_POST["modify_ingroups"]))	{$modify_ingroups=$_POST["modify_ingroups"];}
if (isset($_GET["modify_usergroups"]))			{$modify_usergroups=$_GET["modify_usergroups"];}
	elseif (isset($_POST["modify_usergroups"]))	{$modify_usergroups=$_POST["modify_usergroups"];}
if (isset($_GET["modify_remoteagents"]))			{$modify_remoteagents=$_GET["modify_remoteagents"];}
	elseif (isset($_POST["modify_remoteagents"]))	{$modify_remoteagents=$_POST["modify_remoteagents"];}
if (isset($_GET["modify_servers"]))				{$modify_servers=$_GET["modify_servers"];}
	elseif (isset($_POST["modify_servers"]))	{$modify_servers=$_POST["modify_servers"];}
if (isset($_GET["view_reports"]))				{$view_reports=$_GET["view_reports"];}
	elseif (isset($_POST["view_reports"]))		{$view_reports=$_POST["view_reports"];}
if (isset($_GET["agent_pause_codes_active"]))			{$agent_pause_codes_active=$_GET["agent_pause_codes_active"];}
	elseif (isset($_POST["agent_pause_codes_active"]))	{$agent_pause_codes_active=$_POST["agent_pause_codes_active"];}
if (isset($_GET["pause_code"]))					{$pause_code=$_GET["pause_code"];}
	elseif (isset($_POST["pause_code"]))		{$pause_code=$_POST["pause_code"];}
if (isset($_GET["pause_code_name"]))			{$pause_code_name=$_GET["pause_code_name"];}
	elseif (isset($_POST["pause_code_name"]))	{$pause_code_name=$_POST["pause_code_name"];}
if (isset($_GET["billable"]))					{$billable=$_GET["billable"];}
	elseif (isset($_POST["billable"]))			{$billable=$_POST["billable"];}
if (isset($_GET["campaign_description"]))			{$campaign_description=$_GET["campaign_description"];}
	elseif (isset($_POST["campaign_description"]))	{$campaign_description=$_POST["campaign_description"];}
if (isset($_GET["campaign_stats_refresh"]))			{$campaign_stats_refresh=$_GET["campaign_stats_refresh"];}
	elseif (isset($_POST["campaign_stats_refresh"])){$campaign_stats_refresh=$_POST["campaign_stats_refresh"];}
if (isset($_GET["list_description"]))			{$list_description=$_GET["list_description"];}
	elseif (isset($_POST["list_description"]))	{$list_description=$_POST["list_description"];}
if (isset($_GET["vicidial_recording_override"]))		{$vicidial_recording_override=$_GET["vicidial_recording_override"];}	
	elseif (isset($_POST["vicidial_recording_override"]))	{$vicidial_recording_override=$_POST["vicidial_recording_override"];}
if (isset($_GET["use_non_latin"]))				{$use_non_latin=$_GET["use_non_latin"];}
	elseif (isset($_POST["use_non_latin"]))		{$use_non_latin=$_POST["use_non_latin"];}
if (isset($_GET["webroot_writable"]))			{$webroot_writable=$_GET["webroot_writable"];}
	elseif (isset($_POST["webroot_writable"]))	{$webroot_writable=$_POST["webroot_writable"];}
if (isset($_GET["enable_queuemetrics_logging"]))	{$enable_queuemetrics_logging=$_GET["enable_queuemetrics_logging"];}
	elseif (isset($_POST["enable_queuemetrics_logging"]))	{$enable_queuemetrics_logging=$_POST["enable_queuemetrics_logging"];}
if (isset($_GET["queuemetrics_server_ip"]))				{$queuemetrics_server_ip=$_GET["queuemetrics_server_ip"];}
	elseif (isset($_POST["queuemetrics_server_ip"]))	{$queuemetrics_server_ip=$_POST["queuemetrics_server_ip"];}
if (isset($_GET["queuemetrics_dbname"]))			{$queuemetrics_dbname=$_GET["queuemetrics_dbname"];}
	elseif (isset($_POST["queuemetrics_dbname"]))	{$queuemetrics_dbname=$_POST["queuemetrics_dbname"];}
if (isset($_GET["queuemetrics_login"]))				{$queuemetrics_login=$_GET["queuemetrics_login"];}
	elseif (isset($_POST["queuemetrics_login"]))	{$queuemetrics_login=$_POST["queuemetrics_login"];}
if (isset($_GET["queuemetrics_pass"]))			{$queuemetrics_pass=$_GET["queuemetrics_pass"];}
	elseif (isset($_POST["queuemetrics_pass"]))	{$queuemetrics_pass=$_POST["queuemetrics_pass"];}
if (isset($_GET["queuemetrics_url"]))			{$queuemetrics_url=$_GET["queuemetrics_url"];}
	elseif (isset($_POST["queuemetrics_url"]))	{$queuemetrics_url=$_POST["queuemetrics_url"];}
if (isset($_GET["queuemetrics_log_id"]))			{$queuemetrics_log_id=$_GET["queuemetrics_log_id"];}
	elseif (isset($_POST["queuemetrics_log_id"]))	{$queuemetrics_log_id=$_POST["queuemetrics_log_id"];}
if (isset($_GET["dial_status"]))				{$dial_status=$_GET["dial_status"];}
	elseif (isset($_POST["dial_status"]))		{$dial_status=$_POST["dial_status"];}
if (isset($_GET["queuemetrics_eq_prepend"]))			{$queuemetrics_eq_prepend=$_GET["queuemetrics_eq_prepend"];}
	elseif (isset($_POST["queuemetrics_eq_prepend"]))	{$queuemetrics_eq_prepend=$_POST["queuemetrics_eq_prepend"];}
if (isset($_GET["vicidial_agent_disable"]))				{$vicidial_agent_disable=$_GET["vicidial_agent_disable"];}
	elseif (isset($_POST["vicidial_agent_disable"]))	{$vicidial_agent_disable=$_POST["vicidial_agent_disable"];}
if (isset($_GET["disable_alter_custdata"]))				{$disable_alter_custdata=$_GET["disable_alter_custdata"];}
	elseif (isset($_POST["disable_alter_custdata"]))	{$disable_alter_custdata=$_POST["disable_alter_custdata"];}
if (isset($_GET["alter_custdata_override"]))			{$alter_custdata_override=$_GET["alter_custdata_override"];}
	elseif (isset($_POST["alter_custdata_override"]))	{$alter_custdata_override=$_POST["alter_custdata_override"];}
if (isset($_GET["no_hopper_leads_logins"]))				{$no_hopper_leads_logins=$_GET["no_hopper_leads_logins"];}
	elseif (isset($_POST["no_hopper_leads_logins"]))	{$no_hopper_leads_logins=$_POST["no_hopper_leads_logins"];}
if (isset($_GET["enable_sipsak_messages"]))				{$enable_sipsak_messages=$_GET["enable_sipsak_messages"];}
	elseif (isset($_POST["enable_sipsak_messages"]))	{$enable_sipsak_messages=$_POST["enable_sipsak_messages"];}
if (isset($_GET["allow_sipsak_messages"]))				{$allow_sipsak_messages=$_GET["allow_sipsak_messages"];}
	elseif (isset($_POST["allow_sipsak_messages"]))		{$allow_sipsak_messages=$_POST["allow_sipsak_messages"];}
if (isset($_GET["admin_home_url"]))				{$admin_home_url=$_GET["admin_home_url"];}
	elseif (isset($_POST["admin_home_url"]))	{$admin_home_url=$_POST["admin_home_url"];}
if (isset($_GET["list_order_mix"]))				{$list_order_mix=$_GET["list_order_mix"];}
	elseif (isset($_POST["list_order_mix"]))	{$list_order_mix=$_POST["list_order_mix"];}
if (isset($_GET["vcl_id"]))						{$vcl_id=$_GET["vcl_id"];}
	elseif (isset($_POST["vcl_id"]))			{$vcl_id=$_POST["vcl_id"];}
if (isset($_GET["vcl_name"]))					{$vcl_name=$_GET["vcl_name"];}
	elseif (isset($_POST["vcl_name"]))			{$vcl_name=$_POST["vcl_name"];}
if (isset($_GET["list_mix_container"]))				{$list_mix_container=$_GET["list_mix_container"];}
	elseif (isset($_POST["list_mix_container"]))	{$list_mix_container=$_POST["list_mix_container"];}
if (isset($_GET["mix_method"]))					{$mix_method=$_GET["mix_method"];}
	elseif (isset($_POST["mix_method"]))		{$mix_method=$_POST["mix_method"];}
if (isset($_GET["human_answered"]))				{$human_answered=$_GET["human_answered"];}
	elseif (isset($_POST["human_answered"]))	{$human_answered=$_POST["human_answered"];}
if (isset($_GET["category"]))					{$category=$_GET["category"];}
	elseif (isset($_POST["category"]))			{$category=$_POST["category"];}
if (isset($_GET["vsc_id"]))						{$vsc_id=$_GET["vsc_id"];}
	elseif (isset($_POST["vsc_id"]))			{$vsc_id=$_POST["vsc_id"];}
if (isset($_GET["vsc_name"]))					{$vsc_name=$_GET["vsc_name"];}
	elseif (isset($_POST["vsc_name"]))			{$vsc_name=$_POST["vsc_name"];}
if (isset($_GET["vsc_description"]))			{$vsc_description=$_GET["vsc_description"];}
	elseif (isset($_POST["vsc_description"]))	{$vsc_description=$_POST["vsc_description"];}
if (isset($_GET["tovdad_display"]))				{$tovdad_display=$_GET["tovdad_display"];}
	elseif (isset($_POST["tovdad_display"]))	{$tovdad_display=$_POST["tovdad_display"];}
if (isset($_GET["mix_container_item"]))				{$mix_container_item=$_GET["mix_container_item"];}
	elseif (isset($_POST["mix_container_item"]))	{$mix_container_item=$_POST["mix_container_item"];}
if (isset($_GET["enable_agc_xfer_log"]))			{$enable_agc_xfer_log=$_GET["enable_agc_xfer_log"];}
	elseif (isset($_POST["enable_agc_xfer_log"]))	{$enable_agc_xfer_log=$_POST["enable_agc_xfer_log"];}
if (isset($_GET["after_hours_action"]))				{$after_hours_action=$_GET["after_hours_action"];}
	elseif (isset($_POST["after_hours_action"]))	{$after_hours_action=$_POST["after_hours_action"];}
if (isset($_GET["after_hours_message_filename"]))			{$after_hours_message_filename=$_GET["after_hours_message_filename"];}
	elseif (isset($_POST["after_hours_message_filename"]))	{$after_hours_message_filename=$_POST["after_hours_message_filename"];}
if (isset($_GET["after_hours_exten"]))				{$after_hours_exten=$_GET["after_hours_exten"];}
	elseif (isset($_POST["after_hours_exten"]))		{$after_hours_exten=$_POST["after_hours_exten"];}
if (isset($_GET["after_hours_voicemail"]))			{$after_hours_voicemail=$_GET["after_hours_voicemail"];}
	elseif (isset($_POST["after_hours_voicemail"]))	{$after_hours_voicemail=$_POST["after_hours_voicemail"];}
if (isset($_GET["welcome_message_filename"]))			{$welcome_message_filename=$_GET["welcome_message_filename"];}
	elseif (isset($_POST["welcome_message_filename"]))	{$welcome_message_filename=$_POST["welcome_message_filename"];}
if (isset($_GET["moh_context"]))					{$moh_context=$_GET["moh_context"];}
	elseif (isset($_POST["moh_context"]))			{$moh_context=$_POST["moh_context"];}
if (isset($_GET["onhold_prompt_filename"]))				{$onhold_prompt_filename=$_GET["onhold_prompt_filename"];}
	elseif (isset($_POST["onhold_prompt_filename"]))	{$onhold_prompt_filename=$_POST["onhold_prompt_filename"];}
if (isset($_GET["prompt_interval"]))				{$prompt_interval=$_GET["prompt_interval"];}
	elseif (isset($_POST["prompt_interval"]))		{$prompt_interval=$_POST["prompt_interval"];}
if (isset($_GET["agent_alert_exten"]))				{$agent_alert_exten=$_GET["agent_alert_exten"];}
	elseif (isset($_POST["agent_alert_exten"]))		{$agent_alert_exten=$_POST["agent_alert_exten"];}
if (isset($_GET["agent_alert_delay"]))				{$agent_alert_delay=$_GET["agent_alert_delay"];}
	elseif (isset($_POST["agent_alert_delay"]))		{$agent_alert_delay=$_POST["agent_alert_delay"];}
if (isset($_GET["group_rank"]))					{$group_rank=$_GET["group_rank"];}
	elseif (isset($_POST["group_rank"]))		{$group_rank=$_POST["group_rank"];}
if (isset($_GET["campaign_allow_inbound"]))				{$campaign_allow_inbound=$_GET["campaign_allow_inbound"];}
	elseif (isset($_POST["campaign_allow_inbound"]))	{$campaign_allow_inbound=$_POST["campaign_allow_inbound"];}
if (isset($_GET["old_campaign_allow_inbound"]))				{$old_campaign_allow_inbound=$_GET["old_campaign_allow_inbound"];}
	elseif (isset($_POST["old_campaign_allow_inbound"]))	{$old_campaign_allow_inbound=$_POST["old_campaign_allow_inbound"];}
if (isset($_GET["manual_dial_list_id"]))				{$manual_dial_list_id=$_GET["manual_dial_list_id"];}
	elseif (isset($_POST["manual_dial_list_id"]))		{$manual_dial_list_id=$_POST["manual_dial_list_id"];}
if (isset($_GET["campaign_rank"]))				{$campaign_rank=$_GET["campaign_rank"];}
	elseif (isset($_POST["campaign_rank"]))		{$campaign_rank=$_POST["campaign_rank"];}
if (isset($_GET["source_campaign_id"]))				{$source_campaign_id=$_GET["source_campaign_id"];}
	elseif (isset($_POST["source_campaign_id"]))	{$source_campaign_id=$_POST["source_campaign_id"];}
if (isset($_GET["source_user_id"]))				{$source_user_id=$_GET["source_user_id"];}
	elseif (isset($_POST["source_user_id"]))	{$source_user_id=$_POST["source_user_id"];}
if (isset($_GET["source_group_id"]))			{$source_group_id=$_GET["source_group_id"];}
	elseif (isset($_POST["source_group_id"]))	{$source_group_id=$_POST["source_group_id"];}
if (isset($_GET["default_xfer_group"]))				{$default_xfer_group=$_GET["default_xfer_group"];}
	elseif (isset($_POST["default_xfer_group"]))	{$default_xfer_group=$_POST["default_xfer_group"];}
if (isset($_GET["qc_enabled"]))					{$qc_enabled=$_GET["qc_enabled"];}
	elseif (isset($_POST["qc_enabled"]))		{$qc_enabled=$_POST["qc_enabled"];}
if (isset($_GET["qc_user_level"]))				{$qc_user_level=$_GET["qc_user_level"];}
	elseif (isset($_POST["qc_user_level"]))		{$qc_user_level=$_POST["qc_user_level"];}
if (isset($_GET["qc_pass"]))					{$qc_pass=$_GET["qc_pass"];}
	elseif (isset($_POST["qc_pass"]))			{$qc_pass=$_POST["qc_pass"];}
if (isset($_GET["qc_finish"]))					{$qc_finish=$_GET["qc_finish"];}
	elseif (isset($_POST["qc_finish"]))			{$qc_finish=$_POST["qc_finish"];}
if (isset($_GET["qc_commit"]))					{$qc_commit=$_GET["qc_commit"];}
	elseif (isset($_POST["qc_commit"]))			{$qc_commit=$_POST["qc_commit"];}
if (isset($_GET["qc_campaigns"]))				{$qc_campaigns=$_GET["qc_campaigns"];}
	elseif (isset($_POST["qc_campaigns"]))		{$qc_campaigns=$_POST["qc_campaigns"];}
if (isset($_GET["qc_groups"]))					{$qc_groups=$_GET["qc_groups"];}
	elseif (isset($_POST["qc_groups"]))			{$qc_groups=$_POST["qc_groups"];}
if (isset($_GET["qc_display_group_type"]))					{$qc_display_group_type=$_GET["qc_display_group_type"];}
	elseif (isset($_POST["qc_display_group_type"]))			{$qc_display_group_type=$_POST["qc_display_group_type"];}
if (isset($_GET["qc_claim_limit"]))					{$qc_claim_limit=$_GET["qc_claim_limit"];}
	elseif (isset($_POST["qc_claim_limit"]))			{$qc_claim_limit=$_POST["qc_claim_limit"];}
if (isset($_GET["qc_expire_days"]))					{$qc_expire_days=$_GET["qc_expire_days"];}
	elseif (isset($_POST["qc_expire_days"]))			{$qc_expire_days=$_POST["qc_expire_days"];}
if (isset($_GET["queue_priority"]))				{$queue_priority=$_GET["queue_priority"];}
	elseif (isset($_POST["queue_priority"]))	{$queue_priority=$_POST["queue_priority"];}
if (isset($_GET["drop_inbound_group"]))				{$drop_inbound_group=$_GET["drop_inbound_group"];}
	elseif (isset($_POST["drop_inbound_group"]))	{$drop_inbound_group=$_POST["drop_inbound_group"];}
if (isset($_GET["qc_statuses"]))			{$qc_statuses=$_GET["qc_statuses"];}
	elseif (isset($_POST["qc_statuses"]))	{$qc_statuses=$_POST["qc_statuses"];}
if (isset($_GET["qc_lists"]))				{$qc_lists=$_GET["qc_lists"];}
	elseif (isset($_POST["qc_lists"]))		{$qc_lists=$_POST["qc_lists"];}
if (isset($_GET["qc_statuses"]))			{$qc_statuses=$_GET["qc_statuses"];}
	elseif (isset($_POST["qc_statuses"]))	{$qc_statuses=$_POST["qc_statuses"];}
if (isset($_GET["qc_statuses_id"]))				{$qc_statuses_id=$_GET["qc_statuses_id"];}
	elseif (isset($_POST["qc_statuses_id"]))		{$qc_statuses_id=$_POST["qc_statuses_id"];}
if (isset($_GET["qc_get_record_launch"]))			{$qc_get_record_launch=$_GET["qc_get_record_launch"];}
	elseif (isset($_POST["qc_get_record_launch"]))	{$qc_get_record_launch=$_POST["qc_get_record_launch"];}
if (isset($_GET["qc_show_recording"]))				{$qc_show_recording=$_GET["qc_show_recording"];}
	elseif (isset($_POST["qc_show_recording"]))		{$qc_show_recording=$_POST["qc_show_recording"];}
if (isset($_GET["qc_shift_id"]))				{$qc_shift_id=$_GET["qc_shift_id"];}
	elseif (isset($_POST["qc_shift_id"]))		{$qc_shift_id=$_POST["qc_shift_id"];}
if (isset($_GET["qc_web_form_address"]))				{$qc_web_form_address=$_GET["qc_web_form_address"];}
	elseif (isset($_POST["qc_web_form_address"]))	{$qc_web_form_address=$_POST["qc_web_form_address"];}
if (isset($_GET["qc_scorecard_id"]))						{$qc_scorecard_id=$_GET["qc_scorecard_id"];}
	elseif (isset($_POST["qc_scorecard_id"]))				{$qc_scorecard_id=$_POST["qc_scorecard_id"];}
if (isset($_GET["qc_script"]))						{$qc_script=$_GET["qc_script"];}
	elseif (isset($_POST["qc_script"]))				{$qc_script=$_POST["qc_script"];}
if (isset($_GET["ingroup_recording_override"]))		{$ingroup_recording_override=$_GET["ingroup_recording_override"];}	
	elseif (isset($_POST["ingroup_recording_override"]))	{$ingroup_recording_override=$_POST["ingroup_recording_override"];}
if (isset($_GET["code"]))				{$code=$_GET["code"];}	
	elseif (isset($_POST["code"]))		{$code=$_POST["code"];}
if (isset($_GET["code_name"]))			{$code_name=$_GET["code_name"];}	
	elseif (isset($_POST["code_name"]))	{$code_name=$_POST["code_name"];}
if (isset($_GET["afterhours_xfer_group"]))			{$afterhours_xfer_group=$_GET["afterhours_xfer_group"];}	
	elseif (isset($_POST["afterhours_xfer_group"]))	{$afterhours_xfer_group=$_POST["afterhours_xfer_group"];}
if (isset($_GET["alias_id"]))				{$alias_id=$_GET["alias_id"];}	
	elseif (isset($_POST["alias_id"]))		{$alias_id=$_POST["alias_id"];}
if (isset($_GET["alias_name"]))				{$alias_name=$_GET["alias_name"];}	
	elseif (isset($_POST["alias_name"]))		{$alias_name=$_POST["alias_name"];}
if (isset($_GET["logins_list"]))				{$logins_list=$_GET["logins_list"];}	
	elseif (isset($_POST["logins_list"]))		{$logins_list=$_POST["logins_list"];}
if (isset($_GET["shift_id"]))				{$shift_id=$_GET["shift_id"];}	
	elseif (isset($_POST["shift_id"]))		{$shift_id=$_POST["shift_id"];}
if (isset($_GET["shift_name"]))				{$shift_name=$_GET["shift_name"];}	
	elseif (isset($_POST["shift_name"]))		{$shift_name=$_POST["shift_name"];}
if (isset($_GET["shift_start_time"]))			{$shift_start_time=$_GET["shift_start_time"];}	
	elseif (isset($_POST["shift_start_time"]))	{$shift_start_time=$_POST["shift_start_time"];}
if (isset($_GET["shift_length"]))				{$shift_length=$_GET["shift_length"];}	
	elseif (isset($_POST["shift_length"]))		{$shift_length=$_POST["shift_length"];}
if (isset($_GET["shift_weekdays"]))				{$shift_weekdays=$_GET["shift_weekdays"];}	
	elseif (isset($_POST["shift_weekdays"]))	{$shift_weekdays=$_POST["shift_weekdays"];}
if (isset($_GET["group_shifts"]))			{$group_shifts=$_GET["group_shifts"];}	
	elseif (isset($_POST["group_shifts"]))	{$group_shifts=$_POST["group_shifts"];}
if (isset($_GET["timeclock_end_of_day"]))			{$timeclock_end_of_day=$_GET["timeclock_end_of_day"];}	
	elseif (isset($_POST["timeclock_end_of_day"]))	{$timeclock_end_of_day=$_POST["timeclock_end_of_day"];}
if (isset($_GET["survey_first_audio_file"]))			{$survey_first_audio_file=$_GET["survey_first_audio_file"];}	
	elseif (isset($_POST["survey_first_audio_file"]))	{$survey_first_audio_file=$_POST["survey_first_audio_file"];}
if (isset($_GET["survey_dtmf_digits"]))					{$survey_dtmf_digits=$_GET["survey_dtmf_digits"];}	
	elseif (isset($_POST["survey_dtmf_digits"]))		{$survey_dtmf_digits=$_POST["survey_dtmf_digits"];}
if (isset($_GET["survey_ni_digit"]))					{$survey_ni_digit=$_GET["survey_ni_digit"];}	
	elseif (isset($_POST["survey_ni_digit"]))			{$survey_ni_digit=$_POST["survey_ni_digit"];}
if (isset($_GET["survey_opt_in_audio_file"]))			{$survey_opt_in_audio_file=$_GET["survey_opt_in_audio_file"];}	
	elseif (isset($_POST["survey_opt_in_audio_file"]))	{$survey_opt_in_audio_file=$_POST["survey_opt_in_audio_file"];}
if (isset($_GET["survey_ni_audio_file"]))				{$survey_ni_audio_file=$_GET["survey_ni_audio_file"];}	
	elseif (isset($_POST["survey_ni_audio_file"]))		{$survey_ni_audio_file=$_POST["survey_ni_audio_file"];}
if (isset($_GET["survey_method"]))						{$survey_method=$_GET["survey_method"];}	
	elseif (isset($_POST["survey_method"]))				{$survey_method=$_POST["survey_method"];}
if (isset($_GET["survey_no_response_action"]))			{$survey_no_response_action=$_GET["survey_no_response_action"];}	
	elseif (isset($_POST["survey_no_response_action"]))	{$survey_no_response_action=$_POST["survey_no_response_action"];}
if (isset($_GET["survey_ni_status"]))					{$survey_ni_status=$_GET["survey_ni_status"];}	
	elseif (isset($_POST["survey_ni_status"]))			{$survey_ni_status=$_POST["survey_ni_status"];}
if (isset($_GET["survey_response_digit_map"]))			{$survey_response_digit_map=$_GET["survey_response_digit_map"];}	
	elseif (isset($_POST["survey_response_digit_map"]))	{$survey_response_digit_map=$_POST["survey_response_digit_map"];}
if (isset($_GET["survey_xfer_exten"]))					{$survey_xfer_exten=$_GET["survey_xfer_exten"];}	
	elseif (isset($_POST["survey_xfer_exten"]))			{$survey_xfer_exten=$_POST["survey_xfer_exten"];}
if (isset($_GET["survey_camp_record_dir"]))				{$survey_camp_record_dir=$_GET["survey_camp_record_dir"];}	
	elseif (isset($_POST["survey_camp_record_dir"]))	{$survey_camp_record_dir=$_POST["survey_camp_record_dir"];}
if (isset($_GET["add_timeclock_log"]))				{$add_timeclock_log=$_GET["add_timeclock_log"];}	
	elseif (isset($_POST["add_timeclock_log"]))		{$add_timeclock_log=$_POST["add_timeclock_log"];}
if (isset($_GET["modify_timeclock_log"]))			{$modify_timeclock_log=$_GET["modify_timeclock_log"];}	
	elseif (isset($_POST["modify_timeclock_log"]))	{$modify_timeclock_log=$_POST["modify_timeclock_log"];}
if (isset($_GET["delete_timeclock_log"]))			{$delete_timeclock_log=$_GET["delete_timeclock_log"];}	
	elseif (isset($_POST["delete_timeclock_log"]))	{$delete_timeclock_log=$_POST["delete_timeclock_log"];}
if (isset($_GET["phone_numbers"]))					{$phone_numbers=$_GET["phone_numbers"];}	
	elseif (isset($_POST["phone_numbers"]))			{$phone_numbers=$_POST["phone_numbers"];}
if (isset($_GET["vdc_header_date_format"]))					{$vdc_header_date_format=$_GET["vdc_header_date_format"];}	
	elseif (isset($_POST["vdc_header_date_format"]))		{$vdc_header_date_format=$_POST["vdc_header_date_format"];}
if (isset($_GET["vdc_customer_date_format"]))				{$vdc_customer_date_format=$_GET["vdc_customer_date_format"];}	
	elseif (isset($_POST["vdc_customer_date_format"]))		{$vdc_customer_date_format=$_POST["vdc_customer_date_format"];}
if (isset($_GET["vdc_header_phone_format"]))				{$vdc_header_phone_format=$_GET["vdc_header_phone_format"];}	
	elseif (isset($_POST["vdc_header_phone_format"]))		{$vdc_header_phone_format=$_POST["vdc_header_phone_format"];}
if (isset($_GET["disable_alter_custphone"]))			{$disable_alter_custphone=$_GET["disable_alter_custphone"];}	
	elseif (isset($_POST["disable_alter_custphone"]))	{$disable_alter_custphone=$_POST["disable_alter_custphone"];}
if (isset($_GET["alter_custphone_override"]))			{$alter_custphone_override=$_GET["alter_custphone_override"];}	
	elseif (isset($_POST["alter_custphone_override"]))	{$alter_custphone_override=$_POST["alter_custphone_override"];}
if (isset($_GET["vdc_agent_api_access"]))				{$vdc_agent_api_access=$_GET["vdc_agent_api_access"];}	
	elseif (isset($_POST["vdc_agent_api_access"]))		{$vdc_agent_api_access=$_POST["vdc_agent_api_access"];}
if (isset($_GET["vdc_agent_api_active"]))				{$vdc_agent_api_active=$_GET["vdc_agent_api_active"];}	
	elseif (isset($_POST["vdc_agent_api_active"]))		{$vdc_agent_api_active=$_POST["vdc_agent_api_active"];}
if (isset($_GET["display_queue_count"]))				{$display_queue_count=$_GET["display_queue_count"];}	
	elseif (isset($_POST["display_queue_count"]))		{$display_queue_count=$_POST["display_queue_count"];}
if (isset($_GET["sale_category"]))				{$sale_category=$_GET["sale_category"];}	
	elseif (isset($_POST["sale_category"]))		{$sale_category=$_POST["sale_category"];}
if (isset($_GET["dead_lead_category"]))				{$dead_lead_category=$_GET["dead_lead_category"];}	
	elseif (isset($_POST["dead_lead_category"]))	{$dead_lead_category=$_POST["dead_lead_category"];}
if (isset($_GET["manual_dial_filter"]))				{$manual_dial_filter=$_GET["manual_dial_filter"];}	
	elseif (isset($_POST["manual_dial_filter"]))	{$manual_dial_filter=$_POST["manual_dial_filter"];}
if (isset($_GET["agent_clipboard_copy"]))			{$agent_clipboard_copy=$_GET["agent_clipboard_copy"];}	
	elseif (isset($_POST["agent_clipboard_copy"]))	{$agent_clipboard_copy=$_POST["agent_clipboard_copy"];}
if (isset($_GET["agent_extended_alt_dial"]))			{$agent_extended_alt_dial=$_GET["agent_extended_alt_dial"];}	
	elseif (isset($_POST["agent_extended_alt_dial"]))	{$agent_extended_alt_dial=$_POST["agent_extended_alt_dial"];}
if (isset($_GET["play_place_in_line"]))				{$play_place_in_line=$_GET["play_place_in_line"];}	
	elseif (isset($_POST["play_place_in_line"]))	{$play_place_in_line=$_POST["play_place_in_line"];}
if (isset($_GET["play_estimate_hold_time"]))			{$play_estimate_hold_time=$_GET["play_estimate_hold_time"];}	
	elseif (isset($_POST["play_estimate_hold_time"]))	{$play_estimate_hold_time=$_POST["play_estimate_hold_time"];}
if (isset($_GET["hold_time_option"]))				{$hold_time_option=$_GET["hold_time_option"];}	
	elseif (isset($_POST["hold_time_option"]))		{$hold_time_option=$_POST["hold_time_option"];}
if (isset($_GET["hold_time_option_seconds"]))			{$hold_time_option_seconds=$_GET["hold_time_option_seconds"];}	
	elseif (isset($_POST["hold_time_option_seconds"]))	{$hold_time_option_seconds=$_POST["hold_time_option_seconds"];}
if (isset($_GET["hold_time_option_exten"]))				{$hold_time_option_exten=$_GET["hold_time_option_exten"];}	
	elseif (isset($_POST["hold_time_option_exten"]))	{$hold_time_option_exten=$_POST["hold_time_option_exten"];}
if (isset($_GET["hold_time_option_voicemail"]))				{$hold_time_option_voicemail=$_GET["hold_time_option_voicemail"];}	
	elseif (isset($_POST["hold_time_option_voicemail"]))	{$hold_time_option_voicemail=$_POST["hold_time_option_voicemail"];}
if (isset($_GET["hold_time_option_xfer_group"]))			{$hold_time_option_xfer_group=$_GET["hold_time_option_xfer_group"];}	
	elseif (isset($_POST["hold_time_option_xfer_group"]))	{$hold_time_option_xfer_group=$_POST["hold_time_option_xfer_group"];}
if (isset($_GET["hold_time_option_callback_filename"]))				{$hold_time_option_callback_filename=$_GET["hold_time_option_callback_filename"];}	
	elseif (isset($_POST["hold_time_option_callback_filename"]))	{$hold_time_option_callback_filename=$_POST["hold_time_option_callback_filename"];}
if (isset($_GET["hold_time_option_callback_list_id"]))				{$hold_time_option_callback_list_id=$_GET["hold_time_option_callback_list_id"];}	
	elseif (isset($_POST["hold_time_option_callback_list_id"]))		{$hold_time_option_callback_list_id=$_POST["hold_time_option_callback_list_id"];}
if (isset($_GET["hold_recall_xfer_group"]))				{$hold_recall_xfer_group=$_GET["hold_recall_xfer_group"];}	
	elseif (isset($_POST["hold_recall_xfer_group"]))	{$hold_recall_xfer_group=$_POST["hold_recall_xfer_group"];}
if (isset($_GET["no_delay_call_route"]))			{$no_delay_call_route=$_GET["no_delay_call_route"];}	
	elseif (isset($_POST["no_delay_call_route"]))	{$no_delay_call_route=$_POST["no_delay_call_route"];}
if (isset($_GET["play_welcome_message"]))			{$play_welcome_message=$_GET["play_welcome_message"];}	
	elseif (isset($_POST["play_welcome_message"]))	{$play_welcome_message=$_POST["play_welcome_message"];}
if (isset($_GET["did_id"]))					{$did_id=$_GET["did_id"];}	
	elseif (isset($_POST["did_id"]))		{$did_id=$_POST["did_id"];}
if (isset($_GET["source_did"]))				{$source_did=$_GET["source_did"];}	
	elseif (isset($_POST["source_did"]))	{$source_did=$_POST["source_did"];}
if (isset($_GET["did_pattern"]))			{$did_pattern=$_GET["did_pattern"];}	
	elseif (isset($_POST["did_pattern"]))	{$did_pattern=$_POST["did_pattern"];}
if (isset($_GET["did_description"]))			{$did_description=$_GET["did_description"];}	
	elseif (isset($_POST["did_description"]))	{$did_description=$_POST["did_description"];}
if (isset($_GET["did_active"]))				{$did_active=$_GET["did_active"];}	
	elseif (isset($_POST["did_active"]))	{$did_active=$_POST["did_active"];}
if (isset($_GET["did_route"]))				{$did_route=$_GET["did_route"];}	
	elseif (isset($_POST["did_route"]))		{$did_route=$_POST["did_route"];}
if (isset($_GET["did_pattern_filter"]))				{$did_pattern_filter=$_GET["did_pattern_filter"];}	
	elseif (isset($_POST["did_pattern_filter"]))		{$did_pattern_filter=$_POST["did_pattern_filter"];}
if (isset($_GET["exten_context"]))			{$exten_context=$_GET["exten_context"];}	
	elseif (isset($_POST["exten_context"]))	{$exten_context=$_POST["exten_context"];}
if (isset($_GET["phone"]))					{$phone=$_GET["phone"];}	
	elseif (isset($_POST["phone"]))			{$phone=$_POST["phone"];}
if (isset($_GET["user_unavailable_action"]))			{$user_unavailable_action=$_GET["user_unavailable_action"];}	
	elseif (isset($_POST["user_unavailable_action"]))	{$user_unavailable_action=$_POST["user_unavailable_action"];}
if (isset($_GET["user_route_settings_ingroup"]))			{$user_route_settings_ingroup=$_GET["user_route_settings_ingroup"];}	
	elseif (isset($_POST["user_route_settings_ingroup"]))	{$user_route_settings_ingroup=$_POST["user_route_settings_ingroup"];}
if (isset($_GET["call_handle_method"]))				{$call_handle_method=$_GET["call_handle_method"];}	
	elseif (isset($_POST["call_handle_method"]))	{$call_handle_method=$_POST["call_handle_method"];}
if (isset($_GET["agent_search_method"]))			{$agent_search_method=$_GET["agent_search_method"];}	
	elseif (isset($_POST["agent_search_method"]))	{$agent_search_method=$_POST["agent_search_method"];}
if (isset($_GET["phone_code"]))				{$phone_code=$_GET["phone_code"];}	
	elseif (isset($_POST["phone_code"]))	{$phone_code=$_POST["phone_code"];}
if (isset($_GET["email"]))					{$email=$_GET["email"];}	
	elseif (isset($_POST["email"]))			{$email=$_POST["email"];}
if (isset($_GET["modify_inbound_dids"]))			{$modify_inbound_dids=$_GET["modify_inbound_dids"];}	
	elseif (isset($_POST["modify_inbound_dids"]))	{$modify_inbound_dids=$_POST["modify_inbound_dids"];}
if (isset($_GET["delete_inbound_dids"]))			{$delete_inbound_dids=$_GET["delete_inbound_dids"];}	
	elseif (isset($_POST["delete_inbound_dids"]))	{$delete_inbound_dids=$_POST["delete_inbound_dids"];}
if (isset($_GET["three_way_call_cid"]))				{$three_way_call_cid=$_GET["three_way_call_cid"];}	
	elseif (isset($_POST["three_way_call_cid"]))	{$three_way_call_cid=$_POST["three_way_call_cid"];}
if (isset($_GET["three_way_dial_prefix"]))			{$three_way_dial_prefix=$_GET["three_way_dial_prefix"];}
	elseif (isset($_POST["three_way_dial_prefix"]))	{$three_way_dial_prefix=$_POST["three_way_dial_prefix"];}
if (isset($_GET["forced_timeclock_login"]))				{$forced_timeclock_login=$_GET["forced_timeclock_login"];}
	elseif (isset($_POST["forced_timeclock_login"]))	{$forced_timeclock_login=$_POST["forced_timeclock_login"];}
if (isset($_GET["answer_sec_pct_rt_stat_one"]))				{$answer_sec_pct_rt_stat_one=$_GET["answer_sec_pct_rt_stat_one"];}
	elseif (isset($_POST["answer_sec_pct_rt_stat_one"]))	{$answer_sec_pct_rt_stat_one=$_POST["answer_sec_pct_rt_stat_one"];}
if (isset($_GET["answer_sec_pct_rt_stat_two"]))				{$answer_sec_pct_rt_stat_two=$_GET["answer_sec_pct_rt_stat_two"];}
	elseif (isset($_POST["answer_sec_pct_rt_stat_two"]))	{$answer_sec_pct_rt_stat_two=$_POST["answer_sec_pct_rt_stat_two"];}
if (isset($_GET["list_active_change"]))				{$list_active_change=$_GET["list_active_change"];}
	elseif (isset($_POST["list_active_change"]))	{$list_active_change=$_POST["list_active_change"];}
if (isset($_GET["web_form_target"]))			{$web_form_target=$_GET["web_form_target"];}
	elseif (isset($_POST["web_form_target"]))	{$web_form_target=$_POST["web_form_target"];}
if (isset($_GET["alt_server_ip"]))				{$alt_server_ip=$_GET["alt_server_ip"];}
	elseif (isset($_POST["alt_server_ip"]))	{$alt_server_ip=$_POST["alt_server_ip"];}
if (isset($_GET["recording_web_link"]))				{$recording_web_link=$_GET["recording_web_link"];}
	elseif (isset($_POST["recording_web_link"]))	{$recording_web_link=$_POST["recording_web_link"];}
if (isset($_GET["enable_vtiger_integration"]))			{$enable_vtiger_integration=$_GET["enable_vtiger_integration"];}
	elseif (isset($_POST["enable_vtiger_integration"]))	{$enable_vtiger_integration=$_POST["enable_vtiger_integration"];}
if (isset($_GET["vtiger_server_ip"]))			{$vtiger_server_ip=$_GET["vtiger_server_ip"];}
	elseif (isset($_POST["vtiger_server_ip"]))	{$vtiger_server_ip=$_POST["vtiger_server_ip"];}
if (isset($_GET["vtiger_dbname"]))				{$vtiger_dbname=$_GET["vtiger_dbname"];}
	elseif (isset($_POST["vtiger_dbname"]))		{$vtiger_dbname=$_POST["vtiger_dbname"];}
if (isset($_GET["vtiger_login"]))			{$vtiger_login=$_GET["vtiger_login"];}
	elseif (isset($_POST["vtiger_login"]))	{$vtiger_login=$_POST["vtiger_login"];}
if (isset($_GET["vtiger_pass"]))			{$vtiger_pass=$_GET["vtiger_pass"];}
	elseif (isset($_POST["vtiger_pass"]))	{$vtiger_pass=$_POST["vtiger_pass"];}
if (isset($_GET["vtiger_url"]))				{$vtiger_url=$_GET["vtiger_url"];}
	elseif (isset($_POST["vtiger_url"]))	{$vtiger_url=$_POST["vtiger_url"];}
if (isset($_GET["vtiger_search_category"]))				{$vtiger_search_category=$_GET["vtiger_search_category"];}
	elseif (isset($_POST["vtiger_search_category"]))	{$vtiger_search_category=$_POST["vtiger_search_category"];}
if (isset($_GET["vtiger_create_call_record"]))			{$vtiger_create_call_record=$_GET["vtiger_create_call_record"];}
	elseif (isset($_POST["vtiger_create_call_record"]))	{$vtiger_create_call_record=$_POST["vtiger_create_call_record"];}
if (isset($_GET["vtiger_create_lead_record"]))			{$vtiger_create_lead_record=$_GET["vtiger_create_lead_record"];}
	elseif (isset($_POST["vtiger_create_lead_record"]))	{$vtiger_create_lead_record=$_POST["vtiger_create_lead_record"];}
if (isset($_GET["vtiger_screen_login"]))			{$vtiger_screen_login=$_GET["vtiger_screen_login"];}
	elseif (isset($_POST["vtiger_screen_login"]))	{$vtiger_screen_login=$_POST["vtiger_screen_login"];}
if (isset($_GET["qc_features_active"]))				{$qc_features_active=$_GET["qc_features_active"];}
	elseif (isset($_POST["qc_features_active"]))	{$qc_features_active=$_POST["qc_features_active"];}
if (isset($_GET["outbound_autodial_active"]))			{$outbound_autodial_active=$_GET["outbound_autodial_active"];}
	elseif (isset($_POST["outbound_autodial_active"]))	{$outbound_autodial_active=$_POST["outbound_autodial_active"];}
if (isset($_GET["cpd_amd_action"]))				{$cpd_amd_action=$_GET["cpd_amd_action"];}
	elseif (isset($_POST["cpd_amd_action"]))	{$cpd_amd_action=$_POST["cpd_amd_action"];}
if (isset($_GET["download_lists"]))				{$download_lists=$_GET["download_lists"];}
	elseif (isset($_POST["download_lists"]))	{$download_lists=$_POST["download_lists"];}
if (isset($_GET["active_asterisk_server"]))				{$active_asterisk_server=$_GET["active_asterisk_server"];}
	elseif (isset($_POST["active_asterisk_server"]))	{$active_asterisk_server=$_POST["active_asterisk_server"];}
if (isset($_GET["generate_vicidial_conf"]))				{$generate_vicidial_conf=$_GET["generate_vicidial_conf"];}
	elseif (isset($_POST["generate_vicidial_conf"]))	{$generate_vicidial_conf=$_POST["generate_vicidial_conf"];}
if (isset($_GET["rebuild_conf_files"]))				{$rebuild_conf_files=$_GET["rebuild_conf_files"];}
	elseif (isset($_POST["rebuild_conf_files"]))	{$rebuild_conf_files=$_POST["rebuild_conf_files"];}
if (isset($_GET["template_id"]))			{$template_id=$_GET["template_id"];}
	elseif (isset($_POST["template_id"]))	{$template_id=$_POST["template_id"];}
if (isset($_GET["conf_override"]))			{$conf_override=$_GET["conf_override"];}
	elseif (isset($_POST["conf_override"]))	{$conf_override=$_POST["conf_override"];}
if (isset($_GET["template_name"]))			{$template_name=$_GET["template_name"];}
	elseif (isset($_POST["template_name"]))	{$template_name=$_POST["template_name"];}
if (isset($_GET["template_contents"]))			{$template_contents=$_GET["template_contents"];}
	elseif (isset($_POST["template_contents"]))	{$template_contents=$_POST["template_contents"];}
if (isset($_GET["carrier_id"]))			{$carrier_id=$_GET["carrier_id"];}
	elseif (isset($_POST["carrier_id"]))	{$carrier_id=$_POST["carrier_id"];}
if (isset($_GET["carrier_name"]))			{$carrier_name=$_GET["carrier_name"];}
	elseif (isset($_POST["carrier_name"]))	{$carrier_name=$_POST["carrier_name"];}
if (isset($_GET["registration_string"]))			{$registration_string=$_GET["registration_string"];}
	elseif (isset($_POST["registration_string"]))	{$registration_string=$_POST["registration_string"];}
if (isset($_GET["account_entry"]))			{$account_entry=$_GET["account_entry"];}
	elseif (isset($_POST["account_entry"]))	{$account_entry=$_POST["account_entry"];}
if (isset($_GET["globals_string"]))				{$globals_string=$_GET["globals_string"];}
	elseif (isset($_POST["globals_string"]))	{$globals_string=$_POST["globals_string"];}
if (isset($_GET["dialplan_entry"]))				{$dialplan_entry=$_GET["dialplan_entry"];}
	elseif (isset($_POST["dialplan_entry"]))	{$dialplan_entry=$_POST["dialplan_entry"];}
if (isset($_GET["group_alias_id"]))				{$group_alias_id=$_GET["group_alias_id"];}
	elseif (isset($_POST["group_alias_id"]))	{$group_alias_id=$_POST["group_alias_id"];}
if (isset($_GET["group_alias_name"]))				{$group_alias_name=$_GET["group_alias_name"];}
	elseif (isset($_POST["group_alias_name"]))	{$group_alias_name=$_POST["group_alias_name"];}
if (isset($_GET["caller_id_number"]))				{$caller_id_number=$_GET["caller_id_number"];}
	elseif (isset($_POST["caller_id_number"]))	{$caller_id_number=$_POST["caller_id_number"];}
if (isset($_GET["caller_id_name"]))				{$caller_id_name=$_GET["caller_id_name"];}
	elseif (isset($_POST["caller_id_name"]))	{$caller_id_name=$_POST["caller_id_name"];}
if (isset($_GET["agent_allow_group_alias"]))			{$agent_allow_group_alias=$_GET["agent_allow_group_alias"];}
	elseif (isset($_POST["agent_allow_group_alias"]))	{$agent_allow_group_alias=$_POST["agent_allow_group_alias"];}
if (isset($_GET["default_group_alias"]))				{$default_group_alias=$_GET["default_group_alias"];}
	elseif (isset($_POST["default_group_alias"]))		{$default_group_alias=$_POST["default_group_alias"];}
if (isset($_GET["outbound_calls_per_second"]))				{$outbound_calls_per_second=$_GET["outbound_calls_per_second"];}
	elseif (isset($_POST["outbound_calls_per_second"]))		{$outbound_calls_per_second=$_POST["outbound_calls_per_second"];}
if (isset($_GET["shift_enforcement"]))				{$shift_enforcement=$_GET["shift_enforcement"];}
	elseif (isset($_POST["shift_enforcement"]))		{$shift_enforcement=$_POST["shift_enforcement"];}
if (isset($_GET["agent_shift_enforcement_override"]))			{$agent_shift_enforcement_override=$_GET["agent_shift_enforcement_override"];}
	elseif (isset($_POST["agent_shift_enforcement_override"]))	{$agent_shift_enforcement_override=$_POST["agent_shift_enforcement_override"];}
if (isset($_GET["manager_shift_enforcement_override"]))				{$manager_shift_enforcement_override=$_GET["manager_shift_enforcement_override"];}
	elseif (isset($_POST["manager_shift_enforcement_override"]))	{$manager_shift_enforcement_override=$_POST["manager_shift_enforcement_override"];}
if (isset($_GET["export_reports"]))				{$export_reports=$_GET["export_reports"];}
	elseif (isset($_POST["export_reports"]))	{$export_reports=$_POST["export_reports"];}
if (isset($_GET["delete_from_dnc"]))			{$delete_from_dnc=$_GET["delete_from_dnc"];}
	elseif (isset($_POST["delete_from_dnc"]))	{$delete_from_dnc=$_POST["delete_from_dnc"];}
if (isset($_GET["vtiger_search_dead"]))				{$vtiger_search_dead=$_GET["vtiger_search_dead"];}
	elseif (isset($_POST["vtiger_search_dead"]))	{$vtiger_search_dead=$_POST["vtiger_search_dead"];}
if (isset($_GET["vtiger_status_call"]))				{$vtiger_status_call=$_GET["vtiger_status_call"];}
	elseif (isset($_POST["vtiger_status_call"]))	{$vtiger_status_call=$_POST["vtiger_status_call"];}
if (isset($_GET["sale"]))				{$sale=$_GET["sale"];}
	elseif (isset($_POST["sale"]))		{$sale=$_POST["sale"];}
if (isset($_GET["dnc"]))				{$dnc=$_GET["dnc"];}
	elseif (isset($_POST["dnc"]))		{$dnc=$_POST["dnc"];}
if (isset($_GET["customer_contact"]))			{$customer_contact=$_GET["customer_contact"];}
	elseif (isset($_POST["customer_contact"]))	{$customer_contact=$_POST["customer_contact"];}
if (isset($_GET["not_interested"]))				{$not_interested=$_GET["not_interested"];}
	elseif (isset($_POST["not_interested"]))	{$not_interested=$_POST["not_interested"];}
if (isset($_GET["unworkable"]))					{$unworkable=$_GET["unworkable"];}
	elseif (isset($_POST["unworkable"]))		{$unworkable=$_POST["unworkable"];}
if (isset($_GET["user_code"]))					{$user_code=$_GET["user_code"];}
	elseif (isset($_POST["user_code"]))			{$user_code=$_POST["user_code"];}
if (isset($_GET["territory"]))					{$territory=$_GET["territory"];}
	elseif (isset($_POST["territory"]))			{$territory=$_POST["territory"];}
if (isset($_GET["survey_third_digit"]))				{$survey_third_digit=$_GET["survey_third_digit"];}
	elseif (isset($_POST["survey_third_digit"]))	{$survey_third_digit=$_POST["survey_third_digit"];}
if (isset($_GET["survey_fourth_digit"]))			{$survey_fourth_digit=$_GET["survey_fourth_digit"];}
	elseif (isset($_POST["survey_fourth_digit"]))	{$survey_fourth_digit=$_POST["survey_fourth_digit"];}
if (isset($_GET["survey_third_audio_file"]))			{$survey_third_audio_file=$_GET["survey_third_audio_file"];}
	elseif (isset($_POST["survey_third_audio_file"]))	{$survey_third_audio_file=$_POST["survey_third_audio_file"];}
if (isset($_GET["survey_fourth_audio_file"]))			{$survey_fourth_audio_file=$_GET["survey_fourth_audio_file"];}
	elseif (isset($_POST["survey_fourth_audio_file"]))	{$survey_fourth_audio_file=$_POST["survey_fourth_audio_file"];}
if (isset($_GET["survey_third_status"]))				{$survey_third_status=$_GET["survey_third_status"];}
	elseif (isset($_POST["survey_third_status"]))		{$survey_third_status=$_POST["survey_third_status"];}
if (isset($_GET["survey_fourth_status"]))				{$survey_fourth_status=$_GET["survey_fourth_status"];}
	elseif (isset($_POST["survey_fourth_status"]))		{$survey_fourth_status=$_POST["survey_fourth_status"];}
if (isset($_GET["survey_third_exten"]))					{$survey_third_exten=$_GET["survey_third_exten"];}
	elseif (isset($_POST["survey_third_exten"]))		{$survey_third_exten=$_POST["survey_third_exten"];}
if (isset($_GET["survey_fourth_exten"]))				{$survey_fourth_exten=$_GET["survey_fourth_exten"];}
	elseif (isset($_POST["survey_fourth_exten"]))		{$survey_fourth_exten=$_POST["survey_fourth_exten"];}
if (isset($_GET["menu_id"]))				{$menu_id=$_GET["menu_id"];}
	elseif (isset($_POST["menu_id"]))		{$menu_id=$_POST["menu_id"];}
if (isset($_GET["menu_name"]))				{$menu_name=$_GET["menu_name"];}
	elseif (isset($_POST["menu_name"]))		{$menu_name=$_POST["menu_name"];}
if (isset($_GET["menu_prompt"]))			{$menu_prompt=$_GET["menu_prompt"];}
	elseif (isset($_POST["menu_prompt"]))	{$menu_prompt=$_POST["menu_prompt"];}
if (isset($_GET["menu_timeout"]))			{$menu_timeout=$_GET["menu_timeout"];}
	elseif (isset($_POST["menu_timeout"]))	{$menu_timeout=$_POST["menu_timeout"];}
if (isset($_GET["menu_timeout_prompt"]))			{$menu_timeout_prompt=$_GET["menu_timeout_prompt"];}
	elseif (isset($_POST["menu_timeout_prompt"]))	{$menu_timeout_prompt=$_POST["menu_timeout_prompt"];}
if (isset($_GET["menu_invalid_prompt"]))			{$menu_invalid_prompt=$_GET["menu_invalid_prompt"];}
	elseif (isset($_POST["menu_invalid_prompt"]))	{$menu_invalid_prompt=$_POST["menu_invalid_prompt"];}
if (isset($_GET["menu_repeat"]))				{$menu_repeat=$_GET["menu_repeat"];}
	elseif (isset($_POST["menu_repeat"]))		{$menu_repeat=$_POST["menu_repeat"];}
if (isset($_GET["menu_time_check"]))			{$menu_time_check=$_GET["menu_time_check"];}
	elseif (isset($_POST["menu_time_check"]))	{$menu_time_check=$_POST["menu_time_check"];}
if (isset($_GET["track_in_vdac"]))				{$track_in_vdac=$_GET["track_in_vdac"];}
	elseif (isset($_POST["track_in_vdac"]))		{$track_in_vdac=$_POST["track_in_vdac"];}
if (isset($_GET["source_menu"]))			{$source_menu=$_GET["source_menu"];}
	elseif (isset($_POST["source_menu"]))	{$source_menu=$_POST["source_menu"];}
if (isset($_GET["agentonly_callback_campaign_lock"]))			{$agentonly_callback_campaign_lock=$_GET["agentonly_callback_campaign_lock"];}
	elseif (isset($_POST["agentonly_callback_campaign_lock"]))	{$agentonly_callback_campaign_lock=$_POST["agentonly_callback_campaign_lock"];}
if (isset($_GET["sounds_central_control_active"]))			{$sounds_central_control_active=$_GET["sounds_central_control_active"];}
	elseif (isset($_POST["sounds_central_control_active"]))	{$sounds_central_control_active=$_POST["sounds_central_control_active"];}
if (isset($_GET["sounds_web_server"]))				{$sounds_web_server=$_GET["sounds_web_server"];}
	elseif (isset($_POST["sounds_web_server"]))		{$sounds_web_server=$_POST["sounds_web_server"];}
if (isset($_GET["sounds_web_directory"]))			{$sounds_web_directory=$_GET["sounds_web_directory"];}
	elseif (isset($_POST["sounds_web_directory"]))	{$sounds_web_directory=$_POST["sounds_web_directory"];}
if (isset($_GET["sounds_update"]))			{$sounds_update=$_GET["sounds_update"];}
	elseif (isset($_POST["sounds_update"]))	{$sounds_update=$_POST["sounds_update"];}
if (isset($_GET["active_voicemail_server"]))			{$active_voicemail_server=$_GET["active_voicemail_server"];}
	elseif (isset($_POST["active_voicemail_server"]))	{$active_voicemail_server=$_POST["active_voicemail_server"];}
if (isset($_GET["auto_dial_limit"]))			{$auto_dial_limit=$_GET["auto_dial_limit"];}
	elseif (isset($_POST["auto_dial_limit"]))	{$auto_dial_limit=$_POST["auto_dial_limit"];}
if (isset($_GET["user_territories_active"]))			{$user_territories_active=$_GET["user_territories_active"];}
	elseif (isset($_POST["user_territories_active"]))	{$user_territories_active=$_POST["user_territories_active"];}
if (isset($_GET["list_status_modification_confirmation"]))	{$list_status_modification_confirmation=$_GET["list_status_modification_confirmation"];}
	elseif (isset($_POST["list_status_modification_confirmation"]))	{$list_status_modification_confirmation=$_POST["list_status_modification_confirmation"];}
if (isset($_GET["vicidial_recording_limit"]))			{$vicidial_recording_limit=$_GET["vicidial_recording_limit"];}
	elseif (isset($_POST["vicidial_recording_limit"]))	{$vicidial_recording_limit=$_POST["vicidial_recording_limit"];}
if (isset($_GET["phone_context"]))				{$phone_context=$_GET["phone_context"];}
	elseif (isset($_POST["phone_context"]))		{$phone_context=$_POST["phone_context"];}
if (isset($_GET["carrier_logging_active"]))				{$carrier_logging_active=$_GET["carrier_logging_active"];}
	elseif (isset($_POST["carrier_logging_active"]))	{$carrier_logging_active=$_POST["carrier_logging_active"];}
if (isset($_GET["drop_lockout_time"]))				{$drop_lockout_time=$_GET["drop_lockout_time"];}
	elseif (isset($_POST["drop_lockout_time"]))		{$drop_lockout_time=$_POST["drop_lockout_time"];}
if (isset($_GET["allow_custom_dialplan"]))				{$allow_custom_dialplan=$_GET["allow_custom_dialplan"];}
	elseif (isset($_POST["allow_custom_dialplan"]))		{$allow_custom_dialplan=$_POST["allow_custom_dialplan"];}
if (isset($_GET["custom_dialplan_entry"]))				{$custom_dialplan_entry=$_GET["custom_dialplan_entry"];}
	elseif (isset($_POST["custom_dialplan_entry"]))		{$custom_dialplan_entry=$_POST["custom_dialplan_entry"];}
if (isset($_GET["phone_ring_timeout"]))					{$phone_ring_timeout=$_GET["phone_ring_timeout"];}
	elseif (isset($_POST["phone_ring_timeout"]))		{$phone_ring_timeout=$_POST["phone_ring_timeout"];}
if (isset($_GET["conf_secret"]))					{$conf_secret=$_GET["conf_secret"];}
	elseif (isset($_POST["conf_secret"]))			{$conf_secret=$_POST["conf_secret"];}
if (isset($_GET["tracking_group"]))					{$tracking_group=$_GET["tracking_group"];}
	elseif (isset($_POST["tracking_group"]))		{$tracking_group=$_POST["tracking_group"];}
if (isset($_GET["no_agent_no_queue"]))				{$no_agent_no_queue=$_GET["no_agent_no_queue"];}
	elseif (isset($_POST["no_agent_no_queue"]))		{$no_agent_no_queue=$_POST["no_agent_no_queue"];}
if (isset($_GET["no_agent_action"]))				{$no_agent_action=$_GET["no_agent_action"];}
	elseif (isset($_POST["no_agent_action"]))		{$no_agent_action=$_POST["no_agent_action"];}
if (isset($_GET["no_agent_action_value"]))			{$no_agent_action_value=$_GET["no_agent_action_value"];}
	elseif (isset($_POST["no_agent_action_value"]))	{$no_agent_action_value=$_POST["no_agent_action_value"];}
if (isset($_GET["quick_transfer_button"]))			{$quick_transfer_button=$_GET["quick_transfer_button"];}
	elseif (isset($_POST["quick_transfer_button"]))	{$quick_transfer_button=$_POST["quick_transfer_button"];}
if (isset($_GET["prepopulate_transfer_preset"]))			{$prepopulate_transfer_preset=$_GET["prepopulate_transfer_preset"];}
	elseif (isset($_POST["prepopulate_transfer_preset"]))	{$prepopulate_transfer_preset=$_POST["prepopulate_transfer_preset"];}
if (isset($_GET["enable_tts_integration"]))				{$enable_tts_integration=$_GET["enable_tts_integration"];}
	elseif (isset($_POST["enable_tts_integration"]))	{$enable_tts_integration=$_POST["enable_tts_integration"];}
if (isset($_GET["tts_id"]))							{$tts_id=$_GET["tts_id"];}
	elseif (isset($_POST["tts_id"]))				{$tts_id=$_POST["tts_id"];}
if (isset($_GET["tts_name"]))						{$tts_name=$_GET["tts_name"];}
	elseif (isset($_POST["tts_name"]))				{$tts_name=$_POST["tts_name"];}
if (isset($_GET["tts_text"]))						{$tts_text=$_GET["tts_text"];}
	elseif (isset($_POST["tts_text"]))				{$tts_text=$_POST["tts_text"];}
if (isset($_GET["drop_rate_group"]))				{$drop_rate_group=$_GET["drop_rate_group"];}
	elseif (isset($_POST["drop_rate_group"]))		{$drop_rate_group=$_POST["drop_rate_group"];}
if (isset($_GET["agent_status_viewable_groups"]))			{$agent_status_viewable_groups=$_GET["agent_status_viewable_groups"];}
	elseif (isset($_POST["agent_status_viewable_groups"]))	{$agent_status_viewable_groups=$_POST["agent_status_viewable_groups"];}
if (isset($_GET["agent_status_view_time"]))				{$agent_status_view_time=$_GET["agent_status_view_time"];}
	elseif (isset($_POST["agent_status_view_time"]))	{$agent_status_view_time=$_POST["agent_status_view_time"];}
if (isset($_GET["view_calls_in_queue"]))			{$view_calls_in_queue=$_GET["view_calls_in_queue"];}
	elseif (isset($_POST["view_calls_in_queue"]))	{$view_calls_in_queue=$_POST["view_calls_in_queue"];}
if (isset($_GET["view_calls_in_queue_launch"]))				{$view_calls_in_queue_launch=$_GET["view_calls_in_queue_launch"];}
	elseif (isset($_POST["view_calls_in_queue_launch"]))	{$view_calls_in_queue_launch=$_POST["view_calls_in_queue_launch"];}
if (isset($_GET["grab_calls_in_queue"]))			{$grab_calls_in_queue=$_GET["grab_calls_in_queue"];}
	elseif (isset($_POST["grab_calls_in_queue"]))	{$grab_calls_in_queue=$_POST["grab_calls_in_queue"];}
if (isset($_GET["call_requeue_button"]))			{$call_requeue_button=$_GET["call_requeue_button"];}
	elseif (isset($_POST["call_requeue_button"]))	{$call_requeue_button=$_POST["call_requeue_button"];}
if (isset($_GET["pause_after_each_call"]))			{$pause_after_each_call=$_GET["pause_after_each_call"];}
	elseif (isset($_POST["pause_after_each_call"]))	{$pause_after_each_call=$_POST["pause_after_each_call"];}
if (isset($_GET["no_hopper_dialing"]))				{$no_hopper_dialing=$_GET["no_hopper_dialing"];}
	elseif (isset($_POST["no_hopper_dialing"]))		{$no_hopper_dialing=$_POST["no_hopper_dialing"];}
if (isset($_GET["agent_dial_owner_only"]))			{$agent_dial_owner_only=$_GET["agent_dial_owner_only"];}
	elseif (isset($_POST["agent_dial_owner_only"]))	{$agent_dial_owner_only=$_POST["agent_dial_owner_only"];}
if (isset($_GET["reset_time"]))						{$reset_time=$_GET["reset_time"];}
	elseif (isset($_POST["reset_time"]))			{$reset_time=$_POST["reset_time"];}
if (isset($_GET["allow_alerts"]))					{$allow_alerts=$_GET["allow_alerts"];}
	elseif (isset($_POST["allow_alerts"]))			{$allow_alerts=$_POST["allow_alerts"];}
if (isset($_GET["agent_display_dialable_leads"]))			{$agent_display_dialable_leads=$_GET["agent_display_dialable_leads"];}
	elseif (isset($_POST["agent_display_dialable_leads"]))	{$agent_display_dialable_leads=$_POST["agent_display_dialable_leads"];}
if (isset($_GET["vicidial_balance_rank"]))			{$vicidial_balance_rank=$_GET["vicidial_balance_rank"];}
	elseif (isset($_POST["vicidial_balance_rank"]))	{$vicidial_balance_rank=$_POST["vicidial_balance_rank"];}
if (isset($_GET["agent_script_override"]))			{$agent_script_override=$_GET["agent_script_override"];}
	elseif (isset($_POST["agent_script_override"]))	{$agent_script_override=$_POST["agent_script_override"];}
if (isset($_GET["inbound_list_script_override"]))			{$inbound_list_script_override=$_GET["inbound_list_script_override"];}
	elseif (isset($_POST["inbound_list_script_override"]))	{$inbound_list_script_override=$_POST["inbound_list_script_override"];}
if (isset($_GET["moh_id"]))				{$moh_id=$_GET["moh_id"];}
	elseif (isset($_POST["moh_id"]))	{$moh_id=$_POST["moh_id"];}
if (isset($_GET["moh_name"]))			{$moh_name=$_GET["moh_name"];}
	elseif (isset($_POST["moh_name"]))	{$moh_name=$_POST["moh_name"];}
if (isset($_GET["random"]))				{$random=$_GET["random"];}
	elseif (isset($_POST["random"]))	{$random=$_POST["random"];}
if (isset($_GET["filename"]))			{$filename=$_GET["filename"];}
	elseif (isset($_POST["filename"]))	{$filename=$_POST["filename"];}
if (isset($_GET["rank"]))				{$rank=$_GET["rank"];}
	elseif (isset($_POST["rank"]))		{$rank=$_POST["rank"];}
if (isset($_GET["rebuild_music_on_hold"]))				{$rebuild_music_on_hold=$_GET["rebuild_music_on_hold"];}
	elseif (isset($_POST["rebuild_music_on_hold"]))		{$rebuild_music_on_hold=$_POST["rebuild_music_on_hold"];}
if (isset($_GET["active_agent_login_server"]))			{$active_agent_login_server=$_GET["active_agent_login_server"];}
	elseif (isset($_POST["active_agent_login_server"]))	{$active_agent_login_server=$_POST["active_agent_login_server"];}
if (isset($_GET["enable_second_webform"]))			{$enable_second_webform=$_GET["enable_second_webform"];}
	elseif (isset($_POST["enable_second_webform"]))	{$enable_second_webform=$_POST["enable_second_webform"];}
if (isset($_GET["web_form_address_two"]))			{$web_form_address_two=$_GET["web_form_address_two"];}
	elseif (isset($_POST["web_form_address_two"]))	{$web_form_address_two=$_POST["web_form_address_two"];}
if (isset($_GET["waitforsilence_options"]))			{$waitforsilence_options=$_GET["waitforsilence_options"];}
	elseif (isset($_POST["waitforsilence_options"]))	{$waitforsilence_options=$_POST["waitforsilence_options"];}
if (isset($_GET["campaign_cid_override"]))			{$campaign_cid_override=$_GET["campaign_cid_override"];}
	elseif (isset($_POST["campaign_cid_override"]))	{$campaign_cid_override=$_POST["campaign_cid_override"];}
if (isset($_GET["am_message_exten_override"]))			{$am_message_exten_override=$_GET["am_message_exten_override"];}
	elseif (isset($_POST["am_message_exten_override"]))	{$am_message_exten_override=$_POST["am_message_exten_override"];}
if (isset($_GET["drop_inbound_group_override"]))			{$drop_inbound_group_override=$_GET["drop_inbound_group_override"];}
	elseif (isset($_POST["drop_inbound_group_override"]))	{$drop_inbound_group_override=$_POST["drop_inbound_group_override"];}
if (isset($_GET["agent_select_territories"]))			{$agent_select_territories=$_GET["agent_select_territories"];}
	elseif (isset($_POST["agent_select_territories"]))	{$agent_select_territories=$_POST["agent_select_territories"];}
if (isset($_GET["agent_choose_territories"]))			{$agent_choose_territories=$_GET["agent_choose_territories"];}
	elseif (isset($_POST["agent_choose_territories"]))	{$agent_choose_territories=$_POST["agent_choose_territories"];}
if (isset($_GET["carrier_description"]))			{$carrier_description=$_GET["carrier_description"];}
	elseif (isset($_POST["carrier_description"]))	{$carrier_description=$_POST["carrier_description"];}
if (isset($_GET["delete_vm_after_email"]))			{$delete_vm_after_email=$_GET["delete_vm_after_email"];}
	elseif (isset($_POST["delete_vm_after_email"]))	{$delete_vm_after_email=$_POST["delete_vm_after_email"];}
if (isset($_GET["custom_one"]))					{$custom_one=$_GET["custom_one"];}
	elseif (isset($_POST["custom_one"]))		{$custom_one=$_POST["custom_one"];}
if (isset($_GET["custom_two"]))					{$custom_two=$_GET["custom_two"];}
	elseif (isset($_POST["custom_two"]))		{$custom_two=$_POST["custom_two"];}
if (isset($_GET["custom_three"]))				{$custom_three=$_GET["custom_three"];}
	elseif (isset($_POST["custom_three"]))		{$custom_three=$_POST["custom_three"];}
if (isset($_GET["custom_four"]))				{$custom_four=$_GET["custom_four"];}
	elseif (isset($_POST["custom_four"]))		{$custom_four=$_POST["custom_four"];}
if (isset($_GET["custom_five"]))				{$custom_five=$_GET["custom_five"];}
	elseif (isset($_POST["custom_five"]))		{$custom_five=$_POST["custom_five"];}
if (isset($_GET["crm_popup_login"]))			{$crm_popup_login=$_GET["crm_popup_login"];}
	elseif (isset($_POST["crm_popup_login"]))	{$crm_popup_login=$_POST["crm_popup_login"];}
if (isset($_GET["crm_login_address"]))			{$crm_login_address=$_GET["crm_login_address"];}
	elseif (isset($_POST["crm_login_address"]))	{$crm_login_address=$_POST["crm_login_address"];}
if (isset($_GET["timer_action"]))					{$timer_action=$_GET["timer_action"];}
	elseif (isset($_POST["timer_action"]))			{$timer_action=$_POST["timer_action"];}
if (isset($_GET["timer_action_message"]))			{$timer_action_message=$_GET["timer_action_message"];}
	elseif (isset($_POST["timer_action_message"]))	{$timer_action_message=$_POST["timer_action_message"];}
if (isset($_GET["timer_action_seconds"]))			{$timer_action_seconds=$_GET["timer_action_seconds"];}
	elseif (isset($_POST["timer_action_seconds"]))	{$timer_action_seconds=$_POST["timer_action_seconds"];}
if (isset($_GET["start_call_url"]))				{$start_call_url=$_GET["start_call_url"];}
	elseif (isset($_POST["start_call_url"]))	{$start_call_url=$_POST["start_call_url"];}
if (isset($_GET["dispo_call_url"]))				{$dispo_call_url=$_GET["dispo_call_url"];}
	elseif (isset($_POST["dispo_call_url"]))	{$dispo_call_url=$_POST["dispo_call_url"];}
if (isset($_GET["xferconf_c_number"]))			{$xferconf_c_number=$_GET["xferconf_c_number"];}
	elseif (isset($_POST["xferconf_c_number"]))	{$xferconf_c_number=$_POST["xferconf_c_number"];}
if (isset($_GET["xferconf_d_number"]))			{$xferconf_d_number=$_GET["xferconf_d_number"];}
	elseif (isset($_POST["xferconf_d_number"]))	{$xferconf_d_number=$_POST["xferconf_d_number"];}
if (isset($_GET["xferconf_e_number"]))			{$xferconf_e_number=$_GET["xferconf_e_number"];}
	elseif (isset($_POST["xferconf_e_number"]))	{$xferconf_e_number=$_POST["xferconf_e_number"];}
if (isset($_GET["record_call"]))				{$record_call=$_GET["record_call"];}
	elseif (isset($_POST["record_call"]))		{$record_call=$_POST["record_call"];}
if (isset($_GET["ignore_list_script_override"]))			{$ignore_list_script_override=$_GET["ignore_list_script_override"];}
	elseif (isset($_POST["ignore_list_script_override"]))	{$ignore_list_script_override=$_POST["ignore_list_script_override"];}
if (isset($_GET["external_server_ip"]))			{$external_server_ip=$_GET["external_server_ip"];}
	elseif (isset($_POST["external_server_ip"])){$external_server_ip=$_POST["external_server_ip"];}
if (isset($_GET["is_webphone"]))				{$is_webphone=$_GET["is_webphone"];}
	elseif (isset($_POST["is_webphone"]))		{$is_webphone=$_POST["is_webphone"];}
if (isset($_GET["use_external_server_ip"]))			{$use_external_server_ip=$_GET["use_external_server_ip"];}
	elseif (isset($_POST["use_external_server_ip"])){$use_external_server_ip=$_POST["use_external_server_ip"];}
if (isset($_GET["default_webphone"]))			{$default_webphone=$_GET["default_webphone"];}
	elseif (isset($_POST["default_webphone"]))	{$default_webphone=$_POST["default_webphone"];}
if (isset($_GET["default_external_server_ip"]))			{$default_external_server_ip=$_GET["default_external_server_ip"];}
	elseif (isset($_POST["default_external_server_ip"])){$default_external_server_ip=$_POST["default_external_server_ip"];}
if (isset($_GET["webphone_url"]))				{$webphone_url=$_GET["webphone_url"];}
	elseif (isset($_POST["webphone_url"]))		{$webphone_url=$_POST["webphone_url"];}
if (isset($_GET["enable_agc_dispo_log"]))			{$enable_agc_dispo_log=$_GET["enable_agc_dispo_log"];}
	elseif (isset($_POST["enable_agc_dispo_log"]))	{$enable_agc_dispo_log=$_POST["enable_agc_dispo_log"];}
if (isset($_GET["agent_call_log_view"]))			{$agent_call_log_view=$_GET["agent_call_log_view"];}
	elseif (isset($_POST["agent_call_log_view"]))	{$agent_call_log_view=$_POST["agent_call_log_view"];}
if (isset($_GET["agent_call_log_view_override"]))			{$agent_call_log_view_override=$_GET["agent_call_log_view_override"];}
	elseif (isset($_POST["agent_call_log_view_override"]))	{$agent_call_log_view_override=$_POST["agent_call_log_view_override"];}
if (isset($_GET["use_custom_cid"]))				{$use_custom_cid=$_GET["use_custom_cid"];}
	elseif (isset($_POST["use_custom_cid"]))	{$use_custom_cid=$_POST["use_custom_cid"];}
if (isset($_GET["scheduled_callbacks_alert"]))			{$scheduled_callbacks_alert=$_GET["scheduled_callbacks_alert"];}
	elseif (isset($_POST["scheduled_callbacks_alert"]))	{$scheduled_callbacks_alert=$_POST["scheduled_callbacks_alert"];}
if (isset($_GET["scheduled_callbacks_email_alert"]))			{$scheduled_callbacks_email_alert=$_GET["scheduled_callbacks_email_alert"];}
	elseif (isset($_POST["scheduled_callbacks_email_alert"]))	{$scheduled_callbacks_email_alert=$_POST["scheduled_callbacks_email_alert"];}
if (isset($_GET["queuemetrics_loginout"]))			{$queuemetrics_loginout=$_GET["queuemetrics_loginout"];}
	elseif (isset($_POST["queuemetrics_loginout"]))	{$queuemetrics_loginout=$_POST["queuemetrics_loginout"];}
if (isset($_GET["callcard_enabled"]))				{$callcard_enabled=$_GET["callcard_enabled"];}
	elseif (isset($_POST["callcard_enabled"]))		{$callcard_enabled=$_POST["callcard_enabled"];}
if (isset($_GET["callcard_admin"]))					{$callcard_admin=$_GET["callcard_admin"];}
	elseif (isset($_POST["callcard_admin"]))		{$callcard_admin=$_POST["callcard_admin"];}
if (isset($_GET["agent_xfer_consultative"]))				{$agent_xfer_consultative=$_GET["agent_xfer_consultative"];}
	elseif (isset($_POST["agent_xfer_consultative"]))		{$agent_xfer_consultative=$_POST["agent_xfer_consultative"];}
if (isset($_GET["agent_xfer_dial_override"]))				{$agent_xfer_dial_override=$_GET["agent_xfer_dial_override"];}
	elseif (isset($_POST["agent_xfer_dial_override"]))		{$agent_xfer_dial_override=$_POST["agent_xfer_dial_override"];}
if (isset($_GET["agent_xfer_vm_transfer"]))					{$agent_xfer_vm_transfer=$_GET["agent_xfer_vm_transfer"];}
	elseif (isset($_POST["agent_xfer_vm_transfer"]))		{$agent_xfer_vm_transfer=$_POST["agent_xfer_vm_transfer"];}
if (isset($_GET["agent_xfer_blind_transfer"]))				{$agent_xfer_blind_transfer=$_GET["agent_xfer_blind_transfer"];}
	elseif (isset($_POST["agent_xfer_blind_transfer"]))		{$agent_xfer_blind_transfer=$_POST["agent_xfer_blind_transfer"];}
if (isset($_GET["agent_xfer_dial_with_customer"]))			{$agent_xfer_dial_with_customer=$_GET["agent_xfer_dial_with_customer"];}
	elseif (isset($_POST["agent_xfer_dial_with_customer"]))	{$agent_xfer_dial_with_customer=$_POST["agent_xfer_dial_with_customer"];}
if (isset($_GET["agent_xfer_park_customer_dial"]))			{$agent_xfer_park_customer_dial=$_GET["agent_xfer_park_customer_dial"];}
	elseif (isset($_POST["agent_xfer_park_customer_dial"]))	{$agent_xfer_park_customer_dial=$_POST["agent_xfer_park_customer_dial"];}
if (isset($_GET["agent_fullscreen"]))			{$agent_fullscreen=$_GET["agent_fullscreen"];}
	elseif (isset($_POST["agent_fullscreen"]))	{$agent_fullscreen=$_POST["agent_fullscreen"];}
if (isset($_GET["extension_id"]))				{$extension_id=$_GET["extension_id"];}
	elseif (isset($_POST["extension_id"]))		{$extension_id=$_POST["extension_id"];}
if (isset($_GET["extension_group_id"]))				{$extension_group_id=$_GET["extension_group_id"];}
	elseif (isset($_POST["extension_group_id"]))	{$extension_group_id=$_POST["extension_group_id"];}
if (isset($_GET["campaign_groups"]))			{$campaign_groups=$_GET["campaign_groups"];}
	elseif (isset($_POST["campaign_groups"]))	{$campaign_groups=$_POST["campaign_groups"];}
if (isset($_GET["extension_group"]))			{$extension_group=$_GET["extension_group"];}
	elseif (isset($_POST["extension_group"]))	{$extension_group=$_POST["extension_group"];}
if (isset($_GET["agent_choose_blended"]))			{$agent_choose_blended=$_GET["agent_choose_blended"];}
	elseif (isset($_POST["agent_choose_blended"]))	{$agent_choose_blended=$_POST["agent_choose_blended"];}
if (isset($_GET["queuemetrics_callstatus"]))			{$queuemetrics_callstatus=$_GET["queuemetrics_callstatus"];}
	elseif (isset($_POST["queuemetrics_callstatus"]))	{$queuemetrics_callstatus=$_POST["queuemetrics_callstatus"];}
if (isset($_GET["extension_appended_cidname"]))				{$extension_appended_cidname=$_GET["extension_appended_cidname"];}
	elseif (isset($_POST["extension_appended_cidname"]))	{$extension_appended_cidname=$_POST["extension_appended_cidname"];}
if (isset($_GET["scheduled_callbacks_count"]))			{$scheduled_callbacks_count=$_GET["scheduled_callbacks_count"];}
	elseif (isset($_POST["scheduled_callbacks_count"]))	{$scheduled_callbacks_count=$_POST["scheduled_callbacks_count"];}
if (isset($_GET["realtime_block_user_info"]))			{$realtime_block_user_info=$_GET["realtime_block_user_info"];}
	elseif (isset($_POST["realtime_block_user_info"]))	{$realtime_block_user_info=$_POST["realtime_block_user_info"];}
if (isset($_GET["manual_dial_override"]))			{$manual_dial_override=$_GET["manual_dial_override"];}
	elseif (isset($_POST["manual_dial_override"]))	{$manual_dial_override=$_POST["manual_dial_override"];}
if (isset($_GET["blind_monitor_warning"]))			{$blind_monitor_warning=$_GET["blind_monitor_warning"];}
	elseif (isset($_POST["blind_monitor_warning"]))	{$blind_monitor_warning=$_POST["blind_monitor_warning"];}
if (isset($_GET["blind_monitor_message"]))			{$blind_monitor_message=$_GET["blind_monitor_message"];}
	elseif (isset($_POST["blind_monitor_message"]))	{$blind_monitor_message=$_POST["blind_monitor_message"];}
if (isset($_GET["blind_monitor_filename"]))				{$blind_monitor_filename=$_GET["blind_monitor_filename"];}
	elseif (isset($_POST["blind_monitor_filename"]))	{$blind_monitor_filename=$_POST["blind_monitor_filename"];}
if (isset($_GET["uniqueid_status_display"]))			{$uniqueid_status_display=$_GET["uniqueid_status_display"];}
	elseif (isset($_POST["uniqueid_status_display"]))	{$uniqueid_status_display=$_POST["uniqueid_status_display"];}
if (isset($_GET["uniqueid_status_prefix"]))				{$uniqueid_status_prefix=$_GET["uniqueid_status_prefix"];}
	elseif (isset($_POST["uniqueid_status_prefix"]))	{$uniqueid_status_prefix=$_POST["uniqueid_status_prefix"];}
if (isset($_GET["default_codecs"]))				{$default_codecs=$_GET["default_codecs"];}
	elseif (isset($_POST["default_codecs"]))	{$default_codecs=$_POST["default_codecs"];}
if (isset($_GET["codecs_list"]))			{$codecs_list=$_GET["codecs_list"];}
	elseif (isset($_POST["codecs_list"]))	{$codecs_list=$_POST["codecs_list"];}
if (isset($_GET["codecs_with_template"]))			{$codecs_with_template=$_GET["codecs_with_template"];}
	elseif (isset($_POST["codecs_with_template"]))	{$codecs_with_template=$_POST["codecs_with_template"];}
if (isset($_GET["custom_fields_modify"]))			{$custom_fields_modify=$_GET["custom_fields_modify"];}
	elseif (isset($_POST["custom_fields_modify"]))	{$custom_fields_modify=$_POST["custom_fields_modify"];}
if (isset($_GET["hold_time_option_minimum"]))			{$hold_time_option_minimum=$_GET["hold_time_option_minimum"];}
	elseif (isset($_POST["hold_time_option_minimum"]))	{$hold_time_option_minimum=$_POST["hold_time_option_minimum"];}
if (isset($_GET["source_carrier"]))				{$source_carrier=$_GET["source_carrier"];}
	elseif (isset($_POST["source_carrier"]))	{$source_carrier=$_POST["source_carrier"];}
if (isset($_GET["hold_time_option_press_filename"]))			{$hold_time_option_press_filename=$_GET["hold_time_option_press_filename"];}
	elseif (isset($_POST["hold_time_option_press_filename"]))	{$hold_time_option_press_filename=$_POST["hold_time_option_press_filename"];}
if (isset($_GET["hold_time_option_callmenu"]))			{$hold_time_option_callmenu=$_GET["hold_time_option_callmenu"];}
	elseif (isset($_POST["hold_time_option_callmenu"]))	{$hold_time_option_callmenu=$_POST["hold_time_option_callmenu"];}
if (isset($_GET["inbound_queue_no_dial"]))			{$inbound_queue_no_dial=$_GET["inbound_queue_no_dial"];}
	elseif (isset($_POST["inbound_queue_no_dial"]))	{$inbound_queue_no_dial=$_POST["inbound_queue_no_dial"];}
if (isset($_GET["default_afterhours_filename_override"]))			{$default_afterhours_filename_override=$_GET["default_afterhours_filename_override"];}
	elseif (isset($_POST["default_afterhours_filename_override"]))	{$default_afterhours_filename_override=$_POST["default_afterhours_filename_override"];}
if (isset($_GET["sunday_afterhours_filename_override"]))			{$sunday_afterhours_filename_override=$_GET["sunday_afterhours_filename_override"];}
	elseif (isset($_POST["sunday_afterhours_filename_override"]))	{$sunday_afterhours_filename_override=$_POST["sunday_afterhours_filename_override"];}
if (isset($_GET["monday_afterhours_filename_override"]))			{$monday_afterhours_filename_override=$_GET["monday_afterhours_filename_override"];}
	elseif (isset($_POST["monday_afterhours_filename_override"]))	{$monday_afterhours_filename_override=$_POST["monday_afterhours_filename_override"];}
if (isset($_GET["tuesday_afterhours_filename_override"]))			{$tuesday_afterhours_filename_override=$_GET["tuesday_afterhours_filename_override"];}
	elseif (isset($_POST["tuesday_afterhours_filename_override"]))	{$tuesday_afterhours_filename_override=$_POST["tuesday_afterhours_filename_override"];}
if (isset($_GET["wednesday_afterhours_filename_override"]))			{$wednesday_afterhours_filename_override=$_GET["wednesday_afterhours_filename_override"];}
	elseif (isset($_POST["wednesday_afterhours_filename_override"]))	{$wednesday_afterhours_filename_override=$_POST["wednesday_afterhours_filename_override"];}
if (isset($_GET["thursday_afterhours_filename_override"]))			{$thursday_afterhours_filename_override=$_GET["thursday_afterhours_filename_override"];}
	elseif (isset($_POST["thursday_afterhours_filename_override"]))	{$thursday_afterhours_filename_override=$_POST["thursday_afterhours_filename_override"];}
if (isset($_GET["friday_afterhours_filename_override"]))			{$friday_afterhours_filename_override=$_GET["friday_afterhours_filename_override"];}
	elseif (isset($_POST["friday_afterhours_filename_override"]))	{$friday_afterhours_filename_override=$_POST["friday_afterhours_filename_override"];}
if (isset($_GET["saturday_afterhours_filename_override"]))			{$saturday_afterhours_filename_override=$_GET["saturday_afterhours_filename_override"];}
	elseif (isset($_POST["saturday_afterhours_filename_override"]))	{$saturday_afterhours_filename_override=$_POST["saturday_afterhours_filename_override"];}
if (isset($_GET["onhold_prompt_no_block"]))				{$onhold_prompt_no_block=$_GET["onhold_prompt_no_block"];}
	elseif (isset($_POST["onhold_prompt_no_block"]))	{$onhold_prompt_no_block=$_POST["onhold_prompt_no_block"];}
if (isset($_GET["onhold_prompt_seconds"]))			{$onhold_prompt_seconds=$_GET["onhold_prompt_seconds"];}
	elseif (isset($_POST["onhold_prompt_seconds"]))	{$onhold_prompt_seconds=$_POST["onhold_prompt_seconds"];}
if (isset($_GET["hold_time_option_no_block"]))			{$hold_time_option_no_block=$_GET["hold_time_option_no_block"];}
	elseif (isset($_POST["hold_time_option_no_block"]))	{$hold_time_option_no_block=$_POST["hold_time_option_no_block"];}
if (isset($_GET["hold_time_option_prompt_seconds"]))			{$hold_time_option_prompt_seconds=$_GET["hold_time_option_prompt_seconds"];}
	elseif (isset($_POST["hold_time_option_prompt_seconds"]))	{$hold_time_option_prompt_seconds=$_POST["hold_time_option_prompt_seconds"];}
if (isset($_GET["admin_web_directory"]))			{$admin_web_directory=$_GET["admin_web_directory"];}
	elseif (isset($_POST["admin_web_directory"]))	{$admin_web_directory=$_POST["admin_web_directory"];}
if (isset($_GET["tts_voice"]))				{$tts_voice=$_GET["tts_voice"];}
	elseif (isset($_POST["tts_voice"]))		{$tts_voice=$_POST["tts_voice"];}
if (isset($_GET["label_title"]))					{$label_title=$_GET["label_title"];}
	elseif (isset($_POST["label_title"]))			{$label_title=$_POST["label_title"];}
if (isset($_GET["label_first_name"]))				{$label_first_name=$_GET["label_first_name"];}
	elseif (isset($_POST["label_first_name"]))		{$label_first_name=$_POST["label_first_name"];}
if (isset($_GET["label_middle_initial"]))			{$label_middle_initial=$_GET["label_middle_initial"];}
	elseif (isset($_POST["label_middle_initial"]))	{$label_middle_initial=$_POST["label_middle_initial"];}
if (isset($_GET["label_last_name"]))				{$label_last_name=$_GET["label_last_name"];}
	elseif (isset($_POST["label_last_name"]))		{$label_last_name=$_POST["label_last_name"];}
if (isset($_GET["label_address1"]))					{$label_address1=$_GET["label_address1"];}
	elseif (isset($_POST["label_address1"]))		{$label_address1=$_POST["label_address1"];}
if (isset($_GET["label_address2"]))					{$label_address2=$_GET["label_address2"];}
	elseif (isset($_POST["label_address2"]))		{$label_address2=$_POST["label_address2"];}
if (isset($_GET["label_address3"]))					{$label_address3=$_GET["label_address3"];}
	elseif (isset($_POST["label_address3"]))		{$label_address3=$_POST["label_address3"];}
if (isset($_GET["label_city"]))						{$label_city=$_GET["label_city"];}
	elseif (isset($_POST["label_city"]))			{$label_city=$_POST["label_city"];}
if (isset($_GET["label_state"]))					{$label_state=$_GET["label_state"];}
	elseif (isset($_POST["label_state"]))			{$label_state=$_POST["label_state"];}
if (isset($_GET["label_province"]))					{$label_province=$_GET["label_province"];}
	elseif (isset($_POST["label_province"]))		{$label_province=$_POST["label_province"];}
if (isset($_GET["label_postal_code"]))				{$label_postal_code=$_GET["label_postal_code"];}
	elseif (isset($_POST["label_postal_code"]))		{$label_postal_code=$_POST["label_postal_code"];}
if (isset($_GET["label_vendor_lead_code"]))			{$label_vendor_lead_code=$_GET["label_vendor_lead_code"];}
	elseif (isset($_POST["label_vendor_lead_code"])){$label_vendor_lead_code=$_POST["label_vendor_lead_code"];}
if (isset($_GET["label_gender"]))					{$label_gender=$_GET["label_gender"];}
	elseif (isset($_POST["label_gender"]))			{$label_gender=$_POST["label_gender"];}
if (isset($_GET["label_phone_number"]))				{$label_phone_number=$_GET["label_phone_number"];}
	elseif (isset($_POST["label_phone_number"]))	{$label_phone_number=$_POST["label_phone_number"];}
if (isset($_GET["label_phone_code"]))				{$label_phone_code=$_GET["label_phone_code"];}
	elseif (isset($_POST["label_phone_code"]))		{$label_phone_code=$_POST["label_phone_code"];}
if (isset($_GET["label_alt_phone"]))				{$label_alt_phone=$_GET["label_alt_phone"];}
	elseif (isset($_POST["label_alt_phone"]))		{$label_alt_phone=$_POST["label_alt_phone"];}
if (isset($_GET["label_security_phrase"]))			{$label_security_phrase=$_GET["label_security_phrase"];}
	elseif (isset($_POST["label_security_phrase"]))	{$label_security_phrase=$_POST["label_security_phrase"];}
if (isset($_GET["label_email"]))					{$label_email=$_GET["label_email"];}
	elseif (isset($_POST["label_email"]))			{$label_email=$_POST["label_email"];}
if (isset($_GET["label_comments"]))					{$label_comments=$_GET["label_comments"];}
	elseif (isset($_POST["label_comments"]))		{$label_comments=$_POST["label_comments"];}
if (isset($_GET["custom_fields_enabled"]))			{$custom_fields_enabled=$_GET["custom_fields_enabled"];}
	elseif (isset($_POST["custom_fields_enabled"]))	{$custom_fields_enabled=$_POST["custom_fields_enabled"];}
if (isset($_GET["slave_db_server"]))				{$slave_db_server=$_GET["slave_db_server"];}
	elseif (isset($_POST["slave_db_server"]))		{$slave_db_server=$_POST["slave_db_server"];}
if (isset($_GET["reports_use_slave_db"]))			{$reports_use_slave_db=$_GET["reports_use_slave_db"];}
	elseif (isset($_POST["reports_use_slave_db"]))	{$reports_use_slave_db=$_POST["reports_use_slave_db"];}
if (isset($_GET["custom_reports_use_slave_db"]))			{$custom_reports_use_slave_db=$_GET["custom_reports_use_slave_db"];}
	elseif (isset($_POST["custom_reports_use_slave_db"]))	{$custom_reports_use_slave_db=$_POST["custom_reports_use_slave_db"];}
if (isset($_GET["hold_time_second_option"]))			{$hold_time_second_option=$_GET["hold_time_second_option"];}
	elseif (isset($_POST["hold_time_second_option"]))	{$hold_time_second_option=$_POST["hold_time_second_option"];}
if (isset($_GET["hold_time_third_option"]))				{$hold_time_third_option=$_GET["hold_time_third_option"];}
	elseif (isset($_POST["hold_time_third_option"]))	{$hold_time_third_option=$_POST["hold_time_third_option"];}
if (isset($_GET["wait_hold_option_priority"]))			{$wait_hold_option_priority=$_GET["wait_hold_option_priority"];}
	elseif (isset($_POST["wait_hold_option_priority"]))	{$wait_hold_option_priority=$_POST["wait_hold_option_priority"];}
if (isset($_GET["wait_time_option"]))					{$wait_time_option=$_GET["wait_time_option"];}
	elseif (isset($_POST["wait_time_option"]))			{$wait_time_option=$_POST["wait_time_option"];}
if (isset($_GET["wait_time_second_option"]))			{$wait_time_second_option=$_GET["wait_time_second_option"];}
	elseif (isset($_POST["wait_time_second_option"]))	{$wait_time_second_option=$_POST["wait_time_second_option"];}
if (isset($_GET["wait_time_third_option"]))				{$wait_time_third_option=$_GET["wait_time_third_option"];}
	elseif (isset($_POST["wait_time_third_option"]))	{$wait_time_third_option=$_POST["wait_time_third_option"];}
if (isset($_GET["wait_time_option_seconds"]))			{$wait_time_option_seconds=$_GET["wait_time_option_seconds"];}
	elseif (isset($_POST["wait_time_option_seconds"]))	{$wait_time_option_seconds=$_POST["wait_time_option_seconds"];}
if (isset($_GET["wait_time_option_exten"]))				{$wait_time_option_exten=$_GET["wait_time_option_exten"];}
	elseif (isset($_POST["wait_time_option_exten"]))	{$wait_time_option_exten=$_POST["wait_time_option_exten"];}
if (isset($_GET["wait_time_option_voicemail"]))			{$wait_time_option_voicemail=$_GET["wait_time_option_voicemail"];}
	elseif (isset($_POST["wait_time_option_voicemail"]))	{$wait_time_option_voicemail=$_POST["wait_time_option_voicemail"];}
if (isset($_GET["wait_time_option_xfer_group"]))			{$wait_time_option_xfer_group=$_GET["wait_time_option_xfer_group"];}
	elseif (isset($_POST["wait_time_option_xfer_group"]))	{$wait_time_option_xfer_group=$_POST["wait_time_option_xfer_group"];}
if (isset($_GET["wait_time_option_callmenu"]))				{$wait_time_option_callmenu=$_GET["wait_time_option_callmenu"];}
	elseif (isset($_POST["wait_time_option_callmenu"]))		{$wait_time_option_callmenu=$_POST["wait_time_option_callmenu"];}
if (isset($_GET["wait_time_option_callback_filename"]))				{$wait_time_option_callback_filename=$_GET["wait_time_option_callback_filename"];}
	elseif (isset($_POST["wait_time_option_callback_filename"]))	{$wait_time_option_callback_filename=$_POST["wait_time_option_callback_filename"];}
if (isset($_GET["wait_time_option_callback_list_id"]))			{$wait_time_option_callback_list_id=$_GET["wait_time_option_callback_list_id"];}
	elseif (isset($_POST["wait_time_option_callback_list_id"]))	{$wait_time_option_callback_list_id=$_POST["wait_time_option_callback_list_id"];}
if (isset($_GET["wait_time_option_press_filename"]))			{$wait_time_option_press_filename=$_GET["wait_time_option_press_filename"];}
	elseif (isset($_POST["wait_time_option_press_filename"]))	{$wait_time_option_press_filename=$_POST["wait_time_option_press_filename"];}
if (isset($_GET["wait_time_option_no_block"]))			{$wait_time_option_no_block=$_GET["wait_time_option_no_block"];}
	elseif (isset($_POST["wait_time_option_no_block"]))	{$wait_time_option_no_block=$_POST["wait_time_option_no_block"];}
if (isset($_GET["wait_time_option_prompt_seconds"]))			{$wait_time_option_prompt_seconds=$_GET["wait_time_option_prompt_seconds"];}
	elseif (isset($_POST["wait_time_option_prompt_seconds"]))	{$wait_time_option_prompt_seconds=$_POST["wait_time_option_prompt_seconds"];}
if (isset($_GET["timer_action_destination"]))			{$timer_action_destination=$_GET["timer_action_destination"];}
	elseif (isset($_POST["timer_action_destination"]))	{$timer_action_destination=$_POST["timer_action_destination"];}
if (isset($_GET["allowed_reports"]))			{$allowed_reports=$_GET["allowed_reports"];}
	elseif (isset($_POST["allowed_reports"]))	{$allowed_reports=$_POST["allowed_reports"];}
if (isset($_GET["allowed_custom_reports"]))			{$allowed_custom_reports=$_GET["allowed_custom_reports"];}
	elseif (isset($_POST["allowed_custom_reports"]))	{$allowed_custom_reports=$_POST["allowed_custom_reports"];}
if (isset($_GET["filter_phone_group_id"]))			{$filter_phone_group_id=$_GET["filter_phone_group_id"];}
	elseif (isset($_POST["filter_phone_group_id"]))	{$filter_phone_group_id=$_POST["filter_phone_group_id"];}
if (isset($_GET["filter_phone_group_name"]))			{$filter_phone_group_name=$_GET["filter_phone_group_name"];}
	elseif (isset($_POST["filter_phone_group_name"]))	{$filter_phone_group_name=$_POST["filter_phone_group_name"];}
if (isset($_GET["filter_phone_group_description"]))				{$filter_phone_group_description=$_GET["filter_phone_group_description"];}
	elseif (isset($_POST["filter_phone_group_description"]))	{$filter_phone_group_description=$_POST["filter_phone_group_description"];}
if (isset($_GET["filter_inbound_number"]))			{$filter_inbound_number=$_GET["filter_inbound_number"];}
	elseif (isset($_POST["filter_inbound_number"]))	{$filter_inbound_number=$_POST["filter_inbound_number"];}
if (isset($_GET["filter_url"]))				{$filter_url=$_GET["filter_url"];}
	elseif (isset($_POST["filter_url"]))	{$filter_url=$_POST["filter_url"];}
if (isset($_GET["filter_action"]))			{$filter_action=$_GET["filter_action"];}
	elseif (isset($_POST["filter_action"]))	{$filter_action=$_POST["filter_action"];}
if (isset($_GET["filter_extension"]))			{$filter_extension=$_GET["filter_extension"];}
	elseif (isset($_POST["filter_extension"]))	{$filter_extension=$_POST["filter_extension"];}
if (isset($_GET["filter_exten_context"]))			{$filter_exten_context=$_GET["filter_exten_context"];}
	elseif (isset($_POST["filter_exten_context"]))	{$filter_exten_context=$_POST["filter_exten_context"];}
if (isset($_GET["filter_voicemail_ext"]))			{$filter_voicemail_ext=$_GET["filter_voicemail_ext"];}
	elseif (isset($_POST["filter_voicemail_ext"]))	{$filter_voicemail_ext=$_POST["filter_voicemail_ext"];}
if (isset($_GET["filter_phone"]))			{$filter_phone=$_GET["filter_phone"];}
	elseif (isset($_POST["filter_phone"]))	{$filter_phone=$_POST["filter_phone"];}
if (isset($_GET["filter_server_ip"]))			{$filter_server_ip=$_GET["filter_server_ip"];}
	elseif (isset($_POST["filter_server_ip"]))	{$filter_server_ip=$_POST["filter_server_ip"];}
if (isset($_GET["filter_user"]))			{$filter_user=$_GET["filter_user"];}
	elseif (isset($_POST["filter_user"]))	{$filter_user=$_POST["filter_user"];}
if (isset($_GET["filter_user_unavailable_action"]))				{$filter_user_unavailable_action=$_GET["filter_user_unavailable_action"];}
	elseif (isset($_POST["filter_user_unavailable_action"]))	{$filter_user_unavailable_action=$_POST["filter_user_unavailable_action"];}
if (isset($_GET["filter_user_route_settings_ingroup"]))				{$filter_user_route_settings_ingroup=$_GET["filter_user_route_settings_ingroup"];}
	elseif (isset($_POST["filter_user_route_settings_ingroup"]))	{$filter_user_route_settings_ingroup=$_POST["filter_user_route_settings_ingroup"];}
if (isset($_GET["filter_group_id"]))			{$filter_group_id=$_GET["filter_group_id"];}
	elseif (isset($_POST["filter_group_id"]))	{$filter_group_id=$_POST["filter_group_id"];}
if (isset($_GET["filter_call_handle_method"]))			{$filter_call_handle_method=$_GET["filter_call_handle_method"];}
	elseif (isset($_POST["filter_call_handle_method"]))	{$filter_call_handle_method=$_POST["filter_call_handle_method"];}
if (isset($_GET["filter_agent_search_method"]))				{$filter_agent_search_method=$_GET["filter_agent_search_method"];}
	elseif (isset($_POST["filter_agent_search_method"]))	{$filter_agent_search_method=$_POST["filter_agent_search_method"];}
if (isset($_GET["filter_list_id"]))				{$filter_list_id=$_GET["filter_list_id"];}
	elseif (isset($_POST["filter_list_id"]))	{$filter_list_id=$_POST["filter_list_id"];}
if (isset($_GET["filter_campaign_id"]))				{$filter_campaign_id=$_GET["filter_campaign_id"];}
	elseif (isset($_POST["filter_campaign_id"]))	{$filter_campaign_id=$_POST["filter_campaign_id"];}
if (isset($_GET["filter_phone_code"]))			{$filter_phone_code=$_GET["filter_phone_code"];}
	elseif (isset($_POST["filter_phone_code"]))	{$filter_phone_code=$_POST["filter_phone_code"];}
if (isset($_GET["filter_menu_id"]))				{$filter_menu_id=$_GET["filter_menu_id"];}
	elseif (isset($_POST["filter_menu_id"]))	{$filter_menu_id=$_POST["filter_menu_id"];}
if (isset($_GET["filter_clean_cid_number"]))			{$filter_clean_cid_number=$_GET["filter_clean_cid_number"];}
	elseif (isset($_POST["filter_clean_cid_number"]))	{$filter_clean_cid_number=$_POST["filter_clean_cid_number"];}
if (isset($_GET["webphone_url_override"]))			{$webphone_url_override=$_GET["webphone_url_override"];}
	elseif (isset($_POST["webphone_url_override"]))	{$webphone_url_override=$_POST["webphone_url_override"];}
if (isset($_GET["calculate_estimated_hold_seconds"]))			{$calculate_estimated_hold_seconds=$_GET["calculate_estimated_hold_seconds"];}
	elseif (isset($_POST["calculate_estimated_hold_seconds"]))	{$calculate_estimated_hold_seconds=$_POST["calculate_estimated_hold_seconds"];}
if (isset($_GET["enable_xfer_presets"]))			{$enable_xfer_presets=$_GET["enable_xfer_presets"];}
	elseif (isset($_POST["enable_xfer_presets"]))	{$enable_xfer_presets=$_POST["enable_xfer_presets"];}
if (isset($_GET["hide_xfer_number_to_dial"]))			{$hide_xfer_number_to_dial=$_GET["hide_xfer_number_to_dial"];}
	elseif (isset($_POST["hide_xfer_number_to_dial"]))	{$hide_xfer_number_to_dial=$_POST["hide_xfer_number_to_dial"];}
if (isset($_GET["preset_name"]))			{$preset_name=$_GET["preset_name"];}
	elseif (isset($_POST["preset_name"]))	{$preset_name=$_POST["preset_name"];}
if (isset($_GET["preset_number"]))			{$preset_number=$_GET["preset_number"];}
	elseif (isset($_POST["preset_number"]))	{$preset_number=$_POST["preset_number"];}
if (isset($_GET["preset_dtmf"]))			{$preset_dtmf=$_GET["preset_dtmf"];}
	elseif (isset($_POST["preset_dtmf"]))	{$preset_dtmf=$_POST["preset_dtmf"];}
if (isset($_GET["preset_hide_number"]))				{$preset_hide_number=$_GET["preset_hide_number"];}
	elseif (isset($_POST["preset_hide_number"]))	{$preset_hide_number=$_POST["preset_hide_number"];}
if (isset($_GET["manual_dial_prefix"]))				{$manual_dial_prefix=$_GET["manual_dial_prefix"];}
	elseif (isset($_POST["manual_dial_prefix"]))	{$manual_dial_prefix=$_POST["manual_dial_prefix"];}
if (isset($_GET["webphone_systemkey"]))				{$webphone_systemkey=$_GET["webphone_systemkey"];}
	elseif (isset($_POST["webphone_systemkey"]))	{$webphone_systemkey=$_POST["webphone_systemkey"];}
if (isset($_GET["webphone_dialpad"]))			{$webphone_dialpad=$_GET["webphone_dialpad"];}
	elseif (isset($_POST["webphone_dialpad"]))	{$webphone_dialpad=$_POST["webphone_dialpad"];}
if (isset($_GET["webphone_systemkey_override"]))			{$webphone_systemkey_override=$_GET["webphone_systemkey_override"];}
	elseif (isset($_POST["webphone_systemkey_override"]))	{$webphone_systemkey_override=$_POST["webphone_systemkey_override"];}
if (isset($_GET["webphone_dialpad_override"]))			{$webphone_dialpad_override=$_GET["webphone_dialpad_override"];}
	elseif (isset($_POST["webphone_dialpad_override"]))	{$webphone_dialpad_override=$_POST["webphone_dialpad_override"];}
if (isset($_GET["force_change_password"]))			{$force_change_password=$_GET["force_change_password"];}
	elseif (isset($_POST["force_change_password"]))	{$force_change_password=$_POST["force_change_password"];}
if (isset($_GET["first_login_trigger"]))			{$first_login_trigger=$_GET["first_login_trigger"];}
	elseif (isset($_POST["first_login_trigger"]))	{$first_login_trigger=$_POST["first_login_trigger"];}
if (isset($_GET["default_phone_registration_password"]))			{$default_phone_registration_password=$_GET["default_phone_registration_password"];}
	elseif (isset($_POST["default_phone_registration_password"]))	{$default_phone_registration_password=$_POST["default_phone_registration_password"];}
if (isset($_GET["default_phone_login_password"]))			{$default_phone_login_password=$_GET["default_phone_login_password"];}
	elseif (isset($_POST["default_phone_login_password"]))	{$default_phone_login_password=$_POST["default_phone_login_password"];}
if (isset($_GET["default_server_password"]))			{$default_server_password=$_GET["default_server_password"];}
	elseif (isset($_POST["default_server_password"]))	{$default_server_password=$_POST["default_server_password"];}
if (isset($_GET["customer_3way_hangup_logging"]))			{$customer_3way_hangup_logging=$_GET["customer_3way_hangup_logging"];}
	elseif (isset($_POST["customer_3way_hangup_logging"]))	{$customer_3way_hangup_logging=$_POST["customer_3way_hangup_logging"];}
if (isset($_GET["customer_3way_hangup_seconds"]))			{$customer_3way_hangup_seconds=$_GET["customer_3way_hangup_seconds"];}
	elseif (isset($_POST["customer_3way_hangup_seconds"]))	{$customer_3way_hangup_seconds=$_POST["customer_3way_hangup_seconds"];}
if (isset($_GET["customer_3way_hangup_action"]))			{$customer_3way_hangup_action=$_GET["customer_3way_hangup_action"];}
	elseif (isset($_POST["customer_3way_hangup_action"]))	{$customer_3way_hangup_action=$_POST["customer_3way_hangup_action"];}
if (isset($_GET["add_lead_url"]))			{$add_lead_url=$_GET["add_lead_url"];}
	elseif (isset($_POST["add_lead_url"]))	{$add_lead_url=$_POST["add_lead_url"];}
if (isset($_GET["ivr_park_call"]))			{$ivr_park_call=$_GET["ivr_park_call"];}
	elseif (isset($_POST["ivr_park_call"]))	{$ivr_park_call=$_POST["ivr_park_call"];}
if (isset($_GET["ivr_park_call_agi"]))			{$ivr_park_call_agi=$_GET["ivr_park_call_agi"];}
	elseif (isset($_POST["ivr_park_call_agi"]))	{$ivr_park_call_agi=$_POST["ivr_park_call_agi"];}
if (isset($_GET["manual_preview_dial"]))			{$manual_preview_dial=$_GET["manual_preview_dial"];}
	elseif (isset($_POST["manual_preview_dial"]))	{$manual_preview_dial=$_POST["manual_preview_dial"];}
if (isset($_GET["eht_minimum_prompt_filename"]))			{$eht_minimum_prompt_filename=$_GET["eht_minimum_prompt_filename"];}
	elseif (isset($_POST["eht_minimum_prompt_filename"]))	{$eht_minimum_prompt_filename=$_POST["eht_minimum_prompt_filename"];}
if (isset($_GET["eht_minimum_prompt_no_block"]))			{$eht_minimum_prompt_no_block=$_GET["eht_minimum_prompt_no_block"];}
	elseif (isset($_POST["eht_minimum_prompt_no_block"]))	{$eht_minimum_prompt_no_block=$_POST["eht_minimum_prompt_no_block"];}
if (isset($_GET["eht_minimum_prompt_seconds"]))				{$eht_minimum_prompt_seconds=$_GET["eht_minimum_prompt_seconds"];}
	elseif (isset($_POST["eht_minimum_prompt_seconds"]))	{$eht_minimum_prompt_seconds=$_POST["eht_minimum_prompt_seconds"];}
if (isset($_GET["realtime_agent_time_stats"]))				{$realtime_agent_time_stats=$_GET["realtime_agent_time_stats"];}
	elseif (isset($_POST["realtime_agent_time_stats"]))		{$realtime_agent_time_stats=$_POST["realtime_agent_time_stats"];}
if (isset($_GET["admin_modify_refresh"]))			{$admin_modify_refresh=$_GET["admin_modify_refresh"];}
	elseif (isset($_POST["admin_modify_refresh"]))	{$admin_modify_refresh=$_POST["admin_modify_refresh"];}
if (isset($_GET["nocache_admin"]))			{$nocache_admin=$_GET["nocache_admin"];}
	elseif (isset($_POST["nocache_admin"]))	{$nocache_admin=$_POST["nocache_admin"];}
if (isset($_GET["generate_cross_server_exten"]))			{$generate_cross_server_exten=$_GET["generate_cross_server_exten"];}
	elseif (isset($_POST["generate_cross_server_exten"]))	{$generate_cross_server_exten=$_POST["generate_cross_server_exten"];}
if (isset($_GET["queuemetrics_addmember_enabled"]))				{$queuemetrics_addmember_enabled=$_GET["queuemetrics_addmember_enabled"];}
	elseif (isset($_POST["queuemetrics_addmember_enabled"]))	{$queuemetrics_addmember_enabled=$_POST["queuemetrics_addmember_enabled"];}
if (isset($_GET["modify_page"]))			{$modify_page=$_GET["modify_page"];}
	elseif (isset($_POST["modify_page"]))	{$modify_page=$_POST["modify_page"];}
if (isset($_GET["modify_url"]))				{$modify_url=$_GET["modify_url"];}
	elseif (isset($_POST["modify_url"]))	{$modify_url=$_POST["modify_url"];}
if (isset($_GET["use_auto_hopper"]))			{$use_auto_hopper=$_GET["use_auto_hopper"];}
	elseif (isset($_POST["use_auto_hopper"]))	{$use_auto_hopper=$_POST["use_auto_hopper"];}
if (isset($_GET["auto_hopper_multi"]))			{$auto_hopper_multi=$_GET["auto_hopper_multi"];}
	elseif (isset($_POST["auto_hopper_multi"]))	{$auto_hopper_multi=$_POST["auto_hopper_multi"];}
if (isset($_GET["auto_trim_hopper"]))			{$auto_trim_hopper=$_GET["auto_trim_hopper"];}
	elseif (isset($_POST["auto_trim_hopper"]))	{$auto_trim_hopper=$_POST["auto_trim_hopper"];}
if (isset($_GET["api_manual_dial"]))			{$api_manual_dial=$_GET["api_manual_dial"];}
	elseif (isset($_POST["api_manual_dial"]))	{$api_manual_dial=$_POST["api_manual_dial"];}
if (isset($_GET["manual_dial_call_time_check"]))			{$manual_dial_call_time_check=$_GET["manual_dial_call_time_check"];}
	elseif (isset($_POST["manual_dial_call_time_check"]))	{$manual_dial_call_time_check=$_POST["manual_dial_call_time_check"];}
if (isset($_GET["queuemetrics_dispo_pause"]))			{$queuemetrics_dispo_pause=$_GET["queuemetrics_dispo_pause"];}
	elseif (isset($_POST["queuemetrics_dispo_pause"]))	{$queuemetrics_dispo_pause=$_POST["queuemetrics_dispo_pause"];}
if (isset($_GET["lead_order_randomize"]))			{$lead_order_randomize=$_GET["lead_order_randomize"];}
	elseif (isset($_POST["lead_order_randomize"]))	{$lead_order_randomize=$_POST["lead_order_randomize"];}
if (isset($_GET["lead_order_secondary"]))			{$lead_order_secondary=$_GET["lead_order_secondary"];}
	elseif (isset($_POST["lead_order_secondary"]))	{$lead_order_secondary=$_POST["lead_order_secondary"];}
if (isset($_GET["per_call_notes"]))				{$per_call_notes=$_GET["per_call_notes"];}
	elseif (isset($_POST["per_call_notes"]))	{$per_call_notes=$_POST["per_call_notes"];}
if (isset($_GET["my_callback_option"]))				{$my_callback_option=$_GET["my_callback_option"];}
	elseif (isset($_POST["my_callback_option"]))	{$my_callback_option=$_POST["my_callback_option"];}
if (isset($_GET["agent_lead_search"]))			{$agent_lead_search=$_GET["agent_lead_search"];}
	elseif (isset($_POST["agent_lead_search"]))	{$agent_lead_search=$_POST["agent_lead_search"];}
if (isset($_GET["agent_lead_search_method"]))			{$agent_lead_search_method=$_GET["agent_lead_search_method"];}
	elseif (isset($_POST["agent_lead_search_method"]))	{$agent_lead_search_method=$_POST["agent_lead_search_method"];}
if (isset($_GET["queuemetrics_phone_environment"]))				{$queuemetrics_phone_environment=$_GET["queuemetrics_phone_environment"];}
	elseif (isset($_POST["queuemetrics_phone_environment"]))	{$queuemetrics_phone_environment=$_POST["queuemetrics_phone_environment"];}
if (isset($_GET["active_twin_server_ip"]))			{$active_twin_server_ip=$_GET["active_twin_server_ip"];}
	elseif (isset($_POST["active_twin_server_ip"]))	{$active_twin_server_ip=$_POST["active_twin_server_ip"];}
if (isset($_GET["on_hook_agent"]))			{$on_hook_agent=$_GET["on_hook_agent"];}
	elseif (isset($_POST["on_hook_agent"]))	{$on_hook_agent=$_POST["on_hook_agent"];}
if (isset($_GET["on_hook_ring_time"]))			{$on_hook_ring_time=$_GET["on_hook_ring_time"];}
	elseif (isset($_POST["on_hook_ring_time"]))	{$on_hook_ring_time=$_POST["on_hook_ring_time"];}
if (isset($_GET["auto_pause_precall"]))			{$auto_pause_precall=$_GET["auto_pause_precall"];}
	elseif (isset($_POST["auto_pause_precall"]))	{$auto_pause_precall=$_POST["auto_pause_precall"];}
if (isset($_GET["auto_resume_precall"]))			{$auto_resume_precall=$_GET["auto_resume_precall"];}
	elseif (isset($_POST["auto_resume_precall"]))	{$auto_resume_precall=$_POST["auto_resume_precall"];}
if (isset($_GET["auto_pause_precall_code"]))			{$auto_pause_precall_code=$_GET["auto_pause_precall_code"];}
	elseif (isset($_POST["auto_pause_precall_code"]))	{$auto_pause_precall_code=$_POST["auto_pause_precall_code"];}
if (isset($_GET["audit_comments"]))                    {$audit_comments=$_GET["audit_comments"];}
	elseif (isset($_POST["audit_comments"]))        {$audit_comments=$_POST["audit_comments"];}
if (isset($_GET["reload_dialplan_on_servers"]))				{$reload_dialplan_on_servers=$_GET["reload_dialplan_on_servers"];}
	elseif (isset($_POST["reload_dialplan_on_servers"]))	{$reload_dialplan_on_servers=$_POST["reload_dialplan_on_servers"];}
if (isset($_GET["manual_dial_cid"]))			{$manual_dial_cid=$_GET["manual_dial_cid"];}
	elseif (isset($_POST["manual_dial_cid"]))	{$manual_dial_cid=$_POST["manual_dial_cid"];}
if (isset($_GET["post_phone_time_diff_alert"]))				{$post_phone_time_diff_alert=$_GET["post_phone_time_diff_alert"];}
	elseif (isset($_POST["post_phone_time_diff_alert"]))	{$post_phone_time_diff_alert=$_POST["post_phone_time_diff_alert"];}
if (isset($_GET["custom_3way_button_transfer"]))			{$custom_3way_button_transfer=$_GET["custom_3way_button_transfer"];}
	elseif (isset($_POST["custom_3way_button_transfer"]))	{$custom_3way_button_transfer=$_POST["custom_3way_button_transfer"];}
if (isset($_GET["available_only_tally_threshold"]))				{$available_only_tally_threshold=$_GET["available_only_tally_threshold"];}
	elseif (isset($_POST["available_only_tally_threshold"]))	{$available_only_tally_threshold=$_POST["available_only_tally_threshold"];}
if (isset($_GET["available_only_tally_threshold_agents"]))			{$available_only_tally_threshold_agents=$_GET["available_only_tally_threshold_agents"];}
	elseif (isset($_POST["available_only_tally_threshold_agents"]))	{$available_only_tally_threshold_agents=$_POST["available_only_tally_threshold_agents"];}
if (isset($_GET["dial_level_threshold"]))			{$dial_level_threshold=$_GET["dial_level_threshold"];}
	elseif (isset($_POST["dial_level_threshold"]))	{$dial_level_threshold=$_POST["dial_level_threshold"];}
if (isset($_GET["dial_level_threshold_agents"]))			{$dial_level_threshold_agents=$_GET["dial_level_threshold_agents"];}
	elseif (isset($_POST["dial_level_threshold_agents"]))	{$dial_level_threshold_agents=$_POST["dial_level_threshold_agents"];}
if (isset($_GET["time_zone_setting"]))			{$time_zone_setting=$_GET["time_zone_setting"];}
	elseif (isset($_POST["time_zone_setting"]))	{$time_zone_setting=$_POST["time_zone_setting"];}
if (isset($_GET["safe_harbor_audio"]))			{$safe_harbor_audio=$_GET["safe_harbor_audio"];}
	elseif (isset($_POST["safe_harbor_audio"]))	{$safe_harbor_audio=$_POST["safe_harbor_audio"];}
if (isset($_GET["safe_harbor_menu_id"]))			{$safe_harbor_menu_id=$_GET["safe_harbor_menu_id"];}
	elseif (isset($_POST["safe_harbor_menu_id"]))	{$safe_harbor_menu_id=$_POST["safe_harbor_menu_id"];}
if (isset($_GET["dtmf_log"]))			{$dtmf_log=$_GET["dtmf_log"];}
	elseif (isset($_POST["dtmf_log"]))	{$dtmf_log=$_POST["dtmf_log"];}
if (isset($_GET["webphone_auto_answer"]))			{$webphone_auto_answer=$_GET["webphone_auto_answer"];}
	elseif (isset($_POST["webphone_auto_answer"]))	{$webphone_auto_answer=$_POST["webphone_auto_answer"];}
if (isset($_GET["survey_menu_id"]))				{$survey_menu_id=$_GET["survey_menu_id"];}
	elseif (isset($_POST["survey_menu_id"]))	{$survey_menu_id=$_POST["survey_menu_id"];}
if (isset($_GET["callback_days_limit"]))			{$callback_days_limit=$_GET["callback_days_limit"];}
	elseif (isset($_POST["callback_days_limit"]))	{$callback_days_limit=$_POST["callback_days_limit"];}
if (isset($_GET["dl_diff_target_method"]))			{$dl_diff_target_method=$_GET["dl_diff_target_method"];}
	elseif (isset($_POST["dl_diff_target_method"]))	{$dl_diff_target_method=$_POST["dl_diff_target_method"];}
if (isset($_GET["disable_dispo_screen"]))			{$disable_dispo_screen=$_GET["disable_dispo_screen"];}
	elseif (isset($_POST["disable_dispo_screen"]))	{$disable_dispo_screen=$_POST["disable_dispo_screen"];}
if (isset($_GET["disable_dispo_status"]))			{$disable_dispo_status=$_GET["disable_dispo_status"];}
	elseif (isset($_POST["disable_dispo_status"]))	{$disable_dispo_status=$_POST["disable_dispo_status"];}
if (isset($_GET["screen_labels"]))			{$screen_labels=$_GET["screen_labels"];}
	elseif (isset($_POST["screen_labels"]))	{$screen_labels=$_POST["screen_labels"];}
if (isset($_GET["label_hide_field_logs"]))			{$label_hide_field_logs=$_GET["label_hide_field_logs"];}
	elseif (isset($_POST["label_hide_field_logs"]))	{$label_hide_field_logs=$_POST["label_hide_field_logs"];}
if (isset($_GET["label_id"]))			{$label_id=$_GET["label_id"];}
	elseif (isset($_POST["label_id"]))	{$label_id=$_POST["label_id"];}
if (isset($_GET["label_name"]))				{$label_name=$_GET["label_name"];}
	elseif (isset($_POST["label_name"]))	{$label_name=$_POST["label_name"];}
if (isset($_GET["status_display_fields"]))			{$status_display_fields=$_GET["status_display_fields"];}
	elseif (isset($_POST["status_display_fields"]))	{$status_display_fields=$_POST["status_display_fields"];}
if (isset($_GET["queuemetrics_pe_phone_append"]))			{$queuemetrics_pe_phone_append=$_GET["queuemetrics_pe_phone_append"];}
	elseif (isset($_POST["queuemetrics_pe_phone_append"]))	{$queuemetrics_pe_phone_append=$_POST["queuemetrics_pe_phone_append"];}
if (isset($_GET["test_campaign_calls"]))			{$test_campaign_calls=$_GET["test_campaign_calls"];}
	elseif (isset($_POST["test_campaign_calls"]))	{$test_campaign_calls=$_POST["test_campaign_calls"];}
if (isset($_GET["agents_calls_reset"]))				{$agents_calls_reset=$_GET["agents_calls_reset"];}
	elseif (isset($_POST["agents_calls_reset"]))	{$agents_calls_reset=$_POST["agents_calls_reset"];}
if (isset($_GET["voicemail_timezone"]))				{$voicemail_timezone=$_GET["voicemail_timezone"];}
	elseif (isset($_POST["voicemail_timezone"]))	{$voicemail_timezone=$_POST["voicemail_timezone"];}
if (isset($_GET["voicemail_options"]))			{$voicemail_options=$_GET["voicemail_options"];}
	elseif (isset($_POST["voicemail_options"]))	{$voicemail_options=$_POST["voicemail_options"];}
if (isset($_GET["default_voicemail_timezone"]))				{$default_voicemail_timezone=$_GET["default_voicemail_timezone"];}
	elseif (isset($_POST["default_voicemail_timezone"]))	{$default_voicemail_timezone=$_POST["default_voicemail_timezone"];}
if (isset($_GET["default_local_gmt"]))			{$default_local_gmt=$_GET["default_local_gmt"];}
	elseif (isset($_POST["default_local_gmt"]))	{$default_local_gmt=$_POST["default_local_gmt"];}
if (isset($_GET["na_call_url"]))			{$na_call_url=$_GET["na_call_url"];}
	elseif (isset($_POST["na_call_url"]))	{$na_call_url=$_POST["na_call_url"];}
if (isset($_GET["on_hook_cid"]))			{$on_hook_cid=$_GET["on_hook_cid"];}
	elseif (isset($_POST["on_hook_cid"]))	{$on_hook_cid=$_POST["on_hook_cid"];}
if (isset($_GET["form_end"]))			{$form_end=$_GET["form_end"];}
	elseif (isset($_POST["form_end"]))	{$form_end=$_POST["form_end"];}
if (isset($_GET["noanswer_log"]))			{$noanswer_log=$_GET["noanswer_log"];}
	elseif (isset($_POST["noanswer_log"]))	{$noanswer_log=$_POST["noanswer_log"];}
if (isset($_GET["alt_log_server_ip"]))			{$alt_log_server_ip=$_GET["alt_log_server_ip"];}
	elseif (isset($_POST["alt_log_server_ip"]))	{$alt_log_server_ip=$_POST["alt_log_server_ip"];}
if (isset($_GET["alt_log_dbname"]))			{$alt_log_dbname=$_GET["alt_log_dbname"];}
	elseif (isset($_POST["alt_log_dbname"]))	{$alt_log_dbname=$_POST["alt_log_dbname"];}
if (isset($_GET["alt_log_login"]))			{$alt_log_login=$_GET["alt_log_login"];}
	elseif (isset($_POST["alt_log_login"]))	{$alt_log_login=$_POST["alt_log_login"];}
if (isset($_GET["alt_log_pass"]))			{$alt_log_pass=$_GET["alt_log_pass"];}
	elseif (isset($_POST["alt_log_pass"]))	{$alt_log_pass=$_POST["alt_log_pass"];}
if (isset($_GET["tables_use_alt_log_db"]))			{$tables_use_alt_log_db=$_GET["tables_use_alt_log_db"];}
	elseif (isset($_POST["tables_use_alt_log_db"]))	{$tables_use_alt_log_db=$_POST["tables_use_alt_log_db"];}
if (isset($_GET["did_agent_log"]))			{$did_agent_log=$_GET["did_agent_log"];}
	elseif (isset($_POST["did_agent_log"]))	{$did_agent_log=$_POST["did_agent_log"];}
if (isset($_GET["survey_recording"]))			{$survey_recording=$_GET["survey_recording"];}
	elseif (isset($_POST["survey_recording"]))	{$survey_recording=$_POST["survey_recording"];}
if (isset($_GET["campaign_cid_areacodes_enabled"]))				{$campaign_cid_areacodes_enabled=$_GET["campaign_cid_areacodes_enabled"];}
	elseif (isset($_POST["campaign_cid_areacodes_enabled"]))	{$campaign_cid_areacodes_enabled=$_POST["campaign_cid_areacodes_enabled"];}
if (isset($_GET["areacode"]))			{$areacode=$_GET["areacode"];}
	elseif (isset($_POST["areacode"]))	{$areacode=$_POST["areacode"];}
if (isset($_GET["cid_description"]))			{$cid_description=$_GET["cid_description"];}
	elseif (isset($_POST["cid_description"]))	{$cid_description=$_POST["cid_description"];}
if (isset($_GET["pllb_grouping"]))			{$pllb_grouping=$_GET["pllb_grouping"];}
	elseif (isset($_POST["pllb_grouping"]))	{$pllb_grouping=$_POST["pllb_grouping"];}
if (isset($_GET["pllb_grouping_limit"]))			{$pllb_grouping_limit=$_GET["pllb_grouping_limit"];}
	elseif (isset($_POST["pllb_grouping_limit"]))	{$pllb_grouping_limit=$_POST["pllb_grouping_limit"];}
if (isset($_GET["description"]))			{$description=$_GET["description"];}
	elseif (isset($_POST["description"]))	{$description=$_POST["description"];}
if (isset($_GET["did_ra_extensions_enabled"]))			{$did_ra_extensions_enabled=$_GET["did_ra_extensions_enabled"];}
	elseif (isset($_POST["did_ra_extensions_enabled"]))	{$did_ra_extensions_enabled=$_POST["did_ra_extensions_enabled"];}
if (isset($_GET["modify_shifts"]))			{$modify_shifts=$_GET["modify_shifts"];}
	elseif (isset($_POST["modify_shifts"]))	{$modify_shifts=$_POST["modify_shifts"];}
if (isset($_GET["modify_phones"]))			{$modify_phones=$_GET["modify_phones"];}
	elseif (isset($_POST["modify_phones"]))	{$modify_phones=$_POST["modify_phones"];}
if (isset($_GET["modify_carriers"]))			{$modify_carriers=$_GET["modify_carriers"];}
	elseif (isset($_POST["modify_carriers"]))	{$modify_carriers=$_POST["modify_carriers"];}
if (isset($_GET["modify_labels"]))			{$modify_labels=$_GET["modify_labels"];}
	elseif (isset($_POST["modify_labels"]))	{$modify_labels=$_POST["modify_labels"];}
if (isset($_GET["modify_statuses"]))			{$modify_statuses=$_GET["modify_statuses"];}
	elseif (isset($_POST["modify_statuses"]))	{$modify_statuses=$_POST["modify_statuses"];}
if (isset($_GET["modify_voicemail"]))			{$modify_voicemail=$_GET["modify_voicemail"];}
	elseif (isset($_POST["modify_voicemail"]))	{$modify_voicemail=$_POST["modify_voicemail"];}
if (isset($_GET["modify_audiostore"]))			{$modify_audiostore=$_GET["modify_audiostore"];}
	elseif (isset($_POST["modify_audiostore"]))	{$modify_audiostore=$_POST["modify_audiostore"];}
if (isset($_GET["modify_moh"]))				{$modify_moh=$_GET["modify_moh"];}
	elseif (isset($_POST["modify_moh"]))	{$modify_moh=$_POST["modify_moh"];}
if (isset($_GET["modify_tts"]))				{$modify_tts=$_GET["modify_tts"];}
	elseif (isset($_POST["modify_tts"]))	{$modify_tts=$_POST["modify_tts"];}
if (isset($_GET["action_xfer_cid"]))			{$action_xfer_cid=$_GET["action_xfer_cid"];}
	elseif (isset($_POST["action_xfer_cid"]))	{$action_xfer_cid=$_POST["action_xfer_cid"];}
if (isset($_GET["drop_callmenu"]))			{$drop_callmenu=$_GET["drop_callmenu"];}
	elseif (isset($_POST["drop_callmenu"]))	{$drop_callmenu=$_POST["drop_callmenu"];}
if (isset($_GET["after_hours_callmenu"]))			{$after_hours_callmenu=$_GET["after_hours_callmenu"];}
	elseif (isset($_POST["after_hours_callmenu"]))	{$after_hours_callmenu=$_POST["after_hours_callmenu"];}
if (isset($_GET["dtmf_field"]))			{$dtmf_field=$_GET["dtmf_field"];}
	elseif (isset($_POST["dtmf_field"]))	{$dtmf_field=$_POST["dtmf_field"];}
if (isset($_GET["call_count_limit"]))			{$call_count_limit=$_GET["call_count_limit"];}
	elseif (isset($_POST["call_count_limit"]))	{$call_count_limit=$_POST["call_count_limit"];}
if (isset($_GET["call_count_target"]))			{$call_count_target=$_GET["call_count_target"];}
	elseif (isset($_POST["call_count_target"]))	{$call_count_target=$_POST["call_count_target"];}
if (isset($_GET["completed"]))			{$completed=$_GET["completed"];}
	elseif (isset($_POST["completed"]))	{$completed=$_POST["completed"];}
if (isset($_GET["expanded_list_stats"]))			{$expanded_list_stats=$_GET["expanded_list_stats"];}
	elseif (isset($_POST["expanded_list_stats"]))	{$expanded_list_stats=$_POST["expanded_list_stats"];}
if (isset($_GET["report_option"]))			{$report_option=$_GET["report_option"];}
	elseif (isset($_POST["report_option"]))	{$report_option=$_POST["report_option"];}
if (isset($_GET["preset_contact_search"]))			{$preset_contact_search=$_GET["preset_contact_search"];}
	elseif (isset($_POST["preset_contact_search"]))	{$preset_contact_search=$_POST["preset_contact_search"];}
if (isset($_GET["contacts_enabled"]))			{$contacts_enabled=$_GET["contacts_enabled"];}
	elseif (isset($_POST["contacts_enabled"]))	{$contacts_enabled=$_POST["contacts_enabled"];}
if (isset($_GET["contact_id"]))				{$contact_id=$_GET["contact_id"];}
	elseif (isset($_POST["contact_id"]))	{$contact_id=$_POST["contact_id"];}
if (isset($_GET["first_name"]))				{$first_name=$_GET["first_name"];}
	elseif (isset($_POST["first_name"]))	{$first_name=$_POST["first_name"];}
if (isset($_GET["last_name"]))				{$last_name=$_GET["last_name"];}
	elseif (isset($_POST["last_name"]))		{$last_name=$_POST["last_name"];}
if (isset($_GET["office_num"]))				{$office_num=$_GET["office_num"];}
	elseif (isset($_POST["office_num"]))	{$office_num=$_POST["office_num"];}
if (isset($_GET["cell_num"]))				{$cell_num=$_GET["cell_num"];}
	elseif (isset($_POST["cell_num"]))		{$cell_num=$_POST["cell_num"];}
if (isset($_GET["other_num1"]))				{$other_num1=$_GET["other_num1"];}
	elseif (isset($_POST["other_num1"]))	{$other_num1=$_POST["other_num1"];}
if (isset($_GET["other_num2"]))				{$other_num2=$_GET["other_num2"];}
	elseif (isset($_POST["other_num2"]))	{$other_num2=$_POST["other_num2"];}
if (isset($_GET["modify_contacts"]))			{$modify_contacts=$_GET["modify_contacts"];}
	elseif (isset($_POST["modify_contacts"]))	{$modify_contacts=$_POST["modify_contacts"];}
if (isset($_GET["bu_name"]))			{$bu_name=$_GET["bu_name"];}
	elseif (isset($_POST["bu_name"]))	{$bu_name=$_POST["bu_name"];}
if (isset($_GET["department"]))				{$department=$_GET["department"];}
	elseif (isset($_POST["department"]))	{$department=$_POST["department"];}
if (isset($_GET["job_title"]))			{$job_title=$_GET["job_title"];}
	elseif (isset($_POST["job_title"]))	{$job_title=$_POST["job_title"];}
if (isset($_GET["location"]))			{$location=$_GET["location"];}
	elseif (isset($_POST["location"]))	{$location=$_POST["location"];}
if (isset($_GET["callback_hours_block"]))			{$callback_hours_block=$_GET["callback_hours_block"];}
	elseif (isset($_POST["callback_hours_block"]))	{$callback_hours_block=$_POST["callback_hours_block"];}
if (isset($_GET["callback_list_calltime"]))				{$callback_list_calltime=$_GET["callback_list_calltime"];}
	elseif (isset($_POST["callback_list_calltime"]))	{$callback_list_calltime=$_POST["callback_list_calltime"];}
if (isset($_GET["modify_same_user_level"]))				{$modify_same_user_level=$_GET["modify_same_user_level"];}
	elseif (isset($_POST["modify_same_user_level"]))	{$modify_same_user_level=$_POST["modify_same_user_level"];}
if (isset($_GET["admin_hide_lead_data"]))			{$admin_hide_lead_data=$_GET["admin_hide_lead_data"];}
	elseif (isset($_POST["admin_hide_lead_data"]))	{$admin_hide_lead_data=$_POST["admin_hide_lead_data"];}
if (isset($_GET["admin_hide_phone_data"]))			{$admin_hide_phone_data=$_GET["admin_hide_phone_data"];}
	elseif (isset($_POST["admin_hide_phone_data"]))	{$admin_hide_phone_data=$_POST["admin_hide_phone_data"];}
if (isset($_GET["admin_viewable_groups"]))			{$admin_viewable_groups=$_GET["admin_viewable_groups"];}
	elseif (isset($_POST["admin_viewable_groups"]))	{$admin_viewable_groups=$_POST["admin_viewable_groups"];}
if (isset($_GET["admin_viewable_call_times"]))			{$admin_viewable_call_times=$_GET["admin_viewable_call_times"];}
	elseif (isset($_POST["admin_viewable_call_times"]))	{$admin_viewable_call_times=$_POST["admin_viewable_call_times"];}
if (isset($_GET["max_calls_method"]))			{$max_calls_method=$_GET["max_calls_method"];}
	elseif (isset($_POST["max_calls_method"]))	{$max_calls_method=$_POST["max_calls_method"];}
if (isset($_GET["max_calls_count"]))			{$max_calls_count=$_GET["max_calls_count"];}
	elseif (isset($_POST["max_calls_count"]))	{$max_calls_count=$_POST["max_calls_count"];}
if (isset($_GET["max_calls_action"]))			{$max_calls_action=$_GET["max_calls_action"];}
	elseif (isset($_POST["max_calls_action"]))	{$max_calls_action=$_POST["max_calls_action"];}
if (isset($_GET["territory_reset"]))			{$territory_reset=$_GET["territory_reset"];}
	elseif (isset($_POST["territory_reset"]))	{$territory_reset=$_POST["territory_reset"];}
if (isset($_GET["hopper_vlc_dup_check"]))			{$hopper_vlc_dup_check=$_GET["hopper_vlc_dup_check"];}
	elseif (isset($_POST["hopper_vlc_dup_check"]))	{$hopper_vlc_dup_check=$_POST["hopper_vlc_dup_check"];}
if (isset($_GET["download_max_system_stats_metric"]))			{$download_max_system_stats_metric=$_GET["download_max_system_stats_metric"];}
	elseif (isset($_POST["download_max_system_stats_metric"]))	{$download_max_system_stats_metric=$_POST["download_max_system_stats_metric"];}
if (isset($_GET["download_max_system_stats_metric_name"]))			{$download_max_system_stats_metric_name=$_GET["download_max_system_stats_metric_name"];}
	elseif (isset($_POST["download_max_system_stats_metric_name"]))	{$download_max_system_stats_metric_name=$_POST["download_max_system_stats_metric_name"];}
if (isset($_GET["inventory_report"]))			{$inventory_report=$_GET["inventory_report"];}
	elseif (isset($_POST["inventory_report"]))	{$inventory_report=$_POST["inventory_report"];}
if (isset($_GET["report_rank"]))			{$report_rank=$_GET["report_rank"];}
	elseif (isset($_POST["report_rank"]))	{$report_rank=$_POST["report_rank"];}
if (isset($_GET["in_group_dial"]))			{$in_group_dial=$_GET["in_group_dial"];}
	elseif (isset($_POST["in_group_dial"]))	{$in_group_dial=$_POST["in_group_dial"];}
if (isset($_GET["in_group_dial_select"]))			{$in_group_dial_select=$_GET["in_group_dial_select"];}
	elseif (isset($_POST["in_group_dial_select"]))	{$in_group_dial_select=$_POST["in_group_dial_select"];}
if (isset($_GET["dial_ingroup_cid"]))			{$dial_ingroup_cid=$_GET["dial_ingroup_cid"];}
	elseif (isset($_POST["dial_ingroup_cid"]))	{$dial_ingroup_cid=$_POST["dial_ingroup_cid"];}
if (isset($_GET["allow_emails"]))			{$allow_emails=$_GET["allow_emails"];}
	elseif (isset($_POST["allow_emails"]))	{$allow_emails=$_POST["allow_emails"];}
if (isset($_GET["allow_chats"]))			{$allow_chats=$_GET["allow_chats"];}
	elseif (isset($_POST["allow_chats"]))	{$allow_chats=$_POST["allow_chats"];}
if (isset($_GET["chat_url"]))			{$chat_url=$_GET["chat_url"];}
	elseif (isset($_POST["chat_url"]))	{$chat_url=$_POST["chat_url"];}
if (isset($_GET["chat_timeout"]))			{$chat_timeout=$_GET["chat_timeout"];}
	elseif (isset($_POST["chat_timeout"]))	{$chat_timeout=$_POST["chat_timeout"];}
if (isset($_GET["manager_chat_id"]))			{$manager_chat_id=$_GET["manager_chat_id"];}
	elseif (isset($_POST["manager_chat_id"]))	{$manager_chat_id=$_POST["manager_chat_id"];}
if (isset($_GET["group_handling"]))			{$group_handling=$_GET["group_handling"];}
	elseif (isset($_POST["group_handling"]))	{$group_handling=$_POST["group_handling"];}
if (isset($_GET["agentcall_email"]))			{$agentcall_email=$_GET["agentcall_email"];}
	elseif (isset($_POST["agentcall_email"]))	{$agentcall_email=$_POST["agentcall_email"];}
if (isset($_GET["agentcall_chat"]))			{$agentcall_chat=$_GET["agentcall_chat"];}
	elseif (isset($_POST["agentcall_chat"]))	{$agentcall_chat=$_POST["agentcall_chat"];}
if (isset($_GET["modify_email_accounts"]))			{$modify_email_accounts=$_GET["modify_email_accounts"];}
	elseif (isset($_POST["modify_email_accounts"]))	{$modify_email_accounts=$_POST["modify_email_accounts"];}
if (isset($_GET["safe_harbor_audio_field"]))			{$safe_harbor_audio_field=$_GET["safe_harbor_audio_field"];}
	elseif (isset($_POST["safe_harbor_audio_field"]))	{$safe_harbor_audio_field=$_POST["safe_harbor_audio_field"];}
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["call_menu_qualify_enabled"]))			{$call_menu_qualify_enabled=$_GET["call_menu_qualify_enabled"];}
	elseif (isset($_POST["call_menu_qualify_enabled"]))	{$call_menu_qualify_enabled=$_POST["call_menu_qualify_enabled"];}
if (isset($_GET["qualify_sql"]))			{$qualify_sql=$_GET["qualify_sql"];}
	elseif (isset($_POST["qualify_sql"]))	{$qualify_sql=$_POST["qualify_sql"];}
if (isset($_GET["admin_list_counts"]))			{$admin_list_counts=$_GET["admin_list_counts"];}
	elseif (isset($_POST["admin_list_counts"]))	{$admin_list_counts=$_POST["admin_list_counts"];}
if (isset($_GET["voicemail_greeting"]))				{$voicemail_greeting=$_GET["voicemail_greeting"];}
	elseif (isset($_POST["voicemail_greeting"]))	{$voicemail_greeting=$_POST["voicemail_greeting"];}
if (isset($_GET["old_voicemail_greeting"]))				{$old_voicemail_greeting=$_GET["old_voicemail_greeting"];}
	elseif (isset($_POST["old_voicemail_greeting"]))	{$old_voicemail_greeting=$_POST["old_voicemail_greeting"];}
if (isset($_GET["allow_voicemail_greeting"]))			{$allow_voicemail_greeting=$_GET["allow_voicemail_greeting"];}
	elseif (isset($_POST["allow_voicemail_greeting"]))	{$allow_voicemail_greeting=$_POST["allow_voicemail_greeting"];}
if (isset($_GET["show_vm_on_summary"]))			{$show_vm_on_summary=$_GET["show_vm_on_summary"];}
	elseif (isset($_POST["show_vm_on_summary"]))	{$show_vm_on_summary=$_POST["show_vm_on_summary"];}
if (isset($_GET["pause_after_next_call"]))			{$pause_after_next_call=$_GET["pause_after_next_call"];}
	elseif (isset($_POST["pause_after_next_call"]))	{$pause_after_next_call=$_POST["pause_after_next_call"];}
if (isset($_GET["owner_populate"]))				{$owner_populate=$_GET["owner_populate"];}
	elseif (isset($_POST["owner_populate"]))	{$owner_populate=$_POST["owner_populate"];}
if (isset($_GET["queuemetrics_socket"]))			{$queuemetrics_socket=$_GET["queuemetrics_socket"];}
	elseif (isset($_POST["queuemetrics_socket"]))	{$queuemetrics_socket=$_POST["queuemetrics_socket"];}
if (isset($_GET["queuemetrics_socket_url"]))			{$queuemetrics_socket_url=$_GET["queuemetrics_socket_url"];}
	elseif (isset($_POST["queuemetrics_socket_url"]))	{$queuemetrics_socket_url=$_POST["queuemetrics_socket_url"];}
if (isset($_GET["holiday_id"]))					{$holiday_id=$_GET["holiday_id"];}
	elseif (isset($_POST["holiday_id"]))		{$holiday_id=$_POST["holiday_id"];}
if (isset($_GET["holiday_name"]))				{$holiday_name=$_GET["holiday_name"];}
	elseif (isset($_POST["holiday_name"]))		{$holiday_name=$_POST["holiday_name"];}
if (isset($_GET["holiday_comments"]))			{$holiday_comments=$_GET["holiday_comments"];}
	elseif (isset($_POST["holiday_comments"]))	{$holiday_comments=$_POST["holiday_comments"];}
if (isset($_GET["holiday_date"]))				{$holiday_date=$_GET["holiday_date"];}
	elseif (isset($_POST["holiday_date"]))		{$holiday_date=$_POST["holiday_date"];}
if (isset($_GET["holiday_status"]))				{$holiday_status=$_GET["holiday_status"];}
	elseif (isset($_POST["holiday_status"]))	{$holiday_status=$_POST["holiday_status"];}
if (isset($_GET["holiday_rule"]))				{$holiday_rule=$_GET["holiday_rule"];}
	elseif (isset($_POST["holiday_rule"]))		{$holiday_rule=$_POST["holiday_rule"];}
if (isset($_GET["expiration_date"]))			{$expiration_date=$_GET["expiration_date"];}
	elseif (isset($_POST["expiration_date"]))	{$expiration_date=$_POST["expiration_date"];}
if (isset($_GET["use_other_campaign_dnc"]))				{$use_other_campaign_dnc=$_GET["use_other_campaign_dnc"];}
	elseif (isset($_POST["use_other_campaign_dnc"]))	{$use_other_campaign_dnc=$_POST["use_other_campaign_dnc"];}
if (isset($_GET["enhanced_disconnect_logging"]))			{$enhanced_disconnect_logging=$_GET["enhanced_disconnect_logging"];}
	elseif (isset($_POST["enhanced_disconnect_logging"]))	{$enhanced_disconnect_logging=$_POST["enhanced_disconnect_logging"];}
if (isset($_GET["amd_inbound_group"]))			{$amd_inbound_group=$_GET["amd_inbound_group"];}
	elseif (isset($_POST["amd_inbound_group"]))	{$amd_inbound_group=$_POST["amd_inbound_group"];}
if (isset($_GET["amd_callmenu"]))				{$amd_callmenu=$_GET["amd_callmenu"];}
	elseif (isset($_POST["amd_callmenu"]))		{$amd_callmenu=$_POST["amd_callmenu"];}
if (isset($_GET["level_8_disable_add"]))			{$level_8_disable_add=$_GET["level_8_disable_add"];}
	elseif (isset($_POST["level_8_disable_add"]))	{$level_8_disable_add=$_POST["level_8_disable_add"];}
if (isset($_GET["survey_wait_sec"]))			{$survey_wait_sec=$_GET["survey_wait_sec"];}
	elseif (isset($_POST["survey_wait_sec"]))	{$survey_wait_sec=$_POST["survey_wait_sec"];}
if (isset($_GET["queuemetrics_record_hold"]))			{$queuemetrics_record_hold=$_GET["queuemetrics_record_hold"];}
	elseif (isset($_POST["queuemetrics_record_hold"]))	{$queuemetrics_record_hold=$_POST["queuemetrics_record_hold"];}
if (isset($_GET["country_code_list_stats"]))			{$country_code_list_stats=$_GET["country_code_list_stats"];}
	elseif (isset($_POST["country_code_list_stats"]))	{$country_code_list_stats=$_POST["country_code_list_stats"];}
if (isset($_GET["manual_dial_lead_id"]))			{$manual_dial_lead_id=$_GET["manual_dial_lead_id"];}
	elseif (isset($_POST["manual_dial_lead_id"]))	{$manual_dial_lead_id=$_POST["manual_dial_lead_id"];}
if (isset($_GET["auto_restart_asterisk"]))			{$auto_restart_asterisk=$_GET["auto_restart_asterisk"];}
	elseif (isset($_POST["auto_restart_asterisk"]))	{$auto_restart_asterisk=$_POST["auto_restart_asterisk"];}
if (isset($_GET["asterisk_temp_no_restart"]))			{$asterisk_temp_no_restart=$_GET["asterisk_temp_no_restart"];}
	elseif (isset($_POST["asterisk_temp_no_restart"]))	{$asterisk_temp_no_restart=$_POST["asterisk_temp_no_restart"];}
if (isset($_GET["dead_max"]))					{$dead_max=$_GET["dead_max"];}
	elseif (isset($_POST["dead_max"]))			{$dead_max=$_POST["dead_max"];}
if (isset($_GET["dispo_max"]))					{$dispo_max=$_GET["dispo_max"];}
	elseif (isset($_POST["dispo_max"]))			{$dispo_max=$_POST["dispo_max"];}
if (isset($_GET["pause_max"]))					{$pause_max=$_GET["pause_max"];}
	elseif (isset($_POST["pause_max"]))			{$pause_max=$_POST["pause_max"];}
if (isset($_GET["dead_max_dispo"]))				{$dead_max_dispo=$_GET["dead_max_dispo"];}
	elseif (isset($_POST["dead_max_dispo"]))	{$dead_max_dispo=$_POST["dead_max_dispo"];}
if (isset($_GET["dispo_max_dispo"]))			{$dispo_max_dispo=$_GET["dispo_max_dispo"];}
	elseif (isset($_POST["dispo_max_dispo"]))	{$dispo_max_dispo=$_POST["dispo_max_dispo"];}
if (isset($_GET["voicemail_dump_exten_no_inst"]))			{$voicemail_dump_exten_no_inst=$_GET["voicemail_dump_exten_no_inst"];}
	elseif (isset($_POST["voicemail_dump_exten_no_inst"]))	{$voicemail_dump_exten_no_inst=$_POST["voicemail_dump_exten_no_inst"];}
if (isset($_GET["voicemail_instructions"]))				{$voicemail_instructions=$_GET["voicemail_instructions"];}
	elseif (isset($_POST["voicemail_instructions"]))	{$voicemail_instructions=$_POST["voicemail_instructions"];}
if (isset($_GET["alter_admin_interface_options"]))			{$alter_admin_interface_options=$_GET["alter_admin_interface_options"];}
	elseif (isset($_POST["alter_admin_interface_options"]))	{$alter_admin_interface_options=$_POST["alter_admin_interface_options"];}
if (isset($_GET["filter_dnc_campaign"]))			{$filter_dnc_campaign=$_GET["filter_dnc_campaign"];}
	elseif (isset($_POST["filter_dnc_campaign"]))	{$filter_dnc_campaign=$_POST["filter_dnc_campaign"];}
if (isset($_GET["filter_url_did_redirect"]))			{$filter_url_did_redirect=$_GET["filter_url_did_redirect"];}
	elseif (isset($_POST["filter_url_did_redirect"]))	{$filter_url_did_redirect=$_POST["filter_url_did_redirect"];}
if (isset($_GET["max_inbound_calls"]))			{$max_inbound_calls=$_GET["max_inbound_calls"];}
	elseif (isset($_POST["max_inbound_calls"]))	{$max_inbound_calls=$_POST["max_inbound_calls"];}
if (isset($_GET["manual_dial_search_checkbox"]))			{$manual_dial_search_checkbox=$_GET["manual_dial_search_checkbox"];}
	elseif (isset($_POST["manual_dial_search_checkbox"]))	{$manual_dial_search_checkbox=$_POST["manual_dial_search_checkbox"];}
if (isset($_GET["hide_call_log_info"]))				{$hide_call_log_info=$_GET["hide_call_log_info"];}
	elseif (isset($_POST["hide_call_log_info"]))	{$hide_call_log_info=$_POST["hide_call_log_info"];}
if (isset($_GET["modify_custom_dialplans"]))			{$modify_custom_dialplans=$_GET["modify_custom_dialplans"];}
	elseif (isset($_POST["modify_custom_dialplans"]))	{$modify_custom_dialplans=$_POST["modify_custom_dialplans"];}
if (isset($_GET["queuemetrics_pause_type"]))			{$queuemetrics_pause_type=$_GET["queuemetrics_pause_type"];}
	elseif (isset($_POST["queuemetrics_pause_type"]))	{$queuemetrics_pause_type=$_POST["queuemetrics_pause_type"];}
if (isset($_GET["frozen_server_call_clear"]))			{$frozen_server_call_clear=$_GET["frozen_server_call_clear"];}
	elseif (isset($_POST["frozen_server_call_clear"]))	{$frozen_server_call_clear=$_POST["frozen_server_call_clear"];}
if (isset($_GET["timer_alt_seconds"]))			{$timer_alt_seconds=$_GET["timer_alt_seconds"];}
	elseif (isset($_POST["timer_alt_seconds"]))	{$timer_alt_seconds=$_POST["timer_alt_seconds"];}
if (isset($_GET["wrapup_seconds_override"]))			{$wrapup_seconds_override=$_GET["wrapup_seconds_override"];}
	elseif (isset($_POST["wrapup_seconds_override"]))	{$wrapup_seconds_override=$_POST["wrapup_seconds_override"];}
if (isset($_GET["no_agent_ingroup_redirect"]))			{$no_agent_ingroup_redirect=$_GET["no_agent_ingroup_redirect"];}
	elseif (isset($_POST["no_agent_ingroup_redirect"]))	{$no_agent_ingroup_redirect=$_POST["no_agent_ingroup_redirect"];}
if (isset($_GET["no_agent_ingroup_id"]))			{$no_agent_ingroup_id=$_GET["no_agent_ingroup_id"];}
	elseif (isset($_POST["no_agent_ingroup_id"]))	{$no_agent_ingroup_id=$_POST["no_agent_ingroup_id"];}
if (isset($_GET["no_agent_ingroup_extension"]))			{$no_agent_ingroup_extension=$_GET["no_agent_ingroup_extension"];}
	elseif (isset($_POST["no_agent_ingroup_extension"]))	{$no_agent_ingroup_extension=$_POST["no_agent_ingroup_extension"];}
if (isset($_GET["pre_filter_phone_group_id"]))			{$pre_filter_phone_group_id=$_GET["pre_filter_phone_group_id"];}
	elseif (isset($_POST["pre_filter_phone_group_id"]))	{$pre_filter_phone_group_id=$_POST["pre_filter_phone_group_id"];}
if (isset($_GET["pre_filter_extension"]))			{$pre_filter_extension=$_GET["pre_filter_extension"];}
	elseif (isset($_POST["pre_filter_extension"]))	{$pre_filter_extension=$_POST["pre_filter_extension"];}
if (isset($_GET["wrapup_bypass"]))			{$wrapup_bypass=$_GET["wrapup_bypass"];}
	elseif (isset($_POST["wrapup_bypass"]))	{$wrapup_bypass=$_POST["wrapup_bypass"];}
if (isset($_GET["wrapup_after_hotkey"]))			{$wrapup_after_hotkey=$_GET["wrapup_after_hotkey"];}
	elseif (isset($_POST["wrapup_after_hotkey"]))	{$wrapup_after_hotkey=$_POST["wrapup_after_hotkey"];}
if (isset($_GET["callback_time_24hour"]))			{$callback_time_24hour=$_GET["callback_time_24hour"];}
	elseif (isset($_POST["callback_time_24hour"]))	{$callback_time_24hour=$_POST["callback_time_24hour"];}
if (isset($_GET["callback_active_limit"]))			{$callback_active_limit=$_GET["callback_active_limit"];}
	elseif (isset($_POST["callback_active_limit"]))	{$callback_active_limit=$_POST["callback_active_limit"];}
if (isset($_GET["callback_active_limit_override"]))				{$callback_active_limit_override=$_GET["callback_active_limit_override"];}
	elseif (isset($_POST["callback_active_limit_override"]))	{$callback_active_limit_override=$_POST["callback_active_limit_override"];}
if (isset($_GET["comments_all_tabs"]))			{$comments_all_tabs=$_GET["comments_all_tabs"];}
	elseif (isset($_POST["comments_all_tabs"]))	{$comments_all_tabs=$_POST["comments_all_tabs"];}
if (isset($_GET["comments_dispo_screen"]))			{$comments_dispo_screen=$_GET["comments_dispo_screen"];}
	elseif (isset($_POST["comments_dispo_screen"]))	{$comments_dispo_screen=$_POST["comments_dispo_screen"];}
if (isset($_GET["comments_callback_screen"]))			{$comments_callback_screen=$_GET["comments_callback_screen"];}
	elseif (isset($_POST["comments_callback_screen"]))	{$comments_callback_screen=$_POST["comments_callback_screen"];}
if (isset($_GET["qc_comment_history"]))				{$qc_comment_history=$_GET["qc_comment_history"];}
	elseif (isset($_POST["qc_comment_history"]))	{$qc_comment_history=$_POST["qc_comment_history"];}
if (isset($_GET["show_previous_callback"]))				{$show_previous_callback=$_GET["show_previous_callback"];}
	elseif (isset($_POST["show_previous_callback"]))	{$show_previous_callback=$_POST["show_previous_callback"];}
if (isset($_GET["clear_script"]))				{$clear_script=$_GET["clear_script"];}
	elseif (isset($_POST["clear_script"]))	{$clear_script=$_POST["clear_script"];}
if (isset($_GET["modify_languages"]))			{$modify_languages=$_GET["modify_languages"];}
	elseif (isset($_POST["modify_languages"]))	{$modify_languages=$_POST["modify_languages"];}
if (isset($_GET["enable_languages"]))			{$enable_languages=$_GET["enable_languages"];}
	elseif (isset($_POST["enable_languages"]))	{$enable_languages=$_POST["enable_languages"];}
if (isset($_GET["cpd_unknown_action"]))				{$cpd_unknown_action=$_GET["cpd_unknown_action"];}
	elseif (isset($_POST["cpd_unknown_action"]))	{$cpd_unknown_action=$_POST["cpd_unknown_action"];}
if (isset($_GET["selected_language"]))			{$selected_language=$_GET["selected_language"];}
	elseif (isset($_POST["selected_language"]))	{$selected_language=$_POST["selected_language"];}
if (isset($_GET["user_choose_language"]))			{$user_choose_language=$_GET["user_choose_language"];}
	elseif (isset($_POST["user_choose_language"]))	{$user_choose_language=$_POST["user_choose_language"];}
if (isset($_GET["language_method"]))			{$language_method=$_GET["language_method"];}
	elseif (isset($_POST["language_method"]))	{$language_method=$_POST["language_method"];}
if (isset($_GET["ignore_group_on_search"]))				{$ignore_group_on_search=$_GET["ignore_group_on_search"];}
	elseif (isset($_POST["ignore_group_on_search"]))	{$ignore_group_on_search=$_POST["ignore_group_on_search"];}
if (isset($_GET["manual_dial_search_filter"]))			{$manual_dial_search_filter=$_GET["manual_dial_search_filter"];}
	elseif (isset($_POST["manual_dial_search_filter"]))	{$manual_dial_search_filter=$_POST["manual_dial_search_filter"];}
if (isset($_GET["meetme_enter_login_filename"]))			{$meetme_enter_login_filename=$_GET["meetme_enter_login_filename"];}
	elseif (isset($_POST["meetme_enter_login_filename"]))	{$meetme_enter_login_filename=$_POST["meetme_enter_login_filename"];}
if (isset($_GET["meetme_enter_leave3way_filename"]))			{$meetme_enter_leave3way_filename=$_GET["meetme_enter_leave3way_filename"];}
	elseif (isset($_POST["meetme_enter_leave3way_filename"]))	{$meetme_enter_leave3way_filename=$_POST["meetme_enter_leave3way_filename"];}
if (isset($_GET["enable_did_entry_list_id"]))			{$enable_did_entry_list_id=$_GET["enable_did_entry_list_id"];}
	elseif (isset($_POST["enable_did_entry_list_id"]))	{$enable_did_entry_list_id=$_POST["enable_did_entry_list_id"];}
if (isset($_GET["entry_list_id"]))			{$entry_list_id=$_GET["entry_list_id"];}
	elseif (isset($_POST["entry_list_id"]))	{$entry_list_id=$_POST["entry_list_id"];}
if (isset($_GET["filter_entry_list_id"]))			{$filter_entry_list_id=$_GET["filter_entry_list_id"];}
	elseif (isset($_POST["filter_entry_list_id"]))	{$filter_entry_list_id=$_POST["filter_entry_list_id"];}
if (isset($_GET["allow_chats"]))			{$allow_chats=$_GET["allow_chats"];}
	elseif (isset($_POST["allow_chats"]))	{$allow_chats=$_POST["allow_chats"];}
if (isset($_GET["enable_third_webform"]))			{$enable_third_webform=$_GET["enable_third_webform"];}
	elseif (isset($_POST["enable_third_webform"]))	{$enable_third_webform=$_POST["enable_third_webform"];}
if (isset($_GET["web_form_address_three"]))			{$web_form_address_three=$_GET["web_form_address_three"];}
	elseif (isset($_POST["web_form_address_three"]))	{$web_form_address_three=$_POST["web_form_address_three"];}
if (isset($_GET["enable_international_dncs"]))			{$enable_international_dncs=$_GET["enable_international_dncs"];}
	elseif (isset($_POST["enable_international_dncs"]))	{$enable_international_dncs=$_POST["enable_international_dncs"];}
if (isset($_GET["api_list_restrict"]))			{$api_list_restrict=$_GET["api_list_restrict"];}
	elseif (isset($_POST["api_list_restrict"]))	{$api_list_restrict=$_POST["api_list_restrict"];}
if (isset($_GET["api_allowed_functions"]))			{$api_allowed_functions=$_GET["api_allowed_functions"];}
	elseif (isset($_POST["api_allowed_functions"]))	{$api_allowed_functions=$_POST["api_allowed_functions"];}
if (isset($_GET["manual_dial_override_field"]))			{$manual_dial_override_field=$_GET["manual_dial_override_field"];}
	elseif (isset($_POST["manual_dial_override_field"]))	{$manual_dial_override_field=$_POST["manual_dial_override_field"];}
if (isset($_GET["status_display_ingroup"]))			{$status_display_ingroup=$_GET["status_display_ingroup"];}
	elseif (isset($_POST["status_display_ingroup"]))	{$status_display_ingroup=$_POST["status_display_ingroup"];}
if (isset($_GET["populate_lead_ingroup"]))			{$populate_lead_ingroup=$_GET["populate_lead_ingroup"];}
	elseif (isset($_POST["populate_lead_ingroup"]))	{$populate_lead_ingroup=$_POST["populate_lead_ingroup"];}
if (isset($_GET["script_color"]))			{$script_color=$_GET["script_color"];}
	elseif (isset($_POST["script_color"]))	{$script_color=$_POST["script_color"];}
if (isset($_GET["customer_gone_seconds"]))			{$customer_gone_seconds=$_GET["customer_gone_seconds"];}
	elseif (isset($_POST["customer_gone_seconds"]))	{$customer_gone_seconds=$_POST["customer_gone_seconds"];}
if (isset($_GET["max_queue_ingroup_calls"]))			{$max_queue_ingroup_calls=$_GET["max_queue_ingroup_calls"];}
	elseif (isset($_POST["max_queue_ingroup_calls"]))	{$max_queue_ingroup_calls=$_POST["max_queue_ingroup_calls"];}
if (isset($_GET["max_queue_ingroup_id"]))			{$max_queue_ingroup_id=$_GET["max_queue_ingroup_id"];}
	elseif (isset($_POST["max_queue_ingroup_id"]))	{$max_queue_ingroup_id=$_POST["max_queue_ingroup_id"];}
if (isset($_GET["max_queue_ingroup_extension"]))			{$max_queue_ingroup_extension=$_GET["max_queue_ingroup_extension"];}
	elseif (isset($_POST["max_queue_ingroup_extension"]))	{$max_queue_ingroup_extension=$_POST["max_queue_ingroup_extension"];}
if (isset($_GET["agent_debug_logging"]))			{$agent_debug_logging=$_GET["agent_debug_logging"];}
	elseif (isset($_POST["agent_debug_logging"]))	{$agent_debug_logging=$_POST["agent_debug_logging"];}
if (isset($_GET["agent_display_fields"]))			{$agent_display_fields=$_GET["agent_display_fields"];}
	elseif (isset($_POST["agent_display_fields"]))	{$agent_display_fields=$_POST["agent_display_fields"];}
if (isset($_GET["default_language"]))			{$default_language=$_GET["default_language"];}
	elseif (isset($_POST["default_language"]))	{$default_language=$_POST["default_language"];}
if (isset($_GET["agent_whisper_enabled"]))			{$agent_whisper_enabled=$_GET["agent_whisper_enabled"];}
	elseif (isset($_POST["agent_whisper_enabled"]))	{$agent_whisper_enabled=$_POST["agent_whisper_enabled"];}
if (isset($_GET["drop_lead_reset"]))			{$drop_lead_reset=$_GET["drop_lead_reset"];}
	elseif (isset($_POST["drop_lead_reset"]))	{$drop_lead_reset=$_POST["drop_lead_reset"];}
if (isset($_GET["after_hours_lead_reset"]))				{$after_hours_lead_reset=$_GET["after_hours_lead_reset"];}
	elseif (isset($_POST["after_hours_lead_reset"]))	{$after_hours_lead_reset=$_POST["after_hours_lead_reset"];}
if (isset($_GET["nanq_lead_reset"]))			{$nanq_lead_reset=$_GET["nanq_lead_reset"];}
	elseif (isset($_POST["nanq_lead_reset"]))	{$nanq_lead_reset=$_POST["nanq_lead_reset"];}
if (isset($_GET["wait_time_lead_reset"]))			{$wait_time_lead_reset=$_GET["wait_time_lead_reset"];}
	elseif (isset($_POST["wait_time_lead_reset"]))	{$wait_time_lead_reset=$_POST["wait_time_lead_reset"];}
if (isset($_GET["hold_time_lead_reset"]))			{$hold_time_lead_reset=$_GET["hold_time_lead_reset"];}
	elseif (isset($_POST["hold_time_lead_reset"]))	{$hold_time_lead_reset=$_POST["hold_time_lead_reset"];}
if (isset($_GET["container_id"]))			{$container_id=$_GET["container_id"];}
	elseif (isset($_POST["container_id"]))	{$container_id=$_POST["container_id"];}
if (isset($_GET["container_notes"]))			{$container_notes=$_GET["container_notes"];}
	elseif (isset($_POST["container_notes"]))	{$container_notes=$_POST["container_notes"];}
if (isset($_GET["container_type"]))				{$container_type=$_GET["container_type"];}
	elseif (isset($_POST["container_type"]))	{$container_type=$_POST["container_type"];}
if (isset($_GET["container_entry"]))			{$container_entry=$_GET["container_entry"];}
	elseif (isset($_POST["container_entry"]))	{$container_entry=$_POST["container_entry"];}
if (isset($_GET["admin_cf_show_hidden"]))			{$admin_cf_show_hidden=$_GET["admin_cf_show_hidden"];}
	elseif (isset($_POST["admin_cf_show_hidden"]))	{$admin_cf_show_hidden=$_POST["admin_cf_show_hidden"];}
if (isset($_GET["user_hide_realtime_enabled"]))				{$user_hide_realtime_enabled=$_GET["user_hide_realtime_enabled"];}
	elseif (isset($_POST["user_hide_realtime_enabled"]))	{$user_hide_realtime_enabled=$_POST["user_hide_realtime_enabled"];}
if (isset($_GET["user_hide_realtime"]))				{$user_hide_realtime=$_GET["user_hide_realtime"];}
	elseif (isset($_POST["user_hide_realtime"]))	{$user_hide_realtime=$_POST["user_hide_realtime"];}
if (isset($_GET["did_carrier_description"]))			{$did_carrier_description=$_GET["did_carrier_description"];}
	elseif (isset($_POST["did_carrier_description"]))	{$did_carrier_description=$_POST["did_carrier_description"];}
if (isset($_GET["status_group_id"]))			{$status_group_id=$_GET["status_group_id"];}
	elseif (isset($_POST["status_group_id"]))	{$status_group_id=$_POST["status_group_id"];}
if (isset($_GET["status_group_notes"]))				{$status_group_notes=$_GET["status_group_notes"];}
	elseif (isset($_POST["status_group_notes"]))	{$status_group_notes=$_POST["status_group_notes"];}
if (isset($_GET["min_sec"]))				{$min_sec=$_GET["min_sec"];}
	elseif (isset($_POST["min_sec"]))		{$min_sec=$_POST["min_sec"];}
if (isset($_GET["max_sec"]))				{$max_sec=$_GET["max_sec"];}
	elseif (isset($_POST["max_sec"]))		{$max_sec=$_POST["max_sec"];}
if (isset($_GET["usacan_phone_dialcode_fix"]))				{$usacan_phone_dialcode_fix=$_GET["usacan_phone_dialcode_fix"];}
	elseif (isset($_POST["usacan_phone_dialcode_fix"]))		{$usacan_phone_dialcode_fix=$_POST["usacan_phone_dialcode_fix"];}
if (isset($_GET["am_message_wildcards"]))				{$am_message_wildcards=$_GET["am_message_wildcards"];}
	elseif (isset($_POST["am_message_wildcards"]))		{$am_message_wildcards=$_POST["am_message_wildcards"];}
if (isset($_GET["cache_carrier_stats_realtime"]))				{$cache_carrier_stats_realtime=$_GET["cache_carrier_stats_realtime"];}
	elseif (isset($_POST["cache_carrier_stats_realtime"]))		{$cache_carrier_stats_realtime=$_POST["cache_carrier_stats_realtime"];}
if (isset($_GET["unavail_dialplan_fwd_exten"]))					{$unavail_dialplan_fwd_exten=$_GET["unavail_dialplan_fwd_exten"];}
	elseif (isset($_POST["unavail_dialplan_fwd_exten"]))		{$unavail_dialplan_fwd_exten=$_POST["unavail_dialplan_fwd_exten"];}
if (isset($_GET["unavail_dialplan_fwd_context"]))				{$unavail_dialplan_fwd_context=$_GET["unavail_dialplan_fwd_context"];}
	elseif (isset($_POST["unavail_dialplan_fwd_context"]))		{$unavail_dialplan_fwd_context=$_POST["unavail_dialplan_fwd_context"];}
if (isset($_GET["nva_call_url"]))				{$nva_call_url=$_GET["nva_call_url"];}
	elseif (isset($_POST["nva_call_url"]))		{$nva_call_url=$_POST["nva_call_url"];}
if (isset($_GET["nva_search_method"]))				{$nva_search_method=$_GET["nva_search_method"];}
	elseif (isset($_POST["nva_search_method"]))		{$nva_search_method=$_POST["nva_search_method"];}
if (isset($_GET["nva_error_filename"]))				{$nva_error_filename=$_GET["nva_error_filename"];}
	elseif (isset($_POST["nva_error_filename"]))	{$nva_error_filename=$_POST["nva_error_filename"];}
if (isset($_GET["nva_new_list_id"]))				{$nva_new_list_id=$_GET["nva_new_list_id"];}
	elseif (isset($_POST["nva_new_list_id"]))		{$nva_new_list_id=$_POST["nva_new_list_id"];}
if (isset($_GET["nva_new_phone_code"]))				{$nva_new_phone_code=$_GET["nva_new_phone_code"];}
	elseif (isset($_POST["nva_new_phone_code"]))	{$nva_new_phone_code=$_POST["nva_new_phone_code"];}
if (isset($_GET["nva_new_status"]))					{$nva_new_status=$_GET["nva_new_status"];}
	elseif (isset($_POST["nva_new_status"]))		{$nva_new_status=$_POST["nva_new_status"];}
if (isset($_GET["gather_asterisk_output"]))				{$gather_asterisk_output=$_GET["gather_asterisk_output"];}
	elseif (isset($_POST["gather_asterisk_output"]))	{$gather_asterisk_output=$_POST["gather_asterisk_output"];}
if (isset($_GET["manual_dial_timeout"]))			{$manual_dial_timeout=$_GET["manual_dial_timeout"];}
	elseif (isset($_POST["manual_dial_timeout"]))	{$manual_dial_timeout=$_POST["manual_dial_timeout"];}
if (isset($_GET["agent_allowed_chat_groups"]))			{$agent_allowed_chat_groups=$_GET["agent_allowed_chat_groups"];}
	elseif (isset($_POST["agent_allowed_chat_groups"]))	{$agent_allowed_chat_groups=$_POST["agent_allowed_chat_groups"];}
if (isset($_GET["routing_initiated_recordings"]))			{$routing_initiated_recordings=$_GET["routing_initiated_recordings"];}
	elseif (isset($_POST["routing_initiated_recordings"]))	{$routing_initiated_recordings=$_POST["routing_initiated_recordings"];}
if (isset($_GET["on_hook_cid_number"]))				{$on_hook_cid_number=$_GET["on_hook_cid_number"];}
	elseif (isset($_POST["on_hook_cid_number"]))	{$on_hook_cid_number=$_POST["on_hook_cid_number"];}
if (isset($_GET["manual_dial_hopper_check"]))			{$manual_dial_hopper_check=$_GET["manual_dial_hopper_check"];}
	elseif (isset($_POST["manual_dial_hopper_check"]))	{$manual_dial_hopper_check=$_POST["manual_dial_hopper_check"];}
if (isset($_GET["report_default_format"]))			{$report_default_format=$_GET["report_default_format"];}
	elseif (isset($_POST["report_default_format"]))	{$report_default_format=$_POST["report_default_format"];}
if (isset($_GET["alt_ivr_logging"]))				{$alt_ivr_logging=$_GET["alt_ivr_logging"];}
	elseif (isset($_POST["alt_ivr_logging"]))		{$alt_ivr_logging=$_POST["alt_ivr_logging"];}
if (isset($_GET["question"]))						{$question=$_GET["question"];}
	elseif (isset($_POST["question"]))				{$question=$_POST["question"];}
if (isset($_GET["alt_dtmf_log"]))					{$alt_dtmf_log=$_GET["alt_dtmf_log"];}
	elseif (isset($_POST["alt_dtmf_log"]))			{$alt_dtmf_log=$_POST["alt_dtmf_log"];}
if (isset($_GET["web_socket_url"]))					{$web_socket_url=$_GET["web_socket_url"];}
	elseif (isset($_POST["web_socket_url"]))		{$web_socket_url=$_POST["web_socket_url"];}
if (isset($_GET["webphone_dialbox"]))				{$webphone_dialbox=$_GET["webphone_dialbox"];}
	elseif (isset($_POST["webphone_dialbox"]))		{$webphone_dialbox=$_POST["webphone_dialbox"];}
if (isset($_GET["webphone_mute"]))					{$webphone_mute=$_GET["webphone_mute"];}
	elseif (isset($_POST["webphone_mute"]))			{$webphone_mute=$_POST["webphone_mute"];}
if (isset($_GET["webphone_volume"]))				{$webphone_volume=$_GET["webphone_volume"];}
	elseif (isset($_POST["webphone_volume"]))		{$webphone_volume=$_POST["webphone_volume"];}
if (isset($_GET["webphone_debug"]))					{$webphone_debug=$_GET["webphone_debug"];}
	elseif (isset($_POST["webphone_debug"]))		{$webphone_debug=$_POST["webphone_debug"];}
if (isset($_GET["callback_useronly_move_minutes"]))				{$callback_useronly_move_minutes=$_GET["callback_useronly_move_minutes"];}
	elseif (isset($_POST["callback_useronly_move_minutes"]))	{$callback_useronly_move_minutes=$_POST["callback_useronly_move_minutes"];}
if (isset($_GET["default_phone_code"]))				{$default_phone_code=$_GET["default_phone_code"];}
	elseif (isset($_POST["default_phone_code"]))	{$default_phone_code=$_POST["default_phone_code"];}
if (isset($_GET["admin_row_click"]))			{$admin_row_click=$_GET["admin_row_click"];}
	elseif (isset($_POST["admin_row_click"]))	{$admin_row_click=$_POST["admin_row_click"];}
if (isset($_GET["colors_id"]))			{$colors_id=$_GET["colors_id"];}
	elseif (isset($_POST["colors_id"]))	{$colors_id=$_POST["colors_id"];}
if (isset($_GET["colors_name"]))			{$colors_name=$_GET["colors_name"];}
	elseif (isset($_POST["colors_name"]))	{$colors_name=$_POST["colors_name"];}
if (isset($_GET["menu_background"]))			{$menu_background=$_GET["menu_background"];}
	elseif (isset($_POST["menu_background"]))	{$menu_background=$_POST["menu_background"];}
if (isset($_GET["frame_background"]))			{$frame_background=$_GET["frame_background"];}
	elseif (isset($_POST["frame_background"]))	{$frame_background=$_POST["frame_background"];}
if (isset($_GET["std_row1_background"]))			{$std_row1_background=$_GET["std_row1_background"];}
	elseif (isset($_POST["std_row1_background"]))	{$std_row1_background=$_POST["std_row1_background"];}
if (isset($_GET["std_row2_background"]))			{$std_row2_background=$_GET["std_row2_background"];}
	elseif (isset($_POST["std_row2_background"]))	{$std_row2_background=$_POST["std_row2_background"];}
if (isset($_GET["std_row3_background"]))			{$std_row3_background=$_GET["std_row3_background"];}
	elseif (isset($_POST["std_row3_background"]))	{$std_row3_background=$_POST["std_row3_background"];}
if (isset($_GET["std_row4_background"]))			{$std_row4_background=$_GET["std_row4_background"];}
	elseif (isset($_POST["std_row4_background"]))	{$std_row4_background=$_POST["std_row4_background"];}
if (isset($_GET["std_row5_background"]))			{$std_row5_background=$_GET["std_row5_background"];}
	elseif (isset($_POST["std_row5_background"]))	{$std_row5_background=$_POST["std_row5_background"];}
if (isset($_GET["alt_row1_background"]))			{$alt_row1_background=$_GET["alt_row1_background"];}
	elseif (isset($_POST["alt_row1_background"]))	{$alt_row1_background=$_POST["alt_row1_background"];}
if (isset($_GET["alt_row2_background"]))			{$alt_row2_background=$_GET["alt_row2_background"];}
	elseif (isset($_POST["alt_row2_background"]))	{$alt_row2_background=$_POST["alt_row2_background"];}
if (isset($_GET["alt_row3_background"]))			{$alt_row3_background=$_GET["alt_row3_background"];}
	elseif (isset($_POST["alt_row3_background"]))	{$alt_row3_background=$_POST["alt_row3_background"];}
if (isset($_GET["button_color"]))			{$button_color=$_GET["button_color"];}
	elseif (isset($_POST["button_color"]))	{$button_color=$_POST["button_color"];}
if (isset($_GET["modify_colors"]))			{$modify_colors=$_GET["modify_colors"];}
	elseif (isset($_POST["modify_colors"]))	{$modify_colors=$_POST["modify_colors"];}
if (isset($_GET["admin_screen_colors"]))			{$admin_screen_colors=$_GET["admin_screen_colors"];}
	elseif (isset($_POST["admin_screen_colors"]))	{$admin_screen_colors=$_POST["admin_screen_colors"];}
if (isset($_GET["web_logo"]))			{$web_logo=$_GET["web_logo"];}
	elseif (isset($_POST["web_logo"]))	{$web_logo=$_POST["web_logo"];}
if (isset($_GET["ofcom_uk_drop_calc"]))				{$ofcom_uk_drop_calc=$_GET["ofcom_uk_drop_calc"];}
	elseif (isset($_POST["ofcom_uk_drop_calc"]))	{$ofcom_uk_drop_calc=$_POST["ofcom_uk_drop_calc"];}
if (isset($_GET["answering_machine"]))				{$answering_machine=$_GET["answering_machine"];}
	elseif (isset($_POST["answering_machine"]))		{$answering_machine=$_POST["answering_machine"];}
if (isset($_GET["outbound_alt_cid"]))				{$outbound_alt_cid=$_GET["outbound_alt_cid"];}
	elseif (isset($_POST["outbound_alt_cid"]))		{$outbound_alt_cid=$_POST["outbound_alt_cid"];}
if (isset($_GET["agent_screen_colors"]))			{$agent_screen_colors=$_GET["agent_screen_colors"];}
	elseif (isset($_POST["agent_screen_colors"]))	{$agent_screen_colors=$_POST["agent_screen_colors"];}
if (isset($_GET["script_remove_js"]))			{$script_remove_js=$_GET["script_remove_js"];}
	elseif (isset($_POST["script_remove_js"]))	{$script_remove_js=$_POST["script_remove_js"];}
if (isset($_GET["user_nickname"]))			{$user_nickname=$_GET["user_nickname"];}
	elseif (isset($_POST["user_nickname"]))	{$user_nickname=$_POST["user_nickname"];}
if (isset($_GET["manual_auto_next"]))			{$manual_auto_next=$_GET["manual_auto_next"];}
	elseif (isset($_POST["manual_auto_next"]))	{$manual_auto_next=$_POST["manual_auto_next"];}
if (isset($_GET["manual_auto_show"]))			{$manual_auto_show=$_GET["manual_auto_show"];}
	elseif (isset($_POST["manual_auto_show"]))	{$manual_auto_show=$_POST["manual_auto_show"];}
if (isset($_GET["customer_chat_screen_colors"]))			{$customer_chat_screen_colors=$_GET["customer_chat_screen_colors"];}
	elseif (isset($_POST["customer_chat_screen_colors"]))	{$customer_chat_screen_colors=$_POST["customer_chat_screen_colors"];}
if (isset($_GET["customer_chat_survey_link"]))			{$customer_chat_survey_link=$_GET["customer_chat_survey_link"];}
	elseif (isset($_POST["customer_chat_survey_link"]))	{$customer_chat_survey_link=$_POST["customer_chat_survey_link"];}
if (isset($_GET["customer_chat_survey_text"]))			{$customer_chat_survey_text=$_GET["customer_chat_survey_text"];}
	elseif (isset($_POST["customer_chat_survey_text"]))	{$customer_chat_survey_text=$_POST["customer_chat_survey_text"];}
if (isset($_GET["user_new_lead_limit"]))			{$user_new_lead_limit=$_GET["user_new_lead_limit"];}
	elseif (isset($_POST["user_new_lead_limit"]))	{$user_new_lead_limit=$_POST["user_new_lead_limit"];}
if (isset($_GET["allow_required_fields"]))			{$allow_required_fields=$_GET["allow_required_fields"];}
	elseif (isset($_POST["allow_required_fields"]))	{$allow_required_fields=$_POST["allow_required_fields"];}
if (isset($_GET["agent_xfer_park_3way"]))			{$agent_xfer_park_3way=$_GET["agent_xfer_park_3way"];}
	elseif (isset($_POST["agent_xfer_park_3way"]))	{$agent_xfer_park_3way=$_POST["agent_xfer_park_3way"];}
if (isset($_GET["agent_soundboards"]))			{$agent_soundboards=$_GET["agent_soundboards"];}
	elseif (isset($_POST["agent_soundboards"]))	{$agent_soundboards=$_POST["agent_soundboards"];}
if (isset($_GET["web_loader_phone_length"]))			{$web_loader_phone_length=$_GET["web_loader_phone_length"];}
	elseif (isset($_POST["web_loader_phone_length"]))	{$web_loader_phone_length=$_POST["web_loader_phone_length"];}
if (isset($_GET["agent_script"]))				{$agent_script=$_GET["agent_script"];}
	elseif (isset($_POST["agent_script"]))		{$agent_script=$_POST["agent_script"];}
if (isset($_GET["agent_chat_screen_colors"]))			{$agent_chat_screen_colors=$_GET["agent_chat_screen_colors"];}
	elseif (isset($_POST["agent_chat_screen_colors"]))	{$agent_chat_screen_colors=$_POST["agent_chat_screen_colors"];}
if (isset($_GET["conf_qualify"]))			{$conf_qualify=$_GET["conf_qualify"];}
	elseif (isset($_POST["conf_qualify"]))	{$conf_qualify=$_POST["conf_qualify"];}
if (isset($_GET["populate_lead_province"]))				{$populate_lead_province=$_GET["populate_lead_province"];}
	elseif (isset($_POST["populate_lead_province"]))	{$populate_lead_province=$_POST["populate_lead_province"];}
if (isset($_GET["api_only_user"]))				{$api_only_user=$_GET["api_only_user"];}
	elseif (isset($_POST["api_only_user"]))		{$api_only_user=$_POST["api_only_user"];}
if (isset($_GET["dead_to_dispo"]))				{$dead_to_dispo=$_GET["dead_to_dispo"];}
	elseif (isset($_POST["dead_to_dispo"]))		{$dead_to_dispo=$_POST["dead_to_dispo"];}
if (isset($_GET["areacode_filter"]))				{$areacode_filter=$_GET["areacode_filter"];}
	elseif (isset($_POST["areacode_filter"]))		{$areacode_filter=$_POST["areacode_filter"];}
if (isset($_GET["areacode_filter_seconds"]))			{$areacode_filter_seconds=$_GET["areacode_filter_seconds"];}
	elseif (isset($_POST["areacode_filter_seconds"]))	{$areacode_filter_seconds=$_POST["areacode_filter_seconds"];}
if (isset($_GET["areacode_filter_action"]))				{$areacode_filter_action=$_GET["areacode_filter_action"];}
	elseif (isset($_POST["areacode_filter_action"]))	{$areacode_filter_action=$_POST["areacode_filter_action"];}
if (isset($_GET["areacode_list"]))			{$areacode_list=$_GET["areacode_list"];}
	elseif (isset($_POST["areacode_list"]))	{$areacode_list=$_POST["areacode_list"];}
if (isset($_GET["areacode_filter_action_value"]))			{$areacode_filter_action_value=$_GET["areacode_filter_action_value"];}
	elseif (isset($_POST["areacode_filter_action_value"]))	{$areacode_filter_action_value=$_POST["areacode_filter_action_value"];}
if (isset($_GET["enable_auto_reports"]))			{$enable_auto_reports=$_GET["enable_auto_reports"];}
	elseif (isset($_POST["enable_auto_reports"]))	{$enable_auto_reports=$_POST["enable_auto_reports"];}
if (isset($_GET["modify_auto_reports"]))			{$modify_auto_reports=$_GET["modify_auto_reports"];}
	elseif (isset($_POST["modify_auto_reports"]))	{$modify_auto_reports=$_POST["modify_auto_reports"];}
if (isset($_GET["report_id"]))			{$report_id=$_GET["report_id"];}
	elseif (isset($_POST["report_id"]))	{$report_id=$_POST["report_id"];}
if (isset($_GET["report_name"]))			{$report_name=$_GET["report_name"];}
	elseif (isset($_POST["report_name"]))	{$report_name=$_POST["report_name"];}
if (isset($_GET["report_server"]))			{$report_server=$_GET["report_server"];}
	elseif (isset($_POST["report_server"]))	{$report_server=$_POST["report_server"];}
if (isset($_GET["report_times"]))			{$report_times=$_GET["report_times"];}
	elseif (isset($_POST["report_times"]))	{$report_times=$_POST["report_times"];}
if (isset($_GET["report_weekdays"]))			{$report_weekdays=$_GET["report_weekdays"];}
	elseif (isset($_POST["report_weekdays"]))	{$report_weekdays=$_POST["report_weekdays"];}
if (isset($_GET["report_monthdays"]))			{$report_monthdays=$_GET["report_monthdays"];}
	elseif (isset($_POST["report_monthdays"]))	{$report_monthdays=$_POST["report_monthdays"];}
if (isset($_GET["report_destination"]))			{$report_destination=$_GET["report_destination"];}
	elseif (isset($_POST["report_destination"]))	{$report_destination=$_POST["report_destination"];}
if (isset($_GET["email_from"]))			{$email_from=$_GET["email_from"];}
	elseif (isset($_POST["email_from"]))	{$email_from=$_POST["email_from"];}
if (isset($_GET["email_to"]))			{$email_to=$_GET["email_to"];}
	elseif (isset($_POST["email_to"]))	{$email_to=$_POST["email_to"];}
if (isset($_GET["email_subject"]))			{$email_subject=$_GET["email_subject"];}
	elseif (isset($_POST["email_subject"]))	{$email_subject=$_POST["email_subject"];}
if (isset($_GET["ftp_server"]))				{$ftp_server=$_GET["ftp_server"];}
	elseif (isset($_POST["ftp_server"]))	{$ftp_server=$_POST["ftp_server"];}
if (isset($_GET["ftp_user"]))			{$ftp_user=$_GET["ftp_user"];}
	elseif (isset($_POST["ftp_user"]))	{$ftp_user=$_POST["ftp_user"];}
if (isset($_GET["ftp_pass"]))			{$ftp_pass=$_GET["ftp_pass"];}
	elseif (isset($_POST["ftp_pass"]))	{$ftp_pass=$_POST["ftp_pass"];}
if (isset($_GET["ftp_directory"]))			{$ftp_directory=$_GET["ftp_directory"];}
	elseif (isset($_POST["ftp_directory"]))	{$ftp_directory=$_POST["ftp_directory"];}
if (isset($_GET["report_url"]))				{$report_url=$_GET["report_url"];}
	elseif (isset($_POST["report_url"]))	{$report_url=$_POST["report_url"];}
if (isset($_GET["run_now_trigger"]))			{$run_now_trigger=$_GET["run_now_trigger"];}
	elseif (isset($_POST["run_now_trigger"]))	{$run_now_trigger=$_POST["run_now_trigger"];}
if (isset($_GET["agent_xfer_validation"]))			{$agent_xfer_validation=$_GET["agent_xfer_validation"];}
	elseif (isset($_POST["agent_xfer_validation"]))	{$agent_xfer_validation=$_POST["agent_xfer_validation"];}
if (isset($_GET["populate_state_areacode"]))			{$populate_state_areacode=$_GET["populate_state_areacode"];}
	elseif (isset($_POST["populate_state_areacode"]))	{$populate_state_areacode=$_POST["populate_state_areacode"];}
if (isset($_GET["enable_pause_code_limits"]))			{$enable_pause_code_limits=$_GET["enable_pause_code_limits"];}
	elseif (isset($_POST["enable_pause_code_limits"]))	{$enable_pause_code_limits=$_POST["enable_pause_code_limits"];}
if (isset($_GET["time_limit"]))				{$time_limit=$_GET["time_limit"];}
	elseif (isset($_POST["time_limit"]))	{$time_limit=$_POST["time_limit"];}
if (isset($_GET["enable_drop_lists"]))			{$enable_drop_lists=$_GET["enable_drop_lists"];}
	elseif (isset($_POST["enable_drop_lists"]))	{$enable_drop_lists=$_POST["enable_drop_lists"];}
if (isset($_GET["dl_id"]))			{$dl_id=$_GET["dl_id"];}
	elseif (isset($_POST["dl_id"]))	{$dl_id=$_POST["dl_id"];}
if (isset($_GET["dl_name"]))			{$dl_name=$_GET["dl_name"];}
	elseif (isset($_POST["dl_name"]))	{$dl_name=$_POST["dl_name"];}
if (isset($_GET["last_run"]))			{$last_run=$_GET["last_run"];}
	elseif (isset($_POST["last_run"]))	{$last_run=$_POST["last_run"];}
if (isset($_GET["dl_server"]))			{$dl_server=$_GET["dl_server"];}
	elseif (isset($_POST["dl_server"]))	{$dl_server=$_POST["dl_server"];}
if (isset($_GET["dl_times"]))			{$dl_times=$_GET["dl_times"];}
	elseif (isset($_POST["dl_times"]))	{$dl_times=$_POST["dl_times"];}
if (isset($_GET["dl_weekdays"]))			{$dl_weekdays=$_GET["dl_weekdays"];}
	elseif (isset($_POST["dl_weekdays"]))	{$dl_weekdays=$_POST["dl_weekdays"];}
if (isset($_GET["dl_monthdays"]))			{$dl_monthdays=$_GET["dl_monthdays"];}
	elseif (isset($_POST["dl_monthdays"]))	{$dl_monthdays=$_POST["dl_monthdays"];}
if (isset($_GET["drop_status"]))			{$drop_status=$_GET["drop_status"];}
	elseif (isset($_POST["drop_status"]))	{$drop_status=$_POST["drop_status"];}
if (isset($_GET["duplicate_check"]))			{$duplicate_check=$_GET["duplicate_check"];}
	elseif (isset($_POST["duplicate_check"]))	{$duplicate_check=$_POST["duplicate_check"];}
if (isset($_GET["allow_ip_lists"]))				{$allow_ip_lists=$_GET["allow_ip_lists"];}
	elseif (isset($_POST["allow_ip_lists"]))	{$allow_ip_lists=$_POST["allow_ip_lists"];}
if (isset($_GET["system_ip_blacklist"]))			{$system_ip_blacklist=$_GET["system_ip_blacklist"];}
	elseif (isset($_POST["system_ip_blacklist"]))	{$system_ip_blacklist=$_POST["system_ip_blacklist"];}
if (isset($_GET["modify_ip_lists"]))			{$modify_ip_lists=$_GET["modify_ip_lists"];}
	elseif (isset($_POST["modify_ip_lists"]))	{$modify_ip_lists=$_POST["modify_ip_lists"];}
if (isset($_GET["ignore_ip_list"]))			{$ignore_ip_list=$_GET["ignore_ip_list"];}
	elseif (isset($_POST["ignore_ip_list"]))	{$ignore_ip_list=$_POST["ignore_ip_list"];}
if (isset($_GET["admin_ip_list"]))			{$admin_ip_list=$_GET["admin_ip_list"];}
	elseif (isset($_POST["admin_ip_list"]))	{$admin_ip_list=$_POST["admin_ip_list"];}
if (isset($_GET["agent_ip_list"]))			{$agent_ip_list=$_GET["agent_ip_list"];}
	elseif (isset($_POST["agent_ip_list"]))	{$agent_ip_list=$_POST["agent_ip_list"];}
if (isset($_GET["api_ip_list"]))			{$api_ip_list=$_GET["api_ip_list"];}
	elseif (isset($_POST["api_ip_list"]))	{$api_ip_list=$_POST["api_ip_list"];}
if (isset($_GET["ip_list_id"]))			{$ip_list_id=$_GET["ip_list_id"];}
	elseif (isset($_POST["ip_list_id"]))	{$ip_list_id=$_POST["ip_list_id"];}
if (isset($_GET["ip_list_name"]))			{$ip_list_name=$_GET["ip_list_name"];}
	elseif (isset($_POST["ip_list_name"]))	{$ip_list_name=$_POST["ip_list_name"];}
if (isset($_GET["ip_address"]))				{$ip_address=$_GET["ip_address"];}
	elseif (isset($_POST["ip_address"]))	{$ip_address=$_POST["ip_address"];}
if (isset($_GET["dl_minutes"]))				{$dl_minutes=$_GET["dl_minutes"];}
	elseif (isset($_POST["dl_minutes"]))	{$dl_minutes=$_POST["dl_minutes"];}
if (isset($_GET["ready_max_logout"]))			{$ready_max_logout=$_GET["ready_max_logout"];}
	elseif (isset($_POST["ready_max_logout"]))	{$ready_max_logout=$_POST["ready_max_logout"];}
if (isset($_GET["routing_prefix"]))				{$routing_prefix=$_GET["routing_prefix"];}
	elseif (isset($_POST["routing_prefix"]))	{$routing_prefix=$_POST["routing_prefix"];}
if (isset($_GET["callback_display_days"]))			{$callback_display_days=$_GET["callback_display_days"];}
	elseif (isset($_POST["callback_display_days"]))	{$callback_display_days=$_POST["callback_display_days"];}
if (isset($_GET["three_way_record_stop"]))			{$three_way_record_stop=$_GET["three_way_record_stop"];}
	elseif (isset($_POST["three_way_record_stop"]))	{$three_way_record_stop=$_POST["three_way_record_stop"];}
if (isset($_GET["hangup_xfer_record_start"]))			{$hangup_xfer_record_start=$_GET["hangup_xfer_record_start"];}
	elseif (isset($_POST["hangup_xfer_record_start"]))	{$hangup_xfer_record_start=$_POST["hangup_xfer_record_start"];}
if (isset($_GET["agent_push_events"]))			{$agent_push_events=$_GET["agent_push_events"];}
	elseif (isset($_POST["agent_push_events"]))	{$agent_push_events=$_POST["agent_push_events"];}
if (isset($_GET["agent_push_url"]))				{$agent_push_url=$_GET["agent_push_url"];}
	elseif (isset($_POST["agent_push_url"]))	{$agent_push_url=$_POST["agent_push_url"];}
if (isset($_GET["hide_inactive_lists"]))			{$hide_inactive_lists=$_GET["hide_inactive_lists"];}
	elseif (isset($_POST["hide_inactive_lists"]))	{$hide_inactive_lists=$_POST["hide_inactive_lists"];}
if (isset($_GET["inbound_survey"]))			{$inbound_survey=$_GET["inbound_survey"];}
	elseif (isset($_POST["inbound_survey"]))	{$inbound_survey=$_POST["inbound_survey"];}
if (isset($_GET["inbound_survey_filename"]))			{$inbound_survey_filename=$_GET["inbound_survey_filename"];}
	elseif (isset($_POST["inbound_survey_filename"]))	{$inbound_survey_filename=$_POST["inbound_survey_filename"];}
if (isset($_GET["inbound_survey_accept_digit"]))			{$inbound_survey_accept_digit=$_GET["inbound_survey_accept_digit"];}
	elseif (isset($_POST["inbound_survey_accept_digit"]))	{$inbound_survey_accept_digit=$_POST["inbound_survey_accept_digit"];}
if (isset($_GET["inbound_survey_question_filename"]))			{$inbound_survey_question_filename=$_GET["inbound_survey_question_filename"];}
	elseif (isset($_POST["inbound_survey_question_filename"]))	{$inbound_survey_question_filename=$_POST["inbound_survey_question_filename"];}
if (isset($_GET["inbound_survey_callmenu"]))			{$inbound_survey_callmenu=$_GET["inbound_survey_callmenu"];}
	elseif (isset($_POST["inbound_survey_callmenu"]))	{$inbound_survey_callmenu=$_POST["inbound_survey_callmenu"];}
if (isset($_GET["allow_manage_active_lists"]))			{$allow_manage_active_lists=$_GET["allow_manage_active_lists"];}
	elseif (isset($_POST["allow_manage_active_lists"]))	{$allow_manage_active_lists=$_POST["allow_manage_active_lists"];}
if (isset($_GET["filename_override"]))			{$filename_override=$_GET["filename_override"];}
	elseif (isset($_POST["filename_override"]))	{$filename_override=$_POST["filename_override"];}
if (isset($_GET["expired_lists_inactive"]))				{$expired_lists_inactive=$_GET["expired_lists_inactive"];}
	elseif (isset($_POST["expired_lists_inactive"]))	{$expired_lists_inactive=$_POST["expired_lists_inactive"];}
if (isset($_GET["enable_gdpr_download_deletion"]))				{$enable_gdpr_download_deletion=$_GET["enable_gdpr_download_deletion"];}
	elseif (isset($_POST["enable_gdpr_download_deletion"]))	{$enable_gdpr_download_deletion=$_POST["enable_gdpr_download_deletion"];}
if (isset($_GET["did_system_filter"]))			{$did_system_filter=$_GET["did_system_filter"];}
	elseif (isset($_POST["did_system_filter"]))	{$did_system_filter=$_POST["did_system_filter"];}
if (isset($_GET["webphone_layout"]))			{$webphone_layout=$_GET["webphone_layout"];}
	elseif (isset($_POST["webphone_layout"]))	{$webphone_layout=$_POST["webphone_layout"];}
if (isset($_GET["max_inbound_calls_outcome"]))			{$max_inbound_calls_outcome=$_GET["max_inbound_calls_outcome"];}
	elseif (isset($_POST["max_inbound_calls_outcome"]))	{$max_inbound_calls_outcome=$_POST["max_inbound_calls_outcome"];}
if (isset($_GET["manual_auto_next_options"]))			{$manual_auto_next_options=$_GET["manual_auto_next_options"];}
	elseif (isset($_POST["manual_auto_next_options"]))	{$manual_auto_next_options=$_POST["manual_auto_next_options"];}
if (isset($_GET["agent_screen_time_display"]))			{$agent_screen_time_display=$_GET["agent_screen_time_display"];}
	elseif (isset($_POST["agent_screen_time_display"]))	{$agent_screen_time_display=$_POST["agent_screen_time_display"];}
if (isset($_GET["next_dial_my_callbacks"]))				{$next_dial_my_callbacks=$_GET["next_dial_my_callbacks"];}
	elseif (isset($_POST["next_dial_my_callbacks"]))	{$next_dial_my_callbacks=$_POST["next_dial_my_callbacks"];}
if (isset($_GET["anyone_callback_inactive_lists"]))				{$anyone_callback_inactive_lists=$_GET["anyone_callback_inactive_lists"];}
	elseif (isset($_POST["anyone_callback_inactive_lists"]))	{$anyone_callback_inactive_lists=$_POST["anyone_callback_inactive_lists"];}
if (isset($_GET["inbound_no_agents_no_dial_container"]))			{$inbound_no_agents_no_dial_container=$_GET["inbound_no_agents_no_dial_container"];}
	elseif (isset($_POST["inbound_no_agents_no_dial_container"]))	{$inbound_no_agents_no_dial_container=$_POST["inbound_no_agents_no_dial_container"];}
if (isset($_GET["inbound_no_agents_no_dial_threshold"]))			{$inbound_no_agents_no_dial_threshold=$_GET["inbound_no_agents_no_dial_threshold"];}
	elseif (isset($_POST["inbound_no_agents_no_dial_threshold"]))	{$inbound_no_agents_no_dial_threshold=$_POST["inbound_no_agents_no_dial_threshold"];}
if (isset($_GET["icbq_expiration_hours"]))			{$icbq_expiration_hours=$_GET["icbq_expiration_hours"];}
	elseif (isset($_POST["icbq_expiration_hours"]))	{$icbq_expiration_hours=$_POST["icbq_expiration_hours"];}
if (isset($_GET["closing_time_action"]))			{$closing_time_action=$_GET["closing_time_action"];}
	elseif (isset($_POST["closing_time_action"]))	{$closing_time_action=$_POST["closing_time_action"];}
if (isset($_GET["closing_time_now_trigger"]))			{$closing_time_now_trigger=$_GET["closing_time_now_trigger"];}
	elseif (isset($_POST["closing_time_now_trigger"]))	{$closing_time_now_trigger=$_POST["closing_time_now_trigger"];}
if (isset($_GET["closing_time_filename"]))			{$closing_time_filename=$_GET["closing_time_filename"];}
	elseif (isset($_POST["closing_time_filename"]))	{$closing_time_filename=$_POST["closing_time_filename"];}
if (isset($_GET["closing_time_end_filename"]))			{$closing_time_end_filename=$_GET["closing_time_end_filename"];}
	elseif (isset($_POST["closing_time_end_filename"]))	{$closing_time_end_filename=$_POST["closing_time_end_filename"];}
if (isset($_GET["closing_time_lead_reset"]))			{$closing_time_lead_reset=$_GET["closing_time_lead_reset"];}
	elseif (isset($_POST["closing_time_lead_reset"]))	{$closing_time_lead_reset=$_POST["closing_time_lead_reset"];}
if (isset($_GET["closing_time_option_exten"]))			{$closing_time_option_exten=$_GET["closing_time_option_exten"];}
	elseif (isset($_POST["closing_time_option_exten"]))	{$closing_time_option_exten=$_POST["closing_time_option_exten"];}
if (isset($_GET["closing_time_option_callmenu"]))			{$closing_time_option_callmenu=$_GET["closing_time_option_callmenu"];}
	elseif (isset($_POST["closing_time_option_callmenu"]))	{$closing_time_option_callmenu=$_POST["closing_time_option_callmenu"];}
if (isset($_GET["closing_time_option_voicemail"]))			{$closing_time_option_voicemail=$_GET["closing_time_option_voicemail"];}
	elseif (isset($_POST["closing_time_option_voicemail"]))	{$closing_time_option_voicemail=$_POST["closing_time_option_voicemail"];}
if (isset($_GET["closing_time_option_xfer_group"]))				{$closing_time_option_xfer_group=$_GET["closing_time_option_xfer_group"];}
	elseif (isset($_POST["closing_time_option_xfer_group"]))	{$closing_time_option_xfer_group=$_POST["closing_time_option_xfer_group"];}
if (isset($_GET["closing_time_option_callback_list_id"]))			{$closing_time_option_callback_list_id=$_GET["closing_time_option_callback_list_id"];}
	elseif (isset($_POST["closing_time_option_callback_list_id"]))	{$closing_time_option_callback_list_id=$_POST["closing_time_option_callback_list_id"];}
if (isset($_GET["icbq_call_time_id"]))			{$icbq_call_time_id=$_GET["icbq_call_time_id"];}
	elseif (isset($_POST["icbq_call_time_id"]))	{$icbq_call_time_id=$_POST["icbq_call_time_id"];}
if (isset($_GET["add_lead_timezone"]))			{$add_lead_timezone=$_GET["add_lead_timezone"];}
	elseif (isset($_POST["add_lead_timezone"]))	{$add_lead_timezone=$_POST["add_lead_timezone"];}
if (isset($_GET["icbq_dial_filter"]))			{$icbq_dial_filter=$_GET["icbq_dial_filter"];}
	elseif (isset($_POST["icbq_dial_filter"]))	{$icbq_dial_filter=$_POST["icbq_dial_filter"];}
if (isset($_GET["cid_group_id"]))			{$cid_group_id=$_GET["cid_group_id"];}
	elseif (isset($_POST["cid_group_id"]))	{$cid_group_id=$_POST["cid_group_id"];}
if (isset($_GET["cid_group_notes"]))			{$cid_group_notes=$_GET["cid_group_notes"];}
	elseif (isset($_POST["cid_group_notes"]))	{$cid_group_notes=$_POST["cid_group_notes"];}
if (isset($_GET["cid_group_type"]))				{$cid_group_type=$_GET["cid_group_type"];}
	elseif (isset($_POST["cid_group_type"]))	{$cid_group_type=$_POST["cid_group_type"];}
if (isset($_GET["pause_max_dispo"]))			{$pause_max_dispo=$_GET["pause_max_dispo"];}
	elseif (isset($_POST["pause_max_dispo"]))	{$pause_max_dispo=$_POST["pause_max_dispo"];}
if (isset($_GET["script_top_dispo"]))			{$script_top_dispo=$_GET["script_top_dispo"];}
	elseif (isset($_POST["script_top_dispo"]))	{$script_top_dispo=$_POST["script_top_dispo"];}
if (isset($_GET["source_id_display"]))			{$source_id_display=$_GET["source_id_display"];}
	elseif (isset($_POST["source_id_display"]))	{$source_id_display=$_POST["source_id_display"];}
if (isset($_GET["require_mgr_approval"]))			{$require_mgr_approval=$_GET["require_mgr_approval"];}
	elseif (isset($_POST["require_mgr_approval"]))	{$require_mgr_approval=$_POST["require_mgr_approval"];}
if (isset($_GET["pause_code_approval"]))			{$pause_code_approval=$_GET["pause_code_approval"];}
	elseif (isset($_POST["pause_code_approval"]))	{$pause_code_approval=$_POST["pause_code_approval"];}
if (isset($_GET["populate_lead_source"]))			{$populate_lead_source=$_GET["populate_lead_source"];}
	elseif (isset($_POST["populate_lead_source"]))	{$populate_lead_source=$_POST["populate_lead_source"];}
if (isset($_GET["populate_lead_vendor"]))			{$populate_lead_vendor=$_GET["populate_lead_vendor"];}
	elseif (isset($_POST["populate_lead_vendor"]))	{$populate_lead_vendor=$_POST["populate_lead_vendor"];}
if (isset($_GET["max_hopper_calls"]))			{$max_hopper_calls=$_GET["max_hopper_calls"];}
	elseif (isset($_POST["max_hopper_calls"]))	{$max_hopper_calls=$_POST["max_hopper_calls"];}
if (isset($_GET["max_hopper_calls_hour"]))			{$max_hopper_calls_hour=$_GET["max_hopper_calls_hour"];}
	elseif (isset($_POST["max_hopper_calls_hour"]))	{$max_hopper_calls_hour=$_POST["max_hopper_calls_hour"];}
if (isset($_GET["waiting_call_url_on"]))			{$waiting_call_url_on=$_GET["waiting_call_url_on"];}
	elseif (isset($_POST["waiting_call_url_on"]))	{$waiting_call_url_on=$_POST["waiting_call_url_on"];}
if (isset($_GET["waiting_call_url_off"]))			{$waiting_call_url_off=$_GET["waiting_call_url_off"];}
	elseif (isset($_POST["waiting_call_url_off"]))	{$waiting_call_url_off=$_POST["waiting_call_url_off"];}
if (isset($_GET["enter_ingroup_url"]))			{$enter_ingroup_url=$_GET["enter_ingroup_url"];}
	elseif (isset($_POST["enter_ingroup_url"]))	{$enter_ingroup_url=$_POST["enter_ingroup_url"];}
if (isset($_GET["dead_trigger_seconds"]))			{$dead_trigger_seconds=$_GET["dead_trigger_seconds"];}
	elseif (isset($_POST["dead_trigger_seconds"]))	{$dead_trigger_seconds=$_POST["dead_trigger_seconds"];}
if (isset($_GET["dead_trigger_action"]))			{$dead_trigger_action=$_GET["dead_trigger_action"];}
	elseif (isset($_POST["dead_trigger_action"]))	{$dead_trigger_action=$_POST["dead_trigger_action"];}
if (isset($_GET["dead_trigger_repeat"]))			{$dead_trigger_repeat=$_GET["dead_trigger_repeat"];}
	elseif (isset($_POST["dead_trigger_repeat"]))	{$dead_trigger_repeat=$_POST["dead_trigger_repeat"];}
if (isset($_GET["dead_trigger_filename"]))			{$dead_trigger_filename=$_GET["dead_trigger_filename"];}
	elseif (isset($_POST["dead_trigger_filename"]))	{$dead_trigger_filename=$_POST["dead_trigger_filename"];}
if (isset($_GET["dead_trigger_url"]))			{$dead_trigger_url=$_GET["dead_trigger_url"];}
	elseif (isset($_POST["dead_trigger_url"]))	{$dead_trigger_url=$_POST["dead_trigger_url"];}
if (isset($_GET["cid_cb_confirm_number"]))			{$cid_cb_confirm_number=$_GET["cid_cb_confirm_number"];}
	elseif (isset($_POST["cid_cb_confirm_number"]))	{$cid_cb_confirm_number=$_POST["cid_cb_confirm_number"];}
if (isset($_GET["cid_cb_invalid_filter_phone_group"]))			{$cid_cb_invalid_filter_phone_group=$_GET["cid_cb_invalid_filter_phone_group"];}
	elseif (isset($_POST["cid_cb_invalid_filter_phone_group"]))	{$cid_cb_invalid_filter_phone_group=$_POST["cid_cb_invalid_filter_phone_group"];}
if (isset($_GET["cid_cb_valid_length"]))			{$cid_cb_valid_length=$_GET["cid_cb_valid_length"];}
	elseif (isset($_POST["cid_cb_valid_length"]))	{$cid_cb_valid_length=$_POST["cid_cb_valid_length"];}
if (isset($_GET["cid_cb_valid_filename"]))			{$cid_cb_valid_filename=$_GET["cid_cb_valid_filename"];}
	elseif (isset($_POST["cid_cb_valid_filename"]))	{$cid_cb_valid_filename=$_POST["cid_cb_valid_filename"];}
if (isset($_GET["cid_cb_confirmed_filename"]))			{$cid_cb_confirmed_filename=$_GET["cid_cb_confirmed_filename"];}
	elseif (isset($_POST["cid_cb_confirmed_filename"]))	{$cid_cb_confirmed_filename=$_POST["cid_cb_confirmed_filename"];}
if (isset($_GET["cid_cb_enter_filename"]))			{$cid_cb_enter_filename=$_GET["cid_cb_enter_filename"];}
	elseif (isset($_POST["cid_cb_enter_filename"]))	{$cid_cb_enter_filename=$_POST["cid_cb_enter_filename"];}
if (isset($_GET["cid_cb_you_entered_filename"]))			{$cid_cb_you_entered_filename=$_GET["cid_cb_you_entered_filename"];}
	elseif (isset($_POST["cid_cb_you_entered_filename"]))	{$cid_cb_you_entered_filename=$_POST["cid_cb_you_entered_filename"];}
if (isset($_GET["cid_cb_press_to_confirm_filename"]))			{$cid_cb_press_to_confirm_filename=$_GET["cid_cb_press_to_confirm_filename"];}
	elseif (isset($_POST["cid_cb_press_to_confirm_filename"]))	{$cid_cb_press_to_confirm_filename=$_POST["cid_cb_press_to_confirm_filename"];}
if (isset($_GET["cid_cb_invalid_filename"]))			{$cid_cb_invalid_filename=$_GET["cid_cb_invalid_filename"];}
	elseif (isset($_POST["cid_cb_invalid_filename"]))	{$cid_cb_invalid_filename=$_POST["cid_cb_invalid_filename"];}
if (isset($_GET["cid_cb_reenter_filename"]))			{$cid_cb_reenter_filename=$_GET["cid_cb_reenter_filename"];}
	elseif (isset($_POST["cid_cb_reenter_filename"]))	{$cid_cb_reenter_filename=$_POST["cid_cb_reenter_filename"];}
if (isset($_GET["cid_cb_error_filename"]))			{$cid_cb_error_filename=$_GET["cid_cb_error_filename"];}
	elseif (isset($_POST["cid_cb_error_filename"]))	{$cid_cb_error_filename=$_POST["cid_cb_error_filename"];}
if (isset($_GET["agent_logout_link"]))			{$agent_logout_link=$_GET["agent_logout_link"];}
	elseif (isset($_POST["agent_logout_link"]))	{$agent_logout_link=$_POST["agent_logout_link"];}
if (isset($_GET["scheduled_callbacks_force_dial"]))				{$scheduled_callbacks_force_dial=$_GET["scheduled_callbacks_force_dial"];}
	elseif (isset($_POST["scheduled_callbacks_force_dial"]))	{$scheduled_callbacks_force_dial=$_POST["scheduled_callbacks_force_dial"];}
if (isset($_GET["scheduled_callbacks_auto_reschedule"]))			{$scheduled_callbacks_auto_reschedule=$_GET["scheduled_callbacks_auto_reschedule"];}
	elseif (isset($_POST["scheduled_callbacks_auto_reschedule"]))	{$scheduled_callbacks_auto_reschedule=$_POST["scheduled_callbacks_auto_reschedule"];}
if (isset($_GET["scheduled_callbacks_timezones_container"]))			{$scheduled_callbacks_timezones_container=$_GET["scheduled_callbacks_timezones_container"];}
	elseif (isset($_POST["scheduled_callbacks_timezones_container"]))	{$scheduled_callbacks_timezones_container=$_POST["scheduled_callbacks_timezones_container"];}
if (isset($_GET["daily_reset_limit"]))			{$daily_reset_limit=$_GET["daily_reset_limit"];}
	elseif (isset($_POST["daily_reset_limit"]))	{$daily_reset_limit=$_POST["daily_reset_limit"];}
if (isset($_GET["three_way_volume_buttons"]))			{$three_way_volume_buttons=$_GET["three_way_volume_buttons"];}
	elseif (isset($_POST["three_way_volume_buttons"]))	{$three_way_volume_buttons=$_POST["three_way_volume_buttons"];}
if (isset($_GET["callback_dnc"]))			{$callback_dnc=$_GET["callback_dnc"];}
	elseif (isset($_POST["callback_dnc"]))	{$callback_dnc=$_POST["callback_dnc"];}
if (isset($_GET["external_web_socket_url"]))			{$external_web_socket_url=$_GET["external_web_socket_url"];}
	elseif (isset($_POST["external_web_socket_url"]))	{$external_web_socket_url=$_POST["external_web_socket_url"];}
if (isset($_GET["manual_dial_validation"]))			{$manual_dial_validation=$_GET["manual_dial_validation"];}
	elseif (isset($_POST["manual_dial_validation"]))	{$manual_dial_validation=$_POST["manual_dial_validation"];}
if (isset($_GET["place_in_line_caller_number_filename"]))			{$place_in_line_caller_number_filename=$_GET["place_in_line_caller_number_filename"];}
	elseif (isset($_POST["place_in_line_caller_number_filename"]))	{$place_in_line_caller_number_filename=$_POST["place_in_line_caller_number_filename"];}
if (isset($_GET["place_in_line_you_next_filename"]))			{$place_in_line_you_next_filename=$_GET["place_in_line_you_next_filename"];}
	elseif (isset($_POST["place_in_line_you_next_filename"]))	{$place_in_line_you_next_filename=$_POST["place_in_line_you_next_filename"];}
if (isset($_GET["mute_recordings"]))			{$mute_recordings=$_GET["mute_recordings"];}
	elseif (isset($_POST["mute_recordings"]))	{$mute_recordings=$_POST["mute_recordings"];}
if (isset($_GET["user_admin_redirect"]))			{$user_admin_redirect=$_GET["user_admin_redirect"];}
	elseif (isset($_POST["user_admin_redirect"]))	{$user_admin_redirect=$_POST["user_admin_redirect"];}
if (isset($_GET["user_admin_redirect_url"]))			{$user_admin_redirect_url=$_GET["user_admin_redirect_url"];}
	elseif (isset($_POST["user_admin_redirect_url"]))	{$user_admin_redirect_url=$_POST["user_admin_redirect_url"];}
if (isset($_GET["sip_event_logging"]))			{$sip_event_logging=$_GET["sip_event_logging"];}
	elseif (isset($_POST["sip_event_logging"]))	{$sip_event_logging=$_POST["sip_event_logging"];}
if (isset($_GET["call_quota_lead_ranking"]))			{$call_quota_lead_ranking=$_GET["call_quota_lead_ranking"];}
	elseif (isset($_POST["call_quota_lead_ranking"]))	{$call_quota_lead_ranking=$_POST["call_quota_lead_ranking"];}
if (isset($_GET["auto_active_list_new"]))			{$auto_active_list_new=$_GET["auto_active_list_new"];}
	elseif (isset($_POST["auto_active_list_new"]))	{$auto_active_list_new=$_POST["auto_active_list_new"];}
if (isset($_GET["auto_active_list_rank"]))			{$auto_active_list_rank=$_GET["auto_active_list_rank"];}
	elseif (isset($_POST["auto_active_list_rank"]))	{$auto_active_list_rank=$_POST["auto_active_list_rank"];}
if (isset($_GET["max_inbound_filter_enabled"]))				{$max_inbound_filter_enabled=$_GET["max_inbound_filter_enabled"];}
	elseif (isset($_POST["max_inbound_filter_enabled"]))	{$max_inbound_filter_enabled=$_POST["max_inbound_filter_enabled"];}
if (isset($_GET["max_inbound_filter_statuses"]))			{$max_inbound_filter_statuses=$_GET["max_inbound_filter_statuses"];}
	elseif (isset($_POST["max_inbound_filter_statuses"]))	{$max_inbound_filter_statuses=$_POST["max_inbound_filter_statuses"];}
if (isset($_GET["max_inbound_filter_ingroups"]))			{$max_inbound_filter_ingroups=$_GET["max_inbound_filter_ingroups"];}
	elseif (isset($_POST["max_inbound_filter_ingroups"]))	{$max_inbound_filter_ingroups=$_POST["max_inbound_filter_ingroups"];}
if (isset($_GET["max_inbound_filter_min_sec"]))				{$max_inbound_filter_min_sec=$_GET["max_inbound_filter_min_sec"];}
	elseif (isset($_POST["max_inbound_filter_min_sec"]))	{$max_inbound_filter_min_sec=$_POST["max_inbound_filter_min_sec"];}
if (isset($_GET["enable_second_script"]))			{$enable_second_script=$_GET["enable_second_script"];}
	elseif (isset($_POST["enable_second_script"]))	{$enable_second_script=$_POST["enable_second_script"];}
if (isset($_GET["ingroup_script_two"]))				{$ingroup_script_two=$_GET["ingroup_script_two"];}
	elseif (isset($_POST["ingroup_script_two"]))	{$ingroup_script_two=$_POST["ingroup_script_two"];}
if (isset($_GET["campaign_script_two"]))			{$campaign_script_two=$_GET["campaign_script_two"];}
	elseif (isset($_POST["campaign_script_two"]))	{$campaign_script_two=$_POST["campaign_script_two"];}
if (isset($_GET["leave_vm_message_group_id"]))			{$leave_vm_message_group_id=$_GET["leave_vm_message_group_id"];}
	elseif (isset($_POST["leave_vm_message_group_id"]))	{$leave_vm_message_group_id=$_POST["leave_vm_message_group_id"];}
if (isset($_GET["leave_vm_message_group_notes"]))			{$leave_vm_message_group_notes=$_GET["leave_vm_message_group_notes"];}
	elseif (isset($_POST["leave_vm_message_group_notes"]))	{$leave_vm_message_group_notes=$_POST["leave_vm_message_group_notes"];}
if (isset($_GET["audio_filename"]))			{$audio_filename=$_GET["audio_filename"];}
	elseif (isset($_POST["audio_filename"]))	{$audio_filename=$_POST["audio_filename"];}
if (isset($_GET["audio_name"]))			{$audio_name=$_GET["audio_name"];}
	elseif (isset($_POST["audio_name"]))	{$audio_name=$_POST["audio_name"];}
if (isset($_GET["time_start"]))			{$time_start=$_GET["time_start"];}
	elseif (isset($_POST["time_start"]))	{$time_start=$_POST["time_start"];}
if (isset($_GET["time_end"]))			{$time_end=$_GET["time_end"];}
	elseif (isset($_POST["time_end"]))	{$time_end=$_POST["time_end"];}
if (isset($_GET["leave_vm_no_dispo"]))			{$leave_vm_no_dispo=$_GET["leave_vm_no_dispo"];}
	elseif (isset($_POST["leave_vm_no_dispo"]))	{$leave_vm_no_dispo=$_POST["leave_vm_no_dispo"];}
if (isset($_GET["leave_vm_message_group_id"]))			{$leave_vm_message_group_id=$_GET["leave_vm_message_group_id"];}
	elseif (isset($_POST["leave_vm_message_group_id"]))	{$leave_vm_message_group_id=$_POST["leave_vm_message_group_id"];}
if (isset($_GET["dial_timeout_lead_container"]))			{$dial_timeout_lead_container=$_GET["dial_timeout_lead_container"];}
	elseif (isset($_POST["dial_timeout_lead_container"]))	{$dial_timeout_lead_container=$_POST["dial_timeout_lead_container"];}
if (isset($_GET["amd_type"]))			{$amd_type=$_GET["amd_type"];}
	elseif (isset($_POST["amd_type"]))	{$amd_type=$_POST["amd_type"];}
if (isset($_GET["recording_buttons"]))			{$recording_buttons=$_GET["recording_buttons"];}
	elseif (isset($_POST["recording_buttons"]))	{$recording_buttons=$_POST["recording_buttons"];}
if (isset($_GET["enable_first_webform"]))			{$enable_first_webform=$_GET["enable_first_webform"];}
	elseif (isset($_POST["enable_first_webform"]))	{$enable_first_webform=$_POST["enable_first_webform"];}
if (isset($_GET["vmm_daily_limit"]))			{$vmm_daily_limit=$_GET["vmm_daily_limit"];}
	elseif (isset($_POST["vmm_daily_limit"]))	{$vmm_daily_limit=$_POST["vmm_daily_limit"];}
if (isset($_GET["cid_auto_rotate_minutes"]))			{$cid_auto_rotate_minutes=$_GET["cid_auto_rotate_minutes"];}
	elseif (isset($_POST["cid_auto_rotate_minutes"]))	{$cid_auto_rotate_minutes=$_POST["cid_auto_rotate_minutes"];}
if (isset($_GET["cid_auto_rotate_minimum"]))			{$cid_auto_rotate_minimum=$_GET["cid_auto_rotate_minimum"];}
	elseif (isset($_POST["cid_auto_rotate_minimum"]))	{$cid_auto_rotate_minimum=$_POST["cid_auto_rotate_minimum"];}
if (isset($_GET["opensips_cid_name"]))			{$opensips_cid_name=$_GET["opensips_cid_name"];}
	elseif (isset($_POST["opensips_cid_name"]))	{$opensips_cid_name=$_POST["opensips_cid_name"];}
if (isset($_GET["require_password_length"]))			{$require_password_length=$_GET["require_password_length"];}
	elseif (isset($_POST["require_password_length"]))	{$require_password_length=$_POST["require_password_length"];}
if (isset($_GET["amd_agent_route_options"]))			{$amd_agent_route_options=$_GET["amd_agent_route_options"];}
	elseif (isset($_POST["amd_agent_route_options"]))	{$amd_agent_route_options=$_POST["amd_agent_route_options"];}
if (isset($_GET["user_account_emails"]))			{$user_account_emails=$_GET["user_account_emails"];}
	elseif (isset($_POST["user_account_emails"]))	{$user_account_emails=$_POST["user_account_emails"];}
if (isset($_GET["outbound_cid_any"]))			{$outbound_cid_any=$_GET["outbound_cid_any"];}
	elseif (isset($_POST["outbound_cid_any"]))	{$outbound_cid_any=$_POST["outbound_cid_any"];}
if (isset($_GET["entries_per_page"]))			{$entries_per_page=$_GET["entries_per_page"];}
	elseif (isset($_POST["entries_per_page"]))	{$entries_per_page=$_POST["entries_per_page"];}
if (isset($_GET["start_count"]))			{$start_count=$_GET["start_count"];}
	elseif (isset($_POST["start_count"]))	{$start_count=$_POST["start_count"];}
if (isset($_GET["browser_call_alerts"]))			{$browser_call_alerts=$_GET["browser_call_alerts"];}
	elseif (isset($_POST["browser_call_alerts"]))	{$browser_call_alerts=$_POST["browser_call_alerts"];}
if (isset($_GET["browser_alert_sound"]))			{$browser_alert_sound=$_GET["browser_alert_sound"];}
	elseif (isset($_POST["browser_alert_sound"]))	{$browser_alert_sound=$_POST["browser_alert_sound"];}
if (isset($_GET["browser_alert_volume"]))			{$browser_alert_volume=$_GET["browser_alert_volume"];}
	elseif (isset($_POST["browser_alert_volume"]))	{$browser_alert_volume=$_POST["browser_alert_volume"];}
if (isset($_GET["three_way_record_stop_exception"]))			{$three_way_record_stop_exception=$_GET["three_way_record_stop_exception"];}
	elseif (isset($_POST["three_way_record_stop_exception"]))	{$three_way_record_stop_exception=$_POST["three_way_record_stop_exception"];}
if (isset($_GET["queuemetrics_pausereason"]))			{$queuemetrics_pausereason=$_GET["queuemetrics_pausereason"];}
	elseif (isset($_POST["queuemetrics_pausereason"]))	{$queuemetrics_pausereason=$_POST["queuemetrics_pausereason"];}
if (isset($_GET["inbound_answer_config"]))			{$inbound_answer_config=$_GET["inbound_answer_config"];}
	elseif (isset($_POST["inbound_answer_config"]))	{$inbound_answer_config=$_POST["inbound_answer_config"];}
if (isset($_GET["inbound_route_answer"]))			{$inbound_route_answer=$_GET["inbound_route_answer"];}
	elseif (isset($_POST["inbound_route_answer"]))	{$inbound_route_answer=$_POST["inbound_route_answer"];}
if (isset($_GET["answer_signal"]))			{$answer_signal=$_GET["answer_signal"];}
	elseif (isset($_POST["answer_signal"]))	{$answer_signal=$_POST["answer_signal"];}
if (isset($_GET["inbound_drop_voicemail"]))				{$inbound_drop_voicemail=$_GET["inbound_drop_voicemail"];}
	elseif (isset($_POST["inbound_drop_voicemail"]))	{$inbound_drop_voicemail=$_POST["inbound_drop_voicemail"];}
if (isset($_GET["inbound_after_hours_voicemail"]))			{$inbound_after_hours_voicemail=$_GET["inbound_after_hours_voicemail"];}
	elseif (isset($_POST["inbound_after_hours_voicemail"]))	{$inbound_after_hours_voicemail=$_POST["inbound_after_hours_voicemail"];}
if (isset($_GET["web_loader_phone_strip"]))				{$web_loader_phone_strip=$_GET["web_loader_phone_strip"];}
	elseif (isset($_POST["web_loader_phone_strip"]))	{$web_loader_phone_strip=$_POST["web_loader_phone_strip"];}
if (isset($_GET["manual_dial_phone_strip"]))			{$manual_dial_phone_strip=$_GET["manual_dial_phone_strip"];}
	elseif (isset($_POST["manual_dial_phone_strip"]))	{$manual_dial_phone_strip=$_POST["manual_dial_phone_strip"];}
if (isset($_GET["pause_max_exceptions"]))			{$pause_max_exceptions=$_GET["pause_max_exceptions"];}
	elseif (isset($_POST["pause_max_exceptions"]))	{$pause_max_exceptions=$_POST["pause_max_exceptions"];}
if (isset($_GET["no_agent_delay"]))				{$no_agent_delay=$_GET["no_agent_delay"];}
	elseif (isset($_POST["no_agent_delay"]))	{$no_agent_delay=$_POST["no_agent_delay"];}
if (isset($_GET["hopper_drop_run_trigger"]))			{$hopper_drop_run_trigger=$_GET["hopper_drop_run_trigger"];}
	elseif (isset($_POST["hopper_drop_run_trigger"]))	{$hopper_drop_run_trigger=$_POST["hopper_drop_run_trigger"];}
if (isset($_GET["hopper_drop_run_trigger_all"]))			{$hopper_drop_run_trigger_all=$_GET["hopper_drop_run_trigger_all"];}
	elseif (isset($_POST["hopper_drop_run_trigger_all"]))	{$hopper_drop_run_trigger_all=$_POST["hopper_drop_run_trigger_all"];}
if (isset($_GET["daily_call_count_limit"]))				{$daily_call_count_limit=$_GET["daily_call_count_limit"];}
	elseif (isset($_POST["daily_call_count_limit"]))	{$daily_call_count_limit=$_POST["daily_call_count_limit"];}
if (isset($_GET["daily_limit_manual"]))				{$daily_limit_manual=$_GET["daily_limit_manual"];}
	elseif (isset($_POST["daily_limit_manual"]))	{$daily_limit_manual=$_POST["daily_limit_manual"];}
if (isset($_GET["transfer_button_launch"]))				{$transfer_button_launch=$_GET["transfer_button_launch"];}
	elseif (isset($_POST["transfer_button_launch"]))	{$transfer_button_launch=$_POST["transfer_button_launch"];}
if (isset($_GET["allow_shared_dial"]))			{$allow_shared_dial=$_GET["allow_shared_dial"];}
	elseif (isset($_POST["allow_shared_dial"]))	{$allow_shared_dial=$_POST["allow_shared_dial"];}
if (isset($_GET["shared_dial_rank"]))			{$shared_dial_rank=$_GET["shared_dial_rank"];}
	elseif (isset($_POST["shared_dial_rank"]))	{$shared_dial_rank=$_POST["shared_dial_rank"];}
if (isset($_GET["mobile_number"]))			{$mobile_number=$_GET["mobile_number"];}
	elseif (isset($_POST["mobile_number"]))	{$mobile_number=$_POST["mobile_number"];}
if (isset($_GET["two_factor_auth_hours"]))			{$two_factor_auth_hours=$_GET["two_factor_auth_hours"];}
	elseif (isset($_POST["two_factor_auth_hours"]))	{$two_factor_auth_hours=$_POST["two_factor_auth_hours"];}
if (isset($_GET["two_factor_auth_agent_hours"]))			{$two_factor_auth_agent_hours=$_GET["two_factor_auth_agent_hours"];}
	elseif (isset($_POST["two_factor_auth_agent_hours"]))	{$two_factor_auth_agent_hours=$_POST["two_factor_auth_agent_hours"];}
if (isset($_GET["two_factor_container"]))			{$two_factor_container=$_GET["two_factor_container"];}
	elseif (isset($_POST["two_factor_container"]))	{$two_factor_container=$_POST["two_factor_container"];}
if (isset($_GET["two_factor_override"]))			{$two_factor_override=$_GET["two_factor_override"];}
	elseif (isset($_POST["two_factor_override"]))	{$two_factor_override=$_POST["two_factor_override"];}
if (isset($_GET["auth_entry"]))				{$auth_entry=$_GET["auth_entry"];}
	elseif (isset($_POST["auth_entry"]))	{$auth_entry=$_POST["auth_entry"];}
if (isset($_GET["clear_form"]))				{$clear_form=$_GET["clear_form"];}
	elseif (isset($_POST["clear_form"]))	{$clear_form=$_POST["clear_form"];}
if (isset($_GET["agent_hidden_sound"]))				{$agent_hidden_sound=$_GET["agent_hidden_sound"];}
	elseif (isset($_POST["agent_hidden_sound"]))	{$agent_hidden_sound=$_POST["agent_hidden_sound"];}
if (isset($_GET["agent_hidden_sound_volume"]))			{$agent_hidden_sound_volume=$_GET["agent_hidden_sound_volume"];}
	elseif (isset($_POST["agent_hidden_sound_volume"]))	{$agent_hidden_sound_volume=$_POST["agent_hidden_sound_volume"];}
if (isset($_GET["agent_hidden_sound_seconds"]))				{$agent_hidden_sound_seconds=$_GET["agent_hidden_sound_seconds"];}
	elseif (isset($_POST["agent_hidden_sound_seconds"]))	{$agent_hidden_sound_seconds=$_POST["agent_hidden_sound_seconds"];}
if (isset($_GET["leave_3way_start_recording"]))				{$leave_3way_start_recording=$_GET["leave_3way_start_recording"];}
	elseif (isset($_POST["leave_3way_start_recording"]))	{$leave_3way_start_recording=$_POST["leave_3way_start_recording"];}
if (isset($_GET["leave_3way_start_recording_exception"]))			{$leave_3way_start_recording_exception=$_GET["leave_3way_start_recording_exception"];}
	elseif (isset($_POST["leave_3way_start_recording_exception"]))	{$leave_3way_start_recording_exception=$_POST["leave_3way_start_recording_exception"];}
if (isset($_GET["populate_lead_comments"]))				{$populate_lead_comments=$_GET["populate_lead_comments"];}
	elseif (isset($_POST["populate_lead_comments"]))	{$populate_lead_comments=$_POST["populate_lead_comments"];}
if (isset($_GET["agent_screen_timer"]))				{$agent_screen_timer=$_GET["agent_screen_timer"];}
	elseif (isset($_POST["agent_screen_timer"]))	{$agent_screen_timer=$_POST["agent_screen_timer"];}
if (isset($_GET["calls_waiting_vl_one"]))				{$calls_waiting_vl_one=$_GET["calls_waiting_vl_one"];}
	elseif (isset($_POST["calls_waiting_vl_one"]))	{$calls_waiting_vl_one=$_POST["calls_waiting_vl_one"];}
if (isset($_GET["calls_waiting_vl_two"]))				{$calls_waiting_vl_two=$_GET["calls_waiting_vl_two"];}
	elseif (isset($_POST["calls_waiting_vl_two"]))	{$calls_waiting_vl_two=$_POST["calls_waiting_vl_two"];}
if (isset($_GET["label_lead_id"]))				{$label_lead_id=$_GET["label_lead_id"];}
	elseif (isset($_POST["label_lead_id"]))		{$label_lead_id=$_POST["label_lead_id"];}
if (isset($_GET["label_list_id"]))				{$label_list_id=$_GET["label_list_id"];}
	elseif (isset($_POST["label_list_id"]))		{$label_list_id=$_POST["label_list_id"];}
if (isset($_GET["label_entry_date"]))			{$label_entry_date=$_GET["label_entry_date"];}
	elseif (isset($_POST["label_entry_date"]))	{$label_entry_date=$_POST["label_entry_date"];}
if (isset($_GET["label_gmt_offset_now"]))			{$label_gmt_offset_now=$_GET["label_gmt_offset_now"];}
	elseif (isset($_POST["label_gmt_offset_now"]))	{$label_gmt_offset_now=$_POST["label_gmt_offset_now"];}
if (isset($_GET["label_source_id"]))				{$label_source_id=$_GET["label_source_id"];}
	elseif (isset($_POST["label_source_id"]))		{$label_source_id=$_POST["label_source_id"];}
if (isset($_GET["label_called_since_last_reset"]))			{$label_called_since_last_reset=$_GET["label_called_since_last_reset"];}
	elseif (isset($_POST["label_called_since_last_reset"]))	{$label_called_since_last_reset=$_POST["label_called_since_last_reset"];}
if (isset($_GET["label_status"]))			{$label_status=$_GET["label_status"];}
	elseif (isset($_POST["label_status"]))	{$label_status=$_POST["label_status"];}
if (isset($_GET["label_user"]))				{$label_user=$_GET["label_user"];}
	elseif (isset($_POST["label_user"]))	{$label_user=$_POST["label_user"];}
if (isset($_GET["label_date_of_birth"]))			{$label_date_of_birth=$_GET["label_date_of_birth"];}
	elseif (isset($_POST["label_date_of_birth"]))	{$label_date_of_birth=$_POST["label_date_of_birth"];}
if (isset($_GET["label_country_code"]))				{$label_country_code=$_GET["label_country_code"];}
	elseif (isset($_POST["label_country_code"]))	{$label_country_code=$_POST["label_country_code"];}
if (isset($_GET["label_last_local_call_time"]))				{$label_last_local_call_time=$_GET["label_last_local_call_time"];}
	elseif (isset($_POST["label_last_local_call_time"]))	{$label_last_local_call_time=$_POST["label_last_local_call_time"];}
if (isset($_GET["label_called_count"]))				{$label_called_count=$_GET["label_called_count"];}
	elseif (isset($_POST["label_called_count"]))	{$label_called_count=$_POST["label_called_count"];}
if (isset($_GET["label_rank"]))				{$label_rank=$_GET["label_rank"];}
	elseif (isset($_POST["label_rank"]))	{$label_rank=$_POST["label_rank"];}
if (isset($_GET["label_owner"]))			{$label_owner=$_GET["label_owner"];}
	elseif (isset($_POST["label_owner"]))	{$label_owner=$_POST["label_owner"];}
if (isset($_GET["label_entry_list_id"]))			{$label_entry_list_id=$_GET["label_entry_list_id"];}
	elseif (isset($_POST["label_entry_list_id"]))	{$label_entry_list_id=$_POST["label_entry_list_id"];}
if (isset($_GET["calls_inqueue_count_one"]))			{$calls_inqueue_count_one=$_GET["calls_inqueue_count_one"];}
	elseif (isset($_POST["calls_inqueue_count_one"]))	{$calls_inqueue_count_one=$_POST["calls_inqueue_count_one"];}
if (isset($_GET["calls_inqueue_count_two"]))			{$calls_inqueue_count_two=$_GET["calls_inqueue_count_two"];}
	elseif (isset($_POST["calls_inqueue_count_two"]))	{$calls_inqueue_count_two=$_POST["calls_inqueue_count_two"];}
if (isset($_GET["mohsuggest"]))				{$mohsuggest=$_GET["mohsuggest"];}
	elseif (isset($_POST["mohsuggest"]))	{$mohsuggest=$_POST["mohsuggest"];}
if (isset($_GET["drop_call_seconds_override"]))				{$drop_call_seconds_override=$_GET["drop_call_seconds_override"];}
	elseif (isset($_POST["drop_call_seconds_override"]))	{$drop_call_seconds_override=$_POST["drop_call_seconds_override"];}
if (isset($_GET["in_man_dial_next_ready_seconds"]))				{$in_man_dial_next_ready_seconds=$_GET["in_man_dial_next_ready_seconds"];}
	elseif (isset($_POST["in_man_dial_next_ready_seconds"]))	{$in_man_dial_next_ready_seconds=$_POST["in_man_dial_next_ready_seconds"];}
if (isset($_GET["in_man_dial_next_ready_seconds_override"]))			{$in_man_dial_next_ready_seconds_override=$_GET["in_man_dial_next_ready_seconds_override"];}
	elseif (isset($_POST["in_man_dial_next_ready_seconds_override"]))	{$in_man_dial_next_ready_seconds_override=$_POST["in_man_dial_next_ready_seconds_override"];}
if (isset($_GET["transfer_no_dispo"]))			{$transfer_no_dispo=$_GET["transfer_no_dispo"];}
	elseif (isset($_POST["transfer_no_dispo"]))	{$transfer_no_dispo=$_POST["transfer_no_dispo"];}
if (isset($_GET["call_limit_24hour_method"]))			{$call_limit_24hour_method=$_GET["call_limit_24hour_method"];}
	elseif (isset($_POST["call_limit_24hour_method"]))	{$call_limit_24hour_method=$_POST["call_limit_24hour_method"];}
if (isset($_GET["call_limit_24hour_scope"]))			{$call_limit_24hour_scope=$_GET["call_limit_24hour_scope"];}
	elseif (isset($_POST["call_limit_24hour_scope"]))	{$call_limit_24hour_scope=$_POST["call_limit_24hour_scope"];}
if (isset($_GET["call_limit_24hour"]))			{$call_limit_24hour=$_GET["call_limit_24hour"];}
	elseif (isset($_POST["call_limit_24hour"]))	{$call_limit_24hour=$_POST["call_limit_24hour"];}
if (isset($_GET["call_limit_24hour_override"]))			{$call_limit_24hour_override=$_GET["call_limit_24hour_override"];}
	elseif (isset($_POST["call_limit_24hour_override"]))	{$call_limit_24hour_override=$_POST["call_limit_24hour_override"];}
if (isset($_GET["cid_group_id_two"]))			{$cid_group_id_two=$_GET["cid_group_id_two"];}
	elseif (isset($_POST["cid_group_id_two"]))	{$cid_group_id_two=$_POST["cid_group_id_two"];}
if (isset($_GET["allowed_sip_stacks"]))				{$allowed_sip_stacks=$_GET["allowed_sip_stacks"];}
	elseif (isset($_POST["allowed_sip_stacks"]))	{$allowed_sip_stacks=$_POST["allowed_sip_stacks"];}
if (isset($_GET["populate_lead_owner"]))			{$populate_lead_owner=$_GET["populate_lead_owner"];}
	elseif (isset($_POST["populate_lead_owner"]))	{$populate_lead_owner=$_POST["populate_lead_owner"];}
if (isset($_GET["incall_tally_threshold_seconds"]))				{$incall_tally_threshold_seconds=$_GET["incall_tally_threshold_seconds"];}
	elseif (isset($_POST["incall_tally_threshold_seconds"]))	{$incall_tally_threshold_seconds=$_POST["incall_tally_threshold_seconds"];}
if (isset($_GET["in_queue_nanque"]))			{$in_queue_nanque=$_GET["in_queue_nanque"];}
	elseif (isset($_POST["in_queue_nanque"]))	{$in_queue_nanque=$_POST["in_queue_nanque"];}
if (isset($_GET["in_queue_nanque_exceptions"]))				{$in_queue_nanque_exceptions=$_GET["in_queue_nanque_exceptions"];}
	elseif (isset($_POST["in_queue_nanque_exceptions"]))	{$in_queue_nanque_exceptions=$_POST["in_queue_nanque_exceptions"];}
if (isset($_GET["user_location"]))			{$user_location=$_GET["user_location"];}
	elseif (isset($_POST["user_location"]))	{$user_location=$_POST["user_location"];}
if (isset($_GET["queue_group"]))			{$queue_group=$_GET["queue_group"];}
	elseif (isset($_POST["queue_group"]))	{$queue_group=$_POST["queue_group"];}
if (isset($_GET["queue_group_name"]))			{$queue_group_name=$_GET["queue_group_name"];}
	elseif (isset($_POST["queue_group_name"]))	{$queue_group_name=$_POST["queue_group_name"];}
if (isset($_GET["included_campaigns"]))				{$included_campaigns=$_GET["included_campaigns"];}
	elseif (isset($_POST["included_campaigns"]))	{$included_campaigns=$_POST["included_campaigns"];}
if (isset($_GET["included_inbound_groups"]))			{$included_inbound_groups=$_GET["included_inbound_groups"];}
	elseif (isset($_POST["included_inbound_groups"]))	{$included_inbound_groups=$_POST["included_inbound_groups"];}
if (isset($_GET["allowed_queue_groups"]))			{$allowed_queue_groups=$_GET["allowed_queue_groups"];}
	elseif (isset($_POST["allowed_queue_groups"]))	{$allowed_queue_groups=$_POST["allowed_queue_groups"];}
if (isset($_GET["reports_header_override"]))			{$reports_header_override=$_GET["reports_header_override"];}
	elseif (isset($_POST["reports_header_override"]))	{$reports_header_override=$_POST["reports_header_override"];}
if (isset($_GET["queue_groups"]))			{$queue_groups=$_GET["queue_groups"];}
	elseif (isset($_POST["queue_groups"]))	{$queue_groups=$_POST["queue_groups"];}
if (isset($_GET["auto_alt_threshold"]))				{$auto_alt_threshold=$_GET["auto_alt_threshold"];}
	elseif (isset($_POST["auto_alt_threshold"]))	{$auto_alt_threshold=$_POST["auto_alt_threshold"];}
if (isset($_GET["download_invalid_files"]))				{$download_invalid_files=$_GET["download_invalid_files"];}
	elseif (isset($_POST["download_invalid_files"]))	{$download_invalid_files=$_POST["download_invalid_files"];}
if (isset($_GET["pause_max_url"]))			{$pause_max_url=$_GET["pause_max_url"];}
	elseif (isset($_POST["pause_max_url"]))	{$pause_max_url=$_POST["pause_max_url"];}
if (isset($_GET["agent_hide_hangup"]))			{$agent_hide_hangup=$_GET["agent_hide_hangup"];}
	elseif (isset($_POST["agent_hide_hangup"]))	{$agent_hide_hangup=$_POST["agent_hide_hangup"];}
if (isset($_GET["allow_web_debug"]))			{$allow_web_debug=$_GET["allow_web_debug"];}
	elseif (isset($_POST["allow_web_debug"]))	{$allow_web_debug=$_POST["allow_web_debug"];}
if (isset($_GET["ig_xfer_list_sort"]))			{$ig_xfer_list_sort=$_GET["ig_xfer_list_sort"];}
	elseif (isset($_POST["ig_xfer_list_sort"]))	{$ig_xfer_list_sort=$_POST["ig_xfer_list_sort"];}
if (isset($_GET["pre_filter_recent_call"]))				{$pre_filter_recent_call=$_GET["pre_filter_recent_call"];}
	elseif (isset($_POST["pre_filter_recent_call"]))	{$pre_filter_recent_call=$_POST["pre_filter_recent_call"];}
if (isset($_GET["pre_filter_recent_extension"]))			{$pre_filter_recent_extension=$_GET["pre_filter_recent_extension"];}
	elseif (isset($_POST["pre_filter_recent_extension"]))	{$pre_filter_recent_extension=$_POST["pre_filter_recent_extension"];}
if (isset($_GET["script_tab_frame_size"]))			{$script_tab_frame_size=$_GET["script_tab_frame_size"];}
	elseif (isset($_POST["script_tab_frame_size"]))	{$script_tab_frame_size=$_POST["script_tab_frame_size"];}
if (isset($_GET["user_group_two"]))				{$user_group_two=$_GET["user_group_two"];}
	elseif (isset($_POST["user_group_two"]))	{$user_group_two=$_POST["user_group_two"];}
if (isset($_GET["max_logged_in_agents"]))				{$max_logged_in_agents=$_GET["max_logged_in_agents"];}
	elseif (isset($_POST["max_logged_in_agents"]))	{$max_logged_in_agents=$_POST["max_logged_in_agents"];}
if (isset($_GET["user_codes_admin"]))				{$user_codes_admin=$_GET["user_codes_admin"];}
	elseif (isset($_POST["user_codes_admin"]))	{$user_codes_admin=$_POST["user_codes_admin"];}
if (isset($_GET["conf_engine"]))			{$conf_engine=$_GET["conf_engine"];}
	elseif (isset($_POST["conf_engine"]))	{$conf_engine=$_POST["conf_engine"];}
if (isset($_GET["conf_update_interval"]))			{$conf_update_interval=$_GET["conf_update_interval"];}
	elseif (isset($_POST["conf_update_interval"]))	{$conf_update_interval=$_POST["conf_update_interval"];}
if (isset($_GET["user_group_script"]))			{$user_group_script=$_GET["user_group_script"];}
	elseif (isset($_POST["user_group_script"]))	{$user_group_script=$_POST["user_group_script"];}
if (isset($_GET["login_kickall"]))			{$login_kickall=$_GET["login_kickall"];}
	elseif (isset($_POST["login_kickall"]))	{$login_kickall=$_POST["login_kickall"];}
if (isset($_GET["city_rule"]))			{$city_rule=$_GET["city_rule"];}
	elseif (isset($_POST["city_rule"]))	{$city_rule=$_POST["city_rule"];}
if (isset($_GET["county_rule"]))			{$county_rule=$_GET["county_rule"];}
	elseif (isset($_POST["county_rule"]))	{$county_rule=$_POST["county_rule"];}
if (isset($_GET["ac_rule"]))			{$ac_rule=$_GET["ac_rule"];}
	elseif (isset($_POST["ac_rule"]))	{$ac_rule=$_POST["ac_rule"];}
if (isset($_GET["agent_hangup_route"]))				{$agent_hangup_route=$_GET["agent_hangup_route"];}
	elseif (isset($_POST["agent_hangup_route"]))	{$agent_hangup_route=$_POST["agent_hangup_route"];}
if (isset($_GET["agent_hangup_value"]))				{$agent_hangup_value=$_GET["agent_hangup_value"];}
	elseif (isset($_POST["agent_hangup_value"]))	{$agent_hangup_value=$_POST["agent_hangup_value"];}
if (isset($_GET["agent_hangup_ig_override"]))			{$agent_hangup_ig_override=$_GET["agent_hangup_ig_override"];}
	elseif (isset($_POST["agent_hangup_ig_override"]))	{$agent_hangup_ig_override=$_POST["agent_hangup_ig_override"];}
if (isset($_GET["abandon_check_queue"]))			{$abandon_check_queue=$_GET["abandon_check_queue"];}
	elseif (isset($_POST["abandon_check_queue"]))	{$abandon_check_queue=$_POST["abandon_check_queue"];}
if (isset($_GET["ara_url"]))			{$ara_url=$_GET["ara_url"];}
	elseif (isset($_POST["ara_url"]))	{$ara_url=$_POST["ara_url"];}
if (isset($_GET["show_confetti"]))			{$show_confetti=$_GET["show_confetti"];}
	elseif (isset($_POST["show_confetti"]))	{$show_confetti=$_POST["show_confetti"];}
if (isset($_GET["webphone_settings"]))			{$webphone_settings=$_GET["webphone_settings"];}
	elseif (isset($_POST["webphone_settings"]))	{$webphone_settings=$_POST["webphone_settings"];}
if (isset($_GET["agent_notifications"]))			{$agent_notifications=$_GET["agent_notifications"];}
	elseif (isset($_POST["agent_notifications"]))	{$agent_notifications=$_POST["agent_notifications"];}
if (isset($_GET["demographic_quotas"]))				{$demographic_quotas=$_GET["demographic_quotas"];}
	elseif (isset($_POST["demographic_quotas"]))	{$demographic_quotas=$_POST["demographic_quotas"];}
if (isset($_GET["demographic_quotas_container"]))			{$demographic_quotas_container=$_GET["demographic_quotas_container"];}
	elseif (isset($_POST["demographic_quotas_container"]))	{$demographic_quotas_container=$_POST["demographic_quotas_container"];}
if (isset($_GET["demographic_quotas_rerank"]))			{$demographic_quotas_rerank=$_GET["demographic_quotas_rerank"];}
	elseif (isset($_POST["demographic_quotas_rerank"]))	{$demographic_quotas_rerank=$_POST["demographic_quotas_rerank"];}
if (isset($_GET["demographic_quotas_list_resets"]))			{$demographic_quotas_list_resets=$_GET["demographic_quotas_list_resets"];}
	elseif (isset($_POST["demographic_quotas_list_resets"]))	{$demographic_quotas_list_resets=$_POST["demographic_quotas_list_resets"];}
if (isset($_GET["log_latency_gaps"]))			{$log_latency_gaps=$_GET["log_latency_gaps"];}
	elseif (isset($_POST["log_latency_gaps"]))	{$log_latency_gaps=$_POST["log_latency_gaps"];}
if (isset($_GET["modify_dial_prefix"]))				{$modify_dial_prefix=$_GET["modify_dial_prefix"];}
	elseif (isset($_POST["modify_dial_prefix"]))	{$modify_dial_prefix=$_POST["modify_dial_prefix"];}
if (isset($_GET["inbound_credits"]))			{$inbound_credits=$_GET["inbound_credits"];}
	elseif (isset($_POST["inbound_credits"]))	{$inbound_credits=$_POST["inbound_credits"];}
if (isset($_GET["weekday_resets"]))				{$weekday_resets=$_GET["weekday_resets"];}
	elseif (isset($_POST["weekday_resets"]))	{$weekday_resets=$_POST["weekday_resets"];}
if (isset($_GET["weekday_resets_container"]))			{$weekday_resets_container=$_GET["weekday_resets_container"];}
	elseif (isset($_POST["weekday_resets_container"]))	{$weekday_resets_container=$_POST["weekday_resets_container"];}
if (isset($_GET["second_alert_trigger"]))			{$second_alert_trigger=$_GET["second_alert_trigger"];}
	elseif (isset($_POST["second_alert_trigger"]))	{$second_alert_trigger=$_POST["second_alert_trigger"];}
if (isset($_GET["second_alert_trigger_seconds"]))			{$second_alert_trigger_seconds=$_GET["second_alert_trigger_seconds"];}
	elseif (isset($_POST["second_alert_trigger_seconds"]))	{$second_alert_trigger_seconds=$_POST["second_alert_trigger_seconds"];}
if (isset($_GET["second_alert_filename"]))			{$second_alert_filename=$_GET["second_alert_filename"];}
	elseif (isset($_POST["second_alert_filename"]))	{$second_alert_filename=$_POST["second_alert_filename"];}
if (isset($_GET["second_alert_delay"]))				{$second_alert_delay=$_GET["second_alert_delay"];}
	elseif (isset($_POST["second_alert_delay"]))	{$second_alert_delay=$_POST["second_alert_delay"];}
if (isset($_GET["second_alert_container"]))				{$second_alert_container=$_GET["second_alert_container"];}
	elseif (isset($_POST["second_alert_container"]))	{$second_alert_container=$_POST["second_alert_container"];}
if (isset($_GET["second_alert_only"]))			{$second_alert_only=$_GET["second_alert_only"];}
	elseif (isset($_POST["second_alert_only"]))	{$second_alert_only=$_POST["second_alert_only"];}
if (isset($_GET["dead_stop_recording"]))			{$dead_stop_recording=$_GET["dead_stop_recording"];}
	elseif (isset($_POST["dead_stop_recording"]))	{$dead_stop_recording=$_POST["dead_stop_recording"];}
if (isset($_GET["manual_vm_status_updates"]))			{$manual_vm_status_updates=$_GET["manual_vm_status_updates"];}
	elseif (isset($_POST["manual_vm_status_updates"]))	{$manual_vm_status_updates=$_POST["manual_vm_status_updates"];}
if (isset($_GET["force_per_call_notes"]))			{$force_per_call_notes=$_GET["force_per_call_notes"];}
	elseif (isset($_POST["force_per_call_notes"]))	{$force_per_call_notes=$_POST["force_per_call_notes"];}
if (isset($_GET["third_alert_trigger"]))			{$third_alert_trigger=$_GET["third_alert_trigger"];}
	elseif (isset($_POST["third_alert_trigger"]))	{$third_alert_trigger=$_POST["third_alert_trigger"];}
if (isset($_GET["third_alert_trigger_seconds"]))			{$third_alert_trigger_seconds=$_GET["third_alert_trigger_seconds"];}
	elseif (isset($_POST["third_alert_trigger_seconds"]))	{$third_alert_trigger_seconds=$_POST["third_alert_trigger_seconds"];}
if (isset($_GET["third_alert_filename"]))			{$third_alert_filename=$_GET["third_alert_filename"];}
	elseif (isset($_POST["third_alert_filename"]))	{$third_alert_filename=$_POST["third_alert_filename"];}
if (isset($_GET["third_alert_delay"]))			{$third_alert_delay=$_GET["third_alert_delay"];}
	elseif (isset($_POST["third_alert_delay"]))	{$third_alert_delay=$_POST["third_alert_delay"];}
if (isset($_GET["third_alert_container"]))			{$third_alert_container=$_GET["third_alert_container"];}
	elseif (isset($_POST["third_alert_container"]))	{$third_alert_container=$_POST["third_alert_container"];}
if (isset($_GET["third_alert_only"]))			{$third_alert_only=$_GET["third_alert_only"];}
	elseif (isset($_POST["third_alert_only"]))	{$third_alert_only=$_POST["third_alert_only"];}
if (isset($_GET["agent_search_ingroup_list"]))			{$agent_search_ingroup_list=$_GET["agent_search_ingroup_list"];}
	elseif (isset($_POST["agent_search_ingroup_list"]))	{$agent_search_ingroup_list=$_POST["agent_search_ingroup_list"];}
if (isset($_GET["agent_search_list"]))			{$agent_search_list=$_GET["agent_search_list"];}
	elseif (isset($_POST["agent_search_list"]))	{$agent_search_list=$_POST["agent_search_list"];}
if (isset($_GET["hopper_hold_inserts"]))			{$hopper_hold_inserts=$_GET["hopper_hold_inserts"];}
	elseif (isset($_POST["hopper_hold_inserts"]))	{$hopper_hold_inserts=$_POST["hopper_hold_inserts"];}
if (isset($_GET["hci_enabled"]))			{$hci_enabled=$_GET["hci_enabled"];}
	elseif (isset($_POST["hci_enabled"]))	{$hci_enabled=$_POST["hci_enabled"];}
if (isset($_GET["daily_phone_number_call_limit"]))			{$daily_phone_number_call_limit=$_GET["daily_phone_number_call_limit"];}
	elseif (isset($_POST["daily_phone_number_call_limit"]))	{$daily_phone_number_call_limit=$_POST["daily_phone_number_call_limit"];}
if (isset($_GET["state_descriptions"]))				{$state_descriptions=$_GET["state_descriptions"];}
	elseif (isset($_POST["state_descriptions"]))	{$state_descriptions=$_POST["state_descriptions"];}
if (isset($_GET["holiday_method"]))				{$holiday_method=$_GET["holiday_method"];}
	elseif (isset($_POST["holiday_method"]))	{$holiday_method=$_POST["holiday_method"];}
if (isset($_GET["script_tab_height"]))			{$script_tab_height=$_GET["script_tab_height"];}
	elseif (isset($_POST["script_tab_height"]))	{$script_tab_height=$_POST["script_tab_height"];}
if (isset($_GET["call_log_days"]))			{$call_log_days=$_GET["call_log_days"];}
	elseif (isset($_POST["call_log_days"]))	{$call_log_days=$_POST["call_log_days"];}
if (isset($_GET["leave_3way_stop_recording"]))			{$leave_3way_stop_recording=$_GET["leave_3way_stop_recording"];}
	elseif (isset($_POST["leave_3way_stop_recording"]))	{$leave_3way_stop_recording=$_POST["leave_3way_stop_recording"];}
if (isset($_GET["coldstorage_server_ip"]))			{$coldstorage_server_ip=$_GET["coldstorage_server_ip"];}
	elseif (isset($_POST["coldstorage_server_ip"]))	{$coldstorage_server_ip=$_POST["coldstorage_server_ip"];}
if (isset($_GET["coldstorage_dbname"]))				{$coldstorage_dbname=$_GET["coldstorage_dbname"];}
	elseif (isset($_POST["coldstorage_dbname"]))	{$coldstorage_dbname=$_POST["coldstorage_dbname"];}
if (isset($_GET["coldstorage_login"]))			{$coldstorage_login=$_GET["coldstorage_login"];}
	elseif (isset($_POST["coldstorage_login"]))	{$coldstorage_login=$_POST["coldstorage_login"];}
if (isset($_GET["coldstorage_pass"]))			{$coldstorage_pass=$_GET["coldstorage_pass"];}
	elseif (isset($_POST["coldstorage_pass"]))	{$coldstorage_pass=$_POST["coldstorage_pass"];}
if (isset($_GET["coldstorage_port"]))			{$coldstorage_port=$_GET["coldstorage_port"];}
	elseif (isset($_POST["coldstorage_port"]))	{$coldstorage_port=$_POST["coldstorage_port"];}
if (isset($_GET["manual_minimum_ring_seconds"]))			{$manual_minimum_ring_seconds=$_GET["manual_minimum_ring_seconds"];}
	elseif (isset($_POST["manual_minimum_ring_seconds"]))	{$manual_minimum_ring_seconds=$_POST["manual_minimum_ring_seconds"];}
if (isset($_GET["manual_minimum_attempt_seconds"]))				{$manual_minimum_attempt_seconds=$_GET["manual_minimum_attempt_seconds"];}
	elseif (isset($_POST["manual_minimum_attempt_seconds"]))	{$manual_minimum_attempt_seconds=$_POST["manual_minimum_attempt_seconds"];}
if (isset($_GET["manual_minimum_answer_seconds"]))			{$manual_minimum_answer_seconds=$_GET["manual_minimum_answer_seconds"];}
	elseif (isset($_POST["manual_minimum_answer_seconds"]))	{$manual_minimum_answer_seconds=$_POST["manual_minimum_answer_seconds"];}
if (isset($_GET["khomp_settings_container"]))			{$khomp_settings_container=$_GET["khomp_settings_container"];}
	elseif (isset($_POST["khomp_settings_container"]))	{$khomp_settings_container=$_POST["khomp_settings_container"];}
if (isset($_GET["enhanced_agent_monitoring"]))			{$enhanced_agent_monitoring=$_GET["enhanced_agent_monitoring"];}
	elseif (isset($_POST["enhanced_agent_monitoring"]))	{$enhanced_agent_monitoring=$_POST["enhanced_agent_monitoring"];}
if (isset($_GET["agent_hide_dial_fail"]))			{$agent_hide_dial_fail=$_GET["agent_hide_dial_fail"];}
	elseif (isset($_POST["agent_hide_dial_fail"]))	{$agent_hide_dial_fail=$_POST["agent_hide_dial_fail"];}
if (isset($_GET["apinewlead_url"]))				{$apinewlead_url=$_GET["apinewlead_url"];}
	elseif (isset($_POST["apinewlead_url"]))	{$apinewlead_url=$_POST["apinewlead_url"];}
if (isset($_GET["agent_man_dial_filter"]))			{$agent_man_dial_filter=$_GET["agent_man_dial_filter"];}
	elseif (isset($_POST["agent_man_dial_filter"]))	{$agent_man_dial_filter=$_POST["agent_man_dial_filter"];}
if (isset($_GET["agent_3way_dial_filter"]))				{$agent_3way_dial_filter=$_GET["agent_3way_dial_filter"];}
	elseif (isset($_POST["agent_3way_dial_filter"]))	{$agent_3way_dial_filter=$_POST["agent_3way_dial_filter"];}
if (isset($_GET["stereo_recording"]))			{$stereo_recording=$_GET["stereo_recording"];}
	elseif (isset($_POST["stereo_recording"]))	{$stereo_recording=$_POST["stereo_recording"];}
if (isset($_GET["recording_dtmf_detection"]))			{$recording_dtmf_detection=$_GET["recording_dtmf_detection"];}
	elseif (isset($_POST["recording_dtmf_detection"]))	{$recording_dtmf_detection=$_POST["recording_dtmf_detection"];}
if (isset($_GET["recording_dtmf_muting"]))			{$recording_dtmf_muting=$_GET["recording_dtmf_muting"];}
	elseif (isset($_POST["recording_dtmf_muting"]))	{$recording_dtmf_muting=$_POST["recording_dtmf_muting"];}
if (isset($_GET["stereo_parallel_recording"]))			{$stereo_parallel_recording=$_GET["stereo_parallel_recording"];}
	elseif (isset($_POST["stereo_parallel_recording"]))	{$stereo_parallel_recording=$_POST["stereo_parallel_recording"];}
if (isset($_GET["stereo_rec_filename"]))			{$stereo_rec_filename=$_GET["stereo_rec_filename"];}
	elseif (isset($_POST["stereo_rec_filename"]))	{$stereo_rec_filename=$_POST["stereo_rec_filename"];}
if (isset($_GET["stereo_recording_agent"]))			{$stereo_recording_agent=$_GET["stereo_recording_agent"];}
	elseif (isset($_POST["stereo_recording_agent"]))	{$stereo_recording_agent=$_POST["stereo_recording_agent"];}
if (isset($_GET["parallel_rec_co_filename"]))			{$parallel_rec_co_filename=$_GET["parallel_rec_co_filename"];}
	elseif (isset($_POST["parallel_rec_co_filename"]))	{$parallel_rec_co_filename=$_POST["parallel_rec_co_filename"];}
if (isset($_GET["parallel_rec_cm_filename"]))			{$parallel_rec_cm_filename=$_GET["parallel_rec_cm_filename"];}
	elseif (isset($_POST["parallel_rec_cm_filename"]))	{$parallel_rec_cm_filename=$_POST["parallel_rec_cm_filename"];}
if (isset($_GET["parallel_rec_fr_filename"]))			{$parallel_rec_fr_filename=$_GET["parallel_rec_fr_filename"];}
	elseif (isset($_POST["parallel_rec_fr_filename"]))	{$parallel_rec_fr_filename=$_POST["parallel_rec_fr_filename"];}
if (isset($_GET["call_count_limit_restrict"]))			{$call_count_limit_restrict=$_GET["call_count_limit_restrict"];}
	elseif (isset($_POST["call_count_limit_restrict"]))	{$call_count_limit_restrict=$_POST["call_count_limit_restrict"];}

$DB=preg_replace("/[^0-9a-zA-Z]/","",$DB);

if (isset($script_id)) {$script_id= mb_strtoupper($script_id,'utf-8');}
if (isset($lead_filter_id)) {$lead_filter_id = mb_strtoupper($lead_filter_id,'utf-8');}

if (strlen($dial_status) > 0) 
	{
	$ADD='28';
	$status = $dial_status;
	}

#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,enable_queuemetrics_logging,enable_vtiger_integration,qc_features_active,outbound_autodial_active,sounds_central_control_active,enable_second_webform,user_territories_active,custom_fields_enabled,admin_web_directory,webphone_url,first_login_trigger,hosted_settings,default_phone_registration_password,default_phone_login_password,default_server_password,test_campaign_calls,active_voicemail_server,voicemail_timezones,default_voicemail_timezone,default_local_gmt,campaign_cid_areacodes_enabled,pllb_grouping_limit,did_ra_extensions_enabled,expanded_list_stats,contacts_enabled,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,call_menu_qualify_enabled,admin_list_counts,allow_voicemail_greeting,svn_revision,allow_emails,level_8_disable_add,pass_key,pass_hash_enabled,disable_auto_dial,country_code_list_stats,frozen_server_call_clear,active_modules,allow_chats,enable_languages,language_method,meetme_enter_login_filename,meetme_enter_leave3way_filename,enable_did_entry_list_id,enable_third_webform,default_language,user_hide_realtime_enabled,log_recording_access,alt_ivr_logging,admin_row_click,admin_screen_colors,ofcom_uk_drop_calc,agent_screen_colors,script_remove_js,manual_auto_next,user_new_lead_limit,agent_xfer_park_3way,agent_soundboards,web_loader_phone_length,agent_script,enable_auto_reports,enable_pause_code_limits,enable_drop_lists,allow_ip_lists,system_ip_blacklist,hide_inactive_lists,allow_manage_active_lists,expired_lists_inactive,did_system_filter,enable_gdpr_download_deletion,mute_recordings,user_admin_redirect,list_status_modification_confirmation,sip_event_logging,call_quota_lead_ranking,enable_second_script,enable_first_webform,recording_buttons,opensips_cid_name,require_password_length,user_account_emails,outbound_cid_any,entries_per_page,browser_call_alerts,inbound_answer_config,enable_international_dncs,daily_call_count_limit,allow_shared_dial,agent_search_method,admin_home_url,qc_claim_limit,qc_expire_days,two_factor_auth_hours,two_factor_container,call_limit_24hour,allowed_sip_stacks,agent_hide_hangup,allow_web_debug,max_logged_in_agents,user_codes_admin,abandon_check_queue,agent_notifications,demographic_quotas,inbound_credits,weekday_resets,two_factor_auth_agent_hours,hopper_hold_inserts,coldstorage_server_ip,coldstorage_dbname,coldstorage_login,coldstorage_pass,coldstorage_port,enhanced_agent_monitoring,stereo_recording,recording_dtmf_detection,recording_dtmf_muting,stereo_parallel_recording FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
#if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
	{
	$row=mysqli_fetch_row($rslt);
	$non_latin =							$row[0];
	$SSenable_queuemetrics_logging =		$row[1];
	$SSenable_vtiger_integration =			$row[2];
	$SSqc_features_active =					$row[3];
	$SSoutbound_autodial_active =			$row[4];
	$SSsounds_central_control_active =		$row[5];
	$SSenable_second_webform =				$row[6];
	$SSuser_territories_active =			$row[7];
	$SScustom_fields_enabled =				$row[8];
	$SSadmin_web_directory =				$row[9];
	$SSwebphone_url =						$row[10];
	$SSfirst_login_trigger =				$row[11];
	$SShosted_settings =					$row[12];
	$SSdefault_phone_registration_password =$row[13];
	$SSdefault_phone_login_password =		$row[14];
	$SSdefault_server_password =			$row[15];
	$SStest_campaign_calls =				$row[16];
	$SSactive_voicemail_server =			$row[17];
	$SSvoicemail_timezones =				$row[18];
	$SSdefault_voicemail_timezone =			$row[19];
	$SSdefault_local_gmt =					$row[20];
	$SScampaign_cid_areacodes_enabled =		$row[21];
	$SSpllb_grouping_limit =				$row[22];
	$SSdid_ra_extensions_enabled =			$row[23];
	$SSexpanded_list_stats =				$row[24];
	$SScontacts_enabled =					$row[25];
	$SSalt_log_server_ip =					$row[26];
	$SSalt_log_dbname =						$row[27];
	$SSalt_log_login =						$row[28];
	$SSalt_log_pass =						$row[29];
	$SStables_use_alt_log_db =				$row[30];
	$SScall_menu_qualify_enabled =			$row[31];
	$SSadmin_list_counts =					$row[32];
	$SSallow_voicemail_greeting =			$row[33];
	$SSsvn_revision =						$row[34];
	$SSallow_emails =						$row[35];
	$SSlevel_8_disable_add =				$row[36];
	$SSpass_key =							$row[37];
	$SSpass_hash_enabled =					$row[38];
	$SSdisable_auto_dial =					$row[39];
	$SScountry_code_list_stats =			$row[40];
	$SSfrozen_server_call_clear =			$row[41];
	$SSactive_modules =						$row[42];
	$SSallow_chats =						$row[43];
	$SSenable_languages =					$row[44];
	$SSlanguage_method =					$row[45];
	$SSmeetme_enter_login_filename =		$row[46];
	$SSmeetme_enter_leave3way_filename =	$row[47];
	$SSenable_did_entry_list_id =			$row[48];
	$SSenable_third_webform =				$row[49];
	$SSdefault_language =					$row[50];
	$SSuser_hide_realtime_enabled =			$row[51];
	$SSlog_recording_access =				$row[52];
	$SSalt_ivr_logging =					$row[53];
	$SSadmin_row_click =					$row[54];
	$SSadmin_screen_colors =				$row[55];
	$SSofcom_uk_drop_calc =					$row[56];
	$SSagent_screen_colors =				$row[57];
	$SSscript_remove_js =					$row[58];
	$SSmanual_auto_next =					$row[59];
	$SSuser_new_lead_limit =				$row[60];
	$SSagent_xfer_park_3way =				$row[61];
	$SSagent_soundboards =					$row[62];
	$SSweb_loader_phone_length =			$row[63];
	$SSagent_script =						$row[64];
	$SSenable_auto_reports =				$row[65];
	$SSenable_pause_code_limits =			$row[66];
	$SSenable_drop_lists =					$row[67];
	$SSallow_ip_lists =						$row[68];
	$SSsystem_ip_blacklist =				$row[69];
	$SShide_inactive_lists =				$row[70];
	$SSallow_manage_active_lists =			$row[71];
	$SSexpired_lists_inactive =				$row[72];
	$SSdid_system_filter =					$row[73];
	$SSenable_gdpr_download_deletion =		$row[74];
	$SSmute_recordings =					$row[75];
	$SSuser_admin_redirect =				$row[76];
	$SSlist_status_modification_confirmation =	$row[77];
	$SSsip_event_logging =					$row[78];
	$SScall_quota_lead_ranking =			$row[79];
	$SSenable_second_script =				$row[80];
	$SSenable_first_webform =				$row[81];
	$SSrecording_buttons =					$row[82];
	$SSopensips_cid_name =					$row[83];
	$SSrequire_password_length =			$row[84];
	$SSuser_account_emails =				$row[85];
	$SSoutbound_cid_any =					$row[86];
	$SSentries_per_page =					$row[87];
	$SSbrowser_call_alerts =				$row[88];
	$SSinbound_answer_config =				$row[89];
	$SSenable_international_dncs =			$row[90];
	$SSdaily_call_count_limit =				$row[91];
	$SSallow_shared_dial =					$row[92];
	$SSagent_search_method =				$row[93];
	$SSadmin_home_url =						$row[94];
	$SSqc_claim_limit =						$row[95];
	$SSqc_expire_days =						$row[96];
	$SStwo_factor_auth_hours =				$row[97];
	$SStwo_factor_container =				$row[98];
	$SScall_limit_24hour =					$row[99];
	$SSallowed_sip_stacks =					$row[100];
	$SSagent_hide_hangup =					$row[101];
	$SSallow_web_debug =					$row[102];
	$SSmax_logged_in_agents =				$row[103];
	$SSuser_codes_admin =					$row[104];
	$SSabandon_check_queue =				$row[105];
	$SSagent_notifications =				$row[106];
	$SSdemographic_quotas =					$row[107];
	$SSinbound_credits =					$row[108];
	$SSweekday_resets =						$row[109];
	$SStwo_factor_auth_agent_hours =		$row[110];
	$SShopper_hold_inserts =				$row[111];
	$SScoldstorage_server_ip =				$row[112];
	$SScoldstorage_dbname =					$row[113];
	$SScoldstorage_login =					$row[114];
	$SScoldstorage_pass =					$row[115];
	$SScoldstorage_port =					$row[116];
	$SSenhanced_agent_monitoring =			$row[117];
	$SSstereo_recording =					$row[118];
	$SSrecording_dtmf_detection =			$row[119];
	$SSrecording_dtmf_muting =				$row[120];
	$SSstereo_parallel_recording =			$row[121];
	}
if ($SSallow_web_debug < 1) {$DB=0;}
##### END SETTINGS LOOKUP #####
###########################################

$KHOMP_enabled=0;
$stmt="SELECT count(*) from vicidial_settings_containers where container_id='KHOMPSETTINGS';";
$rslt=mysql_to_mysqli($stmt, $link);
$rows_to_print = mysqli_num_rows($rslt);
if ($rows_to_print > 0) 
	{
	$rowx=mysqli_fetch_row($rslt);
	$KHOMP_enabled = $rowx[0];
	}

### populate pass_key if not set
if ( ($qm_conf_ct > 0) and (strlen($SSpass_key)<16) )
	{
	$SSpass_key = '';
	$possible = "0123456789abcdefghijklmnpqrstvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ";  
	$i = 0; 
	$length = 16;
	while ($i < $length) 
		{ 
		$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
		$SSpass_key .= $char;
		$i++;
		}
	$stmt="UPDATE system_settings set pass_key='$SSpass_key' where ( (pass_key is NULL) or (pass_key='') );";
	if ($DB) {echo "|$stmt|\n";}
	$rslt=mysql_to_mysqli($stmt, $link);
	}
if ($non_latin > 0)
	{
	if (!mysqli_set_charset($link,"utf8")) {printf("Error loading character set utf8: %s\n", mysqli_error());}
#	else {printf("Current character set: %s\n", mysqli_character_set_name($link));}
	$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);
	}

######################################################################################################
######################################################################################################
#######   Form variable filtering for security and data integrity
######################################################################################################
######################################################################################################

### DIGITS ONLY ###
$adaptive_latest_server_time = preg_replace('/[^0-9]/','',$adaptive_latest_server_time);
$admin_hangup_enabled = preg_replace('/[^0-9]/','',$admin_hangup_enabled);
$admin_hijack_enabled = preg_replace('/[^0-9]/','',$admin_hijack_enabled);
$admin_monitor_enabled = preg_replace('/[^0-9]/','',$admin_monitor_enabled);
$AFLogging_enabled = preg_replace('/[^0-9]/','',$AFLogging_enabled);
$agent_choose_ingroups = preg_replace('/[^0-9]/','',$agent_choose_ingroups);
$agentcall_manual = preg_replace('/[^0-9]/','',$agentcall_manual);
$agentonly_callbacks = preg_replace('/[^0-9]/','',$agentonly_callbacks);
$AGI_call_logging_enabled = preg_replace('/[^0-9]/','',$AGI_call_logging_enabled);
$allcalls_delay = preg_replace('/[^0-9]/','',$allcalls_delay);
$alter_agent_interface_options = preg_replace('/[^0-9]/','',$alter_agent_interface_options);
$answer_transfer_agent = preg_replace('/[^0-9]/','',$answer_transfer_agent);
$ast_admin_access = preg_replace('/[^0-9]/','',$ast_admin_access);
$ast_delete_phones = preg_replace('/[^0-9]/','',$ast_delete_phones);
$attempt_delay = preg_replace('/[^0-9]/','',$attempt_delay);
$attempt_maximum = preg_replace('/[^0-9]/','',$attempt_maximum);
$auto_dial_next_number = preg_replace('/[^0-9]/','',$auto_dial_next_number);
$balance_trunks_offlimits = preg_replace('/[^0-9]/','',$balance_trunks_offlimits);
$call_parking_enabled = preg_replace('/[^0-9]/','',$call_parking_enabled);
$CallerID_popup_enabled = preg_replace('/[^0-9]/','',$CallerID_popup_enabled);
$campaign_detail = preg_replace('/[^0-9]/','',$campaign_detail);
$campaign_rec_exten = preg_replace('/[^0-9]/','',$campaign_rec_exten);
$campaign_vdad_exten = preg_replace('/[^0-9]/','',$campaign_vdad_exten);
$change_agent_campaign = preg_replace('/[^0-9]/','',$change_agent_campaign);
$closer_default_blended = preg_replace('/[^0-9]/','',$closer_default_blended);
$conf_exten = preg_replace('/[^0-9]/','',$conf_exten);
$conf_on_extension = preg_replace('/[^0-9]/','',$conf_on_extension);
$conferencing_enabled = preg_replace('/[^0-9]/','',$conferencing_enabled);
$ct_default_start = preg_replace('/[^0-9]/','',$ct_default_start);
$ct_default_stop = preg_replace('/[^0-9]/','',$ct_default_stop);
$ct_friday_start = preg_replace('/[^0-9]/','',$ct_friday_start);
$ct_friday_stop = preg_replace('/[^0-9]/','',$ct_friday_stop);
$ct_monday_start = preg_replace('/[^0-9]/','',$ct_monday_start);
$ct_monday_stop = preg_replace('/[^0-9]/','',$ct_monday_stop);
$ct_saturday_start = preg_replace('/[^0-9]/','',$ct_saturday_start);
$ct_saturday_stop = preg_replace('/[^0-9]/','',$ct_saturday_stop);
$ct_sunday_start = preg_replace('/[^0-9]/','',$ct_sunday_start);
$ct_sunday_stop = preg_replace('/[^0-9]/','',$ct_sunday_stop);
$ct_thursday_start = preg_replace('/[^0-9]/','',$ct_thursday_start);
$ct_thursday_stop = preg_replace('/[^0-9]/','',$ct_thursday_stop);
$ct_tuesday_start = preg_replace('/[^0-9]/','',$ct_tuesday_start);
$ct_tuesday_stop = preg_replace('/[^0-9]/','',$ct_tuesday_stop);
$ct_wednesday_start = preg_replace('/[^0-9]/','',$ct_wednesday_start);
$ct_wednesday_stop = preg_replace('/[^0-9]/','',$ct_wednesday_stop);
$DBX_port = preg_replace('/[^0-9]/','',$DBX_port);
$DBY_port = preg_replace('/[^0-9]/','',$DBY_port);
$dedicated_trunks = preg_replace('/[^0-9]/','',$dedicated_trunks);
$delete_call_times = preg_replace('/[^0-9]/','',$delete_call_times);
$delete_campaigns = preg_replace('/[^0-9]/','',$delete_campaigns);
$delete_filters = preg_replace('/[^0-9]/','',$delete_filters);
$delete_ingroups = preg_replace('/[^0-9]/','',$delete_ingroups);
$delete_lists = preg_replace('/[^0-9]/','',$delete_lists);
$delete_remote_agents = preg_replace('/[^0-9]/','',$delete_remote_agents);
$delete_scripts = preg_replace('/[^0-9]/','',$delete_scripts);
$delete_user_groups = preg_replace('/[^0-9]/','',$delete_user_groups);
$delete_users = preg_replace('/[^0-9]/','',$delete_users);
$dial_timeout = preg_replace('/[^0-9]/','',$dial_timeout);
$dialplan_number = preg_replace('/[^0-9]/','',$dialplan_number);
$enable_fast_refresh = preg_replace('/[^0-9]/','',$enable_fast_refresh);
$enable_persistant_mysql = preg_replace('/[^0-9]/','',$enable_persistant_mysql);
$fast_refresh_rate = preg_replace('/[^0-9]/','',$fast_refresh_rate);
$hopper_level = preg_replace('/[^0-9]/','',$hopper_level);
$hotkey = preg_replace('/[^0-9]/','',$hotkey);
$hotkeys_active = preg_replace('/[^0-9]/','',$hotkeys_active);
$list_id = preg_replace('/[^0-9]/','',$list_id);
$load_leads = preg_replace('/[^0-9]/','',$load_leads);
$max_vicidial_trunks = preg_replace('/[^0-9]/','',$max_vicidial_trunks);
$modify_call_times = preg_replace('/[^0-9]/','',$modify_call_times);
$modify_users = preg_replace('/[^0-9]/','',$modify_users);
$modify_campaigns = preg_replace('/[^0-9]/','',$modify_campaigns);
$modify_lists = preg_replace('/[^0-9]/','',$modify_lists);
$modify_scripts = preg_replace('/[^0-9]/','',$modify_scripts);
$modify_filters = preg_replace('/[^0-9]/','',$modify_filters);
$modify_ingroups = preg_replace('/[^0-9]/','',$modify_ingroups);
$modify_usergroups = preg_replace('/[^0-9]/','',$modify_usergroups);
$modify_remoteagents = preg_replace('/[^0-9]/','',$modify_remoteagents);
$modify_servers = preg_replace('/[^0-9]/','',$modify_servers);
$view_reports = preg_replace('/[^0-9]/','',$view_reports);
$modify_leads = preg_replace('/[^0-9]/','',$modify_leads);
$export_gdpr_leads = preg_replace('/[^0-9]/','',$export_gdpr_leads);
$monitor_prefix = preg_replace('/[^0-9]/','',$monitor_prefix);
$new_dialplan_number = preg_replace('/[^0-9]/','',$new_dialplan_number);
$new_outbound_cid = preg_replace('/[^0-9]/','',$new_outbound_cid);
$number_of_lines = preg_replace('/[^0-9]/','',$number_of_lines);
$old_conf_exten = preg_replace('/[^0-9]/','',$old_conf_exten);
$outbound_cid = preg_replace('/[^0-9]/','',$outbound_cid);
$park_ext = preg_replace('/[^0-9]/','',$park_ext);
$park_on_extension = preg_replace('/[^0-9]/','',$park_on_extension);
$phone_number = preg_replace('/[^0-9]/','',$phone_number);
$QUEUE_ACTION_enabled = preg_replace('/[^0-9]/','',$QUEUE_ACTION_enabled);
$recording_exten = preg_replace('/[^0-9]/','',$recording_exten);
$remote_agent_id = preg_replace('/[^0-9]/','',$remote_agent_id);
$telnet_port = preg_replace('/[^0-9]/','',$telnet_port);
$updater_check_enabled = preg_replace('/[^0-9]/','',$updater_check_enabled);
$user_level = preg_replace('/[^0-9]/','',$user_level);
$user_switching_enabled = preg_replace('/[^0-9]/','',$user_switching_enabled);
$VDstop_rec_after_each_call = preg_replace('/[^0-9]/','',$VDstop_rec_after_each_call);
$VICIDIAL_park_on_extension = preg_replace('/[^0-9]/','',$VICIDIAL_park_on_extension);
$vicidial_recording = preg_replace('/[^0-9]/','',$vicidial_recording);
$vicidial_transfers = preg_replace('/[^0-9]/','',$vicidial_transfers);
$voicemail_button_enabled = preg_replace('/[^0-9]/','',$voicemail_button_enabled);
$voicemail_dump_exten = preg_replace('/[^0-9]/','',$voicemail_dump_exten);
$voicemail_dump_exten_no_inst = preg_replace('/[^0-9]/','',$voicemail_dump_exten_no_inst);
$voicemail_exten = preg_replace('/[^0-9]/','',$voicemail_exten);
$wrapup_seconds = preg_replace('/[^0-9]/','',$wrapup_seconds);
$use_non_latin = preg_replace('/[^0-9]/','',$use_non_latin);
$webroot_writable = preg_replace('/[^0-9]/','',$webroot_writable);
$enable_queuemetrics_logging = preg_replace('/[^0-9]/','',$enable_queuemetrics_logging);
$enable_sipsak_messages = preg_replace('/[^0-9]/','',$enable_sipsak_messages);
$allow_sipsak_messages = preg_replace('/[^0-9]/','',$allow_sipsak_messages);
$mix_container_item = preg_replace('/[^0-9]/','',$mix_container_item);
$prompt_interval = preg_replace('/[^0-9]/','',$prompt_interval);
$agent_alert_delay = preg_replace('/[^0-9]/','',$agent_alert_delay);
$manual_dial_list_id = preg_replace('/[^0-9]/','',$manual_dial_list_id);
$qc_user_level = preg_replace('/[^0-9]/','',$qc_user_level);
$qc_pass = preg_replace('/[^0-9]/','',$qc_pass);
$qc_finish = preg_replace('/[^0-9]/','',$qc_finish);
$qc_commit = preg_replace('/[^0-9]/','',$qc_commit);
$shift_start_time = preg_replace('/[^0-9]/','',$shift_start_time);
$timeclock_end_of_day = preg_replace('/[^0-9]/','',$timeclock_end_of_day);
$survey_xfer_exten = preg_replace('/[^0-9]/','',$survey_xfer_exten);
$add_timeclock_log = preg_replace('/[^0-9]/','',$add_timeclock_log);
$modify_timeclock_log = preg_replace('/[^0-9]/','',$modify_timeclock_log);
$delete_timeclock_log = preg_replace('/[^0-9]/','',$delete_timeclock_log);
$vdc_agent_api_access = preg_replace('/[^0-9]/','',$vdc_agent_api_access);
$vdc_agent_api_active = preg_replace('/[^0-9]/','',$vdc_agent_api_active);
$hold_time_option_seconds = preg_replace('/[^0-9]/','',$hold_time_option_seconds);
$hold_time_option_callback_list_id = preg_replace('/[^0-9]/','',$hold_time_option_callback_list_id);
$source_did = preg_replace('/[^0-9]/','',$source_did);
$modify_inbound_dids = preg_replace('/[^0-9]/','',$modify_inbound_dids);
$delete_inbound_dids = preg_replace('/[^0-9]/','',$delete_inbound_dids);
$answer_sec_pct_rt_stat_one = preg_replace('/[^0-9]/','',$answer_sec_pct_rt_stat_one);
$answer_sec_pct_rt_stat_two = preg_replace('/[^0-9]/','',$answer_sec_pct_rt_stat_two);
$enable_vtiger_integration = preg_replace('/[^0-9]/','',$enable_vtiger_integration);
$qc_features_active = preg_replace('/[^0-9]/','',$qc_features_active);
$outbound_autodial_active = preg_replace('/[^0-9]/','',$outbound_autodial_active);
$download_lists = preg_replace('/[^0-9]/','',$download_lists);
$caller_id_number = preg_replace('/[^0-9]/','',$caller_id_number);
$outbound_calls_per_second = preg_replace('/[^0-9]/','',$outbound_calls_per_second);
$manager_shift_enforcement_override = preg_replace('/[^0-9]/','',$manager_shift_enforcement_override);
$export_reports = preg_replace('/[^0-9]/','',$export_reports);
$delete_from_dnc = preg_replace('/[^0-9]/','',$delete_from_dnc);
$menu_timeout = preg_replace('/[^0-9]/','',$menu_timeout);
$menu_time_check = preg_replace('/[^0-9]/','',$menu_time_check);
$track_in_vdac = preg_replace('/[^0-9]/','',$track_in_vdac);
$menu_repeat = preg_replace('/[^0-9]/','',$menu_repeat);
$agentonly_callback_campaign_lock = preg_replace('/[^0-9]/','',$agentonly_callback_campaign_lock);
$sounds_central_control_active = preg_replace('/[^0-9]/','',$sounds_central_control_active);
$user_territories_active = preg_replace('/[^0-9]/','',$user_territories_active);
$vicidial_recording_limit = preg_replace('/[^0-9]/','',$vicidial_recording_limit);
$allow_custom_dialplan = preg_replace('/[^0-9]/','',$allow_custom_dialplan);
$phone_ring_timeout = preg_replace('/[^0-9]/','',$phone_ring_timeout);
$enable_tts_integration = preg_replace('/[^0-9]/','',$enable_tts_integration);
$allow_alerts = preg_replace('/[^0-9]/','',$allow_alerts);
$vicidial_balance_rank = preg_replace('/[^0-9]/','',$vicidial_balance_rank);
$rank = preg_replace('/[^0-9]/','',$rank);
$enable_second_webform = preg_replace('/[^0-9]/','',$enable_second_webform);
$campaign_cid_override = preg_replace('/[^0-9]/','',$campaign_cid_override);
$agent_choose_territories = preg_replace('/[^0-9]/','',$agent_choose_territories);
$timer_action_seconds = preg_replace('/[^0-9]/','',$timer_action_seconds);
$default_webphone = preg_replace('/[^0-9]/','',$default_webphone);
$default_external_server_ip = preg_replace('/[^0-9]/','',$default_external_server_ip);
$enable_agc_xfer_log = preg_replace('/[^0-9]/','',$enable_agc_xfer_log);
$enable_agc_dispo_log = preg_replace('/[^0-9]/','',$enable_agc_dispo_log);
$callcard_enabled = preg_replace('/[^0-9]/','',$callcard_enabled);
$callcard_admin = preg_replace('/[^0-9]/','',$callcard_admin);
$extension_id = preg_replace('/[^0-9]/','',$extension_id);
$agent_choose_blended = preg_replace('/[^0-9]/','',$agent_choose_blended);
$realtime_block_user_info = preg_replace('/[^0-9]/','',$realtime_block_user_info);
$codecs_with_template = preg_replace('/[^0-9]/','',$codecs_with_template);
$custom_fields_modify = preg_replace('/[^0-9]/','',$custom_fields_modify);
$hold_time_option_minimum = preg_replace('/[^0-9]/','',$hold_time_option_minimum);
$onhold_prompt_seconds = preg_replace('/[^0-9]/','',$onhold_prompt_seconds);
$hold_time_option_prompt_seconds = preg_replace('/[^0-9]/','',$hold_time_option_prompt_seconds);
$custom_fields_enabled = preg_replace('/[^0-9]/','',$custom_fields_enabled);
$wait_time_option_seconds = preg_replace('/[^0-9]/','',$wait_time_option_seconds);
$wait_time_option_callback_list_id = preg_replace('/[^0-9]/','',$wait_time_option_callback_list_id);
$wait_time_option_prompt_seconds = preg_replace('/[^0-9]/','',$wait_time_option_prompt_seconds);
$filter_list_id = preg_replace('/[^0-9]/','',$filter_list_id);
$calculate_estimated_hold_seconds = preg_replace('/[^0-9]/','',$calculate_estimated_hold_seconds);
$customer_3way_hangup_seconds = preg_replace('/[^0-9]/','',$customer_3way_hangup_seconds);
$eht_minimum_prompt_seconds = preg_replace('/[^0-9]/','',$eht_minimum_prompt_seconds);
$admin_modify_refresh = preg_replace('/[^0-9]/','',$admin_modify_refresh);
$nocache_admin = preg_replace('/[^0-9]/','',$nocache_admin);
$generate_cross_server_exten = preg_replace('/[^0-9]/','',$generate_cross_server_exten);
$queuemetrics_addmember_enabled = preg_replace('/[^0-9]/','',$queuemetrics_addmember_enabled);
$modify_page = preg_replace('/[^0-9]/','',$modify_page);
$on_hook_ring_time = preg_replace('/[^0-9]/','',$on_hook_ring_time);
$reload_dialplan_on_servers = preg_replace('/[^0-9]/','',$reload_dialplan_on_servers);
$available_only_tally_threshold_agents = preg_replace('/[^0-9]/','',$available_only_tally_threshold_agents);
$incall_tally_threshold_seconds = preg_replace('/[^0-9]/','',$incall_tally_threshold_seconds);
$dial_level_threshold_agents = preg_replace('/[^0-9]/','',$dial_level_threshold_agents);
$dtmf_log = preg_replace('/[^0-9]/','',$dtmf_log);
$callback_days_limit = preg_replace('/[^0-9]/','',$callback_days_limit);
$queuemetrics_pe_phone_append = preg_replace('/[^0-9]/','',$queuemetrics_pe_phone_append);
$test_campaign_calls = preg_replace('/[^0-9]/','',$test_campaign_calls);
$agents_calls_reset = preg_replace('/[^0-9]/','',$agents_calls_reset);
$campaign_cid_areacodes_enabled = preg_replace('/[^0-9]/','',$campaign_cid_areacodes_enabled);
$pllb_grouping_limit = preg_replace('/[^0-9]/','',$pllb_grouping_limit);
$did_ra_extensions_enabled = preg_replace('/[^0-9]/','',$did_ra_extensions_enabled);
$modify_shifts = preg_replace('/[^0-9]/','',$modify_shifts);
$modify_phones = preg_replace('/[^0-9]/','',$modify_phones);
$modify_carriers = preg_replace('/[^0-9]/','',$modify_carriers);
$modify_labels = preg_replace('/[^0-9]/','',$modify_labels);
$modify_colors = preg_replace('/[^0-9]/','',$modify_colors);
$modify_statuses = preg_replace('/[^0-9]/','',$modify_statuses);
$modify_voicemail = preg_replace('/[^0-9]/','',$modify_voicemail);
$modify_audiostore = preg_replace('/[^0-9]/','',$modify_audiostore);
$modify_moh = preg_replace('/[^0-9]/','',$modify_moh);
$modify_tts = preg_replace('/[^0-9]/','',$modify_tts);
$call_count_limit = preg_replace('/[^0-9]/','',$call_count_limit);
$call_count_target = preg_replace('/[^0-9]/','',$call_count_target);
$expanded_list_stats = preg_replace('/[^0-9]/','',$expanded_list_stats);
$contacts_enabled = preg_replace('/[^0-9]/','',$contacts_enabled);
$contact_id = preg_replace('/[^0-9]/','',$contact_id);
$office_num = preg_replace('/[^0-9]/','',$office_num);
$cell_num = preg_replace('/[^0-9]/','',$cell_num);
$other_num1 = preg_replace('/[^0-9]/','',$other_num1);
$other_num2 = preg_replace('/[^0-9]/','',$other_num2);
$modify_contacts = preg_replace('/[^0-9]/','',$modify_contacts);
$callback_hours_block = preg_replace('/[^0-9]/','',$callback_hours_block);
$modify_same_user_level = preg_replace('/[^0-9]/','',$modify_same_user_level);
$admin_hide_lead_data = preg_replace('/[^0-9]/','',$admin_hide_lead_data);
$max_calls_count = preg_replace('/[^0-9]/','',$max_calls_count);
$report_rank = preg_replace('/[^0-9]/','',$report_rank);
$dial_ingroup_cid = preg_replace('/[^0-9]/','',$dial_ingroup_cid);
$call_menu_qualify_enabled = preg_replace('/[^0-9]/','',$call_menu_qualify_enabled);
$admin_list_counts = preg_replace('/[^0-9]/','',$admin_list_counts);
$allow_voicemail_greeting = preg_replace('/[^0-9]/','',$allow_voicemail_greeting);
$enhanced_disconnect_logging = preg_replace('/[^0-9]/','',$enhanced_disconnect_logging);
$level_8_disable_add = preg_replace('/[^0-9]/','',$level_8_disable_add);
$survey_wait_sec = preg_replace('/[^0-9]/','',$survey_wait_sec);
$queuemetrics_record_hold = preg_replace('/[^0-9]/','',$queuemetrics_record_hold);
$country_code_list_stats = preg_replace('/[^0-9]/','',$country_code_list_stats);
$dead_max = preg_replace('/[^0-9]/','',$dead_max);
$dispo_max = preg_replace('/[^0-9]/','',$dispo_max);
$pause_max = preg_replace('/[^0-9]/','',$pause_max);
$alter_admin_interface_options = preg_replace('/[^0-9]/','',$alter_admin_interface_options);
$max_inbound_calls = preg_replace('/[^0-9]/','',$max_inbound_calls);
$modify_custom_dialplans = preg_replace('/[^0-9]/','',$modify_custom_dialplans);
$queuemetrics_pause_type = preg_replace('/[^0-9]/','',$queuemetrics_pause_type);
$frozen_server_call_clear = preg_replace('/[^0-9]/','',$frozen_server_call_clear);
$callback_time_24hour = preg_replace('/[^0-9]/','',$callback_time_24hour);
$callback_active_limit = preg_replace('/[^0-9]/','',$callback_active_limit);
$modify_languages = preg_replace('/[^0-9]/','',$modify_languages);
$enable_languages = preg_replace('/[^0-9]/','',$enable_languages);
$user_choose_language = preg_replace('/[^0-9]/','',$user_choose_language);
$ignore_group_on_search = preg_replace('/[^0-9]/','',$ignore_group_on_search);
$enable_did_entry_list_id = preg_replace('/[^0-9]/','',$enable_did_entry_list_id);
$entry_list_id = preg_replace('/[^0-9]/','',$entry_list_id);
$filter_entry_list_id = preg_replace('/[^0-9]/','',$filter_entry_list_id);
$enable_third_webform = preg_replace('/[^0-9]/','',$enable_third_webform);
$api_list_restrict = preg_replace('/[^0-9]/','',$api_list_restrict);
$customer_gone_seconds = preg_replace('/[^0-9]/','',$customer_gone_seconds);
$agent_whisper_enabled = preg_replace('/[^0-9]/','',$agent_whisper_enabled);
$admin_cf_show_hidden = preg_replace('/[^0-9]/','',$admin_cf_show_hidden);
$agentcall_chat = preg_replace('/[^0-9]/','',$agentcall_chat);
$user_hide_realtime_enabled = preg_replace('/[^0-9]/','',$user_hide_realtime_enabled);
$user_hide_realtime = preg_replace('/[^0-9]/','',$user_hide_realtime);
$min_sec = preg_replace('/[^0-9]/','',$min_sec);
$max_sec = preg_replace('/[^0-9]/','',$max_sec);
$usacan_phone_dialcode_fix = preg_replace('/[^0-9]/','',$usacan_phone_dialcode_fix);
$cache_carrier_stats_realtime = preg_replace('/[^0-9]/','',$cache_carrier_stats_realtime);
$nva_new_list_id = preg_replace('/[^0-9]/','',$nva_new_list_id);
$nva_new_phone_code = preg_replace('/[^0-9]/','',$nva_new_phone_code);
$manual_dial_timeout = preg_replace('/[^0-9]/','',$manual_dial_timeout);
$alt_ivr_logging = preg_replace('/[^0-9]/','',$alt_ivr_logging);
$question = preg_replace('/[^0-9]/','',$question);
$alt_dtmf_log = preg_replace('/[^0-9]/','',$alt_dtmf_log);
$callback_useronly_move_minutes = preg_replace('/[^0-9]/','',$callback_useronly_move_minutes);
$default_phone_code = preg_replace('/[^0-9]/','',$default_phone_code);
$admin_row_click = preg_replace('/[^0-9]/','',$admin_row_click);
$outbound_alt_cid = preg_replace('/[^0-9]/','',$outbound_alt_cid);
$script_remove_js = preg_replace('/[^0-9]/','',$script_remove_js);
$manual_auto_next = preg_replace('/[^0-9]/','',$manual_auto_next);
$agent_soundboards = preg_replace('/[^0-9]/','',$agent_soundboards);
$api_only_user = preg_replace('/[^0-9]/','',$api_only_user);
$areacode_filter_seconds = preg_replace('/[^0-9]/','',$areacode_filter_seconds);
$enable_auto_reports = preg_replace('/[^0-9]/','',$enable_auto_reports);
$modify_auto_reports = preg_replace('/[^0-9]/','',$modify_auto_reports);
$report_weekdays = preg_replace('/[^0-9]/','',$report_weekdays);
$enable_pause_code_limits = preg_replace('/[^0-9]/','',$enable_pause_code_limits);
$time_limit = preg_replace('/[^0-9]/','',$time_limit);
$enable_drop_lists = preg_replace('/[^0-9]/','',$enable_drop_lists);
$dl_weekdays = preg_replace('/[^0-9]/','',$dl_weekdays);
$allow_ip_lists = preg_replace('/[^0-9]/','',$allow_ip_lists);
$modify_ip_lists = preg_replace('/[^0-9]/','',$modify_ip_lists);
$ignore_ip_list = preg_replace('/[^0-9]/','',$ignore_ip_list);
$dl_minutes = preg_replace('/[^0-9]/','',$dl_minutes);
$callback_display_days = preg_replace('/[^0-9]/','',$callback_display_days);
$agent_push_events = preg_replace('/[^0-9]/','',$agent_push_events);
$hide_inactive_lists = preg_replace('/[^0-9]/','',$hide_inactive_lists);
$inbound_survey_accept_digit = preg_replace('/[^0-9]/','',$inbound_survey_accept_digit);
$allow_manage_active_lists = preg_replace('/[^0-9]/','',$allow_manage_active_lists);
$expired_lists_inactive = preg_replace('/[^0-9]/','',$expired_lists_inactive);
$enable_gdpr_download_deletion = preg_replace('/[^0-9]/','',$enable_gdpr_download_deletion);
$did_system_filter = preg_replace('/[^0-9]/','',$did_system_filter);
$icbq_expiration_hours = preg_replace('/[^0-9]/','',$icbq_expiration_hours);
$source_id_display = preg_replace('/[^0-9]/','',$source_id_display);
$pause_code_approval = preg_replace('/[^0-9]/','',$pause_code_approval);
$max_hopper_calls = preg_replace('/[^0-9]/','',$max_hopper_calls);
$max_hopper_calls_hour = preg_replace('/[^0-9]/','',$max_hopper_calls_hour);
$agent_logout_link = preg_replace('/[^0-9]/','',$agent_logout_link);
$user_admin_redirect = preg_replace('/[^0-9]/','',$user_admin_redirect);
$list_status_modification_confirmation = preg_replace('/[^0-9]/','',$list_status_modification_confirmation);
$max_inbound_filter_enabled = preg_replace('/[^0-9]/','',$max_inbound_filter_enabled);
$enable_second_script = preg_replace('/[^0-9]/','',$enable_second_script);
$time_start = preg_replace('/[^0-9]/','',$time_start);
$time_end = preg_replace('/[^0-9]/','',$time_end);
$enable_first_webform = preg_replace('/[^0-9]/','',$enable_first_webform);
$vmm_daily_limit = preg_replace('/[^0-9]/','',$vmm_daily_limit);
$cid_auto_rotate_minutes = preg_replace('/[^0-9]/','',$cid_auto_rotate_minutes);
$cid_auto_rotate_minimum = preg_replace('/[^0-9]/','',$cid_auto_rotate_minimum);
$require_password_length = preg_replace('/[^0-9]/','',$require_password_length);
$entries_per_page = preg_replace('/[^0-9]/','',$entries_per_page);
$start_count = preg_replace('/[^0-9]/','',$start_count);
$browser_call_alerts = preg_replace('/[^0-9]/','',$browser_call_alerts);
$browser_alert_volume = preg_replace('/[^0-9]/','',$browser_alert_volume);
$inbound_answer_config = preg_replace('/[^0-9]/','',$inbound_answer_config);
$enable_international_dncs = preg_replace('/[^0-9]/','',$enable_international_dncs);
$daily_call_count_limit = preg_replace('/[^0-9]/','',$daily_call_count_limit);
$allow_shared_dial = preg_replace('/[^0-9]/','',$allow_shared_dial);
$shared_dial_rank = preg_replace('/[^0-9]/','',$shared_dial_rank);
$qc_claim_limit = preg_replace('/[^0-9]/','',$qc_claim_limit);
$qc_expire_days = preg_replace('/[^0-9]/','',$qc_expire_days);
$auth_entry = preg_replace('/[^0-9]/','',$auth_entry);
$agent_hidden_sound_volume = preg_replace('/[^0-9]/','',$agent_hidden_sound_volume);
$agent_hidden_sound_seconds = preg_replace('/[^0-9]/','',$agent_hidden_sound_seconds);
$in_man_dial_next_ready_seconds = preg_replace('/[^0-9]/','',$in_man_dial_next_ready_seconds);
$call_limit_24hour = preg_replace('/[^0-9]/','',$call_limit_24hour);
$download_invalid_files = preg_replace('/[^0-9]/','',$download_invalid_files);
$modify_email_accounts = preg_replace('/[^0-9]/','',$modify_email_accounts);
$access_recordings = preg_replace('/[^0-9]/','',$access_recordings);
$agentcall_email = preg_replace('/[^0-9]/','',$agentcall_email);
$allow_web_debug = preg_replace('/[^0-9]/','',$allow_web_debug);
$force_logout = preg_replace('/[^0-9]/','',$force_logout);
$log_recording_access = preg_replace('/[^0-9]/','',$log_recording_access);
$dial_level_override = preg_replace('/[^0-9]/','',$dial_level_override);
$conf_update_interval = preg_replace('/[^0-9]/','',$conf_update_interval);
$login_kickall = preg_replace('/[^0-9]/','',$login_kickall);
$agent_notifications = preg_replace('/[^0-9]/','',$agent_notifications);
$modify_dial_prefix = preg_replace('/[^0-9]/','',$modify_dial_prefix);
$weekday_resets = preg_replace('/[^0-9]/','',$weekday_resets);
$second_alert_trigger_seconds = preg_replace('/[^0-9]/','',$second_alert_trigger_seconds);
$second_alert_delay = preg_replace('/[^0-9]/','',$second_alert_delay);
$third_alert_trigger_seconds = preg_replace('/[^0-9]/','',$third_alert_trigger_seconds);
$third_alert_delay = preg_replace('/[^0-9]/','',$third_alert_delay);
$agent_search_list = preg_replace('/[^0-9]/','',$agent_search_list);
$hci_enabled = preg_replace('/[^0-9]/','',$hci_enabled);
$daily_phone_number_call_limit = preg_replace('/[^0-9]/','',$daily_phone_number_call_limit);
$manual_minimum_ring_seconds = preg_replace('/[^0-9]/','',$manual_minimum_ring_seconds);
$manual_minimum_attempt_seconds = preg_replace('/[^0-9]/','',$manual_minimum_attempt_seconds);
$manual_minimum_answer_seconds = preg_replace('/[^0-9]/','',$manual_minimum_answer_seconds);
$enhanced_agent_monitoring = preg_replace('/[^0-9]/','',$enhanced_agent_monitoring);
$agent_hide_dial_fail = preg_replace('/[^0-9]/','',$agent_hide_dial_fail);
$recording_dtmf_detection = preg_replace('/[^0-9]/','',$recording_dtmf_detection);
$recording_dtmf_muting = preg_replace('/[^0-9]/','',$recording_dtmf_muting);

$user_new_lead_limit = preg_replace('/[^-0-9]/','',$user_new_lead_limit);
$drop_call_seconds = preg_replace('/[^-0-9]/','',$drop_call_seconds);
$timer_alt_seconds = preg_replace('/[^-0-9]/','',$timer_alt_seconds);
$wrapup_seconds_override = preg_replace('/[^-0-9]/','',$wrapup_seconds_override);
$max_queue_ingroup_calls = preg_replace('/[^-0-9]/','',$max_queue_ingroup_calls);
$ready_max_logout = preg_replace('/[^-0-9]/','',$ready_max_logout);
$inbound_no_agents_no_dial_threshold = preg_replace('/[^-0-9]/','',$inbound_no_agents_no_dial_threshold);
$dead_trigger_seconds = preg_replace('/[^-0-9]/','',$dead_trigger_seconds);
$cid_cb_valid_length = preg_replace('/[^-0-9]/','',$cid_cb_valid_length);
$daily_reset_limit = preg_replace('/[^-0-9]/','',$daily_reset_limit);
$auto_active_list_rank = preg_replace('/[^-0-9]/','',$auto_active_list_rank);
$max_inbound_filter_min_sec = preg_replace('/[^-0-9]/','',$max_inbound_filter_min_sec);
$no_agent_delay = preg_replace('/[^-0-9]/','',$no_agent_delay);
$two_factor_auth_hours = preg_replace('/[^-0-9]/','',$two_factor_auth_hours);
$two_factor_auth_agent_hours = preg_replace('/[^-0-9]/','',$two_factor_auth_agent_hours);
$auto_alt_threshold = preg_replace('/[^-0-9]/','',$auto_alt_threshold);
$inbound_credits = preg_replace('/[^-0-9]/','',$inbound_credits);
$script_tab_height = preg_replace('/[^-0-9]/','',$script_tab_height);
$call_log_days = preg_replace('/[^-0-9]/','',$call_log_days);

### DIGITS and COLONS
$shift_length = preg_replace('/[^\:0-9]/','',$shift_length);

### DIGITS and HASHES and STARS
$survey_dtmf_digits = preg_replace('/[^\#\*0-9]/','',$survey_dtmf_digits);
$survey_ni_digit = preg_replace('/[^\#\*0-9]/','',$survey_ni_digit);

### DIGITS and DASHES
$group_rank = preg_replace('/[^-0-9]/','',$group_rank);
$campaign_rank = preg_replace('/[^-0-9]/','',$campaign_rank);
$queue_priority = preg_replace('/[^-0-9]/','',$queue_priority);

### Y or N ONLY ###
$allow_closers = preg_replace('/[^NY]/','',$allow_closers);
$reset_hopper = preg_replace('/[^NY]/','',$reset_hopper);
$amd_send_to_vmx = preg_replace('/[^NY]/','',$amd_send_to_vmx);
$selectable = preg_replace('/[^NY]/','',$selectable);
$reset_list = preg_replace('/[^NY]/','',$reset_list);
$fronter_display = preg_replace('/[^NY]/','',$fronter_display);
$omit_phone_code = preg_replace('/[^NY]/','',$omit_phone_code);
$available_only_ratio_tally = preg_replace('/[^NY]/','',$available_only_ratio_tally);
$sys_perf_log = preg_replace('/[^NY]/','',$sys_perf_log);
$vicidial_balance_active = preg_replace('/[^NY]/','',$vicidial_balance_active);
$vd_server_logs = preg_replace('/[^NY]/','',$vd_server_logs);
$campaign_stats_refresh = preg_replace('/[^NY]/','',$campaign_stats_refresh);
$disable_alter_custdata = preg_replace('/[^NY]/','',$disable_alter_custdata);
$no_hopper_leads_logins = preg_replace('/[^NY]/','',$no_hopper_leads_logins);
$human_answered = preg_replace('/[^NY]/','',$human_answered);
$tovdad_display = preg_replace('/[^NY]/','',$tovdad_display);
$campaign_allow_inbound = preg_replace('/[^NY]/','',$campaign_allow_inbound);
$old_campaign_allow_inbound = preg_replace('/[^NY]/','',$old_campaign_allow_inbound);
$display_queue_count = preg_replace('/[^NY]/','',$display_queue_count);
$qc_show_recording = preg_replace('/[^NY]/','',$qc_show_recording);
$sale_category = preg_replace('/[^NY]/','',$sale_category);
$dead_lead_category = preg_replace('/[^NY]/','',$dead_lead_category);
$agent_extended_alt_dial  = preg_replace('/[^NY]/','',$agent_extended_alt_dial);
$play_place_in_line  = preg_replace('/[^NY]/','',$play_place_in_line);
$play_estimate_hold_time  = preg_replace('/[^NY]/','',$play_estimate_hold_time);
$no_delay_call_route  = preg_replace('/[^NY]/','',$no_delay_call_route);
$did_active  = preg_replace('/[^NY]/','',$did_active);
$active_asterisk_server = preg_replace('/[^NY]/','',$active_asterisk_server);
$generate_vicidial_conf = preg_replace('/[^NY]/','',$generate_vicidial_conf);
$rebuild_conf_files = preg_replace('/[^NY]/','',$rebuild_conf_files);
$agent_allow_group_alias = preg_replace('/[^NY]/','',$agent_allow_group_alias);
$vtiger_status_call = preg_replace('/[^NY]/','',$vtiger_status_call);
$sale = preg_replace('/[^NY]/','',$sale);
$dnc = preg_replace('/[^NY]/','',$dnc);
$customer_contact = preg_replace('/[^NY]/','',$customer_contact);
$not_interested = preg_replace('/[^NY]/','',$not_interested);
$unworkable = preg_replace('/[^NY]/','',$unworkable);
$sounds_update = preg_replace('/[^NY]/','',$sounds_update);
$carrier_logging_active = preg_replace('/[^NY]/','',$carrier_logging_active);
$agent_status_view_time = preg_replace('/[^NY]/','',$agent_status_view_time);
$no_hopper_dialing = preg_replace('/[^NY]/','',$no_hopper_dialing);
$agent_display_dialable_leads = preg_replace('/[^NY]/','',$agent_display_dialable_leads);
$random = preg_replace('/[^NY]/','',$random);
$rebuild_music_on_hold = preg_replace('/[^NY]/','',$rebuild_music_on_hold);
$active_agent_login_server = preg_replace('/[^NY]/','',$active_agent_login_server);
$agent_select_territories = preg_replace('/[^NY]/','',$agent_select_territories);
$delete_vm_after_email = preg_replace('/[^NY]/','',$delete_vm_after_email);
$crm_popup_login = preg_replace('/[^NY]/','',$crm_popup_login);
$ignore_list_script_override = preg_replace('/[^NY]/','',$ignore_list_script_override);
$use_external_server_ip = preg_replace('/[^NY]/','',$use_external_server_ip);
$agent_xfer_consultative = preg_replace('/[^NY]/','',$agent_xfer_consultative);
$agent_xfer_dial_override = preg_replace('/[^NY]/','',$agent_xfer_dial_override);
$agent_xfer_vm_transfer = preg_replace('/[^NY]/','',$agent_xfer_vm_transfer);
$agent_xfer_blind_transfer = preg_replace('/[^NY]/','',$agent_xfer_blind_transfer);
$agent_xfer_dial_with_customer = preg_replace('/[^NY]/','',$agent_xfer_dial_with_customer);
$agent_xfer_park_customer_dial = preg_replace('/[^NY]/','',$agent_xfer_park_customer_dial);
$agent_fullscreen = preg_replace('/[^NY]/','',$agent_fullscreen);
$onhold_prompt_no_block = preg_replace('/[^NY]/','',$onhold_prompt_no_block);
$hold_time_option_no_block = preg_replace('/[^NY]/','',$hold_time_option_no_block);
$wait_time_option_no_block = preg_replace('/[^NY]/','',$wait_time_option_no_block);
$preset_hide_number = preg_replace('/[^NY]/','',$preset_hide_number);
$use_auto_hopper = preg_replace('/[^NY]/','',$use_auto_hopper);
$auto_trim_hopper = preg_replace('/[^NY]/','',$auto_trim_hopper);
$force_change_password = preg_replace('/[^NY]/','',$force_change_password);
$first_login_trigger = preg_replace('/[^NY]/','',$first_login_trigger);
$eht_minimum_prompt_no_block = preg_replace('/[^NY]/','',$eht_minimum_prompt_no_block);
$lead_order_randomize = preg_replace('/[^NY]/','',$lead_order_randomize);
$on_hook_agent = preg_replace('/[^NY]/','',$on_hook_agent);
$auto_pause_precall = preg_replace('/[^NY]/','',$auto_pause_precall);
$auto_resume_precall = preg_replace('/[^NY]/','',$auto_resume_precall);
$webphone_auto_answer = preg_replace('/[^NY]/','',$webphone_auto_answer);
$noanswer_log = preg_replace('/[^NY]/','',$noanswer_log);
$did_agent_log = preg_replace('/[^NY]/','',$did_agent_log);
$completed = preg_replace('/[^NY]/','',$completed);
$report_option = preg_replace('/[^NY]/','',$report_option);
$hopper_vlc_dup_check = preg_replace('/[^NY]/','',$hopper_vlc_dup_check);
$inventory_report = preg_replace('/[^NY]/','',$inventory_report);
$auto_restart_asterisk = preg_replace('/[^NY]/','',$auto_restart_asterisk);
$asterisk_temp_no_restart = preg_replace('/[^NY]/','',$asterisk_temp_no_restart);
$voicemail_instructions = preg_replace('/[^NY]/','',$voicemail_instructions);
$filter_url_did_redirect = preg_replace('/[^NY]/','',$filter_url_did_redirect);
$callback_active_limit_override = preg_replace('/[^NY]/','',$callback_active_limit_override);
$drop_lead_reset = preg_replace('/[^NY]/','',$drop_lead_reset);
$after_hours_lead_reset = preg_replace('/[^NY]/','',$after_hours_lead_reset);
$nanq_lead_reset = preg_replace('/[^NY]/','',$nanq_lead_reset);
$wait_time_lead_reset = preg_replace('/[^NY]/','',$wait_time_lead_reset);
$hold_time_lead_reset = preg_replace('/[^NY]/','',$hold_time_lead_reset);
$am_message_wildcards = preg_replace('/[^NY]/','',$am_message_wildcards);
$gather_asterisk_output = preg_replace('/[^NY]/','',$gather_asterisk_output);
$routing_initiated_recordings = preg_replace('/[^NY]/','',$routing_initiated_recordings);
$manual_dial_hopper_check = preg_replace('/[^NY]/','',$manual_dial_hopper_check);
$webphone_dialbox = preg_replace('/[^NY]/','',$webphone_dialbox);
$webphone_mute = preg_replace('/[^NY]/','',$webphone_mute);
$webphone_volume = preg_replace('/[^NY]/','',$webphone_volume);
$webphone_debug = preg_replace('/[^NY]/','',$webphone_debug);
$answering_machine = preg_replace('/[^NY]/','',$answering_machine);
$manual_auto_show = preg_replace('/[^NY]/','',$manual_auto_show);
$allow_required_fields = preg_replace('/[^NY]/','',$allow_required_fields);
$conf_qualify = preg_replace('/[^NY]/','',$conf_qualify);
$run_now_trigger = preg_replace('/[^NY]/','',$run_now_trigger);
$agent_xfer_validation = preg_replace('/[^NY]/','',$agent_xfer_validation);
$three_way_record_stop = preg_replace('/[^NY]/','',$three_way_record_stop);
$hangup_xfer_record_start = preg_replace('/[^NY]/','',$hangup_xfer_record_start);
$scheduled_callbacks_email_alert = preg_replace('/[^NY]/','',$scheduled_callbacks_email_alert);
$closing_time_now_trigger = preg_replace('/[^NY]/','',$closing_time_now_trigger);
$closing_time_lead_reset = preg_replace('/[^NY]/','',$closing_time_lead_reset);
$script_top_dispo = preg_replace('/[^NY]/','',$script_top_dispo);
$scheduled_callbacks_force_dial = preg_replace('/[^NY]/','',$scheduled_callbacks_force_dial);
$inbound_route_answer = preg_replace('/[^NY]/','',$inbound_route_answer);
$agent_hangup_ig_override = preg_replace('/[^NY]/','',$agent_hangup_ig_override);

$qc_enabled = preg_replace('/[^0-9NY]/','',$qc_enabled);
$active = preg_replace('/[^0-9NY]/','',$active);
$ofcom_uk_drop_calc = preg_replace('/[^0-9NY]/','',$ofcom_uk_drop_calc);
$agent_xfer_park_3way = preg_replace('/[^0-9NY]/','',$agent_xfer_park_3way);
$manual_dial_validation = preg_replace('/[^0-9NY]/','',$manual_dial_validation);

### ALPHACAPS-NUMERIC
$xferconf_a_number = preg_replace('/[^0-9A-Z]/','',$xferconf_a_number);
$xferconf_b_number = preg_replace('/[^0-9A-Z]/','',$xferconf_b_number);
$xferconf_c_number = preg_replace('/[^0-9A-Z]/','',$xferconf_c_number);
$xferconf_d_number = preg_replace('/[^0-9A-Z]/','',$xferconf_d_number);
$xferconf_e_number = preg_replace('/[^0-9A-Z]/','',$xferconf_e_number);

### DIGITS and Dots
$new_server_ip = preg_replace('/[^\.0-9]/','',$new_server_ip);
$server_ip = preg_replace('/[^\.0-9]/','',$server_ip);
$auto_dial_level = preg_replace('/[^\.0-9]/','',$auto_dial_level);
$adaptive_maximum_level = preg_replace('/[^\.0-9]/','',$adaptive_maximum_level);
$phone_ip = preg_replace('/[^\.0-9]/','',$phone_ip);
$old_server_ip = preg_replace('/[^\.0-9]/','',$old_server_ip);
$computer_ip = preg_replace('/[^\.0-9]/','',$computer_ip);
$queuemetrics_server_ip = preg_replace('/[^\.0-9]/','',$queuemetrics_server_ip);
$vtiger_server_ip = preg_replace('/[^\.0-9]/','',$vtiger_server_ip);
$active_voicemail_server = preg_replace('/[^\.0-9]/','',$active_voicemail_server);
$auto_dial_limit = preg_replace('/[^\.0-9]/','',$auto_dial_limit);
$adaptive_dropped_percentage = preg_replace('/[^\.0-9]/','',$adaptive_dropped_percentage);
$drop_lockout_time = preg_replace('/[^\.0-9]/','',$drop_lockout_time);
$filter_server_ip = preg_replace('/[^\.0-9]/','',$filter_server_ip);
$auto_hopper_multi = preg_replace('/[^\.0-9]/','',$auto_hopper_multi);

# Settings alphanumeric, dash, underscore
$daily_limit_manual = preg_replace('/[^-_0-9a-zA-Z]/','',$daily_limit_manual);
$transfer_button_launch = preg_replace('/[^-_0-9a-zA-Z]/','',$transfer_button_launch);
$two_factor_override = preg_replace('/[^-_0-9a-zA-Z]/','',$two_factor_override);
$clear_form = preg_replace('/[^-_0-9a-zA-Z]/','',$clear_form);
$agent_hidden_sound = preg_replace('/[^-_0-9a-zA-Z]/','',$agent_hidden_sound);
$leave_3way_start_recording = preg_replace('/[^-_0-9a-zA-Z]/','',$leave_3way_start_recording);
$leave_3way_start_recording_exception = preg_replace('/[^-_0-9a-zA-Z]/','',$leave_3way_start_recording_exception);
$agent_screen_timer = preg_replace('/[^-_0-9a-zA-Z]/','',$agent_screen_timer);
$hopper_drop_run_trigger = preg_replace('/[^0-9a-zA-Z]/','',$hopper_drop_run_trigger);
$hopper_drop_run_trigger_all = preg_replace('/[^0-9a-zA-Z]/','',$hopper_drop_run_trigger_all);
$calls_waiting_vl_one = preg_replace('/[^-_0-9a-zA-Z]/','',$calls_waiting_vl_one);
$calls_waiting_vl_two = preg_replace('/[^-_0-9a-zA-Z]/','',$calls_waiting_vl_two);
$transfer_no_dispo = preg_replace('/[^-_0-9a-zA-Z]/','',$transfer_no_dispo);
$allowed_sip_stacks = preg_replace('/[^-_0-9a-zA-Z]/','',$allowed_sip_stacks);
$in_queue_nanque = preg_replace('/[^-_0-9a-zA-Z]/','',$in_queue_nanque);
$reports_header_override = preg_replace('/[^-_0-9a-zA-Z]/','',$reports_header_override);
$agent_hide_hangup = preg_replace('/[^-_0-9a-zA-Z]/','',$agent_hide_hangup);
$SUB = preg_replace('/[^-_0-9a-zA-Z]/','',$SUB);
$SUBMIT = preg_replace('/[^-_0-9a-zA-Z]/','',$SUBMIT);
$qc_display_group_type = preg_replace('/[^-_0-9a-zA-Z]/','',$qc_display_group_type);
$available_only_tally_threshold = preg_replace('/[^-_0-9a-zA-Z]/','',$available_only_tally_threshold);
$dial_level_threshold = preg_replace('/[^-_0-9a-zA-Z]/','',$dial_level_threshold);
$form_end = preg_replace('/[^-_0-9a-zA-Z]/','',$form_end);
$download_max_system_stats_metric = preg_replace('/[^- \+_0-9a-zA-Z]/','',$download_max_system_stats_metric);
$download_max_system_stats_metric_name = preg_replace('/[^- \+_0-9a-zA-Z]/','',$download_max_system_stats_metric_name);
$chat_timeout = preg_replace('/[^-_0-9a-zA-Z]/','',$chat_timeout);
$manager_chat_id = preg_replace('/[^-\._0-9a-zA-Z]/','',$manager_chat_id);
$group_handling = preg_replace('/[^-_0-9a-zA-Z]/','',$group_handling);
$query_date = preg_replace('/[^-_0-9a-zA-Z]/','',$query_date);
$end_date = preg_replace('/[^-_0-9a-zA-Z]/','',$end_date);
$show_vm_on_summary = preg_replace('/[^-_0-9a-zA-Z]/','',$show_vm_on_summary);
$admin_screen_colors = preg_replace('/[^-_0-9a-zA-Z]/','',$admin_screen_colors);
$last_run = preg_replace('/[^-_0-9a-zA-Z]/','',$last_run);
$closing_time_option_xfer_group = preg_replace('/[^-_0-9a-zA-Z]/','',$closing_time_option_xfer_group);
$user_account_emails = preg_replace('/[^-_0-9a-zA-Z]/','',$user_account_emails);
$outbound_cid_any = preg_replace('/[^-_0-9a-zA-Z]/','',$outbound_cid_any);
$enable_xfer_presets = preg_replace('/[^0-9a-zA-Z]/','',$enable_xfer_presets);
$ig_xfer_list_sort = preg_replace('/[^-_0-9a-zA-Z]/','',$ig_xfer_list_sort);
$script_tab_frame_size = preg_replace('/[^-_0-9a-zA-Z]/','',$script_tab_frame_size);
$max_logged_in_agents = preg_replace('/[^-_0-9a-zA-Z]/','',$max_logged_in_agents);
$user_codes_admin = preg_replace('/[^-_0-9a-zA-Z]/','',$user_codes_admin);
$conf_engine = preg_replace('/[^-_0-9a-zA-Z]/','',$conf_engine);
$user_group_script = preg_replace('/[^-_0-9a-zA-Z]/','',$user_group_script);
$abandon_check_queue = preg_replace('/[^-_0-9a-zA-Z]/','',$abandon_check_queue);
$demographic_quotas_rerank = preg_replace('/[^-_0-9a-zA-Z]/','',$demographic_quotas_rerank);
$demographic_quotas_list_resets = preg_replace('/[^-_0-9a-zA-Z]/','',$demographic_quotas_list_resets);
$log_latency_gaps = preg_replace('/[^-_0-9a-zA-Z]/','',$log_latency_gaps);
$second_alert_trigger = preg_replace('/[^-_0-9a-zA-Z]/','',$second_alert_trigger);
$dead_stop_recording = preg_replace('/[^-_0-9a-zA-Z]/','',$dead_stop_recording);
$manual_vm_status_updates = preg_replace('/[^-_0-9a-zA-Z]/','',$manual_vm_status_updates);
$force_per_call_notes = preg_replace('/[^-_0-9a-zA-Z]/','',$force_per_call_notes);
$third_alert_trigger = preg_replace('/[^-_0-9a-zA-Z]/','',$third_alert_trigger);
$agent_search_ingroup_list = preg_replace('/[^-_0-9a-zA-Z]/','',$agent_search_ingroup_list);
$hopper_hold_inserts = preg_replace('/[^-_0-9a-zA-Z]/','',$hopper_hold_inserts);
$holiday_method = preg_replace('/[^-_0-9a-zA-Z]/','',$holiday_method);
$leave_3way_stop_recording = preg_replace('/[^-_0-9a-zA-Z]/','',$leave_3way_stop_recording);
$manual_dial_lead_id = preg_replace('/[^-_0-9a-zA-Z]/','',$manual_dial_lead_id);
$stereo_recording = preg_replace('/[^-_0-9a-zA-Z]/','',$stereo_recording);
$stereo_parallel_recording = preg_replace('/[^-_0-9a-zA-Z]/','',$stereo_parallel_recording);
$stereo_recording_agent = preg_replace('/[^-_0-9a-zA-Z]/','',$stereo_recording_agent);
$call_count_limit_restrict = preg_replace('/[^-_0-9a-zA-Z]/','',$call_count_limit_restrict);

if ($non_latin < 1)
	{
	### ALPHA-NUMERIC ONLY ###
	$is_webphone = preg_replace('/[^-_0-9a-zA-Z]/','',$is_webphone);
	$campaign_script = preg_replace('/[^0-9a-zA-Z]/','',$campaign_script);
	$submit = preg_replace('/[^0-9a-zA-Z]/','',$submit);
	$campaign_cid = preg_replace('/[^0-9a-zA-Z]/','',$campaign_cid);
	$campaign_recording = preg_replace('/[^0-9a-zA-Z]/','',$campaign_recording);
	$ADD = preg_replace('/[^0-9a-zA-Z]/','',$ADD);
	$dial_prefix = preg_replace('/[^0-9a-zA-Z]/','',$dial_prefix);
	$state_call_time_state = preg_replace('/[^0-9a-zA-Z]/','',$state_call_time_state);
	$scheduled_callbacks = preg_replace('/[^0-9a-zA-Z]/','',$scheduled_callbacks);
	$concurrent_transfers = preg_replace('/[^0-9a-zA-Z]/','',$concurrent_transfers);
	$billable = preg_replace('/[^0-9a-zA-Z]/','',$billable);
	$pause_code = preg_replace('/[^0-9a-zA-Z]/','',$pause_code);
	$vicidial_recording_override = preg_replace('/[^0-9a-zA-Z]/','',$vicidial_recording_override);
	$ingroup_recording_override = preg_replace('/[^0-9a-zA-Z]/','',$ingroup_recording_override);
	$queuemetrics_log_id = preg_replace('/[^0-9a-zA-Z]/','',$queuemetrics_log_id);
	$after_hours_exten = preg_replace('/[^0-9a-zA-Z]/','',$after_hours_exten);
	$after_hours_voicemail = preg_replace('/[^0-9a-zA-Z]/','',$after_hours_voicemail);
	$qc_script = preg_replace('/[^0-9a-zA-Z]/','',$qc_script);
	$code = preg_replace('/[^0-9a-zA-Z]/','',$code);
	$survey_no_response_action = preg_replace('/[^0-9a-zA-Z]/','',$survey_no_response_action);
	$survey_ni_status = preg_replace('/[^0-9a-zA-Z]/','',$survey_ni_status);
	$qc_get_record_launch = preg_replace('/[^0-9a-zA-Z]/','',$qc_get_record_launch);
	$agent_pause_codes_active = preg_replace('/[^0-9a-zA-Z]/','',$agent_pause_codes_active);
	$three_way_dial_prefix = preg_replace('/[^0-9a-zA-Z]/','',$three_way_dial_prefix);
	$agent_shift_enforcement_override = preg_replace('/[^0-9a-zA-Z]/','',$agent_shift_enforcement_override);
	$survey_third_status = preg_replace('/[^0-9a-zA-Z]/','',$survey_third_status);
	$survey_fourth_status = preg_replace('/[^0-9a-zA-Z]/','',$survey_fourth_status);
	$sounds_web_directory = preg_replace('/[^0-9a-zA-Z]/','',$sounds_web_directory);
	$disable_alter_custphone = preg_replace('/[^0-9a-zA-Z]/','',$disable_alter_custphone);
	$view_calls_in_queue = preg_replace('/[^0-9a-zA-Z]/','',$view_calls_in_queue);
	$view_calls_in_queue_launch = preg_replace('/[^0-9a-zA-Z]/','',$view_calls_in_queue_launch);
	$grab_calls_in_queue = preg_replace('/[^0-9a-zA-Z]/','',$grab_calls_in_queue);
	$call_requeue_button = preg_replace('/[^0-9a-zA-Z]/','',$call_requeue_button);
	$pause_after_each_call = preg_replace('/[^0-9a-zA-Z]/','',$pause_after_each_call);
	$use_internal_dnc = preg_replace('/[^0-9a-zA-Z]/','',$use_internal_dnc);
	$use_campaign_dnc = preg_replace('/[^0-9a-zA-Z]/','',$use_campaign_dnc);
	$voicemail_id = preg_replace('/[^0-9a-zA-Z]/','',$voicemail_id);
	$new_voicemail_id = preg_replace('/[^0-9a-zA-Z]/','',$new_voicemail_id);
	$status_id = preg_replace('/[^0-9a-zA-Z]/','',$status_id);
	$agent_call_log_view = preg_replace('/[^0-9a-zA-Z]/','',$agent_call_log_view);
	$agent_call_log_view_override = preg_replace('/[^0-9a-zA-Z]/','',$agent_call_log_view_override);
	$queuemetrics_loginout = preg_replace('/[^0-9a-zA-Z]/','',$queuemetrics_loginout);
	$queuemetrics_callstatus = preg_replace('/[^0-9a-zA-Z]/','',$queuemetrics_callstatus);
	$hide_xfer_number_to_dial = preg_replace('/[^0-9a-zA-Z]/','',$hide_xfer_number_to_dial);
	$manual_dial_prefix = preg_replace('/[^0-9a-zA-Z]/','',$manual_dial_prefix);
	$customer_3way_hangup_logging = preg_replace('/[^0-9a-zA-Z]/','',$customer_3way_hangup_logging);
	$customer_3way_hangup_action = preg_replace('/[^0-9a-zA-Z]/','',$customer_3way_hangup_action);
	$queuemetrics_dispo_pause = preg_replace('/[^0-9a-zA-Z]/','',$queuemetrics_dispo_pause);
	$per_call_notes = preg_replace('/[^0-9a-zA-Z]/','',$per_call_notes);
	$my_callback_option = preg_replace('/[^0-9a-zA-Z]/','',$my_callback_option);
	$auto_pause_precall_code = preg_replace('/[^0-9a-zA-Z]/','',$auto_pause_precall_code);
	$disable_dispo_status = preg_replace('/[^0-9a-zA-Z]/','',$disable_dispo_status);
	$action_xfer_cid = preg_replace('/[^0-9a-zA-Z]/','',$action_xfer_cid);
	$callback_list_calltime = preg_replace('/[^0-9a-zA-Z]/','',$callback_list_calltime);
	$pause_after_next_call = preg_replace('/[^0-9a-zA-Z]/','',$pause_after_next_call);
	$owner_populate = preg_replace('/[^0-9a-zA-Z]/','',$owner_populate);
	$dead_max_dispo = preg_replace('/[^0-9a-zA-Z]/','',$dead_max_dispo);
	$dispo_max_dispo = preg_replace('/[^0-9a-zA-Z]/','',$dispo_max_dispo);
	$wrapup_bypass = preg_replace('/[^0-9a-zA-Z]/','',$wrapup_bypass);
	$wrapup_after_hotkey = preg_replace('/[^0-9a-zA-Z]/','',$wrapup_after_hotkey);
	$show_previous_callback = preg_replace('/[^0-9a-zA-Z]/','',$show_previous_callback);
	$clear_script = preg_replace('/[^0-9a-zA-Z]/','',$clear_script);
	$allow_chats = preg_replace('/[^0-9a-zA-Z]/','',$allow_chats);
	$allow_emails = preg_replace('/[^0-9a-zA-Z]/','',$allow_emails);
	$status_display_ingroup = preg_replace('/[^0-9a-zA-Z]/','',$status_display_ingroup);
	$populate_lead_ingroup = preg_replace('/[^0-9a-zA-Z]/','',$populate_lead_ingroup);
	$nva_new_status = preg_replace('/[^0-9a-zA-Z]/','',$nva_new_status);
	$report_default_format = preg_replace('/[^0-9a-zA-Z]/','',$report_default_format);
	$menu_background = preg_replace('/[^0-9a-zA-Z]/','',$menu_background);
	$frame_background = preg_replace('/[^0-9a-zA-Z]/','',$frame_background);
	$std_row1_background = preg_replace('/[^0-9a-zA-Z]/','',$std_row1_background);
	$std_row2_background = preg_replace('/[^0-9a-zA-Z]/','',$std_row2_background);
	$std_row3_background = preg_replace('/[^0-9a-zA-Z]/','',$std_row3_background);
	$std_row4_background = preg_replace('/[^0-9a-zA-Z]/','',$std_row4_background);
	$std_row5_background = preg_replace('/[^0-9a-zA-Z]/','',$std_row5_background);
	$alt_row1_background = preg_replace('/[^0-9a-zA-Z]/','',$alt_row1_background);
	$alt_row2_background = preg_replace('/[^0-9a-zA-Z]/','',$alt_row2_background);
	$alt_row3_background = preg_replace('/[^0-9a-zA-Z]/','',$alt_row3_background);
	$button_color = preg_replace('/[^0-9a-zA-Z]/','',$button_color);
	$dead_to_dispo = preg_replace('/[^0-9a-zA-Z]/','',$dead_to_dispo);
	$routing_prefix = preg_replace('/[^0-9a-zA-Z]/','',$routing_prefix);
	$inbound_survey = preg_replace('/[^0-9a-zA-Z]/','',$inbound_survey);
	$pause_max_dispo = preg_replace('/[^0-9a-zA-Z]/','',$pause_max_dispo);
	$areacode = preg_replace('/[^0-9a-zA-Z]/','',$areacode);
	$require_mgr_approval = preg_replace('/[^0-9a-zA-Z]/','',$require_mgr_approval);
	$mute_recordings = preg_replace('/[^0-9a-zA-Z]/','',$mute_recordings);
	$leave_vm_no_dispo = preg_replace('/[^0-9a-zA-Z]/','',$leave_vm_no_dispo);
	$amd_agent_route_options = preg_replace('/[^0-9a-zA-Z]/','',$amd_agent_route_options);
	$did_pattern_filter = preg_replace('/[^0-9a-zA-Z]/','',$did_pattern_filter);

	### ALPHA-NUMERIC and spaces and hash and star and comma
	$xferconf_a_dtmf = preg_replace('/[^ \,\*\#0-9a-zA-Z]/','',trim($xferconf_a_dtmf));
	$xferconf_b_dtmf = preg_replace('/[^ \,\*\#0-9a-zA-Z]/','',trim($xferconf_b_dtmf));
	$xferconf_c_dtmf = preg_replace('/[^ \,\*\#0-9a-zA-Z]/','',trim($xferconf_c_dtmf));
	$xferconf_d_dtmf = preg_replace('/[^ \,\*\#0-9a-zA-Z]/','',trim($xferconf_d_dtmf));
	$xferconf_e_dtmf = preg_replace('/[^ \,\*\#0-9a-zA-Z]/','',trim($xferconf_e_dtmf));
	$survey_third_digit = preg_replace('/[^ \,\*\#0-9a-zA-Z]/','',$survey_third_digit);
	$survey_fourth_digit = preg_replace('/[^ \,\*\#0-9a-zA-Z]/','',$survey_fourth_digit);
	$survey_third_exten = preg_replace('/[^ \,\*\#0-9a-zA-Z]/','',$survey_third_exten);
	$survey_fourth_exten = preg_replace('/[^ \,\*\#0-9a-zA-Z]/','',$survey_fourth_exten);
	$preset_dtmf = preg_replace('/[^ \,\*\#0-9a-zA-Z]/','',$preset_dtmf);

	### ALPHA-NUMERIC and underscore and dash
	$agi_output = preg_replace('/[^-_0-9a-zA-Z]/','',$agi_output);
	$ASTmgrSECRET = preg_replace('/[^-_0-9a-zA-Z]/','',$ASTmgrSECRET);
	$ASTmgrUSERNAME = preg_replace('/[^-_0-9a-zA-Z]/','',$ASTmgrUSERNAME);
	$ASTmgrUSERNAMElisten = preg_replace('/[^-_0-9a-zA-Z]/','',$ASTmgrUSERNAMElisten);
	$ASTmgrUSERNAMEsend = preg_replace('/[^-_0-9a-zA-Z]/','',$ASTmgrUSERNAMEsend);
	$ASTmgrUSERNAMEupdate = preg_replace('/[^-_0-9a-zA-Z]/','',$ASTmgrUSERNAMEupdate);
	$call_time_id = preg_replace('/[^-_0-9a-zA-Z]/','',$call_time_id);
	$campaign_id = preg_replace('/[^-_0-9a-zA-Z]/','',$campaign_id);
	$CoNfIrM = preg_replace('/[^-_0-9a-zA-Z]/','',$CoNfIrM);
	$DBX_database = preg_replace('/[^-_0-9a-zA-Z]/','',$DBX_database);
	$DBX_pass = preg_replace('/[^-_0-9a-zA-Z]/','',$DBX_pass);
	$DBX_user = preg_replace('/[^-_0-9a-zA-Z]/','',$DBX_user);
	$DBY_database = preg_replace('/[^-_0-9a-zA-Z]/','',$DBY_database);
	$DBY_pass = preg_replace('/[^-_0-9a-zA-Z]/','',$DBY_pass);
	$DBY_user = preg_replace('/[^-_0-9a-zA-Z]/','',$DBY_user);
	$dial_method = preg_replace('/[^-_0-9a-zA-Z]/','',$dial_method);
	$dial_status_a = preg_replace('/[^-_0-9a-zA-Z]/','',$dial_status_a);
	$dial_status_b = preg_replace('/[^-_0-9a-zA-Z]/','',$dial_status_b);
	$dial_status_c = preg_replace('/[^-_0-9a-zA-Z]/','',$dial_status_c);
	$dial_status_d = preg_replace('/[^-_0-9a-zA-Z]/','',$dial_status_d);
	$dial_status_e = preg_replace('/[^-_0-9a-zA-Z]/','',$dial_status_e);
	$ext_context = preg_replace('/[^-_0-9a-zA-Z]/','',$ext_context);
	$group_id = preg_replace('/[^-_0-9a-zA-Z]/','',$group_id);
	$lead_filter_id = preg_replace('/[^-_0-9a-zA-Z]/','',$lead_filter_id);
	$local_call_time = preg_replace('/[^-_0-9a-zA-Z]/','',$local_call_time);
	$login = preg_replace('/[^-_0-9a-zA-Z]/','',$login);
	$login_campaign = preg_replace('/[^-_0-9a-zA-Z]/','',$login_campaign);
	$login_pass = preg_replace('/[^-_0-9a-zA-Z]/','',$login_pass);
	$login_user = preg_replace('/[^-_0-9a-zA-Z]/','',$login_user);
	$new_login = preg_replace('/[^-_0-9a-zA-Z]/','',$new_login);
	$new_pass = preg_replace('/[^-_0-9a-zA-Z]/','',$new_pass);
	$next_agent_call = preg_replace('/[^-_0-9a-zA-Z]/','',$next_agent_call);
	$old_campaign_id = preg_replace('/[^-_0-9a-zA-Z]/','',$old_campaign_id);
	$old_server_id = preg_replace('/[^-_0-9a-zA-Z]/','',$old_server_id);
	$OLDuser_group = preg_replace('/[^-_0-9a-zA-Z]/','',$OLDuser_group);
	$park_file_name = preg_replace('/[^-_0-9a-zA-Z]/','',$park_file_name);
	$pass = preg_replace('/[^-_0-9a-zA-Z]/','',$pass);
	$phone_login = preg_replace('/[^-_0-9a-zA-Z]/','',$phone_login);
	$phone_pass = preg_replace('/[^-_0-9a-zA-Z]/','',$phone_pass);
	$PHP_AUTH_PW = preg_replace('/[^-_0-9a-zA-Z]/','',$PHP_AUTH_PW);
	$PHP_AUTH_USER = preg_replace('/[^-_0-9a-zA-Z]/','',$PHP_AUTH_USER);
	$protocol = preg_replace('/[^-_0-9a-zA-Z]/','',$protocol);
	$server_id = preg_replace('/[^-_0-9a-zA-Z]/','',$server_id);
	$stage = preg_replace('/[^-_0-9a-zA-Z]/','',$stage);
	$state_rule = preg_replace('/[^-_0-9a-zA-Z]/','',$state_rule);
	$holiday_rule = preg_replace('/[^-_0-9a-zA-Z]/','',$holiday_rule);
	$trunk_restriction = preg_replace('/[^-_0-9a-zA-Z]/','',$trunk_restriction);
	$user = preg_replace('/[^-_0-9a-zA-Z]/','',$user);
	$user_group = preg_replace('/[^-_0-9a-zA-Z]/','',$user_group);
	$VICIDIAL_park_on_filename = preg_replace('/[^-_0-9a-zA-Z]/','',$VICIDIAL_park_on_filename);
	$auto_alt_dial = preg_replace('/[^-_0-9a-zA-Z]/','',$auto_alt_dial);
	$dial_status = preg_replace('/[^-_0-9a-zA-Z]/','',$dial_status);
	$queuemetrics_eq_prepend = preg_replace('/[^-_0-9a-zA-Z]/','',$queuemetrics_eq_prepend);
	$vicidial_agent_disable = preg_replace('/[^-_0-9a-zA-Z]/','',$vicidial_agent_disable);
	$alter_custdata_override = preg_replace('/[^-_0-9a-zA-Z]/','',$alter_custdata_override);
	$list_order_mix = preg_replace('/[^-_0-9a-zA-Z]/','',$list_order_mix);
	$vcl_id = preg_replace('/[^-_0-9a-zA-Z]/','',$vcl_id);
	$mix_method = preg_replace('/[^-_0-9a-zA-Z]/','',$mix_method);
	$category = preg_replace('/[^-_0-9a-zA-Z]/','',$category);
	$vsc_id = preg_replace('/[^-_0-9a-zA-Z]/','',$vsc_id);
	$moh_context = preg_replace('/[^-_0-9a-zA-Z]/','',$moh_context);
	$source_campaign_id = preg_replace('/[^-_0-9a-zA-Z]/','',$source_campaign_id);
	$source_user_id = preg_replace('/[^-_0-9a-zA-Z]/','',$source_user_id);
	$source_group_id = preg_replace('/[^-_0-9a-zA-Z]/','',$source_group_id);
	$default_xfer_group = preg_replace('/[^-_0-9a-zA-Z]/','',$default_xfer_group);
	$drop_exten = preg_replace('/[^-_0-9a-zA-Z]/','',$drop_exten);
	$safe_harbor_exten = preg_replace('/[^-_0-9a-zA-Z]/','',$safe_harbor_exten);
	$drop_action = preg_replace('/[^-_0-9a-zA-Z]/','',$drop_action);
	$drop_inbound_group = preg_replace('/[^-_0-9a-zA-Z]/','',$drop_inbound_group);
	$afterhours_xfer_group = preg_replace('/[^-_0-9a-zA-Z]/','',$afterhours_xfer_group);
	$after_hours_action = preg_replace('/[^-_0-9a-zA-Z]/','',$after_hours_action);
	$alias_id = preg_replace('/[^-_0-9a-zA-Z]/','',$alias_id);
	$shift_id = preg_replace('/[^-_0-9a-zA-Z]/','',$shift_id);
	$qc_shift_id = preg_replace('/[^-_0-9a-zA-Z]/','',$qc_shift_id);
	$survey_method = preg_replace('/[^-_0-9a-zA-Z]/','',$survey_method);
	$alter_custphone_override = preg_replace('/[^-_0-9a-zA-Z]/','',$alter_custphone_override);
	$manual_dial_filter = preg_replace('/[^-_0-9a-zA-Z]/','',$manual_dial_filter);
	$manual_dial_search_filter = preg_replace('/[^-_0-9a-zA-Z]/','',$manual_dial_search_filter);
	$agent_clipboard_copy = preg_replace('/[^-_0-9a-zA-Z]/','',$agent_clipboard_copy);
	$hold_time_option = preg_replace('/[^-_0-9a-zA-Z]/','',$hold_time_option);
	$hold_time_option_xfer_group = preg_replace('/[^-_0-9a-zA-Z]/','',$hold_time_option_xfer_group);
	$hold_recall_xfer_group = preg_replace('/[^-_0-9a-zA-Z]/','',$hold_recall_xfer_group);
	$play_welcome_message = preg_replace('/[^-_0-9a-zA-Z]/','',$play_welcome_message);
	$did_route = preg_replace('/[^-_0-9a-zA-Z]/','',$did_route);
	$user_unavailable_action = preg_replace('/[^-_0-9a-zA-Z]/','',$user_unavailable_action);
	$user_route_settings_ingroup = preg_replace('/[^-_0-9a-zA-Z]/','',$user_route_settings_ingroup);
	$call_handle_method = preg_replace('/[^-_0-9a-zA-Z]/','',$call_handle_method);
	$agent_search_method = preg_replace('/[^-_0-9a-zA-Z]/','',$agent_search_method);
	$hold_time_option_voicemail = preg_replace('/[^-_0-9a-zA-Z]/','',$hold_time_option_voicemail);
	$exten_context = preg_replace('/[^-_0-9a-zA-Z]/','',$exten_context);
	$three_way_call_cid = preg_replace('/[^-_0-9a-zA-Z]/','',$three_way_call_cid);
	$web_form_target = preg_replace('/[^-_0-9a-zA-Z]/','',$web_form_target);
	$recording_web_link = preg_replace('/[^-_0-9a-zA-Z]/','',$recording_web_link);
	$vtiger_search_category = preg_replace('/[^-_0-9a-zA-Z]/','',$vtiger_search_category);
	$vtiger_create_call_record = preg_replace('/[^-_0-9a-zA-Z]/','',$vtiger_create_call_record);
	$vtiger_create_lead_record = preg_replace('/[^-_0-9a-zA-Z]/','',$vtiger_create_lead_record);
	$vtiger_screen_login = preg_replace('/[^-_0-9a-zA-Z]/','',$vtiger_screen_login);
	$cpd_amd_action = preg_replace('/[^-_0-9a-zA-Z]/','',$cpd_amd_action);
	$cpd_unknown_action = preg_replace('/[^-_0-9a-zA-Z]/','',$cpd_unknown_action);
	$template_id = preg_replace('/[^-_0-9a-zA-Z]/','',$template_id);
	$carrier_id = preg_replace('/[^-_0-9a-zA-Z]/','',$carrier_id);
	$source_carrier = preg_replace('/[^-_0-9a-zA-Z]/','',$source_carrier);
	$group_alias_id = preg_replace('/[^-_0-9a-zA-Z]/','',$group_alias_id);
	$default_group_alias = preg_replace('/[^-_0-9a-zA-Z]/','',$default_group_alias);
	$vtiger_search_dead = preg_replace('/[^-_0-9a-zA-Z]/','',$vtiger_search_dead);
	$menu_id = preg_replace('/[^-_0-9a-zA-Z]/','',$menu_id);
	$source_menu = preg_replace('/[^-_0-9a-zA-Z]/','',$source_menu);
	$call_time_id = preg_replace('/[^-_0-9a-zA-Z]/','',$call_time_id);
	$phone_context = preg_replace('/[^-_0-9a-zA-Z]/','',$phone_context);
	$new_conf_secret = preg_replace('/[^-_0-9a-zA-Z]/','',$new_conf_secret);
	$conf_secret = preg_replace('/[^-_0-9a-zA-Z]/','',$conf_secret);
	$tracking_group = preg_replace('/[^-_0-9a-zA-Z]/','',$tracking_group);
	$no_agent_no_queue = preg_replace('/[^-_0-9a-zA-Z]/','',$no_agent_no_queue);
	$no_agent_action = preg_replace('/[^-_0-9a-zA-Z]/','',$no_agent_action);
	$quick_transfer_button = preg_replace('/[^-_0-9a-zA-Z]/','',$quick_transfer_button);
	$prepopulate_transfer_preset = preg_replace('/[^-_0-9a-zA-Z]/','',$prepopulate_transfer_preset);
	$tts_id = preg_replace('/[^-_0-9a-zA-Z]/','',$tts_id);
	$drop_rate_group = preg_replace('/[^-_0-9a-zA-Z]/','',$drop_rate_group);
	$agent_dial_owner_only = preg_replace('/[^-_0-9a-zA-Z]/','',$agent_dial_owner_only);
	$reset_time = preg_replace('/[^-_0-9a-zA-Z]/','',$reset_time);
	$moh_id = preg_replace('/[^-_0-9a-zA-Z]/','',$moh_id);
	$mohsuggest = preg_replace('/[^-_0-9a-zA-Z]/','',$mohsuggest);
	$drop_inbound_group_override = preg_replace('/[^-_0-9a-zA-Z]/','',$drop_inbound_group_override);
	$timer_action = preg_replace('/[^-_0-9a-zA-Z]/','',$timer_action);
	$record_call = preg_replace('/[^-_0-9a-zA-Z]/','',$record_call);
	$scheduled_callbacks_alert = preg_replace('/[^-_0-9a-zA-Z]/','',$scheduled_callbacks_alert);
	$extension_group_id = preg_replace('/[^-_0-9a-zA-Z]/','',$extension_group_id);
	$extension_group = preg_replace('/[^-_0-9a-zA-Z]/','',$extension_group);
	$scheduled_callbacks_count = preg_replace('/[^-_0-9a-zA-Z]/','',$scheduled_callbacks_count);
	$manual_dial_override = preg_replace('/[^-_0-9a-zA-Z]/','',$manual_dial_override);
	$blind_monitor_warning = preg_replace('/[^-_0-9a-zA-Z]/','',$blind_monitor_warning);
	$uniqueid_status_display = preg_replace('/[^-_0-9a-zA-Z]/','',$uniqueid_status_display);
	$hold_time_option_callmenu = preg_replace('/[^-_0-9a-zA-Z]/','',$hold_time_option_callmenu);
	$inbound_queue_no_dial = preg_replace('/[^-_0-9a-zA-Z]/','',$inbound_queue_no_dial);
	$hold_time_second_option = preg_replace('/[^-_0-9a-zA-Z]/','',$hold_time_second_option);
	$hold_time_third_option = preg_replace('/[^-_0-9a-zA-Z]/','',$hold_time_third_option);
	$wait_hold_option_priority = preg_replace('/[^-_0-9a-zA-Z]/','',$wait_hold_option_priority);
	$wait_time_option = preg_replace('/[^-_0-9a-zA-Z]/','',$wait_time_option);
	$wait_time_second_option = preg_replace('/[^-_0-9a-zA-Z]/','',$wait_time_second_option);
	$wait_time_third_option = preg_replace('/[^-_0-9a-zA-Z]/','',$wait_time_third_option);
	$wait_time_option_xfer_group = preg_replace('/[^-_0-9a-zA-Z]/','',$wait_time_option_xfer_group);
	$wait_time_option_callmenu = preg_replace('/[^-_0-9a-zA-Z]/','',$wait_time_option_callmenu);
	$wait_time_option_voicemail = preg_replace('/[^-_0-9a-zA-Z]/','',$wait_time_option_voicemail);
	$filter_phone_group_id = preg_replace('/[^-_0-9a-zA-Z]/','',$filter_phone_group_id);
	$filter_action = preg_replace('/[^-_0-9a-zA-Z]/','',$filter_action);
	$filter_user_unavailable_action = preg_replace('/[^-_0-9a-zA-Z]/','',$filter_user_unavailable_action);
	$filter_user_route_settings_ingroup = preg_replace('/[^-_0-9a-zA-Z]/','',$filter_user_route_settings_ingroup);
	$filter_agent_search_method = preg_replace('/[^-_0-9a-zA-Z]/','',$filter_agent_search_method);
	$filter_campaign_id = preg_replace('/[^-_0-9a-zA-Z]/','',$filter_campaign_id);
	$filter_group_id = preg_replace('/[^-_0-9a-zA-Z]/','',$filter_group_id);
	$filter_menu_id = preg_replace('/[^-_0-9a-zA-Z]/','',$filter_menu_id);
	$filter_call_handle_method = preg_replace('/[^-_0-9a-zA-Z]/','',$filter_call_handle_method);
	$filter_user = preg_replace('/[^-_0-9a-zA-Z]/','',$filter_user);
	$filter_exten_context = preg_replace('/[^-_0-9a-zA-Z]/','',$filter_exten_context);
	$webphone_systemkey = preg_replace('/[^-_0-9a-zA-Z]/','',$webphone_systemkey);
	$webphone_dialpad = preg_replace('/[^-_0-9a-zA-Z]/','',$webphone_dialpad);
	$webphone_systemkey_override = preg_replace('/[^-_0-9a-zA-Z]/','',$webphone_systemkey_override);
	$webphone_dialpad_override = preg_replace('/[^-_0-9a-zA-Z]/','',$webphone_dialpad_override);
	$default_phone_registration_password = preg_replace('/[^-_0-9a-zA-Z]/','',$default_phone_registration_password);
	$default_phone_login_password = preg_replace('/[^-_0-9a-zA-Z]/','',$default_phone_login_password);
	$default_server_password = preg_replace('/[^-_0-9a-zA-Z]/','',$default_server_password);
	$ivr_park_call = preg_replace('/[^-_0-9a-zA-Z]/','',$ivr_park_call);
	$manual_preview_dial = preg_replace('/[^-_0-9a-zA-Z]/','',$manual_preview_dial);
	$realtime_agent_time_stats = preg_replace('/[^-_0-9a-zA-Z]/','',$realtime_agent_time_stats);
	$api_manual_dial = preg_replace('/[^-_0-9a-zA-Z]/','',$api_manual_dial);
	$manual_dial_call_time_check = preg_replace('/[^-_0-9a-zA-Z]/','',$manual_dial_call_time_check);
	$lead_order_secondary = preg_replace('/[^-_0-9a-zA-Z]/','',$lead_order_secondary);
	$agent_lead_search = preg_replace('/[^-_0-9a-zA-Z]/','',$agent_lead_search);
	$agent_lead_search_method = preg_replace('/[^-_0-9a-zA-Z]/','',$agent_lead_search_method);
	$manual_dial_cid = preg_replace('/[^-_0-9a-zA-Z]/','',$manual_dial_cid);
	$post_phone_time_diff_alert = preg_replace('/[^-_0-9a-zA-Z]/','',$post_phone_time_diff_alert);
	$custom_3way_button_transfer = preg_replace('/[^-_0-9a-zA-Z]/','',$custom_3way_button_transfer);
	$available_only_tally_threshold_agents = preg_replace('/[^-_0-9a-zA-Z]/','',$available_only_tally_threshold_agents);
	$dial_level_threshold_agents = preg_replace('/[^-_0-9a-zA-Z]/','',$dial_level_threshold_agents);
	$time_zone_setting = preg_replace('/[^-_0-9a-zA-Z]/','',$time_zone_setting);
	$safe_harbor_menu_id = preg_replace('/[^-_0-9a-zA-Z]/','',$safe_harbor_menu_id);
	$survey_menu_id = preg_replace('/[^-_0-9a-zA-Z]/','',$survey_menu_id);
	$dl_diff_target_method = preg_replace('/[^-_0-9a-zA-Z]/','',$dl_diff_target_method);
	$disable_dispo_screen = preg_replace('/[^-_0-9a-zA-Z]/','',$disable_dispo_screen);
	$screen_labels = preg_replace('/[^-_0-9a-zA-Z]/','',$screen_labels);
	$label_hide_field_logs = preg_replace('/[^-_0-9a-zA-Z]/','',$label_hide_field_logs);
	$label_id = preg_replace('/[^-_0-9a-zA-Z]/','',$label_id);
	$status_display_fields = preg_replace('/[^-_0-9a-zA-Z]/','',$status_display_fields);
	$voicemail_timezone = preg_replace('/[^-_0-9a-zA-Z]/','',$voicemail_timezone);
	$default_voicemail_timezone = preg_replace('/[^-_0-9a-zA-Z]/','',$default_voicemail_timezone);
	$on_hook_cid = preg_replace('/[^-_0-9a-zA-Z]/','',$on_hook_cid);
	$pllb_grouping = preg_replace('/[^-_0-9a-zA-Z]/','',$pllb_grouping);
	$user_start = preg_replace('/[^-_0-9a-zA-Z]/','',$user_start);
	$drop_callmenu = preg_replace('/[^-_0-9a-zA-Z]/','',$drop_callmenu);
	$after_hours_callmenu = preg_replace('/[^-_0-9a-zA-Z]/','',$after_hours_callmenu);
	$survey_recording = preg_replace('/[^-_0-9a-zA-Z]/','',$survey_recording);
	$dtmf_field = preg_replace('/[^-_0-9a-zA-Z]/','',$dtmf_field);
	$preset_contact_search = preg_replace('/[^-_0-9a-zA-Z]/','',$preset_contact_search);
	$admin_hide_phone_data = preg_replace('/[^-_0-9a-zA-Z]/','',$admin_hide_phone_data);
	$max_calls_method = preg_replace('/[^-_0-9a-zA-Z]/','',$max_calls_method);
	$max_calls_action = preg_replace('/[^-_0-9a-zA-Z]/','',$max_calls_action);
	$in_group_dial = preg_replace('/[^-_0-9a-zA-Z]/','',$in_group_dial);
	$in_group_dial_select = preg_replace('/[^-_0-9a-zA-Z]/','',$in_group_dial_select);
	$queuemetrics_socket = preg_replace('/[^-_0-9a-zA-Z]/','',$queuemetrics_socket);
	$holiday_id = preg_replace('/[^-_0-9a-zA-Z]/','',$holiday_id);
	$holiday_date = preg_replace('/[^-_0-9a-zA-Z]/','',$holiday_date);
	$holiday_status = preg_replace('/[^-_0-9a-zA-Z]/','',$holiday_status);
	$expiration_date = preg_replace('/[^-_0-9a-zA-Z]/','',$expiration_date);
	$amd_inbound_group = preg_replace('/[^-_0-9a-zA-Z]/','',$amd_inbound_group);
	$amd_callmenu = preg_replace('/[^-_0-9a-zA-Z]/','',$amd_callmenu);
	$filter_inbound_number = preg_replace('/[^-_0-9a-zA-Z]/','',$filter_inbound_number);
	$filter_dnc_campaign = preg_replace('/[^-_0-9a-zA-Z]/','',$filter_dnc_campaign);
	$manual_dial_search_checkbox = preg_replace('/[^-_0-9a-zA-Z]/','',$manual_dial_search_checkbox);
	$alt_number_dialing = preg_replace('/[^-_0-9a-zA-Z]/','',$alt_number_dialing);
	$no_agent_ingroup_redirect = preg_replace('/[^-_0-9a-zA-Z]/','',$no_agent_ingroup_redirect);
	$no_agent_ingroup_id = preg_replace('/[^-_0-9a-zA-Z]/','',$no_agent_ingroup_id);
	$pre_filter_phone_group_id = preg_replace('/[^-_0-9a-zA-Z]/','',$pre_filter_phone_group_id);
	$shift_enforcement = preg_replace('/[^-_0-9a-zA-Z]/','',$shift_enforcement);
	$comments_all_tabs = preg_replace('/[^-_0-9a-zA-Z]/','',$comments_all_tabs);
	$comments_dispo_screen = preg_replace('/[^-_0-9a-zA-Z]/','',$comments_dispo_screen);
	$comments_callback_screen = preg_replace('/[^-_0-9a-zA-Z]/','',$comments_callback_screen);
	$qc_comment_history = preg_replace('/[^-_0-9a-zA-Z]/','',$qc_comment_history);
	$language_method = preg_replace('/[^-_0-9a-zA-Z]/','',$language_method);
	$manual_dial_override_field = preg_replace('/[^-_0-9a-zA-Z]/','',$manual_dial_override_field);
	$max_queue_ingroup_id = preg_replace('/[^-_0-9a-zA-Z]/','',$max_queue_ingroup_id);
	$agent_debug_logging = preg_replace('/[^-_0-9a-zA-Z]/','',$agent_debug_logging);
	$container_id = preg_replace('/[^-_0-9a-zA-Z]/','',$container_id);
	$phone_defaults_container = preg_replace('/[^-_0-9a-zA-Z]/','',$phone_defaults_container);
	$container_type = preg_replace('/[^-_0-9a-zA-Z]/','',$container_type);
	$status_group_id = preg_replace('/[^-_0-9a-zA-Z]/','',$status_group_id);
	$unavail_dialplan_fwd_exten = preg_replace('/[^-_0-9a-zA-Z]/','',$unavail_dialplan_fwd_exten);
	$unavail_dialplan_fwd_context = preg_replace('/[^-_0-9a-zA-Z]/','',$unavail_dialplan_fwd_context);
	$nva_search_method = preg_replace('/[^-_0-9a-zA-Z]/','',$nva_search_method);
	$on_hook_cid_number = preg_replace('/[^-_0-9a-zA-Z]/','',$on_hook_cid_number);
	$colors_id = preg_replace('/[^-_0-9a-zA-Z]/','',$colors_id);
	$agent_screen_colors = preg_replace('/[^-_0-9a-zA-Z]/','',$agent_screen_colors);
	$customer_chat_screen_colors = preg_replace('/[^-_0-9a-zA-Z]/','',$customer_chat_screen_colors);
	$web_loader_phone_length = preg_replace('/[^-_0-9a-zA-Z]/','',$web_loader_phone_length);
	$agent_chat_screen_colors = preg_replace('/[^-_0-9a-zA-Z]/','',$agent_chat_screen_colors);
	$populate_lead_province = preg_replace('/[^-_0-9a-zA-Z]/','',$populate_lead_province);
	$populate_lead_owner = preg_replace('/[^-_0-9a-zA-Z]/','',$populate_lead_owner);
	$areacode_filter = preg_replace('/[^-_0-9a-zA-Z]/','',$areacode_filter);
	$areacode_filter_action = preg_replace('/[^-_0-9a-zA-Z]/','',$areacode_filter_action);
	$report_id = preg_replace('/[^-_0-9a-zA-Z]/','',$report_id);
	$report_destination = preg_replace('/[^-_0-9a-zA-Z]/','',$report_destination);
	$report_times = preg_replace('/[^-_0-9a-zA-Z]/','',$report_times);
	$report_monthdays = preg_replace('/[^-_0-9a-zA-Z]/','',$report_monthdays);
	$populate_state_areacode = preg_replace('/[^-_0-9a-zA-Z]/','',$populate_state_areacode);
	$dl_id = preg_replace('/[^-_0-9a-zA-Z]/','',$dl_id);
	$duplicate_check = preg_replace('/[^-_0-9a-zA-Z]/','',$duplicate_check);
	$dl_times = preg_replace('/[^-_0-9a-zA-Z]/','',$dl_times);
	$dl_monthdays = preg_replace('/[^-_0-9a-zA-Z]/','',$dl_monthdays);
	$use_custom_cid = preg_replace('/[^-_0-9a-zA-Z]/','',$use_custom_cid);
	$system_ip_blacklist = preg_replace('/[^-_0-9a-zA-Z]/','',$system_ip_blacklist);
	$admin_ip_list = preg_replace('/[^-_0-9a-zA-Z]/','',$admin_ip_list);
	$agent_ip_list = preg_replace('/[^-_0-9a-zA-Z]/','',$agent_ip_list);
	$api_ip_list = preg_replace('/[^-_0-9a-zA-Z]/','',$api_ip_list);
	$ip_list_id = preg_replace('/[^-_0-9a-zA-Z]/','',$ip_list_id);
	$inbound_survey_callmenu = preg_replace('/[^-_0-9a-zA-Z]/','',$inbound_survey_callmenu);
	$filename_override = preg_replace('/[^-_0-9a-zA-Z]/','',$filename_override);
	$did_id = preg_replace('/[^-_0-9a-zA-Z]/','',$did_id);
	$extension_appended_cidname = preg_replace('/[^-_0-9a-zA-Z]/','',$extension_appended_cidname);
	$max_inbound_calls_outcome = preg_replace('/[^-_0-9a-zA-Z]/','',$max_inbound_calls_outcome);
	$manual_auto_next_options = preg_replace('/[^-_0-9a-zA-Z]/','',$manual_auto_next_options);
	$agent_screen_time_display = preg_replace('/[^-_0-9a-zA-Z]/','',$agent_screen_time_display);
	$get_call_launch = preg_replace('/[^-_0-9a-zA-Z]/','',$get_call_launch);
	$next_dial_my_callbacks = preg_replace('/[^-_0-9a-zA-Z]/','',$next_dial_my_callbacks);
	$anyone_callback_inactive_lists = preg_replace('/[^-_0-9a-zA-Z]/','',$anyone_callback_inactive_lists);
	$inbound_no_agents_no_dial_container = preg_replace('/[^-_0-9a-zA-Z]/','',$inbound_no_agents_no_dial_container);
	$closing_time_action = preg_replace('/[^-_0-9a-zA-Z]/','',$closing_time_action);
	$closing_time_option_exten = preg_replace('/[^-_0-9a-zA-Z]/','',$closing_time_option_exten);
	$closing_time_option_callmenu = preg_replace('/[^-_0-9a-zA-Z]/','',$closing_time_option_callmenu);
	$closing_time_option_voicemail = preg_replace('/[^-_0-9a-zA-Z]/','',$closing_time_option_voicemail);
	$closing_time_option_callback_list_id = preg_replace('/[^-_0-9a-zA-Z]/','',$closing_time_option_callback_list_id);
	$icbq_call_time_id = preg_replace('/[^-_0-9a-zA-Z]/','',$icbq_call_time_id);
	$add_lead_timezone = preg_replace('/[^-_0-9a-zA-Z]/','',$add_lead_timezone);
	$icbq_dial_filter = preg_replace('/[^-_0-9a-zA-Z]/','',$icbq_dial_filter);
	$cid_group_id = preg_replace('/[^-_0-9a-zA-Z]/','',$cid_group_id);
	$cid_group_id_two = preg_replace('/[^-_0-9a-zA-Z]/','',$cid_group_id_two);
	$cid_group_type = preg_replace('/[^-_0-9a-zA-Z]/','',$cid_group_type);
	$populate_lead_source = preg_replace('/[^-_0-9a-zA-Z]/','',$populate_lead_source);
	$dead_trigger_action = preg_replace('/[^-_0-9a-zA-Z]/','',$dead_trigger_action);
	$dead_trigger_repeat = preg_replace('/[^-_0-9a-zA-Z]/','',$dead_trigger_repeat);
	$cid_cb_confirm_number = preg_replace('/[^-_0-9a-zA-Z]/','',$cid_cb_confirm_number);
	$cid_cb_invalid_filter_phone_group = preg_replace('/[^-_0-9a-zA-Z]/','',$cid_cb_invalid_filter_phone_group);
	$scheduled_callbacks_auto_reschedule = preg_replace('/[^-_0-9a-zA-Z]/','',$scheduled_callbacks_auto_reschedule);
	$scheduled_callbacks_timezones_container = preg_replace('/[^-_0-9a-zA-Z]/','',$scheduled_callbacks_timezones_container);
	$three_way_volume_buttons = preg_replace('/[^-_0-9a-zA-Z]/','',$three_way_volume_buttons);
	$callback_dnc = preg_replace('/[^-_0-9a-zA-Z]/','',$callback_dnc);
	$hide_call_log_info = preg_replace('/[^-_0-9a-zA-Z]/','',$hide_call_log_info);
	$call_quota_lead_ranking = preg_replace('/[^-_0-9a-zA-Z]/','',$call_quota_lead_ranking);
	$sip_event_logging = preg_replace('/[^-_0-9a-zA-Z]/','',$sip_event_logging);
	$auto_active_list_new = preg_replace('/[^-_0-9a-zA-Z]/','',$auto_active_list_new);
	$script_id = preg_replace('/[^-_0-9a-zA-Z]/','',$script_id);
	$ingroup_script = preg_replace('/[^-_0-9a-zA-Z]/','',$ingroup_script);
	$ingroup_script_two = preg_replace('/[^-_0-9a-zA-Z]/','',$ingroup_script_two);
	$campaign_script = preg_replace('/[^-_0-9a-zA-Z]/','',$campaign_script);
	$campaign_script_two = preg_replace('/[^-_0-9a-zA-Z]/','',$campaign_script_two);
	$leave_vm_message_group_id = preg_replace('/[^-_0-9a-zA-Z]/','',$leave_vm_message_group_id);
	$dial_timeout_lead_container = preg_replace('/[^-_0-9a-zA-Z]/','',$dial_timeout_lead_container);
	$amd_type = preg_replace('/[^-_0-9a-zA-Z]/','',$amd_type);
	$recording_buttons = preg_replace('/[^-_0-9a-zA-Z]/','',$recording_buttons);
	$use_other_campaign_dnc = preg_replace('/[^-_0-9a-zA-Z]/','',$use_other_campaign_dnc);
	$browser_alert_sound = preg_replace('/[^-_0-9a-zA-Z]/','',$browser_alert_sound);
	$three_way_record_stop_exception = preg_replace('/[^-_0-9a-zA-Z]/','',$three_way_record_stop_exception);
	$queuemetrics_pausereason = preg_replace('/[^-_0-9a-zA-Z]/','',$queuemetrics_pausereason);
	$answer_signal = preg_replace('/[^-_0-9a-zA-Z]/','',$answer_signal);
	$inbound_drop_voicemail = preg_replace('/[^-_0-9a-zA-Z]/','',$inbound_drop_voicemail);
	$inbound_after_hours_voicemail = preg_replace('/[^-_0-9a-zA-Z]/','',$inbound_after_hours_voicemail);
	$pause_max_exceptions = preg_replace('/[^-_0-9a-zA-Z]/','',$pause_max_exceptions);
	$two_factor_container = preg_replace('/[^-_0-9a-zA-Z]/','',$two_factor_container);
	$calls_inqueue_count_one = preg_replace('/[^-_0-9a-zA-Z]/','',$calls_inqueue_count_one);
	$calls_inqueue_count_two = preg_replace('/[^-_0-9a-zA-Z]/','',$calls_inqueue_count_two);
	$drop_call_seconds_override = preg_replace('/[^-_0-9a-zA-Z]/','',$drop_call_seconds_override);
	$in_man_dial_next_ready_seconds_override = preg_replace('/[^-_0-9a-zA-Z]/','',$in_man_dial_next_ready_seconds_override);
	$call_limit_24hour_method = preg_replace('/[^-_0-9a-zA-Z]/','',$call_limit_24hour_method);
	$call_limit_24hour_scope = preg_replace('/[^-_0-9a-zA-Z]/','',$call_limit_24hour_scope);
	$call_limit_24hour_override = preg_replace('/[^-_0-9a-zA-Z]/','',$call_limit_24hour_override);
	$in_queue_nanque_exceptions = preg_replace('/[^-_0-9a-zA-Z]/','',$in_queue_nanque_exceptions);
	$queue_group = preg_replace('/[^-_0-9a-zA-Z]/','',$queue_group);
	$pre_filter_recent_call = preg_replace('/[^-_0-9a-zA-Z]/','',$pre_filter_recent_call);
	$pre_filter_recent_extension = preg_replace('/[^-_0-9a-zA-Z]/','',$pre_filter_recent_extension);
	$user_group_two = preg_replace('/[^-_0-9a-zA-Z]/','',$user_group_two);
	$agent_script_override = preg_replace('/[^-_0-9a-zA-Z]/','',$agent_script_override);
	$inbound_list_script_override = preg_replace('/[^-_0-9a-zA-Z]/','',$inbound_list_script_override);
	$agent_hangup_route = preg_replace('/[^-_0-9a-zA-Z]/','',$agent_hangup_route);
	$show_confetti = preg_replace('/[^-_0-9a-zA-Z]/','',$show_confetti);
	$webphone_settings = preg_replace('/[^-_0-9a-zA-Z]/','',$webphone_settings);
	$demographic_quotas = preg_replace('/[^-_0-9a-zA-Z]/','',$demographic_quotas);
	$demographic_quotas_container = preg_replace('/[^-_0-9a-zA-Z]/','',$demographic_quotas_container);
	$weekday_resets_container = preg_replace('/[^-_0-9a-zA-Z]/','',$weekday_resets_container);
	$second_alert_container = preg_replace('/[^-_0-9a-zA-Z]/','',$second_alert_container);
	$second_alert_only = preg_replace('/[^-_0-9a-zA-Z]/','',$second_alert_only);
	$third_alert_container = preg_replace('/[^-_0-9a-zA-Z]/','',$third_alert_container);
	$third_alert_only = preg_replace('/[^-_0-9a-zA-Z]/','',$third_alert_only);
	$state_descriptions = preg_replace('/[^-_0-9a-zA-Z]/','',$state_descriptions);
	$khomp_settings_container = preg_replace('/[^-_0-9a-zA-Z]/','',$khomp_settings_container);
	$agent_man_dial_filter = preg_replace('/[^-_0-9a-zA-Z]/','',$agent_man_dial_filter);
	$agent_3way_dial_filter = preg_replace('/[^-_0-9a-zA-Z]/','',$agent_3way_dial_filter);

	### ALPHA-NUMERIC and underscore 
	$qc_statuses_id = preg_replace('/[^_0-9a-zA-Z]/','',$qc_statuses_id);

	### ALPHA-NUMERIC and underscore and dash and slash and dot
	$menu_timeout_prompt = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$menu_timeout_prompt);
	$menu_invalid_prompt = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$menu_invalid_prompt);
	$after_hours_message_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$after_hours_message_filename);
	$welcome_message_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$welcome_message_filename);
	$onhold_prompt_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$onhold_prompt_filename);
	$hold_time_option_callback_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$hold_time_option_callback_filename);
	$agent_alert_exten = preg_replace('/[^-\|\/\._0-9a-zA-Z]/','',$agent_alert_exten);
	$filename = preg_replace('/[^-\/\._0-9a-zA-Z]/','',$filename);
	$am_message_exten = preg_replace('/[^-\|\/\._0-9a-zA-Z]/','',$am_message_exten);
	$am_message_exten_override = preg_replace('/[^-\|\/\._0-9a-zA-Z]/','',$am_message_exten_override);
	$campaign_groups = preg_replace('/[^-\|\/\._0-9a-zA-Z]/','',$campaign_groups);
	$blind_monitor_filename = preg_replace('/[^-\|\/\._0-9a-zA-Z]/','',$blind_monitor_filename);
	$hold_time_option_press_filename = preg_replace('/[^-\|\/\._0-9a-zA-Z]/','',$hold_time_option_press_filename);
	$default_afterhours_filename_override = preg_replace('/[^-\|\/\._0-9a-zA-Z]/','',$default_afterhours_filename_override);
	$sunday_afterhours_filename_override = preg_replace('/[^-\|\/\._0-9a-zA-Z]/','',$sunday_afterhours_filename_override);
	$monday_afterhours_filename_override = preg_replace('/[^-\|\/\._0-9a-zA-Z]/','',$monday_afterhours_filename_override);
	$tuesday_afterhours_filename_override = preg_replace('/[^-\|\/\._0-9a-zA-Z]/','',$tuesday_afterhours_filename_override);
	$wednesday_afterhours_filename_override = preg_replace('/[^-\|\/\._0-9a-zA-Z]/','',$wednesday_afterhours_filename_override);
	$thursday_afterhours_filename_override = preg_replace('/[^-\|\/\._0-9a-zA-Z]/','',$thursday_afterhours_filename_override);
	$friday_afterhours_filename_override = preg_replace('/[^-\|\/\._0-9a-zA-Z]/','',$friday_afterhours_filename_override);
	$saturday_afterhours_filename_override = preg_replace('/[^-\|\/\._0-9a-zA-Z]/','',$saturday_afterhours_filename_override);
	$admin_web_directory = preg_replace('/[^-\|\/\._0-9a-zA-Z]/','',$admin_web_directory);
	$tts_voice = preg_replace('/[^-\|\/\._0-9a-zA-Z]/','',$tts_voice);
	$wait_time_option_callback_filename = preg_replace('/[^-\|\/\._0-9a-zA-Z]/','',$wait_time_option_callback_filename);
	$wait_time_option_press_filename = preg_replace('/[^-\|\/\._0-9a-zA-Z]/','',$wait_time_option_press_filename);
	$eht_minimum_prompt_filename = preg_replace('/[^-\|\/\._0-9a-zA-Z]/','',$eht_minimum_prompt_filename);
	$queuemetrics_phone_environment = preg_replace('/[^-\|\/\._0-9a-zA-Z]/','',$queuemetrics_phone_environment);
	$active_twin_server_ip = preg_replace('/[^-\|\/\._0-9a-zA-Z]/','',$active_twin_server_ip);
	$safe_harbor_audio = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$safe_harbor_audio);
	$alt_log_server_ip = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$alt_log_server_ip);
	$alt_log_dbname = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$alt_log_dbname);
	$alt_log_login = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$alt_log_login);
	$alt_log_pass = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$alt_log_pass);
	$coldstorage_server_ip = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$coldstorage_server_ip);
	$coldstorage_dbname = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$coldstorage_dbname);
	$coldstorage_login = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$coldstorage_login);
	$coldstorage_pass = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$coldstorage_pass);
	$coldstorage_port = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$coldstorage_port);
	$survey_first_audio_file = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$survey_first_audio_file);
	$survey_opt_in_audio_file = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$survey_opt_in_audio_file);
	$survey_ni_audio_file = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$survey_ni_audio_file);
	$survey_third_audio_file = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$survey_third_audio_file);
	$survey_fourth_audio_file = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$survey_fourth_audio_file);
	$safe_harbor_audio_field = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$safe_harbor_audio_field);
	$voicemail_greeting = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$voicemail_greeting);
	$old_voicemail_greeting = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$old_voicemail_greeting);
	$meetme_enter_login_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$meetme_enter_login_filename);
	$meetme_enter_leave3way_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$meetme_enter_leave3way_filename);
	$nva_error_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$nva_error_filename);
	$inbound_survey_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$inbound_survey_filename);
	$inbound_survey_question_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$inbound_survey_question_filename);
	$closing_time_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$closing_time_filename);
	$closing_time_end_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$closing_time_end_filename);
	$dead_trigger_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$dead_trigger_filename);
	$cid_cb_valid_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$cid_cb_valid_filename);
	$cid_cb_confirmed_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$cid_cb_confirmed_filename);
	$cid_cb_enter_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$cid_cb_enter_filename);
	$cid_cb_you_entered_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$cid_cb_you_entered_filename);
	$cid_cb_press_to_confirm_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$cid_cb_press_to_confirm_filename);
	$cid_cb_invalid_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$cid_cb_invalid_filename);
	$cid_cb_reenter_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$cid_cb_reenter_filename);
	$cid_cb_error_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$cid_cb_error_filename);
	$place_in_line_caller_number_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$place_in_line_caller_number_filename);
	$place_in_line_you_next_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$place_in_line_you_next_filename);
	$audio_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$audio_filename);
	$agent_hangup_value = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$agent_hangup_value);
	$second_alert_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$second_alert_filename);
	$third_alert_filename = preg_replace('/[^-\/\|\._0-9a-zA-Z]/','',$third_alert_filename);

	### ALPHA-NUMERIC and underscore and dash and slash and dot and comma
	$menu_prompt = preg_replace('/[^-\/\|\,\._0-9a-zA-Z]/','',$menu_prompt);

	### ALPHA-NUMERIC and underscore and dash and comma
	$logins_list = preg_replace('/[^-\,\_0-9a-zA-Z]/','',$logins_list);
	$forced_timeclock_login = preg_replace('/[^-\,\_0-9a-zA-Z]/','',$forced_timeclock_login);
	$uniqueid_status_prefix = preg_replace('/[^-\,\_0-9a-zA-Z]/','',$uniqueid_status_prefix);

	### ALPHA-NUMERIC and spaces
	$lead_order = preg_replace('/[^ 0-9a-zA-Z]/','',$lead_order);
	### ALPHA-NUMERIC and spaces and dashes and underscores
	$preset_name = preg_replace('/[^- \_0-9a-zA-Z]/','',$preset_name);
	$selected_language = preg_replace('/[^- \_0-9a-zA-Z]/','',$selected_language);
	$default_language = preg_replace('/[^- \_0-9a-zA-Z]/','',$default_language);
	$opensips_cid_name = preg_replace('/[^- \_0-9a-zA-Z]/','',$opensips_cid_name);

	### ALPHA-NUMERIC and hash
	$group_color = preg_replace('/[^\#0-9a-zA-Z]/','',$group_color);
	$script_color = preg_replace('/[^\#0-9a-zA-Z]/','',$script_color);
	### ALPHA-NUMERIC and hash and star and dot and underscore
	$hold_time_option_exten = preg_replace('/[^\*\#\.\_0-9a-zA-Z]/','',$hold_time_option_exten);
	$voicemail_ext = preg_replace('/[^\*\#\.\_0-9a-zA-Z]/','',$voicemail_ext);
	$phone = preg_replace('/[^\*\#\.\_0-9a-zA-Z]/','',$phone);
	$phone_code = preg_replace('/[^\*\#\.\_0-9a-zA-Z]/','',$phone_code);
	$wait_time_option_exten = preg_replace('/[^\*\#\.\_0-9a-zA-Z]/','',$wait_time_option_exten);
	$filter_voicemail_ext = preg_replace('/[^\*\#\.\_0-9a-zA-Z]/','',$filter_voicemail_ext);
	$filter_phone_code = preg_replace('/[^\*\#\.\_0-9a-zA-Z]/','',$filter_phone_code);
	$filter_phone = preg_replace('/[^\*\#\.\_0-9a-zA-Z]/','',$filter_phone);
	$preset_number = preg_replace('/[^\*\#\.\_0-9a-zA-Z]/','',$preset_number);
	$no_agent_ingroup_extension = preg_replace('/[^\*\#\.\_0-9a-zA-Z]/','',$no_agent_ingroup_extension);
	$pre_filter_extension = preg_replace('/[^\*\#\.\_0-9a-zA-Z]/','',$pre_filter_extension);
	$max_queue_ingroup_extension = preg_replace('/[^\*\#\.\_0-9a-zA-Z]/','',$max_queue_ingroup_extension);
	$report_server = preg_replace('/[^\*\#\.\_0-9a-zA-Z]/','',$report_server);
	$dl_server = preg_replace('/[^\*\#\.\_0-9a-zA-Z]/','',$dl_server);

	### ALPHA-NUMERIC and hash and star and dot and underscore and colon and plus sign
	$did_pattern = preg_replace('/[^:\+\*\#\.\_0-9a-zA-Z]/','',$did_pattern);
	$web_loader_phone_strip = preg_replace('/[^:\+\*\#\.\_0-9a-zA-Z]/','',$web_loader_phone_strip);
	$manual_dial_phone_strip = preg_replace('/[^:\+\*\#\.\_0-9a-zA-Z]/','',$manual_dial_phone_strip);
	$mobile_number = preg_replace('/[^:\+\*\#\.\_0-9a-zA-Z]/','',$mobile_number);

	### ALPHA-NUMERIC and spaces dots, commas, dashes, underscores
	$adaptive_dl_diff_target = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$adaptive_dl_diff_target);
	$adaptive_intensity = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$adaptive_intensity);
	$asterisk_version = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$asterisk_version);
	$call_time_comments = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$call_time_comments);
	$call_time_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$call_time_name);
	$campaign_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$campaign_name);
	$campaign_rec_filename = preg_replace('/[^-\.\_0-9a-zA-Z]/','',$campaign_rec_filename);
	$ingroup_rec_filename = preg_replace('/[^-\.\_0-9a-zA-Z]/','',$ingroup_rec_filename);
	$company = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$company);
	$full_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$full_name);
	$fullname = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$fullname);
	$group_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$group_name);
	$HKstatus = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$HKstatus);
	$lead_filter_comments = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$lead_filter_comments);
	$lead_filter_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$lead_filter_name);
	$list_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$list_name);
	$local_gmt = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$local_gmt);
	$new_fullname = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$new_fullname);
	$phone_type = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$phone_type);
	$picture = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$picture);
	$script_comments = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$script_comments);
	$script_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$script_name);
	$server_description = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$server_description);
	$status = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$status);
	$status_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$status_name);
	$wrapup_message = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$wrapup_message);
	$pause_code_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$pause_code_name);
	$campaign_description = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$campaign_description);
	$list_description = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$list_description);
	$vcl_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$vcl_name);
	$vsc_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$vsc_name);
	$vsc_description = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$vsc_description);
	$code_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$code_name);
	$alias_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$alias_name);
	$shift_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$shift_name);
	$did_description = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$did_description);
	$template_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$template_name);
	$carrier_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$carrier_name);
	$group_alias_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$group_alias_name);
	$caller_id_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$caller_id_name);
	$user_code = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$user_code);
	$territory = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$territory);
	$tts_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$tts_name);
	$moh_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$moh_name);
	$timer_action_message = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$timer_action_message);
	$default_codecs = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$default_codecs);
	$codecs_list = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$codecs_list);
	$label_title = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_title);
	$label_first_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_first_name);
	$label_middle_initial = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_middle_initial);
	$label_last_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_last_name);
	$label_address1 = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_address1);
	$label_address2 = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_address2);
	$label_address3 = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_address3);
	$label_city = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_city);
	$label_state = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_state);
	$label_province = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_province);
	$label_postal_code = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_postal_code);
	$label_vendor_lead_code = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_vendor_lead_code);
	$label_gender = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_gender);
	$label_phone_number = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_phone_number);
	$label_phone_code = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_phone_code);
	$label_alt_phone = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_alt_phone);
	$label_security_phrase = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_security_phrase);
	$label_email = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_email);
	$label_comments = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_comments);
	$slave_db_server = preg_replace('/[^- \.\,\:\_0-9a-zA-Z]/','',$slave_db_server);
	$filter_phone_group_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$filter_phone_group_name);
	$filter_phone_group_description = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$filter_phone_group_description);
	$filter_clean_cid_number = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$filter_clean_cid_number);
	$label_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_name);
	$default_local_gmt = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$default_local_gmt);
	$cid_description = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$cid_description);
	$description = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$description);
	$first_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$first_name);
	$last_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$last_name);
	$bu_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$bu_name);
	$department = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$department);
	$group = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$group);
	$job_title = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$job_title);
	$location = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$location);
	$holiday_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$holiday_name);
	$holiday_comments = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$holiday_comments);
	$api_allowed_functions = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$api_allowed_functions);
	$agent_display_fields = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$agent_display_fields);
	$container_notes = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$container_notes);
	$did_carrier_description = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$did_carrier_description);
	$status_group_notes = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$status_group_notes);
	$colors_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$colors_name);
	$web_logo = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$web_logo);
	$user_nickname = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$user_nickname);
	$customer_chat_survey_text = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$customer_chat_survey_text);
	$agent_script = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$agent_script);
	$report_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$report_name);
	$dl_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$dl_name);
	$drop_status = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$drop_status);
	$ip_list_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$ip_list_name);
	$cid_group_notes = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$cid_group_notes);
	$populate_lead_vendor = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$populate_lead_vendor);
	$leave_vm_message_group_notes = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$leave_vm_message_group_notes);
	$audio_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$audio_name);
	$populate_lead_comments = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$populate_lead_comments);
	$label_lead_id = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_lead_id);
	$label_list_id = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_list_id);
	$label_entry_date = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_entry_date);
	$label_gmt_offset_now = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_gmt_offset_now);
	$label_source_id = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_source_id);
	$label_called_since_last_reset = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_called_since_last_reset);
	$label_status = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_status);
	$label_user = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_user);
	$label_date_of_birth = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_date_of_birth);
	$label_country_code = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_country_code);
	$label_last_local_call_time = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_last_local_call_time);
	$label_called_count = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_called_count);
	$label_rank = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_rank);
	$label_owner = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_owner);
	$label_entry_list_id = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$label_entry_list_id);
	$user_location = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$user_location);
	$queue_group_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$queue_group_name);
	$qc_scorecard_id = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$qc_scorecard_id);
	$city_rule = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$city_rule);
	$county_rule = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$county_rule);
	$ac_rule = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$ac_rule);
	$stereo_rec_filename = preg_replace('/[^-\.\_0-9a-zA-Z]/','',$stereo_rec_filename);
	$parallel_rec_co_filename = preg_replace('/[^-\.\_0-9a-zA-Z]/','',$parallel_rec_co_filename);
	$parallel_rec_cm_filename = preg_replace('/[^-\.\_0-9a-zA-Z]/','',$parallel_rec_cm_filename);
	$parallel_rec_fr_filename = preg_replace('/[^-\.\_0-9a-zA-Z]/','',$parallel_rec_fr_filename);

	### ALPHA-NUMERIC and underscore and dash and slash and at and dot
	$call_out_number_group = preg_replace('/[^-\.\:\/\@\_0-9a-zA-Z]/','',$call_out_number_group);
	$client_browser = preg_replace('/[^-\.\:\/\@\_0-9a-zA-Z]/','',$client_browser);
	$DBX_server = preg_replace('/[^-\.\:\/\@\_0-9a-zA-Z]/','',$DBX_server);
	$DBY_server = preg_replace('/[^-\.\:\/\@\_0-9a-zA-Z]/','',$DBY_server);
	$dtmf_send_extension = preg_replace('/[^-\.\:\/\@\_0-9a-zA-Z]/','',$dtmf_send_extension);
	$install_directory = preg_replace('/[^-\.\:\/\@\_0-9a-zA-Z]/','',$install_directory);
	$old_extension = preg_replace('/[^-\.\:\/\@\_0-9a-zA-Z]/','',$old_extension);
	$telnet_host = preg_replace('/[^-\.\:\/\@\_0-9a-zA-Z]/','',$telnet_host);
	$queuemetrics_dbname = preg_replace('/[^-\.\:\/\@\_0-9a-zA-Z]/','',$queuemetrics_dbname);
	$queuemetrics_login = preg_replace('/[^-\.\:\/\@\_0-9a-zA-Z]/','',$queuemetrics_login);
	$queuemetrics_pass = preg_replace('/[^-\.\:\/\@\_0-9a-zA-Z]/','',$queuemetrics_pass);
	$email = preg_replace('/[^-\.\:\/\@\_0-9a-zA-Z]/','',$email);
	$vtiger_dbname = preg_replace('/[^-\.\:\/\@\_0-9a-zA-Z]/','',$vtiger_dbname);
	$vtiger_login = preg_replace('/[^-\.\:\/\@\_0-9a-zA-Z]/','',$vtiger_login);
	$vtiger_pass = preg_replace('/[^-\.\:\/\@\_0-9a-zA-Z]/','',$vtiger_pass);
	$external_server_ip = preg_replace('/[^-\.\:\/\@\_0-9a-zA-Z]/','',$external_server_ip);
	$alt_server_ip = preg_replace('/[^-\.\:\/\@\_0-9a-zA-Z]/','',$alt_server_ip);
	$email_from = preg_replace('/[^-\.\:\/\@\_0-9a-zA-Z]/','',$email_from);
	$email_to = preg_replace('/[^-\.\:\/\@\_0-9a-zA-Z]/','',$email_to);
	$ftp_server = preg_replace('/[^-\.\:\/\@\_0-9a-zA-Z]/','',$ftp_server);
	$ftp_directory = preg_replace('/[^-\.\:\/\@\_0-9a-zA-Z]/','',$ftp_directory);

	### ALPHA-NUMERIC and underscore and dash and slash and at and dot and space
	$custom_one = preg_replace('/[^- \.\:\/\@\_0-9a-zA-Z]/','',$custom_one);
	$custom_two = preg_replace('/[^- \.\:\/\@\_0-9a-zA-Z]/','',$custom_two);
	$custom_three = preg_replace('/[^- \.\:\/\@\_0-9a-zA-Z]/','',$custom_three);
	$custom_four = preg_replace('/[^- \.\:\/\@\_0-9a-zA-Z]/','',$custom_four);
	$custom_five = preg_replace('/[^- \.\:\/\@\_0-9a-zA-Z]/','',$custom_five);
	$email_subject = preg_replace('/[^- \.\:\/\@\_0-9a-zA-Z]/','',$email_subject);

	### ALPHA-NUMERIC and underscore and dash and slash and at and dot and pound and star
	$extension = preg_replace('/[^-\*\#\.\:\/\@\_0-9a-zA-Z]/','',$extension);
	$new_extension = preg_replace('/[^-\*\#\.\:\/\@\_0-9a-zA-Z]/','',$new_extension);
	$timer_action_destination = preg_replace('/[^-\*\#\.\:\/\@\_0-9a-zA-Z]/','',$timer_action_destination);
	$filter_extension = preg_replace('/[^-\*\#\.\:\/\@\_0-9a-zA-Z]/','',$filter_extension);

	### ALPHA-NUMERIC and space and underscore and dash and slash and at and dot and pound and star and pipe and comma
	$ivr_park_call_agi = preg_replace('/[^- \*\#\.\,\:\/\|\@\_0-9a-zA-Z]/','',$ivr_park_call_agi);
	$source_phone = preg_replace('/[^- \*\#\.\,\:\/\|\@\_0-9a-zA-Z]/','',$source_phone);

	### ALPHA-NUMERIC and space and underscore and dash and slash and at and dot and pound and star and pipe and comma and equal
	$voicemail_options = preg_replace('/[^- \=\*\#\.\,\:\/\|\@\_0-9a-zA-Z]/','',$voicemail_options);

	### NUMERIC and comma and pipe
	$waitforsilence_options = preg_replace('/[^\|\,0-9a-zA-Z]/','',$waitforsilence_options);

	### value cleaning
	$no_agent_action_value = preg_replace('/[^-\/\|\_\#\*\,\.\_0-9a-zA-Z]/','',$no_agent_action_value);
	$areacode_filter_action_value = preg_replace('/[^-\/\|\_\#\*\,\.\_0-9a-zA-Z]/','',$areacode_filter_action_value);

	### ALPHA-NUMERIC and underscore and dash and slash and at and space and colon
	$vdc_header_date_format = preg_replace('/[^- \:\/\_0-9a-zA-Z]/','',$vdc_header_date_format);
	$vdc_customer_date_format = preg_replace('/[^- \:\/\_0-9a-zA-Z]/','',$vdc_customer_date_format);
	$menu_name = preg_replace('/[^- \:\/\_0-9a-zA-Z]/','',$menu_name);

	### ALPHA-NUMERIC and underscore and dash and at and space and parantheses
	$vdc_header_phone_format = preg_replace('/[^- \(\)\_0-9a-zA-Z]/', '',$vdc_header_phone_format);

	### ALPHA-NUMERIC and newlines
	$areacode_list = preg_replace('/[^\n0-9a-zA-Z]/', '',$areacode_list);

	### ALPHA-NUMERIC and newlines and period and colon
	$ip_address = preg_replace('/[^\n\.\:\0-9a-zA-Z]/', '',$ip_address);
	}
else
	{
	### ALPHA-NUMERIC ONLY ###
	$is_webphone = preg_replace('/[^-_0-9\p{L}]/u','',$is_webphone);
	$campaign_script = preg_replace('/[^0-9\p{L}]/u','',$campaign_script);
	$submit = preg_replace('/[^0-9\p{L}]/u','',$submit);
	$campaign_cid = preg_replace('/[^0-9\p{L}]/u','',$campaign_cid);
	$campaign_recording = preg_replace('/[^0-9\p{L}]/u','',$campaign_recording);
	$ADD = preg_replace('/[^0-9\p{L}]/u','',$ADD);
	$dial_prefix = preg_replace('/[^0-9\p{L}]/u','',$dial_prefix);
	$state_call_time_state = preg_replace('/[^0-9\p{L}]/u','',$state_call_time_state);
	$scheduled_callbacks = preg_replace('/[^0-9\p{L}]/u','',$scheduled_callbacks);
	$concurrent_transfers = preg_replace('/[^0-9\p{L}]/u','',$concurrent_transfers);
	$billable = preg_replace('/[^0-9\p{L}]/u','',$billable);
	$pause_code = preg_replace('/[^0-9\p{L}]/u','',$pause_code);
	$vicidial_recording_override = preg_replace('/[^0-9\p{L}]/u','',$vicidial_recording_override);
	$ingroup_recording_override = preg_replace('/[^0-9\p{L}]/u','',$ingroup_recording_override);
	$queuemetrics_log_id = preg_replace('/[^0-9\p{L}]/u','',$queuemetrics_log_id);
	$after_hours_exten = preg_replace('/[^0-9\p{L}]/u','',$after_hours_exten);
	$after_hours_voicemail = preg_replace('/[^0-9\p{L}]/u','',$after_hours_voicemail);
	$qc_script = preg_replace('/[^0-9\p{L}]/u','',$qc_script);
	$code = preg_replace('/[^0-9\p{L}]/u','',$code);
	$survey_no_response_action = preg_replace('/[^0-9\p{L}]/u','',$survey_no_response_action);
	$survey_ni_status = preg_replace('/[^0-9\p{L}]/u','',$survey_ni_status);
	$qc_get_record_launch = preg_replace('/[^0-9\p{L}]/u','',$qc_get_record_launch);
	$agent_pause_codes_active = preg_replace('/[^0-9\p{L}]/u','',$agent_pause_codes_active);
	$three_way_dial_prefix = preg_replace('/[^0-9\p{L}]/u','',$three_way_dial_prefix);
	$agent_shift_enforcement_override = preg_replace('/[^0-9\p{L}]/u','',$agent_shift_enforcement_override);
	$survey_third_status = preg_replace('/[^0-9\p{L}]/u','',$survey_third_status);
	$survey_fourth_status = preg_replace('/[^0-9\p{L}]/u','',$survey_fourth_status);
	$sounds_web_directory = preg_replace('/[^0-9\p{L}]/u','',$sounds_web_directory);
	$disable_alter_custphone = preg_replace('/[^0-9\p{L}]/u','',$disable_alter_custphone);
	$view_calls_in_queue = preg_replace('/[^0-9\p{L}]/u','',$view_calls_in_queue);
	$view_calls_in_queue_launch = preg_replace('/[^0-9\p{L}]/u','',$view_calls_in_queue_launch);
	$grab_calls_in_queue = preg_replace('/[^0-9\p{L}]/u','',$grab_calls_in_queue);
	$call_requeue_button = preg_replace('/[^0-9\p{L}]/u','',$call_requeue_button);
	$pause_after_each_call = preg_replace('/[^0-9\p{L}]/u','',$pause_after_each_call);
	$use_internal_dnc = preg_replace('/[^0-9\p{L}]/u','',$use_internal_dnc);
	$use_campaign_dnc = preg_replace('/[^0-9\p{L}]/u','',$use_campaign_dnc);
	$new_voicemail_id = preg_replace('/[^0-9\p{L}]/u','',$new_voicemail_id);
	$voicemail_id = preg_replace('/[^0-9a-zA-Z]/','',$voicemail_id);
	$status_id = preg_replace('/[^0-9\p{L}]/u','',$status_id);
	$agent_call_log_view = preg_replace('/[^0-9\p{L}]/u','',$agent_call_log_view);
	$agent_call_log_view_override = preg_replace('/[^0-9\p{L}]/u','',$agent_call_log_view_override);
	$queuemetrics_loginout = preg_replace('/[^0-9\p{L}]/u','',$queuemetrics_loginout);
	$queuemetrics_callstatus = preg_replace('/[^0-9\p{L}]/u','',$queuemetrics_callstatus);
	$hide_xfer_number_to_dial = preg_replace('/[^0-9\p{L}]/u','',$hide_xfer_number_to_dial);
	$manual_dial_prefix = preg_replace('/[^0-9\p{L}]/u','',$manual_dial_prefix);
	$customer_3way_hangup_logging = preg_replace('/[^0-9\p{L}]/u','',$customer_3way_hangup_logging);
	$customer_3way_hangup_action = preg_replace('/[^0-9\p{L}]/u','',$customer_3way_hangup_action);
	$queuemetrics_dispo_pause = preg_replace('/[^0-9\p{L}]/u','',$queuemetrics_dispo_pause);
	$per_call_notes = preg_replace('/[^0-9\p{L}]/u','',$per_call_notes);
	$my_callback_option = preg_replace('/[^0-9\p{L}]/u','',$my_callback_option);
	$auto_pause_precall_code = preg_replace('/[^0-9\p{L}]/u','',$auto_pause_precall_code);
	$disable_dispo_status = preg_replace('/[^0-9\p{L}]/u','',$disable_dispo_status);
	$action_xfer_cid = preg_replace('/[^0-9\p{L}]/u','',$action_xfer_cid);
	$callback_list_calltime = preg_replace('/[^0-9\p{L}]/u','',$callback_list_calltime);
	$pause_after_next_call = preg_replace('/[^0-9\p{L}]/u','',$pause_after_next_call);
	$owner_populate = preg_replace('/[^0-9\p{L}]/u','',$owner_populate);
	$dead_max_dispo = preg_replace('/[^0-9\p{L}]/u','',$dead_max_dispo);
	$dispo_max_dispo = preg_replace('/[^0-9\p{L}]/u','',$dispo_max_dispo);
	$wrapup_bypass = preg_replace('/[^0-9\p{L}]/u','',$wrapup_bypass);
	$wrapup_after_hotkey = preg_replace('/[^0-9\p{L}]/u','',$wrapup_after_hotkey);
	$show_previous_callback = preg_replace('/[^0-9\p{L}]/u','',$show_previous_callback);
	$clear_script = preg_replace('/[^0-9\p{L}]/u','',$clear_script);
	$allow_chats = preg_replace('/[^0-9\p{L}]/u','',$allow_chats);
	$allow_emails = preg_replace('/[^0-9\p{L}]/u','',$allow_emails);
	$status_display_ingroup = preg_replace('/[^0-9\p{L}]/u','',$status_display_ingroup);
	$populate_lead_ingroup = preg_replace('/[^0-9\p{L}]/u','',$populate_lead_ingroup);
	$nva_new_status = preg_replace('/[^0-9\p{L}]/u','',$nva_new_status);
	$report_default_format = preg_replace('/[^0-9\p{L}]/u','',$report_default_format);
	$menu_background = preg_replace('/[^0-9\p{L}]/u','',$menu_background);
	$frame_background = preg_replace('/[^0-9\p{L}]/u','',$frame_background);
	$std_row1_background = preg_replace('/[^0-9\p{L}]/u','',$std_row1_background);
	$std_row2_background = preg_replace('/[^0-9\p{L}]/u','',$std_row2_background);
	$std_row3_background = preg_replace('/[^0-9\p{L}]/u','',$std_row3_background);
	$std_row4_background = preg_replace('/[^0-9\p{L}]/u','',$std_row4_background);
	$std_row5_background = preg_replace('/[^0-9\p{L}]/u','',$std_row5_background);
	$alt_row1_background = preg_replace('/[^0-9\p{L}]/u','',$alt_row1_background);
	$alt_row2_background = preg_replace('/[^0-9\p{L}]/u','',$alt_row2_background);
	$alt_row3_background = preg_replace('/[^0-9\p{L}]/u','',$alt_row3_background);
	$button_color = preg_replace('/[^0-9\p{L}]/u','',$button_color);
	$dead_to_dispo = preg_replace('/[^0-9\p{L}]/u','',$dead_to_dispo);
	$routing_prefix = preg_replace('/[^0-9\p{L}]/u','',$routing_prefix);
	$inbound_survey = preg_replace('/[^0-9\p{L}]/u','',$inbound_survey);
	$pause_max_dispo = preg_replace('/[^0-9\p{L}]/u','',$pause_max_dispo);
	$areacode = preg_replace('/[^0-9\p{L}]/u','',$areacode);
	$require_mgr_approval = preg_replace('/[^0-9\p{L}]/u','',$require_mgr_approval);
	$mute_recordings = preg_replace('/[^0-9\p{L}]/u','',$mute_recordings);
	$leave_vm_no_dispo = preg_replace('/[^0-9\p{L}]/u','',$leave_vm_no_dispo);
	$amd_agent_route_options = preg_replace('/[^0-9\p{L}]/u','',$amd_agent_route_options);
	$did_pattern_filter = preg_replace('/[^0-9a-zA-Z]/','',$did_pattern_filter);

	### ALPHA-NUMERIC and spaces and hash and star and comma
	$xferconf_a_dtmf = preg_replace('/[^ \,\*\#0-9\p{L}]/u','',trim($xferconf_a_dtmf));
	$xferconf_b_dtmf = preg_replace('/[^ \,\*\#0-9\p{L}]/u','',trim($xferconf_b_dtmf));
	$xferconf_c_dtmf = preg_replace('/[^ \,\*\#0-9\p{L}]/u','',trim($xferconf_c_dtmf));
	$xferconf_d_dtmf = preg_replace('/[^ \,\*\#0-9\p{L}]/u','',trim($xferconf_d_dtmf));
	$xferconf_e_dtmf = preg_replace('/[^ \,\*\#0-9\p{L}]/u','',trim($xferconf_e_dtmf));
	$survey_third_digit = preg_replace('/[^ \,\*\#0-9\p{L}]/u','',$survey_third_digit);
	$survey_fourth_digit = preg_replace('/[^ \,\*\#0-9\p{L}]/u','',$survey_fourth_digit);
	$survey_third_exten = preg_replace('/[^ \,\*\#0-9\p{L}]/u','',$survey_third_exten);
	$survey_fourth_exten = preg_replace('/[^ \,\*\#0-9\p{L}]/u','',$survey_fourth_exten);
	$preset_dtmf = preg_replace('/[^ \,\*\#0-9\p{L}]/u','',$preset_dtmf);

	### ALPHA-NUMERIC and underscore and dash
	$agi_output = preg_replace('/[^-_0-9\p{L}]/u','',$agi_output);
	$ASTmgrSECRET = preg_replace('/[^-_0-9\p{L}]/u','',$ASTmgrSECRET);
	$ASTmgrUSERNAME = preg_replace('/[^-_0-9\p{L}]/u','',$ASTmgrUSERNAME);
	$ASTmgrUSERNAMElisten = preg_replace('/[^-_0-9\p{L}]/u','',$ASTmgrUSERNAMElisten);
	$ASTmgrUSERNAMEsend = preg_replace('/[^-_0-9\p{L}]/u','',$ASTmgrUSERNAMEsend);
	$ASTmgrUSERNAMEupdate = preg_replace('/[^-_0-9\p{L}]/u','',$ASTmgrUSERNAMEupdate);
	$call_time_id = preg_replace('/[^-_0-9\p{L}]/u','',$call_time_id);
	$campaign_id = preg_replace('/[^-_0-9\p{L}]/u','',$campaign_id);
	$CoNfIrM = preg_replace('/[^-_0-9\p{L}]/u','',$CoNfIrM);
	$DBX_database = preg_replace('/[^-_0-9\p{L}]/u','',$DBX_database);
	$DBX_pass = preg_replace('/[^-_0-9\p{L}]/u','',$DBX_pass);
	$DBX_user = preg_replace('/[^-_0-9\p{L}]/u','',$DBX_user);
	$DBY_database = preg_replace('/[^-_0-9\p{L}]/u','',$DBY_database);
	$DBY_pass = preg_replace('/[^-_0-9\p{L}]/u','',$DBY_pass);
	$DBY_user = preg_replace('/[^-_0-9\p{L}]/u','',$DBY_user);
	$dial_method = preg_replace('/[^-_0-9\p{L}]/u','',$dial_method);
	$dial_status_a = preg_replace('/[^-_0-9\p{L}]/u','',$dial_status_a);
	$dial_status_b = preg_replace('/[^-_0-9\p{L}]/u','',$dial_status_b);
	$dial_status_c = preg_replace('/[^-_0-9\p{L}]/u','',$dial_status_c);
	$dial_status_d = preg_replace('/[^-_0-9\p{L}]/u','',$dial_status_d);
	$dial_status_e = preg_replace('/[^-_0-9\p{L}]/u','',$dial_status_e);
	$ext_context = preg_replace('/[^-_0-9\p{L}]/u','',$ext_context);
	$group_id = preg_replace('/[^-_0-9\p{L}]/u','',$group_id);
	$lead_filter_id = preg_replace('/[^-_0-9\p{L}]/u','',$lead_filter_id);
	$local_call_time = preg_replace('/[^-_0-9\p{L}]/u','',$local_call_time);
	$login = preg_replace('/[^-_0-9\p{L}]/u','',$login);
	$login_campaign = preg_replace('/[^-_0-9\p{L}]/u','',$login_campaign);
	$login_pass = preg_replace('/[^-_0-9\p{L}]/u','',$login_pass);
	$login_user = preg_replace('/[^-_0-9\p{L}]/u','',$login_user);
	$new_login = preg_replace('/[^-_0-9\p{L}]/u','',$new_login);
	$new_pass = preg_replace('/[^-_0-9\p{L}]/u','',$new_pass);
	$next_agent_call = preg_replace('/[^-_0-9\p{L}]/u','',$next_agent_call);
	$old_campaign_id = preg_replace('/[^-_0-9\p{L}]/u','',$old_campaign_id);
	$old_server_id = preg_replace('/[^-_0-9\p{L}]/u','',$old_server_id);
	$OLDuser_group = preg_replace('/[^-_0-9\p{L}]/u','',$OLDuser_group);
	$park_file_name = preg_replace('/[^-_0-9\p{L}]/u','',$park_file_name);
	$pass = preg_replace('/[^-_0-9\p{L}]/u','',$pass);
	$phone_login = preg_replace('/[^-_0-9\p{L}]/u','',$phone_login);
	$phone_pass = preg_replace('/[^-_0-9\p{L}]/u','',$phone_pass);
	$PHP_AUTH_PW = preg_replace('/[^-_0-9\p{L}]/u','',$PHP_AUTH_PW);
	$PHP_AUTH_USER = preg_replace('/[^-_0-9\p{L}]/u','',$PHP_AUTH_USER);
	$protocol = preg_replace('/[^-_0-9\p{L}]/u','',$protocol);
	$server_id = preg_replace('/[^-_0-9\p{L}]/u','',$server_id);
	$stage = preg_replace('/[^-_0-9\p{L}]/u','',$stage);
	$state_rule = preg_replace('/[^-_0-9\p{L}]/u','',$state_rule);
	$holiday_rule = preg_replace('/[^-_0-9\p{L}]/u','',$holiday_rule);
	$trunk_restriction = preg_replace('/[^-_0-9\p{L}]/u','',$trunk_restriction);
	$user = preg_replace('/[^-_0-9\p{L}]/u','',$user);
	$user_group = preg_replace('/[^-_0-9\p{L}]/u','',$user_group);
	$VICIDIAL_park_on_filename = preg_replace('/[^-_0-9\p{L}]/u','',$VICIDIAL_park_on_filename);
	$auto_alt_dial = preg_replace('/[^-_0-9\p{L}]/u','',$auto_alt_dial);
	$dial_status = preg_replace('/[^-_0-9\p{L}]/u','',$dial_status);
	$queuemetrics_eq_prepend = preg_replace('/[^-_0-9\p{L}]/u','',$queuemetrics_eq_prepend);
	$vicidial_agent_disable = preg_replace('/[^-_0-9\p{L}]/u','',$vicidial_agent_disable);
	$alter_custdata_override = preg_replace('/[^-_0-9\p{L}]/u','',$alter_custdata_override);
	$list_order_mix = preg_replace('/[^-_0-9\p{L}]/u','',$list_order_mix);
	$vcl_id = preg_replace('/[^-_0-9\p{L}]/u','',$vcl_id);
	$mix_method = preg_replace('/[^-_0-9\p{L}]/u','',$mix_method);
	$category = preg_replace('/[^-_0-9\p{L}]/u','',$category);
	$vsc_id = preg_replace('/[^-_0-9\p{L}]/u','',$vsc_id);
	$moh_context = preg_replace('/[^-_0-9\p{L}]/u','',$moh_context);
	$source_campaign_id = preg_replace('/[^-_0-9\p{L}]/u','',$source_campaign_id);
	$source_user_id = preg_replace('/[^-_0-9\p{L}]/u','',$source_user_id);
	$source_group_id = preg_replace('/[^-_0-9\p{L}]/u','',$source_group_id);
	$default_xfer_group = preg_replace('/[^-_0-9\p{L}]/u','',$default_xfer_group);
	$drop_exten = preg_replace('/[^-_0-9\p{L}]/u','',$drop_exten);
	$safe_harbor_exten = preg_replace('/[^-_0-9\p{L}]/u','',$safe_harbor_exten);
	$drop_action = preg_replace('/[^-_0-9\p{L}]/u','',$drop_action);
	$drop_inbound_group = preg_replace('/[^-_0-9\p{L}]/u','',$drop_inbound_group);
	$afterhours_xfer_group = preg_replace('/[^-_0-9\p{L}]/u','',$afterhours_xfer_group);
	$after_hours_action = preg_replace('/[^-_0-9\p{L}]/u','',$after_hours_action);
	$alias_id = preg_replace('/[^-_0-9\p{L}]/u','',$alias_id);
	$shift_id = preg_replace('/[^-_0-9\p{L}]/u','',$shift_id);
	$qc_shift_id = preg_replace('/[^-_0-9\p{L}]/u','',$qc_shift_id);
	$survey_method = preg_replace('/[^-_0-9\p{L}]/u','',$survey_method);
	$alter_custphone_override = preg_replace('/[^-_0-9\p{L}]/u','',$alter_custphone_override);
	$manual_dial_filter = preg_replace('/[^-_0-9\p{L}]/u','',$manual_dial_filter);
	$manual_dial_search_filter = preg_replace('/[^-_0-9\p{L}]/u','',$manual_dial_search_filter);
	$agent_clipboard_copy = preg_replace('/[^-_0-9\p{L}]/u','',$agent_clipboard_copy);
	$hold_time_option = preg_replace('/[^-_0-9\p{L}]/u','',$hold_time_option);
	$hold_time_option_xfer_group = preg_replace('/[^-_0-9\p{L}]/u','',$hold_time_option_xfer_group);
	$hold_recall_xfer_group = preg_replace('/[^-_0-9\p{L}]/u','',$hold_recall_xfer_group);
	$play_welcome_message = preg_replace('/[^-_0-9\p{L}]/u','',$play_welcome_message);
	$did_route = preg_replace('/[^-_0-9\p{L}]/u','',$did_route);
	$user_unavailable_action = preg_replace('/[^-_0-9\p{L}]/u','',$user_unavailable_action);
	$user_route_settings_ingroup = preg_replace('/[^-_0-9\p{L}]/u','',$user_route_settings_ingroup);
	$call_handle_method = preg_replace('/[^-_0-9\p{L}]/u','',$call_handle_method);
	$agent_search_method = preg_replace('/[^-_0-9\p{L}]/u','',$agent_search_method);
	$hold_time_option_voicemail = preg_replace('/[^-_0-9\p{L}]/u','',$hold_time_option_voicemail);
	$exten_context = preg_replace('/[^-_0-9\p{L}]/u','',$exten_context);
	$three_way_call_cid = preg_replace('/[^-_0-9\p{L}]/u','',$three_way_call_cid);
	$web_form_target = preg_replace('/[^-_0-9\p{L}]/u','',$web_form_target);
	$recording_web_link = preg_replace('/[^-_0-9\p{L}]/u','',$recording_web_link);
	$vtiger_search_category = preg_replace('/[^-_0-9\p{L}]/u','',$vtiger_search_category);
	$vtiger_create_call_record = preg_replace('/[^-_0-9\p{L}]/u','',$vtiger_create_call_record);
	$vtiger_create_lead_record = preg_replace('/[^-_0-9\p{L}]/u','',$vtiger_create_lead_record);
	$vtiger_screen_login = preg_replace('/[^-_0-9\p{L}]/u','',$vtiger_screen_login);
	$cpd_amd_action = preg_replace('/[^-_0-9\p{L}]/u','',$cpd_amd_action);
	$cpd_unknown_action = preg_replace('/[^-_0-9\p{L}]/u','',$cpd_unknown_action);
	$template_id = preg_replace('/[^-_0-9\p{L}]/u','',$template_id);
	$carrier_id = preg_replace('/[^-_0-9\p{L}]/u','',$carrier_id);
	$source_carrier = preg_replace('/[^-_0-9\p{L}]/u','',$source_carrier);
	$group_alias_id = preg_replace('/[^-_0-9\p{L}]/u','',$group_alias_id);
	$default_group_alias = preg_replace('/[^-_0-9\p{L}]/u','',$default_group_alias);
	$vtiger_search_dead = preg_replace('/[^-_0-9\p{L}]/u','',$vtiger_search_dead);
	$menu_id = preg_replace('/[^-_0-9\p{L}]/u','',$menu_id);
	$source_menu = preg_replace('/[^-_0-9\p{L}]/u','',$source_menu);
	$call_time_id = preg_replace('/[^-_0-9\p{L}]/u','',$call_time_id);
	$phone_context = preg_replace('/[^-_0-9\p{L}]/u','',$phone_context);
	$new_conf_secret = preg_replace('/[^-_0-9\p{L}]/u','',$new_conf_secret);
	$conf_secret = preg_replace('/[^-_0-9\p{L}]/u','',$conf_secret);
	$tracking_group = preg_replace('/[^-_0-9\p{L}]/u','',$tracking_group);
	$no_agent_no_queue = preg_replace('/[^-_0-9\p{L}]/u','',$no_agent_no_queue);
	$no_agent_action = preg_replace('/[^-_0-9\p{L}]/u','',$no_agent_action);
	$quick_transfer_button = preg_replace('/[^-_0-9\p{L}]/u','',$quick_transfer_button);
	$prepopulate_transfer_preset = preg_replace('/[^-_0-9\p{L}]/u','',$prepopulate_transfer_preset);
	$tts_id = preg_replace('/[^-_0-9\p{L}]/u','',$tts_id);
	$drop_rate_group = preg_replace('/[^-_0-9\p{L}]/u','',$drop_rate_group);
	$agent_dial_owner_only = preg_replace('/[^-_0-9\p{L}]/u','',$agent_dial_owner_only);
	$reset_time = preg_replace('/[^-_0-9\p{L}]/u','',$reset_time);
	$moh_id = preg_replace('/[^-_0-9\p{L}]/u','',$moh_id);
	$mohsuggest = preg_replace('/[^-_0-9\p{L}]/u','',$mohsuggest);
	$drop_inbound_group_override = preg_replace('/[^-_0-9\p{L}]/u','',$drop_inbound_group_override);
	$timer_action = preg_replace('/[^-_0-9\p{L}]/u','',$timer_action);
	$record_call = preg_replace('/[^-_0-9\p{L}]/u','',$record_call);
	$scheduled_callbacks_alert = preg_replace('/[^-_0-9\p{L}]/u','',$scheduled_callbacks_alert);
	$extension_group_id = preg_replace('/[^-_0-9\p{L}]/u','',$extension_group_id);
	$extension_group = preg_replace('/[^-_0-9\p{L}]/u','',$extension_group);
	$scheduled_callbacks_count = preg_replace('/[^-_0-9\p{L}]/u','',$scheduled_callbacks_count);
	$manual_dial_override = preg_replace('/[^-_0-9\p{L}]/u','',$manual_dial_override);
	$blind_monitor_warning = preg_replace('/[^-_0-9\p{L}]/u','',$blind_monitor_warning);
	$uniqueid_status_display = preg_replace('/[^-_0-9\p{L}]/u','',$uniqueid_status_display);
	$hold_time_option_callmenu = preg_replace('/[^-_0-9\p{L}]/u','',$hold_time_option_callmenu);
	$inbound_queue_no_dial = preg_replace('/[^-_0-9\p{L}]/u','',$inbound_queue_no_dial);
	$hold_time_second_option = preg_replace('/[^-_0-9\p{L}]/u','',$hold_time_second_option);
	$hold_time_third_option = preg_replace('/[^-_0-9\p{L}]/u','',$hold_time_third_option);
	$wait_hold_option_priority = preg_replace('/[^-_0-9\p{L}]/u','',$wait_hold_option_priority);
	$wait_time_option = preg_replace('/[^-_0-9\p{L}]/u','',$wait_time_option);
	$wait_time_second_option = preg_replace('/[^-_0-9\p{L}]/u','',$wait_time_second_option);
	$wait_time_third_option = preg_replace('/[^-_0-9\p{L}]/u','',$wait_time_third_option);
	$wait_time_option_xfer_group = preg_replace('/[^-_0-9\p{L}]/u','',$wait_time_option_xfer_group);
	$wait_time_option_callmenu = preg_replace('/[^-_0-9\p{L}]/u','',$wait_time_option_callmenu);
	$wait_time_option_voicemail = preg_replace('/[^-_0-9\p{L}]/u','',$wait_time_option_voicemail);
	$filter_phone_group_id = preg_replace('/[^-_0-9\p{L}]/u','',$filter_phone_group_id);
	$filter_action = preg_replace('/[^-_0-9\p{L}]/u','',$filter_action);
	$filter_user_unavailable_action = preg_replace('/[^-_0-9\p{L}]/u','',$filter_user_unavailable_action);
	$filter_user_route_settings_ingroup = preg_replace('/[^-_0-9\p{L}]/u','',$filter_user_route_settings_ingroup);
	$filter_agent_search_method = preg_replace('/[^-_0-9\p{L}]/u','',$filter_agent_search_method);
	$filter_campaign_id = preg_replace('/[^-_0-9\p{L}]/u','',$filter_campaign_id);
	$filter_group_id = preg_replace('/[^-_0-9\p{L}]/u','',$filter_group_id);
	$filter_menu_id = preg_replace('/[^-_0-9\p{L}]/u','',$filter_menu_id);
	$filter_call_handle_method = preg_replace('/[^-_0-9\p{L}]/u','',$filter_call_handle_method);
	$filter_user = preg_replace('/[^-_0-9\p{L}]/u','',$filter_user);
	$filter_exten_context = preg_replace('/[^-_0-9\p{L}]/u','',$filter_exten_context);
	$webphone_systemkey = preg_replace('/[^-_0-9\p{L}]/u','',$webphone_systemkey);
	$webphone_dialpad = preg_replace('/[^-_0-9\p{L}]/u','',$webphone_dialpad);
	$webphone_systemkey_override = preg_replace('/[^-_0-9\p{L}]/u','',$webphone_systemkey_override);
	$webphone_dialpad_override = preg_replace('/[^-_0-9\p{L}]/u','',$webphone_dialpad_override);
	$default_phone_registration_password = preg_replace('/[^-_0-9\p{L}]/u','',$default_phone_registration_password);
	$default_phone_login_password = preg_replace('/[^-_0-9\p{L}]/u','',$default_phone_login_password);
	$default_server_password = preg_replace('/[^-_0-9\p{L}]/u','',$default_server_password);
	$ivr_park_call = preg_replace('/[^-_0-9\p{L}]/u','',$ivr_park_call);
	$manual_preview_dial = preg_replace('/[^-_0-9\p{L}]/u','',$manual_preview_dial);
	$realtime_agent_time_stats = preg_replace('/[^-_0-9\p{L}]/u','',$realtime_agent_time_stats);
	$api_manual_dial = preg_replace('/[^-_0-9\p{L}]/u','',$api_manual_dial);
	$manual_dial_call_time_check = preg_replace('/[^-_0-9\p{L}]/u','',$manual_dial_call_time_check);
	$lead_order_secondary = preg_replace('/[^-_0-9\p{L}]/u','',$lead_order_secondary);
	$agent_lead_search = preg_replace('/[^-_0-9\p{L}]/u','',$agent_lead_search);
	$agent_lead_search_method = preg_replace('/[^-_0-9\p{L}]/u','',$agent_lead_search_method);
	$manual_dial_cid = preg_replace('/[^-_0-9\p{L}]/u','',$manual_dial_cid);
	$post_phone_time_diff_alert = preg_replace('/[^-_0-9\p{L}]/u','',$post_phone_time_diff_alert);
	$custom_3way_button_transfer = preg_replace('/[^-_0-9\p{L}]/u','',$custom_3way_button_transfer);
	$available_only_tally_threshold_agents = preg_replace('/[^-_0-9\p{L}]/u','',$available_only_tally_threshold_agents);
	$dial_level_threshold_agents = preg_replace('/[^-_0-9\p{L}]/u','',$dial_level_threshold_agents);
	$time_zone_setting = preg_replace('/[^-_0-9\p{L}]/u','',$time_zone_setting);
	$safe_harbor_menu_id = preg_replace('/[^-_0-9\p{L}]/u','',$safe_harbor_menu_id);
	$survey_menu_id = preg_replace('/[^-_0-9\p{L}]/u','',$survey_menu_id);
	$dl_diff_target_method = preg_replace('/[^-_0-9\p{L}]/u','',$dl_diff_target_method);
	$disable_dispo_screen = preg_replace('/[^-_0-9\p{L}]/u','',$disable_dispo_screen);
	$screen_labels = preg_replace('/[^-_0-9\p{L}]/u','',$screen_labels);
	$label_hide_field_logs = preg_replace('/[^-_0-9\p{L}]/u','',$label_hide_field_logs);
	$label_id = preg_replace('/[^-_0-9\p{L}]/u','',$label_id);
	$status_display_fields = preg_replace('/[^-_0-9\p{L}]/u','',$status_display_fields);
	$voicemail_timezone = preg_replace('/[^-_0-9\p{L}]/u','',$voicemail_timezone);
	$default_voicemail_timezone = preg_replace('/[^-_0-9\p{L}]/u','',$default_voicemail_timezone);
	$on_hook_cid = preg_replace('/[^-_0-9\p{L}]/u','',$on_hook_cid);
	$pllb_grouping = preg_replace('/[^-_0-9\p{L}]/u','',$pllb_grouping);
	$user_start = preg_replace('/[^-_0-9\p{L}]/u','',$user_start);
	$drop_callmenu = preg_replace('/[^-_0-9\p{L}]/u','',$drop_callmenu);
	$after_hours_callmenu = preg_replace('/[^-_0-9\p{L}]/u','',$after_hours_callmenu);
	$survey_recording = preg_replace('/[^-_0-9\p{L}]/u','',$survey_recording);
	$dtmf_field = preg_replace('/[^-_0-9\p{L}]/u','',$dtmf_field);
	$preset_contact_search = preg_replace('/[^-_0-9\p{L}]/u','',$preset_contact_search);
	$admin_hide_phone_data = preg_replace('/[^-_0-9\p{L}]/u','',$admin_hide_phone_data);
	$max_calls_method = preg_replace('/[^-_0-9\p{L}]/u','',$max_calls_method);
	$max_calls_action = preg_replace('/[^-_0-9\p{L}]/u','',$max_calls_action);
	$in_group_dial = preg_replace('/[^-_0-9\p{L}]/u','',$in_group_dial);
	$in_group_dial_select = preg_replace('/[^-_0-9\p{L}]/u','',$in_group_dial_select);
	$queuemetrics_socket = preg_replace('/[^-_0-9\p{L}]/u','',$queuemetrics_socket);
	$holiday_id = preg_replace('/[^-_0-9\p{L}]/u','',$holiday_id);
	$holiday_date = preg_replace('/[^-_0-9\p{L}]/u','',$holiday_date);
	$holiday_status = preg_replace('/[^-_0-9\p{L}]/u','',$holiday_status);
	$expiration_date = preg_replace('/[^-_0-9\p{L}]/u','',$expiration_date);
	$amd_inbound_group = preg_replace('/[^-_0-9\p{L}]/u','',$amd_inbound_group);
	$amd_callmenu = preg_replace('/[^-_0-9\p{L}]/u','',$amd_callmenu);
	$filter_inbound_number = preg_replace('/[^-_0-9\p{L}]/u','',$filter_inbound_number);
	$filter_dnc_campaign = preg_replace('/[^-_0-9\p{L}]/u','',$filter_dnc_campaign);
	$manual_dial_search_checkbox = preg_replace('/[^-_0-9\p{L}]/u','',$manual_dial_search_checkbox);
	$alt_number_dialing = preg_replace('/[^-_0-9\p{L}]/u','',$alt_number_dialing);
	$no_agent_ingroup_redirect = preg_replace('/[^-_0-9\p{L}]/u','',$no_agent_ingroup_redirect);
	$no_agent_ingroup_id = preg_replace('/[^-_0-9\p{L}]/u','',$no_agent_ingroup_id);
	$pre_filter_phone_group_id = preg_replace('/[^-_0-9\p{L}]/u','',$pre_filter_phone_group_id);
	$shift_enforcement = preg_replace('/[^-_0-9\p{L}]/u','',$shift_enforcement);
	$comments_all_tabs = preg_replace('/[^-_0-9\p{L}]/u','',$comments_all_tabs);
	$comments_dispo_screen = preg_replace('/[^-_0-9\p{L}]/u','',$comments_dispo_screen);
	$comments_callback_screen = preg_replace('/[^-_0-9\p{L}]/u','',$comments_callback_screen);
	$qc_comment_history = preg_replace('/[^-_0-9\p{L}]/u','',$qc_comment_history);
	$language_method = preg_replace('/[^-_0-9\p{L}]/u','',$language_method);
	$manual_dial_override_field = preg_replace('/[^-_0-9\p{L}]/u','',$manual_dial_override_field);
	$max_queue_ingroup_id = preg_replace('/[^-_0-9\p{L}]/u','',$max_queue_ingroup_id);
	$agent_debug_logging = preg_replace('/[^-_0-9\p{L}]/u','',$agent_debug_logging);
	$container_id = preg_replace('/[^-_0-9\p{L}]/u','',$container_id);
	$phone_defaults_container = preg_replace('/[^-_0-9\p{L}]/u','',$phone_defaults_container);
	$container_type = preg_replace('/[^-_0-9\p{L}]/u','',$container_type);
	$status_group_id = preg_replace('/[^-_0-9\p{L}]/u','',$status_group_id);
	$unavail_dialplan_fwd_exten = preg_replace('/[^-_0-9\p{L}]/u','',$unavail_dialplan_fwd_exten);
	$unavail_dialplan_fwd_context = preg_replace('/[^-_0-9\p{L}]/u','',$unavail_dialplan_fwd_context);
	$nva_search_method = preg_replace('/[^-_0-9\p{L}]/u','',$nva_search_method);
	$on_hook_cid_number = preg_replace('/[^-_0-9\p{L}]/u','',$on_hook_cid_number);
	$colors_id = preg_replace('/[^-_0-9\p{L}]/u','',$colors_id);
	$agent_screen_colors = preg_replace('/[^-_0-9\p{L}]/u','',$agent_screen_colors);
	$customer_chat_screen_colors = preg_replace('/[^-_0-9\p{L}]/u','',$customer_chat_screen_colors);
	$web_loader_phone_length = preg_replace('/[^-_0-9\p{L}]/u','',$web_loader_phone_length);
	$agent_chat_screen_colors = preg_replace('/[^-_0-9\p{L}]/u','',$agent_chat_screen_colors);
	$populate_lead_province = preg_replace('/[^-_0-9\p{L}]/u','',$populate_lead_province);
	$populate_lead_owner = preg_replace('/[^-_0-9\p{L}]/u','',$populate_lead_owner);
	$areacode_filter = preg_replace('/[^-_0-9\p{L}]/u','',$areacode_filter);
	$areacode_filter_action = preg_replace('/[^-_0-9\p{L}]/u','',$areacode_filter_action);
	$report_id = preg_replace('/[^-_0-9\p{L}]/u','',$report_id);
	$report_destination = preg_replace('/[^-_0-9\p{L}]/u','',$report_destination);
	$report_times = preg_replace('/[^-_0-9\p{L}]/u','',$report_times);
	$report_monthdays = preg_replace('/[^-_0-9\p{L}]/u','',$report_monthdays);
	$populate_state_areacode = preg_replace('/[^-_0-9\p{L}]/u','',$populate_state_areacode);
	$dl_id = preg_replace('/[^-_0-9\p{L}]/u','',$dl_id);
	$duplicate_check = preg_replace('/[^-_0-9\p{L}]/u','',$duplicate_check);
	$dl_times = preg_replace('/[^-_0-9\p{L}]/u','',$dl_times);
	$dl_monthdays = preg_replace('/[^-_0-9\p{L}]/u','',$dl_monthdays);
	$use_custom_cid = preg_replace('/[^-_0-9\p{L}]/u','',$use_custom_cid);
	$system_ip_blacklist = preg_replace('/[^-_0-9\p{L}]/u','',$system_ip_blacklist);
	$admin_ip_list = preg_replace('/[^-_0-9\p{L}]/u','',$admin_ip_list);
	$agent_ip_list = preg_replace('/[^-_0-9\p{L}]/u','',$agent_ip_list);
	$api_ip_list = preg_replace('/[^-_0-9\p{L}]/u','',$api_ip_list);
	$ip_list_id = preg_replace('/[^-_0-9\p{L}]/u','',$ip_list_id);
	$inbound_survey_callmenu = preg_replace('/[^-_0-9\p{L}]/u','',$inbound_survey_callmenu);
	$filename_override = preg_replace('/[^-_0-9\p{L}]/u','',$filename_override);
	$did_id = preg_replace('/[^-_0-9\p{L}]/u','',$did_id);
	$extension_appended_cidname = preg_replace('/[^-_0-9\p{L}]/u','',$extension_appended_cidname);
	$max_inbound_calls_outcome = preg_replace('/[^-_0-9\p{L}]/u','',$max_inbound_calls_outcome);
	$manual_auto_next_options = preg_replace('/[^-_0-9\p{L}]/u','',$manual_auto_next_options);
	$agent_screen_time_display = preg_replace('/[^-_0-9\p{L}]/u','',$agent_screen_time_display);
	$get_call_launch = preg_replace('/[^-_0-9\p{L}]/u','',$get_call_launch);
	$next_dial_my_callbacks = preg_replace('/[^-_0-9\p{L}]/u','',$next_dial_my_callbacks);
	$anyone_callback_inactive_lists = preg_replace('/[^-_0-9\p{L}]/u','',$anyone_callback_inactive_lists);
	$inbound_no_agents_no_dial_container = preg_replace('/[^-_0-9\p{L}]/u','',$inbound_no_agents_no_dial_container);
	$closing_time_action = preg_replace('/[^-_0-9\p{L}]/u','',$closing_time_action);
	$closing_time_option_exten = preg_replace('/[^-_0-9\p{L}]/u','',$closing_time_option_exten);
	$closing_time_option_callmenu = preg_replace('/[^-_0-9\p{L}]/u','',$closing_time_option_callmenu);
	$closing_time_option_voicemail = preg_replace('/[^-_0-9\p{L}]/u','',$closing_time_option_voicemail);
	$closing_time_option_callback_list_id = preg_replace('/[^-_0-9\p{L}]/u','',$closing_time_option_callback_list_id);
	$icbq_call_time_id = preg_replace('/[^-_0-9\p{L}]/u','',$icbq_call_time_id);
	$add_lead_timezone = preg_replace('/[^-_0-9\p{L}]/u','',$add_lead_timezone);
	$icbq_dial_filter = preg_replace('/[^-_0-9\p{L}]/u','',$icbq_dial_filter);
	$cid_group_id = preg_replace('/[^-_0-9\p{L}]/u','',$cid_group_id);
	$cid_group_id_two = preg_replace('/[^-_0-9\p{L}]/u','',$cid_group_id_two);
	$cid_group_type = preg_replace('/[^-_0-9\p{L}]/u','',$cid_group_type);
	$populate_lead_source = preg_replace('/[^-_0-9\p{L}]/u','',$populate_lead_source);
	$dead_trigger_action = preg_replace('/[^-_0-9\p{L}]/u','',$dead_trigger_action);
	$dead_trigger_repeat = preg_replace('/[^-_0-9\p{L}]/u','',$dead_trigger_repeat);
	$cid_cb_confirm_number = preg_replace('/[^-_0-9\p{L}]/u','',$cid_cb_confirm_number);
	$cid_cb_invalid_filter_phone_group = preg_replace('/[^-_0-9\p{L}]/u','',$cid_cb_invalid_filter_phone_group);
	$scheduled_callbacks_auto_reschedule = preg_replace('/[^-_0-9\p{L}]/u','',$scheduled_callbacks_auto_reschedule);
	$scheduled_callbacks_timezones_container = preg_replace('/[^-_0-9\p{L}]/u','',$scheduled_callbacks_timezones_container);
	$three_way_volume_buttons = preg_replace('/[^-_0-9\p{L}]/u','',$three_way_volume_buttons);
	$callback_dnc = preg_replace('/[^-_0-9\p{L}]/u','',$callback_dnc);
	$hide_call_log_info = preg_replace('/[^-_0-9\p{L}]/u','',$hide_call_log_info);
	$call_quota_lead_ranking = preg_replace('/[^-_0-9\p{L}]/u','',$call_quota_lead_ranking);
	$sip_event_logging = preg_replace('/[^-_0-9\p{L}]/u','',$sip_event_logging);
	$auto_active_list_new = preg_replace('/[^-_0-9\p{L}]/u','',$auto_active_list_new);
	$script_id = preg_replace('/[^-_0-9\p{L}]/u','',$script_id);
	$ingroup_script = preg_replace('/[^-_0-9\p{L}]/u','',$ingroup_script);
	$ingroup_script_two = preg_replace('/[^-_0-9\p{L}]/u','',$ingroup_script_two);
	$campaign_script = preg_replace('/[^-_0-9\p{L}]/u','',$campaign_script);
	$campaign_script_two = preg_replace('/[^-_0-9\p{L}]/u','',$campaign_script_two);
	$leave_vm_message_group_id = preg_replace('/[^-_0-9\p{L}]/u','',$leave_vm_message_group_id);
	$dial_timeout_lead_container = preg_replace('/[^-_0-9\p{L}]/u','',$dial_timeout_lead_container);
	$amd_type = preg_replace('/[^-_0-9\p{L}]/u','',$amd_type);
	$recording_buttons = preg_replace('/[^-_0-9\p{L}]/u','',$recording_buttons);
	$use_other_campaign_dnc = preg_replace('/[^-_0-9\p{L}]/u','',$use_other_campaign_dnc);
	$browser_alert_sound = preg_replace('/[^-_0-9\p{L}]/u','',$browser_alert_sound);
	$three_way_record_stop_exception = preg_replace('/[^-_0-9\p{L}]/u','',$three_way_record_stop_exception);
	$queuemetrics_pausereason = preg_replace('/[^-_0-9\p{L}]/u','',$queuemetrics_pausereason);
	$answer_signal = preg_replace('/[^-_0-9\p{L}]/u','',$answer_signal);
	$inbound_drop_voicemail = preg_replace('/[^-_0-9\p{L}]/u','',$inbound_drop_voicemail);
	$inbound_after_hours_voicemail = preg_replace('/[^-_0-9\p{L}]/u','',$inbound_after_hours_voicemail);
	$pause_max_exceptions = preg_replace('/[^-_0-9\p{L}]/u','',$pause_max_exceptions);
	$two_factor_container = preg_replace('/[^-_0-9\p{L}]/u','',$two_factor_container);
	$calls_inqueue_count_one = preg_replace('/[^-_0-9\p{L}]/u','',$calls_inqueue_count_one);
	$calls_inqueue_count_two = preg_replace('/[^-_0-9\p{L}]/u','',$calls_inqueue_count_two);
	$drop_call_seconds_override = preg_replace('/[^-_0-9\p{L}]/u','',$drop_call_seconds_override);
	$in_man_dial_next_ready_seconds_override = preg_replace('/[^-_0-9\p{L}]/u','',$in_man_dial_next_ready_seconds_override);
	$call_limit_24hour_method = preg_replace('/[^-_0-9\p{L}]/u','',$call_limit_24hour_method);
	$call_limit_24hour_scope = preg_replace('/[^-_0-9\p{L}]/u','',$call_limit_24hour_scope);
	$call_limit_24hour_override = preg_replace('/[^-_0-9\p{L}]/u','',$call_limit_24hour_override);
	$in_queue_nanque_exceptions = preg_replace('/[^-_0-9\p{L}]/u','',$in_queue_nanque_exceptions);
	$queue_group = preg_replace('/[^-_0-9\p{L}]/u','',$queue_group);
	$pre_filter_recent_call = preg_replace('/[^-_0-9\p{L}]/u','',$pre_filter_recent_call);
	$pre_filter_recent_extension = preg_replace('/[^-_0-9\p{L}]/u','',$pre_filter_recent_extension);
	$agent_script_override = preg_replace('/[^-_0-9\p{L}]/u','',$agent_script_override);
	$inbound_list_script_override = preg_replace('/[^-_0-9\p{L}]/u','',$inbound_list_script_override);
	$user_group_two = preg_replace('/[^-_0-9\p{L}]/u','',$user_group_two);
	$agent_hangup_route = preg_replace('/[^-_0-9\p{L}]/u','',$agent_hangup_route);
	$show_confetti = preg_replace('/[^-_0-9\p{L}]/u','',$show_confetti);
	$webphone_settings = preg_replace('/[^-_0-9\p{L}]/u','',$webphone_settings);
	$demographic_quotas = preg_replace('/[^-_0-9\p{L}]/u','',$demographic_quotas);
	$demographic_quotas_container = preg_replace('/[^-_0-9\p{L}]/u','',$demographic_quotas_container);
	$weekday_resets_container = preg_replace('/[^-_0-9\p{L}]/u','',$weekday_resets_container);
	$second_alert_container = preg_replace('/[^-_0-9\p{L}]/u','',$second_alert_container);
	$second_alert_only = preg_replace('/[^-_0-9\p{L}]/u','',$second_alert_only);
	$third_alert_container = preg_replace('/[^-_0-9\p{L}]/u','',$third_alert_container);
	$third_alert_only = preg_replace('/[^-_0-9\p{L}]/u','',$third_alert_only);
	$state_descriptions = preg_replace('/[^-_0-9\p{L}]/u','',$state_descriptions);
	$khomp_settings_container = preg_replace('/[^-_0-9\p{L}]/u','',$khomp_settings_container);
	$agent_man_dial_filter = preg_replace('/[^-_0-9\p{L}]/u','',$agent_man_dial_filter);
	$agent_3way_dial_filter = preg_replace('/[^-_0-9\p{L}]/u','',$agent_3way_dial_filter);

	### ALPHA-NUMERIC and underscore and dash and slash and dot
	$menu_timeout_prompt = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$menu_timeout_prompt);
	$menu_invalid_prompt = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$menu_invalid_prompt);
	$after_hours_message_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$after_hours_message_filename);
	$welcome_message_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$welcome_message_filename);
	$onhold_prompt_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$onhold_prompt_filename);
	$hold_time_option_callback_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$hold_time_option_callback_filename);
	$agent_alert_exten = preg_replace('/[^-\|\/\._0-9\p{L}]/u','',$agent_alert_exten);
	$filename = preg_replace('/[^-\/\._0-9\p{L}]/u','',$filename);
	$am_message_exten = preg_replace('/[^-\|\/\._0-9\p{L}]/u','',$am_message_exten);
	$am_message_exten_override = preg_replace('/[^-\|\/\._0-9\p{L}]/u','',$am_message_exten_override);
	$campaign_groups = preg_replace('/[^-\|\/\._0-9\p{L}]/u','',$campaign_groups);
	$blind_monitor_filename = preg_replace('/[^-\|\/\._0-9\p{L}]/u','',$blind_monitor_filename);
	$hold_time_option_press_filename = preg_replace('/[^-\|\/\._0-9\p{L}]/u','',$hold_time_option_press_filename);
	$default_afterhours_filename_override = preg_replace('/[^-\|\/\._0-9\p{L}]/u','',$default_afterhours_filename_override);
	$sunday_afterhours_filename_override = preg_replace('/[^-\|\/\._0-9\p{L}]/u','',$sunday_afterhours_filename_override);
	$monday_afterhours_filename_override = preg_replace('/[^-\|\/\._0-9\p{L}]/u','',$monday_afterhours_filename_override);
	$tuesday_afterhours_filename_override = preg_replace('/[^-\|\/\._0-9\p{L}]/u','',$tuesday_afterhours_filename_override);
	$wednesday_afterhours_filename_override = preg_replace('/[^-\|\/\._0-9\p{L}]/u','',$wednesday_afterhours_filename_override);
	$thursday_afterhours_filename_override = preg_replace('/[^-\|\/\._0-9\p{L}]/u','',$thursday_afterhours_filename_override);
	$friday_afterhours_filename_override = preg_replace('/[^-\|\/\._0-9\p{L}]/u','',$friday_afterhours_filename_override);
	$saturday_afterhours_filename_override = preg_replace('/[^-\|\/\._0-9\p{L}]/u','',$saturday_afterhours_filename_override);
	$admin_web_directory = preg_replace('/[^-\|\/\._0-9\p{L}]/u','',$admin_web_directory);
	$tts_voice = preg_replace('/[^-\|\/\._0-9\p{L}]/u','',$tts_voice);
	$wait_time_option_callback_filename = preg_replace('/[^-\|\/\._0-9\p{L}]/u','',$wait_time_option_callback_filename);
	$wait_time_option_press_filename = preg_replace('/[^-\|\/\._0-9\p{L}]/u','',$wait_time_option_press_filename);
	$eht_minimum_prompt_filename = preg_replace('/[^-\|\/\._0-9\p{L}]/u','',$eht_minimum_prompt_filename);
	$queuemetrics_phone_environment = preg_replace('/[^-\|\/\._0-9\p{L}]/u','',$queuemetrics_phone_environment);
	$active_twin_server_ip = preg_replace('/[^-\|\/\._0-9\p{L}]/u','',$active_twin_server_ip);
	$safe_harbor_audio = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$safe_harbor_audio);
	$alt_log_server_ip = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$alt_log_server_ip);
	$alt_log_dbname = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$alt_log_dbname);
	$alt_log_login = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$alt_log_login);
	$alt_log_pass = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$alt_log_pass);
	$coldstorage_server_ip = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$coldstorage_server_ip);
	$coldstorage_dbname = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$coldstorage_dbname);
	$coldstorage_login = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$coldstorage_login);
	$coldstorage_pass = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$coldstorage_pass);
	$coldstorage_port = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$coldstorage_port);
	$survey_first_audio_file = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$survey_first_audio_file);
	$survey_opt_in_audio_file = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$survey_opt_in_audio_file);
	$survey_ni_audio_file = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$survey_ni_audio_file);
	$survey_third_audio_file = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$survey_third_audio_file);
	$survey_fourth_audio_file = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$survey_fourth_audio_file);
	$safe_harbor_audio_field = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$safe_harbor_audio_field);
	$voicemail_greeting = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$voicemail_greeting);
	$old_voicemail_greeting = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$old_voicemail_greeting);
	$meetme_enter_login_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$meetme_enter_login_filename);
	$meetme_enter_leave3way_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$meetme_enter_leave3way_filename);
	$nva_error_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$nva_error_filename);
	$inbound_survey_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$inbound_survey_filename);
	$inbound_survey_question_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$inbound_survey_question_filename);
	$closing_time_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$closing_time_filename);
	$closing_time_end_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$closing_time_end_filename);
	$dead_trigger_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$dead_trigger_filename);
	$cid_cb_valid_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$cid_cb_valid_filename);
	$cid_cb_confirmed_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$cid_cb_confirmed_filename);
	$cid_cb_enter_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$cid_cb_enter_filename);
	$cid_cb_you_entered_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$cid_cb_you_entered_filename);
	$cid_cb_press_to_confirm_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$cid_cb_press_to_confirm_filename);
	$cid_cb_invalid_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$cid_cb_invalid_filename);
	$cid_cb_reenter_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$cid_cb_reenter_filename);
	$cid_cb_error_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$cid_cb_error_filename);
	$place_in_line_caller_number_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$place_in_line_caller_number_filename);
	$place_in_line_you_next_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$place_in_line_you_next_filename);
	$audio_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$audio_filename);
	$agent_hangup_value = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$agent_hangup_value);
	$second_alert_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$second_alert_filename);
	$third_alert_filename = preg_replace('/[^-\/\|\._0-9\p{L}]/u','',$third_alert_filename);

	### ALPHA-NUMERIC and underscore and dash and slash and dot and comma
	$menu_prompt = preg_replace('/[^-\/\|\,\._0-9\p{L}]/u','',$menu_prompt);

	### ALPHA-NUMERIC and underscore and dash and comma
	$logins_list = preg_replace('/[^-\,\_0-9\p{L}]/u','',$logins_list);
	$forced_timeclock_login = preg_replace('/[^-\,\_0-9\p{L}]/u','',$forced_timeclock_login);
	$uniqueid_status_prefix = preg_replace('/[^-\,\_0-9\p{L}]/u','',$uniqueid_status_prefix);

	### ALPHA-NUMERIC and spaces
	$lead_order = preg_replace('/[^ 0-9\p{L}]/u','',$lead_order);
	### ALPHA-NUMERIC and spaces and dashes and underscores
	$preset_name = preg_replace('/[^- \_0-9\p{L}]/u','',$preset_name);
	$selected_language = preg_replace('/[^- \_0-9\p{L}]/u','',$selected_language);
	$default_language = preg_replace('/[^- \_0-9\p{L}]/u','',$default_language);
	$opensips_cid_name = preg_replace('/[^- \_0-9\p{L}]/u','',$opensips_cid_name);

	### ALPHA-NUMERIC and hash
	$group_color = preg_replace('/[^\#0-9\p{L}]/u','',$group_color);
	$script_color = preg_replace('/[^\#0-9\p{L}]/u','',$script_color);
	### ALPHA-NUMERIC and hash and star and dot and underscore
	$hold_time_option_exten = preg_replace('/[^\*\#\.\_0-9\p{L}]/u','',$hold_time_option_exten);
	$voicemail_ext = preg_replace('/[^\*\#\.\_0-9\p{L}]/u','',$voicemail_ext);
	$phone = preg_replace('/[^\*\#\.\_0-9\p{L}]/u','',$phone);
	$phone_code = preg_replace('/[^\*\#\.\_0-9\p{L}]/u','',$phone_code);
	$wait_time_option_exten = preg_replace('/[^\*\#\.\_0-9\p{L}]/u','',$wait_time_option_exten);
	$filter_voicemail_ext = preg_replace('/[^\*\#\.\_0-9\p{L}]/u','',$filter_voicemail_ext);
	$filter_phone_code = preg_replace('/[^\*\#\.\_0-9\p{L}]/u','',$filter_phone_code);
	$filter_phone = preg_replace('/[^\*\#\.\_0-9\p{L}]/u','',$filter_phone);
	$preset_number = preg_replace('/[^\*\#\.\_0-9\p{L}]/u','',$preset_number);
	$no_agent_ingroup_extension = preg_replace('/[^\*\#\.\_0-9\p{L}]/u','',$no_agent_ingroup_extension);
	$pre_filter_extension = preg_replace('/[^\*\#\.\_0-9\p{L}]/u','',$pre_filter_extension);
	$max_queue_ingroup_extension = preg_replace('/[^\*\#\.\_0-9\p{L}]/u','',$max_queue_ingroup_extension);
	$report_server = preg_replace('/[^\*\#\.\_0-9\p{L}]/u','',$report_server);
	$dl_server = preg_replace('/[^\*\#\.\_0-9\p{L}]/u','',$dl_server);

	### ALPHA-NUMERIC and hash and star and dot and underscore and colon and plus sign
	$did_pattern = preg_replace('/[^:\+\*\#\.\_0-9\p{L}]/u','',$did_pattern);
	$web_loader_phone_strip = preg_replace('/[^:\+\*\#\.\_0-9\p{L}]/u','',$web_loader_phone_strip);
	$manual_dial_phone_strip = preg_replace('/[^:\+\*\#\.\_0-9\p{L}]/u','',$manual_dial_phone_strip);
	$mobile_number = preg_replace('/[^:\+\*\#\.\_0-9\p{L}]/u','',$mobile_number);

	### ALPHA-NUMERIC and spaces dots, commas, dashes, underscores
	$adaptive_dl_diff_target = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$adaptive_dl_diff_target);
	$adaptive_intensity = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$adaptive_intensity);
	$asterisk_version = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$asterisk_version);
	$call_time_comments = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$call_time_comments);
	$call_time_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$call_time_name);
	$campaign_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$campaign_name);
	$campaign_rec_filename = preg_replace('/[^-\.\_0-9\p{L}]/u','',$campaign_rec_filename);
	$ingroup_rec_filename = preg_replace('/[^-\.\_0-9\p{L}]/u','',$ingroup_rec_filename);
	$company = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$company);
	$full_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$full_name);
	$fullname = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$fullname);
	$group_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$group_name);
	$HKstatus = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$HKstatus);
	$lead_filter_comments = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$lead_filter_comments);
	$lead_filter_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$lead_filter_name);
	$list_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$list_name);
	$local_gmt = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$local_gmt);
	$new_fullname = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$new_fullname);
	$phone_type = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$phone_type);
	$picture = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$picture);
	$script_comments = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$script_comments);
	$script_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$script_name);
	$server_description = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$server_description);
	$status = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$status);
	$status_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$status_name);
	$wrapup_message = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$wrapup_message);
	$pause_code_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$pause_code_name);
	$campaign_description = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$campaign_description);
	$list_description = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$list_description);
	$vcl_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$vcl_name);
	$vsc_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$vsc_name);
	$vsc_description = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$vsc_description);
	$code_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$code_name);
	$alias_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$alias_name);
	$shift_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$shift_name);
	$did_description = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$did_description);
	$template_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$template_name);
	$carrier_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$carrier_name);
	$group_alias_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$group_alias_name);
	$caller_id_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$caller_id_name);
	$user_code = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$user_code);
	$territory = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$territory);
	$tts_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$tts_name);
	$moh_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$moh_name);
	$timer_action_message = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$timer_action_message);
	$default_codecs = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$default_codecs);
	$codecs_list = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$codecs_list);
	$label_title = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_title);
	$label_first_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_first_name);
	$label_middle_initial = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_middle_initial);
	$label_last_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_last_name);
	$label_address1 = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_address1);
	$label_address2 = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_address2);
	$label_address3 = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_address3);
	$label_city = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_city);
	$label_state = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_state);
	$label_province = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_province);
	$label_postal_code = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_postal_code);
	$label_vendor_lead_code = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_vendor_lead_code);
	$label_gender = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_gender);
	$label_phone_number = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_phone_number);
	$label_phone_code = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_phone_code);
	$label_alt_phone = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_alt_phone);
	$label_security_phrase = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_security_phrase);
	$label_email = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_email);
	$label_comments = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_comments);
	$slave_db_server = preg_replace('/[^- \.\,\:\_0-9\p{L}]/u','',$slave_db_server);
	$filter_phone_group_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$filter_phone_group_name);
	$filter_phone_group_description = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$filter_phone_group_description);
	$filter_clean_cid_number = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$filter_clean_cid_number);
	$label_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_name);
	$default_local_gmt = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$default_local_gmt);
	$cid_description = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$cid_description);
	$description = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$description);
	$first_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$first_name);
	$last_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$last_name);
	$bu_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$bu_name);
	$department = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$department);
	$group = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$group);
	$job_title = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$job_title);
	$location = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$location);
	$holiday_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$holiday_name);
	$holiday_comments = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$holiday_comments);
	$api_allowed_functions = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$api_allowed_functions);
	$agent_display_fields = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$agent_display_fields);
	$container_notes = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$container_notes);
	$did_carrier_description = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$did_carrier_description);
	$status_group_notes = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$status_group_notes);
	$colors_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$colors_name);
	$web_logo = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$web_logo);
	$user_nickname = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$user_nickname);
	$customer_chat_survey_text = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$customer_chat_survey_text);
	$agent_script = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$agent_script);
	$report_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$report_name);
	$dl_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$dl_name);
	$drop_status = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$drop_status);
	$ip_list_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$ip_list_name);
	$cid_group_notes = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$cid_group_notes);
	$populate_lead_vendor = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$populate_lead_vendor);
	$leave_vm_message_group_notes = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$leave_vm_message_group_notes);
	$audio_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$audio_name);
	$populate_lead_comments = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$populate_lead_comments);
	$label_lead_id = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_lead_id);
	$label_list_id = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_list_id);
	$label_entry_date = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_entry_date);
	$label_gmt_offset_now = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_gmt_offset_now);
	$label_source_id = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_source_id);
	$label_called_since_last_reset = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_called_since_last_reset);
	$label_status = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_status);
	$label_user = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_user);
	$label_date_of_birth = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_date_of_birth);
	$label_country_code = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_country_code);
	$label_last_local_call_time = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_last_local_call_time);
	$label_called_count = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_called_count);
	$label_rank = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_rank);
	$label_owner = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_owner);
	$label_entry_list_id = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$label_entry_list_id);
	$user_location = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$user_location);
	$queue_group_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$queue_group_name);
	$qc_scorecard_id = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$qc_scorecard_id);
	$city_rule = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$city_rule);
	$county_rule = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$county_rule);
	$ac_rule = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$ac_rule);
	$stereo_rec_filename = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$stereo_rec_filename);
	$parallel_rec_co_filename = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$parallel_rec_co_filename);
	$parallel_rec_cm_filename = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$parallel_rec_cm_filename);
	$parallel_rec_fr_filename = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$parallel_rec_fr_filename);

	### ALPHA-NUMERIC and underscore and dash and slash and at and dot
	$call_out_number_group = preg_replace('/[^-\.\:\/\@\_0-9\p{L}]/u','',$call_out_number_group);
	$client_browser = preg_replace('/[^-\.\:\/\@\_0-9\p{L}]/u','',$client_browser);
	$DBX_server = preg_replace('/[^-\.\:\/\@\_0-9\p{L}]/u','',$DBX_server);
	$DBY_server = preg_replace('/[^-\.\:\/\@\_0-9\p{L}]/u','',$DBY_server);
	$dtmf_send_extension = preg_replace('/[^-\.\:\/\@\_0-9\p{L}]/u','',$dtmf_send_extension);
	$install_directory = preg_replace('/[^-\.\:\/\@\_0-9\p{L}]/u','',$install_directory);
	$old_extension = preg_replace('/[^-\.\:\/\@\_0-9\p{L}]/u','',$old_extension);
	$telnet_host = preg_replace('/[^-\.\:\/\@\_0-9\p{L}]/u','',$telnet_host);
	$queuemetrics_dbname = preg_replace('/[^-\.\:\/\@\_0-9\p{L}]/u','',$queuemetrics_dbname);
	$queuemetrics_login = preg_replace('/[^-\.\:\/\@\_0-9\p{L}]/u','',$queuemetrics_login);
	$queuemetrics_pass = preg_replace('/[^-\.\:\/\@\_0-9\p{L}]/u','',$queuemetrics_pass);
	$email = preg_replace('/[^-\.\:\/\@\_0-9\p{L}]/u','',$email);
	$vtiger_dbname = preg_replace('/[^-\.\:\/\@\_0-9\p{L}]/u','',$vtiger_dbname);
	$vtiger_login = preg_replace('/[^-\.\:\/\@\_0-9\p{L}]/u','',$vtiger_login);
	$vtiger_pass = preg_replace('/[^-\.\:\/\@\_0-9\p{L}]/u','',$vtiger_pass);
	$external_server_ip = preg_replace('/[^-\.\:\/\@\_0-9\p{L}]/u','',$external_server_ip);
	$alt_server_ip = preg_replace('/[^-\.\:\/\@\_0-9\p{L}]/u','',$alt_server_ip);
	$email_from = preg_replace('/[^-\.\:\/\@\_0-9\p{L}]/u','',$email_from);
	$email_to = preg_replace('/[^-\.\:\/\@\_0-9\p{L}]/u','',$email_to);
	$ftp_server = preg_replace('/[^-\.\:\/\@\_0-9\p{L}]/u','',$ftp_server);
	$ftp_directory = preg_replace('/[^-\.\:\/\@\_0-9\p{L}]/u','',$ftp_directory);

	### ALPHA-NUMERIC and underscore and dash and slash and at and dot and space
	$custom_one = preg_replace('/[^- \.\:\/\@\_0-9\p{L}]/u','',$custom_one);
	$custom_two = preg_replace('/[^- \.\:\/\@\_0-9\p{L}]/u','',$custom_two);
	$custom_three = preg_replace('/[^- \.\:\/\@\_0-9\p{L}]/u','',$custom_three);
	$custom_four = preg_replace('/[^- \.\:\/\@\_0-9\p{L}]/u','',$custom_four);
	$custom_five = preg_replace('/[^- \.\:\/\@\_0-9\p{L}]/u','',$custom_five);
	$email_subject = preg_replace('/[^- \.\:\/\@\_0-9\p{L}]/u','',$email_subject);

	### ALPHA-NUMERIC and underscore and dash and slash and at and dot and pound and star
	$extension = preg_replace('/[^-\*\#\.\:\/\@\_0-9\p{L}]/u','',$extension);
	$new_extension = preg_replace('/[^-\*\#\.\:\/\@\_0-9\p{L}]/u','',$new_extension);
	$timer_action_destination = preg_replace('/[^-\*\#\.\:\/\@\_0-9\p{L}]/u','',$timer_action_destination);
	$filter_extension = preg_replace('/[^-\*\#\.\:\/\@\_0-9\p{L}]/u','',$filter_extension);

	### ALPHA-NUMERIC and space and underscore and dash and slash and at and dot and pound and star and pipe and comma
	$ivr_park_call_agi = preg_replace('/[^- \*\#\.\,\:\/\|\@\_0-9\p{L}]/u','',$ivr_park_call_agi);
	$source_phone = preg_replace('/[^- \*\#\.\,\:\/\|\@\_0-9\p{L}]/u','',$source_phone);

	### ALPHA-NUMERIC and space and underscore and dash and slash and at and dot and pound and star and pipe and comma and equal
	$voicemail_options = preg_replace('/[^- \=\*\#\.\,\:\/\|\@\_0-9\p{L}]/u','',$voicemail_options);

	### NUMERIC and comma and pipe
	$waitforsilence_options = preg_replace('/[^\|\,0-9\p{L}]/u','',$waitforsilence_options);

	### value cleaning
	$no_agent_action_value = preg_replace('/[^-\/\|\_\#\*\,\.\_0-9\p{L}]/u','',$no_agent_action_value);
	$areacode_filter_action_value = preg_replace('/[^-\/\|\_\#\*\,\.\_0-9\p{L}]/u','',$areacode_filter_action_value);

	### ALPHA-NUMERIC and underscore and dash and slash and at and space and colon
	$vdc_header_date_format = preg_replace('/[^- \:\/\_0-9\p{L}]/u','',$vdc_header_date_format);
	$vdc_customer_date_format = preg_replace('/[^- \:\/\_0-9\p{L}]/u','',$vdc_customer_date_format);
	$menu_name = preg_replace('/[^- \:\/\_0-9\p{L}]/u','',$menu_name);

	### ALPHA-NUMERIC and underscore and dash and at and space and parantheses
	$vdc_header_phone_format = preg_replace('/[^- \(\)\_0-9\p{L}]/u', '',$vdc_header_phone_format);

	### ALPHA-NUMERIC and newlines
	$areacode_list = preg_replace('/[^\n0-9\p{L}]/u', '',$areacode_list);

	### ALPHA-NUMERIC and newlines and period and colon
	$ip_address = preg_replace('/[^\n\.\:\0-9\p{L}]/u', '',$ip_address);
	}

### remove semi-colons and other special characters ###
$lead_filter_sql = preg_replace('/;/','',$lead_filter_sql);
$list_mix_container = preg_replace('/;/','',$list_mix_container);
$survey_response_digit_map = preg_replace('/;/','',$survey_response_digit_map);
$survey_camp_record_dir = preg_replace('/;/','',$survey_camp_record_dir);
$conf_override = preg_replace('/;/','',$conf_override);
$template_contents = preg_replace('/;/','',$template_contents);
$registration_string = preg_replace('/;/','',$registration_string);
$account_entry = preg_replace('/;/','',$account_entry);
$account_entry = preg_replace('/\r/', '',$account_entry);
$globals_string = preg_replace('/;/','',$globals_string);
$dialplan_entry = preg_replace('/\\\\/', '',$dialplan_entry);
$dialplan_entry = preg_replace('/\'/', '',$dialplan_entry);
$dialplan_entry = preg_replace('/\r/', '',$dialplan_entry);
$custom_dialplan_entry = preg_replace('/\\\\/', '',$custom_dialplan_entry);
$custom_dialplan_entry = preg_replace('/\'/', '',$custom_dialplan_entry);
$custom_dialplan_entry = preg_replace('/\r/', '',$custom_dialplan_entry);
$tts_text = preg_replace('/\\\\/', '',$tts_text);
$tts_text = preg_replace('/;/','',$tts_text);
$tts_text = preg_replace('/\r/', '',$tts_text);
$tts_text = preg_replace('/\"/', '',$tts_text);
$carrier_description = preg_replace('/\\\\/', '',$carrier_description);
$carrier_description = preg_replace('/;/','',$carrier_description);
$carrier_description = preg_replace('/\r/', '',$carrier_description);
$carrier_description = preg_replace('/\"/', '',$carrier_description);
$blind_monitor_message = preg_replace('/\\\\/', '',$blind_monitor_message);
$blind_monitor_message = preg_replace('/;/','',$blind_monitor_message);
$blind_monitor_message = preg_replace('/\r/', '',$blind_monitor_message);
$blind_monitor_message = preg_replace('/\"/', '',$blind_monitor_message);
$modify_url = preg_replace('/\\\\/', '',$modify_url);
$modify_url = preg_replace('/;/','',$modify_url);
$modify_url = preg_replace('/\r/', '',$modify_url);
$modify_url = preg_replace('/\"/', '',$modify_url);
$qualify_sql = preg_replace('/\\\\/', '',$qualify_sql);
$qualify_sql = preg_replace('/;/','',$qualify_sql);
$qualify_sql = preg_replace('/\r/', '',$qualify_sql);
$qualify_sql = preg_replace('/\'/', "\"",$qualify_sql);
$queuemetrics_socket_url = preg_replace('/\\\\/', '',$queuemetrics_socket_url);
$queuemetrics_socket_url = preg_replace('/;/','',$queuemetrics_socket_url);
$queuemetrics_socket_url = preg_replace('/\r/', '',$queuemetrics_socket_url);
$queuemetrics_socket_url = preg_replace('/\'/', "\"",$queuemetrics_socket_url);
$agent_status_viewable_groups = preg_replace('/\\\\/', '',$agent_status_viewable_groups);
$agent_status_viewable_groups = preg_replace('/\\\\/', '',$agent_status_viewable_groups);
$agent_allowed_chat_groups = preg_replace('/\\\\/', '',$agent_allowed_chat_groups);
$agent_allowed_chat_groups = preg_replace('/\\\\/', '',$agent_allowed_chat_groups);
$report_url = preg_replace('/\\\\/', '',$report_url);
$report_url = preg_replace('/;/','',$report_url);
$report_url = preg_replace('/\r|\n/', '',$report_url);
$report_url = preg_replace('/\'/', '',$report_url);
$agent_push_url = preg_replace('/\\\\/', '',$agent_push_url);
$agent_push_url = preg_replace('/;/','',$agent_push_url);
$agent_push_url = preg_replace('/\r|\n/', '',$agent_push_url);
$agent_push_url = preg_replace('/\'/', '',$agent_push_url);
$waiting_call_url_on = preg_replace('/\\\\/', '',$waiting_call_url_on);
$waiting_call_url_on = preg_replace('/;/','',$waiting_call_url_on);
$waiting_call_url_on = preg_replace('/\r|\n/', '',$waiting_call_url_on);
$waiting_call_url_on = preg_replace('/\'/', '',$waiting_call_url_on);
$waiting_call_url_off = preg_replace('/\\\\/', '',$waiting_call_url_off);
$waiting_call_url_off = preg_replace('/;/','',$waiting_call_url_off);
$waiting_call_url_off = preg_replace('/\r|\n/', '',$waiting_call_url_off);
$waiting_call_url_off = preg_replace('/\'/', '',$waiting_call_url_off);
$sounds_web_server = preg_replace('/\\\\/', '',$sounds_web_server);
$sounds_web_server = preg_replace('/;/','',$sounds_web_server);
$sounds_web_server = preg_replace('/\r|\n/', '',$sounds_web_server);
$sounds_web_server = preg_replace('/\'/', '',$sounds_web_server);
$pause_max_url = preg_replace('/\\\\/', '',$pause_max_url);
$pause_max_url = preg_replace('/;/','',$pause_max_url);
$pause_max_url = preg_replace('/\r|\n/', '',$pause_max_url);
$pause_max_url = preg_replace('/\'/', '',$pause_max_url);
$apinewlead_url = preg_replace('/\\\\/', '',$apinewlead_url);
$apinewlead_url = preg_replace('/;/','',$apinewlead_url);
$apinewlead_url = preg_replace('/\r|\n/', '',$apinewlead_url);
$apinewlead_url = preg_replace('/\'/', '',$apinewlead_url);

### VARIABLES TO BE mysqli_real_escape_string ###
# $web_form_address
# $queuemetrics_url
# $admin_home_url
# $qc_web_form_address
# $vtiger_url
# $web_form_address_two
# $crm_login_address
# $start_call_url
# $dispo_call_url
# $add_lead_url
# $webphone_url
# $webphone_url_override
# $filter_url
# $na_call_url
# $web_form_address_three
# $container_entry
# $nva_call_url
# $web_socket_url
# $external_web_socket_url
# $customer_chat_survey_link
# $ftp_user
# $ftp_pass
# $webphone_layout
# $enter_ingroup_url
# $dead_trigger_url
# $user_admin_redirect_url
# $local_web_callerID_URL
# $VICIDIAL_web_URL
# $audit_comments
# $chat_url
# $ara_url

# filtered further down in the code
# $groups
# $XFERgroups
# $campaigns
# $qc_campaigns
# $qc_groups
# $qc_statuses
# $qc_lists
# $shift_weekdays
# $group_shifts
# $phone_numbers
# $list_active_change
# $reports_use_slave_db
# $custom_reports_use_slave_db
# $allowed_reports
# $allowed_custom_reports
# $tables_use_alt_log_db
# $admin_viewable_groups
# $admin_viewable_call_times
# $territory_reset
# $max_inbound_filter_statuses
# $max_inbound_filter_ingroups
# $included_campaigns
# $included_inbound_groups
# $allowed_queue_groups
# $queue_groups

### VARIABLES optionally filtered: ###

# $script_text JS filtering
$rjs_debug='';
if ($SSscript_remove_js > 0)
	{
	$rjs=0;   $rjs_ct=0;
	$temp_length_a = strlen($script_text);
	if ($temp_length_a > 7)
		{
		while ( ($rjs < 10000000000) and (preg_match("/<script\b[^>]*>/is",$script_text)) )
			{
			$temp_length_a = strlen($script_text);
			$script_text = preg_replace('/<script\b[^>]*>(.*?)<\/script\s*>/is','',$script_text);
			$temp_length_b = strlen($script_text);
			if ($temp_length_a != $temp_length_b) {$rjs_ct++;}
			else {$rjs=99999999999;}
			$rjs++;
			}
		$rjsb=0;
		while ( ($rjsb < 10000000000) and (preg_match("/<script\b[^>]*>/is",$script_text)) )
			{
			$temp_length_a = strlen($script_text);
			$script_text = preg_replace('/<script\b[^>]*>/is','',$script_text);
			$temp_length_b = strlen($script_text);
			if ($temp_length_a != $temp_length_b) {$rjs_ct++;}
			else {$rjsb=99999999999;}
			$rjsb++;
			}
		$rjsc=0;
		while ( ($rjsc < 10000000000) and (preg_match("/javascript:|onabort|onactivate|onafterprint|onafterupdate|onbeforeactivate|onbeforecopy|onbeforecut|onbeforedeactivate|onbeforeeditfocus|onbeforepaste|onbeforeprint|onbeforeunload|onbeforeupdate|onblur|onbounce|oncellchange|onchange|onclick|oncontextmenu|oncontrolselect|oncopy|oncut|ondataavaible|ondatasetchanged|ondatasetcomplete|ondblclick|ondeactivate|ondrag|ondragdrop|ondragend|ondragenter|ondragleave|ondragover|ondragstart|ondrop|onerror|onerrorupdate|onfilterupdate|onfinish|onfocus|onfocusin|onfocusout|onhelp|onkeydown|onkeypress|onkeyup|onlayoutcomplete|onload|onlosecapture|onmousedown|onmouseenter|onmouseleave|onmousemove|onmoveout|onmouseover|onmouseup|onmousewheel|onmove|onmoveend|onmovestart|onpaste|onpropertychange|onreadystatechange|onreset|onresize|onresizeend|onresizestart|onrowexit|onrowsdelete|onrowsinserted|onscroll|onselect|onselectionchange|onselectstart|onstart|onstop|onsubmit|onunload/is",$script_text)) )
			{
			$temp_length_a = strlen($script_text);
			$script_text = preg_replace('/javascript:|onabort|onactivate|onafterprint|onafterupdate|onbeforeactivate|onbeforecopy|onbeforecut|onbeforedeactivate|onbeforeeditfocus|onbeforepaste|onbeforeprint|onbeforeunload|onbeforeupdate|onblur|onbounce|oncellchange|onchange|onclick|oncontextmenu|oncontrolselect|oncopy|oncut|ondataavaible|ondatasetchanged|ondatasetcomplete|ondblclick|ondeactivate|ondrag|ondragdrop|ondragend|ondragenter|ondragleave|ondragover|ondragstart|ondrop|onerror|onerrorupdate|onfilterupdate|onfinish|onfocus|onfocusin|onfocusout|onhelp|onkeydown|onkeypress|onkeyup|onlayoutcomplete|onload|onlosecapture|onmousedown|onmouseenter|onmouseleave|onmousemove|onmoveout|onmouseover|onmouseup|onmousewheel|onmove|onmoveend|onmovestart|onpaste|onpropertychange|onreadystatechange|onreset|onresize|onresizeend|onresizestart|onrowexit|onrowsdelete|onrowsinserted|onscroll|onselect|onselectionchange|onselectstart|onstart|onstop|onsubmit|onunload/is','',$script_text);
			$temp_length_b = strlen($script_text);
			if ($temp_length_a != $temp_length_b) {$rjs_ct++;}
			else {$rjsc=99999999999;}
			$rjsc++;
			}
		if ($rjs_ct > 0) {$rjs_debug = "\n<BR><BR>Script Text JS Filtered: $rjs_ct<BR>\n";}
	#	$script_text = "PROCESSED:".date("U")."\n".$script_text;
		}
	}
##### END VARIABLE FILTERING FOR SECURITY #####


# ViciDial database administration
# admin.php
# 
# CHANGELOG:
# 50315-1110 - Added Custom Campaign Statuses
# 50317-1438 - Added Fronter Display var to inbound groups
# 50322-1355 - Added custom callerID per campaign
# 50517-1356 - Added user_groups sections and user_group to vicidial_users
# 50517-1440 - Added ability to logout (must click OK with empty user/pass)
# 50602-1622 - Added lead loader pages to load new files into vicidial_list
# 50620-1351 - Added custom vdad transfer AGI extension per campaign
# 50810-1414 - modified in groups to kick out spaces and dashes
# 50908-2136 - Added Custom Campaign HotKeys
# 50914-0950 - Fixed user search by user_group
# 50926-1358 - Modified to allow for language translation
# 50926-1615 - Added WeBRooTWritablE write controls
# 51020-1008 - Added editable web address and park ext - NEW dial campaigns
# 51020-1056 - Added fields and help for campaign recording control
# 51123-1335 - Altered code to function in php globals=off
# 51208-1038 - Added user_level changes, function controls and default user phones
# 51208-1556 - Added deletion of users/lists/campaigns/in groups/remote agents
# 51213-1706 - Added add/delete/modify vicidial scripts
# 51214-1737 - Added preview of vicidial script in popup window
# 51219-1225 - Added campaign and ingroups script selector and get_call_launch field
# 51222-1055 - Added am_message_exten to campaigns to allow for AM Message button
# 51222-1125 - Fixed new vicidial_campaigns default values not being assigned bug
# 51222-1156 - Added LOG OUT ALL AGENTS ON THIS CAMPAIGN button to campaign screen
# 60204-0659 - Fixed hopper reset bug
# 60207-1413 - Added AMD send to voicemail extension and xfer-conf dtmf presets
# 60213-1100 - Added several vicidial_users permissions fields
# 60215-1319 - Added On-hold CallBacks display and links
# 60227-1226 - Fixed vicidial_inbound_groups insert bug
# 60413-1308 - Fixed list display to have 1 row/status: count and time zone tables
#            - Added status name in selected dial statuses in campaign screen
# 60417-1416 - Added vicidial_lead_filters sections
#            - Changed the header links to color-coded sectional with sublinks below
#            - Added filter name and script name to campaign and in-group modify sections
#            - Added callback and alt dial options to campaigns section
#            - Added callback, alt dial and other options to users section
# 60419-1628 - Alter Callbacks display to include status and LIVE listings, reordered
# 60421-1441 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60425-2355 - Added agent options to vicidial_users, reformatted user page
# 60502-1627 - Added drop_call_seconds and safe_harbor_ fields to campaign screen
# 60503-1228 - Added drop_call_seconds and drop_ fields to inbound groups screen
# 60505-1117 - Added initial framework for new local_call_times tables and definitions
# 60506-1033 - More revisions to the local_call_time section
# 60508-1354 - Finished call_times and state_call_times sections
#            - Added modify/delete options for call_times
# 60509-1311 - Functionalize campaign dialable leads calculation
#            - Change state_call_times selection from call_times to only allow one per state
#            - Added dialable leads count popup to campaign screen if auto-calc is disabled
#            - Added test dialable leads count popup to filter screen 
# 60510-1050 - Added Wrapup seconds and Wrapup message to campaigns screen
# 60608-1401 - Added allowable inbound_groups checkboxes to CLOSER campaign detail screen
# 60609-1051 - Added add-to-dnc in LISTS section
# 60613-1415 - Added lead recycling options to campaign detail screen
# 60619-1523 - Added variable filtering to eliminate SQL injection attack threat
# 60622-1216 - Fixed HotKey addition form issues and variable filtering
# 60623-1159 - Fixed Scheduled Callbacks over-filtering bug and filter_sql bug
# 60808-1147 - Changed filtering for and added instructions for consutative transfers
# 60816-1552 - Added allcalls_delay start delay for recordings in vicidial.php
# 60817-2226 - Fixed bug that would not allow lead recycling of non-selectable statuses
# 60821-1543 - Added option to Omit Phone Code while dialing in vicidial
# 60821-1625 - Added ALLFORCE recording option for campaign_recording
# 60823-1154 - Added fields for adaptive dialing
# 60824-1326 - Added adaptive_latest_target_gmt for ADAPT_TAPERED dial method
# 60825-1205 - Added adaptive_intensity for ADAPT_ dial methods
# 60828-1019 - Changed adaptive_latest_target_gmt to adaptive_latest_server_time
# 60828-1115 - Added adaptive_dl_diff_target and changed intensity dropdown
# 60927-1246 - Added astguiclient/admin.php functions under SERVERS tab
# 61002-1402 - Added fields for vicidial balance trunk controls
# 61003-1123 - Added functions for vicidial_server_trunks records
# 61109-1022 - Added Emergency VDAC Jam Clear function to Campaign Detail screen
# 61110-1502 - Add ability to select NONE in dial statuses, new list_id must not be < 100
# 61122-1228 - Added user group campaign restrictions
# 61122-1535 - Changed script_text to unfiltered and added more variables to SCRIPTS
# 61129-1028 - Added headers to Users and Phones with clickable order-by titles
# 70108-1405 - Added ADAPT OVERRIDE to allow for forced dial_level changes in ADAPT dial methods
#            - Screen width definable at top of script, merged server_stats into this script
# 70109-1638 - Added ALTPH2 and ADDR3 hotkey options for alt number dialing with HotKeys
# 70109-1716 - Added concurrent_transfers option to vicidial_campaigns
# 70115-1152 - Aded (CLOSER|BLEND|INBND|_C$|_B$|_I$) options for CLOSER-type campaigns
# 70115-1532 - Added auto_alt_dial field to campaign screen for auto-dialing of alt numbers
# 70116-1200 - Added auto_alt_dial_status functionality to campaign screen
# 70117-1235 - Added header formatting variables at top of script
#            - Moved Call Times and Phones/Server functions to Admin section
# 70118-1706 - Added new user group displays and links
# 70123-1519 - Added user permission settings for all sections
# 70124-1346 - Fixed spelling errors and formatting consistency
# 70202-1120 - Added agent_pause_codes section to campaigns
# 70205-1204 - Added memo, last dialed, timestamp and stats-refresh fields to vicidial_campaigns/lists
# 70206-1323 - Added user setting for vicidial_recording_override
# 70212-1412 - Added system settings section
# 70214-1226 - Added QueueMetrics Log ID field to system settings section
# 70219-1102 - Changed campaign dial statuses to be one string allowing for high limit
# 70223-0957 - Added queuemetrics_eq_prepend for custom ENTERQUEUE prepending of a field
# 70302-1111 - Fixed small bug in dialable leads calculation
# 70314-1133 - Added insert selection on script forms
# 70319-1423 - Added Alter Customer Data and agent disable display functions
# 70319-1625 - Added option to allow agents to login to outbound campaigns with no leads in the hopper
# 70322-1455 - Added sipsak messages parameters
# 70402-1157 - Added HOME link and entry to system_settings table, added QM link on reports section
# 70516-1628 - Started reformatting campaigns to use submenus to break up options
# 70529-1653 - Added help for list mix
# 70530-1354 - Added human_answered field to statuses, added system status modification
# 70530-1714 - Added lists for all campaign subsections
# 70531-1631 - Development on List mix admin interface
# 70601-1629 - More development on List mix admin interface, formatting, and added some javascript
# 70602-1300 - More development on List mix admin interface, more javascript
# 70608-1459 - Added option to set LIVE Callbacks to INACTIVE after one month
# 70612-1451 - Added Callback INACTIVE link for after one week, sort by user/group/entrydate
# 70614-0231 - Added Status Categories, ability to Modify Statuses, moved system statuses to sub-section
# 70623-1008 - List Mix section now allows modification of list mix entries
# 70629-1721 - List Mix section adding and removing of list entries active
# 70706-1636 - List Mix section cleanup and more error-checking
# 70908-0941 - Added agc logile enable system_settings
# 71020-1934 - Added inbound groups options: on-hold music, messages, call_times
# 71022-1343 - Added inbound group ranks for users
# 71029-1710 - Added option for campaign to be inbound and/or blended with no restrictions on the campaign_id name
#            - Added 5th NEW and 6th NEW to the dial order options
# 71030-2010 - Added Manual Dial List ID field to campaigns table
# 71103-2207 - Added inbound_group_rank and fewest_calls to the inbound groups call order options
# 71113-1521 - Added campaign_rank to agent options
#            - Added ability to Copy a campaign's setting to a new campaign
# 71113-2225 - Added ability to copy user and in-group settings to new users and in-groups
# 71116-0942 - Added campaign_rank and fewest_calls as methods for agent call routing
# 71122-1135 - Added default transfer group for campaigns and inbound groups
# 71125-1751 - Added allowable transfer groups to campaign detail screen
# 80107-1204 - Started framework for new QC section
# 80112-0242 - Added more options for lead order
# 80211-1901 - Added DB Schema Version to system settings display
# 80224-1334 - Added Queue Priority to in-groups and campaigns
# 80302-0232 - added drop_action and transfer to in-group for both in-groups and outbound
# 80310-1504 - added QC settings section to campaign screen
# 80317-2037 - Added Recording override settings to in-groups
# 80414-1505 - More work on QC, added vicidial_qc_codes
# 80424-0442 - Added non_latin system_settings lookup at top to override dbconnect setting
# 80505-0333 - Added phones_alias sections to allow for load-balanced-phone-logins
# 80512-1529 - Added auto-generate of User ID feature
# 80515-1345 - Added Shifts sub-section to Admin section
# 80528-0001 - Added campaign survey sub-section
# 80528-1102 - Added user timeclock edit options
# 80608-1304 - Changed add-to-DNC to allow for multiple entries per submission
# 80625-0032 - Added time/phone display format options to system settings
# 80703-0124 - Added alter cust phone and api settings
# 80715-1130 - Added Recycle leads limit count
# 80719-1351 - Changed QC settings in campaigns and In-Groups
# 80809-2305 - Added Sale and Dead Lead categories to status categories page
# 80815-1036 - Added manual dial filter to capaigns
# 80823-2124 - Added copy to clipboard campaign option
# 80829-2359 - Added EXTENDED auto_alt_dial options
# 80831-0406 - Added agent screen extended alt-dial option to campaigns
# 80909-0553 - Added campaign-specific DNC list option and add
# 81002-1101 - Added more in-group options and new DID section and user options
# 81007-0936 - Added three_way_call_cid option to campaigns
# 81012-1725 - Added INBOUND_MAN dial method allowing for manual list dialing with inbound calls
# 81030-0348 - Added campaign pause code force option
# 81030-2228 - Fixed DIDs creation issue
# 81103-1408 - Added 3way call dial prefix option
# 81107-1551 - Added Stats Percent of Calls Answered Within X seconds fields to in-groups
# 81118-0933 - Changed lists listing with links and more options
# 81119-0715 - Added ability to bulk enable/disable lists from modify campaign screen
# 81209-1538 - Added web_form_target to campaign screen
# 81210-1430 - Added http server IP and recording link options to servers
# 81222-0500 - Reformatted all listings to same format changed to field selects instead of *
# 81228-2300 - Added fields for vtiger integration and active vicidial_user display
# 90101-1216 - Added options for user synchronization with vtiger
# 90112-0335 - Added vtiger_create_lead_record and vtiger_create_lead_record options
# 90115-0502 - Activated AGENT DID routing option
# 90126-2256 - Added vtiger_screen_login campaign option and user agent alert option
# 90201-1503 - Added option to disable the viewing of inactive QC features
# 90202-0112 - Added option to disable outbound autodialing(or list dialing)
# 90202-0444 - Added cpd_amd_action option for processing of AMD messages
# 90209-1339 - Added download_lists option to allow downloading of lists
# 90210-1042 - Added options for auto-generation of asterisk conf files
# 90301-2026 - Added Vtiger group synchronization
# 90302-2046 - Changed Section heading to be on the left side of the screen
# 90303-0631 - Added web vars to agent campaign and in-group settings
# 90303-2047 - Added group aliases and default group aliases
# 90306-1214 - Added shift enforcement and server/system calls per second options
# 90308-0956 - Added server statistics
# 90309-0059 - Changed logging to admin_server_log
# 90310-2203 - Added export_reports option for call activity report data exports
# 90315-1010 - Changed revision for new trunk 2.2.0
# 90320-0424 - Fixed several small bugs conf records group alias and permissions
# 90322-0122 - Added ability to delete from the DNC lists
# 90322-1105 - Added new status settings and vtiger options
# 90409-2133 - Fixed special characters in SCRIPTS
# 90413-0755 - Fixed filter and script slashes issues
# 90417-0211 - Fixed filter and script slashes issues
# 90422-0613 - Added user_code, territory and email to vicidial_users
# 90429-0542 - Added 3rd&4th options to SURVEY campaigns
# 90430-0154 - Added RANDOM and LAST CALL TIME options to lead order for campaigns
# 90504-0901 - Added Call Menu feature, changed script to use long PHP tags
# 90511-0910 - Added agentonly_callback_campaign_lock to system_settings
# 90512-0440 - Added sounds settings to system_settings table
# 90514-0607 - Added select prompts from list in call menu and in-group screens
# 90521-0029 - Added user territories enable option
# 90522-0506 - Security fix for logins when using non-latin setting
# 90524-2307 - Changed Reports screen layout
# 90528-2055 - Added ViciDial recording limit field in servers and phone_context to phones
# 90530-1206 - Changed List Mix to allow for 40 mixes
# 90531-1802 - Added auto-generated options for users, campaigns, in-groups, etc..., added option to HIDE custphone
# 90531-2339 - Added Dynamic options for Call Menu
# 90605-0248 - Added carrier_logging_active servers option
# 90607-1716 - Changed drop percent limit to allow for 0.1 steps under 3%
# 90608-0944 - Added Drop Lockout Time feature to Campaign Detail Modification screen
# 90612-0909 - Added audio prompt selection feature to survey screen
# 90614-0827 - Added In-Group routing to Call Menu screen, Added pull-down Call Menu option to DID screen
# 90617-0733 - Added phone ring timeout and call menu custom dialplan entries
# 90621-0821 - Added phone Conf File Secret field to use a separate password from the user interface for a phone
# 90621-1220 - Added Call Menu logging tracking_group
# 90627-0547 - Added no-agent-no-queue options
# 90627-2333 - Added default transfer button and prepopulate preset options
# 90628-0924 - Added Text To Speech(TTS) fields
# 90628-2213 - Added Multi-campaign drop rate groups
# 90705-0926 - Added User Group agent view options
# 90710-1528 - Added Agent view and grab queue calls and every call pause options
# 90717-0646 - Added dialed_label and dialed_number to script variables
# 90721-1350 - Added RANK and OWNER as list order options and list screen display tables
# 90722-1235 - Added list reset time and campaign no hopper dialing, agent dial owner only options
# 90726-0153 - Added allow_alerts for users to disable agent browser alerts
# 90729-0555 - Added agent_display_dialable_leads and vicidial_balance_rank options
# 90808-0300 - Added longest_wait_time option for agent call routing
# 90827-1552 - Added agent_script_override option for lists
# 90830-2217 - Added Music On Hold section
# 90904-1536 - Added moh chooser option, timezone list ordering
# 90908-1207 - Added cross-listing linking for DIDs, CallMenus and In-groups
# 90916-1105 - Added second web form to ingroups and campaigns and added audio choose for answering machine message and waitforsilence_options
# 90917-1108 - Added Extra Voicemail boxes config in Admin section
# 90919-2251 - Removed all SELECT STAR instances in the code, code cleanup to conform to standard
# 90924-1645 - Added list_id overrides for cid, am_message and drop in-group
# 90930-2107 - Added agent territory selection options for ViciDial agents
# 91026-1050 - Added AREACODE DNC option for campaigns
# 91031-1232 - Added carrier_description field, campaigns links from in-group screen, server links on reports page, agent ranks listing active only
# 91121-0334 - Limited list called count display to 100+
# 91125-0628 - Added conf_secret for servers
# 91204-1652 - Added recording_filename and recording_id as script variables
# 91205-2231 - Added delete_vm_after_email voicemail option to phones and extra voicemail sections
# 91210-2038 - Added better logging of Campaign emergency logout
# 91211-1359 - Added custom user fields and campaign CRM login fields
# 91219-0719 - Changed some field backgrounds in the Campaign Modification screens
# 91223-1031 - Added VIDPROMPT options for in-group routing in DIDs
# 91228-1837 - Added timer action settings to in-groups and campaigns
# 100103-0727 - Added Start/Dispo call url, 3/4/5 conf number presets, Lists conf-number overrides
# 100104-1454 - Fixed in-group/campaign copy duplication issue
# 100116-0718 - Added presets to script select list
# 100122-0747 - Added NOT-LOGGED-IN-AGENTS option for User Groups
# 100123-1301 - Added DID record call option
# 100127-0601 - Added Vtiger ViciDial user_level role lookup
# 100127-1546 - Added ignore_list_script_override option for ingroups
# 100219-1309 - Added agent dispo log system settings option and user call_log options
# 100220-1411 - Added system settings and servers custom_dialplan_entry
# 100221-0924 - Added Custom CallerID capability in Campaign settings
# 100302-2133 - Added Scheduled Callbacks Alert option
# 100309-0510 - Added queuemetrics_loginout option
# 100311-2348 - Added CallCard links and settings
# 100313-0020 - Added User Group agent screen transfer-conf button display options
# 100317-1244 - Added User Group agent_fullscreen option
# 100401-0014 - Added agent_choose_blended option
# 100405-1425 - Added queuemetrics_callstatus option and full logging of user campaign/in-group settings
# 100414-1603 - Added extension_appended_cidname option to campaigns
# 100420-1010 - Added scheduled_callbacks_count campaign option
# 100423-1030 - Added realtime_block_user_info, manual dial campaign, blind monitor warnings, in-group callid, phones codecs features
# 100506-1807 - Added hidden settings for lists custom fields
# 100507-1102 - Added hold_time_option_minimum option to in-groups and copy carrier function
# 100512-1615 - Added more hold time press-1 options
# 100518-0643 - Added inbound_queue_no_dial and call time after hours override features
# 100523-0840 - Added inbound prompt and no-block options
# 100616-2232 - Added VIDPROMPT call menu options
# 100621-1010 - Added admin_web_directory system setting
# 100622-1700 - Added custom agent field names for default fields
# 100702-1142 - Added FORM get_call_launch option for custom list fields tab in agent interface
# 100703-1322 - Added LEADS ability to admin log display
# 100709-1025 - Added option for slave DB server to be used for selected reports
# 100718-2318 - Added Wait Time options to in-groups
# 100720-1332 - Small changes to Phone addition and modification pages
# 100723-1519 - Added LOCKED options for Quick Transfer Button in campaigns
# 100726-1017 - Added HANGUP, CALLMENU, EXTENSION and IN_GROUP timer actions to campaigns and in-groups
# 100802-2130 - Changed Admin links to point to links page instead of Phones listings, changed Remote Agents to allow 9-digit IDs
# 100803-1412 - Added allowed_reports option to User Groups, added CAMPLISTS_ALL for manual_dial_filter(issue #369)
#             - Added allowed_campaigns enforcement for Campaign listings
# 100804-2313 - Added filter phone groups section for inbound call filtering by incoming phone number when it comes into a DID
# 100805-1539 - Added option to clean up cid numbers when calls come into DIDs
# 100806-0607 - Added validation for remote agents settings, user_start must be valid user, number of lines must not overlap
# 100811-0827 - Added webphone_url_override to User Groups and calculate_estimated_hold_seconds to In-Groups
# 100813-0544 - Added campaign presets and option to hide xfer number to dial
# 100815-0802 - Added manual_dial_prefix campaign option
# 100817-1243 - Added checking for reserved menu_id on creation of Call Menus
# 100823-1501 - Added CallCard search as an available User Group report option
# 100827-1535 - Added webphone options for dialpad and systemkey
# 100901-2055 - Added password strength grading, force password change, password default settings and first login screen
# 100908-0926 - Added 3way hangup logging options to campaigns
# 100912-0842 - Several small changes, removed Emergency VDAC clear since it does not do anything anymore
# 100927-2321 - Added entry_list_id as a script, webform, dispo_call_url variable
# 100928-1634 - Moved Realtime Block User Info user setting into the new ADMIN REPORT OPTIONS section
# 100929-1203 - Added add_lead_url feature to In-Groups
# 101008-0349 - Added Estimated Hold Time Minimum options, Manual Dial Preview settings and two new variables for recording filenames
# 101022-1427 - Added ability to change user in-group prefs from in-group mod screen, added realtime_agent_time_stats campaign option
# 101106-1850 - Added admin refrech, no-cache, cross-server-exten, QM-addmember options
# 101109-1621 - Added Auto Hopper Level which allows Vicidial to adjust the hopper for a campaign as needed (MikeC)
#             - Added Auto Trim Hopper which will allow Vicidial to remove excess leads from the hopper (MikeC)
# 101115-1355 - Added more options for the concurrent transfer limit campaign setting
# 101123-2214 - Added api_manual_dial and manual_dial_call_time_check campaign options
# 101127-2232 - Added webform override options to lists
# 101208-0341 - Changed some descriptions and field names in Phones
# 101209-2027 - Added display_leads_count option for campaign modification screens
# 101216-1838 - Changed Realtime report links to go to new realtime_report
# 101227-1320 - Added dialplan off toggle options
# 110103-1135 - Added queuemetrics_dispo_pause and lead_order_randomize features
# 110111-1305 - Added sort by list name for list listings in list section and campaign screens
# 110124-1134 - Small query fix for large queue_log tables
# 110212-2048 - Added Scheduled Callback as status flag to allow for custom scheduled callback statuses
# 110214-0001 - Added campaign settings for lead_order_secondary, per_call_notes and my_callback_option
# 110215-1721 - Added add-a-new-lead link to the lists submenu
# 110215-2135 - Added agent_lead_search options to user and campaign
# 110222-2039 - Added USER, GROUP and TERRITORY restrictions to agent lead search
# 110224-1427 - Added queuemetrics_phone_environment and active_twin_server_ip options
# 110301-1206 - Added options for ring-all in-group next-agent-call
# 110304-1651 - Added DEFER options to the scheduled callbacks alert campaign feature
# 110310-0311 - Added pre-call auto-pause and resume with pause code, for auto-pausing of callback-check, lead search, etc...
# 110408-0433 - Added Multi-alt block code and system settings reload dialplan setting
# 110428-1108 - Added manual_dial_cid campaign option
# 110430-1642 - Added post_phone_time_diff_alert campaign option
# 110506-1537 - Added custom_3way_button_transfer campaign option
# 110514-1351 - Added dial level and available only tally threshold campaign settings, and time zone list setting
# 110524-1401 - Small help text fix, issue #486
# 110525-2109 - Added safe_harbor_audio, safe_harbor_menu_id campaign options and dtmf_log call menu option
# 110526-1715 - Added webphone_auto_answer option
# 110528-2304 - Added campaign survey callmenu option
# 110531-2009 - Added callback_days_limit campaign option
# 110602-0941 - Added dl_diff_target_method campaign option
# 110619-1942 - Added disable_dispo_ agent screen options
# 110624-0842 - Added Export Leads Report links and permissions
# 110624-2246 - Added Screen Labels subsection for Admin and status_display_fields feature
# 110625-2338 - Added queuemetrics_pe_phone_append option
# 110703-1400 - Added test_campaign_calls and agents_calls_reset features
# 110707-0725 - Added AGENTEXT notes for in-groups settings
# 110707-1402 - Added last_inbound_call_time and finish to next agent call options for in-groups
# 110727-0130 - Added more voicemail box options and default timezone and voicemail zone to system settings
# 110730-2249 - Added DISPO_SELECT_DISABLED option for the Dispo Disable setting in campaigns
# 110731-0245 - Added na_call_url options to campaigns and in-groups
# 110801-0833 - Added on_hook_cid option for in-groups
# 110802-2053 - Added links to Team Performance Detail Report
# 110809-1547 - Added no-answer log and alt-log server system settings
# 110815-2155 - Added the Campaign Status List Report
# 110822-1204 - Added did_agent_log System Settings option
# 110829-1600 - Added multiple invalid option to Call Menus
# 110829-2129 - Added survey recording option
# 110831-2038 - Added Campaign Areacode CID features
# 110920-1344 - Added pllb_grouping_limit settings
# 110922-1218 - Added new User admin permissions, Added DID Remote Agent extension override section
# 110923-0834 - Added option for in-group action transfer cid, and CALLMENU as drop and after-hours action options
# 110923-2043 - Added custom DID fields
# 111004-1539 - Added dtmf_field call menu option
# 111006-1403 - Added several new campaign and other options, call_count_limit, status flag, shift report flag, etc...
# 111015-1914 - Added Preset Contact Search options
# 111018-1535 - Added more contact fields
# 111021-1646 - Added callback_hours_block option
# 111024-1234 - Added callback_list_calltime option
# 111025-0728 - Added user group to all sections, more user settings
# 111102-1930 - Added in-group max_calls_ options
# 111106-1116 - Many fixes for user_group restrictions
# 111116-0207 - Added ALT and ADDR3 in-group handle methods
# 111122-1333 - Added Inbound Daily Report
# 111201-0939 - Added graded-random next-agent-call option
# 111223-0043 - Added max stats displays for in-groups and , fixed several ereg issues
# 111227-1938 - Added Timer Action for Dx_DIAL_QUIET options
# 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
# 120125-2107 - Added User Group Active User In-Group Select function to User Group page
# 120207-1955 - Added List territory reset function
# 120213-1512 - Added remote agent max stats display and campaign VLC hopper dup check option
# 120221-0054 - Fixed Call Time and User Group restrictions on several pages
# 120221-1647 - Added inventory report options to lists and shifts
# 120316-1203 - Fixed DIALBLE counts for completed statuses
# 120402-2111 - Added lead loading template and two carrier log reports to the admin utils page
# 120409-1136 - Added Search Leads Logs as slave db option
# 120420-1620 - Forked 2.4 to branches, changing trunk to 2.6
# 120512-0844 - Added In-Group Manual Dial options to campaign screen
# 120514-0936 - Added Dial In-group CID override setting
# 120518-1456 - Added XFTAMM/LTMG special hotkeys for send to answering machine message
# 120526-0827 - Added User Group User Login Report
# 120529-2112 - Added safe_harbor_audio_field campaign option
# 120706-1255 - Added Max stats date range and call menu qualify_sql options
# 120713-2123 - Added max stats download link and extended_vl option
# 120810-1018 - Added Admin List Counts system settings option
# 120820-1104 - Added is_webphone option Y_API_LAUNCH
# 120831-1523 - Added vicidial_dial_log outbound call logging
# 121018-2321 - Added blank option to owner only dialing
# 121019-0520 - Added voicemail greeting audio chooser options to phones and voicemail boxes
# 121025-2339 - Added without-filter output to test filter function, added server option to test call
# 121027-2344 - Added servers versions page
# 121029-0109 - Added pause_after_next_call and owner_populate campaign options
# 121114-1923 - Added Basic Lead Management page link. Added INGROUP as a recording filename option
# 121116-1410 - Added QC functionality
# 121120-0824 - Added queuemetrics_socket functionality to system settings
# 121123-1208 - Added inbound holiday functions
# 121124-1957 - Added List Expiration Date feature and Campaign Other-DNC-List feature
# 121129-2319 - Added enhanced_disconnect_logging option
# 121130-1425 - Fixed user group permissions issue with allowed campaigns modifications of user groups
# 121205-1619 - Added parentheses around filter SQL when in SQL queries
# 121206-0630 - Added inbound lead search feature
# 121212-1529 - Standardization of list_id fields at 19 digits in forms
# 121222-2146 - Added new email features
# 130102-1135 - Small change to admin log viewing for email accounts
# 130124-1721 - Added Inbound Email report link, added Status Display LEADID options(issue #639)
# 130130-1207 - Added new CPD AMD options for In-Groups and CallMenus
# 130221-1736 - Added Level 8 Disable Add option to system settings and new Email Log Report link, DID exten made non-editable
# 130402-2322 - Added user_group script variable
# 130414-1924 - Added report logging and display
# 130424-1601 - Added survey_wait_sec campaign survey option
# 130425-0700 - Added DROP option for survey_no_response_action to go to campaign drop method
# 130503-1509 - Added red color to server table on reports page if asterisk out of sync
# 130508-2306 - Branched 2.7, trunk becomes 2.8
# 130510-1350 - Added outbound state call time holidays functionality
# 130605-0841 - Converted ereg to preg
#             - Added display of agent login information on User Modify screen, and reset of failed_logins on update
# 130615-2124 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130627-0745 - Added url log, lagged log and user group login reports to admin utilities page
# 130709-1350 - Changes for encrypted password compatibility, added Dial Log Report
# 130711-2208 - Added SYSTEM SNAPSHOT STATS as new welcome screen, and added new 
# 130809-1410 - Small fixes for call times and holidays
# 130824-2319 - Changed to mysqli PHP functions
# 130915-0045 - Added counts for new nanpa prefix type tables
# 130926-1731 - Added queuemetrics_record_hold system setting
# 130928-1130 - Added country_code_list_stats system setting option
# 131003-1749 - Small fix for voicemail box duplication with phone account
# 131007-1234 - Fix for copy user on encrypted passwords systems
# 131016-2112 - Added manual_dial_lead_id campaign option, fixes some small issues
# 131019-0849 - Moved help section to help.php
# 131029-2008 - Added Asterisk auto-restart options to servers
# 131208-1626 - Added campaign options for max dead, dispo and pause time
# 131210-1741 - Added ability to define slave server with port number, issue #687
# 140108-0752 - Added webserver and hostname to report logging
# 140117-0840 - Added option for Lists Pass Report
# 140126-0939 - Added VMAIL_NO_INST options
# 140126-2253 - Added voicemail_instructions option for phones
# 140206-1357 - Filter dashes from new or copied campaigns and in-groups
# 140214-1643 - Added system settings dialplan reload timestamp
# 140302-0958 - Added Webserver-URL Report
# 140305-0846 - Bug fix for list modify admin logging issue
# 140313-0727 - Added links to Called Counts List IDs Report
# 140313-1014 - Added warning to in-groups if they are not set as allowed in any campaigns
# 140314-1134 - Added more strict enforcement of level 9 report and user permissions and definable max stats days
# 140404-1007 - Added new DID filter features for DNC matching and URL DID Redirects
# 140411-1434 - Added Performance Comparison Report
# 140418-0914 - Added users and campaigns max_inbound_calls
# 140423-1636 - Added campaign settings for manual_dial_search_checkbox and hide_call_log_info
# 140425-0906 - Added user permission for editing custom dialplan entries
# 140425-1257 - Added queuemetrics_pause_type system settings option, and added pause_type to agent logout
# 140509-2201 - Added frozen_server_call_clear system setting, used in admin.php and AST_timecheck.pl
# 140515-1610 - Added clear list option, Issue #763
# 140521-2101 - Added timer_alt_seconds and more Manual Auto Dial options
# 140612-2153 - branched 2.9 version, raised trunk to 2.10
# 140617-2017 - Added vicidial_users wrapup_seconds_override option
# 140621-2136 - Added DID pre-filter phone-group redirection and no-agent-ingroup redirection options
# 140623-2147 - Added wrapup_bypass and script_message changes
# 140625-1931 - Added wrapup_after_hotkey campaign option
# 140706-0829 - Incorporated QC includes into code
# 140706-0927 - Added callback_time_24hour system setting
# 140817-0928 - Added User Group report permission for the Front Page System Summary report
# 140822-1034 - Fixed minor voicemail chooser bug on DID modify page
# 140902-0816 - Added callback_active_limit and callback_active_limit_override
# 141111-0554 - Finalized adding QXZ translation to all admin files
# 141118-1541 - Added agent_email script and webform variable
# 141121-0116 - Added campaign options for comments and QC comment history display in agent screen
# 141124-2138 - Added show_previous_callback campaign option
# 141124-2226 - Added clear_script campaign option
# 141124-2352 - Allow spaces in user custom fields, issue #465
# 141128-0758 - Fixed carrier-related seccurity issue in carrier listings
# 141204-0559 - Fixed Contacts alt-db issue, Added user modify_languages user option and enable_languages system option
# 141211-1639 - Added cpd_unknown_action campaign option and na_call_url lists option
# 141212-0930 - Added selected_language,user_choose_language user options and language_method system option
# 141227-1008 - Trigger sounds update on voicemail server when phone record is updated
# 141229-1543 - Added code for on-the-fly language translations display
# 150101-1511 - Updated for 2015
# 150107-1938 - Added ignore_group_on_search user option
# 150111-1543 - Added Lists local call time option(Issue #812) and a campaign option for manual_dial_search_filter
# 150112-2005 - Added flag to delete voicemail greeting when changed from an audio file to empty
# 150114-2249 - Added Single Agent Daily Time report
# 150117-1416 - Added list local call time validation when calculating dialable
# 150117-1454 - Added NAME as status dialplay option
# 150119-0920 - Added more list local calltime safety, issue #812
# 150120-0749 - Prevent modification of user_group ID, Hide non-functional agent_extended_alt_dial campaign feature, Export Calls Report Carrier added
# 150210-0657 - Added LOCK options for manual_dial_search_checkbox campaign setting
# 150217-0702 - Added Show VM on Summary Screen option for phones and voicemail boxes
# 150218-0924 - Added link to callbacks bulk move, also now we will archive deleted callbacks
# 150302-0951 - Release of 2.11 stable branch and raising trunk to 2.12
# 150307-1914 - Added login and leave3way custom sounds system settings options
# 150313-0912 - Added DB Schema Version warning if mismatched with astguiclient.conf value
# 150404-0932 - Added enable_did_entry_list_id and related DID options
# 150421-2315 - Fixed bugs in allow_emails
# 150422-1953 - Don't allow dial_timeout of less than 4 seconds
# 150428-1705 - Added options for third webform
# 150429-1222 - Added new API user restrictions
# 150512-2225 - Fixed SQL for permissions
# 150603-2000 - Modified for chat settings
# 150608-1127 - Added manual dial filer and search options for ALT/ADDR3 numbers, Added manual dial override field campaign option
# 150609-1207 - Fixes for chat settings
# 150609-1216 - Added in-group and script display settings
# 150609-2142 - Changes for different types of in-groups
# 150610-0934 - Added customer_gone_seconds campaign setting
# 150701-1131 - Modified mysqli_error() to mysqli_connect_error() where appropriate
# 150703-2105 - Fixed field sizes in Issues #867 and #868
# 150706-0811 - Added user setting for lead_filter_id in no-hopper dialing
# 150708-2246 - Added max_queue_ingroup_ DID settings options
# 150710-1120 - Added options for alternate Dispo Call URLs
# 150717-1333 - Optimization for dialable lead count SQL
# 150724-0822 - Added agent_debug_logging SS option and report
# 150725-1341 - Added agent_display_fields campaign options
# 150727-0903 - Added default_language System Setting option
# 150728-1012 - Added $DB hidden variable in Filter Text form, Issue #845
# 150728-1048 - Added option for secondary sorting by vendor_lead_code, Issue #833
# 150804-1107 - Added agent_whisper_enabled system settings option
# 150804-1608 - Added inbound group _lead_reset options
# 150806-1348 - Added Admin -> Settings Containers
# 150903-1457 - Added options for encrypt hosted features
# 150909-0158 - Added Report Page Servers Summary and Admin Utilities Page options for User Group Allowed Reports
# 150909-1418 - Added $active_only_default_campaigns options.php option for Campaigns Listings
# 150915-2113 - Added x_ra_carrier module option
# 150917-1629 - Added more permission validation before deleting records, issue #893
# 150925-2126 - Added user_hide_realtime options
# 150927-0820 - Added did_carrier_description, sorting by columns in DID list page, integer sort for user list page
# 150928-1235 - Separated User Group permissions for Inbound Report report by in-group and by DID
# 150928-1817 - Added DNC logging and DNC phone number log search
# 151007-2224 - Added links and lists for DIDs and Call Menus in use in sections, Issue #835
# 151022-1404 - Added status groups admin, Added custom reports display and admin
# 151030-0636 - Added usacan_phone_dialcode_fix system setting option, executed by keepalive at timeclock end of day
# 151104-1518 - Added am_message_wildcards campaign option and amm-multi admin page
# 151124-1141 - Added cache_carrier_stats_realtime settings option
# 151125-0010 - Added oldest_logs_date display field to system settings
# 151203-2142 - Added links to search page from called counts within this list table of list modify page
# 151204-0615 - Added phone options to have call go to dialplan extension instead of voicemail if phone not answered
# 151211-0940 - Added phone options for NVA recording agi script
# 151216-1053 - Added links to Inbound Chat Report
# 151220-1545 - Added more phone NVA settings
# 151221-0750 - Changes to Chat In-group Modify page
# 151229-1653 - Added gather_asterisk_output server option
# 151229-2258 - Added campaign setting for manual_dial_timeout
# 151231-0009 - Fixed admin logging in several places
# 151231-0834 - Added agent_allowed_chat_groups to User Groups
# 160101-0928 - Added routing_initiated_recordings to in-group and campaign settings, and updated for 2016
# 160106-0751 - Added GROUP_AREACODE option to inbound did filters
# 160106-1342 - Added on_hook_cid_number setting to in-groups
# 160106-1733 - Fixed user modification issue with certain manager user settings
# 160108-2211 - Added manual_dial_hopper_check campaign option
# 160111-0626 - Fixed SQL issues with making changes, Issue #913
# 160116-1439 - Added options/permissions for accessing recordings and logging the access time
# 160122-1401 - Added report_default_format system setting, added agent count per server on reports page
# 160304-2348 - Added link to API log report
# 160305-2048 - Added alternate ivr(call menu) dtmf logging
# 160306-1053 - Added new webphone options, added option to have carriers on all active asterisk servers
# 160312-1931 - Added select/deselect all options to AC-CID modify page. Reworked max stats calculations
# 160313-0756 - Changed AC-CID changes to log to the same entry instead of one per record
# 160325-1435 - Changes for sidebar, added callback_useronly_move_minutes campaign feature
# 160327-0145 - Reworked System Summary Screen
# 160328-0316 - Added links to the real-time report from the summary screen
# 160330-1559 - Redesign of Admin sub-menu and added icons
# 160331-2204 - Made URL form input fields longer
# 160404-0940 - design changes
# 160414-1013 - Added default_phone_code to system_settings
# 160427-1656 - Added more detail on active servers column on reports page
# 160429-0835 - Added admin_row_click system settings option
# 160506-0644 - Fixed old mysql connector, issue #950
# 160508-1155 - Added screen colors admin section
# 160508-1948 - Changed lists view to default to not show leads counts, with link to click to show counts
# 160514-1437 - Added ofcom_uk_drop_calc option
# 160517-1927 - formatting fixes
# 160602-1450 - Hiding email group settings that are not needed
# 160611-2230 - Added diff to last change on admin change detail display
# 160621-1733 - Added agent_screen_colors and script_remove_js settings to system settings
# 160708-0745 - Added more Automatic Hopper Multiplier options, up to 4
# 160731-1026 - Added campaign option to automatically manual dial next number in agent	screen after X seconds
# 160801-2119 - Added Admin Bulk Tools page link from Admin Utilities page
# 160809-1339 - Added customer_chat_screen_colors, customer_chat_survey_link/text as Chat Groups options
# 160816-2113 - Added trim to transfer-conf numbers so they don't retain spaces at the beginning or end of the number
# 160827-0917 - Added the User Group Hourly Report
# 161014-0902 - Added List Merge utility and User List NEW Lead Limit options
# 161018-2249 - Added allow_required_fields campaign option
# 161021-1320 - Added Fronter - Closer Detail Report, Fixed admin logging bug
# 161028-1539 - Added agent_xfer_park_3way option to system settings and user groups
# 161029-2304 - Added rec_prompt_count display to system settings
# 161031-1415 - Added User Overall user_new_lead_limit
# 161102-1040 - Fixed QM partition problem
# 161103-2204 - Added web_loader_phone_length and agent soundboards
# 161106-2058 - Added agent_script
# 161113-0900 - Changed script_id to 20 characters max, other small script changes
# 161126-2157 - Release of 2.13 stable branch and raising trunk to 2.14
# 161128-1552 - Small fix for link on DID modify page with plus sign'+' in did pattern
# 161128-1746 - Updated 3 INSERT SQL queries to specify fields
# 161205-1650 - Added AGI container_type to settings containers
# 161207-1953 - Added Agent DID Report
# 161222-0841 - Added agent_chat_screen_colors
# 161226-2224 - Added conf_qualify servers option
# 170113-1637 - Added call menu in-group option DYNAMIC_INGROUP_VAR for use with cm_phonesearch.agi, and updated for 2017
# 170114-1356 - Added populate_lead_province in-group option
# 170118-0106 - Added OW options to populate_lead_province in-group option
# 170207-1317 - Added phone_number_log API function, added api_only_user User option
# 170211-1041 - Moved api_only_user option in User Modify screen
# 170217-1350 - Added dead_to_dispo campaign setting
# 170220-1209 - Added switch_lead Agent API function
# 170220-1632 - Added In-group areacode_filter feature
# 170221-1542 - Added more DNC options for campaign setting 'manual dial filter', added counts to DNC add/delete page
# 170223-0657 - Added warning for On Hold Message if too long, adjusted chooser placements
# 170226-0850 - Added recording override options to chat and email groups to disable recordings for those, issue #992
# 170227-2231 - Change to allow horizontal_bar_chart header to be translated, issue #991
# 170228-1621 - Changed emergency logout to hangup all agent session calls, and more logging
# 170304-1355 - Added Automated Reports section to Admin
# 170309-1209 - Added campaign agent_xfer_validation option and ingroup populate_state_areacode option
# 170311-0928 - Fixes for QC allowed campaign permissions, issue #1003
# 170313-1041 - Added CHAT options to inbound_queue_no_dial
# 170315-0633 - Fix in in-group copy SQL
# 170320-1340 - Added conf_qualify phones option for IAX
# 170321-1100 - Added pause code time limits warning feature
# 170327-0704 - Added Drop Lists section
# 170327-1655 - Added USER_CUSTOM_ options to campaign custom callerID setting
# 170330-0953 - Fixed translation phrases in callbacks list, issue #1006
# 170407-0744 - Added Agents count on server page
# 170409-0950 - Added IP Lists (white and black) functionality
# 170410-1326 - Added dl_minutes option for drop lists
# 170412-2222 - Added Agent Parked Call Report link in Admin Utilities
# 170416-1548 - Added ready_max_logout campaign/user setting and routing_prefix server setting
# 170425-1353 - Fixed issue with entries in this server lists
# 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
# 170527-0041 - Added filtering of browser details before logging
# 170529-2320 - Added agent events push settings
# 170609-1529 - Added ccc_lead_info API function
# 170613-0851 - Added hide_inactive_lists system settings option
# 170623-2142 - Changed parameters for password recommendations
# 170717-1444 - Fix for empty agent_choose_territories value
# 170816-1240 - Added in-group survey options
# 170818-0741 - Added User Group Hourly Report v2(detail)
# 170819-0949 - Added allow_manage_active_lists system setting
# 170821-2009 - Fix for issue #1036
# 170825-1708 - Added filename_override option for Automated Reports, added more space for report_times
# 170828-2105 - Added Inbound DID Summary Report
# 170913-0908 - Added Agent Inbound Status Summary Report
# 170920-2153 - Added expired_lists_inactive system setting and functions
# 170923-1425 - Added did_system_filter system setting and functions
# 170926-1618 - Fix for Test Call function for Asterisk 13
# 170930-0853 - Added extension_appended_cidname options and custom reports variable display
# 171001-1544 - Moved user IP Lists permissions to new security section in Modify User page
# 171005-1707 - Fix for remote agent modify overlap issue
# 171006-2039 - Added inbound list script override, Issue #1038
# 171011-1450 - Added webphone_layout option to phones and user groups
# 171018-1314 - Added scheduled_callbacks_email_alert campaign option
# 171018-2234 - Added server function to clear agent conferences
# 171028-0913 - Added Real-Time Whiteboard Report
# 171114-1100 - Fixed issue with admin log viewer for logs of modifications made by deleted users
# 171124-1041 - Added max_inbound_calls_outcome campaign setting
# 171124-1349 - Added manual_auto_next_options campaign setting
# 171126-1413 - Changes to allow for Email groups to display script tab on get_call_launch
# 171130-0036 - Added agent_screen_time_display campaign setting
# 171214-2045 - Added PREVIEW_ options for get_call_launch
# 171224-1220 - Added List default_xfer_group override
# 171229-2309 - Added housecleaning code
# 180108-2011 - Added next_dial_my_callbacks campaign option, updated for 2018
# 180109-1316 - Added call_status_stats API function
# 180111-1544 - Added anyone_callback_inactive_lists system setting
# 180130-2309 - Added inbound_no_agents_no_dial options
# 180204-0208 - Added In-Group Wait-Time option PRESS_CALLBACK_QUEUE, and Closing-Time options
# 180211-1024 - Changed campaign dial statuses to allow List and allowed In-Group selected status group statuses
# 180211-1126 - Added Outbound Lead Source Report
# 180213-0010 - Added GDPR system and user settings
# 180215-1318 - Added CID Groups admin screens
# 180216-1332 - Fix for system summary screen, issue #1068
# 180216-1743 - Many translation strings and permissions fixes, issue #1065
# 180217-0934 - Added NO_READY option for no_agent_no_queue in-group feature, issue #1046
# 180219-2204 - Fixed issue with CID Groups
# 180222-0017 - Added higher hopper level options
# 180306-1718 - Added script_top_dispo feature
# 180310-2230 - Added bulk change function for campaign and ingroup ranks in user modify page
# 180310-2321 - Added source_id_display system option
# 180316-0751 - Translated phrases fixes, issue #1081
# 180330-1425 - Added download of CID Group records feature
# 180331-1715 - Added update_did non-agent API function
# 180410-1600 - Added pause code manager approval settings
# 180411-1647 - Added DISPO_FILTER as Settings Container type
# 180424-1521 - Added in-group populate_lead_source, populate_lead_vendor settings
# 180430-1834 - Added in-group park_file_name override
# 180512-0852 - New AJAX-based help interface 
# 180512-2217 - Added users-max_hopper_calls,max_hopper_calls_hour settings
# 180516-1246 - Added waiting_call_url_ feature to In-Groups
# 180520-1749 - Added enter_ingroup_url feature to In-Groups
# 180530-0017 - Small DID bug fix, added Call Menus list on Modify Call Time page
# 180610-2309 - Added Campaign settings for Dead Call Triggers
# 180613-0943 - Fix for issue #1108
# 180618-2300 - Modified calls to audio file chooser function
# 180806-0752 - Added link to Callmenu Survey Report, Added fields for In-Group Callback CID features
# 180807-0958 - Added change for admin change log for Admin Modify Lead to better show lead changes
# 180807-1653 - Added agent_logout_link credentials setting to System Settings
# 180809-1547 - Added scheduled_callbacks_force_dial campaign setting
# 180812-0902 - Added scheduled_callbacks_auto_reschedule campaign setting
# 180825-2100 - Added scheduled_callbacks_timezones_container campaign setting and timezones display
# 180904-1206 - Added copying of in-group user grades/ranks when copying an in-group
# 180908-1618 - Added force_fronter_leave_3way API function
# 180916-0824 - Added daily_reset_limit Lists feature(level 9 users only)
# 180922-0958 - Added copying of user selected in-groups in copying of an in-group
# 180923-2226 - Added three_way_volume_buttons campaign setting
# 180924-1731 - Added callback_dnc campaign setting
# 180927-0018 - Added _wait_time options for next agent call options in campaigns and in-groups
# 181003-1619 - Added external_web_socket_url server setting
# 181005-1738 - Added SYSTEM to Manual Dial Filter campaign options
# 181116-1133 - Fix for DID server IP de-assignment
# 190108-0806 - Added manual_dial_validation system and campaign options, update date for 2019
# 190121-2019 - Added RA_AGENT_PHONE on-hook agent option
# 190207-2301 - Fix for user-group, in-group and campaign allowed/permissions matching issues
# 190221-1831 - Added force_fronter_audio_stop API function
# 190223-0850 - Added static prompt fields for in-group play-place-in-line
# 190302-1745 - Added disclaimers for pure-knob code
# 190310-1909 - Added mute_recordings system setting and campaign/user options
# 190311-2153 - Added indicators for lists being assigned to non-existing campaigns
# 190312-0928 - Added more hide_call_log_info options
# 190327-2311 - Added READ_ONLY settings container type
# 190329-1909 - Added AMD Log Report
# 190406-1437 - Added user override option for next_dial_my_callbacks
# 190414-0924 - Added user_admin_redirect system setting and user option
# 190530-1014 - Added list_status_modification_confirmation feature
# 190530-1715 - Added sip_event_logging system setting
# 190607-1525 - Added SIP Event Report link
# 190627-1528 - Added new options for campaign agent_screen_time_display setting
# 190628-0835 - Added copying/deleting of vicidial_url_multi records when copying/deleting campaigns/in-groups
# 190628-1511 - Added API update_cid_group_entry function
# 190705-1012 - Added call_quota_lead_ranking settings
# 190722-1602 - Added ENABLED_EXTENDED_RANGE Agent Screen Time campaign option
# 190724-1603 - Added sip_event_logging campaign actions
# 190902-0839 - Fixes for PHP 7.2
# 190930-2110 - More PHP7 fixes
# 191014-1816 - Additional PHP7 fixes
# 191015-1620 - Added user inbound call count filters
# 191101-1149 - Added 2nd script tab, voicemail message groups and fixed translation issues
# 191106-0934 - Added several multi-campaign options to the add/delete DNC number page
# 191107-1150 - Added list_info as API function option
# 191107-2356 - Added Dial Timeout Lead Container functionality
# 191111-0833 - Added LTMGAD/XAMMAD Hotkey options
# 191111-1601 - Added additional user status group setting(status_group_id)
# 191113-1751 - Added add_dnc_phone add_fpg_phone API functions
# 191114-0923 - Added enable_first_webform and recording_buttons system settings
# 191121-2256 - Extended survey audio file lengths
# 191230-1001 - Added Voicemail Message Daily Limit
# 200108-0937 - Added CID Group Type of NONE, update date for 2020
# 200115-1702 - Added Caller ID Log Report to Admin Utilities
# 200122-0921 - Added CID Group auto-rotate feature settings
# 200127-1620 - Changes to HELP content
# 200204-2336 - Added opensips_cid_name settings
# 200206-2154 - Added require_password_length system setting and display of password length in modify pages
# 200210-1628 - Added link for KHOMP Admin Tool in admin utilities
# 200310-0946 - Added AGENT_PHONE_OVERRIDE campaign option, and amd_agent_route_options
# 200315-1126 - Added a SKIP option for the CID Group auto-rotate feature
# 200318-1330 - Added a default bgcolor to the servers table on the Reports page, Issue #1203
# 200327-1715 - Translation fixes
# 200331-1148 - Added list_custom_fields API function, and more translation fixes
# 200401-1448 - Added email_agent_login_link.php feature
# 200405-1805 - Added entries_per_page system setting option, fixed phone relocate conf file load issue
# 200405-2339 - Added warnings for inactive voicemail server
# 200406-0033 - Fix for Remote Agents where user deleted
# 200406-2319 - Small changes to entries_per_page display(w/ display all), also added it for DIDs
# 200407-1030 - Added browser_call_alerts system setting
# 200409-1719 - Reorganized Inbound admin section
# 200425-0949 - Added 2nd option for agentcall_manual to disable FAST DIAL
# 200508-1024 - Added feature to Call Menus to allow copying of previous option
# 200518-0828 - Fixed issue with Carrier custom dialplan allowing comments';'
# 200528-2126 - Added three_way_record_stop_exception campaign option
# 200601-2129 - Added link for Auto Reports FTP server if using SFTP or FTPSSL
# 200609-2257 - Added NONE_ options for the campaign manual_dial_filter
# 200619-1643 - Added queuemetrics_pausereason system settings option
# 200623-1957 - Added inbound answer configuration
# 200624-1939 - Added Callbacks Export report
# 200701-1525 - Added more concurrent_transfers options
# 200708-1033 - Added List overrides for some inbound settings
# 200711-1822 - Added EVERY_NEW_ADMINCALL option for QM PAUSEREASON system setting
# 200719-1645 - Added EVERY_NEW_ALLCALL option for QM PAUSEREASON system setting
# 200814-2249 - Added International DNC scrub options
# 200815-0015 - Added another modify_leads option for users
# 200816-0912 - Removed the ability to delete the 'default' DID entry
# 200912-1649 - Added more get_call_launch PREVIEW_ options
# 200913-0820 - Added UNSELECTED options for campaign alt_number_dialing
# 200916-0922 - Added more modify_leads options for users(modify log statuses)
# 200922-0924 - Added web_loader_phone_strip & manual_dial_phone_strip system settings
# 201002-1534 - Allowed for secure sounds_web_server setting
# 201004-1045 - Added campaign pause_max_exceptions setting, also fix for issue #1235
# 201101-1056 - Added In-Group setting for No-Agent-No-Queue delay
# 201106-2324 - Fix for issue with populate_lead_source menu
# 201111-1258 - Added campaigns hopper_drop_run_trigger setting
# 201111-1616 - Fix for CID Groups permissions issue #1234
# 201113-0754 - Changed Modify DID page variable population
# 201118-1057 - Better compatibility with non-latin data input
# 201123-2300 - Added daily_call_count_limit features
# 201201-1944 - Added transfer_button_launch campaign feature
# 201214-1545 - Fixes for PHP8 compatibility
# 210102-1651 - Added SHARED agent features for outbound dialing campaigns
# 210103-0856 - Added agent_search_method override settings
# 210124-0947 - Added copy_user Non-Agent API function
# 210207-0915 - Added Shared Debug Page to admin utilities
# 210210-1601 - Added add_did Non-Agent API function
# 210211-1145 - Added Matex use information
# 210226-1545 - Added Copy Phone functionality
# 210227-1126 - Variable filter changes
# 210302-1032 - Changed Logout to auto-logout through AJAX, with redirect to Admin Home URL
# 210304-1615 - Added User modify_leads = 5 option, for READONLY
# 210305-2159 - Added Default Phone Fields, Changed CLEAR LIST to remove custom fields for removed leads
# 210306-0840 - Added new QC module with QC scorecards, Quality Control Report, Settings Compare Utility
# 210309-2207 - Added Inbound main panel sub-links, fixed System Settings modify SQL
# 210312-1239 - Added Two-Factor Authentication system, Added mobile_number to User Modify screen
# 210312-1456 - Small change to Copy User page
# 210314-0919 - Added more enhanced_disconnect_logging options in System Settings
# 210315-1730 - Added clear_form campaign option, Issue #1179
# 210315-2118 - Added new manual_dial_filter CALLBACK options, Issue #1139
# 210316-0923 - Small fix for 2FA consistency
# 210317-0819 - Added lead_all_info Non-Agent API function, Changed lead-modify page links to javascript because of Chrome
# 210317-1211 - Fixes for better consistency in password change process, Issue #1261
# 210317-1736 - Added the ability to see orphan Remote Agent entries(with no valid User account)
# 210317-2329 - Added system settings for agent_hidden_sound and added more browser_alert_sounds
# 210321-0120 - Added classAudioFile PHP library
# 210324-0954 - Added leave_3way_start_recording campaign options
# 210325-2220 - Added populate_lead_comments in-group option
# 210406-1821 - Added hopper_drop_run_trigger_all option, moved dialable_leads function to functions.php
# 210417-1027 - Added calls_waiting_vl_X campaign settings
# 210421-2227 - Added more screen labels for non-form fields
# 210425-1506 - Added calls_inqueue_count_ campaign options
# 210429-1624 - Added mohsuggest phone config option
# 210519-1747 - Fix for Copy Phone conf rebuild, Require prompt be populated on Call Menu creation and modification
# 210608-2108 - Added In-Group Drop Seconds Override Container and Inbound Manual Dial Agent Forced Ready features
# 210615-1108 - Default security fixes, CVE-2021-28854
# 210624-1243 - Fix for Copy Phone issue
# 210702-0848 - Added transfer_no_dispo campaign setting
# 210705-1037 - Added User override for campaign manual_dial_filter setting
# 210706-0128 - Added display of Call Time Holidays to the agent screen Scheduled Callbacks calendar
# 210707-0731 - Added display of phone codes and postal codes, linked from System Settings page
# 210712-1733 - Allow brackets and spaces in Filter Phone Group numbers([ ])
# 210715-1248 - Added call_limit_24hour campaign settings
# 210729-2127 - Added CID Group Failover campaign setting(cid_group_id_two)
# 210804-0712 - Fix for closing time action issue #1321
# 210812-1609 - Added 'Phone Stats' to report permissions list
# 210827-0753 - Added allowed_sip_stacks system setting and PJSIP Phone and Carrier options
# 210901-2051 - Fix for User Modify page issue
# 210907-1901 - Added new OWNERCUSTOMx handle methods for menu options
# 210911-1958 - Added populate_lead_owner in-group option
# 210920-2159 - Added batch_update_lead API function
# 211012-0934 - Added incall_tally_threshold_seconds campaign feature
# 211027-1031 - Added lead_search Non-Agent API function
# 211106-1500 - Added In-Group in_queue_nanque settings
# 211208-1646 - Added user_location to User Modify page, Added Queue Groups to Admin pages
# 211213-1619 - Fix for new phone inserts template_id issue on some MySQL setups
# 211214-1157 - Fix for Queue Groups link issue #1343
# 211215-1806 - Added some User Group settings
# 211217-0732 - Fixes for PHP8, issue #1341
# 220118-1944 - Added auto_alt_threshold option for campaigns and override option for lists
# 220120-0902 - Added download_invalid_files user option
# 220122-1659 - Added more variable filtering, updated copyright year to 2022
# 220127-2915 - Added update_alt_url Non-Agent API function
# 220212-0758 - Added pause_max_url campaign setting
# 220215-1011 - Fix for XSS multi-script security issue
# 220215-1431 - Additional XSS script text variable filtering
# 220217-1727 - Added agent_hide_hangup system and campaign settings
# 220217-2022 - Added input variable filtering
# 220218-1656 - Added allow_web_debug system setting to disable $DB output by default
# 220307-1151 - Added 'update_presets' Non-Agent API function
# 220310-1007 - Added STAGING option for campaign presets
# 220311-0808 - Added List setting for Campaign CID Group Override
# 220312-0937 - Added vicidial_dial_cid_log logging
# 220328-1420 - Disallow adding 'INCALL','QUEUE' statuses in Auto-Alt-Dial and Lead Recycling
# 220429-1111 - Code cleanup and more optional DB output for queries
# 220506-0905 - Added ig_xfer_list_sort campaign setting
# 220510-0822 - Added pre_filter_recent_call DID settings and Inbound DID Detail Report
# 220510-1617 - Added script_tab_frame_size campaign setting
# 220513-0819 - Added user_group_two to User Modify screen
# 220623-0824 - Added max_logged_in_agents campaign/system settings and dial_prefix list setting
# 220730-0859 - Added user_codes_admin user/system setting
# 220811-0854 - Added webphone inticator"(w)" to Phone Listing page
# 220824-1452 - Fix for Script override input variable filtering issues
# 220827-0855 - Added BETA support for ConfBridge in Servers and Conferences
# 220829-1036 - Added testing code for VERM(VICIdial Enhanced Reporting Module)
# 220831-0850 - Added Campaign user_group_script override option, with User Group script option
# 220921-1319 - Added more User failed login details for level 9 users
# 221017-0822 - Fix for Copy Carrier issue #1384
# 221020-1632 - Added login_kickall system setting
# 221021-1038 - Added webphone_settings option to phones, pointed to a settings container
# 221214-1153 - Added $HTMLcolors validation for color form entry fields
# 221230-2231 - Added Postal Codes Cities display
# 230117-0838 - Added Agent Call Hangup Routing options, changed year to 2023
# 230204-1642 - Added No Agent Call URL "ALT" multi-url options
# 230227-1150 - Updated VERM code and notices
# 230306-1336 - Added 20Hz_tone browser sound, Issue #1448
# 230306-2050 - Added setTimeoutAudioLoop agent_screen_timer option, Issue #1448
# 230311-0859 - Added abandon_check_queue system setting, ara_url server option and show_confetti campaign feature
# 230312-2212 - Fix for webphone_settings issue #1451
# 230407-1038 - Added VERM report links to main admin Reports page
# 230412-0946 - Added send_notification Agent-API function, agent_notifications system_setting
# 230421-0847 - Added Agent Latency Report
# 230421-1739 - Fix for QC issue #1352
# 230515-1621 - Added demographic_quotas system setting and cammpaign options and DEMOGRAPHIC_QUOTAS container, Latency Gaps Report
# 230518-0908 - Added in-group and campaign custom fields 1-5, for script/webform/dispo-call-url use
# 230522-0903 - Added modify_dial_prefix user setting
# 230523-0832 - Added inbound_credits user setting
# 230524-1742 - Added weekday_resets settings
# 230607-0918 - Added second_alert_trigger settings
# 230612-0752 - Added VIDPROMPTSPECIAL... Call Menu In-Group routing feature, Added CM_VIDPROMPT_SPECIAL Container Type
# 230615-0849 - Added dead_stop_recording campaign option
# 230621-0114 - Added missing API functions to the permissions list
# 230726-0922 - Added manual_vm_status_updates campaign setting
# 230810-1617 - Added force_per_call_notes campaign setting
# 230810-2005 - Added third_alert_trigger features
# 230830-1059 - Changed settings-outbound_calls_per_second max to allow up to 1000 CPS
# 230926-0849 - Added camp_lead_order_random options.php setting
# 230927-0857 - Added agent_search_ingroup_list campaign and agent_search_list ingroup options
# 231109-0904 - Added two_factor_auth_agent_hours system setting
# 231109-2027 - Added lead_dearchive API function
# 231115-1636 - Added vm_view_messages_link options.php setting, hopper_hold_inserts system and campaign settings
# 231119-1520 - Added hci_enabled user setting
# 231129-0936 - Added daily_phone_number_call_limit campaign setting
# 231129-1541 - Added refresh_panel Agent API function
# 231204-0858 - Added Agent LAGGED Summary Report
# 231227-2217 - Added 3-Way Press Log Report
# 240214-2120 - Added STATE_DESCRIPTIONS container type and state_descriptions campaign and in-group settings, change year to 2024
# 240221-0331 - Changes for in-group daily limits, small changes for stats_descriptions
# 240223-0854 - Added INBOUND_DID In-Group populate option
# 240225-0933 - Added the AUTONEXT hopper_hold_inserts campaign option
# 240226-2128 - Fix for READ_ONLY settings container type
# 240227-1127 - Added holiday_method option
# 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
# 240419-1817 - Added call_log_days campaign option
# 240516-1720 - Added ALT option for start_call_url fields
# 240528-1722 - Added display of Dial Prefixes column on the CAMPAIGH LISTINGS page
# 240617-0833 - Fix for 2FA user override
# 240627-1950 - Added leave_3way_stop_recording campaign setting
# 240703-1758 - Added update_remote_agent Non-Agent API function
# 240704-0944 - Added coldstorage database connection fields to system_settings
# 240706-2332 - Added DB Schema Compare Utility
# 240716-1453 - Small header fixes
# 240730-1829 - Changes for PHP8 compatibility, added copy_did Non-Agent API function
# 240805-1738 - Added DID listing display filter
# 240824-1629 - Added user_details Non-Agent API function
# 240826-0918 - Added mnaual dial minimum campaign settings
# 241001-1532 - Added Khomp Quick Stats Report
# 241021-2138 - Added Khomp campaign settings option
# 241113-2002 - Added update timestamps for sub-settings groups(like campaigns)
# 241206-1527 - Do not display inactive VDAD/VDCL users in Copy User screen
# 241208-1747 - Changed DID filter_phone_group_id & pre_filter_phone_group_id to multi-selects
# 250103-0843 - Added Enhanced Agent Monitoring system settings option, Changed copyright date
# 250210-1701 - Fix for PHP8 issue on User Modify page
# 250227-1607 - Fix for test call phone code issue (PHP8-related)
# 250326-2023 - Added agent_hide_dial_fail system_settings feature
# 250424-0715 - Fix for modify IP Lists screen permissions issue
# 250620-1001 - Added apinewlead options for system settings and lists
# 250722-1546 - Added hopper_bulk_insert non-agent API function
# 250806-0841 - Added manual_dial_lead_id user setting, and new 'ONLY' option for campaign setting
# 250808-1120 - Added agent_man_dial_filter & agent_3way_dial_filter system settings
# 250822-2056 - Added system/campaign/ingroup settings for stereo_recording
# 250922-0841 - Added Talk Seconds URL links to multi-url admin page in campaigns and in-groups
# 251002-1428 - Added call_count_limit_restrict campaign setting
#

# 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-945a';
$build = '251002-1428';

$STARTtime = date("U");
$SQLdate = date("Y-m-d H:i:s");
$REPORTdate = date("Y-m-d");
$EXPtestdate = date("Ymd");
$CIDdate = date("mdHis");
$dateint = date("YmdHis");
while (strlen($CIDdate) > 9) {$CIDdate = substr("$CIDdate", 1);}

$MT[0]='';
$US='_';
$active_lists=0;
$inactive_lists=0;
$modify_refresh_set=0;
$modify_footer_refresh=0;
$check_time = ($STARTtime - 86400);
$SSanswer_transfer_agent =	'8368';
$add_copy_disabled=0;
$camp_lead_order_random=1;
$vm_view_messages_link='';
$stereo_dev_mode=1;

$month_old = mktime(0, 0, 0, date("m")-1, date("d"),  date("Y"));
$past_month_date = date("Y-m-d H:i:s",$month_old);
$week_old = mktime(0, 0, 0, date("m"), date("d")-7,  date("Y"));
$past_week_date = date("Y-m-d H:i:s",$week_old);

$dtmf[0]='0';				$dtmf_key[0]='0';
$dtmf[1]='1';				$dtmf_key[1]='1';
$dtmf[2]='2';				$dtmf_key[2]='2';
$dtmf[3]='3';				$dtmf_key[3]='3';
$dtmf[4]='4';				$dtmf_key[4]='4';
$dtmf[5]='5';				$dtmf_key[5]='5';
$dtmf[6]='6';				$dtmf_key[6]='6';
$dtmf[7]='7';				$dtmf_key[7]='7';
$dtmf[8]='8';				$dtmf_key[8]='8';
$dtmf[9]='9';				$dtmf_key[9]='9';
$dtmf[10]='HASH';			$dtmf_key[10]='#';
$dtmf[11]='STAR';			$dtmf_key[11]='*';
$dtmf[12]='A';				$dtmf_key[12]='A';
$dtmf[13]='B';				$dtmf_key[13]='B';
$dtmf[14]='C';				$dtmf_key[14]='C';
$dtmf[15]='D';				$dtmf_key[15]='D';
$dtmf[16]='TIMECHECK';		$dtmf_key[16]=_QXZ('TIMECHECK');
$dtmf[17]='TIMEOUT';		$dtmf_key[17]=_QXZ('TIMEOUT');
$dtmf[18]='INVALID';		$dtmf_key[18]=_QXZ('INVALID');
$dtmf[19]='INVALID_2ND';	$dtmf_key[19]=_QXZ('INVALID_2ND');
$dtmf[20]='INVALID_3RD';	$dtmf_key[20]=_QXZ('INVALID_3RD');

$stmt="SELECT selected_language,user_admin_redirect_url 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];
	$VUuser_admin_redirect_url = $row[1];
	}

if ($force_logout)
	{
	if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) )
		{
		if ($SStwo_factor_auth_hours > 0)
			{
			$stmt="UPDATE vicidial_two_factor_auth SET auth_stage='2' where user='$PHP_AUTH_USER' and auth_stage='1';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		echo "<html>\n";
		echo "<head>\n";
		echo "<!-- Logout screen $PHP_SELF -->\n";
		echo "<META NAME=\"ROBOTS\" CONTENT=\"NONE\">\n";
		echo "<META NAME=\"COPYRIGHT\" CONTENT=\"&copy; 2025 ViciDial Group\">\n";
		echo "<META NAME=\"AUTHOR\" CONTENT=\"ViciDial Group\">\n";
		?>
		<script type="text/javascript">

		function ajax_logout_now() 
			{
			var xmlhttp=false;
			/*@cc_on @*/
			/*@if (@_jscript_version >= 5)
			// JScript gives us Conditional compilation, we can cope with old IE versions.
			// and security blocked creation of the objects.
			 try {
			  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			 } catch (e) {
			  try {
			   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			  } catch (E) {
			   xmlhttp = false;
			  }
			 }
			@end @*/
			if (!xmlhttp && typeof XMLHttpRequest!='undefined')
				{
				xmlhttp = new XMLHttpRequest();
				}
			if (xmlhttp) 
				{ 
				logout_query = "ADD=999999";
				xmlhttp.open('POST', 'admin.php',false,'AJAXviciLOGOUT','1234'); 
				xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
				xmlhttp.send(logout_query); 
				xmlhttp.onreadystatechange = function()
					{ 
					if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
						{
						var check_logout = null;
						check_logout = xmlhttp.responseText;
						alert(xmlhttp.responseText + "\n|" + check_DS_array[1] + "\n|" + check_DS_array[2] + "|");
						}
					}
				delete xmlhttp;
				}
			window.document.location='<?php echo $SSadmin_home_url ?>';
			}
		</script>
	<?php
		echo "</head>\n";
		echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 onload=\"ajax_logout_now();\">\n";

	#	Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\"");
	#	Header("HTTP/1.0 401 Unauthorized");
		}
	echo _QXZ("You have now logged out. Thank you")."\n<BR>"._QXZ("To log back in").", <a href=\"$PHP_SELF\">"._QXZ("click here")."</a>";
	exit;
	}
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,auto_dial_limit,user_territories_active,allow_custom_dialplan,callcard_enabled,admin_modify_refresh,nocache_admin,webroot_writable,allow_emails,manual_dial_validation FROM system_settings;";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
	{
	$row=mysqli_fetch_row($rslt);
	$non_latin =					$row[0];
	$SSauto_dial_limit =			$row[1];
	$SSuser_territories_active =	$row[2];
	$SSallow_custom_dialplan =		$row[3];
	$SScallcard_enabled =			$row[4];
	$SSadmin_modify_refresh =		$row[5];
	$SSnocache_admin =				$row[6];
	$SSwebroot_writable =			$row[7];
	$SSemail_enabled =				$row[8];
	$SSmanual_dial_validation =		$row[9];

	# slightly increase limit value, because PHP somehow thinks 2.8 > 2.8
	$SSauto_dial_limit = ($SSauto_dial_limit + 0.001);
	}
##### END SETTINGS LOOKUP #####
###########################################

$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");

$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(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 1 and qc_enabled='1' and api_only_user != '1';";
	if ($DB) {echo "|$stmt|\n";}
	$rslt=mysql_to_mysqli($stmt, $link);
	$row=mysqli_fetch_row($rslt);
	$qc_auth=$row[0];

	$reports_only_user=0;
	$qc_only_user=0;
	if ( ($reports_auth > 0) and ($auth < 1) )
		{
		$ADD=999999;
		$reports_only_user=1;
		}
	if ( ($qc_auth > 0) and ($reports_auth < 1) and ($auth < 1) )
		{
		if ( ($ADD != '881') and ($ADD != '100000000000000') )
			{
            $ADD=100000000000000;
			}
		$qc_only_user=1;
		}
	if ( ($qc_auth < 1) and ($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 ( (strlen($VUuser_admin_redirect_url) > 5) and ($SSuser_admin_redirect > 0) )
		{
		Header('Location: '.$VUuser_admin_redirect_url);
		echo"<TITLE>"._QXZ("Admin Redirect")."</TITLE>\n";
		echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
		echo"<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=$VUuser_admin_redirect_url\">\n";
		echo"</HEAD>\n";
		echo"<BODY BGCOLOR=#FFFFFF marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
		echo"<a href=\"$VUuser_admin_redirect_url\">"._QXZ("click here to continue").". . .</a>\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;
	}

$admin_lists_custom = 'admin_lists_custom.php';
$x_ra_carrier = 0;
if (preg_match("/x_ra_carrier/",$SSactive_modules))
	{$x_ra_carrier = 1;}

##############################################
# Include QC Agents with no other permission #
##############################################
//Get QC User permissions
$stmt="SELECT qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit from vicidial_users where user='$PHP_AUTH_USER' and user_level > 1 and active='Y' and qc_enabled='1';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$qc_auth=$row[0];
//Not "qc_" as it will interfere with ADD=4A storage of modified user.
if ($qc_auth=='1') 
	{
    $qcuser_level=$row[1];
    $qcpass=$row[2];
    $qcfinish=$row[3];
    $qccommit=$row[4];
	}
//Modify menuing to allow qc users into the system (if they have no permission otherwise)
//Copied Reports-Only user setup for QC-Only user (Poundteam QC setup)
$qc_only_user=0;
if ( ($qc_auth > 0) and ($auth < 1) )
        {
        if ($ADD != '881')
			{
			$ADD=100000000000000;
		   }
        $qc_only_user=1;
        }

$stmt="SELECT user_id,user,pass,full_name,user_level,user_group,phone_login,phone_pass,delete_users,delete_user_groups,delete_lists,delete_campaigns,delete_ingroups,delete_remote_agents,load_leads,campaign_detail,ast_admin_access,ast_delete_phones,delete_scripts,modify_leads,hotkeys_active,change_agent_campaign,agent_choose_ingroups,closer_campaigns,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,delete_filters,alter_agent_interface_options,closer_default_blended,delete_call_times,modify_call_times,modify_users,modify_campaigns,modify_lists,modify_scripts,modify_filters,modify_ingroups,modify_usergroups,modify_remoteagents,modify_servers,view_reports,vicidial_recording_override,alter_custdata_override,qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit,add_timeclock_log,modify_timeclock_log,delete_timeclock_log,alter_custphone_override,vdc_agent_api_access,modify_inbound_dids,delete_inbound_dids,active,alert_enabled,download_lists,agent_shift_enforcement_override,manager_shift_enforcement_override,shift_override_flag,export_reports,delete_from_dnc,email,user_code,territory,allow_alerts,callcard_admin,force_change_password,modify_shifts,modify_phones,modify_carriers,modify_labels,modify_statuses,modify_voicemail,modify_audiostore,modify_moh,modify_tts,modify_contacts,modify_same_user_level,alter_admin_interface_options,modify_custom_dialplans,modify_languages,selected_language,user_choose_language,modify_colors,api_only_user,modify_auto_reports,modify_ip_lists,export_gdpr_leads,mobile_number,two_factor_override,modify_dial_prefix,hci_enabled from vicidial_users where user='$PHP_AUTH_USER';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$LOGfull_name				=$row[3];
$LOGuser_level				=$row[4];
$LOGuser_group				=$row[5];
$LOGdelete_users			=$row[8];
$LOGdelete_user_groups		=$row[9];
$LOGdelete_lists			=$row[10];
$LOGdelete_campaigns		=$row[11];
$LOGdelete_ingroups			=$row[12];
$LOGdelete_remote_agents	=$row[13];
$LOGload_leads				=$row[14];
$LOGcampaign_detail			=$row[15];
$LOGast_admin_access		=$row[16];
$LOGast_delete_phones		=$row[17];
$LOGdelete_scripts			=$row[18];
$LOGmodify_leads			=$row[19];
$LOGdelete_filters			=$row[29];
$LOGalter_agent_interface	=$row[30];
$LOGdelete_call_times		=$row[32];
$LOGmodify_call_times		=$row[33];
$LOGmodify_users			=$row[34];
$LOGmodify_campaigns		=$row[35];
$LOGmodify_lists			=$row[36];
$LOGmodify_scripts			=$row[37];
$LOGmodify_filters			=$row[38];
$LOGmodify_ingroups			=$row[39];
$LOGmodify_usergroups		=$row[40];
$LOGmodify_remoteagents		=$row[41];
$LOGmodify_servers			=$row[42];
$LOGview_reports			=$row[43];
$LOGmodify_dids				=$row[56];
$LOGdelete_dids				=$row[57];
$LOGmanager_shift_enforcement_override=$row[61];
$LOGexport_reports			=$row[64];
$LOGdelete_from_dnc			=$row[65];
$LOGemail					=$row[66];
$LOGcallcard_admin			=$row[70];
$LOGforce_change_password	=$row[71];
$LOGmodify_shifts			=$row[72];
$LOGmodify_phones			=$row[73];
$LOGmodify_carriers			=$row[74];
$LOGmodify_labels			=$row[75];
$LOGmodify_statuses			=$row[76];
$LOGmodify_voicemail		=$row[77];
$LOGmodify_audiostore		=$row[78];
$LOGmodify_moh				=$row[79];
$LOGmodify_tts				=$row[80];
$LOGmodify_contacts			=$row[81];
$LOGmodify_same_user_level	=$row[82];
$LOGalter_admin_interface	=$row[83];
$LOGmodify_custom_dialplans =$row[84];
$LOGmodify_languages		=$row[85];
$LOGselected_language		=$row[86];
$LOGuser_choose_language	=$row[87];
$LOGmodify_colors			=$row[88];
$LOGapi_only_user			=$row[89];
$LOGmodify_auto_reports		=$row[90];
$LOGmodify_ip_lists			=$row[91];
$LOGexport_gdpr_leads		=$row[92];
$LOGmobile_number			=$row[93];
$LOGtwo_factor_override		=$row[94];
$LOGmodify_dial_prefix		=$row[95];
$LOGhci_enabled				=$row[96];

$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times,qc_allowed_campaigns,qc_allowed_inbound_groups,reports_header_override,admin_home_url,allowed_queue_groups from vicidial_user_groups where user_group='$LOGuser_group';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$LOGallowed_campaigns =			$row[0];
$LOGallowed_reports =			$row[1];
$LOGadmin_viewable_groups =		$row[2];
$LOGadmin_viewable_call_times =	$row[3];
$LOGqc_allowed_campaigns =		$row[4];
$LOGqc_allowed_inbound_groups =	$row[5];
$LOGreports_header_override	=	$row[6];
$LOGadmin_home_url =			$row[7];
$LOGallowed_queue_groups	=	$row[8];

if (strlen($LOGadmin_home_url) > 5) {$SSadmin_home_url = $LOGadmin_home_url;}
$LOGallowed_campaignsSQL='';
$notLOGallowed_campaignsSQL = "and campaign_id IN('')";
$campLOGallowed_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')";
	$notLOGallowed_campaignsSQL = "and campaign_id NOT IN('$rawLOGallowed_campaignsSQL')";
	$campLOGallowed_campaignsSQL = "and camp.campaign_id IN('$rawLOGallowed_campaignsSQL')";
	$whereLOGallowed_campaignsSQL = "where campaign_id IN('$rawLOGallowed_campaignsSQL')";
	}
$regexLOGallowed_campaigns = " $LOGallowed_campaigns ";

if (preg_match("/DRA/",$SShosted_settings))
	{$LOGmodify_remoteagents=0;}

$admin_viewable_groupsALL=0;
$LOGadmin_viewable_groupsSQL='';
$whereLOGadmin_viewable_groupsSQL='';
$valLOGadmin_viewable_groupsSQL='';
$vmLOGadmin_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')";
	$valLOGadmin_viewable_groupsSQL = "and val.user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')";
	$vmLOGadmin_viewable_groupsSQL = "and vm.user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')";
	}
else 
	{$admin_viewable_groupsALL=1;}
$regexLOGadmin_viewable_groups = " $LOGadmin_viewable_groups ";

$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')";
	}
$regexLOGadmin_viewable_call_times = " $LOGadmin_viewable_call_times ";

$UUgroups_list='';
if ($admin_viewable_groupsALL > 0)
	{$UUgroups_list .= "<option value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";}
$stmt="SELECT user_group,group_name from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$UUgroups_to_print = mysqli_num_rows($rslt);
$o=0;
while ($UUgroups_to_print > $o) 
	{
	$rowx=mysqli_fetch_row($rslt);
	$UUgroups_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
	$o++;
	}

$LOGqc_allowed_campaignsSQL='';
$whereLOGqc_allowed_campaignsSQL='';
if ( (!preg_match('/\-ALL/i', $LOGqc_allowed_campaigns)) )
	{
	$rawLOGqc_allowed_campaignsSQL = preg_replace("/ -/",'',$LOGqc_allowed_campaigns);
	$rawLOGqc_allowed_campaignsSQL = preg_replace("/ /","','",$rawLOGqc_allowed_campaignsSQL);
	$LOGqc_allowed_campaignsSQL = "and campaign_id IN('$rawLOGqc_allowed_campaignsSQL')";
	$whereLOGqc_allowed_campaignsSQL = "where campaign_id IN('$rawLOGqc_allowed_campaignsSQL')";
	}

$LOGqc_allowed_inbound_groupsSQL='';
$whereLOGqc_allowed_inbound_groupsSQL='';
if ( (!preg_match('/\-ALL/i', $LOGqc_allowed_inbound_groups)) )
	{
	$rawLOGqc_allowed_inbound_groupsSQL = preg_replace("/ -/",'',$LOGqc_allowed_inbound_groups);
	$rawLOGqc_allowed_inbound_groupsSQL = preg_replace("/ /","','",$rawLOGqc_allowed_inbound_groupsSQL);
	$LOGqc_allowed_inbound_groupsSQL = "and group_id IN('$rawLOGqc_allowed_inbound_groupsSQL')";
	$whereLOGqc_allowed_inbound_groupsSQL = "where group_id IN('$rawLOGqc_allowed_inbound_groupsSQL')";
	}


$first_login_link=0;
$VALID_2FA=1;


# check for 2FA being active, and if so, see if there is a non-expired 2FA auth
if ( ($SStwo_factor_auth_hours > 0) and ($SStwo_factor_container != '') and ($SStwo_factor_container != '---DISABLED---') and ($LOGtwo_factor_override != 'DISABLED') )
	{
	$stmt="SELECT count(*) from vicidial_two_factor_auth where user='$PHP_AUTH_USER' and auth_stage='1' and auth_exp_date > NOW();";
	if ($DB) {echo "$stmt\n";}
	$rslt=mysql_to_mysqli($stmt, $link);
	$auth_check_to_print = mysqli_num_rows($rslt);
	if ($auth_check_to_print < 1)
		{$VALID_2FA=0;}
	else
		{
		$row=mysqli_fetch_row($rslt);
		$VALID_2FA = $row[0];
		}
	}
if ($VALID_2FA < 1)
	{
	$ADD=99999701;
	$reports_only_user=1;
	}

if ($LOGforce_change_password=='Y')
	{
	$ADD=999997;
	$reports_only_user=1;
	}
if ($SSfirst_login_trigger=='Y')
	{
	if ($ADD==999996)
		{$reports_only_user=1;}
	else
		{
		$ADD=999995;
		$first_login_link=1;
		}
	}
if ($ADD==999995)
	{
	$reports_only_user=1;
	}

if (($LOGuser_level < 9) and ($SSlevel_8_disable_add > 0))
	{$add_copy_disabled++;}


$SSmenu_background='015B91';
$SSframe_background='D9E6FE';
$SSstd_row1_background='9BB9FB';
$SSstd_row2_background='B9CBFD';
$SSstd_row3_background='8EBCFD';
$SSstd_row4_background='B6D3FC';
$SSstd_row5_background='A3C3D6';
$SSalt_row1_background='BDFFBD';
$SSalt_row2_background='99FF99';
$SSalt_row3_background='CCFFCC';
$SSbutton_color='EFEFEF';
$SSweb_logo='default_old';

if ($SSadmin_screen_colors != 'default')
	{
	$stmt = "SELECT menu_background,frame_background,std_row1_background,std_row2_background,std_row3_background,std_row4_background,std_row5_background,alt_row1_background,alt_row2_background,alt_row3_background,web_logo,button_color FROM vicidial_screen_colors where colors_id='$SSadmin_screen_colors';";
	if ($DB) {echo "$stmt\n";}
	$rslt=mysql_to_mysqli($stmt, $link);
	$colors_ct = mysqli_num_rows($rslt);
	if ($colors_ct > 0)
		{
		$row=mysqli_fetch_row($rslt);
		$SSmenu_background =		$row[0];
		$SSframe_background =		$row[1];
		$SSstd_row1_background =	$row[2];
		$SSstd_row2_background =	$row[3];
		$SSstd_row3_background =	$row[4];
		$SSstd_row4_background =	$row[5];
		$SSstd_row5_background =	$row[6];
		$SSalt_row1_background =	$row[7];
		$SSalt_row2_background =	$row[8];
		$SSalt_row3_background =	$row[9];
		$SSweb_logo =				$row[10];
		$SSbutton_color =			$row[11];
		}
	}

$Mhead_color =	$SSstd_row5_background;
$Mmain_bgcolor = $SSmenu_background;
$Mhead_color =	$SSstd_row5_background;

if ($download_max_system_stats_metric_name) 
	{
	if (!$query_date) {$query_date=date("Y-m-d", time()-(29*86400));}
	if (!$end_date) 
		{
		$end_date=date("Y-m-d", time());
		}
	else if (strtotime($end_date)>strtotime(date("Y-m-d"))) 
		{
		$end_date=date("Y-m-d");
		}
	if ($query_date>$end_date) {$query_date=$end_date;}

	$num_graph_days = ceil(abs(strtotime($end_date) - strtotime($query_date)) / 86400)+1;
	$CSV_text="";

	if ($download_max_system_stats_metric_name=="ALL" || $download_max_system_stats_metric_name=="total call count in and out") 
		{
		download_max_system_stats($campaign_id,$num_graph_days,'system','total_calls','total call count in and out',$end_date);
		}
	if ($download_max_system_stats_metric_name=="ALL" || $download_max_system_stats_metric_name=="total inbound call count") 
		{
		download_max_system_stats($campaign_id,$num_graph_days,'system','total_calls_inbound_all','total inbound call count',$end_date);
		}
	if ($download_max_system_stats_metric_name=="ALL" || $download_max_system_stats_metric_name=="total outbound call count") 
		{
		download_max_system_stats($campaign_id,$num_graph_days,'system','total_calls_outbound_all','total outbound call count',$end_date);
		}
	if ($download_max_system_stats_metric_name=="ALL" || $download_max_system_stats_metric_name=="most concurrent calls in and out") 
		{
		download_max_system_stats($campaign_id,$num_graph_days,'system','(max_inbound + max_outbound)','most concurrent calls in and out',$end_date);
		}
	if ($download_max_system_stats_metric_name=="ALL" || $download_max_system_stats_metric_name=="most concurrent calls inbound total") 
		{
		download_max_system_stats($campaign_id,$num_graph_days,'system','max_inbound','most concurrent calls inbound total',$end_date);
		}
	if ($download_max_system_stats_metric_name=="ALL" || $download_max_system_stats_metric_name=="most concurrent calls outbound total") 
		{
		download_max_system_stats($campaign_id,$num_graph_days,'system','max_outbound','most concurrent calls outbound total',$end_date);
		}
	if ($download_max_system_stats_metric_name=="ALL" || $download_max_system_stats_metric_name=="most concurrent agents") 
		{
		download_max_system_stats($campaign_id,$num_graph_days,'system','max_agents','most concurrent agents',$end_date);
		}

	$FILE_TIME = date("Ymd-His");
	$CSVfilename = "MAX_SYSTEM_STATS_$US$FILE_TIME.csv";
	$CSV_text=preg_replace('/ +\"/', '"', $CSV_text);
	$CSV_text=preg_replace('/\" +/', '"', $CSV_text);
	header('Content-type: application/octet-stream');

	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";

	exit;
	}


######################################################################################################
######################################################################################################
#######   Header settings
######################################################################################################
######################################################################################################


header ("Content-type: text/html; charset=utf-8");
if ($SSnocache_admin=='1')
	{
	header ("Cache-Control: no-cache, must-revalidate");  // HTTP/1.1
	header ("Pragma: no-cache");                          // HTTP/1.0
	}
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $admin_version   BUILD: $build   ADD: $ADD   PHP_SELF: $PHP_SELF-->\n";
echo "<META NAME=\"ROBOTS\" CONTENT=\"NONE\">\n";
echo "<META NAME=\"COPYRIGHT\" CONTENT=\"&copy; 2025 ViciDial Group\">\n";
echo "<META NAME=\"AUTHOR\" CONTENT=\"ViciDial Group\">\n";
echo "<script language=\"JavaScript\" src=\"calendar_db.js\"></script>\n";
echo "<script language=\"JavaScript\" src=\"help.js\"></script>\n";


echo "<div id='HelpDisplayDiv' class='help_info' style='display:none;'></div>";

echo "<link rel=\"stylesheet\" href=\"calendar.css\">\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"vicidial_stylesheet.php\">\n";

if ($SSnocache_admin=='1')
	{
	echo "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n";
	echo "<META HTTP-EQUIV=\"Expires\" CONTENT=\"-1\">\n";
	echo "<META HTTP-EQUIV=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\">\n";
	}
if ( ($SSadmin_modify_refresh > 1) and (preg_match("/^3/",$ADD)) )
	{
	$modify_refresh_set=1;
	if (preg_match("/^3/",$ADD)) {$modify_url = "$PHP_SELF?$QUERY_STRING";}
	echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"$SSadmin_modify_refresh;URL=$modify_url\">\n";
	}
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "<title>"._QXZ("ADMINISTRATION").": ";

### set the default screen to the user list
if ( (!isset($ADD)) or (strlen($ADD)<1) )   {$ADD="999990";}
if ($ADD=='0') {$ADD="999990";}

### set the sections and headers
if ($ADD=="1")			{$hh='users';		$sh='new';	echo _QXZ("Add New User");}
if ($ADD=="1A")			{$hh='users';		$sh='copy';	echo _QXZ("Copy User");}
if ($ADD==11)			{$hh='campaigns';	$sh='basic';	echo _QXZ("Add New Campaign");}
if ($ADD==12)			{$hh='campaigns';	$sh='basic';	echo _QXZ("Copy Campaign");}
if ($ADD==111)			{$hh='lists';		$sh='new';	echo _QXZ("Add New List");}
if ($ADD==121)			{$hh='lists';		$sh='dnc';	echo _QXZ("Add New DNC");}
if ($ADD==131)			{$hh='lists';		$sh='droplist';	echo _QXZ("Add New Drop List");}
if ($ADD==171)			{$hh='ingroups';	$sh='addFPG';	echo _QXZ("Filter Phone Group Numbers");}
if ($ADD==1111)			{$hh='ingroups';	$sh='newIG';	echo _QXZ("Add New In-Group");}
if ($ADD==1211)			{$hh='ingroups';	$sh='copyIG';	echo _QXZ("Copy In-Group");}
if ($ADD==1311)			{$hh='ingroups';	$sh='newDID';	echo _QXZ("Add New DID");}
if ($ADD==1411)			{$hh='ingroups';	$sh='copyDID';	echo _QXZ("Copy DID");}
if ($ADD==1511)			{$hh='ingroups';	$sh='newCM';	echo _QXZ("Add Call Menu");}
if ($ADD==1611)			{$hh='ingroups';	$sh='copyCM';	echo _QXZ("Copy Call Menu");}
if ($ADD==1711)			{$hh='ingroups';	$sh='newFPG';	echo _QXZ("Add Filter Phone Group");}
if ($ADD==1811)			{$hh='ingroups';	$sh='newEG';	echo _QXZ("Add New EMAIL In-Group");}
if ($ADD==18111)		{$hh='ingroups';	$sh='newCG';	echo _QXZ("Add New CHAT In-Group");}
if ($ADD==1911)			{$hh='ingroups';	$sh='copyEG';	echo _QXZ("Copy EMAIL In-Group");}
if ($ADD==19111)		{$hh='ingroups';	$sh='copyCG';	echo _QXZ("Copy CHAT In-Group");}
if ($ADD==11111)		{$hh='remoteagent';	$sh='new';	echo _QXZ("Add New Remote Agents");}
if ($ADD==12111)		{$hh='remoteagent';	$sh='newEG';	echo _QXZ("Add Extension Group");}
if ($ADD==111111)		{$hh='usergroups';	$sh='new';	echo _QXZ("Add New Users Group");}
if ($ADD==1111111)		{$hh='scripts';	$sh='new';		echo _QXZ("Add New Script");}
if ($ADD==11111111)		{$hh='filters';	$sh='new';		echo _QXZ("Add New Filter");}
if ($ADD==111111111)	{$hh='admin';	$sh='times';	echo _QXZ("Add New Call Time");}
if ($ADD==131111111)	{$hh='admin';	$sh='shifts';	echo _QXZ("Add New Shift");}
if ($ADD==1111111111)	{$hh='admin';	$sh='times';	echo _QXZ("Add New State Call Time");}
if ($ADD==1211111111)	{$hh='admin';	$sh='times';	echo _QXZ("Add Holiday");}
if ($ADD==11111111111)	{$hh='admin';	$sh='phones';	echo _QXZ("ADD NEW PHONE");}
if ($ADD==12222222222)	{$hh='admin';	$sh='phones';	echo _QXZ("COPY NEW PHONE");}
if ($ADD==12111111111)	{$hh='admin';	$sh='phones';	echo _QXZ("ADD NEW PHONE ALIAS");}
if ($ADD==13111111111)	{$hh='admin';	$sh='phones';	echo _QXZ("ADD NEW GROUP ALIAS");}
if ($ADD==111111111111)	{$hh='admin';	$sh='server';	echo _QXZ("ADD NEW SERVER");}
if ($ADD==131111111111)	{$hh='admin';	$sh='templates';	echo _QXZ("ADD NEW CONF TEMPLATE");}
if ($ADD==141111111111)	{$hh='admin';	$sh='carriers';	echo _QXZ("ADD NEW CARRIER");}
if ($ADD==140111111111)	{$hh='admin';	$sh='carriers';	echo _QXZ("ADD COPIED CARRIER");}
if ($ADD==151111111111)	{$hh='admin';	$sh='tts';	echo _QXZ("ADD NEW TTS ENTRY");}
if ($ADD==161111111111)	{$hh='admin';	$sh='moh';	echo _QXZ("ADD NEW MUSIC ON HOLD ENTRY");}
if ($ADD==171111111111)	{$hh='admin';	$sh='vm';	echo _QXZ("ADD NEW VOICEMAIL BOX");}
if ($ADD==181111111111)	{$hh='admin';	$sh='label';	echo _QXZ("ADD NEW SCREEN LABEL");}
if ($ADD==182111111111)	{$hh='admin';	$sh='colors';	echo _QXZ("ADD NEW SCREEN COLORS");}
if ($ADD==191111111111)	{$hh='admin';	$sh='cts';	echo _QXZ("ADD NEW CONTACT");}
if ($ADD==192111111111)	{$hh='admin';	$sh='sc';	echo _QXZ("ADD SETTINGS CONTAINER");}
if ($ADD==193111111111)	{$hh='admin';	$sh='sg';	echo _QXZ("ADD STATUS GROUP");}
if ($ADD==194111111111)	{$hh='admin';	$sh='ar';	echo _QXZ("ADD AUTOMATED REPORT");}
if ($ADD==195111111111)	{$hh='admin';	$sh='il';	echo _QXZ("ADD IP LIST");}
if ($ADD==196111111111)	{$hh='admin';	$sh='cg';	echo _QXZ("ADD CID GROUP");}
if ($ADD==197111111111)	{$hh='admin';	$sh='vmmg';	echo _QXZ("ADD VM MESSAGE GROUP");}
if ($ADD==198111111111)	{$hh='admin';	$sh='qg';	echo _QXZ("ADD QUEUE GROUP");}
if ($ADD==1111111111111)	{$hh='admin';	$sh='conference';	echo _QXZ("ADD NEW CONFERENCE");}
if ($ADD==11111111111111)	{$hh='admin';	$sh='conference';	echo _QXZ("ADD NEW AGENT CONFERENCE");}
if ($ADD==12111111111111)	{$hh='admin';	$sh='conference';	echo _QXZ("ADD NEW AGENT CONFBRIDGE");}
if ($ADD=='2')			{$hh='users';		$sh='new';	echo _QXZ("New User Addition");}
if ($ADD=='2A')			{$hh='users';		$sh='copy';	echo _QXZ("New Copied User Addition");}
if ($ADD==20)			{$hh='campaigns';	$sh='basic';	echo _QXZ("New Copied Campaign Addition");}
if ($ADD==21)			{$hh='campaigns';	$sh='basic';	echo _QXZ("New Campaign Addition");}
if ($ADD==22)			{$hh='campaigns';	$sh='status';	echo _QXZ("New Campaign Status Addition");}
if ($ADD==23)			{$hh='campaigns';	$sh='hotkey';	echo _QXZ("New Campaign HotKey Addition");}
if ($ADD==25)			{$hh='campaigns';	$sh='recycle';	echo _QXZ("New Campaign Lead Recycle Addition");}
if ($ADD==26)			{$hh='campaigns';	$sh='autoalt';	echo _QXZ("New Auto Alt Dial Status");}
if ($ADD==27)			{$hh='campaigns';	$sh='pause';	echo _QXZ("New Agent Pause Code");}
if ($ADD==28)			{$hh='campaigns';	$sh='dialstat';	echo _QXZ("Campaign Dial Status Added");}
if ($ADD==29)			{$hh='campaigns';	$sh='listmix';	echo _QXZ("Campaign List Mix Added");}
if ($ADD==201)			{$hh='campaigns';	$sh='preset';	echo _QXZ("Campaign Preset Added");}
if ($ADD==202)			{$hh='campaigns';	$sh='accid';	echo _QXZ("Campaign Areacode CID Modify");}
if ($ADD==211)			{$hh='lists';		$sh='new';	echo _QXZ("New List Addition");}
if ($ADD==231)			{$hh='lists';		$sh='droplist';	echo _QXZ("New Drop List Addition");}
if ($ADD==2111)			{$hh='ingroups';	$sh='newIG';	echo _QXZ("New In-Group Addition");}
if ($ADD==2011)			{$hh='ingroups';	$sh='copyIG';	echo _QXZ("New Copied In-Group Addition");}
if ($ADD==2311)			{$hh='ingroups';	$sh='newDID';	echo _QXZ("New DID Addition");}
if ($ADD==2411)			{$hh='ingroups';	$sh='copyDID';	echo _QXZ("New Copied DID Addition");}
if ($ADD==2511)			{$hh='ingroups';	$sh='newCM';	echo _QXZ("New Call Menu");}
if ($ADD==2611)			{$hh='ingroups';	$sh='copyCM';	echo _QXZ("New Call Menu");}
if ($ADD==2711)			{$hh='ingroups';	$sh='newFPG';	echo _QXZ("New Filter Phone Group");}
if ($ADD==2811)			{$hh='ingroups';	$sh='newEG';	echo _QXZ("New Email Group Addition");}
if ($ADD==2911)			{$hh='ingroups';	$sh='copyEG';	echo _QXZ("New Copied Email Group Addition");}
if ($ADD==29111)		{$hh='ingroups';	$sh='copyCG';	echo _QXZ("New Copied Chat Group Addition");}
if ($ADD==21111)		{$hh='remoteagent';	$sh='new';	echo _QXZ("New Remote Agents Addition");}
if ($ADD==22111)		{$hh='remoteagent';	$sh='newEG';	echo _QXZ("New Group Extension Addition");}
if ($ADD==211111)		{$hh='usergroups';	$sh='new';	echo _QXZ("New Users Group Addition");}
if ($ADD==2111111)		{$hh='scripts';	$sh='new';	echo _QXZ("New Script Addition");}
if ($ADD==21111111)		{$hh='filters';	$sh='new';	echo _QXZ("New Filter Addition");}
if ($ADD==211111111)	{$hh='admin';	$sh='times';	echo _QXZ("New Call Time Addition");}
if ($ADD==231111111)	{$hh='admin';	$sh='shifts';	echo _QXZ("New Shift Addition");}
if ($ADD==2111111111)	{$hh='admin';	$sh='times';	echo _QXZ("New State Call Time Addition");}
if ($ADD==2211111111)	{$hh='admin';	$sh='times';	echo _QXZ("New Holiday Addition");}
if ($ADD==21111111111)	{$hh='admin';	$sh='phones';	echo _QXZ("ADDING NEW PHONE");}
if ($ADD==21222222222)	{$hh='admin';	$sh='phones';	echo _QXZ("COPYING NEW PHONE");}
if ($ADD==22111111111)	{$hh='admin';	$sh='phones';	echo _QXZ("ADDING NEW PHONE ALIAS");}
if ($ADD==23111111111)	{$hh='admin';	$sh='phones';	echo _QXZ("ADDING NEW GROUP ALIAS");}
if ($ADD==211111111111)	{$hh='admin';	$sh='server';	echo _QXZ("ADDING NEW SERVER");}
if ($ADD==221111111111)	{$hh='admin';	$sh='server';	echo _QXZ("ADDING NEW SERVER TRUNK RECORD");}
if ($ADD==231111111111)	{$hh='admin';	$sh='templates';	echo _QXZ("ADDING NEW CONF TEMPLATE");}
if ($ADD==241111111111)	{$hh='admin';	$sh='carriers';	echo _QXZ("ADDING NEW CARRIER");}
if ($ADD==240111111111)	{$hh='admin';	$sh='carriers';	echo _QXZ("ADDING COPIED CARRIER");}
if ($ADD==251111111111)	{$hh='admin';	$sh='tts';	echo _QXZ("ADDING NEW TTS ENTRY");}
if ($ADD==261111111111)	{$hh='admin';	$sh='moh';	echo _QXZ("ADDING NEW MUSIC ON HOLD ENTRY");}
if ($ADD==271111111111)	{$hh='admin';	$sh='vm';	echo _QXZ("ADDING NEW VOICEMAIL BOX");}
if ($ADD==281111111111)	{$hh='admin';	$sh='label';	echo _QXZ("ADDING NEW SCREEN LABEL");}
if ($ADD==282111111111)	{$hh='admin';	$sh='colors';	echo _QXZ("ADDING NEW SCREEN COLORS");}
if ($ADD==291111111111)	{$hh='admin';	$sh='cts';	echo _QXZ("ADDING NEW CONTACT");}
if ($ADD==292111111111)	{$hh='admin';	$sh='sc';	echo _QXZ("ADDING NEW SETTINGS CONTAINER");}
if ($ADD==293111111111)	{$hh='admin';	$sh='sg';	echo _QXZ("ADDING NEW STATUS GROUP");}
if ($ADD==294111111111)	{$hh='admin';	$sh='ar';	echo _QXZ("ADDING NEW AUTOMATED REPORT");}
if ($ADD==295111111111)	{$hh='admin';	$sh='il';	echo _QXZ("ADDING NEW IP LIST");}
if ($ADD==296111111111)	{$hh='admin';	$sh='cg';	echo _QXZ("ADDING NEW CID GROUP");}
if ($ADD==297111111111)	{$hh='admin';	$sh='vmmg';	echo _QXZ("ADDING NEW VM MESSAGE GROUP");}
if ($ADD==298111111111)	{$hh='admin';	$sh='qg';	echo _QXZ("ADDING NEW QUEUE GROUP");}
if ($ADD==2111111111111)	{$hh='admin';	$sh='conference';	echo _QXZ("ADDING NEW CONFERENCE");}
if ($ADD==21111111111111)	{$hh='admin';	$sh='conference';	echo _QXZ("ADDING NEW AGENT CONFERENCE");}
if ($ADD==22111111111111)	{$hh='admin';	$sh='conference';	echo _QXZ("ADDING NEW AGENT CONFBRIDGE");}
if ($ADD==221111111111111)	{$hh='admin';	$sh='status';	echo _QXZ("ADDING SYSTEM STATUSES");}
if ($ADD==231111111111111)	{$hh='admin';	$sh='status';	echo _QXZ("ADDING STATUS CATEGORY");}
if ($ADD==241111111111111)	{$hh='admin';	$sh='status';	echo _QXZ("ADDING QC STATUS CODE");}
if ($ADD==3)			{$hh='users';		$sh='list';	echo _QXZ("Modify User");}
if ($ADD==30)			{$hh='campaigns';	echo _QXZ("Campaign Not Allowed");}
if ($ADD==31)			
	{
	$hh='campaigns';	$sh='detail';	echo _QXZ("Modify Campaign - Detail")." - $campaign_id";
	if ($SUB==22)	{echo " - "._QXZ("Statuses");}
	if ($SUB==23)	{echo " - "._QXZ("HotKeys");}
	if ($SUB==25)	{echo " - "._QXZ("Lead Recycle Entries");}
	if ($SUB==26)	{echo " - "._QXZ("Auto Alt Dial Statuses");}
	if ($SUB==27)	{echo " - "._QXZ("Agent Pause Codes");}
	if ($SUB==28)	{echo " - "._QXZ("QC");}
	if ($SUB==29)	{echo " - "._QXZ("List Mixes");}
	if ($SUB=='20A')	{echo " - "._QXZ("Survey");}
	if ($SUB==201)	{echo " - "._QXZ("Presets");}
	if ($SUB==202)	{echo " - "._QXZ("AC-CID");}
	}
if ($ADD==34)
	{
	$hh='campaigns';	$sh='basic';	echo _QXZ("Modify Campaign - Basic View")." - $campaign_id";
	if ($SUB==22)	{echo " - "._QXZ("Statuses");}
	if ($SUB==23)	{echo " - "._QXZ("HotKeys");}
	if ($SUB==25)	{echo " - "._QXZ("Lead Recycle Entries");}
	if ($SUB==26)	{echo " - "._QXZ("Auto Alt Dial Statuses");}
	if ($SUB==27)	{echo " - "._QXZ("Agent Pause Codes");}
	if ($SUB==28)	{echo " - "._QXZ("QC");}
	if ($SUB==29)	{echo " - "._QXZ("List Mixes");}
	if ($SUB=='20A')	{echo " - "._QXZ("Survey");}
	if ($SUB==201)	{echo " - "._QXZ("Presets");}
	if ($SUB==202)	{echo " - "._QXZ("AC-CID");}
	}
if ($ADD==32)			{$hh='campaigns';	$sh='status';	echo _QXZ("Campaign Statuses");}
if ($ADD==33)			{$hh='campaigns';	$sh='hotkey';	echo _QXZ("Campaign HotKeys");}
if ($ADD==35)			{$hh='campaigns';	$sh='recycle';	echo _QXZ("Campaign Lead Recycle Entries");}
if ($ADD==36)			{$hh='campaigns';	$sh='autoalt';	echo _QXZ("Campaign Auto Alt Dial Statuses");}
if ($ADD==37)			{$hh='campaigns';	$sh='pause';	echo _QXZ("Campaign Agent Pause Codes");}
if ($ADD==38)			{$hh='campaigns';	$sh='dialstat';	echo _QXZ("Campaign Dial Statuses");}
if ($ADD==39)			{$hh='campaigns';	$sh='listmix';	echo _QXZ("Campaign List Mixes");}
if ($ADD==301)			{$hh='campaigns';	$sh='preset';	echo _QXZ("Campaign Presets");}
if ($ADD==302)			{$hh='campaigns';	$sh='accid';	echo _QXZ("Campaign Areacode CID");}
if ($ADD==311)			{$hh='lists';		$sh='list';	echo _QXZ("Modify List");}
if ($ADD==331)			{$hh='lists';		$sh='droplist';	echo _QXZ("Modify Drop List");}
if ($ADD==333)			{$hh='lists';		$sh='droplist';	echo _QXZ("Modify Drop List Status");}
if ($ADD==3111)			{$hh='ingroups';	echo _QXZ("Modify In-Group");}
if ($ADD==3311)			{$hh='ingroups';	echo _QXZ("Modify DID");}
if ($ADD==3321)			{$hh='ingroups';	echo _QXZ("Modify DID RA Extension Overrides");}
if ($ADD==3511)			{$hh='ingroups';	echo _QXZ("Modify Call Menu");}
if ($ADD==3711)			{$hh='ingroups';	echo _QXZ("Modify Filter Phone Group");}
if ($ADD==3811)			{$hh='ingroups';	echo _QXZ("Modify EMAIL In-Group");}
if ($ADD==3911)			{$hh='ingroups';	echo _QXZ("Modify CHAT In-Group");}
if ($ADD==3211)			{$hh='ingroups';	echo _QXZ("Modify Areacode List");}
if ($ADD==31111)		{$hh='remoteagent';	echo _QXZ("Modify Remote Agents");}
if ($ADD==32111)		{$hh='remoteagent';	echo _QXZ("Modify Extension Group");}
if ($ADD==311111)		{$hh='usergroups';	echo _QXZ("Modify Users Groups");}
if ($ADD==3111111)		{$hh='scripts';		echo _QXZ("Modify Script");}
if ($ADD==31111111)		{$hh='filters';		echo _QXZ("Modify Filter");}
if ($ADD==311111111)	{$hh='admin';	$sh='times';	echo _QXZ("Modify Call Time");}
if ($ADD==321111111)	{$hh='admin';	$sh='times';	echo _QXZ("Modify Call Time State Definitions List");}
if ($ADD==322111111)	{$hh='admin';	$sh='times';	echo _QXZ("Modify Call Time State Holiday");}
if ($ADD==331111111)	{$hh='admin';	$sh='shifts';	echo _QXZ("Modify Shift");}
if ($ADD==3111111111)	{$hh='admin';	$sh='times';	echo _QXZ("Modify State Call Time");}
if ($ADD==3211111111)	{$hh='admin';	$sh='times';	echo _QXZ("Modify Holiday");}
if ($ADD==31111111111)	{$hh='admin';	$sh='phones';	echo _QXZ("MODIFY PHONE");}
if ($ADD==32111111111)	{$hh='admin';	$sh='phones';	echo _QXZ("MODIFY PHONE ALIAS");}
if ($ADD==33111111111)	{$hh='admin';	$sh='phones';	echo _QXZ("MODIFY GROUP ALIAS");}
if ($ADD==311111111111)	{$hh='admin';	$sh='server';	echo _QXZ("MODIFY SERVER");}
if ($ADD==331111111111)	{$hh='admin';	$sh='templates';	echo _QXZ("MODIFY CONF TEMPLATE");}
if ($ADD==341111111111)	{$hh='admin';	$sh='carriers';	echo _QXZ("MODIFY CARRIER");}
if ($ADD==351111111111)	{$hh='admin';	$sh='tts';	echo _QXZ("MODIFY TTS ENTRY");}
if ($ADD==361111111111)	{$hh='admin';	$sh='moh';	echo _QXZ("MODIFY MUSIC ON HOLD ENTRY");}
if ($ADD==371111111111)	{$hh='admin';	$sh='vm';	echo _QXZ("MODIFY VOICEMAIL BOX");}
if ($ADD==381111111111)	{$hh='admin';	$sh='label';	echo _QXZ("MODIFY SCREEN LABEL");}
if ($ADD==382111111111)	{$hh='admin';	$sh='colors';	echo _QXZ("MODIFY SCREEN COLORS");}
if ($ADD==391111111111)	{$hh='admin';	$sh='cts';	echo _QXZ("MODIFY CONTACT");}
if ($ADD==392111111111)	{$hh='admin';	$sh='sc';	echo _QXZ("MODIFY SETTINGS CONTAINER");}
if ($ADD==393111111111)	{$hh='admin';	$sh='sg';	echo _QXZ("MODIFY STATUS GROUP");}
if ($ADD==394111111111)	{$hh='admin';	$sh='ar';	echo _QXZ("MODIFY AUTOMATED REPORT");}
if ($ADD==395111111111)	{$hh='admin';	$sh='il';	echo _QXZ("MODIFY IP LIST");}
if ($ADD==396111111111)	{$hh='admin';	$sh='cg';	echo _QXZ("MODIFY CID GROUP");}
if ($ADD==397111111111)	{$hh='admin';	$sh='vmmg';	echo _QXZ("MODIFY VM MESSAGE GROUP");}
if ($ADD==398111111111)	{$hh='admin';	$sh='qg';	echo _QXZ("MODIFY QUEUE GROUP");}
if ($ADD==3111111111111)	{$hh='admin';	$sh='conference';	echo _QXZ("MODIFY CONFERENCE");}
if ($ADD==31111111111111)	{$hh='admin';	$sh='conference';	echo _QXZ("MODIFY AGENT CONFERENCE");}
if ($ADD==32111111111111)	{$hh='admin';	$sh='conference';	echo _QXZ("MODIFY AGENT CONFBRIDGE");}
if ($ADD==311111111111111)	{$hh='admin';	$sh='settings';	echo _QXZ("MODIFY SYSTEM SETTINGS");}
if ($ADD==321111111111111)	{$hh='admin';	$sh='status';	echo _QXZ("MODIFY SYSTEM STATUSES");}
if ($ADD==331111111111111)	{$hh='admin';	$sh='status';	echo _QXZ("MODIFY STATUS CATEGORY");}
if ($ADD==341111111111111)	{$hh='qc';	$sh='modify';	echo _QXZ("MODIFY QC STATUS CODE");}
if ($ADD=="4A")			{$hh='users';		$sh='list';	echo _QXZ("Modify User - Admin");}
if ($ADD=="4B")			{$hh='users';		$sh='list';	echo _QXZ("Modify User - Admin");}
if ($ADD==4)			{$hh='users';		$sh='list';	echo _QXZ("Modify User");}
if ($ADD==41)			{$hh='campaigns';	$sh='detail';	echo _QXZ("Modify Campaign");}
if ($ADD==42)			{$hh='campaigns';	$sh='status';	echo _QXZ("Modify Campaign Status");}
if ($ADD==43)			{$hh='campaigns';	$sh='hotkey';	echo _QXZ("Modify Campaign HotKey");}
if ($ADD==44)			{$hh='campaigns';	$sh='basic';	echo _QXZ("Modify Campaign - Basic View");}
if ($ADD==45)			{$hh='campaigns';	$sh='recycle';	echo _QXZ("Modify Campaign Lead Recycle");}
if ($ADD==47)			{$hh='campaigns';	$sh='pause';	echo _QXZ("Modify Agent Pause Code");}
if ($ADD==48)			{$hh='campaigns';	$sh='qc';	echo _QXZ("Modify Campaign QC Settings");}
if ($ADD==49)			{$hh='campaigns';	$sh='listmix';	echo _QXZ("Modify Campaign List Mix");}
if ($ADD==401)			{$hh='campaigns';	$sh='preset';	echo _QXZ("Modify Campaign Preset");}
if ($ADD=='40A')		{$hh='campaigns';	$sh='survey';	echo _QXZ("Modify Campaign Survey");}
if ($ADD==411)			{$hh='lists';		$sh='list';	echo _QXZ("Modify List");}
if ($ADD==431)			{$hh='lists';		$sh='droplist';	echo _QXZ("Modify Drop List");}
if ($ADD==4111)			{$hh='ingroups';	echo _QXZ("Modify In-Group");}
if ($ADD==4311)			{$hh='ingroups';	echo _QXZ("Modify DID");}
if ($ADD==4511)			{$hh='ingroups';	echo _QXZ("Modify Call Menu");}
if ($ADD==4711)			{$hh='ingroups';	echo _QXZ("Modify Filter Phone Group");}
if ($ADD==4811)			{$hh='ingroups';	echo _QXZ("Modify Email In-Group");}
if ($ADD==4911)			{$hh='ingroups';	echo _QXZ("Modify Chat In-Group");}
if ($ADD==41111)		{$hh='remoteagent';	echo _QXZ("Modify Remote Agents");}
if ($ADD==42111)		{$hh='remoteagent';	echo _QXZ("Modify Extension Group");}
if ($ADD==411111)		{$hh='usergroups';	echo _QXZ("Modify Users Groups");}
if ($ADD==4111111)		{$hh='scripts';		echo _QXZ("Modify Script");}
if ($ADD==41111111)		{$hh='filters';		echo _QXZ("Modify Filter");}
if ($ADD==411111111)	{$hh='admin';	$sh='times';	echo _QXZ("Modify Call Time");}
if ($ADD==431111111)	{$hh='admin';	$sh='shifts';	echo _QXZ("Modify Shift");}
if ($ADD==4111111111)	{$hh='admin';	$sh='times';	echo _QXZ("Modify State Call Time");}
if ($ADD==4211111111)	{$hh='admin';	$sh='times';	echo _QXZ("Modify Holiday");}
if ($ADD==41111111111)	{$hh='admin';	$sh='phones';	echo _QXZ("MODIFY PHONE");}
if ($ADD==42111111111)	{$hh='admin';	$sh='phones';	echo _QXZ("MODIFY PHONE ALIAS");}
if ($ADD==43111111111)	{$hh='admin';	$sh='phones';	echo _QXZ("MODIFY GROUP ALIAS");}
if ($ADD==411111111111)	{$hh='admin';	$sh='server';	echo _QXZ("MODIFY SERVER");}
if ($ADD==421111111111)	{$hh='admin';	$sh='server';	echo _QXZ("MODIFY SERVER TRUNK RECORD");}
if ($ADD==431111111111)	{$hh='admin';	$sh='templates';	echo _QXZ("MODIFY CONF TEMPLATE");}
if ($ADD==441111111111)	{$hh='admin';	$sh='carriers';	echo _QXZ("MODIFY CARRIER");}
if ($ADD==451111111111)	{$hh='admin';	$sh='tts';	echo _QXZ("MODIFY TTS ENTRY");}
if ($ADD==461111111111)	{$hh='admin';	$sh='moh';	echo _QXZ("MODIFY MUSIC ON HOLD ENTRY");}
if ($ADD==471111111111)	{$hh='admin';	$sh='vm';	echo _QXZ("MODIFY VOICEMAIL BOX");}
if ($ADD==481111111111)	{$hh='admin';	$sh='label';	echo _QXZ("MODIFY SCREEN LABEL");}
if ($ADD==482111111111)	{$hh='admin';	$sh='colors';	echo _QXZ("MODIFY SCREEN COLORS");}
if ($ADD==491111111111)	{$hh='admin';	$sh='cts';	echo _QXZ("MODIFY CONTACT");}
if ($ADD==492111111111)	{$hh='admin';	$sh='sc';	echo _QXZ("MODIFY SETTINGS CONTAINER");}
if ($ADD==493111111111)	{$hh='admin';	$sh='sg';	echo _QXZ("MODIFY STATUS GROUP");}
if ($ADD==494111111111)	{$hh='admin';	$sh='ar';	echo _QXZ("MODIFY AUTOMATED REPORT");}
if ($ADD==496111111111)	{$hh='admin';	$sh='cg';	echo _QXZ("MODIFY CID GROUP");}
if ($ADD==497111111111)	{$hh='admin';	$sh='vmmg';	echo _QXZ("MODIFY VM MESSAGE GROUP");}
if ($ADD==498111111111)	{$hh='admin';	$sh='qg';	echo _QXZ("MODIFY QUEUE GROUP");}
if ($ADD==4111111111111)	{$hh='admin';	$sh='conference';	echo _QXZ("MODIFY CONFERENCE");}
if ($ADD==41111111111111)	{$hh='admin';	$sh='conference';	echo _QXZ("MODIFY CONFERENCE");}
if ($ADD==42111111111111)	{$hh='admin';	$sh='conference';	echo _QXZ("MODIFY CONFBRIDGE");}
if ($ADD==411111111111111)	{$hh='admin';	$sh='settings';	echo _QXZ("MODIFY SYSTEM SETTINGS");}
if ($ADD==421111111111111)	{$hh='admin';	$sh='status';	echo _QXZ("MODIFY SYSTEM STATUSES");}
if ($ADD==431111111111111)	{$hh='admin';	$sh='status';	echo _QXZ("MODIFY STATUS CATEGORIES");}
if ($ADD==441111111111111)	{$hh='admin';	$sh='status';	echo _QXZ("MODIFY QC STATUS CODE");}
if ($ADD==5)			{$hh='users';		$sh='list';	echo _QXZ("Delete User");}
if ($ADD==51)			{$hh='campaigns';	$sh='detail';	echo _QXZ("Delete Campaign");}
if ($ADD==52)			{$hh='campaigns';	$sh='detail';	echo _QXZ("Logout Agents");}
if ($ADD==53)			{$hh='campaigns';	$sh='detail';	echo _QXZ("Emergency VDAC Jam Clear");}
if ($ADD==511)			{$hh='lists';		$sh='list';	echo _QXZ("Delete List");}
if ($ADD==512)			{$hh='lists';		$sh='list';	echo _QXZ("Clear List");}
if ($ADD==531)			{$hh='lists';		$sh='droplist';	echo _QXZ("Delete Drop List");}
if ($ADD==5111)			{$hh='ingroups';	echo _QXZ("Delete In-Group");}
if ($ADD==5311)			{$hh='ingroups';	echo _QXZ("Delete DID");}
if ($ADD==5511)			{$hh='ingroups';	echo _QXZ("Delete Call Menu");}
if ($ADD==5711)			{$hh='ingroups';	echo _QXZ("Delete Phone Filter Group");}
if ($ADD==51111)		{$hh='remoteagent';	echo _QXZ("Delete Remote Agents");}
if ($ADD==52111)		{$hh='remoteagent';	echo _QXZ("Delete Extension Group");}
if ($ADD==511111)		{$hh='usergroups';	echo _QXZ("Delete Users Group");}
if ($ADD==5111111)		{$hh='scripts';		echo _QXZ("Delete Script");}
if ($ADD==51111111)		{$hh='filters';		echo _QXZ("Delete Filter");}
if ($ADD==511111111)	{$hh='admin';	$sh='times';	echo _QXZ("Delete Call Time");}
if ($ADD==531111111)	{$hh='admin';	$sh='shifts';	echo _QXZ("Delete Shift");}
if ($ADD==5111111111)	{$hh='admin';	$sh='times';	echo _QXZ("Delete State Call Time");}
if ($ADD==5211111111)	{$hh='admin';	$sh='times';	echo _QXZ("Delete Holiday");}
if ($ADD==51111111111)	{$hh='admin';	$sh='phones';	echo _QXZ("DELETE PHONE");}
if ($ADD==52111111111)	{$hh='admin';	$sh='phones';	echo _QXZ("DELETE PHONE ALIAS");}
if ($ADD==53111111111)	{$hh='admin';	$sh='phones';	echo _QXZ("DELETE GROUP ALIAS");}
if ($ADD==511111111111)	{$hh='admin';	$sh='server';	echo _QXZ("DELETE SERVER");}
if ($ADD==521111111111)	{$hh='admin';	$sh='server';	echo _QXZ("CLEAR AGENT CONFERENCES");}
if ($ADD==531111111111)	{$hh='admin';	$sh='templates';	echo _QXZ("DELETE CONF TEMPLATE");}
if ($ADD==541111111111)	{$hh='admin';	$sh='carriers';	echo _QXZ("DELETE CARRIER");}
if ($ADD==551111111111)	{$hh='admin';	$sh='tts';	echo _QXZ("DELETE TTS ENTRY");}
if ($ADD==561111111111)	{$hh='admin';	$sh='moh';	echo _QXZ("DELETE MUSIC ON HOLD ENTRY");}
if ($ADD==571111111111)	{$hh='admin';	$sh='vm';	echo _QXZ("DELETE VOICEMAIL BOX");}
if ($ADD==581111111111)	{$hh='admin';	$sh='label';	echo _QXZ("DELETE SCREEN LABEL");}
if ($ADD==582111111111)	{$hh='admin';	$sh='colors';	echo _QXZ("DELETE SCREEN COLORS");}
if ($ADD==591111111111)	{$hh='admin';	$sh='cts';	echo _QXZ("DELETE CONTACT");}
if ($ADD==592111111111)	{$hh='admin';	$sh='sc';	echo _QXZ("DELETE SETTINGS CONTAINER");}
if ($ADD==593111111111)	{$hh='admin';	$sh='sg';	echo _QXZ("DELETE STATUS GROUP");}
if ($ADD==594111111111)	{$hh='admin';	$sh='ar';	echo _QXZ("DELETE AUTOMATED REPORT");}
if ($ADD==595111111111)	{$hh='admin';	$sh='il';	echo _QXZ("DELETE IP LIST");}
if ($ADD==596111111111)	{$hh='admin';	$sh='cg';	echo _QXZ("DELETE CID GROUP");}
if ($ADD==597111111111)	{$hh='admin';	$sh='vmmg';	echo _QXZ("DELETE VM MESSAGE GROUP");}
if ($ADD==598111111111)	{$hh='admin';	$sh='qg';	echo _QXZ("DELETE QUEUE GROUP");}
if ($ADD==5111111111111)	{$hh='admin';	$sh='conference';	echo _QXZ("DELETE CONFERENCE");}
if ($ADD==51111111111111)	{$hh='admin';	$sh='conference';	echo _QXZ("DELETE AGENT CONFERENCE");}
if ($ADD==52111111111111)	{$hh='admin';	$sh='conference';	echo _QXZ("DELETE AGENT CONFBRIDGE");}
if ($ADD==6)			{$hh='users';		$sh='list';	echo _QXZ("Delete User");}
if ($ADD==61)			{$hh='campaigns';	$sh='detail';	echo _QXZ("Delete Campaign");}
if ($ADD==62)			{$hh='campaigns';	$sh='detail';	echo _QXZ("Logout Agents");}
if ($ADD==63)			{$hh='campaigns';	$sh='detail';	echo _QXZ("Emergency VDAC Jam Clear");}
if ($ADD==65)			{$hh='campaigns';	$sh='recycle';	echo _QXZ("Delete Lead Recycle");}
if ($ADD==66)			{$hh='campaigns';	$sh='autoalt';	echo _QXZ("Delete Auto Alt Dial Status");}
if ($ADD==67)			{$hh='campaigns';	$sh='pause';	echo _QXZ("Delete Agent Pause Code");}
if ($ADD==68)			{$hh='campaigns';	$sh='dialstat';	echo _QXZ("Campaign Dial Status Removed");}
if ($ADD==69)			{$hh='campaigns';	$sh='listmix';	echo _QXZ("Campaign List Mix Removed");}
if ($ADD==601)			{$hh='campaigns';	$sh='preset';	echo _QXZ("Campaign Preset Removed");}
if ($ADD==611)			{$hh='lists';		$sh='list';	echo _QXZ("Delete List");}
if ($ADD==612)			{$hh='lists';		$sh='list';	echo _QXZ("Clear List");}
if ($ADD==631)			{$hh='lists';		$sh='droplist';	echo _QXZ("Delete Drop List");}
if ($ADD==6111)			{$hh='ingroups';	echo _QXZ("Delete In-Group");}
if ($ADD==6311)			{$hh='ingroups';	echo _QXZ("Delete DID");}
if ($ADD==6511)			{$hh='ingroups';	echo _QXZ("Delete Call Menu");}
if ($ADD==6711)			{$hh='ingroups';	echo _QXZ("Delete Phone Filter Group");}
if ($ADD==61111)		{$hh='remoteagent';	echo _QXZ("Delete Remote Agents");}
if ($ADD==62111)		{$hh='remoteagent';	echo _QXZ("Delete Extension Group");}
if ($ADD==611111)		{$hh='usergroups';	echo _QXZ("Delete Users Group");}
if ($ADD==6111111)		{$hh='scripts';		echo _QXZ("Delete Script");}
if ($ADD==61111111)		{$hh='filters';		echo _QXZ("Delete Filter");}
if ($ADD==611111111)	{$hh='admin';	$sh='times';	echo _QXZ("Delete Call Time");}
if ($ADD==631111111)	{$hh='admin';	$sh='shifts';	echo _QXZ("Delete Shift");}
if ($ADD==6111111111)	{$hh='admin';	$sh='times';	echo _QXZ("Delete State Call Time");}
if ($ADD==6211111111)	{$hh='admin';	$sh='times';	echo _QXZ("Delete Holiday");}
if ($ADD==61111111111)	{$hh='admin';	$sh='phones';	echo _QXZ("DELETE PHONE");}
if ($ADD==62111111111)	{$hh='admin';	$sh='phones';	echo _QXZ("DELETE PHONE ALIAS");}
if ($ADD==63111111111)	{$hh='admin';	$sh='phones';	echo _QXZ("DELETE GROUP ALIAS");}
if ($ADD==611111111111)	{$hh='admin';	$sh='server';	echo _QXZ("DELETE SERVER");}
if ($ADD==622111111111)	{$hh='admin';	$sh='server';	echo _QXZ("CLEAR AGENT CONFERENCES");}
if ($ADD==621111111111)	{$hh='admin';	$sh='server';	echo _QXZ("DELETE SERVER TRUNK RECORD");}
if ($ADD==631111111111)	{$hh='admin';	$sh='templates';	echo _QXZ("DELETE CONF TEMPLATE");}
if ($ADD==641111111111)	{$hh='admin';	$sh='carriers';	echo _QXZ("DELETE CARRIER");}
if ($ADD==651111111111)	{$hh='admin';	$sh='tts';	echo _QXZ("DELETE TTS ENTRY");}
if ($ADD==661111111111)	{$hh='admin';	$sh='moh';	echo _QXZ("DELETE MUSIC ON HOLD ENTRY");}
if ($ADD==671111111111)	{$hh='admin';	$sh='vm';	echo _QXZ("DELETE VOICEMAIL BOX");}
if ($ADD==681111111111)	{$hh='admin';	$sh='label';	echo _QXZ("DELETE SCREEN LABEL");}
if ($ADD==682111111111)	{$hh='admin';	$sh='colors';	echo _QXZ("DELETE SCREEN COLORS");}
if ($ADD==691111111111)	{$hh='admin';	$sh='cts';	echo _QXZ("DELETE CONTACT");}
if ($ADD==692111111111)	{$hh='admin';	$sh='sc';	echo _QXZ("DELETE SETTINGS CONTAINER");}
if ($ADD==693111111111)	{$hh='admin';	$sh='sg';	echo _QXZ("DELETE STATUS GROUP");}
if ($ADD==694111111111)	{$hh='admin';	$sh='ar';	echo _QXZ("DELETE AUTOMATED REPORT");}
if ($ADD==695111111111)	{$hh='admin';	$sh='il';	echo _QXZ("DELETE IP LIST");}
if ($ADD==696111111111)	{$hh='admin';	$sh='cg';	echo _QXZ("DELETE CID GROUP");}
if ($ADD==697111111111)	{$hh='admin';	$sh='vmmg';	echo _QXZ("DELETE VM MESSAGE GROUP");}
if ($ADD==698111111111)	{$hh='admin';	$sh='qg';	echo _QXZ("DELETE QUEUE GROUP");}
if ($ADD==6111111111111)	{$hh='admin';	$sh='conference';	echo _QXZ("DELETE CONFERENCE");}
if ($ADD==61111111111111)	{$hh='admin';	$sh='conference';	echo _QXZ("DELETE AGENT CONFERENCE");}
if ($ADD==62111111111111)	{$hh='admin';	$sh='conference';	echo _QXZ("DELETE AGENT CONFBRIDGE");}
if ($ADD==73)			{$hh='campaigns';	echo _QXZ("Dialable Lead Count");}
if ($ADD==7111111)		{$hh='scripts';	$sh='list';	echo _QXZ("Preview Script");}
if ($ADD==700000000000000)	{$hh='reports';	echo _QXZ("ADMIN CHANGE LOG");}
if ($ADD==710000000000000)	{$hh='reports';	echo _QXZ("USER ADMIN CHANGE LOG");}
if ($ADD==720000000000000)	{$hh='reports';	echo _QXZ("SECTION ADMIN CHANGE LOG");}
if ($ADD==730000000000000)	{$hh='reports';	echo _QXZ("DETAIL ADMIN CHANGE LOG");}
if ($ADD==800000000000000)	{$hh='reports';	echo _QXZ("ADMIN REPORT LOG");}
if ($ADD==810000000000000)	{$hh='reports';	echo _QXZ("USER ADMIN REPORT LOG");}
if ($ADD==830000000000000)	{$hh='reports';	echo _QXZ("DETAIL ADMIN REPORT LOG");}
if ($ADD=="0A")			{$hh='users';	$sh='list';		echo _QXZ("Users List");}
if ($ADD==8)			{$hh='users';	$sh='list';		echo _QXZ("CallBacks Within Agent");}
if ($ADD==81)			{$hh='campaigns';	$sh='list';	echo _QXZ("CallBacks Within Campaign");}
if ($ADD==811)			{$hh='lists';		$sh='list';	echo _QXZ("CallBacks Within List");}
if ($ADD==8111)			{$hh='usergroups';	echo _QXZ("CallBacks Within User Group");}
if ($ADD==10)			{$hh='campaigns';	$sh='list';	echo _QXZ("Campaigns");}
if ($ADD==100)			{$hh='lists';		$sh='list';	echo _QXZ("Lists");}
if ($ADD==130)			{$hh='lists';		$sh='droplist';	echo _QXZ("Drop Lists");}
if ($ADD==1001)			{$hh='ingroups';	$sh='sections';	echo _QXZ("Inbound");}
if ($ADD==1000)			{$hh='ingroups';	$sh='listIG';	echo _QXZ("In-Groups");}
if ($ADD==1300)			{$hh='ingroups';	$sh='listDID';	echo _QXZ("DIDs");}
if ($ADD==1320)			{$hh='ingroups';	$sh='didRA';	echo _QXZ("Modify DID RA Extension Overrides");}
if ($ADD==1500)			{$hh='ingroups';	$sh='listCM';	echo _QXZ("Call Menus");}
if ($ADD==1700)			{$hh='ingroups';	$sh='listFPG';	echo _QXZ("Filter Phone Groups");}
if ($ADD==1800)			{$hh='ingroups';	$sh='listEG';	echo _QXZ("Email In-Groups");}
if ($ADD==1900)			{$hh='ingroups';	$sh='listCG';	echo _QXZ("Chat In-Groups");}
if ($ADD==10000)		{$hh='remoteagent';	$sh='list';	echo _QXZ("Remote Agents");}
if ($ADD==12000)		{$hh='remoteagent';	$sh='listEG';	echo _QXZ("Extension Groups");}
if ($ADD==100000)		{$hh='usergroups';	$sh='list';	echo _QXZ("User Groups");}
if ($ADD==1000000)		{$hh='scripts';	$sh='list';	echo _QXZ("Scripts");}
if ($ADD==10000000)		{$hh='filters';	$sh='list';	echo _QXZ("Filters");}
if ($ADD==100000000)	{$hh='admin';	$sh='times';	echo _QXZ("Call Times");}
if ($ADD==130000000)	{$hh='admin';	$sh='shifts';	echo _QXZ("Shifts");}
if ($ADD==1000000000)	{$hh='admin';	$sh='times';	echo _QXZ("State Call Times");}
if ($ADD==1200000000)	{$hh='admin';	$sh='times';	echo _QXZ("Holidays");}
if ($ADD==10000000000)	{$hh='admin';	$sh='phones';	echo _QXZ("PHONE LIST");}
if ($ADD==12000000000)	{$hh='admin';	$sh='phones';	echo _QXZ("PHONE ALIAS LIST");}
if ($ADD==13000000000)	{$hh='admin';	$sh='phones';	echo _QXZ("GROUP ALIAS LIST");}
if ($ADD==100000000000)	{$hh='admin';	$sh='server';	echo _QXZ("SERVER LIST");}
if ($ADD==130000000000)	{$hh='admin';	$sh='templates';	echo _QXZ("CONF TEMPLATE LIST");}
if ($ADD==140000000000)	{$hh='admin';	$sh='carriers';	echo _QXZ("CARRIER LIST");}
if ($ADD==150000000000)	{$hh='admin';	$sh='tts';	echo _QXZ("TTS ENTRY LIST");}
if ($ADD==160000000000)	{$hh='admin';	$sh='moh';	echo _QXZ("MUSIC ON HOLD ENTRY LIST");}
if ($ADD==170000000000)	{$hh='admin';	$sh='vm';	echo _QXZ("VOICEMAIL BOXES LIST");}
if ($ADD==180000000000)	{$hh='admin';	$sh='label';	echo _QXZ("SCREEN LABELS LIST");}
if ($ADD==182000000000)	{$hh='admin';	$sh='colors';	echo _QXZ("SCREEN COLORS LIST");}
if ($ADD==190000000000)	{$hh='admin';	$sh='cts';	echo _QXZ("CONTACTS LIST");}
if ($ADD==192000000000)	{$hh='admin';	$sh='sc';	echo _QXZ("SETTINGS CONTAINTER LIST");}
if ($ADD==193000000000)	{$hh='admin';	$sh='sg';	echo _QXZ("STATUS GROUP LIST");}
if ($ADD==194000000000)	{$hh='admin';	$sh='ar';	echo _QXZ("AUTOMATED REPORTS LIST");}
if ($ADD==195000000000)	{$hh='admin';	$sh='il';	echo _QXZ("IP LISTS");}
if ($ADD==196000000000)	{$hh='admin';	$sh='cg';	echo _QXZ("CID GROUP LIST");}
if ($ADD==197000000000)	{$hh='admin';	$sh='vmmg';	echo _QXZ("VM MESSAGE GROUPS LIST");}
if ($ADD==198000000000)	{$hh='admin';	$sh='qg';	echo _QXZ("QUEUE GROUPS LIST");}
if ($ADD==1000000000000)	{$hh='admin';	$sh='conference';	echo _QXZ("CONFERENCE LIST");}
if ($ADD==10000000000000)	{$hh='admin';	$sh='conference';	echo _QXZ("AGENT CONFERENCE LIST");}
if ($ADD==12000000000000)	{$hh='admin';	$sh='conference';	echo _QXZ("AGENT CONFBRIDGE LIST");}
if ($ADD==100000000000000)	{$hh='qc';	$sh='campaign';	echo _QXZ("Quality Control");}
if ($ADD==881)          {$hh='qc';		$sh='enter';	echo _QXZ("Quality Control Campaign")," $campaign_id";}
if ($ADD==550)			{$hh='users';		$sh='search';	echo _QXZ("Search Form");}
if ($ADD==551)			{$hh='users';		echo _QXZ("SEARCH PHONES");}
if ($ADD==660)			{$hh='users';		echo _QXZ("Search Results");}
if ($ADD==661)			{$hh='users';		echo _QXZ("SEARCH PHONES RESULTS");}
if ($ADD==99999)		{$hh='users';		echo _QXZ("HELP");}
if ($ADD==999999)		{$hh='reports';		echo _QXZ("REPORTS");}
if ($ADD==999998)		{$hh='admin';		echo _QXZ("ADMIN");}
if ($ADD==999997)		{$hh='reports';		echo _QXZ("CHANGE PASSWORD");}
if ($ADD==99999701)		{$hh='reports';		echo _QXZ("TWO-FACTOR-AUTHENTICATION");}
if ($ADD==999996)		{$hh='reports';		echo _QXZ("INITIAL INSTALL WELCOME");}
if ($ADD==999995)		{$hh='reports';		echo _QXZ("COPYRIGHT TRADEMARK LICENSE");}
if ($ADD==999994)		{$hh='reports';		echo _QXZ("ADMIN UTILITIES");}
if ($ADD==999993)		{$hh='reports';		echo _QXZ("SUMMARY STATS");}
if ($ADD==999992)		{$hh='reports';		echo _QXZ("SYSTEM SUMMARY STATS");}
if ($ADD==999991)		{$hh='reports';		echo _QXZ("SERVERS VERSIONS");}
if ($ADD==999990)		{$hh='reports';		echo _QXZ("SYSTEM SNAPSHOT STATS");}
if ($ADD==999989)		{$hh='reports';		echo _QXZ("USER CHANGE LANGUAGE");}
if ($ADD==999988)		{$hh='reports';		echo _QXZ("AVAILABLE TIMEZONES");}
if ($ADD==999987)		{$hh='reports';		echo _QXZ("PHONE CODES");}
if ($ADD==999986)		{$hh='reports';		echo _QXZ("POSTAL CODES");}
if ($ADD==999985)		{$hh='reports';		echo _QXZ("POSTAL CODES CITIES");}

echo "</title>\n";

if ( ($ADD==999993) or ($ADD==999992) or ($ADD==730000000000000) or ($ADD==830000000000000) )
	{
	if ($ADD==999993)		{$report_name = "SUMMARY STATS";}
	if ($ADD==999992)		{$report_name = "SYSTEM SUMMARY STATS";}
	if ($ADD==730000000000000)	{$report_name = "DETAIL ADMIN CHANGE LOG";}
	if ($ADD==830000000000000)	{$report_name = "DETAIL ADMIN REPORT LOG";}

	##### 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;";
	if ($DB) {echo "$stmt\n";}
	$rslt=mysql_to_mysqli($stmt, $link);
	$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, $query_date, $end_date, $shift, $stage, $report_display_type|', url='$LOGfull_url', webserver='$webserver_id';";
	$rslt=mysql_to_mysqli($stmt, $link);
	$report_log_id = mysqli_insert_id($link);
	if ($DB) {echo "$report_log_id|$stmt|\n";}
	##### END log visit to the vicidial_report_log table #####
	}

if ( ($ADD>2) and ($ADD < 99998) )
	{
	##### get scripts listing for dynamic pulldown
	$stmt="SELECT script_id,script_name from vicidial_scripts $whereLOGadmin_viewable_groupsSQL order by script_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$scripts_to_print = mysqli_num_rows($rslt);
	if ($DB) {echo "$scripts_to_print|$stmt|\n";}
	$scripts_list="<option value=\"\">"._QXZ("NONE")."</option>\n";

	$o=0;
	while ($scripts_to_print > $o)
		{
		$rowx=mysqli_fetch_row($rslt);
		$scripts_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
		$scriptname_list["$rowx[0]"] = "$rowx[1]";
		$o++;
		}

	##### get filters listing for dynamic pulldown
	$stmt="SELECT lead_filter_id,lead_filter_name,lead_filter_sql from vicidial_lead_filters $whereLOGadmin_viewable_groupsSQL order by lead_filter_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$filters_to_print = mysqli_num_rows($rslt);
	if ($DB) {echo "$filters_to_print|$stmt|\n";}
	$filters_list="<option value=\"\">"._QXZ("NONE")."</option>\n";

	$o=0;
	while ($filters_to_print > $o)
		{
		$rowx=mysqli_fetch_row($rslt);
		$filters_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
		$filtername_list["$rowx[0]"] = "$rowx[1]";
		$filtersql_list["$rowx[0]"] = "$rowx[2]";
		$o++;
		}

	##### get call_times listing for dynamic pulldown
	$stmt="SELECT call_time_id,call_time_name from vicidial_call_times $whereLOGadmin_viewable_call_timesSQL order by call_time_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$times_to_print = mysqli_num_rows($rslt);
	if ($DB) {echo "$times_to_print|$stmt|\n";}

	$o=0;
	while ($times_to_print > $o)
		{
		$rowx=mysqli_fetch_row($rslt);
		$call_times_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
		$call_timename_list["$rowx[0]"] = "$rowx[1]";
		$o++;
		}
	}

if ( ( (strlen($ADD)>4) and ($ADD < 99998) ) or ($ADD==3) or (($ADD>20) and ($ADD<70)) or ($ADD=="4A")  or ($ADD=="4B") or (strlen($ADD)==12) )
	{
	##### BEGIN get campaigns listing for rankings #####

	$h="9";
	$headRANKcampaigns_list='';
	while ($h>=-9)
		{
		$headRANKcampaigns_list .= "<option value=\"$h\">$h</option>";
		$h--;
		}
	$h="10";
	$headGRADEcampaigns_list='';
	while ($h>=1)
		{
		$headGRADEcampaigns_list .= "<option value=\"$h\">$h</option>";
		$h--;
		}

	$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id";
	$rslt=mysql_to_mysqli($stmt, $link);
	$campaigns_to_print = mysqli_num_rows($rslt);
	if ($DB) {echo "$campaigns_to_print|$stmt|\n";}
	$campaigns_list='';
	$campaigns_value='';
	$RANKcampaigns_list='';
	$RANKcampaigns_list.="<tr bgcolor=#$SSmenu_background><td><font color=white> &nbsp; "._QXZ("CAMPAIGN")."</td>\n";
	$RANKcampaigns_list.="<td nowrap><font color=white> &nbsp; "._QXZ("RANK")." &nbsp; <br><select name=\"campaign_js_rank_select\" id=\"campaign_js_rank_select\" size=1 style=\"font-family: sans-serif; font-size: 10px; overflow: hidden;\"><option value=\"\">-></option>$headRANKcampaigns_list</select><a href=\"#\" onclick=\"campaign_rank_val_change();return false;\"><font size=1 color=white>"._QXZ("change")."</font></a></td>\n";
	$RANKcampaigns_list.="<td nowrap><font color=white> &nbsp; "._QXZ("GRADE")." &nbsp; <br><select name=\"campaign_js_grade_select\" id=\"campaign_js_grade_select\" size=1 style=\"font-family: sans-serif; font-size: 10px; overflow: hidden;\"><option value=\"\">-></option>$headGRADEcampaigns_list</select><a href=\"#\" onclick=\"campaign_grade_val_change();return false;\"><font size=1 color=white>"._QXZ("change")."</font></a></td>\n";
	$RANKcampaigns_list.="<td nowrap><font color=white> &nbsp; "._QXZ("CALLS")." &nbsp; </td><td ALIGN=CENTER><font color=white>"._QXZ("WEB VARS")."</td></tr>\n";

	$o=0;
	while ($campaigns_to_print > $o)
		{
		$rowx=mysqli_fetch_row($rslt);
		$campaigns_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
		$campaign_id_values[$o] = $rowx[0];
		$campaign_name_values[$o] = $rowx[1];
		$o++;
		}

	$o=0;
	$stmt_grp_values='';
	$campaign_js_rank='';
	$campaign_js_grade='';
	$campaign_js_rank_ct=0;
	$campaign_js_grade_ct=0;

	while ($campaigns_to_print > $o)
		{
		$group_web_vars='';
		$campaign_web='';
		$stmt="SELECT campaign_rank,calls_today,group_web_vars,campaign_grade,hopper_calls_today,hopper_calls_hour from vicidial_campaign_agents where user='$user' and campaign_id='$campaign_id_values[$o]' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$ranks_to_print = mysqli_num_rows($rslt);
		if ($DB) {echo "$ranks_to_print|$stmt|\n";}
		if ($ranks_to_print > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$SELECT_campaign_rank =		$row[0];
			$calls_today =				$row[1];
			$group_web_vars =			$row[2];
			$SELECT_campaign_grade =	$row[3];
			$hopper_calls_today =		$row[4];
			$hopper_calls_hour =		$row[5];
			}
		else
			{$calls_today=0;   $SELECT_campaign_rank=0;   $SELECT_campaign_grade=1;   $group_web_vars='';}
		if ( ($ADD=="4A") or ($ADD=="4B") )
			{
			if (isset($_GET["RANK_$campaign_id_values[$o]"]))			{$campaign_rank=$_GET["RANK_$campaign_id_values[$o]"];}
				elseif (isset($_POST["RANK_$campaign_id_values[$o]"]))	{$campaign_rank=$_POST["RANK_$campaign_id_values[$o]"];}
			if (isset($_GET["WEB_$campaign_id_values[$o]"]))			{$campaign_web=$_GET["WEB_$campaign_id_values[$o]"];}
				elseif (isset($_POST["WEB_$campaign_id_values[$o]"]))	{$campaign_web=$_POST["WEB_$campaign_id_values[$o]"];}
			if (isset($_GET["GRADE_$campaign_id_values[$o]"]))			{$campaign_grade=$_GET["GRADE_$campaign_id_values[$o]"];}
				elseif (isset($_POST["GRADE_$campaign_id_values[$o]"]))	{$campaign_grade=$_POST["GRADE_$campaign_id_values[$o]"];}
			$campaign_rank = preg_replace('/[^-\_0-9]/','',$campaign_rank);
			$campaign_web = preg_replace("/;|\"|\'/","",$campaign_web);
			$campaign_grade = preg_replace('/[^-\_0-9]/','',$campaign_grade);

			if ($ranks_to_print > 0)
				{
				$stmt="UPDATE vicidial_campaign_agents set campaign_rank='$campaign_rank', campaign_weight='$campaign_rank', group_web_vars='$campaign_web',campaign_grade='$campaign_grade' where campaign_id='$campaign_id_values[$o]' and user='$user';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$stmt_grp_values .= "$stmt|";
				}
			else
				{
				$stmt="INSERT INTO vicidial_campaign_agents set campaign_rank='$campaign_rank', campaign_weight='$campaign_rank', campaign_id='$campaign_id_values[$o]', user='$user', group_web_vars='$campaign_web',campaign_grade='$campaign_grade';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$stmt_grp_values .= "$stmt|";
				}

			$stmt="UPDATE vicidial_live_agents set campaign_weight='$campaign_rank',campaign_grade='$campaign_grade' where campaign_id='$campaign_id_values[$o]' and user='$user';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$stmt_grp_values .= "$stmt|";
			}
		else 
			{
			$campaign_rank = $SELECT_campaign_rank;
			$campaign_grade = $SELECT_campaign_grade;
			}

		$USER_hopper_calls_today = ($USER_hopper_calls_today + $hopper_calls_today);
		$USER_hopper_calls_hour = ($USER_hopper_calls_hour + $hopper_calls_hour);

		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
		else
			{$bgcolor='bgcolor="#' . $SSstd_row1_background . '"';}

		# disable non user-group allowable campaign ranks
		$stmt="SELECT user_group from vicidial_users where user='$user' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$Ruser_group =	$row[0];

		$stmt="SELECT allowed_campaigns from vicidial_user_groups where user_group='$Ruser_group' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$allowed_campaigns =	$row[0];
		$allowed_campaigns = preg_replace("/ -$/","",$allowed_campaigns);
		$UGcampaigns = explode(" ", $allowed_campaigns);

		$p=0;   $RANK_camp_active=0;   $GRADE_camp_active=0;   $CR_disabled = '';
		if (preg_match('/\-ALL\-CAMPAIGNS\-/i',$allowed_campaigns))
			{$RANK_camp_active++;   $GRADE_camp_active++;}
		else
			{
			$UGcampaign_ct = count($UGcampaigns);
			while ($p < $UGcampaign_ct)
				{
				if ($campaign_id_values[$o] === $UGcampaigns[$p]) 
					{$RANK_camp_active++;   $GRADE_camp_active++;}
				$p++;
				}
			}
		if ($RANK_camp_active < 1) 
			{$CR_disabled = 'DISABLED';}
		else
			{
			$campaign_js_rank_ct++;
			$campaign_js_grade_ct++;
			if (strlen($campaign_js_rank) > 1)
				{
				$campaign_js_rank .= ",";
				$campaign_js_grade .= ",";
				}
			$campaign_js_rank .= "'RANK_$campaign_id_values[$o]'";
			$campaign_js_grade .= "'GRADE_$campaign_id_values[$o]'";
			}

		$RANKcampaigns_list .= "<tr $bgcolor><td>";
		$campaigns_list .= "<a href=\"$PHP_SELF?ADD=31&campaign_id=$campaign_id_values[$o]\">$campaign_id_values[$o]</a> - $campaign_name_values[$o] <BR>\n";
		$RANKcampaigns_list .= "<a href=\"$PHP_SELF?ADD=31&campaign_id=$campaign_id_values[$o]\">$campaign_id_values[$o]</a> - $campaign_name_values[$o] </td>";
		$RANKcampaigns_list .= "<td> &nbsp; <select size=1 name=RANK_$campaign_id_values[$o] id=RANK_$campaign_id_values[$o] $CR_disabled>\n";
		$h="9";
		while ($h>=-9)
			{
			$RANKcampaigns_list .= "<option value=\"$h\"";
			if ($h==$campaign_rank)
				{$RANKcampaigns_list .= " SELECTED";}
			$RANKcampaigns_list .= ">$h</option>";
			$h--;
			}
		if ( (strlen($campaign_web) < 1) and (strlen($group_web_vars) > 0) )
			{$campaign_web=$group_web_vars;}
		$RANKcampaigns_list .= "</select></td>\n";
		$RANKcampaigns_list .= "<td> &nbsp; <select size=1 name=GRADE_$campaign_id_values[$o] id=GRADE_$campaign_id_values[$o] $CR_disabled>\n";
		$h="10";
		while ($h>=1)
			{
			$RANKcampaigns_list .= "<option value=\"$h\"";
			if ($h==$campaign_grade)
				{$RANKcampaigns_list .= " SELECTED";}
			$RANKcampaigns_list .= ">$h</option>";
			$h--;
			}
		if ( (strlen($campaign_web) < 1) and (strlen($group_web_vars) > 0) )
			{$campaign_web=$group_web_vars;}
		$RANKcampaigns_list .= "</select></td>\n";
		$RANKcampaigns_list .= "<td align=right> &nbsp; &nbsp; $calls_today</td>\n";
		$RANKcampaigns_list .= "<td> &nbsp; &nbsp; <input type=text size=25 maxlength=255 name=WEB_$campaign_id_values[$o] value=\"$campaign_web\"></td></tr>\n";
		$o++;
		}
	##### END get campaigns listing for rankings #####


	##### BEGIN get inbound groups listing for checkboxes #####
	$xfer_groupsSQL='';
	if ( (($ADD>20) and ($ADD<70)) and ($ADD!="4A") and ($ADD!=41) or ( ($ADD==41) and ( (preg_match('/list_activation/i', $stage)) or (preg_match('/test_call/',$stage)) ) ) )
		{
		$stmt="SELECT closer_campaigns,xfer_groups from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$closer_campaigns =	$row[0];
			$closer_campaigns = preg_replace("/ -$/","",$closer_campaigns);
			$groups = explode(" ", $closer_campaigns);
		$xfer_groups =	$row[1];
			$xfer_groups = preg_replace("/ -$/","",$xfer_groups);
			$XFERgroups = explode(" ", $xfer_groups);
		$xfer_groupsSQL = preg_replace("/^ | -$/","",$xfer_groups);
		$xfer_groupsSQL = preg_replace("/ /","','",$xfer_groupsSQL);
		$xfer_groupsSQL = "WHERE group_id IN('$xfer_groupsSQL')";
		}
	if ($ADD==41)
		{
		$p=0;
		if (!is_array($XFERgroups)) $XFERgroups = array();
		$XFERgroup_ct = count($XFERgroups);
		while ($p < $XFERgroup_ct)
			{
			$xfer_groups .= " $XFERgroups[$p]";
			$p++;
			}
		$xfer_groups = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$xfer_groups);
		$xfer_groupsSQL = preg_replace("/^ | -$/","",$xfer_groups);
		$xfer_groupsSQL = preg_replace("/ /","','",$xfer_groupsSQL);
		$xfer_groupsSQL = "WHERE group_id IN('$xfer_groupsSQL')";
		}

	if ( (($ADD==31111) or ($ADD==31111)) and (count($groups)<1) )
		{
		$stmt="SELECT closer_campaigns from vicidial_remote_agents where remote_agent_id='$remote_agent_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$closer_campaigns =	$row[0];
		$closer_campaigns = preg_replace("/ -$/","",$closer_campaigns);
		$groups = explode(" ", $closer_campaigns);
		}

	if ($ADD==3)
		{
		$stmt="SELECT closer_campaigns from vicidial_users where user='$user' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$closer_campaigns =	$row[0];
		$closer_campaigns = preg_replace("/ -$/","",$closer_campaigns);
		$groups = explode(" ", $closer_campaigns);
		}

	$h="9";
	$headRANKgroups_list='';
	while ($h>=-9)
		{
		$headRANKgroups_list .= "<option value=\"$h\">$h</option>";
		$h--;
		}
	$h="10";
	$headGRADEgroups_list='';
	while ($h>=1)
		{
		$headGRADEgroups_list .= "<option value=\"$h\">$h</option>";
		$h--;
		}


	$stmt="SELECT group_id,group_name from vicidial_inbound_groups $whereLOGadmin_viewable_groupsSQL order by group_id;";
#	$stmt="SELECT group_id,group_name from vicidial_inbound_groups where group_id NOT IN('AGENTDIRECT') order by group_id";
	$rslt=mysql_to_mysqli($stmt, $link);
	$groups_to_print = mysqli_num_rows($rslt);
	$groups_list='';
	$groups_value='';
	$XFERgroups_list='';
	$RANKgroups_list='';
	$RANKgroups_list.="<tr bgcolor=#$SSmenu_background><td><font color=white> &nbsp; "._QXZ("INBOUND GROUP")."</td>\n";
	$RANKgroups_list.="<td nowrap><font color=white> &nbsp; "._QXZ("RANK")." &nbsp; <br><select name=\"ingroup_js_rank_select\" id=\"ingroup_js_rank_select\" size=1 style=\"font-family: sans-serif; font-size: 10px; overflow: hidden;\"><option value=\"\">-></option>$headRANKgroups_list</select><a href=\"#\" onclick=\"ingroup_rank_val_change();return false;\"><font size=1 color=white>"._QXZ("change")."</font></a></td>\n";
	$RANKgroups_list.="<td nowrap><font color=white> &nbsp; "._QXZ("GRADE")." &nbsp; <br><select name=\"ingroup_js_grade_select\" id=\"ingroup_js_grade_select\" size=1 style=\"font-family: sans-serif; font-size: 10px; overflow: hidden;\"><option value=\"\">-></option>$headGRADEgroups_list</select><a href=\"#\" onclick=\"ingroup_grade_val_change();return false;\"><font size=1 color=white>"._QXZ("change")."</font></a></td>\n";
	$RANKgroups_list.="<td nowrap><font color=white> &nbsp; "._QXZ("CALLS")." &nbsp; </td>\n";
	$RANKgroups_list.="<td nowrap><font color=white> &nbsp; "._QXZ("LIMIT")." &nbsp; </td>\n";
	$RANKgroups_list.="<td ALIGN=CENTER><font color=white>"._QXZ("WEB VARS")."</td></tr>\n";

	$o=0;
	while ($groups_to_print > $o)
		{
		$rowx=mysqli_fetch_row($rslt);
		$group_id_values[$o] = $rowx[0];
		$group_name_values[$o] = $rowx[1];
		$o++;
		}

	$o=0;
	$USER_inbound_calls_today=0;
	$USER_inbound_calls_today_filtered=0;
	$ingroup_js_rank='';
	$ingroup_js_grade='';
	$ingroup_js_rank_ct=0;
	$ingroup_js_grade_ct=0;

	while ($groups_to_print > $o)
		{
		$group_web_vars='';
		$group_web='';
		$stmt="SELECT group_rank,calls_today,group_web_vars,group_grade,calls_today_filtered,daily_limit from vicidial_inbound_group_agents where user='$user' and group_id='$group_id_values[$o]';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$ranks_to_print = mysqli_num_rows($rslt);
		if ($ranks_to_print > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$SELECT_group_rank =	$row[0];
			$calls_today =			$row[1];
			$group_web_vars =		$row[2];
			$SELECT_group_grade =	$row[3];
			$calls_today_filtered =	$row[4];
			$group_limit =			$row[5];
			}
		else
			{$calls_today=0;   $SELECT_group_rank=0;   $SELECT_group_grade=1;   $calls_today_filtered=0;   $group_limit=-1;}
		if ( ($ADD=="4A") or ($ADD=="4B") )
			{
			if (isset($_GET["RANK_$group_id_values[$o]"]))			{$group_rank=$_GET["RANK_$group_id_values[$o]"];}
				elseif (isset($_POST["RANK_$group_id_values[$o]"]))	{$group_rank=$_POST["RANK_$group_id_values[$o]"];}
			if (isset($_GET["WEB_$group_id_values[$o]"]))			{$group_web=$_GET["WEB_$group_id_values[$o]"];}
				elseif (isset($_POST["WEB_$group_id_values[$o]"]))	{$group_web=$_POST["WEB_$group_id_values[$o]"];}
			if (isset($_GET["GRADE_$group_id_values[$o]"]))				{$group_grade=$_GET["GRADE_$group_id_values[$o]"];}
				elseif (isset($_POST["GRADE_$group_id_values[$o]"]))	{$group_grade=$_POST["GRADE_$group_id_values[$o]"];}
			if (isset($_GET["LIMIT_$group_id_values[$o]"]))				{$group_limit=$_GET["LIMIT_$group_id_values[$o]"];}
				elseif (isset($_POST["LIMIT_$group_id_values[$o]"]))	{$group_limit=$_POST["LIMIT_$group_id_values[$o]"];}

			$group_rank = preg_replace('/[^-\_0-9]/','',$group_rank);
			$group_web = preg_replace("/;|\"|\'/","",$group_web);
			$group_grade = preg_replace('/[^-\_0-9]/','',$group_grade);
			$group_limit = preg_replace('/[^-\_0-9]/','',$group_limit);
			if ( (strlen($group_limit) < 1) or ($group_limit == 'NULL') )	{$group_limit=-1;}

			if ($ranks_to_print > 0)
				{
				$stmt="UPDATE vicidial_inbound_group_agents set group_rank='$group_rank', group_weight='$group_rank', group_web_vars='$group_web', group_grade='$group_grade', daily_limit='$group_limit' where group_id='$group_id_values[$o]' and user='$user';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$affected_rows_grp = mysqli_affected_rows($link);
				if ($DB) {echo "$affected_rows_grp|$stmt|<br>\n";}
				$stmt_grp_values .= "$stmt|";
				}
			else
				{
				$stmt="INSERT INTO vicidial_inbound_group_agents set group_rank='$group_rank', group_weight='$group_rank', group_id='$group_id_values[$o]', user='$user', group_web_vars='$group_web', group_grade='$group_grade', daily_limit='$group_limit';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$affected_rows_grp = mysqli_affected_rows($link);
				if ($DB) {echo "$affected_rows_grp|$stmt|<br>\n";}
				$stmt_grp_values .= "$stmt|";
				}

			$stmt="UPDATE vicidial_live_inbound_agents set group_weight='$group_rank', group_grade='$group_grade' where group_id='$group_id_values[$o]' and user='$user';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$stmt_grp_values .= "$stmt|";
			}
		else 
			{
			$group_rank = $SELECT_group_rank;
			$group_grade = $SELECT_group_grade;
			}

		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
		else
			{$bgcolor='bgcolor="#' . $SSstd_row1_background . '"';}

		$groups_list .= "<input type=\"checkbox\" name=\"groups[]\" value=\"$group_id_values[$o]\"";
		$XFERgroups_list .= "<input type=\"checkbox\" name=\"XFERgroups[]\" value=\"$group_id_values[$o]\"";
		$RANKgroups_list .= "<tr $bgcolor><td><input type=\"checkbox\" name=\"groups[]\" value=\"$group_id_values[$o]\"";
		$p=0;
		if (is_array($groups)) {$group_ct = count($groups);} else {$group_ct=0;}
		while ($p < $group_ct)
			{
			if ($group_id_values[$o] === $groups[$p]) 
				{
				$groups_list .= " CHECKED";
				$RANKgroups_list .= " CHECKED";
				$groups_value .= " $group_id_values[$o]";
				}
			$p++;
			}
		$p=0;
		if (is_array($XFERgroups)) {$XFERgroup_ct = count($XFERgroups);} else {$XFERgroup_ct=0;}
		while ($p < $XFERgroup_ct)
			{
			if ($group_id_values[$o] === $XFERgroups[$p]) 
				{
				$XFERgroups_list .= " CHECKED";
				$XFERgroups_value .= " $group_id_values[$o]";
				}
			$p++;
			}
		$stmt="SELECT queue_priority from vicidial_inbound_groups where group_id='$group_id_values[$o]' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$VIG_priority =			$row[0];

		$ingroup_js_rank_ct++;
		$ingroup_js_grade_ct++;
		if (strlen($ingroup_js_rank) > 1)
			{
			$ingroup_js_rank .= ",";
			$ingroup_js_grade .= ",";
			}
		$ingroup_js_rank .= "'RANK_$group_id_values[$o]'";
		$ingroup_js_grade .= "'GRADE_$group_id_values[$o]'";

		$groups_list .= "> <a href=\"$PHP_SELF?ADD=3111&group_id=$group_id_values[$o]\">$group_id_values[$o]</a> - $group_name_values[$o] - $VIG_priority <BR>\n";
		$XFERgroups_list .= "> <a href=\"$PHP_SELF?ADD=3111&group_id=$group_id_values[$o]\">$group_id_values[$o]</a> - $group_name_values[$o] <BR>\n";
		$RANKgroups_list .= "> <a href=\"$PHP_SELF?ADD=3111&group_id=$group_id_values[$o]\">$group_id_values[$o]</a> - $group_name_values[$o] </td>";
		$RANKgroups_list .= "<td> &nbsp; <select size=1 name=RANK_$group_id_values[$o] id=RANK_$group_id_values[$o]>\n";
		$h="9";
		while ($h>=-9)
			{
			$RANKgroups_list .= "<option value=\"$h\"";
			if ($h==$group_rank)
				{$RANKgroups_list .= " SELECTED";}
			$RANKgroups_list .= ">$h</option>";
			$h--;
			}
		if ( (strlen($group_web) < 1) and (strlen($group_web_vars) > 0) )
			{$group_web=$group_web_vars;}
		$RANKgroups_list .= "</select></td>\n";
		$RANKgroups_list .= "<td> &nbsp; <select size=1 name=GRADE_$group_id_values[$o] id=GRADE_$group_id_values[$o]>\n";
		$h="10";
		while ($h>=1)
			{
			$RANKgroups_list .= "<option value=\"$h\"";
			if ($h==$group_grade)
				{$RANKgroups_list .= " SELECTED";}
			$RANKgroups_list .= ">$h</option>";
			$h--;
			}
		if ( (strlen($group_web) < 1) and (strlen($group_web_vars) > 0) )
			{$group_web=$group_web_vars;}
		$RANKgroups_list .= "</select></td>\n";
		$RANKgroups_list .= "<td align=right nowrap> &nbsp; &nbsp; $calls_today</td>\n";
		$RANKgroups_list .= "<td nowrap> &nbsp; <input type=text size=5 maxlength=4 name=LIMIT_$group_id_values[$o] value=\"$group_limit\"></td>\n";
		$RANKgroups_list .= "<td nowrap> &nbsp; <input type=text size=25 maxlength=255 name=WEB_$group_id_values[$o] value=\"$group_web\"></td></tr>\n";
		$o++;
		$USER_inbound_calls_today = ($USER_inbound_calls_today + $calls_today);
		$USER_inbound_calls_today_filtered = ($USER_inbound_calls_today_filtered + $calls_today_filtered);
		}
	if (strlen($groups_value)>2) {$groups_value .= " -";}
	if (strlen($XFERgroups_value)>2) {$XFERgroups_value .= " -";}
	}
	##### END get inbound groups listing for checkboxes #####


##### BEGIN get campaigns listing for checkboxes #####
if ( ($ADD==211111) or ($ADD==311111) or ($ADD==411111) or ($ADD==511111) or ($ADD==611111) )
	{
	if ( ($ADD==211111) or ($ADD==311111) or ($ADD==511111) or ($ADD==611111) )
		{
		$stmt="SELECT allowed_campaigns,qc_allowed_campaigns,qc_allowed_inbound_groups,allowed_queue_groups from vicidial_user_groups where user_group='$user_group' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$allowed_campaigns =			$row[0];
		$qc_allowed_campaigns =			$row[1];
		$qc_allowed_inbound_groups =	$row[2];
		$allowed_queue_groups =			$row[3];
		$allowed_campaigns = preg_replace("/ -$/","",$allowed_campaigns);
		$campaigns = explode(" ", $allowed_campaigns);
		$qc_allowed_campaigns = preg_replace("/ -$/","",$qc_allowed_campaigns);
		$qc_campaigns = explode(" ", $qc_allowed_campaigns);
		$qc_allowed_inbound_groups = preg_replace("/ -$/","",$qc_allowed_inbound_groups);
		$qc_groups = explode(" ", $qc_allowed_inbound_groups);
		$allowed_queue_groups = preg_replace("/ -$/","",$allowed_queue_groups);
		$queue_groups = explode(" ", $allowed_queue_groups);
		}

	$campaigns_value='';
	if ( (preg_match('/\-ALL/i', $LOGallowed_campaigns)) )
		{$campaigns_list='<B><input type="checkbox" name="campaigns[]" value="-ALL-CAMPAIGNS-"';}
	$qc_campaigns_value='';
	$qc_campaigns_list='<B><input type="checkbox" name="qc_campaigns[]" value="-ALL-CAMPAIGNS-"';
	$qc_groups_value='';
	$qc_groups_list='<B><input type="checkbox" name="qc_groups[]" value="-ALL-GROUPS-"';
	$queue_groups_value='';
	$queue_groups_list='<B><input type="checkbox" name="queue_groups[]" value="-ALL-GROUPS-"';
	$p=0;
	while ($p<2000)
		{
		if (preg_match('/ALL\-CAMPAIGNS/i',$campaigns[$p])) 
			{
			if ( (preg_match('/\-ALL/i', $LOGallowed_campaigns)) )
				{
				$campaigns_list.=" CHECKED";
				$campaigns_value .= " -ALL-CAMPAIGNS-";
				}
			}
		if (preg_match('/ALL\-CAMPAIGNS/i',$qc_campaigns[$p])) 
			{
			$qc_campaigns_list.=" CHECKED";
			$qc_campaigns_value .= " -ALL-CAMPAIGNS-";
			}
		if (preg_match('/ALL\-GROUPS/i',$qc_groups[$p])) 
			{
			$qc_groups_list.=" CHECKED";
			$qc_groups_value .= " -ALL-GROUPS-";
			}
		if (preg_match('/ALL\-GROUPS/i',$queue_groups[$p])) 
			{
			$queue_groups_list.=" CHECKED";
			$queue_groups_value .= " -ALL-GROUPS-";
			}
		$p++;
		}
	if ( (preg_match('/\-ALL/i', $LOGallowed_campaigns)) )
		{$campaigns_list.="> "._QXZ("ALL-CAMPAIGNS - USERS CAN VIEW ANY CAMPAIGN")."</B><BR>\n";}
	$qc_campaigns_list.="> "._QXZ("ALL-CAMPAIGNS - USERS CAN QC ANY CAMPAIGN")."</B><BR>\n";
	$qc_groups_list.="> "._QXZ("ALL-GROUPS - USERS CAN QC ANY INBOUND GROUP")."</B><BR>\n";
	$queue_groups_list.="> "._QXZ("ALL-GROUPS - USERS CAN VIEW ANY QUEUE GROUP")."</B><BR>\n";

	$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$campaigns_to_print = mysqli_num_rows($rslt);

	$o=0;
	while ($campaigns_to_print > $o)
		{
		$rowx=mysqli_fetch_row($rslt);
		$campaign_id_value = $rowx[0];
		$campaign_name_value = $rowx[1];
		$campaigns_list .= "<input type=\"checkbox\" name=\"campaigns[]\" value=\"$campaign_id_value\"";
		$qc_campaigns_list .= "<input type=\"checkbox\" name=\"qc_campaigns[]\" value=\"$campaign_id_value\"";
		$p=0;
		while ($p<1000)
			{
			if ( ($campaign_id_value === $campaigns[$p]) and (strlen($campaign_id_value) > 1) )
				{
			#	echo "<!--  X $p|$campaign_id_value|$campaigns[$p]| -->";
				$campaigns_list .= " CHECKED";
				$campaigns_value .= " $campaign_id_value";
				}
			if ($campaign_id_value === $qc_campaigns[$p]) 
				{
				$qc_campaigns_list .= " CHECKED";
				$qc_campaigns_value .= " $campaign_id_value";
				}
		#	echo "<!--  O $p|$campaign_id_value|$campaigns[$p]| -->";
			$p++;
			}
		$campaigns_list .= "> $campaign_id_value - $campaign_name_value<BR>\n";
		$qc_campaigns_list .= "> $campaign_id_value - $campaign_name_value<BR>\n";
		$o++;
		}

	$stmt="SELECT group_id,group_name from vicidial_inbound_groups where group_id NOT IN('AGENTDIRECT') $LOGadmin_viewable_groupsSQL order by group_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$groups_to_print = mysqli_num_rows($rslt);

	$o=0;
	while ($groups_to_print > $o)
		{
		$rowx=mysqli_fetch_row($rslt);
		$group_id_value = $rowx[0];
		$group_name_value = $rowx[1];
		$qc_groups_list .= "<input type=\"checkbox\" name=\"qc_groups[]\" value=\"$group_id_value\"";
		$p=0;
		while ($p<2000)
			{
			if ( ($group_id_value === $qc_groups[$p]) and (strlen($group_id_value) > 1) )
				{
				$qc_groups_list .= " CHECKED";
				$qc_groups_value .= " $group_id_value";
				}
			$p++;
			}
		$qc_groups_list .= "> $group_id_value - $group_name_value<BR>\n";
		$o++;
		}

	$stmt="SELECT queue_group,queue_group_name from vicidial_queue_groups where queue_group NOT IN('') $LOGadmin_viewable_groupsSQL order by queue_group;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$groups_to_print = mysqli_num_rows($rslt);

	$o=0;
	while ($groups_to_print > $o)
		{
		$rowx=mysqli_fetch_row($rslt);
		$group_id_value = $rowx[0];
		$group_name_value = $rowx[1];
		$queue_groups_list .= "<input type=\"checkbox\" name=\"queue_groups[]\" value=\"$group_id_value\"";
		$p=0;
		while ($p<2000)
			{
			if ( ($group_id_value === $queue_groups[$p]) and (strlen($group_id_value) > 1) )
				{
				$queue_groups_list .= " CHECKED";
				$queue_groups_value .= " $group_id_value";
				}
			$p++;
			}
		$queue_groups_list .= "> $group_id_value - $group_name_value<BR>\n";
		$o++;
		}

	if (strlen($campaigns_value)>2) {$campaigns_value .= " -";}
	if (strlen($qc_campaigns_value)>2) {$qc_campaigns_value .= " -";}
	if (strlen($qc_groups_value)>2) {$qc_groups_value .= " -";}
	if (strlen($queue_groups_value)>2) {$queue_groups_value .= " -";}
	}
	##### END get campaigns listing for checkboxes #####

##### BEGIN Queue Groups campaigns/in-groups listings #####
if ( ($ADD==298111111111) or ($ADD==398111111111) or ($ADD==498111111111) or ($ADD==598111111111) or ($ADD==698111111111) )
	{
	if ( ($ADD==298111111111) or ($ADD==398111111111) or ($ADD==598111111111) or ($ADD==698111111111) )
		{
		$stmt="SELECT queue_group,queue_group_name,active,user_group,included_campaigns,included_inbound_groups from vicidial_queue_groups where queue_group='$queue_group' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$included_campaigns =		$row[4];
		$included_inbound_groups =	$row[5];

		$qg_allowed_campaigns = preg_replace("/ -$/","",$included_campaigns);
		$qg_campaigns = explode(" ", $qg_allowed_campaigns);
		$qg_allowed_inbound_groups = preg_replace("/ -$/","",$included_inbound_groups);
		$qg_groups = explode(" ", $qg_allowed_inbound_groups);
		}
	if ($ADD==498111111111)
		{
		$qg_campaigns = $included_campaigns;
		$qg_groups = $included_inbound_groups;
		}

	$qg_campaigns_value='';
	$qg_campaigns_list='';
	$qg_groups_value='';
	$qg_groups_list='';

	$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$campaigns_to_print = mysqli_num_rows($rslt);

	$o=0;
	while ($campaigns_to_print > $o)
		{
		$rowx=mysqli_fetch_row($rslt);
		$campaign_id_value = $rowx[0];
		$campaign_name_value = $rowx[1];
		$qg_campaigns_list .= "<input type=\"checkbox\" name=\"included_campaigns[]\" value=\"$campaign_id_value\"";
		$p=0;
		while ($p<1000)
			{
			if ($campaign_id_value === $qg_campaigns[$p]) 
				{
				$qg_campaigns_list .= " CHECKED";
				$qg_campaigns_value .= " $campaign_id_value";
				}
		#	echo "<!--  O $p|$campaign_id_value|$campaigns[$p]| -->";
			$p++;
			}
		$qg_campaigns_list .= "> $campaign_id_value - $campaign_name_value<BR>\n";
		$o++;
		}

	$stmt="SELECT group_id,group_name from vicidial_inbound_groups where group_id NOT IN('AGENTDIRECT') $LOGadmin_viewable_groupsSQL order by group_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$groups_to_print = mysqli_num_rows($rslt);

	$o=0;
	while ($groups_to_print > $o)
		{
		$rowx=mysqli_fetch_row($rslt);
		$group_id_value = $rowx[0];
		$group_name_value = $rowx[1];
		$qg_groups_list .= "<input type=\"checkbox\" name=\"included_inbound_groups[]\" value=\"$group_id_value\"";
		$p=0;
		while ($p<2000)
			{
			if ( ($group_id_value === $qg_groups[$p]) and (strlen($group_id_value) > 1) )
				{
				$qg_groups_list .= " CHECKED";
				$qg_groups_value .= " $group_id_value";
				}
			$p++;
			}
		$qg_groups_list .= "> $group_id_value - $group_name_value<BR>\n";
		$o++;
		}

	if (strlen($qg_campaigns_value)>2) {$qg_campaigns_value .= " -";}
	if (strlen($qg_groups_value)>2) {$qg_groups_value .= " -";}
	}
##### END Queue Groups campaigns/in-groups listings #####


if ( (strlen($ADD)==11) or (strlen($ADD)>12) or ( ($ADD > 1299) and ($ADD < 9999) ) or ($ADD=='141111111111') or ($ADD=='140111111111') or ($ADD=='341111111111') or ($ADD=='311111111111111') or ( (strlen($ADD)>4) and ($ADD < 99998) ) or ($ADD==3) or (($ADD>20) and ($ADD<70)) or ($ADD=="4A") or ($ADD=="4B") or (strlen($ADD)==12) )
	{
	##### get server listing for dynamic pulldown 
	$stmt="SELECT server_ip,server_description,external_server_ip,active,active_asterisk_server from servers order by server_ip";
	$rsltx=mysql_to_mysqli($stmt, $link);
	$servers_to_print = mysqli_num_rows($rsltx);
	$servers_list='';

	$o=0;
	while ($servers_to_print > $o)
		{
		$rowx=mysqli_fetch_row($rsltx);
		$servers_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1] - $rowx[2] - "._QXZ("$rowx[3]")." - "._QXZ("$rowx[4]")."</option>\n";
		$o++;
		}
	}



$NWB = "<IMG SRC=\"help.png\" onClick=\"FillAndShowHelpDiv(event, '";
$NWE = "')\" WIDTH=20 HEIGHT=20 BORDER=0 ALT=\"HELP\" ALIGN=TOP>";



if ($ADD==99999)
	{
	echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
	echo "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=./help.php\">\n";
	echo "</HEAD>\n";
	echo "<BODY BGCOLOR=#FFFFFF marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
	echo "<a href=\"./help.php\">"._QXZ("click here to continue").". . .</a>\n";
	exit;
	}


######################################################################################################
######################################################################################################
#######   7 series, filter count preview and script preview
######################################################################################################
######################################################################################################




######################
# ADD=73 view dialable leads from a filter and a campaign
######################
if ($ADD==73)
	{
	if ($LOGmodify_campaigns==1)
		{
		echo "</head>\n";
		echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT dial_statuses,local_call_time,lead_filter_id,drop_lockout_time,call_count_limit from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$dial_statuses =		$row[0];
		$local_call_time =		$row[1];
		$drop_lockout_time =	$row[3];
		$call_count_limit =		$row[4];
		if ($lead_filter_id=='')
			{
			$lead_filter_id =	$row[2];
			if ($lead_filter_id=='') 
				{
				$lead_filter_id='NONE';
				}
			}

		$stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$lists_to_print = mysqli_num_rows($rslt);
		$camp_lists='';
		$o=0;
		while ($lists_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$o++;
			if (preg_match('/Y/', $rowx[1])) {$camp_lists .= "'$rowx[0]',";}
			}
		$camp_lists = preg_replace('/.$/i','',$camp_lists);

		$filterSQL = $filtersql_list[$lead_filter_id];
		$filterSQL = preg_replace("/\\\\/","",$filterSQL);
		$filterSQL = preg_replace('/^and|and$|^or|or$/i', '',$filterSQL);
		if (strlen($filterSQL)>4)
			{$fSQL = "and ($filterSQL)";}
		else
			{$fSQL = '';}


		echo "<BR><BR>\n";
		echo "<B>"._QXZ("Show Dialable Leads Count")."</B> -<BR><BR>\n";
		echo "<B>"._QXZ("CAMPAIGN").":</B> $campaign_id<BR>\n";
		echo "<B>"._QXZ("LISTS").":</B> $camp_lists<BR>\n";
		echo "<B>"._QXZ("STATUSES").":</B> $dial_statuses<BR>\n";
		echo "<B>"._QXZ("FILTER").":</B> $lead_filter_id<BR>\n";
		echo "<B>"._QXZ("CALL LIMIT").":</B> $call_count_limit\n";
		echo "<B>"._QXZ("CALL TIME").":</B> $local_call_time<BR><BR>\n";
		echo "<B>"._QXZ("With Filter").":</B>\n";
		echo "<BR><BR>\n";

		### call function to calculate and print dialable leads
		$single_status=0;
		$only_return=0;
		dialable_leads($DB,$link,$local_call_time,$dial_statuses,$camp_lists,$drop_lockout_time,$call_count_limit,$single_status,$fSQL,$only_return);

		echo "<BR><BR>\n";
		echo "<B>"._QXZ("Without Filter").":</B>\n";
		echo "<BR><BR>\n";

		dialable_leads($DB,$link,$local_call_time,$dial_statuses,$camp_lists,$drop_lockout_time,$call_count_limit,$single_status,'',$only_return);

		echo "<BR><BR>\n";
		echo "</BODY></HTML>\n";

		exit;
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=7111111 view sample script with test variables
######################
if ($ADD==7111111)
	{
	##### TEST VARIABLES #####
	$vendor_lead_code = 'VENDOR:LEAD;CODE';
	$list_id = 'LISTID';
	$list_name = 'LISTNAME';
	$list_description = 'LISTDESCRIPTION';
	$gmt_offset_now = 'GMTOFFSET';
	$phone_code = '1';
	$phone_number = '7275551212';
	$title = 'Mr.';
	$first_name = 'JOHN';
	$middle_initial = 'Q';
	$last_name = 'PUBLIC';
	$address1 = '1234 Main St.';
	$address2 = 'Apt. 3';
	$address3 = 'ADDRESS3';
	$city = 'CHICAGO';
	$state = 'IL';
	$province = 'PROVINCE';
	$postal_code = '33760';
	$country_code = 'USA';
	$gender = 'M';
	$date_of_birth = '1970-01-01';
	$alt_phone = '3125551111';
	$email = 'test@test.com';
	$security_phrase = 'SECUTIRY';
	$comments = 'COMMENTS FIELD';
	$RGfullname = 'JOE AGENT';
	$RGagent_email = 'Joe@agent.com';
	$RGuser = '6666';
	$RGlead_id = '1234';
	$RGcampaign = 'TESTCAMP';
	$RGphone_login = 'gs102';
	$RGgroup = 'TESTCAMP';
	$RGchannel_group = 'TESTCAMP';
	$RGSQLdate = date("Y-m-d H:i:s");
	$RGepoch = date("U");
	$RGuniqueid = '1163095830.4136';
	$RGcustomer_zap_channel = 'Zap/1-1';
	$RGserver_ip = '10.10.10.15';
	$RGSIPexten = 'SIP/gs102';
	$RGsession_id = '8600051';
	$RGdialed_number = '3125551111';
	$RGdialed_label = 'ALT';
	$RGrank = '99';
	$RGowner = '6666';
	$RGcamp_script = 'TESTSCRIPT';
	$RGin_script = '';
	$script_width = '600';
	$script_height = '400';
	$recording_filename = '20091204-1639_6666_7275551212';
	$recording_id = '1235';
	$user_custom_one = 'custom one';
	$user_custom_two = 'custom two';
	$user_custom_three = 'custom three';
	$user_custom_four = 'custom four';
	$user_custom_five = 'custom five';
	$preset_number_a = 'preset_a';
	$preset_number_b = 'preset_b';
	$preset_number_c = 'preset_c';
	$preset_number_d = 'preset_d';
	$preset_number_e = 'preset_e';
	$preset_number_f = 'preset_f';
	$preset_dtmf_a = 'preset_dtmf_a';
	$preset_dtmf_b = 'preset_dtmf_b';
	$did_id = 'did_id';
	$did_extension = 'did_extension';
	$did_pattern = 'did_pattern';
	$did_description = 'did_description';
	$closecallid = 'closecallid';
	$xfercallid = 'xfercallid';
	$agent_log_id = 'agent_log_id';
	$entry_list_id = 'entry_list_id';
	$call_id = 'call_id';
	$user_group = 'user_group';
	$called_count = '2';

	echo "</head>\n";
	echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT script_id,script_name,script_comments,script_text,active,script_color from vicidial_scripts where script_id='$script_id' $LOGadmin_viewable_groupsSQL;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$row=mysqli_fetch_row($rslt);
	$script_name =		$row[1];
	$script_text =		stripslashes($row[3]);
	$script_color =		$row[5];

	if (preg_match('/iframe src/i',$script_text))
		{
		$vendor_lead_code = preg_replace('/\s/i', '+',$vendor_lead_code);
		$list_id = preg_replace('/\s/i', '+',$list_id);
		$list_name = preg_replace('/\s/i', '+',$list_name);
		$list_description = preg_replace('/\s/i', '+',$list_description);
		$gmt_offset_now = preg_replace('/\s/i', '+',$gmt_offset_now);
		$phone_code = preg_replace('/\s/i', '+',$phone_code);
		$phone_number = preg_replace('/\s/i', '+',$phone_number);
		$title = preg_replace('/\s/i', '+',$title);
		$first_name = preg_replace('/\s/i', '+',$first_name);
		$middle_initial = preg_replace('/\s/i', '+',$middle_initial);
		$last_name = preg_replace('/\s/i', '+',$last_name);
		$address1 = preg_replace('/\s/i', '+',$address1);
		$address2 = preg_replace('/\s/i', '+',$address2);
		$address3 = preg_replace('/\s/i', '+',$address2);
		$city = preg_replace('/\s/i', '+',$city);
		$state = preg_replace('/\s/i', '+',$state);
		$province = preg_replace('/\s/i', '+',$province);
		$postal_code = preg_replace('/\s/i', '+',$postal_code);
		$country_code = preg_replace('/\s/i', '+',$country_code);
		$gender = preg_replace('/\s/i', '+',$gender);
		$date_of_birth = preg_replace('/\s/i', '+',$date_of_birth);
		$alt_phone = preg_replace('/\s/i', '+',$alt_phone);
		$email = preg_replace('/\s/i', '+',$email);
		$security_phrase = preg_replace('/\s/i', '+',$security_phrase);
		$comments = preg_replace('/\s/i', '+',$comments);
		$source_id = preg_replace('/\s/i', '+',$source_id);
		$RGfullname = preg_replace('/\s/i', '+',$RGfullname);
		$RGagent_email = preg_replace('/\s/i', '+',$RGagent_email);
		$RGuser = preg_replace('/\s/i', '+',$RGuser);
		$RGlead_id = preg_replace('/\s/i', '+',$RGlead_id);
		$RGcampaign = preg_replace('/\s/i', '+',$RGcampaign);
		$RGphone_login = preg_replace('/\s/i', '+',$RGphone_login);
		$RGgroup = preg_replace('/\s/i', '+',$RGgroup);
		$RGchannel_group = preg_replace('/\s/i', '+',$RGchannel_group);
		$RGSQLdate = preg_replace('/\s/i', '+',$RGSQLdate);
		$RGepoch = preg_replace('/\s/i', '+',$RGepoch);
		$RGuniqueid = preg_replace('/\s/i', '+',$RGuniqueid);
		$RGcustomer_zap_channel = preg_replace('/\s/i', '+',$RGcustomer_zap_channel);
		$RGserver_ip = preg_replace('/\s/i', '+',$RGserver_ip);
		$RGSIPexten = preg_replace('/\s/i', '+',$RGSIPexten);
		$RGsession_id = preg_replace('/\s/i', '+',$RGsession_id);
		$RGdialed_number = preg_replace('/\s/i', '+',$RGdialed_number);
		$RGdialed_label = preg_replace('/\s/i', '+',$RGdialed_label);
		$RGrank = preg_replace('/\s/i', '+',$RGrank);
		$RGowner = preg_replace('/\s/i', '+',$RGowner);
		$RGcamp_script = preg_replace('/\s/i', '+',$RGcamp_script);
		$RGin_script = preg_replace('/\s/i', '+',$RGin_script);
		$script_width = preg_replace('/\s/i', '+',$script_width);
		$script_height = preg_replace('/\s/i', '+',$script_height);
		$recording_filename = preg_replace('/\s/i', '+',$recording_filename);
		$recording_id = preg_replace('/\s/i', '+',$recording_id);
		$user_custom_one = preg_replace('/\s/i', '+',$user_custom_one);
		$user_custom_two = preg_replace('/\s/i', '+',$user_custom_two);
		$user_custom_three = preg_replace('/\s/i', '+',$user_custom_three);
		$user_custom_four = preg_replace('/\s/i', '+',$user_custom_four);
		$user_custom_five = preg_replace('/\s/i', '+',$user_custom_five);
		$preset_number_a = preg_replace('/\s/i', '+',$preset_number_a);
		$preset_number_b = preg_replace('/\s/i', '+',$preset_number_b);
		$preset_number_c = preg_replace('/\s/i', '+',$preset_number_c);
		$preset_number_d = preg_replace('/\s/i', '+',$preset_number_d);
		$preset_number_e = preg_replace('/\s/i', '+',$preset_number_e);
		$preset_number_f = preg_replace('/\s/i', '+',$preset_number_f);
		$preset_dtmf_a = preg_replace('/\s/i', '+',$preset_dtmf_a);
		$preset_dtmf_b = preg_replace('/\s/i', '+',$preset_dtmf_b);
		$did_description = preg_replace('/\s/i', '+',$did_description);
		}

	$script_text = preg_replace('/\-\-A\-\-vendor_lead_code\-\-B\-\-/i', "$vendor_lead_code",$script_text);
	$script_text = preg_replace('/\-\-A\-\-list_id\-\-B\-\-/i', "$list_id",$script_text);
	$script_text = preg_replace('/\-\-A\-\-list_name\-\-B\-\-/i', "$list_name",$script_text);
	$script_text = preg_replace('/\-\-A\-\-list_description\-\-B\-\-/i', "$list_description",$script_text);
	$script_text = preg_replace('/\-\-A\-\-gmt_offset_now\-\-B\-\-/i', "$gmt_offset_now",$script_text);
	$script_text = preg_replace('/\-\-A\-\-phone_code\-\-B\-\-/i', "$phone_code",$script_text);
	$script_text = preg_replace('/\-\-A\-\-phone_number\-\-B\-\-/i', "$phone_number",$script_text);
	$script_text = preg_replace('/\-\-A\-\-title\-\-B\-\-/i', "$title",$script_text);
	$script_text = preg_replace('/\-\-A\-\-first_name\-\-B\-\-/i', "$first_name",$script_text);
	$script_text = preg_replace('/\-\-A\-\-middle_initial\-\-B\-\-/i', "$middle_initial",$script_text);
	$script_text = preg_replace('/\-\-A\-\-last_name\-\-B\-\-/i', "$last_name",$script_text);
	$script_text = preg_replace('/\-\-A\-\-address1\-\-B\-\-/i', "$address1",$script_text);
	$script_text = preg_replace('/\-\-A\-\-address2\-\-B\-\-/i', "$address2",$script_text);
	$script_text = preg_replace('/\-\-A\-\-address3\-\-B\-\-/i', "$address3",$script_text);
	$script_text = preg_replace('/\-\-A\-\-city\-\-B\-\-/i', "$city",$script_text);
	$script_text = preg_replace('/\-\-A\-\-state\-\-B\-\-/i', "$state",$script_text);
	$script_text = preg_replace('/\-\-A\-\-province\-\-B\-\-/i', "$province",$script_text);
	$script_text = preg_replace('/\-\-A\-\-postal_code\-\-B\-\-/i', "$postal_code",$script_text);
	$script_text = preg_replace('/\-\-A\-\-country_code\-\-B\-\-/i', "$country_code",$script_text);
	$script_text = preg_replace('/\-\-A\-\-gender\-\-B\-\-/i', "$gender",$script_text);
	$script_text = preg_replace('/\-\-A\-\-date_of_birth\-\-B\-\-/i', "$date_of_birth",$script_text);
	$script_text = preg_replace('/\-\-A\-\-alt_phone\-\-B\-\-/i', "$alt_phone",$script_text);
	$script_text = preg_replace('/\-\-A\-\-email\-\-B\-\-/i', "$email",$script_text);
	$script_text = preg_replace('/\-\-A\-\-security_phrase\-\-B\-\-/i', "$security_phrase",$script_text);
	$script_text = preg_replace('/\-\-A\-\-comments\-\-B\-\-/i', "$comments",$script_text);
	$script_text = preg_replace('/\-\-A\-\-source_id\-\-B\-\-/i', "$source_id",$script_text);
	$script_text = preg_replace('/\-\-A\-\-fullname\-\-B\-\-/i', "$RGfullname",$script_text);
	$script_text = preg_replace('/\-\-A\-\-agent_email\-\-B\-\-/i', "$RGagent_email",$script_text);
	$script_text = preg_replace('/\-\-A\-\-fronter\-\-B\-\-/i', "$RGuser",$script_text);
	$script_text = preg_replace('/\-\-A\-\-user\-\-B\-\-/i', "$RGuser",$script_text);
	$script_text = preg_replace('/\-\-A\-\-lead_id\-\-B\-\-/i', "$RGlead_id",$script_text);
	$script_text = preg_replace('/\-\-A\-\-campaign\-\-B\-\-/i', "$RGcampaign",$script_text);
	$script_text = preg_replace('/\-\-A\-\-phone_login\-\-B\-\-/i', "$RGphone_login",$script_text);
	$script_text = preg_replace('/\-\-A\-\-group\-\-B\-\-/i', "$RGgroup",$script_text);
	$script_text = preg_replace('/\-\-A\-\-channel_group\-\-B\-\-/i', "$RGchannel_group",$script_text);
	$script_text = preg_replace('/\-\-A\-\-SQLdate\-\-B\-\-/i', "$RGSQLdate",$script_text);
	$script_text = preg_replace('/\-\-A\-\-epoch\-\-B\-\-/i', "$RGepoch",$script_text);
	$script_text = preg_replace('/\-\-A\-\-uniqueid\-\-B\-\-/i', "$RGuniqueid",$script_text);
	$script_text = preg_replace('/\-\-A\-\-customer_zap_channel\-\-B\-\-/i', "$RGcustomer_zap_channel",$script_text);
	$script_text = preg_replace('/\-\-A\-\-server_ip\-\-B\-\-/i', "$RGserver_ip",$script_text);
	$script_text = preg_replace('/\-\-A\-\-SIPexten\-\-B\-\-/i', "$RGSIPexten",$script_text);
	$script_text = preg_replace('/\-\-A\-\-session_id\-\-B\-\-/i', "$RGsession_id",$script_text);
	$script_text = preg_replace('/\-\-A\-\-dialed_number\-\-B\-\-/i', "$RGdialed_number",$script_text);
	$script_text = preg_replace('/\-\-A\-\-dialed_label\-\-B\-\-/i', "$RGdialed_label",$script_text);
	$script_text = preg_replace('/\-\-A\-\-rank\-\-B\-\-/i', "$RGrank",$script_text);
	$script_text = preg_replace('/\-\-A\-\-owner\-\-B\-\-/i', "$RGowner",$script_text);
	$script_text = preg_replace('/\-\-A\-\-camp_script\-\-B\-\-/i', "$RGcamp_script",$script_text);
	$script_text = preg_replace('/\-\-A\-\-in_script\-\-B\-\-/i', "$RGin_script",$script_text);
	$script_text = preg_replace('/\-\-A\-\-script_width\-\-B\-\-/i', "$script_width",$script_text);
	$script_text = preg_replace('/\-\-A\-\-script_height\-\-B\-\-/i', "$script_height",$script_text);
	$script_text = preg_replace('/\-\-A\-\-recording_filename\-\-B\-\-/i', "$recording_filename",$script_text);
	$script_text = preg_replace('/\-\-A\-\-recording_id\-\-B\-\-/i', "$recording_id",$script_text);
	$script_text = preg_replace('/\-\-A\-\-user_custom_one\-\-B\-\-/i', "$user_custom_one",$script_text);
	$script_text = preg_replace('/\-\-A\-\-user_custom_two\-\-B\-\-/i', "$user_custom_two",$script_text);
	$script_text = preg_replace('/\-\-A\-\-user_custom_three\-\-B\-\-/i', "$user_custom_three",$script_text);
	$script_text = preg_replace('/\-\-A\-\-user_custom_four\-\-B\-\-/i', "$user_custom_four",$script_text);
	$script_text = preg_replace('/\-\-A\-\-user_custom_five\-\-B\-\-/i', "$user_custom_five",$script_text);
	$script_text = preg_replace('/\-\-A\-\-preset_number_a\-\-B\-\-/i', "$preset_number_a",$script_text);
	$script_text = preg_replace('/\-\-A\-\-preset_number_b\-\-B\-\-/i', "$preset_number_b",$script_text);
	$script_text = preg_replace('/\-\-A\-\-preset_number_c\-\-B\-\-/i', "$preset_number_c",$script_text);
	$script_text = preg_replace('/\-\-A\-\-preset_number_d\-\-B\-\-/i', "$preset_number_d",$script_text);
	$script_text = preg_replace('/\-\-A\-\-preset_number_e\-\-B\-\-/i', "$preset_number_e",$script_text);
	$script_text = preg_replace('/\-\-A\-\-preset_number_f\-\-B\-\-/i', "$preset_number_f",$script_text);
	$script_text = preg_replace('/\-\-A\-\-preset_dtmf_a\-\-B\-\-/i', "$preset_dtmf_a",$script_text);
	$script_text = preg_replace('/\-\-A\-\-preset_dtmf_b\-\-B\-\-/i', "$preset_dtmf_b",$script_text);
	$script_text = preg_replace('/\-\-A\-\-did_id\-\-B\-\-/i', "$did_id",$script_text);
	$script_text = preg_replace('/\-\-A\-\-did_extension\-\-B\-\-/i', "$RGdid_extension",$script_text);
	$script_text = preg_replace('/\-\-A\-\-did_pattern\-\-B\-\-/i', "$did_pattern",$script_text);
	$script_text = preg_replace('/\-\-A\-\-did_description\-\-B\-\-/i', "$RGdid_description",$script_text);
	$script_text = preg_replace('/\-\-A\-\-closecallid\-\-B\-\-/i', "$closecallid",$script_text);
	$script_text = preg_replace('/\-\-A\-\-xfercallid\-\-B\-\-/i', "$xfercallid",$script_text);
	$script_text = preg_replace('/\-\-A\-\-agent_log_id\-\-B\-\-/i', "$agent_log_id",$script_text);
	$script_text = preg_replace('/\-\-A\-\-entry_list_id\-\-B\-\-/i', "$entry_list_id",$script_text);
	$script_text = preg_replace('/\-\-A\-\-call_id\-\-B\-\-/i', "$call_id",$script_text);
	$script_text = preg_replace('/\-\-A\-\-user_group\-\-B\-\-/i', "$user_group",$script_text);
	$script_text = preg_replace('/\-\-A\-\-called_count\-\-B\-\-/i', "$called_count",$script_text);
	$script_text = preg_replace('/\n/i', "<BR>",$script_text);


	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	echo _QXZ("Preview Script").": $script_id<BR>\n";
	echo "<TABLE WIDTH=600";
	if (strlen($script_color)>1) {echo " bgcolor=\"$script_color\"";}
	echo "><TR><TD>\n";
	echo "<center><B>$script_name</B><BR></center>\n";
	echo "$script_text\n";
	echo "</TD></TR></TABLE></center>\n";

	echo "</BODY></HTML>\n";

	exit;
	}

$no_title=1;
$ADMIN=$PHP_SELF;
require("admin_header.php");

if ( ($SSadmin_modify_refresh > 1) and (preg_match("/^3|^4/",$ADD)) )
	{
	echo "<span id=refresh_countdown></span><BR>";
	}


######################################################################################################
######################################################################################################
#######   1 series, ADD NEW forms for inserting new records into the database
######################################################################################################
######################################################################################################


######################
# ADD=1 display the ADD NEW USER FORM SCREEN
######################
if ($ADD=="1")
	{
	if ($LOGmodify_users==1)
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_users' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$voi_count = "$row[0]";
			}
		##### END ID override optional section #####

		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_black_users.png\" alt=\"Users\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD A NEW USER")."<form action=$PHP_SELF method=POST name=userform id=userform>\n";
		echo "<input type=hidden name=ADD value=2>\n";
		echo "<input type=hidden name=DB value=$DB>\n";
		echo "<input type=hidden name=user_toggle id=user_toggle value=0>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		if ($voi_count > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User Number").": </td><td align=left>"._QXZ("Auto-Generated")." <input type=hidden name=user id=user value=\"99999\">$NWB#users-user$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User Number").": </td><td align=left><input type=text name=user id=user size=20 maxlength=20> <input style='background-color:#$SSbutton_color' type=button name=auto_user value=\""._QXZ("AUTO-GENERATE")."\" onClick=\"user_auto()\"> $NWB#users-user$NWE</td></tr>\n";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Password").": </td><td align=left style=\"display:table-cell; vertical-align:middle;\" NOWRAP><input type=text id=reg_pass name=pass size=50 maxlength=100 onkeyup=\"return pwdChanged('reg_pass','reg_pass_img','pass_length','$SSrequire_password_length');\">$NWB#users-pass$NWE &nbsp; &nbsp; <font size=1> "._QXZ("Strength").":</font> <IMG id=reg_pass_img src='images/pixel.gif' style=\"vertical-align:middle;\" onLoad=\"return pwdChanged('reg_pass','reg_pass_img','pass_length','$SSrequire_password_length');\"> &nbsp; <font size=1>"._QXZ("Length").": <span id=pass_length name=pass_length>0</span></font></td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Full Name").": </td><td align=left><input type=text name=full_name size=20 maxlength=100>$NWB#users-full_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User Level").": </td><td align=left><select size=1 name=user_level>";
		$h=1;
		$count_user_level=$LOGuser_level;
		if ( ($LOGmodify_same_user_level < 1) and ($LOGuser_level > 8) )
			{$count_user_level=($LOGuser_level - 1);}
		while ($h<=$count_user_level)
			{
			echo "<option>$h</option>";
			$h++;
			}
		echo "</select>$NWB#users-user_level$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "</select>$NWB#users-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Phone Login").": </td><td align=left><input type=text name=phone_login size=20 maxlength=20>$NWB#users-phone_login$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Phone Pass").": </td><td align=left><input type=text name=phone_pass size=20 maxlength=20>$NWB#users-phone_pass$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=button name=SUBMIT value='"._QXZ("SUBMIT")."' onClick=\"user_submit()\"></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=1A display the COPY USER FORM SCREEN
######################
if ($ADD=="1A")
	{
	if ($LOGmodify_users==1)
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_users' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$voi_count = "$row[0]";
			}
		##### END ID override optional section #####

		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_black_users.png\" alt=\"Users\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("COPY USER")."<form action=$PHP_SELF method=POST name=userform id=userform>\n";
		echo "<input type=hidden name=ADD value=2A>\n";
		echo "<input type=hidden name=user_toggle id=user_toggle value=0>\n";
		echo "<center><TABLE width=800 cellspacing=3>\n";
		if ($voi_count > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("New User Number").": </td><td align=left>"._QXZ("Auto-Generated")." <input type=hidden name=user id=user value=\"99999\">$NWB#users-user$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("New User Number").": </td><td align=left><input type=text name=user id=user size=20 maxlength=20> <input style='background-color:#$SSbutton_color' type=button name=auto_user value=\""._QXZ("AUTO-GENERATE")."\" onClick=\"user_auto()\"> $NWB#users-user$NWE</td></tr>\n";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Password").": </td><td align=left style=\"display:table-cell; vertical-align:middle;\" NOWRAP><input type=text id=reg_pass name=pass size=50 maxlength=100 onkeyup=\"return pwdChanged('reg_pass','reg_pass_img','pass_length','$SSrequire_password_length');\">$NWB#users-pass$NWE &nbsp; &nbsp; <font size=1>"._QXZ("Strength").":</font> <IMG id=reg_pass_img src='images/pixel.gif' style=\"vertical-align:middle;\" onLoad=\"return pwdChanged('reg_pass','reg_pass_img','pass_length','$SSrequire_password_length');\"> &nbsp; <font size=1> "._QXZ("Length").": <span id=pass_length name=pass_length>0</span></font></td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Full Name").": </td><td align=left><input type=text name=full_name size=20 maxlength=100>$NWB#users-full_name$NWE</td></tr>\n";

		if ($LOGuser_level==9) {$levelMAX=10;}
		else {$levelMAX=$LOGuser_level;}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Source User").": </td><td align=left><select size=1 name=source_user_id>\n";

		$stmt="SELECT user,full_name from vicidial_users where user_level < $levelMAX and user NOT IN('VDAD','VDCL') $LOGadmin_viewable_groupsSQL order by full_name;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$Uusers_to_print = mysqli_num_rows($rslt);
		$Uusers_list='';

		$o=0;
		while ($Uusers_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$Uusers_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		echo "$Uusers_list";
		echo "</select>$NWB#users-user$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=button name=SUBMIT value='"._QXZ("SUBMIT")."' onClick=\"user_submit()\"></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=11 display the ADD NEW CAMPAIGN FORM SCREEN
######################
if ($ADD==11)
	{
	if ($LOGmodify_campaigns==1)
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_campaigns' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$voi_count = "$row[0]";
			}
		##### END ID override optional section #####

		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_black_campaigns.png\" alt=\"Campaigns\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD A NEW CAMPAIGN")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=21>\n";
		echo "<input type=hidden name=park_ext value=''>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		if ($voi_count > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign ID").": </td><td align=left>"._QXZ("Auto-Generated")." $NWB#campaigns-campaign_id$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign ID").": </td><td align=left><input type=text name=campaign_id size=10 maxlength=8>$NWB#campaigns-campaign_id$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign Name").": </td><td align=left><input type=text name=campaign_name size=40 maxlength=40>$NWB#campaigns-campaign_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign Description").": </td><td align=left><input type=text name=campaign_description size=40 maxlength=255>$NWB#campaigns-campaign_description$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#campaigns-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option></select>$NWB#campaigns-active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Park Music-on-Hold").": </td><td align=left><input type=text name=park_file_name id=park_file_name size=20 maxlength=100> <a href=\"javascript:launch_moh_chooser('park_file_name','moh');\">"._QXZ("moh chooser")."</a> $NWB#campaigns-park_ext$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Web Form").": </td><td align=left><input type=text name=web_form_address size=70 maxlength=9999>$NWB#campaigns-web_form_address$NWE"; if ($SSenable_first_webform < 1) {echo " <font color=red><b>"._QXZ("DISABLED")."</b></font>";} echo "</td></tr>\n";
		if ($SSoutbound_autodial_active > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Allow Closers").": </td><td align=left><select size=1 name=allow_closers><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option></select>$NWB#campaigns-allow_closers$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Minimum Hopper Level").": </td><td align=left><select size=1 name=hopper_level><option>1</option><option>5</option><option>10</option><option>20</option><option>50</option><option>100</option><option>200</option><option>500</option><option>1000</option><option>2000</option><option>3000</option><option>4000</option><option>5000</option></select>$NWB#campaigns-hopper_level$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Auto Dial Level").": </td><td align=left><select size=1 name=auto_dial_level><option selected>1</option><option>0</option>\n";
			$adl=0;
			while($adl <= $SSauto_dial_limit)
				{
				if ($adl < 1)
					{$adl = ($adl + 1);}
				else
					{
					if ($adl < 3)
						{$adl = ($adl + 0.1);}
					else
						{
						if ($adl < 4)
							{$adl = ($adl + 0.25);}
						else
							{
							if ($adl < 5)
								{$adl = ($adl + 0.5);}
							else
								{
								if ($adl < 20)
									{$adl = ($adl + 1);}
								else
									{
									if ($adl < 40)
										{$adl = ($adl + 2);}
									else
										{
										if ($adl < 100)
											{$adl = ($adl + 5);}
										else
											{
											if ($adl < 200)
												{$adl = ($adl + 10);}
											else
												{
												if ($adl < 400)
													{$adl = ($adl + 50);}
												else
													{
													if ($adl < 1000)
														{$adl = ($adl + 100);}
													else
														{$adl = ($adl + 1);}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				if ($adl > $SSauto_dial_limit) {$hmm=1;}
				else {echo "<option>$adl</option>\n";}
				}
			echo "</select>(0 = "._QXZ("off").")$NWB#campaigns-auto_dial_level$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Next Agent Call").": </td><td align=left><select size=1 name=next_agent_call><option value='random'>"._QXZ("random")."</option><option value='oldest_call_start'>"._QXZ("oldest_call_start")."</option><option value='oldest_call_finish'>"._QXZ("oldest_call_finish")."</option><option value='overall_user_level'>"._QXZ("overall_user_level")."</option><option value='campaign_rank'>"._QXZ("campaign_rank")."</option><option value='campaign_grade_random'>"._QXZ("campaign_grade_random")."</option><option value='fewest_calls'>"._QXZ("fewest_calls")."</option><option value='longest_wait_time'>"._QXZ("longest_wait_time")."</option><option value='overall_user_level_wait_time'>"._QXZ("overall_user_level_wait_time")."</option><option value='campaign_rank_wait_time'>"._QXZ("campaign_rank_wait_time")."</option><option value='fewest_calls_wait_time'>"._QXZ("fewest_calls_wait_time")."</option></select>$NWB#campaigns-next_agent_call$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Local Call Time").": </td><td align=left><select size=1 name=local_call_time>";
		echo "$call_times_list";
		echo "</select>$NWB#campaigns-local_call_time$NWE</td></tr>\n";

		if ($SSoutbound_autodial_active > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Voicemail").": </td><td align=left><input type=text name=voicemail_ext size=10 maxlength=10 value=\"$voicemail_ext\">$NWB#campaigns-voicemail_ext$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Script").": </td><td align=left><select size=1 name=script_id>\n";
		echo "$scripts_list";
		echo "</select>$NWB#campaigns-campaign_script$NWE</td></tr>\n";
		if ($SSenable_second_script > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Script Two").": </td><td align=left><select size=1 name=campaign_script_two>\n";
			echo "$scripts_list";
			echo "</select>$NWB#campaigns-campaign_script$NWE</td></tr>\n";
			}

		$eswHTML=''; $cfwHTML=''; $aemHTML=''; $achHTML='';
		if ($SSenable_second_script > 0)
			{$eswHTML .= "<option value='SCRIPTTWO'>"._QXZ("SCRIPTTWO")."</option>";}
		if ($SSenable_second_webform > 0)
			{$eswHTML .= "<option value='WEBFORMTWO'>"._QXZ("WEBFORMTWO")."</option>";}
		if ($SSenable_third_webform > 0)
			{$eswHTML .= "<option value='WEBFORMTHREE'>"._QXZ("WEBFORMTHREE")."</option>";}
		if ($SScustom_fields_enabled > 0)
			{$cfwHTML .= "<option value='FORM'>"._QXZ("FORM")."</option>";}
		if ($SSallow_emails > 0)
			{$aemHTML .= "<option value='EMAIL'>"._QXZ("EMAIL")."</option>";}
		if ($SSallow_chats > 0)
			{$achHTML .= "<option value='CHAT'>"._QXZ("CHAT")."</option>";}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Get Call Launch").": </td><td align=left><select size=1 name=get_call_launch><option selected value='NONE'>"._QXZ("NONE")."</option><option value='SCRIPT'>"._QXZ("SCRIPT")."</option><option value='WEBFORM'>"._QXZ("WEBFORM")."</option>$eswHTML$cfwHTML$aemHTML$achHTML</select>$NWB#campaigns-get_call_launch$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=12 display the COPY CAMPAIGN FORM SCREEN
######################
if ($ADD==12)
	{
	if ($LOGmodify_campaigns==1)
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_campaigns' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$voi_count = "$row[0]";
			}
		##### END ID override optional section #####

		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_black_campaigns.png\" alt=\"Campaigns\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("COPY A CAMPAIGN")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=20>\n";
		echo "<input type=hidden name=DB value=\"$DB\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		if ($voi_count > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign ID").": </td><td align=left>"._QXZ("Auto-Generated")." $NWB#campaigns-campaign_id$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign ID").": </td><td align=left><input type=text name=campaign_id size=10 maxlength=8>$NWB#campaigns-campaign_id$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign Name").": </td><td align=left><input type=text name=campaign_name size=40 maxlength=40>$NWB#campaigns-campaign_name$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Source Campaign").": </td><td align=left><select size=1 name=source_campaign_id>\n";

		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campaigns_to_print = mysqli_num_rows($rslt);
		$campaigns_list='';

		$o=0;
		while ($campaigns_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$campaigns_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		echo "$campaigns_list";
		echo "</select>$NWB#campaigns-campaign_id$NWE</td></tr>\n";
		
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>"._QXZ("NOTE: Copying a campaign will copy all settings from the master campaign you select, but it will not copy a campaign-specific DNC list if there was one on the selected master campaign.")."</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=111 display the ADD NEW LIST FORM SCREEN
######################
if ($ADD==111)
	{
	if ($LOGmodify_lists==1)
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_lists' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$voi_count = "$row[0]";
			}
		##### END ID override optional section #####

		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_black_lists.png\" alt=\"Lists\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD A NEW LIST")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=211>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		if ($voi_count > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("List ID").": </td><td align=left>"._QXZ("Auto-Generated")." $NWB#lists-list_id$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("List ID").": </td><td align=left><input type=text name=list_id size=19 maxlength=19> ("._QXZ("digits only").")$NWB#lists-list_id$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("List Name").": </td><td align=left><input type=text name=list_name size=30 maxlength=30>$NWB#lists-list_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("List Description").": </td><td align=left><input type=text name=list_description size=30 maxlength=255>$NWB#lists-list_description$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign").": </td><td align=left><select size=1 name=campaign_id>\n";

		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campaigns_to_print = mysqli_num_rows($rslt);
		$campaigns_list='';

		$o=0;
		while ($campaigns_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$campaigns_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		echo "$campaigns_list";
		echo "<option SELECTED>$campaign_id</option>\n";
		echo "</select>$NWB#lists-campaign_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='Y'>"._QXZ("Y")."</option><option value=\"N\" SELECTED>"._QXZ("N")."</option></select>$NWB#lists-active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=121 display the ADD NUMBER TO DNC FORM SCREEN and add a new number
######################
if ($ADD==121)
	{
	### filter for DIGITS and NEWLINES
	$phone_numbers = preg_replace('/[^X\n0-9]/', '',$phone_numbers);

	echo "<TABLE WIDTH=900><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$campaigns_list = "<option SELECTED value=\"SYSTEM_INTERNAL\">"._QXZ("SYSTEM_INTERNAL - INTERNAL DNC LIST")."</option>\n";
	$campaigns_list .= "<option value=\"ALL_DNC_CAMPAIGNS\">"._QXZ("ALL_DNC_CAMPAIGNS - All campaign DNC lists with camp DNC active")."</option>\n";
	$campaigns_list .= "<option value=\"ALL_ACTIVE_CAMPAIGNS\">"._QXZ("ALL_ACTIVE_CAMPAIGNS - All campaign DNC lists for active campaigns")."</option>\n";
	$campaigns_list .= "<option value=\"ALL_ACTIVE_DNC_CAMPAIGNS\">"._QXZ("ALL_ACTIVE_DNC_CAMPAIGNS - All campaign DNC lists with camp DNC active for active campaigns")."</option>\n";
	$campaigns_list .= "<option value=\"ALL_CAMPAIGNS\">"._QXZ("ALL_CAMPAIGNS - All campaign DNC lists")."</option>\n";


	$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where use_campaign_dnc IN('Y','AREACODE') $LOGallowed_campaignsSQL order by campaign_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$campaigns_to_print = mysqli_num_rows($rslt);

	$o=0;
	while ($campaigns_to_print > $o) 
		{
		$rowx=mysqli_fetch_row($rslt);
		$campaigns_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
		$o++;
		}

	# DNC Log Search
	if (strlen($phone) > 2)
		{
		echo "<br>"._QXZ("SEARCHING FOR PHONE NUMBER IN DNC LIST LOGS").": <b>$phone</b><br><br>\n";

		$stmt = "SELECT campaign_id,action,action_date,user FROM vicidial_dnc_log where phone_number='$phone' order by action_date desc limit 1000;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$vdl_ct = mysqli_num_rows($rslt);
		$i=0;
		if ($vdl_ct > 0)
			{
			echo "<center><TABLE width=400 cellspacing=0 cellpadding=1>\n";
			echo "<tr bgcolor=black>";
			echo "<td><font size=1 color=white align=left><B>"._QXZ("CAMPAIGN")."</B></td>";
			echo "<td><font size=1 color=white><B>"._QXZ("ACTION")."</B></td>";
			echo "<td><font size=1 color=white><B>"._QXZ("DATE")." &nbsp; </B></td>";
			echo "<td><font size=1 color=white><B>"._QXZ("USER")." &nbsp; </B></td></tr>\n";
			}
		else
			{
			echo _QXZ("No Results Found")."\n";
			}
		while ($vdl_ct > $i)
			{
			if (preg_match('/1$|3$|5$|7$|9$/i', $i))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#' . $SSstd_row1_background . '"';}
			$row=mysqli_fetch_row($rslt);
			$vdl_campaign =		$row[0];
			$vdl_action =		$row[1];
			$vdl_action_date =	$row[2];
			$vdl_user =			$row[3];

			echo "<tr $bgcolor><td><font size=1>";
			if ($vdl_campaign == '-SYSINT-')
				{echo "$vdl_campaign";}
			else
				{echo "<a href=\"$PHP_SELF?ADD=31&campaign_id=$vdl_campaign\">$vdl_campaign</a>";}
			echo "</font></td>";
			echo "<td><font size=1> $vdl_action</td>";
			echo "<td><font size=1> $vdl_action_date</td>";
			echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=3&user=$vdl_user\">$vdl_user</a></td></tr>\n";

			$i++;
			}

		echo "</TABLE></center>\n";
		echo "<br><br><br>\n";
		}

	# Add / Delete from DNC
	if (strlen($phone_numbers) > 2)
		{
		$PN = explode("\n",$phone_numbers);
		$PNct = count($PN);
		$p=0;   $DNCadded=0;   $DNCnotadded=0;   $DNCdeleted=0;   $DNCnotdeleted=0;
		while ($p < $PNct)
			{
			if ( (preg_match('/delete/',$stage)) and ($LOGdelete_from_dnc > 0) )
				{
				##### BEGIN DELETE FROM DNC #####
				if (preg_match('/SYSTEM_INTERNAL/',$campaign_id))
					{
					$stmt="SELECT count(*) from vicidial_dnc where phone_number='$PN[$p]';";
					$rslt=mysql_to_mysqli($stmt, $link);
					$row=mysqli_fetch_row($rslt);
					if ($row[0] < 1)
						{
						echo "<br>"._QXZ("DNC NOT DELETED - This phone number is not in the Do Not Call List").": $PN[$p]\n";
						$DNCnotdeleted++;
						}
					else
						{
						$stmt="DELETE FROM vicidial_dnc where phone_number='$PN[$p]';";
						$rslt=mysql_to_mysqli($stmt, $link);

						echo "<br><B>"._QXZ("DNC DELETED").": $PN[$p]</B>\n";
						$DNCdeleted++;

						### LOG INSERTION Admin Log Table ###
						$SQL_log = "$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='LISTS', event_type='DELETE', record_id='$PN[$p]', event_code='ADMIN DELETE NUMBER FROM DNC LIST', event_sql=\"$SQL_log\", event_notes='';";
						if ($DB) {echo "|$stmt|\n";}
						$rslt=mysql_to_mysqli($stmt, $link);

						$stmt="INSERT INTO vicidial_dnc_log SET phone_number='$PN[$p]', campaign_id='-SYSINT-', action='delete', action_date=NOW(), user='$PHP_AUTH_USER';";
						$rslt=mysql_to_mysqli($stmt, $link);
						}
					}
				### DELETE FROM ALL_CAMPAIGNS, ALL_DNC_CAMPAIGNS, ALL_ACTIVE_CAMPAIGNS, ALL_ACTIVE_DNC_CAMPAIGNS
				elseif (preg_match('/ALL_CAMPAIGNS|ALL_ACTIVE_CAMPAIGNS|ALL_DNC_CAMPAIGNS|ALL_ACTIVE_DNC_CAMPAIGNS/',$campaign_id))
					{
					echo "<br><i>"._QXZ("DNC DELETE PROCESS STARTED").": $PN[$p] $campaign_id</i>\n";
					$multi_stmts='';
					$camp_typeSQL='';
					$numberDNCnotdeleted=0;
					$numberDNCdeleted=0;
					if (preg_match('/ALL_DNC_CAMPAIGNS/',$campaign_id)) {$camp_typeSQL = "where use_campaign_dnc IN('Y','AREACODE')";}
					if (preg_match('/ALL_ACTIVE_CAMPAIGNS/',$campaign_id)) {$camp_typeSQL = "where active='Y'";}
					if (preg_match('/ALL_ACTIVE_DNC_CAMPAIGNS/',$campaign_id)) {$camp_typeSQL = "where active='Y' and use_campaign_dnc IN('Y','AREACODE')";}
					### gather all campaign IDs for selected group of campaigns
					$stmt = "SELECT campaign_id FROM vicidial_campaigns $camp_typeSQL order by campaign_id;";
					$rslt=mysql_to_mysqli($stmt, $link);
					$camp_ct = mysqli_num_rows($rslt);
					$cdnc=0;
					while ($camp_ct > $cdnc)
						{
						$row=mysqli_fetch_row($rslt);
						$camp_list[$cdnc] = $row[0];
						$cdnc++;
						}
					$cdnc=0;
					while ($camp_ct > $cdnc)
						{
						$temp_campaign_id = $camp_list[$cdnc];
						$stmt="SELECT count(*) from vicidial_campaign_dnc where phone_number='$PN[$p]' and campaign_id='$temp_campaign_id' $LOGallowed_campaignsSQL;";
						$rslt=mysql_to_mysqli($stmt, $link);
						$row=mysqli_fetch_row($rslt);
						if ($row[0] < 1)
							{
							echo "<br>"._QXZ("DNC NOT DELETED - This phone number is not in the Do Not Call List").": $PN[$p] $temp_campaign_id\n";
							$DNCnotdeleted++;
							$numberDNCnotdeleted++;
							}
						else
							{
							$stmt="DELETE FROM vicidial_campaign_dnc where phone_number='$PN[$p]' and campaign_id='$temp_campaign_id';";
							$rslt=mysql_to_mysqli($stmt, $link);
							$affected_rows = mysqli_affected_rows($link);
							$multi_stmts .= "$stmt|";

							echo "<br><B>"._QXZ("DNC DELETED").": $affected_rows - $PN[$p] $temp_campaign_id</B>\n";
							$DNCdeleted = ($DNCdeleted + $affected_rows);
							$numberDNCdeleted = ($numberDNCdeleted + $affected_rows);

							$stmt="INSERT INTO vicidial_dnc_log SET phone_number='$PN[$p]', campaign_id='$temp_campaign_id', action='delete', action_date=NOW(), user='$PHP_AUTH_USER';";
							$rslt=mysql_to_mysqli($stmt, $link);
							}
						$cdnc++;
						}

					if ($camp_ct > 0)
						{
						### LOG INSERTION Admin Log Table ###
						$SQL_log = "$multi_stmts|";
						$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='LISTS', event_type='DELETE', record_id='$PN[$p]', event_code='ADMIN DELETE NUMBER FROM CAMPAIGN DNC LIST $campaign_id', event_sql=\"$SQL_log\", event_notes='Deleted: $numberDNCdeleted   Not-Deleted: $numberDNCnotdeleted';";
						if ($DB) {echo "|$stmt|\n";}
						$rslt=mysql_to_mysqli($stmt, $link);
						}
					}
				else
					{
					$stmt="SELECT count(*) from vicidial_campaign_dnc where phone_number='$PN[$p]' and campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
					$rslt=mysql_to_mysqli($stmt, $link);
					$row=mysqli_fetch_row($rslt);
					if ($row[0] < 1)
						{
						echo "<br>"._QXZ("DNC NOT DELETED - This phone number is not in the Do Not Call List").": $PN[$p] $campaign_id\n";
						$DNCnotdeleted++;
						}
					else
						{
						$stmt="DELETE FROM vicidial_campaign_dnc where phone_number='$PN[$p]' and campaign_id='$campaign_id';";
						$rslt=mysql_to_mysqli($stmt, $link);

						echo "<br><B>"._QXZ("DNC DELETED").": $PN[$p] $campaign_id</B>\n";
						$DNCdeleted++;

						### LOG INSERTION Admin Log Table ###
						$SQL_log = "$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='LISTS', event_type='DELETE', record_id='$PN[$p]', event_code='ADMIN DELETE NUMBER FROM CAMPAIGN DNC LIST $campaign_id', event_sql=\"$SQL_log\", event_notes='';";
						if ($DB) {echo "|$stmt|\n";}
						$rslt=mysql_to_mysqli($stmt, $link);

						$stmt="INSERT INTO vicidial_dnc_log SET phone_number='$PN[$p]', campaign_id='$campaign_id', action='delete', action_date=NOW(), user='$PHP_AUTH_USER';";
						$rslt=mysql_to_mysqli($stmt, $link);
						}
					}
				##### END DELETE FROM DNC #####
				}
			else
				{
				##### BEGIN ADD TO DNC #####
				if (preg_match('/SYSTEM_INTERNAL/',$campaign_id))
					{
					$stmt="SELECT count(*) from vicidial_dnc where phone_number='$PN[$p]';";
					$rslt=mysql_to_mysqli($stmt, $link);
					$row=mysqli_fetch_row($rslt);
					if ($row[0] > 0)
						{
						echo "<br>"._QXZ("DNC NOT ADDED - This phone number is already in the Do Not Call List").": $PN[$p]\n";
						$DNCnotadded++;
						}
					else
						{
						$stmt="INSERT INTO vicidial_dnc (phone_number) values('$PN[$p]');";
						$rslt=mysql_to_mysqli($stmt, $link);

						echo "<br><B>"._QXZ("DNC ADDED").": $PN[$p]</B>\n";
						$DNCadded++;

						### LOG INSERTION Admin Log Table ###
						$SQL_log = "$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='LISTS', event_type='ADD', record_id='$PN[$p]', event_code='ADMIN ADD NUMBER TO DNC LIST', event_sql=\"$SQL_log\", event_notes='';";
						if ($DB) {echo "|$stmt|\n";}
						$rslt=mysql_to_mysqli($stmt, $link);

						$stmt="INSERT INTO vicidial_dnc_log SET phone_number='$PN[$p]', campaign_id='-SYSINT-', action='add', action_date=NOW(), user='$PHP_AUTH_USER';";
						$rslt=mysql_to_mysqli($stmt, $link);
						}
					}
				### ADD TO ALL_CAMPAIGNS, ALL_DNC_CAMPAIGNS, ALL_ACTIVE_CAMPAIGNS, ALL_ACTIVE_DNC_CAMPAIGNS
				elseif (preg_match('/ALL_CAMPAIGNS|ALL_ACTIVE_CAMPAIGNS|ALL_DNC_CAMPAIGNS|ALL_ACTIVE_DNC_CAMPAIGNS/',$campaign_id))
					{
					echo "<br><i>"._QXZ("DNC ADD PROCESS STARTED").": $PN[$p] $campaign_id</i>\n";
					$multi_stmts='';
					$camp_typeSQL='';
					$numberDNCnotadded=0;
					$numberDNCadded=0;
					if (preg_match('/ALL_DNC_CAMPAIGNS/',$campaign_id)) {$camp_typeSQL = "where use_campaign_dnc IN('Y','AREACODE')";}
					if (preg_match('/ALL_ACTIVE_CAMPAIGNS/',$campaign_id)) {$camp_typeSQL = "where active='Y'";}
					if (preg_match('/ALL_ACTIVE_DNC_CAMPAIGNS/',$campaign_id)) {$camp_typeSQL = "where active='Y' and use_campaign_dnc IN('Y','AREACODE')";}
					### gather all campaign IDs for selected group of campaigns
					$stmt = "SELECT campaign_id FROM vicidial_campaigns $camp_typeSQL order by campaign_id;";
					$rslt=mysql_to_mysqli($stmt, $link);
					$camp_ct = mysqli_num_rows($rslt);
					$cdnc=0;
					while ($camp_ct > $cdnc)
						{
						$row=mysqli_fetch_row($rslt);
						$camp_list[$cdnc] = $row[0];
						$cdnc++;
						}
					$cdnc=0;
					while ($camp_ct > $cdnc)
						{
						$temp_campaign_id = $camp_list[$cdnc];
						$stmt="SELECT count(*) from vicidial_campaign_dnc where phone_number='$PN[$p]' and campaign_id='$temp_campaign_id' $LOGallowed_campaignsSQL;";
						$rslt=mysql_to_mysqli($stmt, $link);
						$row=mysqli_fetch_row($rslt);
						if ($row[0] > 0)
							{
							echo "<br>"._QXZ("DNC NOT ADDED - This phone number is already in the Do Not Call List").": $PN[$p] $temp_campaign_id\n";
							$DNCnotadded++;
							$numberDNCnotadded++;
							}
						else
							{
							$stmt="INSERT INTO vicidial_campaign_dnc (phone_number,campaign_id) values('$PN[$p]','$temp_campaign_id');";
							$rslt=mysql_to_mysqli($stmt, $link);
							$affected_rows = mysqli_affected_rows($link);
							$multi_stmts .= "$stmt|";

							echo "<br><B>"._QXZ("DNC ADDED").": $affected_rows - $PN[$p] $temp_campaign_id</B>\n";
							$DNCadded = ($DNCadded + $affected_rows);
							$numberDNCadded = ($numberDNCadded + $affected_rows);

							$stmt="INSERT INTO vicidial_dnc_log SET phone_number='$PN[$p]', campaign_id='$temp_campaign_id', action='add', action_date=NOW(), user='$PHP_AUTH_USER';";
							$rslt=mysql_to_mysqli($stmt, $link);
							}
						$cdnc++;
						}

					if ($camp_ct > 0)
						{
						### LOG INSERTION Admin Log Table ###
						$SQL_log = "$multi_stmts|";
						$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='LISTS', event_type='ADD', record_id='$PN[$p]', event_code='ADMIN ADD NUMBER TO CAMPAIGN DNC LIST $campaign_id', event_sql=\"$SQL_log\", event_notes='Added: $numberDNCadded   Not-Added: $numberDNCnotadded';";
						if ($DB) {echo "|$stmt|\n";}
						$rslt=mysql_to_mysqli($stmt, $link);
						}
					}
				else
					{
					$stmt="SELECT count(*) from vicidial_campaign_dnc where phone_number='$PN[$p]' and campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
					$rslt=mysql_to_mysqli($stmt, $link);
					$row=mysqli_fetch_row($rslt);
					if ($row[0] > 0)
						{
						echo "<br>"._QXZ("DNC NOT ADDED - This phone number is already in the Do Not Call List").": $PN[$p] $campaign_id\n";
						$DNCnotadded++;
						}
					else
						{
						$stmt="INSERT INTO vicidial_campaign_dnc (phone_number,campaign_id) values('$PN[$p]','$campaign_id');";
						$rslt=mysql_to_mysqli($stmt, $link);

						echo "<br><B>"._QXZ("DNC ADDED").": $PN[$p] $campaign_id</B>\n";
						$DNCadded++;

						### LOG INSERTION Admin Log Table ###
						$SQL_log = "$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='LISTS', event_type='ADD', record_id='$PN[$p]', event_code='ADMIN ADD NUMBER TO CAMPAIGN DNC LIST $campaign_id', event_sql=\"$SQL_log\", event_notes='';";
						if ($DB) {echo "|$stmt|\n";}
						$rslt=mysql_to_mysqli($stmt, $link);

						$stmt="INSERT INTO vicidial_dnc_log SET phone_number='$PN[$p]', campaign_id='$campaign_id', action='add', action_date=NOW(), user='$PHP_AUTH_USER';";
						$rslt=mysql_to_mysqli($stmt, $link);
						}
					}
				##### END ADD TO DNC #####
				}
			$p++;
			}
		
		if ( ($DNCadded > 0) or ($DNCnotadded > 0) )
			{
			echo "<br>\n";
			echo "<br><B>"._QXZ("TOTAL NUMBERS ADDED TO DNC LIST").": $DNCadded</B>\n";
			echo "<br><B>"._QXZ("TOTAL NUMBERS NOT ADDED TO DNC LIST").": $DNCnotadded</B>\n";
			echo "<br>\n";
			}
		if ( ($DNCdeleted > 0) or ($DNCnotdeleted > 0) )
			{
			echo "<br>\n";
			echo "<br><B>"._QXZ("TOTAL NUMBERS DELETED FROM DNC LIST").": $DNCdeleted</B>\n";
			echo "<br><B>"._QXZ("TOTAL NUMBERS NOT DELETED FROM DNC LIST").": $DNCnotdeleted</B>\n";
			echo "<br>\n";
			}
		}

	if ($LOGdelete_from_dnc > 0)
		{echo "<br>"._QXZ("ADD OR DELETE NUMBERS FROM THE DNC LIST")."<form action=$PHP_SELF method=POST>\n";}
	else
		{echo "<br>"._QXZ("ADD NUMBERS TO THE DNC LIST")."<form action=$PHP_SELF method=POST>\n";}
	echo "<input type=hidden name=ADD value=121>\n";
	echo "<center><TABLE width=850 cellspacing=3>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("List").": </td><td align=left><select size=1 name=campaign_id>\n";
	echo "$campaigns_list";
	echo "</select></td></tr>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Phone Numbers").": <BR><BR> ("._QXZ("one phone number per line only").")<BR>$NWB#internal_list-dnc$NWE</td><td align=left><TEXTAREA name=phone_numbers ROWS=20 COLS=20></TEXTAREA></td></tr>\n";
	if ($LOGdelete_from_dnc > 0)
		{
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Add or Delete").": </td><td align=left><select size=1 name=stage><option value='add' SELECTED>"._QXZ("add")."</option><option value='delete'>"._QXZ("delete")."</option></select></td></tr>\n";
		}
	echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
	echo "</FORM></TABLE></center>\n";

	echo "<br>"._QXZ("DNC LOG SEARCH")."<BR><form action=$PHP_SELF method=POST>\n";
	echo "<input type=hidden name=ADD value=121>\n";
	echo "<center><TABLE width=400 cellspacing=3>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Phone Number").": </td><td align=left><input type=text name=phone size=12 maxlength=18></td></tr>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SEARCH")."'></td></tr>\n";
	echo "</FORM></TABLE></center>\n";

	if ( ($LOGuser_level >= 9) and ( (preg_match("/Download List/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
		{
		echo "<br>"._QXZ("Download numbers in this list to a file").": <form action=\"list_download.php\" method=POST>\n";
		echo "<input type=hidden name=download_type value=dnc>\n";
		echo "<select size=1 name=group_id>\n";
		echo "$campaigns_list";
		echo "</select><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></FORM>\n";
		}
	}


######################
# ADD=131 display the ADD NEW DROP LIST FORM SCREEN
######################
if ($ADD==131)
	{
	if ($LOGmodify_lists==1)
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_drop_lists' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$voi_count = "$row[0]";
			}
		##### END ID override optional section #####

		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_black_lists.png\" alt=\"Lists\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD A NEW DROP LIST")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=231>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		if ($voi_count > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Drop List ID").": </td><td align=left>"._QXZ("Auto-Generated")." $NWB#drop_lists-dl_id$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Drop List ID").": </td><td align=left><input type=text name=dl_id size=20 maxlength=30> $NWB#drop_lists-dl_id$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Drop List Name").": </td><td align=left><input type=text name=dl_name size=30 maxlength=100>$NWB#drop_lists-dl_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=171 display the ADD NUMBER TO Filter Phone Group FORM SCREEN and add a new number
######################
if ($ADD==171)
	{
	### filter for Letters DIGITS and NEWLINES
	if ($non_latin < 1)
		{
		$phone_numbers = preg_replace('/[^\n\[\] 0-9a-zA-Z]/', '',$phone_numbers);
		}
	else
		{
		$phone_numbers = preg_replace('/[^\n\[\] 0-9\p{L}]/u', '',$phone_numbers);
		}
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT filter_phone_group_id,filter_phone_group_name from vicidial_filter_phone_groups $whereLOGadmin_viewable_groupsSQL order by filter_phone_group_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$vfpg_to_print = mysqli_num_rows($rslt);

	$o=0;
	while ($vfpg_to_print > $o) 
		{
		$rowx=mysqli_fetch_row($rslt);
		$vfpg_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
		$o++;
		}

	if (strlen($phone_numbers) > 2)
		{
		$PN = explode("\n",$phone_numbers);
		$PNct = count($PN);
		$p=0;
		while ($p < $PNct)
			{
			if ( (preg_match('/delete/',$stage)) and ($LOGdelete_from_dnc > 0) )
				{
				$stmt="SELECT count(*) from vicidial_filter_phone_numbers where phone_number='$PN[$p]' and filter_phone_group_id='$filter_phone_group_id';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				if ($row[0] < 1)
					{echo "<br>"._QXZ("FILTER PHONE GROUP NUMBER NOT DELETED - This phone number is not in the Filter Phone Group List").": $PN[$p] $filter_phone_group_id\n";}
				else
					{
					$stmt="DELETE FROM vicidial_filter_phone_numbers where phone_number='$PN[$p]' and filter_phone_group_id='$filter_phone_group_id';";
					$rslt=mysql_to_mysqli($stmt, $link);

					echo "<br><B>"._QXZ("FILTER PHONE GROUP NUMBER DELETED").": $PN[$p] $filter_phone_group_id</B>\n";

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$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='FILTERPHONEGROUPS', event_type='DELETE', record_id='$PN[$p]', event_code='ADMIN DELETE NUMBER FROM FILTER PHONE GROUP $filter_phone_group_id', event_sql=\"$SQL_log\", event_notes='';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			else
				{
				$stmt="SELECT count(*) from vicidial_filter_phone_numbers where phone_number='$PN[$p]' and filter_phone_group_id='$filter_phone_group_id';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				if ($row[0] > 0)
					{echo "<br>"._QXZ("FILTER PHONE GROUP NUMBER NOT ADDED - This phone number is already in the Filter Phone Group List").": $PN[$p] $filter_phone_group_id\n";}
				else
					{
					$stmt="INSERT INTO vicidial_filter_phone_numbers (phone_number,filter_phone_group_id) values('$PN[$p]','$filter_phone_group_id');";
					$rslt=mysql_to_mysqli($stmt, $link);

					echo "<br><B>"._QXZ("FILTER PHONE GROUP NUMBER ADDED").": $PN[$p] $filter_phone_group_id</B>\n";

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$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='FILTERPHONEGROUPS', event_type='ADD', record_id='$PN[$p]', event_code='ADMIN ADD NUMBER TO FILTER PHONE GROUP $filter_phone_group_id', event_sql=\"$SQL_log\", event_notes='';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			$p++;
			}
		}

	if ($LOGdelete_from_dnc > 0)
		{echo "<br>"._QXZ("ADD OR DELETE NUMBERS FROM THE FILTER PHONE GROUP LIST")."<form action=$PHP_SELF method=POST>\n";}
	else
		{echo "<br>"._QXZ("ADD NUMBERS TO THE FILTER PHONE GROUP LIST")."<form action=$PHP_SELF method=POST>\n";}
	echo "<input type=hidden name=ADD value=171>\n";
	echo "<center><TABLE width=$section_width cellspacing=3>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Filter Phone Group").": </td><td align=left><select size=1 name=filter_phone_group_id>\n";
	echo "$vfpg_list";
	echo "</select></td></tr>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Phone Numbers").": <BR><BR> ("._QXZ("one phone number per line only").")<BR>$NWB#filter-phone-list$NWE</td><td align=left><TEXTAREA name=phone_numbers ROWS=20 COLS=20></TEXTAREA></td></tr>\n";
	if ($LOGdelete_from_dnc > 0)
		{
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Add or Delete").": </td><td align=left><select size=1 name=stage><option SELECTED value='add'>"._QXZ("add")."</option><option value='delete'>"._QXZ("delete")."</option></select></td></tr>\n";
		}
	echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
	echo "</FORM></TABLE></center>\n";

	if ( ($LOGuser_level >= 9) and ( (preg_match("/Download List/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
		{
		echo "<br>"._QXZ("Download numbers in this list to a file").": <form action=\"list_download.php\" method=POST>\n";
		echo "<input type=hidden name=download_type value=fpgn>\n";
		echo "<select size=1 name=group_id>\n";
		echo "$vfpg_list";
		echo "</select><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></FORM>\n";
		}

	}


######################
# ADD=3211 areacode list modification screen
######################
if ($ADD==3211)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ($LOGmodify_ingroups==1)
		{
		$stmt = "SELECT count(*) FROM vicidial_inbound_groups where group_id='$group_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$vig_exists = $row[0];

		if ($vig_exists > 0)
			{
			### read in all areacodes in this in-group areacode filter list
			$stmt = "SELECT areacode FROM vicidial_areacode_filters where group_id='$group_id' order by areacode;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$vaf_ct = mysqli_num_rows($rslt);
			$vaf=0;
			while ($vaf_ct > $vaf)
				{
				$row=mysqli_fetch_row($rslt);
				$vaf_list[$vaf] = $row[0];
				$vaf_count[$vaf] = 0;
				$vaf++;
				}

			if (strlen($areacode_list) > 2)
				{
				$PN = explode("\n",$areacode_list);
				$PNct = count($PN);
				$p=0;
				$stmt_log='';
				while ($p < $PNct)
					{
					if (strlen($PN[$p]) > 0)
						{
						$ac_found=0;
						$vaf=0;
						while ($vaf_ct > $vaf)
							{
							if ($PN[$p] == $vaf_list[$vaf]) 
								{
								$vaf_count[$vaf]++;
								$ac_found++;
								}
							$vaf++;
							}
						if ($ac_found < 1)
							{
							$stmt="SELECT count(*) from vicidial_areacode_filters where areacode='$PN[$p]' and group_id='$group_id';";
							$rslt=mysql_to_mysqli($stmt, $link);
							$row=mysqli_fetch_row($rslt);
							if ($row[0] < 1)
								{
								$stmt="INSERT INTO vicidial_areacode_filters (areacode,group_id) values('$PN[$p]','$group_id');";
								$rslt=mysql_to_mysqli($stmt, $link);
								$stmt_log .= "$stmt|";
								if ($DB > 0) {echo "Added areacode $PN[$p]<br>\n";}
								}
							else
								{if ($DB > 0) {echo "Skipped add, already exists: $PN[$p]<br>\n";}}
							}
						}
					$p++;
					}

				$vaf=0;
				while ($vaf_ct > $vaf)
					{
					if ($vaf_count[$vaf] < 1)
						{
						$stmt="SELECT count(*) from vicidial_areacode_filters where areacode='$vaf_list[$vaf]' and group_id='$group_id';";
						$rslt=mysql_to_mysqli($stmt, $link);
						$row=mysqli_fetch_row($rslt);
						if ($row[0] > 0)
							{
							$stmt="DELETE FROM vicidial_areacode_filters where areacode='$vaf_list[$vaf]' and group_id='$group_id';";
							$rslt=mysql_to_mysqli($stmt, $link);
							$stmt_log .= "$stmt|";
							if ($DB > 0) {echo "Removed areacode $vaf_list[$vaf]<br>\n";}
							}
						else
							{if ($DB > 0) {echo "Skipped delete, already removed: $vaf_list[$vaf]<br>\n";}}
						}
					$vaf++;
					}

				if (strlen($stmt_log) > 10)
					{
					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$stmt_log|";
					$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='INGROUPS', event_type='MODIFY', record_id='$group_id', event_code='ADMIN MODIFY AREACODE FILTER', event_sql=\"$SQL_log\", event_notes='';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}

			### read in all areacodes in this in-group areacode filter list
			$stmt = "SELECT areacode FROM vicidial_areacode_filters where group_id='$group_id' order by areacode;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$vaf_ct = mysqli_num_rows($rslt);
			$vaf=0;   $vaf_textarea='';
			while ($vaf_ct > $vaf)
				{
				$row=mysqli_fetch_row($rslt);
				$vaf_textarea .= "$row[0]\n";
				$vaf++;
				}

			echo "<br>"._QXZ("MODIFY AREACODE LIST")."<form action=$PHP_SELF method=POST>\n";
			echo "<input type=hidden name=ADD value=3211>\n";
			echo "<input type=hidden name=group_id value=\"$group_id\">\n";
			echo "<input type=hidden name=DB value=\"$DB\">\n";
			echo "<center><TABLE width=500 cellspacing=3>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("In-Group").": </td><td align=left><b>$group_id</b> - <a href=\"$PHP_SELF?ADD=3111&group_id=$group_id\">modify</a></td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Areacodes").": <BR><BR> ("._QXZ("one areacode per line only").")<BR>$NWB#internal_list-dnc$NWE</td><td align=left><TEXTAREA name=areacode_list ROWS=20 COLS=7>$vaf_textarea</TEXTAREA></td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
			echo "</FORM></TABLE></center>\n";
			}
		else
			{
			echo _QXZ("You must use a valid group")."\n";
			exit;
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=1111 display the ADD NEW INBOUND GROUP SCREEN
######################
if ($ADD==1111)
	{
	if ($LOGmodify_ingroups==1)
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_inbound_groups' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$voi_count = "$row[0]";
			}
		##### END ID override optional section #####

		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_black_inbound.png\" alt=\"Inbound\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD A NEW INBOUND GROUP")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=2111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		if ($voi_count > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group ID").": </td><td align=left>"._QXZ("Auto-Generated")." $NWB#inbound_groups-group_id$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group ID").": </td><td align=left><input type=text name=group_id size=20 maxlength=20> ("._QXZ("no spaces").")$NWB#inbound_groups-group_id$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group Name").": </td><td align=left><input type=text name=group_name size=30 maxlength=30>$NWB#inbound_groups-group_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group Color")." <font size=2>(<a href=\"javascript:launch_color_chooser('group_color','color','1');\">"._QXZ("color chooser")."</a>)</font>: </td><td align=left id=\"group_color_td\"><input type=text name=group_color id=group_color size=7 maxlength=20> $NWB#inbound_groups-group_color$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='Y' SELECTED>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option></select>$NWB#inbound_groups-active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#inbound_groups-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Web Form").": </td><td align=left><input type=text name=web_form_address size=70 maxlength=9999 value=\"$web_form_address\">$NWB#inbound_groups-web_form_address$NWE"; if ($SSenable_first_webform < 1) {echo " <font color=red><b>"._QXZ("DISABLED")."</b></font>";} echo "</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Voicemail").": </td><td align=left><input type=text name=voicemail_ext size=10 maxlength=10 value=\"$voicemail_ext\">$NWB#inbound_groups-voicemail_ext$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Next Agent Call").": </td><td align=left><select size=1 name=next_agent_call><option value='random'>"._QXZ("random")."</option><option value='oldest_call_start'>"._QXZ("oldest_call_start")."</option><option value='oldest_call_finish'>"._QXZ("oldest_call_finish")."</option><option value='oldest_inbound_call_start'>"._QXZ("oldest_inbound_call_start")."</option><option value='oldest_inbound_call_finish'>"._QXZ("oldest_inbound_call_finish")."</option><option value='oldest_inbound_filtered_call_start'>"._QXZ("oldest_inbound_filtered_call_start")."</option><option value='oldest_inbound_filtered_call_finish'>"._QXZ("oldest_inbound_filtered_call_finish")."</option><option value='overall_user_level'>"._QXZ("overall_user_level")."</option><option value='inbound_group_rank'>"._QXZ("inbound_group_rank")."</option><option value='campaign_rank'>"._QXZ("campaign_rank")."</option><option value='ingroup_grade_random'>"._QXZ("ingroup_grade_random")."</option><option value='campaign_grade_random'>"._QXZ("campaign_grade_random")."</option><option value='fewest_calls'>"._QXZ("fewest_calls")."</option><option value='fewest_calls_campaign'>"._QXZ("fewest_calls_campaign")."</option><option value='longest_wait_time'>"._QXZ("longest_wait_time")."</option><option value='ring_all'>"._QXZ("ring_all")."</option><option value='overall_user_level_wait_time'>"._QXZ("overall_user_level_wait_time")."</option><option value='campaign_rank_wait_time'>"._QXZ("campaign_rank_wait_time")."</option><option value='fewest_calls_campaign_wait_time'>"._QXZ("fewest_calls_campaign_wait_time")."</option><option value='inbound_group_rank_wait_time'>"._QXZ("inbound_group_rank_wait_time")."</option><option value='fewest_calls_wait_time'>"._QXZ("fewest_calls_wait_time")."</option></select>$NWB#inbound_groups-next_agent_call$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Fronter Display").": </td><td align=left><select size=1 name=fronter_display><option value='Y' SELECTED>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option></select>$NWB#inbound_groups-fronter_display$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Script").": </td><td align=left><select size=1 name=script_id>\n";
		echo "$scripts_list";
		echo "</select>$NWB#inbound_groups-ingroup_script$NWE</td></tr>\n";
		if ($SSenable_second_script > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Script Two").": </td><td align=left><select size=1 name=ingroup_script_two>\n";
			echo "$scripts_list";
			echo "</select>$NWB#inbound_groups-ingroup_script$NWE</td></tr>\n";
			}
		$eswHTML=''; $cfwHTML=''; $aemHTML=''; $achHTML='';
		if ($SSenable_second_script > 0)
			{$eswHTML .= "<option value='SCRIPTTWO'>"._QXZ("SCRIPTTWO")."</option>";}
		if ($SSenable_second_webform > 0)
			{$eswHTML .= "<option value='WEBFORMTWO'>"._QXZ("WEBFORMTWO")."</option>";}
		if ($SSenable_third_webform > 0)
			{$eswHTML .= "<option value='WEBFORMTHREE'>"._QXZ("WEBFORMTHREE")."</option>";}
		if ($SScustom_fields_enabled > 0)
			{$cfwHTML .= "<option value='FORM'>"._QXZ("FORM")."</option>";}
		if ($SSallow_emails > 0)
			{$aemHTML .= "<option value='EMAIL'>"._QXZ("EMAIL")."</option>";}
		if ($SSallow_chats > 0)
			{$achHTML .= "<option value='CHAT'>"._QXZ("CHAT")."</option>";}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Get Call Launch").": </td><td align=left><select size=1 name=get_call_launch><option selected value='NONE'>"._QXZ("NONE")."</option><option value='SCRIPT'>"._QXZ("SCRIPT")."</option><option value='WEBFORM'>"._QXZ("WEBFORM")."</option>$eswHTML$cfwHTML$aemHTML$achHTML</select>$NWB#inbound_groups-get_call_launch$NWE</td></tr>\n";
/* Don't give an option (yet).  This is clearly for phones only. 
		if ($SSallow_emails>0 || $SSallow_chats > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group Handling").": </td><td align=left><select size=1 name=group_handling><option selected value='PHONE'>"._QXZ("PHONE")."</option>";
			if ($SSallow_emails>0) {echo "<option value='EMAIL'>"._QXZ("EMAIL")."</option>";}
			if ($SSallow_chats>0) {echo "<option value='CHAT'>"._QXZ("CHAT")."</option>";}			
			echo "</select>$NWB#inbound_groups-group_handling$NWE</td></tr>\n";
			}
		else
			{
*/
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right></td><td align=left><input type=hidden name=group_handling value='PHONE'></td></tr>\n";
#			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=1811 display the ADD NEW EMAIL GROUP SCREEN
######################
if ($ADD==1811)
	{
	if ( ($LOGmodify_ingroups==1) and ($SSallow_emails>0) )
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_inbound_groups' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$voi_count = "$row[0]";
			}
		##### END ID override optional section #####

		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<img src=\"images/icon_email.png\" alt=\"Email Groups\" width=42 height=42> "._QXZ("ADD A NEW EMAIL GROUP")."<form action=$PHP_SELF method=GET>\n";
		echo "<input type=hidden name=ADD value=2811>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		if ($voi_count > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group ID").": </td><td align=left>"._QXZ("Auto-Generated")." $NWB#inbound_groups-group_id$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group ID").": </td><td align=left><input type=text name=group_id size=20 maxlength=20> ("._QXZ("no spaces").")$NWB#inbound_groups-group_id$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group Name").": </td><td align=left><input type=text name=group_name size=30 maxlength=30>$NWB#inbound_groups-group_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group Color")." <font size=2>(<a href=\"javascript:launch_color_chooser('group_color','color','1');\">"._QXZ("color chooser")."</a>)</font>: </td><td align=left id=\"group_color_td\"><input type=text name=group_color id=group_color size=7 maxlength=20> $NWB#inbound_groups-group_color$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='Y' SELECTED>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option></select>$NWB#inbound_groups-active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#inbound_groups-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Web Form").": </td><td align=left><input type=text name=web_form_address size=70 maxlength=9999 value=\"$web_form_address\">$NWB#inbound_groups-web_form_address$NWE"; if ($SSenable_first_webform < 1) {echo " <font color=red><b>"._QXZ("DISABLED")."</b></font>";} echo "</td></tr>\n";
		# echo "<tr bgcolor=#$SSstd_row4_background><td align=right>Voicemail: </td><td align=left><input type=text name=voicemail_ext size=10 maxlength=10 value=\"$voicemail_ext\">$NWB#inbound_groups-voicemail_ext$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Next Agent Email").": </td><td align=left><select size=1 name=next_agent_call><option value='random'>"._QXZ("random")."</option><option value='oldest_call_start'>"._QXZ("oldest_call_start")."</option><option value='oldest_call_finish'>"._QXZ("oldest_call_finish")."</option><option value='oldest_inbound_call_start'>"._QXZ("oldest_inbound_call_start")."</option><option value='oldest_inbound_call_finish'>"._QXZ("oldest_inbound_call_finish")."</option><option value='oldest_inbound_filtered_call_start'>"._QXZ("oldest_inbound_filtered_call_start")."</option><option value='oldest_inbound_filtered_call_finish'>"._QXZ("oldest_inbound_filtered_call_finish")."</option><option value='overall_user_level'>"._QXZ("overall_user_level")."</option><option value='inbound_group_rank'>"._QXZ("inbound_group_rank")."</option><option value='campaign_rank'>"._QXZ("campaign_rank")."</option><option value='ingroup_grade_random'>"._QXZ("ingroup_grade_random")."</option><option value='campaign_grade_random'>"._QXZ("campaign_grade_random")."</option><option value='fewest_calls'>"._QXZ("fewest_calls")."</option><option value='fewest_calls_campaign'>"._QXZ("fewest_calls_campaign")."</option><option value='longest_wait_time'>"._QXZ("longest_wait_time")."</option><option value='ring_all'>"._QXZ("ring_all")."</option><option value='overall_user_level_wait_time'>"._QXZ("overall_user_level_wait_time")."</option><option value='campaign_rank_wait_time'>"._QXZ("campaign_rank_wait_time")."</option><option value='fewest_calls_campaign_wait_time'>"._QXZ("fewest_calls_campaign_wait_time")."</option><option value='inbound_group_rank_wait_time'>"._QXZ("inbound_group_rank_wait_time")."</option><option value='fewest_calls_wait_time'>"._QXZ("fewest_calls_wait_time")."</option></select>$NWB#inbound_groups-next_agent_email$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Fronter Display").": </td><td align=left><select size=1 name=fronter_display><option value='Y' SELECTED>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option></select>$NWB#inbound_groups-fronter_display$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Script").": </td><td align=left><select size=1 name=script_id>\n";
		echo "$scripts_list";
		echo "</select>$NWB#inbound_groups-ingroup_script$NWE</td></tr>\n";
		if ($SSenable_second_script > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Script Two").": </td><td align=left><select size=1 name=ingroup_script_two>\n";
			echo "$scripts_list";
			echo "</select>$NWB#inbound_groups-ingroup_script$NWE</td></tr>\n";
			}
		$eswHTML=''; $cfwHTML=''; $aemHTML=''; $achHTML='';
		if ($SSenable_second_script > 0)
			{$eswHTML .= "<option value='SCRIPTTWO'>"._QXZ("SCRIPTTWO")."</option>";}
		if ($SSenable_second_webform > 0)
			{$eswHTML .= "<option value='WEBFORMTWO'>"._QXZ("WEBFORMTWO")."</option>";}
		if ($SSenable_third_webform > 0)
			{$eswHTML .= "<option value='WEBFORMTHREE'>"._QXZ("WEBFORMTHREE")."</option>";}
		if ($SScustom_fields_enabled > 0)
			{$cfwHTML .= "<option value='FORM'>"._QXZ("FORM")."</option>";}
		if ($SSallow_emails > 0)
			{$aemHTML .= "<option value='EMAIL'>"._QXZ("EMAIL")."</option>";}
		if ($SSallow_chats > 0)
			{$achHTML .= "<option value='CHAT'>"._QXZ("CHAT")."</option>";}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Get Call Launch").": </td><td align=left><select size=1 name=get_call_launch><option value='NONE' selected>"._QXZ("NONE")."</option><option value='SCRIPT'>"._QXZ("SCRIPT")."</option><option value='WEBFORM'>"._QXZ("WEBFORM")."</option>$eswHTML$cfwHTML$aemHTML$achHTML</select>$NWB#inbound_groups-get_call_launch$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right></td><td align=left><input type=hidden name=group_handling value='EMAIL'></td></tr>\n";
		
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=18111 display the ADD NEW CHAT GROUP SCREEN
######################
if ($ADD==18111)
	{
	if ( ($LOGmodify_ingroups==1) and ($SSallow_chats>0) )
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_inbound_groups' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$voi_count = "$row[0]";
			}
		##### END ID override optional section #####

		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<img src=\"images/icon_chat.png\" alt=\"Chat Groups\" width=42 height=42> "._QXZ("ADD A NEW CHAT GROUP")."<form action=$PHP_SELF method=GET>\n";
		echo "<input type=hidden name=ADD value=28111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		if ($voi_count > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group ID").": </td><td align=left>"._QXZ("Auto-Generated")."$NWB#inbound_groups-group_id$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group ID").": </td><td align=left><input type=text name=group_id size=20 maxlength=20> ("._QXZ("no spaces").")$NWB#inbound_groups-group_id$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group Name").": </td><td align=left><input type=text name=group_name size=30 maxlength=30>$NWB#inbound_groups-group_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group Color")." <font size=2>(<a href=\"javascript:launch_color_chooser('group_color','color','1');\">"._QXZ("color chooser")."</a>)</font>: </td><td align=left id=\"group_color_td\"><input type=text name=group_color id=group_color size=7 maxlength=20> $NWB#inbound_groups-group_color$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='Y' SELECTED>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option></select>$NWB#inbound_groups-active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Default List ID").": </td><td align=left><input type=text name=hold_time_option_callback_list_id size=19 maxlength=19 value=0>$NWB#inbound_groups-default_list_id$NWE</td></tr>";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#inbound_groups-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Web Form").": </td><td align=left><input type=text name=web_form_address size=70 maxlength=9999 value=\"$web_form_address\">$NWB#inbound_groups-web_form_address$NWE"; if ($SSenable_first_webform < 1) {echo " <font color=red><b>"._QXZ("DISABLED")."</b></font>";} echo "</td></tr>\n";
		# echo "<tr bgcolor=#$SSstd_row4_background><td align=right>Voicemail: </td><td align=left><input type=text name=voicemail_ext size=10 maxlength=10 value=\"$voicemail_ext\">$NWB#inbound_groups-voicemail_ext$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Next Agent Chat").": </td><td align=left><select size=1 name=next_agent_call><option value='random'>"._QXZ("random")."</option><option value='oldest_call_start'>"._QXZ("oldest_call_start")."</option><option value='oldest_call_finish'>"._QXZ("oldest_call_finish")."</option><option value='oldest_inbound_call_start'>"._QXZ("oldest_inbound_call_start")."</option><option value='oldest_inbound_call_finish'>"._QXZ("oldest_inbound_call_finish")."</option><option value='oldest_inbound_filtered_call_start'>"._QXZ("oldest_inbound_filtered_call_start")."</option><option value='oldest_inbound_filtered_call_finish'>"._QXZ("oldest_inbound_filtered_call_finish")."</option><option value='overall_user_level'>"._QXZ("overall_user_level")."</option><option value='inbound_group_rank'>"._QXZ("inbound_group_rank")."</option><option value='campaign_rank'>"._QXZ("campaign_rank")."</option><option value='ingroup_grade_random'>"._QXZ("ingroup_grade_random")."</option><option value='campaign_grade_random'>"._QXZ("campaign_grade_random")."</option><option value='fewest_calls'>"._QXZ("fewest_calls")."</option><option value='fewest_calls_campaign'>"._QXZ("fewest_calls_campaign")."</option><option value='longest_wait_time'>"._QXZ("longest_wait_time")."</option><option value='ring_all'>"._QXZ("ring_all")."</option><option value='overall_user_level_wait_time'>"._QXZ("overall_user_level_wait_time")."</option><option value='campaign_rank_wait_time'>"._QXZ("campaign_rank_wait_time")."</option><option value='fewest_calls_campaign_wait_time'>"._QXZ("fewest_calls_campaign_wait_time")."</option><option value='inbound_group_rank_wait_time'>"._QXZ("inbound_group_rank_wait_time")."</option><option value='fewest_calls_wait_time'>"._QXZ("fewest_calls_wait_time")."</option></select>$NWB#inbound_groups-next_agent_chat$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Fronter Display").": </td><td align=left><select size=1 name=fronter_display><option value='Y' SELECTED>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option></select>$NWB#inbound_groups-fronter_display$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Script").": </td><td align=left><select size=1 name=script_id>\n";
		echo "$scripts_list";
		echo "</select>$NWB#inbound_groups-ingroup_script$NWE</td></tr>\n";
		if ($SSenable_second_script > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Script Two").": </td><td align=left><select size=1 name=ingroup_script_two>\n";
			echo "$scripts_list";
			echo "</select>$NWB#inbound_groups-ingroup_script$NWE</td></tr>\n";
			}
		$eswHTML=''; $cfwHTML=''; $aemHTML=''; $achHTML='';
		if ($SSenable_second_script > 0)
			{$eswHTML .= "<option value='SCRIPTTWO'>"._QXZ("SCRIPTTWO")."</option>";}
		if ($SSenable_second_webform > 0)
			{$eswHTML .= "<option value='WEBFORMTWO'>"._QXZ("WEBFORMTWO")."</option>";}
		if ($SSenable_third_webform > 0)
			{$eswHTML .= "<option value='WEBFORMTHREE'>"._QXZ("WEBFORMTHREE")."</option>";}
		if ($SScustom_fields_enabled > 0)
			{$cfwHTML .= "<option value='FORM'>"._QXZ("FORM")."</option>";}
		if ($SSallow_emails > 0)
			{$aemHTML .= "<option value='EMAIL'>"._QXZ("EMAIL")."</option>";}
		if ($SSallow_chats > 0)
			{$achHTML .= "<option value='CHAT'>"._QXZ("CHAT")."</option>";}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Get Call Launch").": </td><td align=left><select size=1 name=get_call_launch><option value='NONE' selected>"._QXZ("NONE")."</option><option value='SCRIPT'>"._QXZ("SCRIPT")."</option><option value='WEBFORM'>"._QXZ("WEBFORM")."</option>$eswHTML$cfwHTML$aemHTML$achHTML</select>$NWB#inbound_groups-get_call_launch$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right></td><td align=left><input type=hidden name=group_handling value='CHAT'></td></tr>\n";
		
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=1211 display the COPY INBOUND GROUP SCREEN
######################
if ($ADD==1211)
	{
	if ($LOGmodify_ingroups==1)
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_inbound_groups' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$voi_count = "$row[0]";
			}
		##### END ID override optional section #####

		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_black_inbound.png\" alt=\"Inbound\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("COPY INBOUND GROUP")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=2011>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		if ($voi_count > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group ID").": </td><td align=left>"._QXZ("Auto-Generated")." $NWB#inbound_groups-group_id$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group ID").": </td><td align=left><input type=text name=group_id size=20 maxlength=20> ("._QXZ("no spaces").")$NWB#inbound_groups-group_id$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group Name").": </td><td align=left><input type=text name=group_name size=30 maxlength=30>$NWB#inbound_groups-group_name$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Source Group ID").": </td><td align=left><select size=1 name=source_group_id>\n";

		$stmt="SELECT group_id,group_name from vicidial_inbound_groups where group_handling='PHONE' $LOGadmin_viewable_groupsSQL order by group_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$groups_to_print = mysqli_num_rows($rslt);
		$groups_list='';

		$o=0;
		while ($groups_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$groups_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		echo "$groups_list";
		echo "</select>$NWB#inbound_groups-group_id$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=1911 display the COPY EMAIL INBOUND GROUP SCREEN
######################
if ($ADD==1911)
	{
	if ( ($LOGmodify_ingroups==1) and ($SSallow_emails>0) )
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_inbound_groups' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$voi_count = "$row[0]";
			}
		##### END ID override optional section #####

		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<img src=\"images/icon_email.png\" alt=\"Email Groups\" width=42 height=42> "._QXZ("COPY EMAIL GROUP")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=2911>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		if ($voi_count > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Email Group ID").": </td><td align=left>"._QXZ("Auto-Generated")." $NWB#inbound_groups-group_id$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Email Group ID").": </td><td align=left><input type=text name=group_id size=20 maxlength=20> ("._QXZ("no spaces").")$NWB#inbound_groups-group_id$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Email Group Name").": </td><td align=left><input type=text name=group_name size=30 maxlength=30>$NWB#inbound_groups-group_name$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Source Email Group ID").": </td><td align=left><select size=1 name=source_group_id>\n";

		$stmt="SELECT group_id,group_name from vicidial_inbound_groups where group_handling='EMAIL' $LOGadmin_viewable_groupsSQL order by group_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$groups_to_print = mysqli_num_rows($rslt);
		$groups_list='';

		$o=0;
		while ($groups_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$groups_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		echo "$groups_list";
		echo "</select>$NWB#inbound_groups-group_id$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=19111 display the COPY CHAT INBOUND GROUP SCREEN
######################
if ($ADD==19111)
	{
	if ( ($LOGmodify_ingroups==1) and ($SSallow_chats>0) )
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_inbound_groups' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$voi_count = "$row[0]";
			}
		##### END ID override optional section #####

		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<img src=\"images/icon_chat.png\" alt=\"Chat Groups\" width=42 height=42> "._QXZ("COPY CHAT GROUP")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=29111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		if ($voi_count > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Chat Group ID").": </td><td align=left>"._QXZ("Auto-Generated")." $NWB#inbound_groups-group_id$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Chat Group ID").": </td><td align=left><input type=text name=group_id size=20 maxlength=20> ("._QXZ("no spaces").")$NWB#inbound_groups-group_id$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Chat Group Name").": </td><td align=left><input type=text name=group_name size=30 maxlength=30>$NWB#inbound_groups-group_name$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Source Chat Group ID").": </td><td align=left><select size=1 name=source_group_id>\n";

		$stmt="SELECT group_id,group_name from vicidial_inbound_groups where group_handling='CHAT' $LOGadmin_viewable_groupsSQL order by group_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$groups_to_print = mysqli_num_rows($rslt);
		$groups_list='';

		$o=0;
		while ($groups_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$groups_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		echo "$groups_list";
		echo "</select>$NWB#inbound_groups-group_id$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=1311 display the ADD NEW DID SCREEN
######################
if ($ADD==1311)
	{
	if ($LOGmodify_dids==1)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<img src=\"images/icon_cidgroups.png\" alt=\"DIDs\" width=42 height=42> "._QXZ("ADD A NEW DID")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=2311>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("DID Extension").": </td><td align=left><input type=text name=did_pattern size=20 maxlength=50> ("._QXZ("no spaces or dashes").")$NWB#inbound_dids-did_pattern$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("DID Description").": </td><td align=left><input type=text name=did_description size=40 maxlength=50>$NWB#inbound_dids-did_description$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#inbound_dids-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=1411 display the COPY DID SCREEN
######################
if ($ADD==1411)
	{
	if ($LOGmodify_dids==1)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<img src=\"images/icon_cidgroups.png\" alt=\"DIDs\" width=42 height=42> "._QXZ("COPY DID")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=2411>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("DID Extension").": </td><td align=left><input type=text name=did_pattern size=20 maxlength=50> ("._QXZ("no spaces or dashes").")$NWB#inbound_dids-did_pattern$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("DID Description").": </td><td align=left><input type=text name=did_description size=40 maxlength=50>$NWB#inbound_dids-did_description$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Source DID").": </td><td align=left><select size=1 name=source_did>\n";

		$stmt="SELECT did_id,did_pattern,did_description from vicidial_inbound_dids where did_pattern!='did_system_filter' $LOGadmin_viewable_groupsSQL order by did_pattern;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$dids_to_print = mysqli_num_rows($rslt);
		$dids_list='';

		$o=0;
		while ($dids_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$dids_list .= "<option value=\"$rowx[0]\">$rowx[1] - $rowx[2]</option>\n";
			$o++;
			}
		echo "$dids_list";
		echo "</select>$NWB#inbound_dids-did_pattern$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=1511 display the ADD NEW CALL MENU SCREEN
######################
if ($ADD==1511)
	{
	if ($LOGmodify_dids==1)
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_call_menu' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$voi_count = "$row[0]";
			}
		##### END ID override optional section #####

		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<img src=\"images/icon_callmenu.png\" alt=\"Call Menus\" width=42 height=42> "._QXZ("ADD A NEW CALL MENU")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=2511>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		if ($voi_count > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Menu ID").": </td><td align=left>"._QXZ("Auto-Generated")." $NWB#call_menu-menu_id$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Menu ID").": </td><td align=left><input type=text name=menu_id size=40 maxlength=50> ("._QXZ("no spaces or special characters").")$NWB#call_menu-menu_id$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Menu Name").": </td><td align=left><input type=text name=menu_name size=50 maxlength=100>$NWB#call_menu-menu_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#call_menu-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=1611 display the COPY CALL MENU SCREEN
######################
if ($ADD==1611)
	{
	if ($LOGmodify_dids==1)
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_call_menu' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$voi_count = "$row[0]";
			}
		##### END ID override optional section #####

		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<img src=\"images/icon_callmenu.png\" alt=\"Call Menus\" width=42 height=42> "._QXZ("COPY CALL MENU")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=2611>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		if ($voi_count > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Menu ID").": </td><td align=left>"._QXZ("Auto-Generated")." $NWB#call_menu-menu_id$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Menu ID").": </td><td align=left><input type=text name=menu_id size=40 maxlength=50> ("._QXZ("no spaces or special characters").")$NWB#call_menu-menu_id$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Menu Name").": </td><td align=left><input type=text name=menu_name size=50 maxlength=100>$NWB#call_menu-menu_name$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Source Menu").": </td><td align=left><select size=1 name=source_menu>\n";

		$stmt="SELECT menu_id,menu_name from vicidial_call_menu $whereLOGadmin_viewable_groupsSQL order by menu_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$menus_to_print = mysqli_num_rows($rslt);
		$menus_list='';

		$o=0;
		while ($menus_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$menus_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		echo "$menus_list";
		echo "</select>$NWB#call_menu-menu_id$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=1711 display the ADD NEW FILTER PHONE GROUP SCREEN
######################
if ($ADD==1711)
	{
	if ($LOGmodify_dids==1)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<img src=\"images/icon_filterphonegroup.png\" alt=\"Filter Phone Groups\" width=42 height=42> "._QXZ("Add Filter Phone Group")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=2711>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Filter Phone Group ID").": </td><td align=left><input type=text name=filter_phone_group_id size=20 maxlength=20> ("._QXZ("no spaces or special characters").")$NWB#filter_phone_groups-filter_phone_group_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Filter Phone Group Name").": </td><td align=left><input type=text name=filter_phone_group_name size=40 maxlength=40>$NWB#filter_phone_groups-filter_phone_group_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Filter Phone Group Description").": </td><td align=left><input type=text name=filter_phone_group_description size=60 maxlength=100>$NWB#filter_phone_groups-filter_phone_group_description$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#filter_phone_groups-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=11111 display the ADD NEW REMOTE AGENTS SCREEN
######################
if ($ADD==11111)
	{
	if ( ($LOGmodify_remoteagents==1) and ($x_ra_carrier < 1) )
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_black_remoteagents.png\" alt=\"Remote Agents\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW REMOTE AGENTS")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=21111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User ID Start").": </td><td align=left><input type=text name=user_start size=9 maxlength=9> ("._QXZ("numbers only, incremented, must be an existing vicidial user").")$NWB#remote_agents-user_start$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Number of Lines").": </td><td align=left><input type=text name=number_of_lines size=3 maxlength=3> ("._QXZ("numbers only").")$NWB#remote_agents-number_of_lines$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Server IP").": </td><td align=left><select size=1 name=server_ip>\n";
		echo "$servers_list";
		echo "</select>$NWB#remote_agents-server_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("External Extension").": </td><td align=left><input type=text name=conf_exten size=20 maxlength=20> ("._QXZ("dial plan number dialed to reach agents").")$NWB#remote_agents-conf_exten$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Status").": </td><td align=left><select size=1 name=status><option value='ACTIVE'>"._QXZ("ACTIVE")."</option><option value=\"INACTIVE\" SELECTED>"._QXZ("INACTIVE")."</option></select>$NWB#remote_agents-status$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign").": </td><td align=left><select size=1 name=campaign_id>\n";
		echo "$campaigns_list";
		echo "</select>$NWB#remote_agents-campaign_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Inbound Groups").": </td><td align=left>\n";
		echo "$groups_list";
		echo "$NWB#remote_agents-closer_campaigns$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		echo _QXZ("NOTE: It can take up to 30 seconds for changes submitted on this screen to go live")."\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=12111 display the ADD NEW EXTENSION GROUP SCREEN
######################
if ($ADD==12111)
	{
	if ($LOGmodify_remoteagents==1)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("Add Extension Group Entry")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=22111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Extension Group").": </td><td align=left><input type=text name=extension_group_id size=20 maxlength=20> ("._QXZ("no spaces").")$NWB#extension_groups-extension_group_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Extension").": </td><td align=left><input type=text name=extension size=18 maxlength=18> ("._QXZ("numbers only").")$NWB#extension_groups-extension$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Rank").": </td><td align=left><select size=1 name=rank>\n";
		$n=99; $rank=0;
		while ($n>=-99)
			{
			if ($n == $rank) 
				{echo "<option SELECTED value=\"$n\">$n</option>\n";}
			else
				{echo "<option value=\"$n\">$n</option>\n";}
			$n--;
			}
		echo "</select> $NWB#extension_groups-rank$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaigns Groups").": </td><td align=left><input type=text name=campaign_groups size=50 maxlength=255> ("._QXZ("pipe-delimited list").")$NWB#extension_groups-campaign_groups$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=111111 display the ADD NEW USER GROUP SCREEN
######################
if ($ADD==111111)
	{
	if ($LOGmodify_usergroups==1)
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_user_groups' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$voi_count = "$row[0]";
			}
		##### END ID override optional section #####

		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_black_usergroups.png\" alt=\"User Groups\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW USERS GROUP")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=211111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		if ($voi_count > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group").": </td><td align=left>"._QXZ("Auto-Generated")." $NWB#user_groups-user_group$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group").": </td><td align=left><input type=text name=user_group size=15 maxlength=20> ("._QXZ("no spaces or punctuation").")$NWB#user_groups-user_group$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Description").": </td><td align=left><input type=text name=group_name size=40 maxlength=40> ("._QXZ("description of group").")$NWB#user_groups-group_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=1111111 display the ADD NEW SCRIPT SCREEN
######################
if ($ADD==1111111)
	{
	if ($LOGmodify_scripts==1)
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_scripts' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$voi_count = "$row[0]";
			}
		##### END ID override optional section #####

		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_black_scripts.png\" alt=\"Scripts\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW SCRIPT")."<form name=scriptForm action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=2111111>\n";
		echo "<input type=hidden name=DB value=\"$DB\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		if ($voi_count > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Script ID").": </td><td align=left>"._QXZ("Auto-Generated")." $NWB#scripts-script_id$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Script ID").": </td><td align=left><input type=text name=script_id size=22 maxlength=20> ("._QXZ("no spaces or punctuation").")$NWB#scripts-script_id$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Script Name").": </td><td align=left><input type=text name=script_name size=40 maxlength=50> ("._QXZ("title of the script").")$NWB#scripts-script_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Script Comments").": </td><td align=left><input type=text name=script_comments size=50 maxlength=255> $NWB#scripts-script_comments$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='Y' SELECTED>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option></select>$NWB#scripts-active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#scripts-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Script Text").": </td><td align=left>";
		# BEGIN Insert Field
		echo "<select id=\"selectedField\" name=\"selectedField\">";
		echo "<option value=\"fullname\">"._QXZ("Agent Name")."(fullname)</option>";
		echo "<option>vendor_lead_code</option>";
		echo "<option>source_id</option>";
		echo "<option>list_id</option>";
		echo "<option>list_name</option>";
		echo "<option>list_description</option>";
		echo "<option>gmt_offset_now</option>";
		echo "<option>called_since_last_reset</option>";
		echo "<option>phone_code</option>";
		echo "<option>phone_number</option>";
		echo "<option>title</option>";
		echo "<option>first_name</option>";
		echo "<option>middle_initial</option>";
		echo "<option>last_name</option>";
		echo "<option>address1</option>";
		echo "<option>address2</option>";
		echo "<option>address3</option>";
		echo "<option>city</option>";
		echo "<option>state</option>";
		echo "<option>province</option>";
		echo "<option>postal_code</option>";
		echo "<option>country_code</option>";
		echo "<option>gender</option>";
		echo "<option>date_of_birth</option>";
		echo "<option>alt_phone</option>";
		echo "<option>email</option>";
		echo "<option>security_phrase</option>";
		echo "<option>comments</option>";
		echo "<option>lead_id</option>";
		echo "<option>campaign</option>";
		echo "<option>phone_login</option>";
		echo "<option>group</option>";
		echo "<option>channel_group</option>";
		echo "<option>SQLdate</option>";
		echo "<option>epoch</option>";
		echo "<option>uniqueid</option>";
		echo "<option>customer_zap_channel</option>";
		echo "<option>server_ip</option>";
		echo "<option>SIPexten</option>";
		echo "<option>session_id</option>";
		echo "<option>dialed_number</option>";
		echo "<option>dialed_label</option>";
		echo "<option>rank</option>";
		echo "<option>owner</option>";
		echo "<option>camp_script</option>";
		echo "<option>in_script</option>";
		echo "<option>script_width</option>";
		echo "<option>script_height</option>";
		echo "<option>recording_filename</option>";
		echo "<option>recording_id</option>";
		echo "<option>user_custom_one</option>";
		echo "<option>user_custom_two</option>";
		echo "<option>user_custom_three</option>";
		echo "<option>user_custom_four</option>";
		echo "<option>user_custom_five</option>";
		echo "<option>preset_number_a</option>";
		echo "<option>preset_number_b</option>";
		echo "<option>preset_number_c</option>";
		echo "<option>preset_number_d</option>";
		echo "<option>preset_number_e</option>";
		echo "<option>preset_number_f</option>";
		echo "<option>preset_dtmf_a</option>";
		echo "<option>preset_dtmf_b</option>";
		echo "<option>did_id</option>";
		echo "<option>did_extension</option>";
		echo "<option>did_pattern</option>";
		echo "<option>did_description</option>";
		echo "<option>closecallid</option>";
		echo "<option>xfercallid</option>";
		echo "<option>agent_log_id</option>";
		echo "<option>entry_list_id</option>";
		echo "<option>call_id</option>";
		echo "<option>user_group</option>";
		echo "<option>called_count</option>";
		echo "<option>TABLEper_call_notes</option>";
		echo "<option>agent_email</option>";
		echo "</select>";
		echo "<input type=\"button\" name=\"insertField\" value=\""._QXZ("Insert")."\" onClick=\"scriptInsertField();\"><BR>";
		# END Insert Field
		echo "<TEXTAREA NAME=script_text ROWS=20 COLS=50 value=\"\"></TEXTAREA> $NWB#scripts-script_text$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=11111111 display the ADD NEW FILTER SCREEN
######################
if ($ADD==11111111)
	{
	if ($LOGmodify_filters==1)
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_lead_filters' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$voi_count = "$row[0]";
			}
		##### END ID override optional section #####

		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_black_filters.png\" alt=\"Filters\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW FILTER")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=21111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		if ($voi_count > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Filter ID").": </td><td align=left>"._QXZ("Auto-Generated")." $NWB#lead_filters-lead_filter_id$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Filter ID").": </td><td align=left><input type=text name=lead_filter_id size=22 maxlength=20> ("._QXZ("no spaces or punctuation").")$NWB#lead_filters-lead_filter_id$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Filter Name").": </td><td align=left><input type=text name=lead_filter_name size=30 maxlength=30> ("._QXZ("short description of the filter").")$NWB#lead_filters-lead_filter_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Filter Comments").": </td><td align=left><input type=text name=lead_filter_comments size=50 maxlength=255> $NWB#lead_filters-lead_filter_comments$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#lead_filters-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Filter SQL").": </td><td align=left><TEXTAREA NAME=lead_filter_sql ROWS=20 COLS=50 value=\"\"></TEXTAREA> $NWB#lead_filters-lead_filter_sql$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=111111111 display the ADD NEW CALL TIME SCREEN
######################
if ($ADD==111111111)
	{
	if ($LOGmodify_call_times==1)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_calltimes.png\" alt=\"Call Times\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW CALL TIME")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=211111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Call Time ID").": </td><td align=left><input type=text name=call_time_id size=12 maxlength=10> ("._QXZ("no spaces or punctuation").")$NWB#call_times-call_time_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Call Time Name").": </td><td align=left><input type=text name=call_time_name size=30 maxlength=30> ("._QXZ("short description of the call time").")$NWB#call_times-call_time_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Call Time Comments").": </td><td align=left><input type=text name=call_time_comments size=50 maxlength=255> $NWB#call_times-call_time_comments$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#call_times-user_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>"._QXZ("Day and time options will appear once you have created the Call Time Definition")."</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=1111111111 display the ADD NEW STATE CALL TIME SCREEN
######################
if ($ADD==1111111111)
	{
	if ($LOGmodify_call_times==1)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_calltimes.png\" alt=\"State Call Times\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW STATE CALL TIME")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=2111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("State Call Time ID").": </td><td align=left><input type=text name=call_time_id size=12 maxlength=10> ("._QXZ("no spaces or punctuation").")$NWB#call_times-call_time_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("State Call Time State").": </td><td align=left><input type=text name=state_call_time_state size=4 maxlength=2> ("._QXZ("no spaces or punctuation").")$NWB#call_times-state_call_time_state$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("State Call Time Name").": </td><td align=left><input type=text name=call_time_name size=30 maxlength=30> ("._QXZ("short description of the call time").")$NWB#call_times-call_time_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("State Call Time Comments").": </td><td align=left><input type=text name=call_time_comments size=50 maxlength=255> $NWB#call_times-call_time_comments$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#call_times-user_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>"._QXZ("Day and time options will appear once you have created the Call Time Definition")."</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=1211111111 display the ADD NEW HOLIDAY SCREEN
######################
if ($ADD==1211111111)
	{
	if ($LOGmodify_call_times==1)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_calltimes.png\" alt=\"Holidays\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW STATE CALL TIME")."<form action=$PHP_SELF method=POST name=vicidial_report id=vicidial_report>\n";
		echo "<input type=hidden name=ADD value=2211111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Holiday ID").": </td><td align=left><input type=text name=holiday_id size=20 maxlength=30> ("._QXZ("no spaces or punctuation").")$NWB#call_times-holiday_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Holiday Name").": </td><td align=left><input type=text name=holiday_name size=50 maxlength=100> ("._QXZ("short description of the holiday").")$NWB#call_times-holiday_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Holiday Comments").": </td><td align=left><input type=text name=holiday_comments size=50 maxlength=255> $NWB#call_times-holiday_comments$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Holiday Date").": </td><td align=left><input type=text name=holiday_date id=holiday_date size=10 maxlength=10> $NWB#call_times-holiday_date$NWE\n";
		echo "<script language=\"JavaScript\">\n";
		echo "var o_cal = new tcal ({\n";
		echo "	// form name\n";
		echo "	'formname': 'vicidial_report',\n";
		echo "	// input name\n";
		echo "	'controlname': 'holiday_date'\n";
		echo "});\n";
		echo "o_cal.a_tpl.yearscroll = false;\n";
		echo "// o_cal.a_tpl.weekstart = 1; // Monday week start\n";
		echo "</script></td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#call_times-user_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>"._QXZ("Day and time options will appear once you have created the Holiday Definition")."</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=131111111 display the ADD NEW SHIFT SCREEN
######################
if ($ADD==131111111)
	{
	if ( ($LOGmodify_call_times==1) or ($LOGmodify_shifts==1) )
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_shifts.png\" alt=\"Shifts\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW SHIFT")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=231111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Shift ID").": </td><td align=left><input type=text name=shift_id size=22 maxlength=20> ("._QXZ("no spaces or punctuation").")$NWB#shifts-shift_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Shift Name").": </td><td align=left><input type=text name=shift_name size=50 maxlength=50> ("._QXZ("short description of the shift").")$NWB#shifts-shift_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#shifts-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Shift Start Time").": </td><td align=left><input type=text name=shift_start_time size=5 maxlength=4 id=shift_start_time>\n";
		echo " &nbsp; "._QXZ("Shift End Time").": <input type=text name=shift_end_time size=5 maxlength=4 id=shift_end_time>\n";
		echo "<input style='background-color:#$SSbutton_color' type=button name=shift_calc value=\""._QXZ("Calculate Shift Length")."\" onClick=\"shift_time();\"> $NWB#shifts-shift_start_time$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Shift Length").": </td><td align=left><input type=text name=shift_length id=shift_length size=6 maxlength=5> $NWB#shifts-shift_length$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Shift Weekdays").": <BR>$NWB#shifts-shift_weekdays$NWE</td><td align=left>\n";
		echo "<input type=\"checkbox\" name=\"shift_weekdays[]\" value=\"0\">Sunday<BR>\n";
		echo "<input type=\"checkbox\" name=\"shift_weekdays[]\" value=\"1\">Monday<BR>\n";
		echo "<input type=\"checkbox\" name=\"shift_weekdays[]\" value=\"2\">Tuesday<BR>\n";
		echo "<input type=\"checkbox\" name=\"shift_weekdays[]\" value=\"3\">Wednesday<BR>\n";
		echo "<input type=\"checkbox\" name=\"shift_weekdays[]\" value=\"4\">Thursday<BR>\n";
		echo "<input type=\"checkbox\" name=\"shift_weekdays[]\" value=\"5\">Friday<BR>\n";
		echo "<input type=\"checkbox\" name=\"shift_weekdays[]\" value=\"6\">Saturday<BR>\n";
		echo "</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Report Option").": </td><td align=left><select size=1 name=report_option><option value='Y'>"._QXZ("Y")."</option><option value=\"N\" SELECTED>"._QXZ("N")."</option></select>$NWB#shifts-report_option$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=11111111111 display the ADD NEW PHONE SCREEN
######################
if ($ADD==11111111111)
	{
	if ( ($LOGast_admin_access==1) or ($LOGmodify_phones==1) )
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='phones' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$voi_count = "$row[0]";
			}
		##### END ID override optional section #####

		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_phones.png\" alt=\"Phones\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD A NEW PHONE")."<form action=$PHP_SELF method=POST>\n";

		##### Lookup settings container #####
		$SScontainer_stmt="select phone_defaults_container from system_settings limit 1";
		$SScontainer_rslt=mysql_to_mysqli($SScontainer_stmt, $link);
		$SScontainer_row=mysqli_fetch_row($SScontainer_rslt);
		$dps=array(); # Default phone setting array
		if (!preg_match('/\-\-\-DISABLED\-\-\-/', $SScontainer_row[0]))
			{
			$container_stmt="select container_entry from vicidial_settings_containers where container_id='$SScontainer_row[0]'";
			$container_rslt=mysql_to_mysqli($container_stmt, $link);
			$container_entry="";
			if (mysqli_num_rows($container_rslt)>0)
				{
				echo "<B><font color='#F00'>"._QXZ("Using default phone setting container")." $SScontainer_row[0]...</font></B><BR>\n";
				$container_row=mysqli_fetch_row($container_rslt);
				$container_entry=$container_row[0];
				$container_entry_array=explode("\n", $container_entry);
				for ($c=0; $c<count($container_entry_array); $c++)
					{
					$container_line=trim($container_entry_array[$c]);
					if (!preg_match('/^\#/', $container_line))
						{
						$current_setting_array=explode("=>", $container_line);
						if (strlen(trim($current_setting_array[0]))>0 && strlen(trim($current_setting_array[1]))>0)
							{
							# $$current_setting_array[0]=$current_setting_array[1];
							$dps[trim($current_setting_array[0])]=trim($current_setting_array[1]);
							}
						}
					}
				}
			}

		echo "<input type=hidden name=ADD value=21111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";

		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		if ($voi_count > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Phone Extension").": </td><td align=left>"._QXZ("Auto-Generated")." $NWB#phones-extension$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Phone Extension").": </td><td align=left><input type=text name=extension size=20 maxlength=100 value=\"\">$NWB#phones-extension$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Dial Plan Number").": </td><td align=left><input type=text name=dialplan_number size=15 maxlength=20> ("._QXZ("digits only").")$NWB#phones-dialplan_number$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Voicemail Box").": </td><td align=left><input type=text name=voicemail_id size=10 maxlength=10 value='".$dps["voicemail_id"]."'> ("._QXZ("digits only").")$NWB#phones-voicemail_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Outbound CallerID").": </td><td align=left><input type=text name=outbound_cid size=10 maxlength=20 value='".$dps["outbound_cid"]."'> ("._QXZ("digits only").")$NWB#phones-outbound_cid$NWE</td></tr>\n";
#		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>Phone IP address: </td><td align=left><input type=text name=phone_ip size=20 maxlength=15> (optional)$NWB#phones-phone_ip$NWE</td></tr>\n";
#		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>Computer IP address: </td><td align=left><input type=text name=computer_ip size=20 maxlength=15> (optional)$NWB#phones-computer_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		$s="SELECTED";
		if ($dps["user_group"])
			{
			echo "<option SELECTED value=\"".$dps["user_group"]."\">".$dps["user_group"]."</option>\n";
			$s="";
			}
		echo "$UUgroups_list";
		echo "<option $s value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#phones-user_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Server IP").": </td><td align=left><select size=1 name=server_ip>\n";
		if ($dps["server_ip"])
			{
			echo "<option SELECTED value=\"".$dps["server_ip"]."\">".$dps["server_ip"]."</option>\n";
			}
		echo "$servers_list";
		echo "</select>$NWB#phones-server_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Screen Login").": </td><td align=left><input type=text name=login size=15 maxlength=15>$NWB#phones-login$NWE</td></tr>\n";
		if ($dps["pass"])
			{
			$SSdefault_phone_login_password=$dps["pass"];
			}
		if ($dps["conf_secret"])
			{
			$SSdefault_phone_registration_password=$dps["conf_secret"];
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Login Password").": </td><td align=left><input type=text name=pass size=40 maxlength=100 value=\"$SSdefault_phone_login_password\">$NWB#phones-pass$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Registration Password").": </td><td align=left style=\"display:table-cell; vertical-align:middle;\" NOWRAP><input type=text id=reg_pass name=conf_secret size=40 maxlength=100 value=\"$SSdefault_phone_registration_password\" onkeyup=\"return pwdChanged('reg_pass','reg_pass_img','pass_length','$SSrequire_password_length');\">$NWB#phones-conf_secret$NWE &nbsp; &nbsp; <font size=1>"._QXZ("Strength").":</font> <IMG id=reg_pass_img src='images/pixel.gif' style=\"vertical-align:middle;\" onLoad=\"return pwdChanged('reg_pass','reg_pass_img','pass_length','$SSrequire_password_length');\"> &nbsp; <font size=1> "._QXZ("Length").": <span id=pass_length name=pass_length>0</span></font></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Status").": </td><td align=left><select size=1 name=status>";
		
		if ($dps["status"])
			{
			echo "<option value='".$dps["status"]."' SELECTED>".$dps["status"]."</option>";
			echo "<option value='ACTIVE'>"._QXZ("ACTIVE")."</option>";
			}
		else
			{
			echo "<option value='ACTIVE' SELECTED>"._QXZ("ACTIVE")."</option>";
			}
		echo "<option value='SUSPENDED'>"._QXZ("SUSPENDED")."</option><option value='CLOSED'>"._QXZ("CLOSED")."</option><option value='PENDING'>"._QXZ("PENDING")."</option><option value='ADMIN'>"._QXZ("ADMIN")."</option></select>$NWB#phones-status$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active Account").": </td><td align=left><select size=1 name=active>";
		
		echo "<option value='Y' ".($dps["active"]!="N" ? "selected" : "").">"._QXZ("Y")."</option><option value='N' ".($dps["active"]=="N" ? "selected" : "").">"._QXZ("N")."</option></select>$NWB#phones-active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Phone Type").": </td><td align=left><input type=text name=phone_type size=20 maxlength=50 value='".$dps["phone_type"]."'>$NWB#phones-phone_type$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Full Name").": </td><td align=left><input type=text name=fullname size=20 maxlength=50>$NWB#phones-fullname$NWE</td></tr>\n";
#		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>Company: </td><td align=left><input type=text name=company size=10 maxlength=10>$NWB#phones-company$NWE</td></tr>\n";
#		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>Picture: </td><td align=left><input type=text name=picture size=20 maxlength=19>$NWB#phones-picture$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Client Protocol").": </td><td align=left><select size=1 name=protocol>";
		$SIP_selected=0;
		if ($dps["protocol"])
			{
			echo "<option value='".$dps["protocol"]."' SELECTED>".$dps["protocol"]."</option>";
			if ( ($SSallowed_sip_stacks == 'SIP') or ($SSallowed_sip_stacks == 'SIP_and_PJSIP') ) {echo "<option>SIP</option>";}
			$SIP_selected++;
			}
		else
			{
			if ( ($SSallowed_sip_stacks == 'SIP') or ($SSallowed_sip_stacks == 'SIP_and_PJSIP') ) {echo "<option SELECTED>SIP</option>";   $SIP_selected++;}
			}
		$PJSIP_selected='';
		if ($SIP_selected < 1) {$PJSIP_selected = ' SELECTED';}
		if ( ($SSallowed_sip_stacks == 'PJSIP') or ($SSallowed_sip_stacks == 'SIP_and_PJSIP') ) {echo "<option$PJSIP_selected>PJSIP</option>";}
		echo "<option>Zap</option><option>IAX2</option><option value='EXTERNAL'>"._QXZ("EXTERNAL")."</option><option>DAHDI</option></select>$NWB#phones-protocol$NWE</td></tr>\n";
		if ($dps["local_gmt"])
			{
			$SSdefault_local_gmt=$dps["local_gmt"];
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Local GMT").": </td><td align=left><select size=1 name=local_gmt><option>12.75</option><option>12.00</option><option>11.00</option><option>10.00</option><option>9.50</option><option>9.00</option><option>8.00</option><option>7.00</option><option>6.50</option><option>6.00</option><option>5.75</option><option>5.50</option><option>5.00</option><option>4.50</option><option>4.00</option><option>3.50</option><option>3.00</option><option>2.00</option><option>1.00</option><option>0.00</option><option>-1.00</option><option>-2.00</option><option>-3.00</option><option>-3.50</option><option>-4.00</option><option>-5.00</option><option>-6.00</option><option>-7.00</option><option>-8.00</option><option>-9.00</option><option>-10.00</option><option>-11.00</option><option>-12.00</option><option SELECTED>$SSdefault_local_gmt</option></select> ("._QXZ("Do NOT Adjust for DST").")$NWB#phones-local_gmt$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}

######################
# ADD=21222222222 adds copied new phone to the system
######################
if ($ADD==21222222222)
	{
	$source_phone_array=explode("|", $source_phone);
	$source_extension=$source_phone_array[0];
	$source_server_ip=$source_phone_array[1];
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	 else
		{
		$stmt="SELECT count(*) from phones where extension='$source_extension' and server_ip='$source_server_ip';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{
			echo "<br>"._QXZ("PHONE NOT COPIED - Your selected Source Phone does not exist")."\n";
			}
		 else
			{
			echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
			$stmt="SELECT count(*) from phones where extension='$new_extension' and server_ip='$new_server_ip';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] > 0)
				{echo "<br>"._QXZ("PHONE NOT COPIED - there is already a phone in the system with this extension/server")."\n";}
			else
				{
				$stmt="SELECT count(*) from phones where login='$new_login';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				if ($row[0] > 0)
					{echo "<br>"._QXZ("PHONE NOT COPIED - there is already a Phone in the system with this login")."\n";}
				else
					{
					$stmt="SELECT count(*) from phones_alias where alias_id='$new_login';";
					$rslt=mysql_to_mysqli($stmt, $link);
					$row=mysqli_fetch_row($rslt);
					if ($row[0] > 0)
						{echo "<br>"._QXZ("PHONE NOT COPIED - there is already a Phone alias in the system with this login")."\n";}
					else
						{
						$stmt="SELECT count(*) from vicidial_voicemail where voicemail_id='$new_voicemail_id';";
						$rslt=mysql_to_mysqli($stmt, $link);
						$row=mysqli_fetch_row($rslt);
						if ($row[0] > 0)
							{echo "<br>"._QXZ("PHONE NOT COPIED - there is already a Voicemail ID in the system with this ID")."\n";}
						else
							{
							if ( (strlen($new_extension) < 1) or (strlen($new_server_ip) < 7) or (strlen($new_dialplan_number) < 1) or (strlen($new_voicemail_id) < 1) or (strlen($new_login) < 1)  or (strlen($new_pass) < 1) or ( ($SSrequire_password_length > 0) and ($SSrequire_password_length > strlen($new_conf_secret)) ))
								{
								echo "<br>"._QXZ("PHONE NOT COPIED - Please go back and look at the data you entered")."\n";
								echo "<br>"._QXZ("The following fields must have data").": extension, server_ip, dialplan_number, voicemail_id, login, pass\n";
								if ($SSrequire_password_length > 0)
									{
									echo "<br>"._QXZ("registration password must be at least $SSrequire_password_length characters long")."\n";
									}
								}
							else
								{
								$ins_stmt="INSERT INTO phones(extension, dialplan_number, voicemail_id, phone_ip, computer_ip, server_ip, login, pass, status, active, phone_type, fullname, company, picture, messages, old_messages, protocol, local_gmt, ASTmgrUSERNAME, ASTmgrSECRET, login_user, login_pass, login_campaign, park_on_extension, conf_on_extension, VICIDIAL_park_on_extension, VICIDIAL_park_on_filename, monitor_prefix, recording_exten, voicemail_exten, voicemail_dump_exten, ext_context, dtmf_send_extension, call_out_number_group, client_browser, install_directory, local_web_callerID_URL, VICIDIAL_web_URL, AGI_call_logging_enabled, user_switching_enabled, conferencing_enabled, admin_hangup_enabled, admin_hijack_enabled, admin_monitor_enabled, call_parking_enabled, updater_check_enabled, AFLogging_enabled, QUEUE_ACTION_enabled, CallerID_popup_enabled, voicemail_button_enabled, enable_fast_refresh, fast_refresh_rate, enable_persistant_mysql, auto_dial_next_number, VDstop_rec_after_each_call, DBX_server, DBX_database, DBX_user, DBX_pass, DBX_port, DBY_server, DBY_database, DBY_user, DBY_pass, DBY_port, outbound_cid, enable_sipsak_messages, email, template_id, conf_override, phone_context, phone_ring_timeout, conf_secret, delete_vm_after_email, is_webphone, use_external_server_ip, codecs_list, codecs_with_template, webphone_dialpad, on_hook_agent, webphone_auto_answer, voicemail_timezone, voicemail_options, user_group, voicemail_greeting, voicemail_dump_exten_no_inst, voicemail_instructions, on_login_report, unavail_dialplan_fwd_exten, unavail_dialplan_fwd_context, nva_call_url, nva_search_method, nva_error_filename, nva_new_list_id, nva_new_phone_code, nva_new_status, webphone_dialbox, webphone_mute, webphone_volume, webphone_debug, outbound_alt_cid, conf_qualify, webphone_layout, mohsuggest, webphone_settings) SELECT '$new_extension', '$new_dialplan_number', '$new_voicemail_id', phone_ip, computer_ip, '$new_server_ip', '$new_login', '$new_pass', status, active, phone_type, '$new_fullname', company, picture, messages, old_messages, protocol, local_gmt, ASTmgrUSERNAME, ASTmgrSECRET, login_user, login_pass, login_campaign, park_on_extension, conf_on_extension, VICIDIAL_park_on_extension, VICIDIAL_park_on_filename, monitor_prefix, recording_exten, voicemail_exten, voicemail_dump_exten, ext_context, dtmf_send_extension, call_out_number_group, client_browser, install_directory, local_web_callerID_URL, VICIDIAL_web_URL, AGI_call_logging_enabled, user_switching_enabled, conferencing_enabled, admin_hangup_enabled, admin_hijack_enabled, admin_monitor_enabled, call_parking_enabled, updater_check_enabled, AFLogging_enabled, QUEUE_ACTION_enabled, CallerID_popup_enabled, voicemail_button_enabled, enable_fast_refresh, fast_refresh_rate, enable_persistant_mysql, auto_dial_next_number, VDstop_rec_after_each_call, DBX_server, DBX_database, DBX_user, DBX_pass, DBX_port, DBY_server, DBY_database, DBY_user, DBY_pass, DBY_port, '$new_outbound_cid', enable_sipsak_messages, email, template_id, conf_override, phone_context, phone_ring_timeout, '$new_conf_secret', delete_vm_after_email, is_webphone, use_external_server_ip, codecs_list, codecs_with_template, webphone_dialpad, on_hook_agent, webphone_auto_answer, voicemail_timezone, voicemail_options, user_group, voicemail_greeting, voicemail_dump_exten_no_inst, voicemail_instructions, on_login_report, unavail_dialplan_fwd_exten, unavail_dialplan_fwd_context, nva_call_url, nva_search_method, nva_error_filename, nva_new_list_id, nva_new_phone_code, nva_new_status, webphone_dialbox, webphone_mute, webphone_volume, webphone_debug, outbound_alt_cid, conf_qualify, webphone_layout, mohsuggest, webphone_settings from phones where extension='$source_extension' and server_ip='$source_server_ip'";
								$ins_rslt=mysql_to_mysqli($ins_stmt, $link);
								$affected_rows = mysqli_affected_rows($link);
								if ($affected_rows>0)
									{
									echo "<br><B>"._QXZ("PHONE COPIED").": $new_extension, $new_server_ip - <a href='admin.php?ADD=31111111111&extension=$new_extension&server_ip=$new_server_ip'>VIEW HERE</a></B>.  <BR><BR>Please allow up to 1 minute for the server dialplan to update with the new phone.\n";

									$upd_stmt="UPDATE servers set rebuild_conf_files='Y' where server_ip='$new_server_ip';";
									$upd_rslt=mysql_to_mysqli($upd_stmt, $link);
									$affected_rowsS = mysqli_affected_rows($link);

									### LOG INSERTION Admin Log Table ###
									$SQL_log = "$ins_stmt|$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='PHONES', event_type='COPY', record_id='$new_extension-$new_server_ip', event_code='ADMIN COPY PHONE', event_sql=\"$SQL_log\", event_notes='$affected_rows,$affected_rowsS';";
									if ($DB) {echo "|$stmt|\n";}
									$rslt=mysql_to_mysqli($stmt, $link);

									}
								else
									{
									echo "<br>"._QXZ("UNKNOWN SQL ERROR - $ins_stmt")."\n";
									}
								}
							}
						}
					}
				}
			}
		}
	echo "</font>";
	$ADD=12222222222;
	}

######################
# ADD=12222222222 display the COPY PHONE SCREEN
######################
if ($ADD==12222222222)
	{
	if ($LOGmodify_phones==1)
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_campaigns' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$voi_count = "$row[0]";
			}
		##### END ID override optional section #####

		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_phones.png\" alt=\"Phones\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo ""._QXZ("COPY A PHONE")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=21222222222>\n";
		echo "<input type=hidden name=DB value=\"$DB\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		/*
		if ($voi_count > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign ID").": </td><td align=left>"._QXZ("Auto-Generated")." $NWB#campaigns-campaign_id$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign ID").": </td><td align=left><input type=text name=campaign_id size=10 maxlength=8>$NWB#campaigns-campaign_id$NWE</td></tr>\n";
			}
		*/
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Phone Extension").": </td><td align=left><input type=text name=new_extension size=20 maxlength=100 value='$new_extension'>$NWB#phones-extension$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Dial Plan Number").": </td><td align=left><input type=text name=new_dialplan_number size=15 maxlength=20 value='$new_dialplan_number'> ("._QXZ("digits only").")$NWB#phones-dialplan_number$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Voicemail Box").": </td><td align=left><input type=text name=new_voicemail_id size=10 maxlength=10 value='$new_voicemail_id'> ("._QXZ("digits only").")$NWB#phones-voicemail_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Outbound CallerID").": </td><td align=left><input type=text name=new_outbound_cid size=10 maxlength=20 value='$new_outbound_cid'> ("._QXZ("digits only").")$NWB#phones-outbound_cid$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Server IP").": </td><td align=left><select size=1 name=new_server_ip>\n";
		if ($new_server_ip) {echo "<option value='$new_server_ip' selected>$new_server_ip</option>\n";}
		echo "$servers_list";
		echo "</select>$NWB#phones-server_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Screen Login").": </td><td align=left><input type=text name=new_login size=15 maxlength=15 value='$new_login'>$NWB#phones-login$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Login Password").": </td><td align=left><input type=text name=new_pass size=40 maxlength=100 value=\"".(!$new_pass ? $SSdefault_phone_login_password : $new_pass)."\">$NWB#phones-pass$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Registration Password").": </td><td align=left style=\"display:table-cell; vertical-align:middle;\" NOWRAP><input type=text id=reg_pass name=new_conf_secret size=40 maxlength=100 value=\"".(!$new_conf_secret ? $SSdefault_phone_registration_password : $new_conf_secret)."\" onkeyup=\"return pwdChanged('reg_pass','reg_pass_img','pass_length','$SSrequire_password_length');\">$NWB#phones-conf_secret$NWE &nbsp; &nbsp; <font size=1>"._QXZ("Strength").":</font> <IMG id=reg_pass_img src='images/pixel.gif' style=\"vertical-align:middle;\" onLoad=\"return pwdChanged('reg_pass','reg_pass_img','pass_length','$SSrequire_password_length');\"> &nbsp; <font size=1> "._QXZ("Length").": <span id=pass_length name=pass_length>0</span></font></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Full Name").": </td><td align=left><input type=text name=new_fullname size=20 maxlength=50 value='$new_fullname'>$NWB#phones-fullname$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Source Phone").": </td><td align=left><select size=1 name=source_phone>\n";
		$stmt="SELECT extension, server_ip, fullname from phones $whereLOGadmin_viewable_groupsSQL order by extension, server_ip, fullname;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$phones_to_print = mysqli_num_rows($rslt);
		$phones_list='';
		$phone_selected=0;
		$o=0;
		while ($phones_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			if ($source_phone=="$rowx[0]|$rowx[1]") {$s=" selected";   $phone_selected++;} else {$s="";}
			$phones_list .= "<option value=\"$rowx[0]|$rowx[1]\"$s>$rowx[0], $rowx[1]</option>\n";
			$o++;
			}
		if ($phone_selected < 1)
			{echo "<option value=\"\" selected>-- Select a Phone (Extension, Server) --</option>\n";}
		echo "$phones_list";
		echo "</select>$NWB#campaigns-campaign_id$NWE</td></tr>\n";
		
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>"._QXZ("NOTE: Copying a phone will copy all the settings from the selected source phone, except for the settings entered above.")."</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}

######################
# ADD=12111111111 display the ADD NEW PHONE ALIAS SCREEN
######################
if ($ADD==12111111111)
	{
	if ( ($LOGast_admin_access==1) or ($LOGmodify_phones==1) )
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_phones.png\" alt=\"Phones\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD A NEW PHONE ALIAS")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=22111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";

		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Alias ID").": </td><td align=left><input type=text name=alias_id size=20 maxlength=20 value=\"\">$NWB#phones-alias_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Alias Name").": </td><td align=left><input type=text name=alias_name size=30 maxlength=50> $NWB#phones-alias_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#phones-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Phone Logins List").": </td><td align=left><input type=text name=logins_list size=50 maxlength=255> ("._QXZ("comma separated").")$NWB#phones-logins_list$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=13111111111 display the ADD NEW GROUP ALIAS SCREEN
######################
if ($ADD==13111111111)
	{
	if ( ($LOGast_admin_access==1) or ($LOGmodify_phones==1) )
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_phones.png\" alt=\"Phones\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD A NEW GROUP ALIAS")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=23111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";

		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group Alias ID").": </td><td align=left><input type=text name=group_alias_id size=30 maxlength=30 value=\"\">$NWB#phones-group_alias_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group Alias Name").": </td><td align=left><input type=text name=group_alias_name size=30 maxlength=50> $NWB#phones-group_alias_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("CallerID Number").": </td><td align=left><input type=text name=caller_id_number size=20 maxlength=20> $NWB#phones-caller_id_number$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("CallerID Name").": </td><td align=left><input type=text name=caller_id_name size=20 maxlength=20> $NWB#phones-caller_id_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='Y'>"._QXZ("Y")."</option><option selected value='N'>"._QXZ("N")."</option></select></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#phones-user_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=111111111111 display the ADD NEW SERVER SCREEN
######################
if ($ADD==111111111111)
	{
	if ($LOGmodify_servers==1)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_servers.png\" alt=\"Servers\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD A NEW SERVER")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=211111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Server ID").": </td><td align=left><input type=text name=server_id size=10 maxlength=10>$NWB#servers-server_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Server Description").": </td><td align=left><input type=text name=server_description size=30 maxlength=255>$NWB#servers-server_description$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Server IP Address").": </td><td align=left><input type=text name=server_ip size=20 maxlength=15>$NWB#servers-server_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option></select>$NWB#servers-active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Asterisk Version").": </td><td align=left><input type=text name=asterisk_version size=20 maxlength=20>$NWB#servers-asterisk_version$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#servers-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=131111111111 display the ADD NEW CONF TEMPLATE SCREEN
######################
if ($ADD==131111111111)
	{
	if ($LOGmodify_servers==1)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_templates.png\" alt=\"Templates\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW CONF TEMPLATE")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=231111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Template ID").": </td><td align=left><input type=text name=template_id size=15 maxlength=15>$NWB#conf_templates-template_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Template Name").": </td><td align=left><input type=text name=template_name size=40 maxlength=50>$NWB#conf_templates-template_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#conf_templates-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Template Contents").": </td><td align=left><TEXTAREA NAME=template_contents ROWS=12 COLS=70></TEXTAREA> $NWB#conf_templates-template_contents$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=141111111111 display the ADD NEW CARRIER SCREEN
######################
if ($ADD==141111111111)
	{
	if ( ( ($LOGmodify_servers==1) or ($LOGmodify_carriers==1) ) and ($x_ra_carrier < 1) )
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_carriers.png\" alt=\"Carriers\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW CARRIER")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=241111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Carrier ID").": </td><td align=left><input type=text name=carrier_id size=15 maxlength=15>$NWB#server_carriers-carrier_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Carrier Name").": </td><td align=left><input type=text name=carrier_name size=40 maxlength=50>$NWB#server_carriers-carrier_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Carrier Description").": </td><td align=left><input type=text name=carrier_description size=70 maxlength=255>$NWB#server_carriers-carrier_description$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#server_carriers-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Registration String").": </td><td align=left><input type=text name=registration_string size=50 maxlength=255>$NWB#server_carriers-registration_string$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Template ID").": </td><td align=left><select size=1 name=template_id>\n";
		$stmt="SELECT template_id,template_name from vicidial_conf_templates $whereLOGadmin_viewable_groupsSQL order by template_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$templates_to_print = mysqli_num_rows($rslt);
		$templates_list='<option value=\'--NONE--\' SELECTED>--'._QXZ("NONE").'--</option>';
		$o=0;
		while ($templates_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$templates_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		echo "$templates_list";
		echo "</select>$NWB#server_carriers-template_id$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Account Entry").": </td><td align=left><TEXTAREA NAME=account_entry ROWS=10 COLS=70></TEXTAREA> $NWB#server_carriers-account_entry$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Protocol").": </td><td align=left><select size=1 name=protocol>";
		if ( ($SSallowed_sip_stacks == 'SIP') or ($SSallowed_sip_stacks == 'SIP_and_PJSIP') ) {echo "<option>SIP</option>";}
		if ( ($SSallowed_sip_stacks == 'PJSIP') or ($SSallowed_sip_stacks == 'SIP_and_PJSIP') ) {echo "<option>PJSIP</option><option>PJSIP_WIZ</option>";}
		echo "<option>Zap</option>";
		echo "<option>IAX2</option>";
		echo "<option value='EXTERNAL'>"._QXZ("EXTERNAL")."</option>";
		echo "</select>$NWB#server_carriers-protocol$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Globals String").": </td><td align=left><input type=text name=globals_string size=50 maxlength=255>$NWB#server_carriers-globals_string$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Dialplan Entry").": </td><td align=left><TEXTAREA NAME=dialplan_entry ROWS=10 COLS=70></TEXTAREA> $NWB#server_carriers-dialplan_entry$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Server IP").": </td><td align=left><select size=1 name=server_ip>\n";
		echo "$servers_list";
		echo "</select>$NWB#server_carriers-server_ip$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=140111111111 display the ADD COPIED CARRIER SCREEN
######################
if ($ADD==140111111111)
	{
	if ( ( ($LOGmodify_servers==1) or ($LOGmodify_carriers==1) ) and ($x_ra_carrier < 1) )
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_carriers.png\" alt=\"Carriers\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD COPIED CARRIER")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=240111111111>\n";
		echo "<input type=hidden name=DB value='$DB'>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Carrier ID").": </td><td align=left><input type=text name=carrier_id size=15 maxlength=15>$NWB#server_carriers-carrier_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Carrier Name").": </td><td align=left><input type=text name=carrier_name size=40 maxlength=50>$NWB#server_carriers-carrier_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Server IP").": </td><td align=left><select size=1 name=server_ip>\n";
		echo "$servers_list";
		echo "</select>$NWB#server_carriers-server_ip$NWE</td></tr>\n";


		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Source Carrier").": </td><td align=left><select size=1 name=source_carrier>\n";

		$stmt="SELECT carrier_id,carrier_name,server_ip from vicidial_server_carriers $whereLOGadmin_viewable_groupsSQL order by carrier_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$menus_to_print = mysqli_num_rows($rslt);
		$menus_list='';

		$o=0;
		while ($menus_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$menus_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1] - $rowx[2]</option>\n";
			$o++;
			}
		echo "$menus_list";
		echo "</select>$NWB#server_carriers-carrier_id$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=151111111111 display the ADD NEW TTS ENTRY SCREEN
######################
if ($ADD==151111111111)
	{
	if ( ($LOGmodify_servers==1) or ($LOGmodify_tts==1) )
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_texttospeech.png\" alt=\"Text to Speech\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW TTS ENTRY")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=251111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("TTS ID").": </td><td align=left><input type=text name=tts_id size=30 maxlength=50>$NWB#tts_prompts-tts_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("TTS Name").": </td><td align=left><input type=text name=tts_name size=50 maxlength=100>$NWB#tts_prompts-tts_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option>$NWB#tts_prompts-active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#tts_prompts-user_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=161111111111 display the ADD NEW MUSIC ON HOLD ENTRY SCREEN
######################
if ($ADD==161111111111)
	{
	if ( ($LOGmodify_servers==1) or ($LOGmodify_moh==1) )
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_musiconhold.png\" alt=\"Music on Hold\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW MUSIC ON HOLD ENTRY")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=261111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Music On Hold ID").": </td><td align=left><input type=text name=moh_id size=50 maxlength=100>$NWB#music_on_hold-moh_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Music On Hold Name").": </td><td align=left><input type=text name=moh_name size=70 maxlength=255>$NWB#music_on_hold-moh_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Random Order").": </td><td align=left><select size=1 name=random><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option>$NWB#music_on_hold-random$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#music_on_hold-user_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=171111111111 display the ADD NEW VOICEMAIL BOX SCREEN
######################
if ($ADD==171111111111)
	{
	if ( ($LOGmodify_servers==1) or ($LOGmodify_moh==1) )
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_voicemail.png\" alt=\"Voicemail\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW VOICEMAIL BOX")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=271111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Voicemail ID").": </td><td align=left><input type=text name=voicemail_id size=12 maxlength=10>$NWB#voicemail-voicemail_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Pass").": </td><td align=left><input type=text name=pass size=10 maxlength=10>$NWB#voicemail-pass$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Name").": </td><td align=left><input type=text name=fullname size=50 maxlength=100>$NWB#voicemail-fullname$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option>$NWB#voicemail-active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Email").": </td><td align=left><input type=text name=email size=50 maxlength=100>$NWB#voicemail-email$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#voicemail-user_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=181111111111 display the ADD NEW SCREEN LABEL SCREEN
######################
if ($ADD==181111111111)
	{
	if ( ($LOGmodify_servers==1) or ($LOGmodify_labels==1) )
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_screenlabels.png\" alt=\"Screen Labels\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW SCREEN LABEL")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=281111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Screen Label ID").": </td><td align=left><input type=text name=label_id size=21 maxlength=20>$NWB#screen_labels-label_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Screen Label Name").": </td><td align=left><input type=text name=label_name size=70 maxlength=100>$NWB#screen_labels-label_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#screen_labels-user_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=182111111111 display the ADD NEW SCREEN LABEL SCREEN
######################
if ($ADD==182111111111)
	{
	if ( ($LOGmodify_servers==1) or ($LOGmodify_colors==1) )
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_screencolors.png\" alt=\"Screen Colors\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW SCREEN COLORS")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=282111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Screen Colors ID").": </td><td align=left><input type=text name=colors_id size=21 maxlength=20>$NWB#screen_labels-label_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Screen Colors Name").": </td><td align=left><input type=text name=colors_name size=70 maxlength=100>$NWB#screen_labels-label_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#screen_labels-user_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=191111111111 display the ADD NEW CONTACT SCREEN
######################
if ($ADD==191111111111)
	{
	if ( ($LOGmodify_servers==1) or ($LOGmodify_contacts==1) )
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_contacts.png\" alt=\"Contacts\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW CONTACT")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=291111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("First Name").": </td><td align=left><input type=text name=first_name size=50 maxlength=50>$NWB#contact_information$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Last Name").": </td><td align=left><input type=text name=last_name size=50 maxlength=50>$NWB#contact_information$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Office Number").": </td><td align=left><input type=text name=office_num size=20 maxlength=20>$NWB#contact_information$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Cell Number").": </td><td align=left><input type=text name=cell_num size=20 maxlength=20>$NWB#contact_information$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Other Number")." 1: </td><td align=left><input type=text name=other_num1 size=20 maxlength=20>$NWB#contact_information$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Other Number")." 2: </td><td align=left><input type=text name=other_num2 size=20 maxlength=20>$NWB#contact_information$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("BU Name").": </td><td align=left><input type=text name=bu_name size=50 maxlength=100>$NWB#contact_information$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Department").": </td><td align=left><input type=text name=department size=50 maxlength=100>$NWB#contact_information$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group").": </td><td align=left><input type=text name=group_name size=50 maxlength=100>$NWB#contact_information$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Job Title").": </td><td align=left><input type=text name=job_title size=50 maxlength=100>$NWB#contact_information$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Location").": </td><td align=left><input type=text name=location size=50 maxlength=100>$NWB#contact_information$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=192111111111 display the ADD NEW SETTINGS CONTAINER
######################
if ($ADD==192111111111)
	{
	if ($LOGmodify_servers==1)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_settingscontainer.png\" alt=\"Settings Container\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW SETTINGS CONTAINER")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=292111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Container ID").": </td><td align=left><input type=text name=container_id size=40 maxlength=40>$NWB#settings_containers-container_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Container Notes").": </td><td align=left><input type=text name=container_notes size=50 maxlength=255>$NWB#settings_containers-container_notes$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Container Type").": </td><td align=left><select size=1 name=container_type>
		<option value='2FA_SETTINGS'>"._QXZ("2FA_SETTINGS")."</option>
		<option value='AGI'>"._QXZ("AGI")."</option>
		<option value='AMD_AGENT_OPTIONS'>"._QXZ("AMD_AGENT_OPTIONS")."</option>
		<option value='CALL_LIMITS_OVERRIDE'>"._QXZ("CALL_LIMITS_OVERRIDE")."</option>
		<option value='CALL_QUOTA'>"._QXZ("CALL_QUOTA")."</option>
		<option value='CALLS_IN_QUEUE_COUNT'>"._QXZ("CALLS_IN_QUEUE_COUNT")."</option>
		<option value='CAMPAIGN_LIST'>"._QXZ("CAMPAIGN_LIST")."</option>
		<option value='CM_VIDPROMPT_SPECIAL'>"._QXZ("CM_VIDPROMPT_SPECIAL")."</option>
		<option value='DEMOGRAPHIC_QUOTAS'>"._QXZ("DEMOGRAPHIC_QUOTAS")."</option>
		<option value='DIAL_TIMEOUTS'>"._QXZ("DIAL_TIMEOUTS")."</option>
		<option value='DID_RECENT_CALL'>"._QXZ("DID_RECENT_CALL")."</option>
		<option value='DISPO_FILTER'>"._QXZ("DISPO_FILTER")."</option>
		<option value='EMAIL_TEMPLATE'>"._QXZ("EMAIL_TEMPLATE")."</option>
		<option value='INGROUP_LIST'>"._QXZ("INGROUP_LIST")."</option>
		<option value='KHOMP_SETTINGS'>"._QXZ("KHOMP_SETTINGS")."</option>
		<option value='LIST_WEEKDAY_RESETS'>"._QXZ("LIST_WEEKDAY_RESETS")."</option>
		<option value='OTHER' SELECTED>"._QXZ("OTHER")."</option>
		<option value='PAUSE_CODES_LIST'>"._QXZ("PAUSE_CODES_LIST")."</option>
		<option value='PERL_CLI'>"._QXZ("PERL_CLI")."</option>
		<option value='PHONE_DEFAULTS'>"._QXZ("PHONE_DEFAULTS")."</option>
		<option value='PHONE_NUMBERS'>"._QXZ("PHONE_NUMBERS")."</option>
		<option value='QC_TEMPLATE'>"._QXZ("QC_TEMPLATE")."</option>
		<option value='READ_ONLY'>"._QXZ("READ_ONLY")."</option>
		<option value='SIP_EVENT_ACTIONS'>"._QXZ("SIP_EVENT_ACTIONS")."</option>
		<option value='STATE_DESCRIPTIONS'>"._QXZ("STATE_DESCRIPTIONS")."</option>
		<option value='TIMEZONE_LIST'>"._QXZ("TIMEZONE_LIST")."</option>
		<option value='WEBPHONE_SETTINGS'>"._QXZ("WEBPHONE_SETTINGS")."</option>
		<option value='WEEKDAY_TIMERANGE_SECONDS'>"._QXZ("WEEKDAY_TIMERANGE_SECONDS")."</option>
		</select>$NWB#settings_containers-container_type$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#settings_containers-user_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=193111111111 display the ADD NEW Statuses Group
######################
if ($ADD==193111111111)
	{
	if ($LOGmodify_statuses==1)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_statusgroups.png\" alt=\"Status Groups\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW STATUSES GROUP")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=293111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Status Group ID").": </td><td align=left><input type=text name=status_group_id size=20 maxlength=20>$NWB#status_groups$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Status Group Notes").": </td><td align=left><input type=text name=status_group_notes size=50 maxlength=255>$NWB#status_groups$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#status_groups$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=194111111111 display the ADD NEW AUTOMATED REPORT screen
######################
if ($ADD==194111111111)
	{
	if ($LOGmodify_auto_reports==1)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_autoreports.png\" alt=\"Automated Reports\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW AUTOMATED REPORT")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=294111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Report ID").": </td><td align=left><input type=text name=report_id size=30 maxlength=30>$NWB#auto_reports-report_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Report Name").": </td><td align=left><input type=text name=report_name size=70 maxlength=100>$NWB#auto_reports-report_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#auto_reports-user_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=195111111111 display the ADD NEW IP LIST screen
######################
if ($ADD==195111111111)
	{
	if ($LOGmodify_ip_lists==1)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_iplists.png\" alt=\"IP Lists\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW IP LIST")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=295111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("IP List ID").": </td><td align=left><input type=text name=ip_list_id size=30 maxlength=30>$NWB#ip_lists-ip_list_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("IP List Name").": </td><td align=left><input type=text name=ip_list_name size=70 maxlength=100>$NWB#ip_lists-ip_list_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#ip_lists-user_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=196111111111 display the ADD NEW CID Group
######################
if ($ADD==196111111111)
	{
	if ($LOGmodify_statuses==1)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_cidgroups.png\" alt=\"CID Groups\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW CID GROUP")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=296111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("CID Group ID").": </td><td align=left><input type=text name=cid_group_id size=20 maxlength=20>$NWB#cid_groups$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("CID Group Notes").": </td><td align=left><input type=text name=cid_group_notes size=50 maxlength=255>$NWB#cid_groups$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("CID Group Type").": </td><td align=left><select size=1 name=cid_group_type>\n";
		echo "<option SELECTED value=\"AREACODE\">"._QXZ("AREACODE")."</option>\n";
		echo "<option value=\"STATE\">"._QXZ("STATE")."</option>\n";
		echo "<option value=\"NONE\">"._QXZ("NONE")."</option>\n";
		echo "</select>$NWB#cid_groups$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#cid_groups$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=197111111111 display the ADD NEW VM MESSAGE Group
######################
if ($ADD==197111111111)
	{
	if ($LOGmodify_statuses==1)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_vm_messages.png\" alt=\"VM Message Groups\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW VM MESSAGE GROUP")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=297111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("VM Message Group ID").": </td><td align=left><input type=text name=leave_vm_message_group_id size=40 maxlength=40>$NWB#vm_message_groups$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("VM Message Group Notes").": </td><td align=left><input type=text name=leave_vm_message_group_notes size=50 maxlength=255>$NWB#vm_message_groups$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active>\n";
		echo "<option SELECTED value=\"N\">"._QXZ("No")."</option>\n";
		echo "<option value=\"Y\">"._QXZ("Yes")."</option>\n";
		echo "</select>$NWB#vm_message_groups$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#vm_message_groups$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=198111111111 display the ADD NEW Queue Group
######################
if ($ADD==198111111111)
	{
	if ($LOGmodify_statuses==1)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_queuegroups.png\" alt=\"Queue Groups\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD NEW QUEUE GROUP")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=298111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Queue Group ID").": </td><td align=left><input type=text name=queue_group size=20 maxlength=20>$NWB#queue_groups$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Queue Group Name").": </td><td align=left><input type=text name=queue_group_name size=40 maxlength=40>$NWB#queue_groups$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active>\n";
		echo "<option SELECTED value=\"N\">"._QXZ("No")."</option>\n";
		echo "<option value=\"Y\">"._QXZ("Yes")."</option>\n";
		echo "</select>$NWB#queue_groups$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"---ALL---\">"._QXZ("All Admin User Groups")."</option>\n";
		echo "</select>$NWB#queue_groups$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=1111111111111 display the ADD NEW CONFERENCE SCREEN
######################
if ($ADD==1111111111111)
	{
	if ($LOGast_admin_access==1)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_conferences.png\" alt=\"Conferences\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD A NEW CONFERENCE")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=2111111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Conference Number").": </td><td align=left><input type=text name=conf_exten size=8 maxlength=7> ("._QXZ("digits only").")$NWB#conferences-conf_exten$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Server IP").": </td><td align=left><select size=1 name=server_ip>\n";
		echo "$servers_list";
		echo "</select>$NWB#conferences-server_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=11111111111111 display the ADD NEW VICIDIAL CONFERENCE SCREEN
######################
if ($ADD==11111111111111)
	{
	if ($LOGast_admin_access==1)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_conferences.png\" alt=\"Conferences\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD A NEW AGENT CONFERENCE")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=21111111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Conference Number").": </td><td align=left><input type=text name=conf_exten size=8 maxlength=7> ("._QXZ("digits only").")$NWB#conferences-conf_exten$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Server IP").": </td><td align=left><select size=1 name=server_ip>\n";
		echo "$servers_list";
		echo "</select>$NWB#conferences-server_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=12111111111111 display the ADD NEW VICIDIAL CONFBRIDGE SCREEN
######################
if ($ADD==12111111111111)
	{
	if ($LOGast_admin_access==1)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_conferences.png\" alt=\"ConfBridges\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("ADD A NEW AGENT CONFBRIDGE")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=22111111111111>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("ConfBridge Number").": </td><td align=left><input type=text name=conf_exten size=8 maxlength=7> ("._QXZ("digits only").")$NWB#conferences-conf_exten$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Server IP").": </td><td align=left><select size=1 name=server_ip>\n";
		echo "$servers_list";
		echo "</select>$NWB#conferences-server_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}





######################################################################################################
######################################################################################################
#######   2 series, validates form data and inserts the new record into the database
######################################################################################################
######################################################################################################


######################
# ADD=2 adds the new user to the system
######################
if ($ADD=="2")
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_users' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$user = ($row[0] + 1);

			$stmt="UPDATE vicidial_override_ids SET value='$user' where id_table='vicidial_users' and active='1';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		##### END ID override optional section #####

		echo "<img src=\"images/icon_black_users.png\" alt=\"Users\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_users where user='$user';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("USER NOT ADDED - there is already a user in the system with this user number")."\n";}
		else
			{
			if (preg_match('/AUTOGENERA/',$user))
				{
				$user = 'AUTOGENERA';
				}
			if ( (strlen($user) < 2) or (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_group) < 2) or ( (mb_strlen($user,'utf-8') > 20) and (!preg_match('/AUTOGENERA/',$user)) ) or ( ($SSrequire_password_length > 0) and ($SSrequire_password_length > strlen($pass)) ) )
				{
				echo "<br>"._QXZ("USER NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("user id must be between 2 and 20 characters long")."\n";
				if ($SSrequire_password_length > 0)
					{
					echo "<br>"._QXZ("full name must be at least 2 characters long")."\n";
					echo "<br>"._QXZ("password must be at least $SSrequire_password_length characters long")."\n";
					}
				else
					{echo "<br>"._QXZ("full name and password must be at least 2 characters long")."\n";}
				echo "<br>"._QXZ("you must select a user group")."\n";
				}
			else
				{
				if (preg_match('/AUTOGENERA/',$user))
					{
					$new_user=0;
					$auto_user_add_value=0;
					while ($new_user < 2)
						{
						if ($new_user < 1)
							{
							$stmt = "SELECT auto_user_add_value FROM system_settings;";
							$rslt=mysql_to_mysqli($stmt, $link);
							$ss_auav_ct = mysqli_num_rows($rslt);
							if ($ss_auav_ct > 0)
								{
								$row=mysqli_fetch_row($rslt);
								$auto_user_add_value = $row[0];
								}
							$new_user++;
							}
						$stmt = "SELECT count(*) FROM vicidial_users where user='$auto_user_add_value';";
						$rslt=mysql_to_mysqli($stmt, $link);
						$row=mysqli_fetch_row($rslt);
						if ($row[0] < 1)
							{
							$new_user++;
							}
						else 
							{
							echo "<!-- AG: $auto_user_add_value -->\n";
							$auto_user_add_value = ($auto_user_add_value + 7);
							}
						}
					$user = $auto_user_add_value;
					echo "<br><B>user_id "._QXZ("has been auto-generated").": $user</B><br>\n";

					$stmt="UPDATE system_settings SET auto_user_add_value='$user';";
					$rslt=mysql_to_mysqli($stmt, $link);
					}

				$pass_hash='';
				if ($SSpass_hash_enabled > 0)
					{
					$pass = preg_replace("/\'|\"|\\\\|;|<|>| /","",$pass);
					$pass_hash = exec("../agc/bp.pl --pass=$pass");
					$pass_hash = preg_replace("/PHASH: |\n|\r|\t| /",'',$pass_hash);
					$pass='';
					}

				echo "<br><B>"._QXZ("USER ADDED").": $user</B>\n";

				$stmt="INSERT INTO vicidial_users (user,pass,full_name,user_level,user_group,phone_login,phone_pass,pass_hash) values('$user','$pass','$full_name','$user_level','$user_group','$phone_login','$phone_pass','$pass_hash');";
				$rslt=mysql_to_mysqli($stmt, $link);
				$affected_rows_user = mysqli_affected_rows($link);
				if ($DB) {echo "$affected_rows_user|$stmt|\n";}

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='ADD', record_id='$user', event_code='ADMIN ADD USER', event_sql=\"$SQL_log\", event_notes='user: $user inserts: $affected_rows_user';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);

				###############################################################
				##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP #####
				$stmt = "SELECT enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url FROM system_settings;";
				$rslt=mysql_to_mysqli($stmt, $link);
				if ($DB) {echo "$stmt\n";}
				$ss_conf_ct = mysqli_num_rows($rslt);
				if ($ss_conf_ct > 0)
					{
					$row=mysqli_fetch_row($rslt);
					$enable_vtiger_integration =	$row[0];
					$vtiger_server_ip	=			$row[1];
					$vtiger_dbname =				$row[2];
					$vtiger_login =					$row[3];
					$vtiger_pass =					$row[4];
					$vtiger_url =					$row[5];
					}
				##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP #####
				#############################################################

				if ($enable_vtiger_integration > 0)
					{
					### connect to your vtiger database

					#$linkV=mysql_connect("$vtiger_server_ip", "$vtiger_login","$vtiger_pass");
					#if (!$linkV) {die("Could not connect: $vtiger_server_ip|$vtiger_dbname|$vtiger_login|$vtiger_pass" . mysqli_error());}
					#echo 'Connected successfully';
					#mysql_select_db("$vtiger_dbname", $linkV);

					$linkV=mysqli_connect("$vtiger_server_ip", "$vtiger_login", "$vtiger_pass", "$vtiger_dbname");
					if (!$linkV) 
						{
						die('MySQL '._QXZ("connect ERROR").': ' . mysqli_connect_error());
						}

					$user_name =		$user;
					$user_password =	$pass;
					$last_name =		$full_name;
					$is_admin =			'off';
					$roleid =			'H5';
					$status =			'Active';
					$groupid =			'1';
						if ($user_level >= 7) {$roleid = 'H3';}
						if ($user_level >= 8) {$roleid = 'H4';}
						if ($user_level >= 9) {$roleid = 'H2';}
						if ($user_level >= 9) {$is_admin = 'on';}
					$salt = substr($user_name, 0, 2);
					$salt = '$1$' . $salt . '$';
					$encrypted_password = crypt($user_password, $salt);
					### search for role in ViciDial
					$stmt = "SELECT vtiger_role FROM vtiger_vicidial_roles where user_level='$user_level';";
					$rslt=mysql_to_mysqli($stmt, $link);
					if ($DB) {echo "$stmt\n";}
					$vvr_ct = mysqli_num_rows($rslt);
					if ($vvr_ct > 0)
						{
						$row=mysqli_fetch_row($rslt);
						$roleid =	$row[0];
						}

					######################################
					##### BEGIN Add/Update group info in Vtiger
					$stmt="SELECT count(*) from vtiger_groups where groupname='$user_group';";
					$rslt=mysql_to_mysqli($stmt, $linkV);
					if ($DB) {echo "$stmt\n";}
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
					$row=mysqli_fetch_row($rslt);
					$group_found_count = $row[0];

					### group exists in vtiger, update it
					if ($group_found_count > 0)
						{
						$stmt="SELECT groupid from vtiger_groups where groupname='$user_group';";
						$rslt=mysql_to_mysqli($stmt, $linkV);
						if ($DB) {echo "$stmt\n";}
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
						$row=mysqli_fetch_row($rslt);
						$groupid = $row[0];
						}

					### user doesn't exist in vtiger, insert it
					else
						{
						#### BEGIN CREATE NEW GROUP RECORD IN VTIGER
						# Get next available id from vtiger_users_seq to use as groupid
						$stmt="SELECT id from vtiger_users_seq;";
						if ($DB) {echo "$stmt\n";}
						$rslt=mysql_to_mysqli($stmt, $linkV);
						$row=mysqli_fetch_row($rslt);
						$groupid = ($row[0] + 1);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						# Increase next available groupid with 1 so next record gets proper id
						$stmt="UPDATE vtiger_users_seq SET id = '$groupid';";
						if ($DB) {echo "$stmt\n";}
						$rslt=mysql_to_mysqli($stmt, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						$stmtA = "INSERT INTO vtiger_groups SET groupid='$groupid',groupname='$user_group',description='';";
						if ($DB) {echo "|$stmtA|\n";}
						$rslt=mysql_to_mysqli($stmtA, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						#### END CREATE NEW GROUP RECORD IN VTIGER
						}
					##### END Add/Update group info in Vtiger
					######################################

					######################################
					##### BEGIN Add/Update user info in Vtiger
					$stmt="SELECT count(*) from vtiger_users where user_name='$user_name';";
					$rslt=mysql_to_mysqli($stmt, $linkV);
					if ($DB) {echo "$stmt\n";}
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
					$row=mysqli_fetch_row($rslt);
					$found_count = $row[0];

					### user exists in vtiger, update it
					if ($found_count > 0)
						{
						$stmt="SELECT id from vtiger_users where user_name='$user_name';";
						$rslt=mysql_to_mysqli($stmt, $linkV);
						if ($DB) {echo "$stmt\n";}
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
						$row=mysqli_fetch_row($rslt);
						$userid = $row[0];

						$stmt="SELECT count(*) from vtiger_users2group WHERE userid='$userid' and groupid='$groupid';";
						$rslt=mysql_to_mysqli($stmt, $linkV);
						if ($DB) {echo "$stmt\n";}
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
						$row=mysqli_fetch_row($rslt);
						$usergroupcount = $row[0];

						$stmtA = "UPDATE vtiger_users SET user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status' where id='$userid';";
						if ($DB) {echo "|$stmtA|\n";}
						$rslt=mysql_to_mysqli($stmtA, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						$stmtB = "UPDATE vtiger_user2role SET roleid='$roleid' where userid='$userid';";
						if ($DB) {echo "|$stmtB|\n";}
						$rslt=mysql_to_mysqli($stmtB, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						if ($usergroupcount < 1)
							{
							$stmt="SELECT user_group FROM vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;";
							$rslt=mysql_to_mysqli($stmt, $link);
							if ($DB) {echo "$stmt\n";}
							$VD_groups_ct = mysqli_num_rows($rslt);
							$k=0;
							$VD_groups_list='';
							while ($k < $VD_groups_ct)
								{
								$row=mysqli_fetch_row($rslt);
								$VD_groups_list .= "'$row[0]',";
								$k++;
								}
							$VD_groups_list = preg_replace("/.$/",'',$VD_groups_list);

							$stmtC = "DELETE FROM vtiger_users2group WHERE userid='$userid' and groupid IN(SELECT groupid from vtiger_groups where groupname IN($VD_groups_list));";
							if ($DB) {echo "|$stmtC|\n";}
							$rslt=mysql_to_mysqli($stmtC, $linkV);
							if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

							$stmtD = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';";
							if ($DB) {echo "|$stmtD|\n";}
							$rslt=mysql_to_mysqli($stmtD, $linkV);
							if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
							}
						}

					### user doesn't exist in vtiger, insert it
					else
						{
						#### BEGIN CREATE NEW USER RECORD IN VTIGER
						$stmtA = "INSERT INTO vtiger_users SET user_name='$user_name',user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status',date_format='yyyy-mm-dd',first_name='',reports_to_id='',description='',title='',department='',phone_home='',phone_mobile='',phone_work='',phone_other='',phone_fax='',email1='',email2='',yahoo_id='',signature='',address_street='',address_city='',address_state='',address_country='',address_postalcode='',user_preferences='',imagename='';";
						if ($DB) {echo "|$stmtA|\n";}
						$rslt=mysql_to_mysqli($stmtA, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
						$userid = mysqli_insert_id($linkV);
					
						$stmtB = "INSERT INTO vtiger_user2role SET userid='$userid',roleid='$roleid';";
						if ($DB) {echo "|$stmtB|\n";}
						$rslt=mysql_to_mysqli($stmtB, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						$stmtC = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';";
						if ($DB) {echo "|$stmtC|\n";}
						$rslt=mysql_to_mysqli($stmtC, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						$stmtD = "UPDATE vtiger_users_seq SET id='$userid';";
						if ($DB) {echo "|$stmtD|\n";}
						$rslt=mysql_to_mysqli($stmtD, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						#### END CREATE NEW USER RECORD IN VTIGER
						}
					##### END Add/Update user info in Vtiger
					######################################
					}
				### END vtiger integration
				}
			}
		}
	$ADD=3;
	}


######################
# ADD=2A adds the copied new user to the system
######################
if ($ADD=="2A")
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_users' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$user = ($row[0] + 1);

			$stmt="UPDATE vicidial_override_ids SET value='$user' where id_table='vicidial_users' and active='1';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		##### END ID override optional section #####

		echo "<img src=\"images/icon_black_users.png\" alt=\"Users\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_users where user='$user';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("USER NOT ADDED - there is already a user in the system with this user number")."\n";}
		else
			{
			if ( (strlen($user) < 2) or (strlen($pass) < 2) or (strlen($full_name) < 2) or (mb_strlen($user,'utf-8') > 20) or ( ($SSrequire_password_length > 0) and ($SSrequire_password_length > strlen($pass)) ) )
				{
				echo "<br>"._QXZ("USER NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("user id must be between 2 and 20 characters long")."\n";
				if ($SSrequire_password_length > 0)
					{
					echo "<br>"._QXZ("full name must be at least 2 characters long")."\n";
					echo "<br>"._QXZ("password must be at least $SSrequire_password_length characters long")."\n";
					}
				else
					{echo "<br>"._QXZ("full name and password must be at least 2 characters long")."\n";}
				echo "<!-- |$user|$pass|$full_name| -->\n";
				}
			else
				{
				if (preg_match('/AUTOGEN/',$user))
					{
					$new_user=0;
					$auto_user_add_value=0;
					while ($new_user < 2)
						{
						if ($new_user < 1)
							{
							$stmt = "SELECT auto_user_add_value FROM system_settings;";
							$rslt=mysql_to_mysqli($stmt, $link);
							$ss_auav_ct = mysqli_num_rows($rslt);
							if ($ss_auav_ct > 0)
								{
								$row=mysqli_fetch_row($rslt);
								$auto_user_add_value = $row[0];
								}
							$new_user++;
							}
						$stmt = "SELECT count(*) FROM vicidial_users where user='$auto_user_add_value';";
						$rslt=mysql_to_mysqli($stmt, $link);
						$row=mysqli_fetch_row($rslt);
						if ($row[0] < 1)
							{
							$new_user++;
							}
						else 
							{
							echo "<!-- AG: $auto_user_add_value -->\n";
							$auto_user_add_value = ($auto_user_add_value + 7);
							}
						}
					$user = $auto_user_add_value;
					echo "<br><B>user_id "._QXZ("has been auto-generated").": $user</B><br>\n";

					$stmt="UPDATE system_settings SET auto_user_add_value='$user';";
					$rslt=mysql_to_mysqli($stmt, $link);
					}

				$pass_hash='';
				if ($SSpass_hash_enabled > 0)
					{
					$pass = preg_replace("/\'|\"|\\\\|;|<|>| /","",$pass);
					$pass_hash = exec("../agc/bp.pl --pass=$pass");
					$pass_hash = preg_replace("/PHASH: |\n|\r|\t| /",'',$pass_hash);
					$pass='';
					}

				$stmt="INSERT INTO vicidial_users (user,pass,full_name,user_level,user_group,phone_login,phone_pass,delete_users,delete_user_groups,delete_lists,delete_campaigns,delete_ingroups,delete_remote_agents,load_leads,campaign_detail,ast_admin_access,ast_delete_phones,delete_scripts,modify_leads,hotkeys_active,change_agent_campaign,agent_choose_ingroups,closer_campaigns,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,delete_filters,alter_agent_interface_options,closer_default_blended,delete_call_times,modify_call_times,modify_users,modify_campaigns,modify_lists,modify_scripts,modify_filters,modify_ingroups,modify_usergroups,modify_remoteagents,modify_servers,view_reports,vicidial_recording_override,alter_custdata_override,qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit,add_timeclock_log,modify_timeclock_log,delete_timeclock_log,alter_custphone_override,vdc_agent_api_access,modify_inbound_dids,delete_inbound_dids,active,alert_enabled,download_lists,agent_shift_enforcement_override,manager_shift_enforcement_override,export_reports,delete_from_dnc,email,user_code,territory,allow_alerts,agent_choose_territories,custom_one,custom_two,custom_three,custom_four,custom_five,voicemail_id,agent_call_log_view_override,callcard_admin,agent_choose_blended,realtime_block_user_info,custom_fields_modify,force_change_password,agent_lead_search_override,modify_shifts,modify_phones,modify_carriers,modify_labels,modify_statuses,modify_voicemail,modify_audiostore,modify_moh,modify_tts,preset_contact_search,modify_contacts,modify_same_user_level,admin_hide_lead_data,admin_hide_phone_data,agentcall_email,agentcall_chat,modify_email_accounts,pass_hash,alter_admin_interface_options,max_inbound_calls,modify_custom_dialplans,wrapup_seconds_override,modify_languages,selected_language,user_choose_language,ignore_group_on_search,api_list_restrict,api_allowed_functions,lead_filter_id,admin_cf_show_hidden,user_hide_realtime,modify_colors,user_nickname,user_new_lead_limit,api_only_user,modify_auto_reports,modify_ip_lists,ignore_ip_list,ready_max_logout,export_gdpr_leads,access_recordings,pause_code_approval,max_hopper_calls,max_hopper_calls_hour,mute_recordings,hide_call_log_info,next_dial_my_callbacks,user_admin_redirect_url,max_inbound_filter_enabled,max_inbound_filter_statuses,max_inbound_filter_ingroups,max_inbound_filter_min_sec,status_group_id,mobile_number,two_factor_override,manual_dial_filter,user_location,download_invalid_files,user_group_two,modify_dial_prefix,inbound_credits,hci_enabled,manual_dial_lead_id) SELECT \"$user\",\"$pass\",\"$full_name\",user_level,user_group,phone_login,phone_pass,delete_users,delete_user_groups,delete_lists,delete_campaigns,delete_ingroups,delete_remote_agents,load_leads,campaign_detail,ast_admin_access,ast_delete_phones,delete_scripts,modify_leads,hotkeys_active,change_agent_campaign,agent_choose_ingroups,closer_campaigns,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,delete_filters,alter_agent_interface_options,closer_default_blended,delete_call_times,modify_call_times,modify_users,modify_campaigns,modify_lists,modify_scripts,modify_filters,modify_ingroups,modify_usergroups,modify_remoteagents,modify_servers,view_reports,vicidial_recording_override,alter_custdata_override,qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit,add_timeclock_log,modify_timeclock_log,delete_timeclock_log,alter_custphone_override,vdc_agent_api_access,modify_inbound_dids,delete_inbound_dids,active,alert_enabled,download_lists,agent_shift_enforcement_override,manager_shift_enforcement_override,export_reports,delete_from_dnc,email,user_code,territory,allow_alerts,agent_choose_territories,custom_one,custom_two,custom_three,custom_four,custom_five,voicemail_id,agent_call_log_view_override,callcard_admin,agent_choose_blended,realtime_block_user_info,custom_fields_modify,force_change_password,agent_lead_search_override,modify_shifts,modify_phones,modify_carriers,modify_labels,modify_statuses,modify_voicemail,modify_audiostore,modify_moh,modify_tts,preset_contact_search,modify_contacts,modify_same_user_level,admin_hide_lead_data,admin_hide_phone_data,agentcall_email,agentcall_chat,modify_email_accounts,\"$pass_hash\",alter_admin_interface_options,max_inbound_calls,modify_custom_dialplans,wrapup_seconds_override,modify_languages,selected_language,user_choose_language,ignore_group_on_search,api_list_restrict,api_allowed_functions,lead_filter_id,admin_cf_show_hidden,user_hide_realtime,modify_colors,user_nickname,user_new_lead_limit,api_only_user,modify_auto_reports,modify_ip_lists,ignore_ip_list,ready_max_logout,export_gdpr_leads,access_recordings,pause_code_approval,max_hopper_calls,max_hopper_calls_hour,mute_recordings,hide_call_log_info,next_dial_my_callbacks,user_admin_redirect_url,max_inbound_filter_enabled,max_inbound_filter_statuses,max_inbound_filter_ingroups,max_inbound_filter_min_sec,status_group_id,mobile_number,two_factor_override,manual_dial_filter,user_location,download_invalid_files,user_group_two,modify_dial_prefix,inbound_credits,hci_enabled,manual_dial_lead_id from vicidial_users where user=\"$source_user_id\";";
				$rslt=mysql_to_mysqli($stmt, $link);

				$stmtA="INSERT INTO vicidial_inbound_group_agents (user,group_id,group_rank,group_weight,calls_today,group_type,daily_limit) SELECT \"$user\",group_id,group_rank,group_weight,\"0\",group_type,daily_limit from vicidial_inbound_group_agents where user=\"$source_user_id\";";
				$rslt=mysql_to_mysqli($stmtA, $link);

				$stmtB="INSERT INTO vicidial_campaign_agents (user,campaign_id,campaign_rank,campaign_weight,calls_today) SELECT \"$user\",campaign_id,campaign_rank,campaign_weight,\"0\" from vicidial_campaign_agents where user=\"$source_user_id\";";
				$rslt=mysql_to_mysqli($stmtB, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtA|$stmtB|";
				$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='COPY', record_id='$user', event_code='ADMIN COPY USER', event_sql=\"$SQL_log\", event_notes='user: $user';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);

				###############################################################
				##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP #####
				$stmt = "SELECT enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url FROM system_settings;";
				$rslt=mysql_to_mysqli($stmt, $link);
				if ($DB) {echo "$stmt\n";}
				$ss_conf_ct = mysqli_num_rows($rslt);
				if ($ss_conf_ct > 0)
					{
					$row=mysqli_fetch_row($rslt);
					$enable_vtiger_integration =	$row[0];
					$vtiger_server_ip	=			$row[1];
					$vtiger_dbname =				$row[2];
					$vtiger_login =					$row[3];
					$vtiger_pass =					$row[4];
					$vtiger_url =					$row[5];
					}
				##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP #####
				#############################################################

				if ($enable_vtiger_integration > 0)
					{
					### connect to your vtiger database
					#$linkV=mysql_connect("$vtiger_server_ip", "$vtiger_login","$vtiger_pass");
					#if (!$linkV) {die("Could not connect: $vtiger_server_ip|$vtiger_dbname|$vtiger_login|$vtiger_pass" . mysqli_error());}
					#echo 'Connected successfully';
					#mysql_select_db("$vtiger_dbname", $linkV);
					$linkV=mysqli_connect("$vtiger_server_ip", "$vtiger_login", "$vtiger_pass", "$vtiger_dbname");
					if (!$linkV) 
						{
						die('MySQL '._QXZ("connect ERROR").': ' . mysqli_connect_error());
						}

					$user_name =		$user;
					$user_password =	$pass;
					$last_name =		$full_name;
					$is_admin =			'off';
					$roleid =			'H5';
					$status =			'Active';
					$groupid =			'1';
						if ($user_level >= 7) {$roleid = 'H3';}
						if ($user_level >= 8) {$roleid = 'H4';}
						if ($user_level >= 9) {$roleid = 'H2';}
						if ($user_level >= 9) {$is_admin = 'on';}
					$salt = substr($user_name, 0, 2);
					$salt = '$1$' . $salt . '$';
					$encrypted_password = crypt($user_password, $salt);
					### search for role in ViciDial
					$stmt = "SELECT vtiger_role FROM vtiger_vicidial_roles where user_level='$user_level';";
					$rslt=mysql_to_mysqli($stmt, $link);
					if ($DB) {echo "$stmt\n";}
					$vvr_ct = mysqli_num_rows($rslt);
					if ($vvr_ct > 0)
						{
						$row=mysqli_fetch_row($rslt);
						$roleid =	$row[0];
						}

					######################################
					##### BEGIN Add/Update group info in Vtiger
					$stmt="SELECT count(*) from vtiger_groups where groupname='$user_group';";
					$rslt=mysql_to_mysqli($stmt, $linkV);
					if ($DB) {echo "$stmt\n";}
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
					$row=mysqli_fetch_row($rslt);
					$group_found_count = $row[0];

					### group exists in vtiger, update it
					if ($group_found_count > 0)
						{
						$stmt="SELECT groupid from vtiger_groups where groupname='$user_group';";
						$rslt=mysql_to_mysqli($stmt, $linkV);
						if ($DB) {echo "$stmt\n";}
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
						$row=mysqli_fetch_row($rslt);
						$groupid = $row[0];
						}

					### user doesn't exist in vtiger, insert it
					else
						{
						#### BEGIN CREATE NEW GROUP RECORD IN VTIGER
						# Get next available id from vtiger_users_seq to use as groupid
						$stmt="SELECT id from vtiger_users_seq;";
						if ($DB) {echo "$stmt\n";}
						$rslt=mysql_to_mysqli($stmt, $linkV);
						$row=mysqli_fetch_row($rslt);
						$groupid = ($row[0] + 1);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						# Increase next available groupid with 1 so next record gets proper id
						$stmt="UPDATE vtiger_users_seq SET id = '$groupid';";
						if ($DB) {echo "$stmt\n";}
						$rslt=mysql_to_mysqli($stmt, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						$stmtA = "INSERT INTO vtiger_groups SET groupid='$groupid',groupname='$user_group',description='';";
						if ($DB) {echo "|$stmtA|\n";}
						$rslt=mysql_to_mysqli($stmtA, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						#### END CREATE NEW GROUP RECORD IN VTIGER
						}
					##### END Add/Update group info in Vtiger
					######################################

					######################################
					##### BEGIN Add/Update user info in Vtiger
					$stmt="SELECT count(*) from vtiger_users where user_name='$user_name';";
					$rslt=mysql_to_mysqli($stmt, $linkV);
					if ($DB) {echo "$stmt\n";}
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
					$row=mysqli_fetch_row($rslt);
					$found_count = $row[0];

					### user exists in vtiger, update it
					if ($found_count > 0)
						{
						$stmt="SELECT id from vtiger_users where user_name='$user_name';";
						$rslt=mysql_to_mysqli($stmt, $linkV);
						if ($DB) {echo "$stmt\n";}
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
						$row=mysqli_fetch_row($rslt);
						$userid = $row[0];

						$stmt="SELECT count(*) from vtiger_users2group WHERE userid='$userid' and groupid='$groupid';";
						$rslt=mysql_to_mysqli($stmt, $linkV);
						if ($DB) {echo "$stmt\n";}
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
						$row=mysqli_fetch_row($rslt);
						$usergroupcount = $row[0];

						$stmtA = "UPDATE vtiger_users SET user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status' where id='$userid';";
						if ($DB) {echo "|$stmtA|\n";}
						$rslt=mysql_to_mysqli($stmtA, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						$stmtB = "UPDATE vtiger_user2role SET roleid='$roleid' where userid='$userid';";
						if ($DB) {echo "|$stmtB|\n";}
						$rslt=mysql_to_mysqli($stmtB, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						if ($usergroupcount < 1)
							{
							$stmt="SELECT user_group FROM vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;";
							$rslt=mysql_to_mysqli($stmt, $link);
							if ($DB) {echo "$stmt\n";}
							$VD_groups_ct = mysqli_num_rows($rslt);
							$k=0;
							$VD_groups_list='';
							while ($k < $VD_groups_ct)
								{
								$row=mysqli_fetch_row($rslt);
								$VD_groups_list .= "'$row[0]',";
								$k++;
								}
							$VD_groups_list = preg_replace("/.$/",'',$VD_groups_list);

							$stmtC = "DELETE FROM vtiger_users2group WHERE userid='$userid' and groupid IN(SELECT groupid from vtiger_groups where groupname IN($VD_groups_list));";
							if ($DB) {echo "|$stmtC|\n";}
							$rslt=mysql_to_mysqli($stmtC, $linkV);
							if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

							$stmtD = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';";
							if ($DB) {echo "|$stmtD|\n";}
							$rslt=mysql_to_mysqli($stmtD, $linkV);
							if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
							}
						}

					### user doesn't exist in vtiger, insert it
					else
						{
						#### BEGIN CREATE NEW USER RECORD IN VTIGER
						$stmtA = "INSERT INTO vtiger_users SET user_name='$user_name',user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status',date_format='yyyy-mm-dd',first_name='',reports_to_id='',description='',title='',department='',phone_home='',phone_mobile='',phone_work='',phone_other='',phone_fax='',email1='',email2='',yahoo_id='',signature='',address_street='',address_city='',address_state='',address_country='',address_postalcode='',user_preferences='',imagename='';";
						if ($DB) {echo "|$stmtA|\n";}
						$rslt=mysql_to_mysqli($stmtA, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
						$userid = mysqli_insert_id($linkV);
					
						$stmtB = "INSERT INTO vtiger_user2role SET userid='$userid',roleid='$roleid';";
						if ($DB) {echo "|$stmtB|\n";}
						$rslt=mysql_to_mysqli($stmtB, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						$stmtC = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';";
						if ($DB) {echo "|$stmtC|\n";}
						$rslt=mysql_to_mysqli($stmtC, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						$stmtD = "UPDATE vtiger_users_seq SET id='$userid';";
						if ($DB) {echo "|$stmtD|\n";}
						$rslt=mysql_to_mysqli($stmtD, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						#### END CREATE NEW USER RECORD IN VTIGER
						}
					##### END Add/Update user info in Vtiger
					######################################
					}
				### END vtiger integration

				echo "<br><B>"._QXZ("USER COPIED").": $user "._QXZ("copied from")." $source_user_id</B>\n";
				echo "<br><br>\n";
				echo "<a href=\"$PHP_SELF?ADD=3&user=$user\">"._QXZ("Click here to go to the user record")."</a>\n";
				echo "<br><br>\n";
				}
			}
		}
	exit;
	}


######################
# ADD=21 adds the new campaign to the system
######################
if ($ADD==21)
	{
	$campaign_id = preg_replace("/\-/",'',$campaign_id);
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_campaigns' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$campaign_id = ($row[0] + 1);

			$stmt="UPDATE vicidial_override_ids SET value='$campaign_id' where id_table='vicidial_campaigns' and active='1';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		##### END ID override optional section #####

		echo "<img src=\"images/icon_black_campaigns.png\" alt=\"Campaigns\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("CAMPAIGN NOT ADDED - there is already a campaign in the system with this ID")."\n";}
		else
			{
			$stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$campaign_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] > 0)
				{echo "<br>"._QXZ("CAMPAIGN NOT ADDED - there is already an inbound group in the system with this ID")."\n";}
			else
				{
				$stmt="SELECT count(*) from vicidial_status_groups where status_group_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				if ($row[0] > 0)
					{echo "<br>"._QXZ("CAMPAIGN NOT ADDED - there is already a status group in the system with this ID")."\n";}
				else
					{
					if ( (strlen($campaign_id) < 2) or (mb_strlen($campaign_id,'utf-8') > 8) or (strlen($campaign_name) < 6)  or (mb_strlen($campaign_name,'utf-8') > 40) )
						{
						echo "<br>"._QXZ("CAMPAIGN NOT ADDED - Please go back and look at the data you entered")."\n";
						echo "<br>"._QXZ("campaign ID must be between 2 and 8 characters in length")."\n";
						echo "<br>"._QXZ("campaign name must be between 6 and 40 characters in length")."\n";
						}
					else
						{
						echo "<br><B>"._QXZ("CAMPAIGN ADDED").": $campaign_id</B>\n";

						# if admin user's user group does not have -ALL-CAMPAIGNS- then add this new campaign to their user group's allowable campaigns
						if ( (!preg_match('/\-ALL/i', $LOGallowed_campaigns)) )
							{
							$UPDATEallowed_campaigns =	$LOGallowed_campaigns;
							$UPDATEallowed_campaigns = preg_replace("/ -$/"," $campaign_id -",$UPDATEallowed_campaigns);
							$LOGallowed_campaigns = $UPDATEallowed_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 ";
							$stmt="UPDATE vicidial_user_groups SET allowed_campaigns='$UPDATEallowed_campaigns' where user_group='$LOGuser_group';";
							$rslt=mysql_to_mysqli($stmt, $link);
							}

						$stmt="INSERT INTO vicidial_campaigns (campaign_id,campaign_name,campaign_description,active,dial_status_a,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,campaign_script,get_call_launch,campaign_changedate,campaign_stats_refresh,list_order_mix,web_form_address_two,start_call_url,dispo_call_url,na_call_url,user_group,web_form_address_three,campaign_script_two,survey_first_audio_file,survey_ni_audio_file,survey_opt_in_audio_file,survey_third_audio_file,survey_fourth_audio_file,agent_hangup_value) values('$campaign_id','$campaign_name','$campaign_description','$active','NEW','DOWN','$park_ext','$park_file_name','" . mysqli_real_escape_string($link, $web_form_address) . "','$allow_closers','$hopper_level','$auto_dial_level','$next_agent_call','$local_call_time','$voicemail_ext','$script_id','$get_call_launch','$SQLdate','Y','DISABLED','','','','','$user_group','','$campaign_script_two','US_pol_survey_hello','US_thanks_no_contact','US_pol_survey_transfer','US_thanks_no_contact','US_thanks_no_contact','');";
						$rslt=mysql_to_mysqli($stmt, $link);

						$stmtA="INSERT INTO vicidial_campaign_stats (campaign_id) values('$campaign_id');";
						$rslt=mysql_to_mysqli($stmtA, $link);

						$stmtB="INSERT INTO vicidial_campaign_stats_debug (campaign_id) values('$campaign_id');";
						$rslt=mysql_to_mysqli($stmtB, $link);

						### LOG INSERTION Admin Log Table ###
						$SQL_log = "$stmt|$stmtA|$stmtB|";
						$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='CAMPAIGNS', event_type='ADD', record_id='$campaign_id', event_code='ADMIN ADD CAMPAIGN', event_sql=\"$SQL_log\", event_notes='';";
						if ($DB) {echo "|$stmt|\n";}
						$rslt=mysql_to_mysqli($stmt, $link);
						}
					}
				}
			}
		}
	$ADD=31;
	}


######################
# ADD=20 adds copied new campaign to the system
######################
if ($ADD==20)
	{
	$campaign_id = preg_replace("/\-/",'',$campaign_id);
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_campaigns' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$campaign_id = ($row[0] + 1);

			$stmt="UPDATE vicidial_override_ids SET value='$campaign_id' where id_table='vicidial_campaigns' and active='1';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		##### END ID override optional section #####

		echo "<img src=\"images/icon_black_campaigns.png\" alt=\"Campaigns\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("CAMPAIGN NOT ADDED - there is already a campaign in the system with this ID")."\n";}
		else
			{
			$stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$campaign_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] > 0)
				{echo "<br>"._QXZ("CAMPAIGN NOT ADDED - there is already an inbound group in the system with this ID")."\n";}
			else
				{
				$stmt="SELECT count(*) from vicidial_status_groups where status_group_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				if ($row[0] > 0)
					{echo "<br>"._QXZ("CAMPAIGN NOT ADDED - there is already a status group in the system with this ID")."\n";}
				else
					{
					if ( (strlen($campaign_id) < 2) or (mb_strlen($campaign_id,'utf-8') > 8) or  (strlen($campaign_name) < 6) or (strlen($source_campaign_id) < 2) or (mb_strlen($source_campaign_id,'utf-8') > 8) )
						{
						echo "<br>"._QXZ("CAMPAIGN NOT ADDED - Please go back and look at the data you entered")."\n";
						echo "<br>"._QXZ("campaign ID must be between 2 and 8 characters in length")."\n";
						echo "<br>"._QXZ("source campaign ID must be between 2 and 8 characters in length")."\n";
						}
					else
						{
						echo "<br><B>"._QXZ("CAMPAIGN COPIED").": $campaign_id "._QXZ("copied from")." $source_campaign_id</B>\n";

						# if admin user's user group does not have -ALL-CAMPAIGNS- then add this new campaign to their user group's allowable campaigns
						if ( (!preg_match('/\-ALL/i', $LOGallowed_campaigns)) )
							{
							$UPDATEallowed_campaigns =	$LOGallowed_campaigns;
							$UPDATEallowed_campaigns = preg_replace("/ -$/"," $campaign_id -",$UPDATEallowed_campaigns);
							$LOGallowed_campaigns = $UPDATEallowed_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 ";
							$stmtX="UPDATE vicidial_user_groups SET allowed_campaigns='$UPDATEallowed_campaigns' where user_group='$LOGuser_group';";
							$rslt=mysql_to_mysqli($stmtX, $link);
							}

						$stmt="INSERT INTO vicidial_campaigns (campaign_name,campaign_id,active,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,list_order_mix,campaign_allow_inbound,manual_dial_list_id,default_xfer_group,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,qc_get_record_launch,qc_show_recording,qc_shift_id,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_fourth_digit,survey_third_audio_file,survey_fourth_audio_file,survey_third_status,survey_fourth_status,survey_third_exten,survey_fourth_exten,drop_lockout_time,quick_transfer_button,prepopulate_transfer_preset,drop_rate_group,view_calls_in_queue,view_calls_in_queue_launch,grab_calls_in_queue,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,waitforsilence_options,agent_select_territories,crm_popup_login,crm_login_address,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,use_custom_cid,scheduled_callbacks_alert,queuemetrics_callstatus_override,extension_appended_cidname,scheduled_callbacks_count,manual_dial_override,blind_monitor_warning,blind_monitor_message,blind_monitor_filename,inbound_queue_no_dial,timer_action_destination,enable_xfer_presets,hide_xfer_number_to_dial,manual_dial_prefix,customer_3way_hangup_logging,customer_3way_hangup_seconds,customer_3way_hangup_action,ivr_park_call,ivr_park_call_agi,manual_preview_dial,realtime_agent_time_stats,use_auto_hopper,auto_hopper_multi,auto_trim_hopper,api_manual_dial,manual_dial_call_time_check,display_leads_count,lead_order_randomize,lead_order_secondary,per_call_notes,my_callback_option,agent_lead_search,agent_lead_search_method,queuemetrics_phone_environment,auto_pause_precall,auto_resume_precall,auto_pause_precall_code,manual_dial_cid,post_phone_time_diff_alert,custom_3way_button_transfer,available_only_tally_threshold,available_only_tally_threshold_agents,dial_level_threshold,dial_level_threshold_agents,safe_harbor_audio,safe_harbor_menu_id,survey_menu_id,callback_days_limit,dl_diff_target_method,disable_dispo_screen,disable_dispo_status,screen_labels,status_display_fields,na_call_url,survey_recording,pllb_grouping,pllb_grouping_limit,call_count_limit,call_count_target,callback_hours_block,callback_list_calltime,user_group,hopper_vlc_dup_check,safe_harbor_audio_field,pause_after_next_call,owner_populate,use_other_campaign_dnc,allow_emails,allow_chats,amd_inbound_group,amd_callmenu,survey_wait_sec,manual_dial_lead_id,dead_max,dispo_max,pause_max,dead_max_dispo,dispo_max_dispo,max_inbound_calls,manual_dial_search_checkbox,hide_call_log_info,timer_alt_seconds,wrapup_bypass,wrapup_after_hotkey,callback_active_limit,callback_active_limit_override,comments_all_tabs,comments_dispo_screen,comments_callback_screen,qc_comment_history,show_previous_callback,clear_script,cpd_unknown_action,manual_dial_search_filter,web_form_address_three,manual_dial_override_field,status_display_ingroup,customer_gone_seconds,agent_display_fields,am_message_wildcards,manual_dial_timeout,routing_initiated_recordings,manual_dial_hopper_check,callback_useronly_move_minutes,ofcom_uk_drop_calc,manual_auto_next,manual_auto_show,allow_required_fields,dead_to_dispo,agent_xfer_validation,ready_max_logout,callback_display_days,three_way_record_stop,hangup_xfer_record_start,scheduled_callbacks_email_alert,max_inbound_calls_outcome,manual_auto_next_options,agent_screen_time_display,next_dial_my_callbacks,inbound_no_agents_no_dial_container,inbound_no_agents_no_dial_threshold,cid_group_id,pause_max_dispo,script_top_dispo,dead_trigger_seconds,dead_trigger_action,dead_trigger_repeat,dead_trigger_filename,dead_trigger_url,scheduled_callbacks_force_dial,scheduled_callbacks_auto_reschedule,scheduled_callbacks_timezones_container,three_way_volume_buttons,callback_dnc,manual_dial_validation,mute_recordings,auto_active_list_new,call_quota_lead_ranking,sip_event_logging,campaign_script_two,leave_vm_no_dispo,leave_vm_message_group_id,dial_timeout_lead_container,amd_type,vmm_daily_limit,opensips_cid_name,amd_agent_route_options,browser_alert_sound,browser_alert_volume,three_way_record_stop_exception,in_group_dial,pause_max_exceptions,hopper_drop_run_trigger,daily_call_count_limit,daily_limit_manual,transfer_button_launch,shared_dial_rank,agent_search_method,qc_scorecard_id,qc_statuses_id,clear_form,leave_3way_start_recording,leave_3way_start_recording_exception,calls_waiting_vl_one,calls_waiting_vl_two,calls_inqueue_count_one,calls_inqueue_count_two,in_man_dial_next_ready_seconds,in_man_dial_next_ready_seconds_override,transfer_no_dispo,call_limit_24hour_method,call_limit_24hour_scope,call_limit_24hour,call_limit_24hour_override,cid_group_id_two,incall_tally_threshold_seconds,auto_alt_threshold,pause_max_url,agent_hide_hangup,ig_xfer_list_sort,script_tab_frame_size,max_logged_in_agents,user_group_script,agent_hangup_route,agent_hangup_value,agent_hangup_ig_override,show_confetti,demographic_quotas,demographic_quotas_container,demographic_quotas_rerank,demographic_quotas_list_resets,custom_one,custom_two,custom_three,custom_four,custom_five,dead_stop_recording,manual_vm_status_updates,force_per_call_notes,agent_search_ingroup_list,hopper_hold_inserts,daily_phone_number_call_limit,state_descriptions,script_tab_height,call_log_days,leave_3way_stop_recording,manual_minimum_ring_seconds,manual_minimum_attempt_seconds,manual_minimum_answer_seconds,khomp_settings_container,stereo_recording,stereo_rec_filename,stereo_parallel_recording,recording_dtmf_muting,stereo_recording_agent,parallel_rec_co_filename,parallel_rec_cm_filename,parallel_rec_fr_filename,call_count_limit_restrict) SELECT \"$campaign_name\",\"$campaign_id\",\"N\",dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,\"DISABLED\",campaign_allow_inbound,manual_dial_list_id,default_xfer_group,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,qc_get_record_launch,qc_show_recording,qc_shift_id,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_fourth_digit,survey_third_audio_file,survey_fourth_audio_file,survey_third_status,survey_fourth_status,survey_third_exten,survey_fourth_exten,drop_lockout_time,quick_transfer_button,prepopulate_transfer_preset,drop_rate_group,view_calls_in_queue,view_calls_in_queue_launch,grab_calls_in_queue,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,waitforsilence_options,agent_select_territories,crm_popup_login,crm_login_address,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,use_custom_cid,scheduled_callbacks_alert,queuemetrics_callstatus_override,extension_appended_cidname,scheduled_callbacks_count,manual_dial_override,blind_monitor_warning,blind_monitor_message,blind_monitor_filename,inbound_queue_no_dial,timer_action_destination,enable_xfer_presets,hide_xfer_number_to_dial,manual_dial_prefix,customer_3way_hangup_logging,customer_3way_hangup_seconds,customer_3way_hangup_action,ivr_park_call,ivr_park_call_agi,manual_preview_dial,realtime_agent_time_stats,use_auto_hopper,auto_hopper_multi,auto_trim_hopper,api_manual_dial,manual_dial_call_time_check,display_leads_count,lead_order_randomize,lead_order_secondary,per_call_notes,my_callback_option,agent_lead_search,agent_lead_search_method,queuemetrics_phone_environment,auto_pause_precall,auto_resume_precall,auto_pause_precall_code,manual_dial_cid,post_phone_time_diff_alert,custom_3way_button_transfer,available_only_tally_threshold,available_only_tally_threshold_agents,dial_level_threshold,dial_level_threshold_agents,safe_harbor_audio,safe_harbor_menu_id,survey_menu_id,callback_days_limit,dl_diff_target_method,disable_dispo_screen,disable_dispo_status,screen_labels,status_display_fields,na_call_url,survey_recording,pllb_grouping,pllb_grouping_limit,call_count_limit,call_count_target,callback_hours_block,callback_list_calltime,user_group,hopper_vlc_dup_check,safe_harbor_audio_field,pause_after_next_call,owner_populate,use_other_campaign_dnc,allow_emails,allow_chats,amd_inbound_group,amd_callmenu,survey_wait_sec,manual_dial_lead_id,dead_max,dispo_max,pause_max,dead_max_dispo,dispo_max_dispo,max_inbound_calls,manual_dial_search_checkbox,hide_call_log_info,timer_alt_seconds,wrapup_bypass,wrapup_after_hotkey,callback_active_limit,callback_active_limit_override,comments_all_tabs,comments_dispo_screen,comments_callback_screen,qc_comment_history,show_previous_callback,clear_script,cpd_unknown_action,manual_dial_search_filter,web_form_address_three,manual_dial_override_field,status_display_ingroup,customer_gone_seconds,agent_display_fields,am_message_wildcards,manual_dial_timeout,routing_initiated_recordings,manual_dial_hopper_check,callback_useronly_move_minutes,ofcom_uk_drop_calc,manual_auto_next,manual_auto_show,allow_required_fields,dead_to_dispo,agent_xfer_validation,ready_max_logout,callback_display_days,three_way_record_stop,hangup_xfer_record_start,scheduled_callbacks_email_alert,max_inbound_calls_outcome,manual_auto_next_options,agent_screen_time_display,next_dial_my_callbacks,inbound_no_agents_no_dial_container,inbound_no_agents_no_dial_threshold,cid_group_id,pause_max_dispo,script_top_dispo,dead_trigger_seconds,dead_trigger_action,dead_trigger_repeat,dead_trigger_filename,dead_trigger_url,scheduled_callbacks_force_dial,scheduled_callbacks_auto_reschedule,scheduled_callbacks_timezones_container,three_way_volume_buttons,callback_dnc,manual_dial_validation,mute_recordings,auto_active_list_new,call_quota_lead_ranking,sip_event_logging,campaign_script_two,leave_vm_no_dispo,leave_vm_message_group_id,dial_timeout_lead_container,amd_type,vmm_daily_limit,opensips_cid_name,amd_agent_route_options,browser_alert_sound,browser_alert_volume,three_way_record_stop_exception,in_group_dial,pause_max_exceptions,hopper_drop_run_trigger,daily_call_count_limit,daily_limit_manual,transfer_button_launch,shared_dial_rank,agent_search_method,qc_scorecard_id,qc_statuses_id,clear_form,leave_3way_start_recording,leave_3way_start_recording_exception,calls_waiting_vl_one,calls_waiting_vl_two,calls_inqueue_count_one,calls_inqueue_count_two,in_man_dial_next_ready_seconds,in_man_dial_next_ready_seconds_override,transfer_no_dispo,call_limit_24hour_method,call_limit_24hour_scope,call_limit_24hour,call_limit_24hour_override,cid_group_id_two,incall_tally_threshold_seconds,auto_alt_threshold,pause_max_url,agent_hide_hangup,ig_xfer_list_sort,script_tab_frame_size,max_logged_in_agents,user_group_script,agent_hangup_route,agent_hangup_value,agent_hangup_ig_override,show_confetti,demographic_quotas,demographic_quotas_container,demographic_quotas_rerank,demographic_quotas_list_resets,custom_one,custom_two,custom_three,custom_four,custom_five,dead_stop_recording,manual_vm_status_updates,force_per_call_notes,agent_search_ingroup_list,hopper_hold_inserts,daily_phone_number_call_limit,state_descriptions,script_tab_height,call_log_days,leave_3way_stop_recording,manual_minimum_ring_seconds,manual_minimum_attempt_seconds,manual_minimum_answer_seconds,khomp_settings_container,stereo_recording,stereo_rec_filename,stereo_parallel_recording,recording_dtmf_muting,stereo_recording_agent,parallel_rec_co_filename,parallel_rec_cm_filename,parallel_rec_fr_filename,call_count_limit_restrict from vicidial_campaigns where campaign_id='$source_campaign_id';";
						$rslt=mysql_to_mysqli($stmt, $link);
						$affected_rows = mysqli_affected_rows($link);

						$stmtA="INSERT INTO vicidial_campaign_stats (campaign_id) values('$campaign_id');";
						$rslt=mysql_to_mysqli($stmtA, $link);
						$affected_rowsA = mysqli_affected_rows($link);

						$stmtB="INSERT INTO vicidial_campaign_stats_debug (campaign_id) values('$campaign_id');";
						$rslt=mysql_to_mysqli($stmtB, $link);
						$affected_rowsB = mysqli_affected_rows($link);

						$stmtC="INSERT INTO vicidial_campaign_statuses (status,status_name,selectable,campaign_id,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable,scheduled_callback,completed,min_sec,max_sec,answering_machine) SELECT status,status_name,selectable,\"$campaign_id\",human_answered,category,sale,dnc,customer_contact,not_interested,unworkable,scheduled_callback,completed,min_sec,max_sec,answering_machine from vicidial_campaign_statuses where campaign_id='$source_campaign_id';";
						$rslt=mysql_to_mysqli($stmtC, $link);
						$affected_rowsC = mysqli_affected_rows($link);

						$stmtD="INSERT INTO vicidial_campaign_hotkeys (status,hotkey,status_name,selectable,campaign_id) SELECT status,hotkey,status_name,selectable,\"$campaign_id\" from vicidial_campaign_hotkeys where campaign_id='$source_campaign_id';";
						$rslt=mysql_to_mysqli($stmtD, $link);
						$affected_rowsD = mysqli_affected_rows($link);

						$stmtE="INSERT INTO vicidial_lead_recycle (status,attempt_delay,attempt_maximum,active,campaign_id) SELECT status,attempt_delay,attempt_maximum,active,\"$campaign_id\" from vicidial_lead_recycle where campaign_id='$source_campaign_id';";
						$rslt=mysql_to_mysqli($stmtE, $link);
						$affected_rowsE = mysqli_affected_rows($link);

						$stmtF="INSERT INTO vicidial_pause_codes (pause_code,pause_code_name,billable,campaign_id,time_limit,require_mgr_approval) SELECT pause_code,pause_code_name,billable,\"$campaign_id\",time_limit,require_mgr_approval from vicidial_pause_codes where campaign_id='$source_campaign_id';";
						$rslt=mysql_to_mysqli($stmtF, $link);
						$affected_rowsF = mysqli_affected_rows($link);

						$stmtG="INSERT INTO vicidial_xfer_presets (campaign_id,preset_name,preset_number,preset_dtmf,preset_hide_number) SELECT \"$campaign_id\",preset_name,preset_number,preset_dtmf,preset_hide_number from vicidial_xfer_presets where campaign_id='$source_campaign_id';";
						$rslt=mysql_to_mysqli($stmtG, $link);
						$affected_rowsG = mysqli_affected_rows($link);

						$stmtH="INSERT INTO vicidial_xfer_stats (campaign_id,preset_name) SELECT \"$campaign_id\",preset_name from vicidial_xfer_presets where campaign_id='$source_campaign_id';";
						$rslt=mysql_to_mysqli($stmtH, $link);
						$affected_rowsH = mysqli_affected_rows($link);

						$stmtI="INSERT INTO vicidial_campaign_cid_areacodes (areacode,outbound_cid,active,cid_description,campaign_id) SELECT areacode,outbound_cid,active,cid_description,\"$campaign_id\" from vicidial_campaign_cid_areacodes where campaign_id='$source_campaign_id';";
						$rslt=mysql_to_mysqli($stmtI, $link);
						$affected_rowsI = mysqli_affected_rows($link);

						$stmtJ="INSERT INTO vicidial_url_multi (entry_type,active,url_type,url_rank,url_statuses,url_description,url_address,url_lists,campaign_id) SELECT entry_type,active,url_type,url_rank,url_statuses,url_description,url_address,url_lists,\"$campaign_id\" from vicidial_url_multi where campaign_id='$source_campaign_id';";
						$rslt=mysql_to_mysqli($stmtJ, $link);
						$affected_rowsJ = mysqli_affected_rows($link);

						$stmtK="SELECT count(*) from vicidial_settings_containers where container_id='AMD_AGENT_OPT_$source_campaign_id';";
						$rslt=mysql_to_mysqli($stmtK, $link);
						$row=mysqli_fetch_row($rslt);
						$AMDAOcount =	$row[0];

						if ($AMDAOcount > 0)
							{
							$stmtL = "INSERT INTO vicidial_settings_containers (container_id,container_notes,container_type,user_group,container_entry) SELECT \"AMD_AGENT_OPT_$campaign_id\",\"AMD agent options for $campaign_id campaign\",container_type,user_group,container_entry from  vicidial_settings_containers where container_id='AMD_AGENT_OPT_$source_campaign_id';";
							$rslt=mysql_to_mysqli($stmtL, $link);
							$affected_rowsL = mysqli_affected_rows($link);
							}

						### LOG INSERTION Admin Log Table ###
						$SQL_log = "$stmt|$stmtA|$stmtB|$stmtC|$stmtD|$stmtE|$stmtF|$stmtG|$stmtH|$stmtI|$stmtJ|$stmtK|$stmtL|";
						$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='CAMPAIGNS', event_type='COPY', record_id='$campaign_id', event_code='ADMIN COPY CAMPAIGN', event_sql=\"$SQL_log\", event_notes='$affected_rows|$affected_rowsA|$affected_rowsB|$affected_rowsC|$affected_rowsD|$affected_rowsE|$affected_rowsF|$affected_rowsG|$affected_rowsH|$affected_rowsI|$affected_rowsJ|$AMDAOcount|$affected_rowsL';";
						if ($DB) {echo "|$stmt|\n";}
						$rslt=mysql_to_mysqli($stmt, $link);
						}
					}
				}
			}
		}
	$ADD=31;
	}


######################
# ADD=22 adds the new campaign status to the system
######################
if ($ADD==22)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("CAMPAIGN STATUS NOT ADDED - there is already a campaign-status in the system with this name")."\n";}
		else
			{
			$stmt="SELECT count(*) from vicidial_statuses where status='$status_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] > 0)
				{echo "<br>"._QXZ("CAMPAIGN STATUS NOT ADDED - there is already a global-status in the system with this name")."\n";}
			else
				{
				if ( (strlen($campaign_id) < 2) or (strlen($status_id) < 1) or (strlen($status_name) < 2) )
					{
					echo "<br>"._QXZ("CAMPAIGN STATUS NOT ADDED - Please go back and look at the data you entered")."\n";
					echo "<br>"._QXZ("status must be between 1 and 8 characters in length")."\n";
					echo "<br>"._QXZ("status name must be between 2 and 30 characters in length")."\n";
					}
				else
					{
					echo "<br><B>"._QXZ("CAMPAIGN STATUS ADDED").": $campaign_id - $status_id</B>\n";

					$stmt="INSERT INTO vicidial_campaign_statuses (status,status_name,selectable,campaign_id,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable,scheduled_callback,completed,min_sec,max_sec,answering_machine) values('$status_id','$status_name','$selectable','$campaign_id','$human_answered','$category','$sale','$dnc','$customer_contact','$not_interested','$unworkable','$scheduled_callbacks','$completed','$min_sec','$max_sec','$answering_machine');";
					$rslt=mysql_to_mysqli($stmt, $link);

					$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
					$rslt=mysql_to_mysqli($stmtB, $link);

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$stmt|$stmtB|";
					$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='CAMPAIGN_STATUS', event_type='ADD', record_id='$campaign_id', event_code='ADMIN ADD CAMPAIGN STATUS', event_sql=\"$SQL_log\", event_notes='Status: $status_id';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	$SUB=22;
	$ADD=31;
	}


######################
# ADD=23 adds the new campaign hotkey to the system
######################
if ($ADD==23)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		$HKstatus_data = explode('-----',$HKstatus);
		$status = $HKstatus_data[0];
		$status_name = $HKstatus_data[1];

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_campaign_hotkeys where campaign_id='$campaign_id' and hotkey='$hotkey' and hotkey='$hotkey';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("CAMPAIGN HOT KEY NOT ADDED - there is already a campaign-hotkey in the system with this hotkey")."\n";}
		else
			{
			if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($hotkey) < 1) )
				{
				echo "<br>"._QXZ("CAMPAIGN HOT KEY NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("hotkey must be a single character between 1 and 9")." \n";
				echo "<br>"._QXZ("status must be between 1 and 8 characters in length")."\n";
				}
			else
				{
				echo "<br><B>"._QXZ("CAMPAIGN HOT KEY ADDED").": $campaign_id - $status - $hotkey</B>\n";

				$stmt="INSERT INTO vicidial_campaign_hotkeys(status,hotkey,status_name,selectable,campaign_id) values('$status','$hotkey','$status_name','$selectable','$campaign_id');";
				$rslt=mysql_to_mysqli($stmt, $link);

				$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmtB, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtB|";
				$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='CAMPAIGN_HOTKEY', event_type='ADD', record_id='$campaign_id', event_code='ADMIN ADD CAMPAIGN HOTKEY', event_sql=\"$SQL_log\", event_notes='Status: $status|HotKey: $hotkey';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$SUB=23;
	$ADD=31;
	}


######################
# ADD=25 adds the new campaign lead recycle entry to the system
######################
if ($ADD==25)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		$status = preg_replace('/\-\-\-\-\-.*/i', '',$status);
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_lead_recycle where campaign_id='$campaign_id' and status='$status';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("CAMPAIGN LEAD RECYCLE NOT ADDED - there is already a lead-recycle for this campaign with this status")."\n";}
		else
			{
			if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or ($attempt_delay < 120) or ($attempt_delay >= 43200) or ($attempt_maximum < 1) or ($attempt_maximum > 10) )
				{
				echo "<br>"._QXZ("CAMPAIGN LEAD RECYCLE NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("status must be between 1 and 6 characters in length")."\n";
				echo "<br>"._QXZ("attempt delay must be at least 120 seconds and less than 43200 seconds or 12 hours")."\n";
				echo "<br>"._QXZ("maximum attempts must be from 1 to 10")."\n";
				}
			else
				{
				echo "<br><B>"._QXZ("CAMPAIGN LEAD RECYCLE ADDED").": $campaign_id - $status - $attempt_delay</B>\n";

				$stmt="INSERT INTO vicidial_lead_recycle(campaign_id,status,attempt_delay,attempt_maximum,active) values('$campaign_id','$status','$attempt_delay','$attempt_maximum','$active');";
				$rslt=mysql_to_mysqli($stmt, $link);

				$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmtB, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtB|";
				$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='CAMPAIGN_RECYCLE', event_type='ADD', record_id='$campaign_id', event_code='ADMIN ADD CAMPAIGN LEAD RECYCLE', event_sql=\"$SQL_log\", event_notes='Status: $status';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$SUB=25;
	$ADD=31;
	}


######################
# ADD=26 adds the new auto alt dial status to the campaign
######################
if ($ADD==26)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		$status = preg_replace('/\-\-\-\-\-.*/i', '',$status);
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id' and auto_alt_dial_statuses LIKE \"% $status %\";";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("AUTO ALT DIAL STATUS NOT ADDED - there is already an entry for this campaign with this status")."\n";}
		else
			{
			if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) )
				{
				echo "<br>"._QXZ("AUTO ALT DIAL STATUS NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("status must be between 1 and 6 characters in length")."\n";
				}
			else
				{
				echo "<br><B>"._QXZ("AUTO ALT DIAL STATUS ADDED").": $campaign_id - $status</B>\n";

				$stmt="SELECT auto_alt_dial_statuses from vicidial_campaigns where campaign_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);

				if (strlen($row[0])<2) {$row[0] = ' -';}
				$auto_alt_dial_statuses = " $status$row[0]";
				$stmt="UPDATE vicidial_campaigns set auto_alt_dial_statuses='$auto_alt_dial_statuses',campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='CAMPAIGN_ALTDIAL', event_type='ADD', record_id='$campaign_id', event_code='ADMIN ADD CAMPAIGN ALT DIAL', event_sql=\"$SQL_log\", event_notes='Status: $auto_alt_dial_statuses';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$SUB=26;
	$ADD=31;
	}


######################
# ADD=27 adds the new campaign agent pause code entry to the system
######################
if ($ADD==27)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_pause_codes where campaign_id='$campaign_id' and pause_code='$pause_code';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("AGENT PAUSE CODE NOT ADDED - there is already an entry for this campaign with this  pause code")."\n";}
		else
			{
			if ( (strlen($campaign_id) < 2) or (strlen($pause_code) < 1) or (mb_strlen($pause_code,'utf-8') > 6) or (strlen($pause_code_name) < 2) )
				{
				echo "<br>"._QXZ("AGENT PAUSE CODE NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("pause code must be between 1 and 6 characters in length")."\n";
				echo "<br>"._QXZ("pause code name must be between 2 and 30 characters in length")."\n";
				}
			else
				{
				echo "<br><B>"._QXZ("AGENT PAUSE CODE ADDED").": $campaign_id - $pause_code - $pause_code_name</B>\n";

				if (strlen($time_limit) < 1) {$time_limit='65000';}
				$stmt="INSERT INTO vicidial_pause_codes(campaign_id,pause_code,pause_code_name,billable,time_limit,require_mgr_approval) values('$campaign_id','$pause_code','$pause_code_name','$billable','$time_limit','$require_mgr_approval');";
				$rslt=mysql_to_mysqli($stmt, $link);

				$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmtB, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtB|";
				$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='CAMPAIGN_PAUSECODE', event_type='ADD', record_id='$campaign_id', event_code='ADMIN ADD CAMPAIGN PAUSE CODE', event_sql=\"$SQL_log\", event_notes='Pause Code: $pause_code';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$SUB=27;
	$ADD=31;
	}


######################
# ADD=28 adds new status to the campaign dial statuses
######################
if ($ADD==28)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		$status = preg_replace('/\-\-\-\-\-.*/i', '',$status);
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id' and dial_statuses LIKE \"% $status %\";";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("CAMPAIGN DIAL STATUS NOT ADDED - there is already an entry for this campaign with this status")."\n";}
		else
			{
			if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) )
				{
				echo "<br>"._QXZ("CAMPAIGN DIAL STATUS NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("status must be between 1 and 6 characters in length")."\n";
				}
			else
				{
				echo "<br><B>"._QXZ("CAMPAIGN DIAL STATUS ADDED").": $campaign_id - $status</B>\n";

				$stmt="SELECT dial_statuses from vicidial_campaigns where campaign_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);

				if (strlen($row[0])<2) {$row[0] = ' -';}
				$dial_statuses = " $status$row[0]";
				$stmt="UPDATE vicidial_campaigns set dial_statuses='$dial_statuses',campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='CAMPAIGN_DIALSTATUS', event_type='ADD', record_id='$campaign_id', event_code='ADMIN ADD CAMPAIGN DIAL STATUS', event_sql=\"$SQL_log\", event_notes='Status: $statuses';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	#$SUB=28;
	$ADD=31;
	}


######################
# ADD=201 adds new preset to the campaign presets
######################
if ($ADD==201)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_xfer_presets where campaign_id='$campaign_id' and preset_name='$preset_name';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("PRESET NOT ADDED - there is already an entry for this campaign with this preset")."\n";}
		else
			{
			if ( (strlen($campaign_id) < 2) or (strlen($preset_name) < 1) or (strlen($preset_number) < 1) )
				{
				echo "<br>"._QXZ("PRESET NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("preset name must be between 1 and 40 characters in length")."\n";
				echo "<br>"._QXZ("preset number must be between 2 and 50 characters in length")."\n";
				}
			else
				{
				echo "<br><B>"._QXZ("PRESET ADDED").": $campaign_id - $preset_name - $preset_number</B>\n";

				$stmt="INSERT INTO vicidial_xfer_presets(campaign_id,preset_name,preset_number,preset_dtmf,preset_hide_number) values('$campaign_id','$preset_name','$preset_number','$preset_dtmf','$preset_hide_number');";
				$rslt=mysql_to_mysqli($stmt, $link);

				$stmtA="INSERT INTO vicidial_xfer_stats(campaign_id,preset_name) values('$campaign_id','$preset_name');";
				$rslt=mysql_to_mysqli($stmtA, $link);

				$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmtB, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtA|$stmtB|";
				$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='CAMPAIGN_PRESET', event_type='ADD', record_id='$campaign_id', event_code='ADMIN ADD CAMPAIGN PRESET', event_sql=\"$SQL_log\", event_notes='Preset: $preset_name - $preset_number';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$SUB=201;
	$ADD=31;
	}


######################
# ADD=202 adds/deletes/modifies areacode cid to the campaign
######################
if ($ADD==202)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		if ($stage == 'ADD')
			{
			$stmt="SELECT count(*) from vicidial_campaign_cid_areacodes where campaign_id='$campaign_id' and areacode='$areacode' and outbound_cid='$outbound_cid';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] > 0)
				{echo "<br>"._QXZ("AREACODE CID NOT ADDED - there is already an entry for this campaign with this CID")."<br>\n";}
			else
				{
				if ( (strlen($campaign_id) < 2) or (strlen($areacode) < 2) or (strlen($outbound_cid) < 6) )
					{
					echo "<br>"._QXZ("AREACODE CID NOT ADDED - Please go back and look at the data you entered")."<br>\n";
					}
				else
					{
					echo "<br><B>"._QXZ("AREACODE CID ADDED").": $campaign_id - $areacode - $outbound_cid</B><br>\n";

					$stmt="INSERT INTO vicidial_campaign_cid_areacodes(campaign_id,areacode,outbound_cid,cid_description) values('$campaign_id','$areacode','$outbound_cid','$cid_description');";
					$rslt=mysql_to_mysqli($stmt, $link);

					$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
					$rslt=mysql_to_mysqli($stmtB, $link);

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$stmt|$stmtB|";
					$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='CAMPAIGN_AC-CID', event_type='ADD', record_id='$campaign_id', event_code='ADMIN ADD CAMPAIGN AC-CID', event_sql=\"$SQL_log\", event_notes='CID: $areacode - $outbound_cid';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		if ($stage == 'DELETE')
			{
			$stmt="SELECT count(*) from vicidial_campaign_cid_areacodes where campaign_id='$campaign_id' and areacode='$areacode' and outbound_cid='$outbound_cid' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] < 1)
				{echo "<br>"._QXZ("AREACODE CID NOT DELETED - this entry does not exist")."<br>\n";}
			else
				{
				if ( (strlen($campaign_id) < 2) or (strlen($areacode) < 2) or (strlen($outbound_cid) < 6) )
					{
					echo "<br>"._QXZ("AREACODE CID NOT DELETED - Please go back and look at the data you entered")."<br>\n";
					}
				else
					{
					echo "<br><B>"._QXZ("AREACODE CID DELETED").": $campaign_id - $areacode - $outbound_cid</B><br>\n";

					$stmt="DELETE FROM vicidial_campaign_cid_areacodes WHERE campaign_id='$campaign_id' and areacode='$areacode' and outbound_cid='$outbound_cid';";
					$rslt=mysql_to_mysqli($stmt, $link);

					$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
					$rslt=mysql_to_mysqli($stmtB, $link);

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$stmt|$stmtB|";
					$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='CAMPAIGN_AC-CID', event_type='DELETE', record_id='$campaign_id', event_code='ADMIN DELETE CAMPAIGN AC-CID', event_sql=\"$SQL_log\", event_notes='CID: $areacode - $outbound_cid';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		if ($stage == 'MODIFY')
			{
			$stmt="SELECT areacode,outbound_cid,active,cid_description,call_count_today from vicidial_campaign_cid_areacodes where campaign_id='$campaign_id' $LOGallowed_campaignsSQL order by areacode,outbound_cid";
			$rslt=mysql_to_mysqli($stmt, $link);
			$accids_to_print = mysqli_num_rows($rslt);
			$o=0;
			while ($accids_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$Xareacode[$o] =			$rowx[0];
				$Xoutbound_cid[$o] =		$rowx[1];
				$Xactive[$o] =				$rowx[2];
				$Xcid_description[$o] =		$rowx[3];
				$Xcall_count_today[$o] =	$rowx[4];
				$o++;
				}

			$accid_modified=0;
			$stmt_log='';
			$accid_log='';
			$o=0;
			while ($accids_to_print > $o) 
				{
				$Factive_value='';
				$Fcid_description_value='';
				$Factive = "active_$Xareacode[$o]_$Xoutbound_cid[$o]";
				$Fcid_description = "cid_description_$Xareacode[$o]_$Xoutbound_cid[$o]";

				if (isset($_GET[$Factive]))						{$Factive_value=$_GET[$Factive];}
					elseif (isset($_POST[$Factive]))			{$Factive_value=$_POST[$Factive];}
				if (isset($_GET[$Fcid_description]))			{$Fcid_description_value=$_GET[$Fcid_description];}
					elseif (isset($_POST[$Fcid_description]))	{$Fcid_description_value=$_POST[$Fcid_description];}
				if ($non_latin < 1)
					{
					$Fcid_description_value = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$Fcid_description_value);
					}
				else
					{
					$Fcid_description_value = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$Fcid_description_value);
					}

				$Factive_value = preg_replace('/[^A-Z]/','',$Factive_value);

			#	echo "$campaign_id - $Xareacode[$o] - $Xoutbound_cid[$o] - $Factive($Factive_value|$Xactive[$o]) - $Fcid_description($Fcid_description_value|$Xcid_description[$o])<BR>";

				if ( ($Factive_value == $Xactive[$o]) and ($Fcid_description_value == $Xcid_description[$o]) )
					{
				#	echo "<br>AREACODE CID NOT MODIFIED - Please go back and look at the data you entered<br>\n";
					}
				else
					{
					$accid_modified++;
					echo "<B>"._QXZ("AREACODE CID MODIFIED").": $Xareacode[$o] - $Xoutbound_cid[$o]</B><br>\n";

					$stmt="UPDATE vicidial_campaign_cid_areacodes SET active='$Factive_value',cid_description='$Fcid_description_value' WHERE campaign_id='$campaign_id' and areacode='$Xareacode[$o]' and outbound_cid='$Xoutbound_cid[$o]';";
					$rslt=mysql_to_mysqli($stmt, $link);

					$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
					$rslt=mysql_to_mysqli($stmtB, $link);

					$stmt_log .= "$stmt|$stmtB|";
					$accid_log .= "CID: $Xareacode[$o] - $Xoutbound_cid[$o] - $Factive_value - $Fcid_description_value|";
					}
				$o++;
				}
			if ($accid_modified > 0)
				{
				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt_log|";
				$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='CAMPAIGN_AC-CID', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN AC-CID', event_sql=\"$SQL_log\", event_notes='$accid_modified AC-CIDs MODIFIED. CHANGES: $accid_log';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$SUB=202;
	$ADD=31;
	}


######################
# ADD=211 adds the new list to the system
######################
if ($ADD==211)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_lists' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$list_id = ($row[0] + 1);

			$stmt="UPDATE vicidial_override_ids SET value='$list_id' where id_table='vicidial_lists' and active='1';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		##### END ID override optional section #####

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_lists where list_id='$list_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("LIST NOT ADDED - there is already a list in the system with this ID")."\n";}
		else
			{
			if ( (strlen($campaign_id) < 2) or (strlen($list_name) < 2)  or ($list_id < 100) or (strlen($list_id) > 19) )
				{
				echo "<br>"._QXZ("LIST NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("List ID must be between 2 and 8 characters in length")."\n";
				echo "<br>"._QXZ("List name must be at least 2 characters in length")."\n";
				echo "<br>"._QXZ("List ID must be greater than 100")."\n";
				}
			else
				{
				echo "<br><B>"._QXZ("LIST ADDED").": $list_id</B>\n";

				$stmt="INSERT INTO vicidial_lists (list_id,list_name,campaign_id,active,list_description,list_changedate) values('$list_id','$list_name','$campaign_id','$active','$list_description','$SQLdate');";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='LISTS', event_type='ADD', record_id='$list_id', event_code='ADMIN ADD LIST', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=311;
	}


######################
# ADD=231 adds the new drop list to the system
######################
if ($ADD==231)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_drop_lists' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$dl_id = ($row[0] + 1);

			$stmt="UPDATE vicidial_override_ids SET value='$dl_id' where id_table='vicidial_drop_lists' and active='1';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		##### END ID override optional section #####

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_drop_lists where dl_id='$dl_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("DROP LIST NOT ADDED - there is already a drop list in the system with this ID")."\n";}
		else
			{
			if ( (strlen($dl_id) < 2) or (strlen($dl_name) < 2) )
				{
				echo "<br>"._QXZ("DROP LIST NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("Drop List ID must be between 2 and 30 characters in length")."\n";
				echo "<br>"._QXZ("Drop List name must be at least 2 characters in length")."\n";
				}
			else
				{
				echo "<br><B>"._QXZ("DROP LIST ADDED").": $list_id</B>\n";

				$stmt="INSERT INTO vicidial_drop_lists (dl_id,dl_name) values('$dl_id','$dl_name');";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='DROPLISTS', event_type='ADD', record_id='$dl_id', event_code='ADMIN ADD DROP LIST', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);

				$ADD=331;
				}
			}
		}
	}


######################
# ADD=2111 adds the new inbound group to the system
######################
if ($ADD==2111)
	{
	$group_id = preg_replace("/\-/",'',$group_id);
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_inbound_groups' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$group_id = ($row[0] + 1);

			$stmt="UPDATE vicidial_override_ids SET value='$group_id' where id_table='vicidial_inbound_groups' and active='1';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		##### END ID override optional section #####

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$group_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("GROUP NOT ADDED - there is already a group in the system with this ID")."\n";}
		else
			{
			$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$group_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] > 0)
				{echo "<br>"._QXZ("GROUP NOT ADDED - there is already a campaign in the system with this ID")."\n";}
			else
				{
				if ( (strlen($group_id) < 2) or (strlen($group_name) < 2)  or (strlen($group_color) < 2) or (mb_strlen($group_id,'utf-8') > 20) or (preg_match('/\s/i',$group_id)) or (preg_match('/\-/i',$group_id)) or (preg_match("/\+/i",$group_id)) )
					{
					echo "<br>"._QXZ("GROUP NOT ADDED - Please go back and look at the data you entered")."\n";
					echo "<br>"._QXZ("Group ID must be between 2 and 20 characters in length and contain no")." ' -+'.\n";
					echo "<br>"._QXZ("Group name and group color must be at least 2 characters in length")."\n";
					}
				else
					{
					if ( (!preg_match("/\|$group_color,/i",$HTMLcolors)) and ( (strlen($group_color) > 7) or (strlen($group_color) < 7) or (!preg_match("/^#/",$group_color)) ) )
						{
						if (!preg_match("/^#/",$group_color)) {$group_color = "#$group_color";}
						if (strlen($group_color) > 7) {$group_color = substr($group_color,0,7);}
						while (strlen($group_color) < 7) {$group_color .= '0';}
						}
					$stmt="INSERT INTO vicidial_inbound_groups (group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,web_form_address_two,start_call_url,dispo_call_url,add_lead_url,na_call_url,user_group,group_handling,web_form_address_three,place_in_line_caller_number_filename,place_in_line_you_next_filename,custom_one,custom_two,custom_three,custom_four,custom_five) values('$group_id','$group_name','$group_color','$active','" . mysqli_real_escape_string($link, $web_form_address) . "','$voicemail_ext','$next_agent_call','$fronter_display','$script_id','$get_call_launch','','','','','','$user_group','$group_handling','','','','','','','','');";
					$rslt=mysql_to_mysqli($stmt, $link);

					$stmtA="INSERT INTO vicidial_campaign_stats (campaign_id) values('$group_id');";
					$rslt=mysql_to_mysqli($stmtA, $link);

					$stmtB="INSERT INTO vicidial_campaign_stats_debug (campaign_id) values('$group_id');";
					$rslt=mysql_to_mysqli($stmtB, $link);

					echo "<br><B>"._QXZ("GROUP ADDED").": $group_id</B>\n";

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$stmt|$stmtA|$stmtB|";
					$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='INGROUPS', event_type='ADD', record_id='$group_id', event_code='ADMIN ADD INBOUND GROUP', event_sql=\"$SQL_log\", event_notes='';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	$ADD=3111;
	}


######################
# ADD=2811 adds the new EMAIL inbound group to the system
######################
if ( ($ADD==2811) and ($SSallow_emails>0) )
	{
	$group_id = preg_replace("/\-/",'',$group_id);
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_inbound_groups' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$group_id = ($row[0] + 1);

			$stmt="UPDATE vicidial_override_ids SET value='$group_id' where id_table='vicidial_inbound_groups' and active='1';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		##### END ID override optional section #####

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$group_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("EMAIL GROUP NOT ADDED - there is already a group in the system with this ID")."\n";}
		else
			{
			$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$group_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] > 0)
				{echo "<br>"._QXZ("EMAIL GROUP NOT ADDED - there is already a campaign in the system with this ID")."\n";}
			else
				{
				if ( (strlen($group_id) < 2) or (strlen($group_name) < 2)  or (strlen($group_color) < 2) or (mb_strlen($group_id,'utf-8') > 20) or (preg_match('/\s/i',$group_id)) or (preg_match('/\-/i',$group_id)) or (preg_match("/\+/i",$group_id)) )
					{
					echo "<br>"._QXZ("GROUP NOT ADDED - Please go back and look at the data you entered")."\n";
					echo "<br>"._QXZ("Group ID must be between 2 and 20 characters in length and contain no")." ' -+'.\n";
					echo "<br>"._QXZ("Group name and group color must be at least 2 characters in length")."\n";
					}
				else
					{
					if ( (!preg_match("/\|$group_color,/i",$HTMLcolors)) and ( (strlen($group_color) > 7) or (strlen($group_color) < 7) or (!preg_match("/^#/",$group_color)) ) )
						{
						if (!preg_match("/^#/",$group_color)) {$group_color = "#$group_color";}
						if (strlen($group_color) > 7) {$group_color = substr($group_color,0,7);}
						while (strlen($group_color) < 7) {$group_color .= '0';}
						}
					$stmt="INSERT INTO vicidial_inbound_groups (group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,web_form_address_two,start_call_url,dispo_call_url,add_lead_url,na_call_url,user_group,group_handling,web_form_address_three,place_in_line_caller_number_filename,place_in_line_you_next_filename,custom_one,custom_two,custom_three,custom_four,custom_five) values('$group_id','$group_name','$group_color','$active','" . mysqli_real_escape_string($link, $web_form_address) . "','$voicemail_ext','$next_agent_call','$fronter_display','$script_id','EMAIL','','','','','','$user_group','$group_handling','','','','','','','','');";
					$rslt=mysql_to_mysqli($stmt, $link);

					$stmtA="INSERT INTO vicidial_campaign_stats (campaign_id) values('$group_id');";
					$rslt=mysql_to_mysqli($stmtA, $link);

					$stmtB="INSERT INTO vicidial_campaign_stats_debug (campaign_id) values('$group_id');";
					$rslt=mysql_to_mysqli($stmtB, $link);

					echo "<br><B>"._QXZ("EMAIL GROUP ADDED").": $group_id</B>\n";

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$stmt|$stmtA|$stmtB|";
					$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='INGROUPS', event_type='ADD', record_id='$group_id', event_code='ADMIN ADD INBOUND GROUP', event_sql=\"$SQL_log\", event_notes='';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	$ADD=3811;
	}


######################
# ADD=28111 adds the new CHAT inbound group to the system
######################
if ( ($ADD==28111) and ($SSallow_chats>0) )
	{
	$group_id = preg_replace("/\-/",'',$group_id);
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_inbound_groups' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$group_id = ($row[0] + 1);

			$stmt="UPDATE vicidial_override_ids SET value='$group_id' where id_table='vicidial_inbound_groups' and active='1';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		##### END ID override optional section #####

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$group_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("CHAT GROUP NOT ADDED - there is already a group in the system with this ID")."\n";}
		else
			{
			$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$group_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] > 0)
				{echo "<br>"._QXZ("CHAT GROUP NOT ADDED - there is already a campaign in the system with this ID")."\n";}
			else
				{
				if ( (strlen($group_id) < 2) or (strlen($group_name) < 2)  or (strlen($group_color) < 2) or (mb_strlen($group_id,'utf-8') > 20) or (preg_match('/\s/i',$group_id)) or (preg_match('/\-/i',$group_id)) or (preg_match("/\+/i",$group_id)) )
					{
					echo "<br>"._QXZ("GROUP NOT ADDED - Please go back and look at the data you entered")."\n";
					echo "<br>"._QXZ("Group ID must be between 2 and 20 characters in length and contain no")." ' -+'.\n";
					echo "<br>"._QXZ("Group name and group color must be at least 2 characters in length")."\n";
					}
				else
					{
					if ( (!preg_match("/\|$group_color,/i",$HTMLcolors)) and ( (strlen($group_color) > 7) or (strlen($group_color) < 7) or (!preg_match("/^#/",$group_color)) ) )
						{
						if (!preg_match("/^#/",$group_color)) {$group_color = "#$group_color";}
						if (strlen($group_color) > 7) {$group_color = substr($group_color,0,7);}
						while (strlen($group_color) < 7) {$group_color .= '0';}
						}
					$stmt="INSERT INTO vicidial_inbound_groups (group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,web_form_address_two,start_call_url,dispo_call_url,add_lead_url,na_call_url,user_group,group_handling,hold_time_option_callback_list_id,web_form_address_three,place_in_line_caller_number_filename,place_in_line_you_next_filename,custom_one,custom_two,custom_three,custom_four,custom_five) values('$group_id','$group_name','$group_color','$active','" . mysqli_real_escape_string($link, $web_form_address) . "','$voicemail_ext','$next_agent_call','$fronter_display','$script_id','CHAT','','','','','','$user_group','$group_handling','$hold_time_option_callback_list_id','','','','','','','','');";
					$rslt=mysql_to_mysqli($stmt, $link);

					$stmtA="INSERT INTO vicidial_campaign_stats (campaign_id) values('$group_id');";
					$rslt=mysql_to_mysqli($stmtA, $link);

					$stmtB="INSERT INTO vicidial_campaign_stats_debug (campaign_id) values('$group_id');";
					$rslt=mysql_to_mysqli($stmtB, $link);

					echo "<br><B>CHAT GROUP ADDED: $group_id</B>\n";

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$stmt|$stmtA|$stmtB|";
					$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='INGROUPS', event_type='ADD', record_id='$group_id', event_code='ADMIN ADD INBOUND GROUP', event_sql=\"$SQL_log\", event_notes='';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	$ADD=3911;
	}


######################
# ADD=2011 adds copied inbound group to the system
######################
if ($ADD==2011)
	{
	$group_id = preg_replace("/\-/",'',$group_id);
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_inbound_groups' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$group_id = ($row[0] + 1);

			$stmt="UPDATE vicidial_override_ids SET value='$group_id' where id_table='vicidial_inbound_groups' and active='1';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		##### END ID override optional section #####

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$group_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("GROUP NOT ADDED - there is already a group in the system with this ID")."\n";}
		else
			{
			$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$group_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] > 0)
				{echo "<br>"._QXZ("GROUP NOT ADDED - there is already a campaign in the system with this ID")."\n";}
			else
				{
				if ( (strlen($group_id) < 2) or (strlen($group_name) < 2) or (mb_strlen($group_id,'utf-8') > 20) or (preg_match('/\s/i',$group_id)) or (preg_match('/\-/i',$group_id)) or (preg_match("/\+/i",$group_id)) )
					{
					echo "<br>"._QXZ("GROUP NOT ADDED - Please go back and look at the data you entered")."\n";
					echo "<br>"._QXZ("Group ID must be between 2 and 20 characters in length and contain no")." ' -+'.\n";
					echo "<br>"._QXZ("Group name and group color must be at least 2 characters in length")."\n";
					}
				else
					{
					if ( (!preg_match("/\|$group_color,/i",$HTMLcolors)) and ( (strlen($group_color) > 7) or (strlen($group_color) < 7) or (!preg_match("/^#/",$group_color)) ) )
						{
						if (!preg_match("/^#/",$group_color)) {$group_color = "#$group_color";}
						if (strlen($group_color) > 7) {$group_color = substr($group_color,0,7);}
						while (strlen($group_color) < 7) {$group_color .= '0';}
						}
					$stmt="INSERT INTO vicidial_inbound_groups (group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,drop_call_seconds,drop_action,drop_exten,call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,default_xfer_group,queue_priority,drop_inbound_group,ingroup_recording_override,ingroup_rec_filename,afterhours_xfer_group,qc_enabled,qc_statuses,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two,default_group_alias,no_agent_no_queue,no_agent_action,no_agent_action_value,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,ignore_list_script_override,extension_appended_cidname,uniqueid_status_display,uniqueid_status_prefix,hold_time_option_minimum,hold_time_option_press_filename,hold_time_option_callmenu,onhold_prompt_no_block,onhold_prompt_seconds,hold_time_option_no_block,hold_time_option_prompt_seconds,hold_time_second_option,hold_time_third_option,wait_hold_option_priority,wait_time_option,wait_time_second_option,wait_time_third_option,wait_time_option_seconds,wait_time_option_exten,wait_time_option_voicemail,wait_time_option_xfer_group,wait_time_option_callmenu,wait_time_option_callback_filename,wait_time_option_callback_list_id,wait_time_option_press_filename,wait_time_option_no_block,wait_time_option_prompt_seconds,timer_action_destination,calculate_estimated_hold_seconds,add_lead_url,eht_minimum_prompt_filename,eht_minimum_prompt_no_block,eht_minimum_prompt_seconds,on_hook_ring_time,na_call_url,on_hook_cid,action_xfer_cid,drop_callmenu,after_hours_callmenu,user_group,max_calls_method,max_calls_count,max_calls_action,dial_ingroup_cid,group_handling,web_form_address_three,populate_lead_ingroup,drop_lead_reset,after_hours_lead_reset,nanq_lead_reset,wait_time_lead_reset,hold_time_lead_reset,status_group_id,routing_initiated_recordings,on_hook_cid_number,customer_chat_screen_colors,customer_chat_survey_link,customer_chat_survey_text,populate_lead_province,areacode_filter,areacode_filter_seconds,areacode_filter_action,areacode_filter_action_value,populate_state_areacode,inbound_survey,inbound_survey_filename,inbound_survey_accept_digit,inbound_survey_question_filename,inbound_survey_callmenu,icbq_expiration_hours,closing_time_action,closing_time_now_trigger,closing_time_filename,closing_time_end_filename,closing_time_lead_reset,closing_time_option_exten,closing_time_option_callmenu,closing_time_option_voicemail,closing_time_option_xfer_group,closing_time_option_callback_list_id,icbq_call_time_id,add_lead_timezone,icbq_dial_filter,populate_lead_source,populate_lead_vendor,park_file_name,waiting_call_url_on,waiting_call_url_off,enter_ingroup_url,cid_cb_confirm_number,cid_cb_invalid_filter_phone_group,cid_cb_valid_length,cid_cb_valid_filename,cid_cb_confirmed_filename,cid_cb_enter_filename,cid_cb_you_entered_filename,cid_cb_press_to_confirm_filename,cid_cb_invalid_filename,cid_cb_reenter_filename,cid_cb_error_filename,place_in_line_caller_number_filename,place_in_line_you_next_filename,ingroup_script_two,browser_alert_sound,browser_alert_volume,answer_signal,no_agent_delay,agent_search_method,qc_scorecard_id,qc_statuses_id,populate_lead_comments,drop_call_seconds_override,populate_lead_owner,in_queue_nanque,in_queue_nanque_exceptions,custom_one,custom_two,custom_three,custom_four,custom_five,second_alert_trigger,second_alert_trigger_seconds,second_alert_filename,second_alert_delay,second_alert_container,second_alert_only,third_alert_trigger,third_alert_trigger_seconds,third_alert_filename,third_alert_delay,third_alert_container,third_alert_only,agent_search_list,state_descriptions,stereo_recording,stereo_rec_filename,stereo_parallel_recording,recording_dtmf_muting,stereo_recording_agent,parallel_rec_co_filename,parallel_rec_cm_filename,parallel_rec_fr_filename) SELECT \"$group_id\",\"$group_name\",group_color,\"N\",web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,drop_call_seconds,drop_action,drop_exten,call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,default_xfer_group,queue_priority,drop_inbound_group,ingroup_recording_override,ingroup_rec_filename,afterhours_xfer_group,qc_enabled,qc_statuses,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two,default_group_alias,no_agent_no_queue,no_agent_action,no_agent_action_value,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,ignore_list_script_override,extension_appended_cidname,uniqueid_status_display,uniqueid_status_prefix,hold_time_option_minimum,hold_time_option_press_filename,hold_time_option_callmenu,onhold_prompt_no_block,onhold_prompt_seconds,hold_time_option_no_block,hold_time_option_prompt_seconds,hold_time_second_option,hold_time_third_option,wait_hold_option_priority,wait_time_option,wait_time_second_option,wait_time_third_option,wait_time_option_seconds,wait_time_option_exten,wait_time_option_voicemail,wait_time_option_xfer_group,wait_time_option_callmenu,wait_time_option_callback_filename,wait_time_option_callback_list_id,wait_time_option_press_filename,wait_time_option_no_block,wait_time_option_prompt_seconds,timer_action_destination,calculate_estimated_hold_seconds,add_lead_url,eht_minimum_prompt_filename,eht_minimum_prompt_no_block,eht_minimum_prompt_seconds,on_hook_ring_time,na_call_url,on_hook_cid,action_xfer_cid,drop_callmenu,after_hours_callmenu,user_group,max_calls_method,max_calls_count,max_calls_action,dial_ingroup_cid,group_handling,web_form_address_three,populate_lead_ingroup,drop_lead_reset,after_hours_lead_reset,nanq_lead_reset,wait_time_lead_reset,hold_time_lead_reset,status_group_id,routing_initiated_recordings,on_hook_cid_number,customer_chat_screen_colors,customer_chat_survey_link,customer_chat_survey_text,populate_lead_province,areacode_filter,areacode_filter_seconds,areacode_filter_action,areacode_filter_action_value,populate_state_areacode,inbound_survey,inbound_survey_filename,inbound_survey_accept_digit,inbound_survey_question_filename,inbound_survey_callmenu,icbq_expiration_hours,closing_time_action,closing_time_now_trigger,closing_time_filename,closing_time_end_filename,closing_time_lead_reset,closing_time_option_exten,closing_time_option_callmenu,closing_time_option_voicemail,closing_time_option_xfer_group,closing_time_option_callback_list_id,icbq_call_time_id,add_lead_timezone,icbq_dial_filter,populate_lead_source,populate_lead_vendor,park_file_name,waiting_call_url_on,waiting_call_url_off,enter_ingroup_url,cid_cb_confirm_number,cid_cb_invalid_filter_phone_group,cid_cb_valid_length,cid_cb_valid_filename,cid_cb_confirmed_filename,cid_cb_enter_filename,cid_cb_you_entered_filename,cid_cb_press_to_confirm_filename,cid_cb_invalid_filename,cid_cb_reenter_filename,cid_cb_error_filename,place_in_line_caller_number_filename,place_in_line_you_next_filename,ingroup_script_two,browser_alert_sound,browser_alert_volume,answer_signal,no_agent_delay,agent_search_method,qc_scorecard_id,qc_statuses_id,populate_lead_comments,drop_call_seconds_override,populate_lead_owner,in_queue_nanque,in_queue_nanque_exceptions,custom_one,custom_two,custom_three,custom_four,custom_five,second_alert_trigger,second_alert_trigger_seconds,second_alert_filename,second_alert_delay,second_alert_container,second_alert_only,third_alert_trigger,third_alert_trigger_seconds,third_alert_filename,third_alert_delay,third_alert_container,third_alert_only,agent_search_list,state_descriptions,stereo_recording,stereo_rec_filename,stereo_parallel_recording,recording_dtmf_muting,stereo_recording_agent,parallel_rec_co_filename,parallel_rec_cm_filename,parallel_rec_fr_filename from vicidial_inbound_groups where group_id=\"$source_group_id\";";
					$rslt=mysql_to_mysqli($stmt, $link);
					$affected_rows = mysqli_affected_rows($link);

					$stmtA="INSERT INTO vicidial_campaign_stats (campaign_id) values('$group_id');";
					$rslt=mysql_to_mysqli($stmtA, $link);
					$affected_rowsA = mysqli_affected_rows($link);

					$stmtB="INSERT INTO vicidial_campaign_stats_debug (campaign_id) values('$group_id');";
					$rslt=mysql_to_mysqli($stmtB, $link);
					$affected_rowsB = mysqli_affected_rows($link);

					# copy agent ranks and grades from source in-group
					$stmtC="INSERT INTO vicidial_inbound_group_agents (user,group_id,group_rank,group_weight,group_grade,group_web_vars,daily_limit) SELECT user,'$group_id',group_rank,group_weight,group_grade,group_web_vars,daily_limit from vicidial_inbound_group_agents where group_id=\"$source_group_id\";";
					$rslt=mysql_to_mysqli($stmtC, $link);
					$affected_rowsC = mysqli_affected_rows($link);

					# add new in-group to user's agent-selected in-groups
					$SQL_group_id = preg_replace("/_/",'\\_',$group_id);
					$SQL_source_group_id = preg_replace("/_/",'\\_',$source_group_id);
					$stmtD="UPDATE vicidial_users set closer_campaigns=REPLACE( closer_campaigns, ' $source_group_id ', ' $source_group_id $group_id ' ) where closer_campaigns LIKE \"% $SQL_source_group_id %\" and closer_campaigns NOT LIKE \"% $SQL_group_id %\";";
					$rslt=mysql_to_mysqli($stmtD, $link);
					$affected_rowsD = mysqli_affected_rows($link);

					$stmtE="INSERT INTO vicidial_url_multi (entry_type,active,url_type,url_rank,url_statuses,url_description,url_address,url_lists,campaign_id) SELECT entry_type,active,url_type,url_rank,url_statuses,url_description,url_address,url_lists,\"$group_id\" from vicidial_url_multi where campaign_id='$source_group_id';";
					$rslt=mysql_to_mysqli($stmtE, $link);
					$affected_rowsE = mysqli_affected_rows($link);

					echo "<br><B>"._QXZ("INBOUND GROUP ADDED").": $group_id</B>\n";

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$stmt|$stmtA|$stmtB|$stmtC|$stmtD|$stmtE|";
					$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='INGROUPS', event_type='COPY', record_id='$group_id', event_code='ADMIN COPY INBOUND GROUP', event_sql=\"$SQL_log\", event_notes='$affected_rows|$affected_rowsA|$affected_rowsB|$affected_rowsC|$affected_rowsD|$affected_rowsE';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	$ADD=3111;
	}


######################
# ADD=2911 adds copied email group to the system
######################
if ( ($ADD==2911) and ($SSallow_emails>0) )
	{
	$group_id = preg_replace("/\-/",'',$group_id);
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_inbound_groups' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$group_id = ($row[0] + 1);

			$stmt="UPDATE vicidial_override_ids SET value='$group_id' where id_table='vicidial_inbound_groups' and active='1';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		##### END ID override optional section #####

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$group_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("EMAIL GROUP NOT ADDED - there is already a group in the system with this ID")."\n";}
		else
			{
			$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$group_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] > 0)
				{echo "<br>"._QXZ("EMAIL GROUP NOT ADDED - there is already a campaign in the system with this ID")."\n";}
			else
				{
				if ( (strlen($group_id) < 2) or (strlen($group_name) < 2) or (mb_strlen($group_id,'utf-8') > 20) or (preg_match('/\s/i',$group_id)) or (preg_match('/\-/i',$group_id)) or (preg_match("/\+/i",$group_id)) )
					{
					echo "<br>"._QXZ("EMAIL GROUP NOT ADDED - Please go back and look at the data you entered")."\n";
					echo "<br>"._QXZ("Email group ID must be between 2 and 20 characters in length and contain no")." ' -+'.\n";
					echo "<br>"._QXZ("Email group name and group color must be at least 2 characters in length")."\n";
					}
				else
					{
					if ( (!preg_match("/\|$group_color,/i",$HTMLcolors)) and ( (strlen($group_color) > 7) or (strlen($group_color) < 7) or (!preg_match("/^#/",$group_color)) ) )
						{
						if (!preg_match("/^#/",$group_color)) {$group_color = "#$group_color";}
						if (strlen($group_color) > 7) {$group_color = substr($group_color,0,7);}
						while (strlen($group_color) < 7) {$group_color .= '0';}
						}
					$stmt="INSERT INTO vicidial_inbound_groups (group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,drop_call_seconds,drop_action,drop_exten,call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,default_xfer_group,queue_priority,drop_inbound_group,ingroup_recording_override,ingroup_rec_filename,afterhours_xfer_group,qc_enabled,qc_statuses,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two,default_group_alias,no_agent_no_queue,no_agent_action,no_agent_action_value,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,ignore_list_script_override,extension_appended_cidname,uniqueid_status_display,uniqueid_status_prefix,hold_time_option_minimum,hold_time_option_press_filename,hold_time_option_callmenu,onhold_prompt_no_block,onhold_prompt_seconds,hold_time_option_no_block,hold_time_option_prompt_seconds,hold_time_second_option,hold_time_third_option,wait_hold_option_priority,wait_time_option,wait_time_second_option,wait_time_third_option,wait_time_option_seconds,wait_time_option_exten,wait_time_option_voicemail,wait_time_option_xfer_group,wait_time_option_callmenu,wait_time_option_callback_filename,wait_time_option_callback_list_id,wait_time_option_press_filename,wait_time_option_no_block,wait_time_option_prompt_seconds,timer_action_destination,calculate_estimated_hold_seconds,add_lead_url,eht_minimum_prompt_filename,eht_minimum_prompt_no_block,eht_minimum_prompt_seconds,on_hook_ring_time,na_call_url,on_hook_cid,action_xfer_cid,drop_callmenu,after_hours_callmenu,user_group,max_calls_method,max_calls_count,max_calls_action,dial_ingroup_cid,group_handling,web_form_address_three,populate_lead_ingroup,drop_lead_reset,after_hours_lead_reset,nanq_lead_reset,wait_time_lead_reset,hold_time_lead_reset,status_group_id,routing_initiated_recordings,on_hook_cid_number,customer_chat_screen_colors,customer_chat_survey_link,customer_chat_survey_text,populate_lead_province,areacode_filter,areacode_filter_seconds,areacode_filter_action,areacode_filter_action_value,populate_state_areacode,inbound_survey,inbound_survey_filename,inbound_survey_accept_digit,inbound_survey_question_filename,inbound_survey_callmenu,icbq_expiration_hours,closing_time_action,closing_time_now_trigger,closing_time_filename,closing_time_end_filename,closing_time_lead_reset,closing_time_option_exten,closing_time_option_callmenu,closing_time_option_voicemail,closing_time_option_xfer_group,closing_time_option_callback_list_id,icbq_call_time_id,add_lead_timezone,icbq_dial_filter,populate_lead_source,populate_lead_vendor,park_file_name,waiting_call_url_on,waiting_call_url_off,enter_ingroup_url,cid_cb_confirm_number,cid_cb_invalid_filter_phone_group,cid_cb_valid_length,cid_cb_valid_filename,cid_cb_confirmed_filename,cid_cb_enter_filename,cid_cb_you_entered_filename,cid_cb_press_to_confirm_filename,cid_cb_invalid_filename,cid_cb_reenter_filename,cid_cb_error_filename,place_in_line_caller_number_filename,place_in_line_you_next_filename,ingroup_script_two,browser_alert_sound,browser_alert_volume,answer_signal,no_agent_delay,agent_search_method,qc_scorecard_id,qc_statuses_id,populate_lead_comments,drop_call_seconds_override,populate_lead_owner,in_queue_nanque,in_queue_nanque_exceptions,custom_one,custom_two,custom_three,custom_four,custom_five,second_alert_trigger,second_alert_trigger_seconds,second_alert_filename,second_alert_delay,second_alert_container,second_alert_only,third_alert_trigger,third_alert_trigger_seconds,third_alert_filename,third_alert_delay,third_alert_container,third_alert_only,agent_search_list,state_descriptions) SELECT \"$group_id\",\"$group_name\",group_color,\"N\",web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,drop_call_seconds,drop_action,drop_exten,call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,default_xfer_group,queue_priority,drop_inbound_group,ingroup_recording_override,ingroup_rec_filename,afterhours_xfer_group,qc_enabled,qc_statuses,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two,default_group_alias,no_agent_no_queue,no_agent_action,no_agent_action_value,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,ignore_list_script_override,extension_appended_cidname,uniqueid_status_display,uniqueid_status_prefix,hold_time_option_minimum,hold_time_option_press_filename,hold_time_option_callmenu,onhold_prompt_no_block,onhold_prompt_seconds,hold_time_option_no_block,hold_time_option_prompt_seconds,hold_time_second_option,hold_time_third_option,wait_hold_option_priority,wait_time_option,wait_time_second_option,wait_time_third_option,wait_time_option_seconds,wait_time_option_exten,wait_time_option_voicemail,wait_time_option_xfer_group,wait_time_option_callmenu,wait_time_option_callback_filename,wait_time_option_callback_list_id,wait_time_option_press_filename,wait_time_option_no_block,wait_time_option_prompt_seconds,timer_action_destination,calculate_estimated_hold_seconds,add_lead_url,eht_minimum_prompt_filename,eht_minimum_prompt_no_block,eht_minimum_prompt_seconds,on_hook_ring_time,na_call_url,on_hook_cid,action_xfer_cid,drop_callmenu,after_hours_callmenu,user_group,max_calls_method,max_calls_count,max_calls_action,dial_ingroup_cid,group_handling,web_form_address_three,populate_lead_ingroup,drop_lead_reset,after_hours_lead_reset,nanq_lead_reset,wait_time_lead_reset,hold_time_lead_reset,status_group_id,routing_initiated_recordings,on_hook_cid_number,customer_chat_screen_colors,customer_chat_survey_link,customer_chat_survey_text,populate_lead_province,areacode_filter,areacode_filter_seconds,areacode_filter_action,areacode_filter_action_value,populate_state_areacode,inbound_survey,inbound_survey_filename,inbound_survey_accept_digit,inbound_survey_question_filename,inbound_survey_callmenu,icbq_expiration_hours,closing_time_action,closing_time_now_trigger,closing_time_filename,closing_time_end_filename,closing_time_lead_reset,closing_time_option_exten,closing_time_option_callmenu,closing_time_option_voicemail,closing_time_option_xfer_group,closing_time_option_callback_list_id,icbq_call_time_id,add_lead_timezone,icbq_dial_filter,populate_lead_source,populate_lead_vendor,park_file_name,waiting_call_url_on,waiting_call_url_off,enter_ingroup_url,cid_cb_confirm_number,cid_cb_invalid_filter_phone_group,cid_cb_valid_length,cid_cb_valid_filename,cid_cb_confirmed_filename,cid_cb_enter_filename,cid_cb_you_entered_filename,cid_cb_press_to_confirm_filename,cid_cb_invalid_filename,cid_cb_reenter_filename,cid_cb_error_filename,place_in_line_caller_number_filename,place_in_line_you_next_filename,ingroup_script_two,browser_alert_sound,browser_alert_volume,answer_signal,no_agent_delay,agent_search_method,qc_scorecard_id,qc_statuses_id,populate_lead_comments,drop_call_seconds_override,populate_lead_owner,in_queue_nanque,in_queue_nanque_exceptions,custom_one,custom_two,custom_three,custom_four,custom_five,second_alert_trigger,second_alert_trigger_seconds,second_alert_filename,second_alert_delay,second_alert_container,second_alert_only,third_alert_trigger,third_alert_trigger_seconds,third_alert_filename,third_alert_delay,third_alert_container,third_alert_only,agent_search_list,state_descriptions from vicidial_inbound_groups where group_id=\"$source_group_id\";";
					$rslt=mysql_to_mysqli($stmt, $link);
					$affected_rows = mysqli_affected_rows($link);

					$stmtA="INSERT INTO vicidial_campaign_stats (campaign_id) values('$group_id');";
					$rslt=mysql_to_mysqli($stmtA, $link);
					$affected_rowsA = mysqli_affected_rows($link);

					$stmtB="INSERT INTO vicidial_campaign_stats_debug (campaign_id) values('$group_id');";
					$rslt=mysql_to_mysqli($stmtB, $link);
					$affected_rowsB = mysqli_affected_rows($link);

					# copy agent ranks and grades from source in-group
					$stmtC="INSERT INTO vicidial_inbound_group_agents (user,group_id,group_rank,group_weight,group_grade,group_web_vars,daily_limit) SELECT user,'$group_id',group_rank,group_weight,group_grade,group_web_vars,daily_limit from vicidial_inbound_group_agents where group_id=\"$source_group_id\";";
					$rslt=mysql_to_mysqli($stmtC, $link);
					$affected_rowsC = mysqli_affected_rows($link);

					# add new in-group to user's agent-selected in-groups
					$SQL_group_id = preg_replace("/_/",'\\_',$group_id);
					$SQL_source_group_id = preg_replace("/_/",'\\_',$source_group_id);
					$stmtD="UPDATE vicidial_users set closer_campaigns=REPLACE( closer_campaigns, ' $source_group_id ', ' $source_group_id $group_id ' ) where closer_campaigns LIKE \"% $SQL_source_group_id %\" and closer_campaigns NOT LIKE \"% $SQL_group_id %\";";
					$rslt=mysql_to_mysqli($stmtD, $link);
					$affected_rowsD = mysqli_affected_rows($link);

					$stmtE="INSERT INTO vicidial_url_multi (entry_type,active,url_type,url_rank,url_statuses,url_description,url_address,url_lists,campaign_id) SELECT entry_type,active,url_type,url_rank,url_statuses,url_description,url_address,url_lists,\"$group_id\" from vicidial_url_multi where campaign_id='$source_group_id';";
					$rslt=mysql_to_mysqli($stmtE, $link);
					$affected_rowsE = mysqli_affected_rows($link);

					echo "<br><B>"._QXZ("EMAIL GROUP ADDED").": $group_id</B>\n";

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$stmt|$stmtA|$stmtB|$stmtC|$stmtD|$stmtE|";
					$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='INGROUPS', event_type='COPY', record_id='$group_id', event_code='ADMIN COPY INBOUND GROUP', event_sql=\"$SQL_log\", event_notes='$affected_rows|$affected_rowsA|$affected_rowsB|$affected_rowsC|$affected_rowsD|$affected_rowsE';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	$ADD=3811;
	}


######################
# ADD=29111 adds copied chat group to the system
######################
if ( ($ADD==29111) and ($SSallow_chats>0) )
	{
	$group_id = preg_replace("/\-/",'',$group_id);
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_inbound_groups' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$group_id = ($row[0] + 1);

			$stmt="UPDATE vicidial_override_ids SET value='$group_id' where id_table='vicidial_inbound_groups' and active='1';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		##### END ID override optional section #####

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$group_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("CHAT GROUP NOT ADDED - there is already a group in the system with this ID")."\n";}
		else
			{
			$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$group_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] > 0)
				{echo "<br>"._QXZ("CHAT GROUP NOT ADDED - there is already a campaign in the system with this ID")."\n";}
			else
				{
				if ( (strlen($group_id) < 2) or (strlen($group_name) < 2) or (mb_strlen($group_id,'utf-8') > 20) or (preg_match('/\s/i',$group_id)) or (preg_match('/\-/i',$group_id)) or (preg_match("/\+/i",$group_id)) )
					{
					echo "<br>"._QXZ("CHAT GROUP NOT ADDED - Please go back and look at the data you entered")."\n";
					echo "<br>"._QXZ("Chat group ID must be between 2 and 20 characters in length and contain no")." ' -+'.\n";
					echo "<br>"._QXZ("Chat group name and group color must be at least 2 characters in length")."\n";
					}
				else
					{
					if ( (!preg_match("/\|$group_color,/i",$HTMLcolors)) and ( (strlen($group_color) > 7) or (strlen($group_color) < 7) or (!preg_match("/^#/",$group_color)) ) )
						{
						if (!preg_match("/^#/",$group_color)) {$group_color = "#$group_color";}
						if (strlen($group_color) > 7) {$group_color = substr($group_color,0,7);}
						while (strlen($group_color) < 7) {$group_color .= '0';}
						}
					$stmt="INSERT INTO vicidial_inbound_groups (group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,drop_call_seconds,drop_action,drop_exten,call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,default_xfer_group,queue_priority,drop_inbound_group,ingroup_recording_override,ingroup_rec_filename,afterhours_xfer_group,qc_enabled,qc_statuses,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two,default_group_alias,no_agent_no_queue,no_agent_action,no_agent_action_value,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,ignore_list_script_override,extension_appended_cidname,uniqueid_status_display,uniqueid_status_prefix,hold_time_option_minimum,hold_time_option_press_filename,hold_time_option_callmenu,onhold_prompt_no_block,onhold_prompt_seconds,hold_time_option_no_block,hold_time_option_prompt_seconds,hold_time_second_option,hold_time_third_option,wait_hold_option_priority,wait_time_option,wait_time_second_option,wait_time_third_option,wait_time_option_seconds,wait_time_option_exten,wait_time_option_voicemail,wait_time_option_xfer_group,wait_time_option_callmenu,wait_time_option_callback_filename,wait_time_option_callback_list_id,wait_time_option_press_filename,wait_time_option_no_block,wait_time_option_prompt_seconds,timer_action_destination,calculate_estimated_hold_seconds,add_lead_url,eht_minimum_prompt_filename,eht_minimum_prompt_no_block,eht_minimum_prompt_seconds,on_hook_ring_time,na_call_url,on_hook_cid,action_xfer_cid,drop_callmenu,after_hours_callmenu,user_group,max_calls_method,max_calls_count,max_calls_action,dial_ingroup_cid,group_handling,web_form_address_three,populate_lead_ingroup,drop_lead_reset,after_hours_lead_reset,nanq_lead_reset,wait_time_lead_reset,hold_time_lead_reset,status_group_id,routing_initiated_recordings,on_hook_cid_number,customer_chat_screen_colors,customer_chat_survey_link,customer_chat_survey_text,populate_lead_province,areacode_filter,areacode_filter_seconds,areacode_filter_action,areacode_filter_action_value,populate_state_areacode,inbound_survey,inbound_survey_filename,inbound_survey_accept_digit,inbound_survey_question_filename,inbound_survey_callmenu,icbq_expiration_hours,closing_time_action,closing_time_now_trigger,closing_time_filename,closing_time_end_filename,closing_time_lead_reset,closing_time_option_exten,closing_time_option_callmenu,closing_time_option_voicemail,closing_time_option_xfer_group,closing_time_option_callback_list_id,icbq_call_time_id,add_lead_timezone,icbq_dial_filter,populate_lead_source,populate_lead_vendor,park_file_name,waiting_call_url_on,waiting_call_url_off,enter_ingroup_url,cid_cb_confirm_number,cid_cb_invalid_filter_phone_group,cid_cb_valid_length,cid_cb_valid_filename,cid_cb_confirmed_filename,cid_cb_enter_filename,cid_cb_you_entered_filename,cid_cb_press_to_confirm_filename,cid_cb_invalid_filename,cid_cb_reenter_filename,cid_cb_error_filename,place_in_line_caller_number_filename,place_in_line_you_next_filename,ingroup_script_two,browser_alert_sound,browser_alert_volume,answer_signal,no_agent_delay,agent_search_method,qc_scorecard_id,qc_statuses_id,populate_lead_comments,drop_call_seconds_override,populate_lead_owner,in_queue_nanque,in_queue_nanque_exceptions,custom_one,custom_two,custom_three,custom_four,custom_five,second_alert_trigger,second_alert_trigger_seconds,second_alert_filename,second_alert_delay,second_alert_container,second_alert_only,third_alert_trigger,third_alert_trigger_seconds,third_alert_filename,third_alert_delay,third_alert_container,third_alert_only,agent_search_list,state_descriptions) SELECT \"$group_id\",\"$group_name\",group_color,\"N\",web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,drop_call_seconds,drop_action,drop_exten,call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,default_xfer_group,queue_priority,drop_inbound_group,ingroup_recording_override,ingroup_rec_filename,afterhours_xfer_group,qc_enabled,qc_statuses,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two,default_group_alias,no_agent_no_queue,no_agent_action,no_agent_action_value,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,ignore_list_script_override,extension_appended_cidname,uniqueid_status_display,uniqueid_status_prefix,hold_time_option_minimum,hold_time_option_press_filename,hold_time_option_callmenu,onhold_prompt_no_block,onhold_prompt_seconds,hold_time_option_no_block,hold_time_option_prompt_seconds,hold_time_second_option,hold_time_third_option,wait_hold_option_priority,wait_time_option,wait_time_second_option,wait_time_third_option,wait_time_option_seconds,wait_time_option_exten,wait_time_option_voicemail,wait_time_option_xfer_group,wait_time_option_callmenu,wait_time_option_callback_filename,wait_time_option_callback_list_id,wait_time_option_press_filename,wait_time_option_no_block,wait_time_option_prompt_seconds,timer_action_destination,calculate_estimated_hold_seconds,add_lead_url,eht_minimum_prompt_filename,eht_minimum_prompt_no_block,eht_minimum_prompt_seconds,on_hook_ring_time,na_call_url,on_hook_cid,action_xfer_cid,drop_callmenu,after_hours_callmenu,user_group,max_calls_method,max_calls_count,max_calls_action,dial_ingroup_cid,group_handling,web_form_address_three,populate_lead_ingroup,drop_lead_reset,after_hours_lead_reset,nanq_lead_reset,wait_time_lead_reset,hold_time_lead_reset,status_group_id,routing_initiated_recordings,on_hook_cid_number,customer_chat_screen_colors,customer_chat_survey_link,customer_chat_survey_text,populate_lead_province,areacode_filter,areacode_filter_seconds,areacode_filter_action,areacode_filter_action_value,populate_state_areacode,inbound_survey,inbound_survey_filename,inbound_survey_accept_digit,inbound_survey_question_filename,inbound_survey_callmenu,icbq_expiration_hours,closing_time_action,closing_time_now_trigger,closing_time_filename,closing_time_end_filename,closing_time_lead_reset,closing_time_option_exten,closing_time_option_callmenu,closing_time_option_voicemail,closing_time_option_xfer_group,closing_time_option_callback_list_id,icbq_call_time_id,add_lead_timezone,icbq_dial_filter,populate_lead_source,populate_lead_vendor,park_file_name,waiting_call_url_on,waiting_call_url_off,enter_ingroup_url,cid_cb_confirm_number,cid_cb_invalid_filter_phone_group,cid_cb_valid_length,cid_cb_valid_filename,cid_cb_confirmed_filename,cid_cb_enter_filename,cid_cb_you_entered_filename,cid_cb_press_to_confirm_filename,cid_cb_invalid_filename,cid_cb_reenter_filename,cid_cb_error_filename,place_in_line_caller_number_filename,place_in_line_you_next_filename,ingroup_script_two,browser_alert_sound,browser_alert_volume,answer_signal,no_agent_delay,agent_search_method,qc_scorecard_id,qc_statuses_id,populate_lead_comments,drop_call_seconds_override,populate_lead_owner,in_queue_nanque,in_queue_nanque_exceptions,custom_one,custom_two,custom_three,custom_four,custom_five,second_alert_trigger,second_alert_trigger_seconds,second_alert_filename,second_alert_delay,second_alert_container,second_alert_only,third_alert_trigger,third_alert_trigger_seconds,third_alert_filename,third_alert_delay,third_alert_container,third_alert_only,agent_search_list,state_descriptions from vicidial_inbound_groups where group_id=\"$source_group_id\";";
					$rslt=mysql_to_mysqli($stmt, $link);
					$affected_rows = mysqli_affected_rows($link);

					$stmtA="INSERT INTO vicidial_campaign_stats (campaign_id) values('$group_id');";
					$rslt=mysql_to_mysqli($stmtA, $link);
					$affected_rowsB = mysqli_affected_rows($link);

					$stmtB="INSERT INTO vicidial_campaign_stats_debug (campaign_id) values('$group_id');";
					$rslt=mysql_to_mysqli($stmtB, $link);
					$affected_rowsC = mysqli_affected_rows($link);

					# copy agent ranks and grades from source in-group
					$stmtC="INSERT INTO vicidial_inbound_group_agents (user,group_id,group_rank,group_weight,group_grade,group_web_vars,daily_limit) SELECT user,'$group_id',group_rank,group_weight,group_grade,group_web_vars,daily_limit from vicidial_inbound_group_agents where group_id=\"$source_group_id\";";
					$rslt=mysql_to_mysqli($stmtC, $link);

					# add new in-group to user's agent-selected in-groups
					$SQL_group_id = preg_replace("/_/",'\\_',$group_id);
					$SQL_source_group_id = preg_replace("/_/",'\\_',$source_group_id);
					$stmtD="UPDATE vicidial_users set closer_campaigns=REPLACE( closer_campaigns, ' $source_group_id ', ' $source_group_id $group_id ' ) where closer_campaigns LIKE \"% $SQL_source_group_id %\" and closer_campaigns NOT LIKE \"% $SQL_group_id %\";";
					$rslt=mysql_to_mysqli($stmtD, $link);
					$affected_rowsD = mysqli_affected_rows($link);

					$stmtE="INSERT INTO vicidial_url_multi (entry_type,active,url_type,url_rank,url_statuses,url_description,url_address,url_lists,campaign_id) SELECT entry_type,active,url_type,url_rank,url_statuses,url_description,url_address,url_lists,\"$group_id\" from vicidial_url_multi where campaign_id='$source_group_id';";
					$rslt=mysql_to_mysqli($stmtE, $link);
					$affected_rowsE = mysqli_affected_rows($link);

					echo "<br><B>CHAT GROUP ADDED: $group_id</B>\n";

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$stmt|$stmtA|$stmtB|$stmtC|$stmtD|$stmtE|";
					$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='INGROUPS', event_type='COPY', record_id='$group_id', event_code='ADMIN COPY INBOUND GROUP', event_sql=\"$SQL_log\", event_notes='$affected_rows|$affected_rowsA|$affected_rowsB|$affected_rowsC|$affected_rowsD|$affected_rowsE';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	$ADD=3911;
	}


######################
# ADD=2311 adds the new did to the system
######################
if ($ADD==2311)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_inbound_dids where did_pattern='$did_pattern';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("DID NOT ADDED - there is already a DID in the system with this ID")."\n";}
		else
			{
			$stmt="SELECT count(*) from vicidial_inbound_dids where did_pattern='$did_pattern';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] > 0)
				{echo "<br>"._QXZ("DID NOT ADDED - there is already a DID in the system with this extension")."\n";}
			else
				{ #  or (preg_match("/\+/i",$did_pattern))
				if ( (strlen($did_pattern) < 2) or (preg_match('/\s/i',$did_pattern)) or (preg_match('/\-/i',$did_pattern)) )
					{
					echo "<br>"._QXZ("DID NOT ADDED - Please go back and look at the data you entered")."\n";
					echo "<br>"._QXZ("DID Extension must be between 2 and 20 characters in length and contain no")." ' -+'.\n";
					}
				else
					{
					$stmtA="INSERT INTO vicidial_inbound_dids (did_pattern,did_description,user_group,filter_phone_group_id,pre_filter_phone_group_id) values('$did_pattern','$did_description','$user_group','','');";
					$rslt=mysql_to_mysqli($stmtA, $link);

					$stmt="SELECT did_id from vicidial_inbound_dids where did_pattern='$did_pattern';";
					$rslt=mysql_to_mysqli($stmt, $link);
					$row=mysqli_fetch_row($rslt);
					$did_id = $row[0];

					echo "<br><B>"._QXZ("DID ADDED").": $did_pattern $did_description    - $did_id</B>\n";

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$stmtA|";
					$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='DIDS', event_type='ADD', record_id='$did_id', event_code='ADMIN ADD DID', event_sql=\"$SQL_log\", event_notes='';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	$ADD=3311;
	}


######################
# ADD=2411 adds copied did to the system
######################
if ($ADD==2411)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_inbound_dids where did_pattern='$did_pattern';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("DID NOT ADDED - there is already a DID in the system with this extension")."\n";}
		else
			{
			if ( (strlen($source_did) < 1) or (strlen($did_pattern) < 1) or (preg_match('/\s/i',$source_did)) or (preg_match('/\s/i',$did_pattern)) or (preg_match("/\+/i",$source_did)) )
				{
				echo "<br>"._QXZ("DID NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("DID Extension must be between 2 and 20 characters in length and contain no")." ' -+'.\n";
				}
			else
				{
				$stmtA="INSERT INTO vicidial_inbound_dids (did_pattern,did_description,did_active,did_route,extension,exten_context,voicemail_ext,phone,server_ip,user,user_unavailable_action,user_route_settings_ingroup,group_id,call_handle_method,agent_search_method,list_id,campaign_id,phone_code,menu_id,record_call,filter_inbound_number,filter_phone_group_id,filter_url,filter_action,filter_extension,filter_exten_context,filter_voicemail_ext,filter_phone,filter_server_ip,filter_user,filter_user_unavailable_action,filter_user_route_settings_ingroup,filter_group_id,filter_call_handle_method,filter_agent_search_method,filter_list_id,filter_campaign_id,filter_phone_code,filter_menu_id,filter_clean_cid_number,custom_one,custom_two,custom_three,custom_four,custom_five,user_group,filter_dnc_campaign,filter_url_did_redirect,no_agent_ingroup_redirect,no_agent_ingroup_id,no_agent_ingroup_extension,pre_filter_phone_group_id,pre_filter_extension,entry_list_id,filter_entry_list_id,max_queue_ingroup_calls,max_queue_ingroup_id,max_queue_ingroup_extension,did_carrier_description,inbound_route_answer,pre_filter_recent_call,pre_filter_recent_extension) SELECT \"$did_pattern\",\"$did_description\",did_active,did_route,extension,exten_context,voicemail_ext,phone,server_ip,user,user_unavailable_action,user_route_settings_ingroup,group_id,call_handle_method,agent_search_method,list_id,campaign_id,phone_code,menu_id,record_call,filter_inbound_number,filter_phone_group_id,filter_url,filter_action,filter_extension,filter_exten_context,filter_voicemail_ext,filter_phone,filter_server_ip,filter_user,filter_user_unavailable_action,filter_user_route_settings_ingroup,filter_group_id,filter_call_handle_method,filter_agent_search_method,filter_list_id,filter_campaign_id,filter_phone_code,filter_menu_id,filter_clean_cid_number,custom_one,custom_two,custom_three,custom_four,custom_five,user_group,filter_dnc_campaign,filter_url_did_redirect,no_agent_ingroup_redirect,no_agent_ingroup_id,no_agent_ingroup_extension,pre_filter_phone_group_id,pre_filter_extension,entry_list_id,filter_entry_list_id,max_queue_ingroup_calls,max_queue_ingroup_id,max_queue_ingroup_extension,did_carrier_description,inbound_route_answer,pre_filter_recent_call,pre_filter_recent_extension from vicidial_inbound_dids where did_id=\"$source_did\";";
				$rslt=mysql_to_mysqli($stmtA, $link);

				$stmt="SELECT did_id from vicidial_inbound_dids where did_pattern='$did_pattern';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				$did_id = $row[0];

				echo "<br><B>"._QXZ("DID ADDED").": $did_pattern     - $did_id</B>\n";

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmtA|";
				$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='DIDS', event_type='COPY', record_id='$did_id', event_code='ADMIN COPY DID', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=3311;
	}


######################
# ADD=2511 adds the new call menu to the system
######################
if ($ADD==2511)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_call_menu' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$menu_id = ($row[0] + 1);

			$stmt="UPDATE vicidial_override_ids SET value='$menu_id' where id_table='vicidial_call_menu' and active='1';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		##### END ID override optional section #####

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_call_menu where menu_id='$menu_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{
			echo "<br>"._QXZ("CALL MENU NOT ADDED - there is already a CALL MENU in the system with this ID")."\n";
			$ADD=1500;
			}
		else
			{
			if ( (preg_match("/^vicidial$/i",$menu_id)) or (preg_match("/^vicidial-auto$/i",$menu_id)) or (preg_match("/^general$/i",$menu_id)) or (preg_match("/^globals$/i",$menu_id)) or (preg_match("/^default$/i",$menu_id)) or (preg_match("/^trunkinbound$/i",$menu_id)) or (preg_match("/^loopback-no-log$/i",$menu_id)) or (preg_match("/^monitor_exit$/i",$menu_id)) or (preg_match("/^monitor$/i",$menu_id)) )
				{
				echo "<br>"._QXZ("CALL MENU NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("Call Menu ID cannot use reserved words").": vicidial, vicidial-auto, general, globals, default, trunkinbound, loopback-no-log, monitor_exit, monitor\n";
				$ADD=1500;
				}
			else
				{
				if ( (strlen($menu_id) < 2) or (preg_match('/\s/i',$menu_id)) )
					{
					echo "<br>"._QXZ("CALL MENU NOT ADDED - Please go back and look at the data you entered")."\n";
					echo "<br>"._QXZ("Call Menu ID must be between 2 and 50 characters in length and contain no").".\n";
					$ADD=1500;
					}
				else
					{
					$stmt="INSERT INTO vicidial_call_menu (menu_id,menu_name,user_group) values('$menu_id','$menu_name','$user_group');";
					$rslt=mysql_to_mysqli($stmt, $link);

					echo "<br><B>"._QXZ("CALL MENU ADDED").": $menu_id $menu_name</B>\n";

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$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='CALLMENUS', event_type='ADD', record_id='$menu_id', event_code='ADMIN ADD CALL MENU', event_sql=\"$SQL_log\", event_notes='';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);

					$ADD=3511;
					}
				}
			}
		}
	}


######################
# ADD=2611 adds copied call menu to the system
######################
if ($ADD==2611)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_call_menu' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$menu_id = ($row[0] + 1);

			$stmt="UPDATE vicidial_override_ids SET value='$menu_id' where id_table='vicidial_call_menu' and active='1';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		##### END ID override optional section #####

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_call_menu where menu_id='$menu_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{
			echo "<br>"._QXZ("CALL MENU NOT ADDED - there is already a CALL MENU in the system with this ID")."\n";
			$ADD=1500;
			}
		else
			{
			if ( (preg_match("/^vicidial$/i",$menu_id)) or (preg_match("/^vicidial-auto$/i",$menu_id)) or (preg_match("/^general$/i",$menu_id)) or (preg_match("/^globals$/i",$menu_id)) or (preg_match("/^default$/i",$menu_id)) or (preg_match("/^trunkinbound$/i",$menu_id)) or (preg_match("/^loopback-no-log$/i",$menu_id)) or (preg_match("/^monitor_exit$/i",$menu_id)) or (preg_match("/^monitor$/i",$menu_id)) )
				{
				echo "<br>"._QXZ("CALL MENU NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("Call Menu ID cannot use reserved words").": vicidial, vicidial-auto, general, globals, default, trunkinbound, loopback-no-log, monitor_exit, monitor\n";
				$ADD=1500;
				}
			else
				{
				if ( (strlen($menu_id) < 2) or (preg_match('/\s/i',$menu_id)) or  (strlen($source_menu) < 2) or (preg_match('/\s/i',$source_menu)) )
					{
					echo "<br>"._QXZ("CALL MENU NOT ADDED - Please go back and look at the data you entered")."\n";
					echo "<br>"._QXZ("Call Menu ID must be between 2 and 50 characters in length and contain no")." ' '.\n";
					$ADD=1500;
					}
				else
					{
					$stmt="INSERT INTO vicidial_call_menu (menu_id,menu_name,menu_prompt,menu_timeout,menu_timeout_prompt,menu_invalid_prompt,menu_repeat,menu_time_check,call_time_id,track_in_vdac,custom_dialplan_entry,tracking_group,dtmf_log,dtmf_field,user_group,qualify_sql,alt_dtmf_log,question,answer_signal) SELECT \"$menu_id\",\"$menu_name\",menu_prompt,menu_timeout,menu_timeout_prompt,menu_invalid_prompt,menu_repeat,menu_time_check,call_time_id,track_in_vdac,custom_dialplan_entry,tracking_group,dtmf_log,dtmf_field,user_group,qualify_sql,alt_dtmf_log,question,answer_signal from vicidial_call_menu where menu_id=\"$source_menu\";";
					$rslt=mysql_to_mysqli($stmt, $link);

					$stmtA="INSERT INTO vicidial_call_menu_options (menu_id,option_value,option_description,option_route,option_route_value,option_route_value_context) SELECT \"$menu_id\",option_value,option_description,option_route,option_route_value,option_route_value_context from vicidial_call_menu_options where menu_id='$source_menu';";
					$rslt=mysql_to_mysqli($stmtA, $link);

					echo "<br><B>"._QXZ("CALL MENU ADDED").": $menu_id     - $menu_name</B>\n";

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$stmt|$stmtA";
					$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='CALLMENUS', event_type='COPY', record_id='$menu_id', event_code='ADMIN COPY MENU', event_sql=\"$SQL_log\", event_notes='';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);

					$ADD=3511;
					}
				}
			}
		}
	}


######################
# ADD=2711 adds the new filter phone group to the system
######################
if ($ADD==2711)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_filter_phone_groups where filter_phone_group_id='$filter_phone_group_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("PHONE FILTER GROUP NOT ADDED - there is already a PHONE FILTER GROUP in the system with this ID")."\n";}
		else
			{
			if ( (strlen($filter_phone_group_id) < 2) or (mb_strlen($filter_phone_group_id,'utf-8') > 20) or (preg_match('/\s/i',$filter_phone_group_id)) )
				{
				echo "<br>"._QXZ("PHONE FILTER GROUP NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("Phone Filter Group ID must be between 2 and 20 characters in length and contain no")." ' '.\n";
				}
			else
				{
				$stmt="INSERT INTO vicidial_filter_phone_groups (filter_phone_group_id,filter_phone_group_name,filter_phone_group_description,user_group) values('$filter_phone_group_id','$filter_phone_group_name','$filter_phone_group_description','$user_group');";
				$rslt=mysql_to_mysqli($stmt, $link);

				echo "<br><B>"._QXZ("PHONE FILTER GROUP ADDED").": $filter_phone_group_id $filter_phone_group_name</B>\n";

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='FILTERPHONEGROUPS', event_type='ADD', record_id='$filter_phone_group_id', event_code='ADMIN ADD FILTER PHONE GROUP', event_sql=\"$SQL_log\", event_notes='$filter_phone_group_name';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=3711;
	}


######################
# ADD=21111 adds new remote agents to the system
######################
if ($ADD==21111)
	{
	if ( ($add_copy_disabled > 0) or ($LOGmodify_remoteagents!='1') or ($x_ra_carrier > 0) )
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_remote_agents where server_ip='$server_ip' and user_start='$user_start';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("REMOTE AGENTS NOT ADDED - there is already a remote agents entry starting with this user ID")."\n";}
		else
			{
			### check for a valid user that will be associated with this account
			$stmt="SELECT count(*) from vicidial_users where user='$user_start' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] < 1)
				{echo "<br>"._QXZ("REMOTE AGENTS NOT ADDED - you must use a valid user as the user_start for remote agents")."\n";}
			else
				{
				### check for closest remote agents to this account to ensure no overlapping
				$user_finish = ($user_start + $number_of_lines);
				$stmt="SELECT count(*) from vicidial_remote_agents where user_start >= '$user_start' and user_start < '$user_finish';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				if ($row[0] > 0)
					{echo "<br>"._QXZ("REMOTE AGENTS NOT ADDED - your number of lines overlaps with another remote agent")."\n";}
				else
					{
					if ( (strlen($server_ip) < 2) or (strlen($user_start) < 2)  or (strlen($campaign_id) < 2) or (strlen($conf_exten) < 2) )
						{
						echo "<br>"._QXZ("REMOTE AGENTS NOT ADDED - Please go back and look at the data you entered")."\n";
						echo "<br>"._QXZ("User ID start and external extension must be at least 2 characters in length")."\n";
						}
					else
						{
						$stmt="INSERT INTO vicidial_remote_agents (user_start,number_of_lines,server_ip,conf_exten,status,campaign_id,closer_campaigns) values('$user_start','$number_of_lines','$server_ip','$conf_exten','$status','$campaign_id','$groups_value');";
						$rslt=mysql_to_mysqli($stmt, $link);

						echo "<br><B>"._QXZ("REMOTE AGENTS ADDED").": $user_start</B>\n";

						### LOG INSERTION Admin Log Table ###
						$SQL_log = "$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='REMOTEAGENTS', event_type='ADD', record_id='$user_start', event_code='ADMIN ADD REMOTE AGENT', event_sql=\"$SQL_log\", event_notes='';";
						if ($DB) {echo "|$stmt|\n";}
						$rslt=mysql_to_mysqli($stmt, $link);
						}
					}
				}
			}
		}
	$ADD=10000;
	}


######################
# ADD=22111 adds new extension group entry to the system
######################
if ($ADD==22111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_extension_groups where extension_group_id='$extension_group_id' and extension='$extension';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("EXTENSION GROUP ENTRY NOT ADDED - there is already an extension group entry with these values")."\n";}
		else
			{
			if ( (strlen($extension_group_id) < 2) or (strlen($extension) < 2)  or (strlen($rank) < 1) )
				{
				echo "<br>"._QXZ("EXTENSION GROUP ENTRY NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("extension group id and extension and rank must be at least 2 characters in length")."\n";
				}
			else
				{
				$stmtA="INSERT INTO vicidial_extension_groups (extension_group_id,extension,rank,campaign_groups) values('$extension_group_id','$extension','$rank','$campaign_groups');";
				$rslt=mysql_to_mysqli($stmtA, $link);

				$stmt="SELECT extension_id from vicidial_extension_groups where extension_group_id='$extension_group_id' and extension='$extension';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				$extension_id = $row[0];

				echo "<br><B>"._QXZ("EXTENSION GROUP ENTRY ADDED").": $extension_id - $extension_group_id - $extension</B>\n";

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmtA|";
				$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='EXTENGROUP', event_type='ADD', record_id='$extension_id', event_code='ADMIN ADD EXTENSION GROUP', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=12000;
	}


######################
# ADD=211111 adds new user group to the system
######################
if ($ADD==211111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_user_groups' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$user_group = ($row[0] + 1);

			$stmt="UPDATE vicidial_override_ids SET value='$user_group' where id_table='vicidial_user_groups' and active='1';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		##### END ID override optional section #####

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_user_groups where user_group='$user_group';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("USER GROUP NOT ADDED - there is already a user group entry with this name")."\n";}
		else
			{
			if ( (strlen($user_group) < 2) or (strlen($group_name) < 2) )
				{
				echo "<br>"._QXZ("USER GROUP NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("Group name and description must be at least 2 characters in length")."\n";
				}
			else
				{
				$allowed_user_group_insert_SQL = '---ALL---';
				$allowed_campaign_insert_SQL = '-ALL-CAMPAIGNS-';
				# if admin user's user group does not have --ALL-- then add this new user group to their user group's allowable user groups
				if ($admin_viewable_groupsALL < 1)
					{
					$UPDATEadmin_viewable_groups =	$LOGadmin_viewable_groups;
					$UPDATEadmin_viewable_groups = preg_replace("/ $/"," $user_group ",$UPDATEadmin_viewable_groups);
					$LOGadmin_viewable_groups = $UPDATEadmin_viewable_groups;

					$stmt="UPDATE vicidial_user_groups SET admin_viewable_groups='$UPDATEadmin_viewable_groups' where user_group='$LOGuser_group';";
					$rslt=mysql_to_mysqli($stmt, $link);

					$allowed_user_group_insert_SQL = " $user_group -";

					$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')";
					}
				if ( (!preg_match('/\-ALL/i', $LOGallowed_campaigns)) )
					{
					$allowed_campaign_insert_SQL = $LOGallowed_campaigns;
					}

				$stmt="INSERT INTO vicidial_user_groups(user_group,group_name,allowed_campaigns,admin_viewable_groups,allowed_queue_groups) values('$user_group','$group_name','$allowed_campaign_insert_SQL','$allowed_user_group_insert_SQL','-ALL-GROUPS-');";
				$rslt=mysql_to_mysqli($stmt, $link);

				echo "<br><B>"._QXZ("USER GROUP ADDED").": $user_group</B>\n";

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='USERGROUPS', event_type='ADD', record_id='$user_group', event_code='ADMIN ADD USER GROUP', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);

				###############################################################
				##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP #####
				$stmt = "SELECT enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url FROM system_settings;";
				$rslt=mysql_to_mysqli($stmt, $link);
				if ($DB) {echo "$stmt\n";}
				$ss_conf_ct = mysqli_num_rows($rslt);
				if ($ss_conf_ct > 0)
					{
					$row=mysqli_fetch_row($rslt);
					$enable_vtiger_integration =	$row[0];
					$vtiger_server_ip	=			$row[1];
					$vtiger_dbname =				$row[2];
					$vtiger_login =					$row[3];
					$vtiger_pass =					$row[4];
					$vtiger_url =					$row[5];
					}
				##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP #####
				#############################################################

				if ($enable_vtiger_integration > 0)
					{
					### connect to your vtiger database
					#$linkV=mysql_connect("$vtiger_server_ip", "$vtiger_login","$vtiger_pass");
					#if (!$linkV) {die("Could not connect: $vtiger_server_ip|$vtiger_dbname|$vtiger_login|$vtiger_pass" . mysqli_error());}
					#echo 'Connected successfully';
					#mysql_select_db("$vtiger_dbname", $linkV);
					$linkV=mysqli_connect("$vtiger_server_ip", "$vtiger_login", "$vtiger_pass", "$vtiger_dbname");
					if (!$linkV) 
						{
						die('MySQL '._QXZ("connect ERROR").': ' . mysqli_connect_error());
						}


					######################################
					##### BEGIN Add/Update group info in Vtiger
					$stmt="SELECT count(*) from vtiger_groups where groupname='$user_group';";
					$rslt=mysql_to_mysqli($stmt, $linkV);
					if ($DB) {echo "$stmt\n";}
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
					$row=mysqli_fetch_row($rslt);
					$group_found_count = $row[0];

					### group exists in vtiger, update it
					if ($group_found_count > 0)
						{
						$stmt="SELECT groupid from vtiger_groups where groupname='$user_group';";
						$rslt=mysql_to_mysqli($stmt, $linkV);
						if ($DB) {echo "$stmt\n";}
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
						$row=mysqli_fetch_row($rslt);
						$groupid = $row[0];
						}

					### user doesn't exist in vtiger, insert it
					else
						{
						#### BEGIN CREATE NEW GROUP RECORD IN VTIGER
						# Get next available id from vtiger_users_seq to use as groupid
						$stmt="SELECT id from vtiger_users_seq;";
						if ($DB) {echo "$stmt\n";}
						$rslt=mysql_to_mysqli($stmt, $linkV);
						$row=mysqli_fetch_row($rslt);
						$groupid = ($row[0] + 1);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						# Increase next available groupid with 1 so next record gets proper id
						$stmt="UPDATE vtiger_users_seq SET id = '$groupid';";
						if ($DB) {echo "$stmt\n";}
						$rslt=mysql_to_mysqli($stmt, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						$stmtA = "INSERT INTO vtiger_groups SET groupid='$groupid',groupname='$user_group',description='$group_name';";
						if ($DB) {echo "|$stmtA|\n";}
						$rslt=mysql_to_mysqli($stmtA, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						#### END CREATE NEW GROUP RECORD IN VTIGER
						}
					##### END Add/Update group info in Vtiger
					######################################
					}
				}
			}
		}
	$ADD=100000;
	}


######################
# ADD=2111111 adds new script to the system
######################
if ($ADD==2111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_scripts' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$script_id = ($row[0] + 1);

			$stmt="UPDATE vicidial_override_ids SET value='$script_id' where id_table='vicidial_scripts' and active='1';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		##### END ID override optional section #####

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_scripts where script_id='$script_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("SCRIPT NOT ADDED - there is already a script entry with this name")."\n";}
		else
			{
			if ( (strlen($script_id) < 2) or (strlen($script_name) < 2) or (strlen($script_text) < 2) )
				{
				echo "<br>"._QXZ("SCRIPT NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("Script name, description and text must be at least 2 characters in length")."\n";
				}
			else
				{
				if ( (!preg_match("/\|$script_color,/i",$HTMLcolors)) and (strlen($script_color) > 0) and ( (strlen($script_color) > 7) or (strlen($script_color) < 7) or (!preg_match("/^#/",$script_color)) ) )
					{
					if (!preg_match("/^#/",$script_color)) {$script_color = "#$script_color";}
					if (strlen($script_color) > 7) {$script_color = substr($rowx[1],0,7);}
					while (strlen($script_color) < 7) {$script_color .= '0';}
					}
				$stmt="INSERT INTO vicidial_scripts(script_id, script_name, script_comments, script_text, active, user_group, script_color) values('$script_id','$script_name','$script_comments','" . mysqli_real_escape_string($link, $script_text) . "','$active','$user_group','');";
				$rslt=mysql_to_mysqli($stmt, $link);
				if ($DB > 0) {echo "|$stmt|";}
				echo "<br><B>"._QXZ("SCRIPT ADDED").": $script_id</B>\n";

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='SCRIPTS', event_type='ADD', record_id='$script_id', event_code='ADMIN ADD SCRIPT', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=1000000;
	}


######################
# ADD=21111111 adds new filter to the system
######################
if ($ADD==21111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_lead_filters' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$lead_filter_id = ($row[0] + 1);

			$stmt="UPDATE vicidial_override_ids SET value='$lead_filter_id' where id_table='vicidial_lead_filters' and active='1';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		##### END ID override optional section #####

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_lead_filters where lead_filter_id='$lead_filter_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("FILTER NOT ADDED - there is already a filter entry with this ID")."\n";}
		else
			{
			if ( (strlen($lead_filter_id) < 2) or (strlen($lead_filter_name) < 2) or (strlen($lead_filter_sql) < 2) )
				{
				echo "<br>"._QXZ("FILTER NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("Filter ID, name and SQL must be at least 2 characters in length")."\n";
				}
			else
				{
				$stmt="INSERT INTO vicidial_lead_filters SET lead_filter_id='$lead_filter_id',lead_filter_name='$lead_filter_name',user_group='$user_group',lead_filter_comments='$lead_filter_comments',lead_filter_sql='" . mysqli_real_escape_string($link, $lead_filter_sql) . "';";
				$rslt=mysql_to_mysqli($stmt, $link);

				if ($DB > 0) {echo "|$stmt|";}
				echo "<br><B>"._QXZ("FILTER ADDED").": $lead_filter_id</B>\n";

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='FILTERS', event_type='ADD', record_id='$lead_filter_id', event_code='ADMIN ADD FILTER', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=10000000;
	}


######################
# ADD=211111111 adds new call time definition to the system
######################
if ($ADD==211111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_call_times where call_time_id='$call_time_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("CALL TIME DEFINITION NOT ADDED - there is already a call time entry with this ID")."\n";}
		else
			{
			if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) or ($call_time_id == 'campaign') )
				{
				echo "<br>"._QXZ("CALL TIME DEFINITION NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("Call Time ID and name must be at least 2 characters in length")."\n";
				}
			else
				{
				$stmt="INSERT INTO vicidial_call_times SET call_time_id='$call_time_id',call_time_name='$call_time_name',call_time_comments='$call_time_comments',user_group='$user_group',ct_state_call_times='',ct_holidays='';";
				$rslt=mysql_to_mysqli($stmt, $link);
				if ($DB > 0) {echo "|$stmt|";}

				echo "<br><B>"._QXZ("CALL TIME ADDED").": $call_time_id</B>\n";

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='CALLTIMES', event_type='ADD', record_id='$call_time_id', event_code='ADMIN ADD CALL TIME', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=311111111;
	}


######################
# ADD=2111111111 adds new state call time definition to the system
######################
if ($ADD==2111111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_state_call_times where state_call_time_id='$call_time_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("STATE CALL TIME DEFINITION NOT ADDED - there is already a call time entry with this ID")."\n";}
		else
			{
			if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) or (strlen($state_call_time_state) < 2) )
				{
				echo "<br>"._QXZ("STATE CALL TIME DEFINITION NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("State Call Time ID, name and state must be at least 2 characters in length")."\n";
				}
			else
				{
				$stmt="INSERT INTO vicidial_state_call_times SET state_call_time_id='$call_time_id',state_call_time_name='$call_time_name',state_call_time_comments='$call_time_comments',state_call_time_state='$state_call_time_state',user_group='$user_group';";
				$rslt=mysql_to_mysqli($stmt, $link);
				if ($DB > 0) {echo "|$stmt|";}

				echo "<br><B>"._QXZ("STATE CALL TIME ADDED").": $call_time_id</B>\n";

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='CALLTIMES_STATE', event_type='ADD', record_id='$call_time_id', event_code='ADMIN ADD STATE CALL TIME', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=3111111111;
	}


######################
# ADD=2211111111 adds new holiday definition to the system
######################
if ($ADD==2211111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_call_time_holidays where holiday_id='$holiday_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("HOLIDAY DEFINITION NOT ADDED - there is already a holiday entry with this ID")."\n";}
		else
			{
			if ( (strlen($holiday_id) < 2) or (strlen($holiday_name) < 2) or (strlen($holiday_date) < 10) )
				{
				echo "<br>"._QXZ("HOLIDAY DEFINITION NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("Holiday ID, name and date must be populated")."\n";
				}
			else
				{
				$stmt="INSERT INTO vicidial_call_time_holidays SET holiday_id='$holiday_id',holiday_name='$holiday_name',holiday_comments='$holiday_comments',holiday_date='$holiday_date',holiday_status='INACTIVE',user_group='$user_group';";
				$rslt=mysql_to_mysqli($stmt, $link);
				if ($DB > 0) {echo "|$stmt|";}

				echo "<br><B>"._QXZ("HOLIDAY ADDED").": $holiday_id</B>\n";

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='HOLIDAYS', event_type='ADD', record_id='$holiday_id', event_code='ADMIN ADD HOLIDAY', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=3211111111;
	}


######################
# ADD=231111111 adds new shift definition to the system
######################
if ($ADD==231111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_shifts' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$shift_id = ($row[0] + 1);

			$stmt="UPDATE vicidial_override_ids SET value='$shift_id' where id_table='vicidial_shifts' and active='1';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		##### END ID override optional section #####

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_shifts where shift_id='$shift_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("SHIFT DEFINITION NOT ADDED - there is already a shift entry with this ID")."\n";}
		else if (!is_array($shift_weekdays))
			{echo "<br>"._QXZ("SHIFT DEFINITION NOT ADDED - you have to select at least one weekday")."\n";}
		else
			{
			$shift_length_test = preg_replace('/:/i', '',$shift_length);
			if ( (strlen($shift_id) < 2) or (strlen($shift_name) < 2) or (strlen($shift_start_time) < 4) or (strlen($shift_start_time) > 4) or (strlen($shift_length) < 5) or (strlen($shift_length) > 5) or ($shift_start_time > 2359) or ($shift_length_test > 2400) )
				{
				echo "<br>"._QXZ("SHIFT DEFINITION NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("Shift ID and name must be at least 2 characters in length")."\n";
				echo "<br>"._QXZ("Shift Start Time must be 4 digits in length and be a valid time")."\n";
				echo "<br>"._QXZ("Shift Length must be 5 characters in length and be 24 hours or less")."\n";
				}
			else
				{
				$p=0;
				$shift_weekdays_ct = count($shift_weekdays);
				while ($p <= $shift_weekdays_ct)
					{
					$SHIFT_weekdays .= "$shift_weekdays[$p]";
					$p++;
					}
				$SHIFT_weekdays = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$SHIFT_weekdays);
				$stmt="INSERT INTO vicidial_shifts SET shift_id='$shift_id',shift_name='$shift_name',shift_start_time='$shift_start_time',shift_length='$shift_length',report_option='$report_option',shift_weekdays='$SHIFT_weekdays',user_group='$user_group';";
				$rslt=mysql_to_mysqli($stmt, $link);
				if ($DB > 0) {echo "|$stmt|";}

				echo "<br><B>"._QXZ("SHIFT ADDED").": $shift_id</B>\n";

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='SHIFTS', event_type='ADD', record_id='$shift_id', event_code='ADMIN ADD SHIFT', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=331111111;
	}


######################
# ADD=21111111111 adds new phone to the system
######################
if ($ADD==21111111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value #####
		$stmt = "SELECT value FROM vicidial_override_ids where id_table='phones' and active='1';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$voi_ct = mysqli_num_rows($rslt);
		if ($voi_ct > 0)
			{
			$row=mysqli_fetch_row($rslt);
			$extension = ($row[0] + 1);

			$stmt="UPDATE vicidial_override_ids SET value='$extension' where id_table='phones' and active='1';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		##### END ID override optional section #####

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from phones where extension='$extension' and server_ip='$server_ip';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("PHONE NOT ADDED - there is already a Phone in the system with this extension/server")."\n";}
		else
			{
			$stmt="SELECT count(*) from phones where login='$login';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] > 0)
				{echo "<br>"._QXZ("PHONE NOT ADDED - there is already a Phone in the system with this login")."\n";}
			else
				{
				$stmt="SELECT count(*) from phones_alias where alias_id='$login';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				if ($row[0] > 0)
					{echo "<br>"._QXZ("PHONE NOT ADDED - there is already a Phone alias in the system with this login")."\n";}
				else
					{
					$stmt="SELECT count(*) from vicidial_voicemail where voicemail_id='$voicemail_id';";
					$rslt=mysql_to_mysqli($stmt, $link);
					$row=mysqli_fetch_row($rslt);
					if ($row[0] > 0)
						{echo "<br>"._QXZ("PHONE NOT ADDED - there is already a Voicemail ID in the system with this ID")."\n";}
					else
						{
						if ( (strlen($extension) < 1) or (strlen($server_ip) < 7) or (strlen($dialplan_number) < 1) or (strlen($voicemail_id) < 1) or (strlen($login) < 1)  or (strlen($pass) < 1) or ( ($SSrequire_password_length > 0) and ($SSrequire_password_length > strlen($conf_secret)) ))
							{
							echo "<br>"._QXZ("PHONE NOT ADDED - Please go back and look at the data you entered")."\n";
							echo "<br>"._QXZ("The following fields must have data").": extension, server_ip, dialplan_number, voicemail_id, login, pass\n";
							if ($SSrequire_password_length > 0)
								{
								echo "<br>"._QXZ("registration password must be at least $SSrequire_password_length characters long")."\n";
								}
							}
						else
							{
							echo "<br>"._QXZ("PHONE ADDED")."\n";

							##### Lookup settings container #####
							$SScontainer_stmt="select phone_defaults_container from system_settings limit 1";
							$SScontainer_rslt=mysql_to_mysqli($SScontainer_stmt, $link);
							$SScontainer_row=mysqli_fetch_row($SScontainer_rslt);
							$dps=array("voicemail_timezone" => "$SSdefault_voicemail_timezone"); # Default phone setting array, need to set voicemail timezone here due to system settings

							# Below settings were pre-set at the initial page, so we remove them here so the settings don't overwrite anything the user may have modified.
							$settings_to_purge=array("active", "local_gmt", "conf_secret", "outbound_cid", "pass", "phone_type", "protocol", "server_ip", "status", "voicemail_id", "user_group");
							if (!preg_match('/\-\-\-DISABLED\-\-\-/', $SScontainer_row[0]))
								{
								$container_stmt="select container_entry from vicidial_settings_containers where container_id='$SScontainer_row[0]'";
								$container_rslt=mysql_to_mysqli($container_stmt, $link);
								$container_entry="";
								if (mysqli_num_rows($container_rslt)>0)
									{
									# echo "Using container $SScontainer_row[0]...<BR>\n";
									$container_row=mysqli_fetch_row($container_rslt);
									$container_entry=$container_row[0];
									$container_entry_array=explode("\n", $container_entry);
									for ($c=0; $c<count($container_entry_array); $c++)
										{
										$container_line=trim($container_entry_array[$c]);
										if (!preg_match('/^\#/', $container_line))
											{
											$current_setting_array=explode("=>", $container_line);
											$setting_key=trim($current_setting_array[0]);
											$setting_value=trim($current_setting_array[1]);

											if (strlen($setting_key)>0 && (strlen($setting_value)>0 || $setting_key=="conf_override") && !in_array($setting_key, $settings_to_purge))
												{
												if($setting_key=="conf_override")
													{
													$conf_override_on=1;
													$conf_override_str=$setting_value;
													}
												else
													{
													if ($conf_override_on==1)
														{
														$conf_override_on=0;
														$dps["conf_override"]=trim($conf_override_str);
														}
													$dps[$setting_key]=$setting_value;
													}
												# $$current_setting_array[0]=$current_setting_array[1];
												}
											else if ($conf_override_on==1)
												{
												$conf_override_str.="\n".trim($container_line);
												}
											} 
										else
											{
											if ($conf_override_on==1)
												{
												$dps["conf_override"]=trim($conf_override_str);
												}
											$conf_override_on=0;
											}
										}
									}
								
								# Compile additional SQL to insert into phones
								foreach($dps as $field_name => $field_val)
									{
									$SQLfields.=",$field_name";
									$SQLvalues.=",'".mysqli_real_escape_string($link, $field_val)."'";
									}
								}

							$stmt="INSERT INTO phones (extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,protocol,local_gmt,outbound_cid,conf_secret,user_group,template_id$SQLfields) values('$extension','$dialplan_number','$voicemail_id','$phone_ip','$computer_ip','$server_ip','$login','$pass','$status','$active','$phone_type','$fullname','$company','$picture','$protocol','$local_gmt','$outbound_cid','$conf_secret','$user_group',''$SQLvalues);";
							#print_r($dps);
							#echo "$stmt<BR>"; die;
							$rslt=mysql_to_mysqli($stmt, $link);

							$stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';";
							$rslt=mysql_to_mysqli($stmtA, $link);

							$stmtB="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$SSactive_voicemail_server';";
							$rslt=mysql_to_mysqli($stmtB, $link);

							### LOG INSERTION Admin Log Table ###
							$SQL_log = "$stmt|$stmtA|$stmtB|";
							$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='PHONES', event_type='ADD', record_id='$extension', event_code='ADMIN ADD PHONE', event_sql=\"$SQL_log\", event_notes='';";
							if ($DB) {echo "|$stmt|\n";}
							$rslt=mysql_to_mysqli($stmt, $link);
							}
						}
					}
				}
			}
		}
	$ADD=31111111111;
	}


######################
# ADD=22111111111 adds new phone alias to the system
######################
if ($ADD==22111111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from phones_alias where alias_id='$alias_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("PHONE ALIAS NOT ADDED - there is already a Phone Alias in the system with this ID")."\n";}
		else
			{
			$stmt="SELECT count(*) from phones where login='$alias_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] > 0)
				{echo "<br>"._QXZ("PHONE ALIAS NOT ADDED - there is already a Phone Login in the system with this ID")."\n";}
			else
				{
				if ( (strlen($alias_id) < 1) or (strlen($alias_name) < 2) )
					{echo "<br>"._QXZ("PHONE ALIAS NOT ADDED - Please go back and look at the data you entered")."\n";}
				else
					{
					echo "<br>"._QXZ("PHONE ALIAS ADDED")."\n";

					$stmt="INSERT INTO phones_alias (alias_id,alias_name,logins_list,user_group) values('$alias_id','$alias_name','$logins_list','$user_group');";
					$rslt=mysql_to_mysqli($stmt, $link);

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$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='PHONEALIASES', event_type='ADD', record_id='$alias_id', event_code='ADMIN ADD PHONE ALIAS', event_sql=\"$SQL_log\", event_notes='';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	$ADD=32111111111;
	}


######################
# ADD=23111111111 adds new group alias to the system
######################
if ($ADD==23111111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from groups_alias where group_alias_id='$group_alias_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("GROUP ALIAS NOT ADDED - there is already a Phone Alias in the system with this ID")."\n";}
		else
			{
			if (preg_match("/AGENT_PHONE|CUSTOMER|CAMPAIGN|NONE/",$group_alias_id))
				{echo "<br>"._QXZ("GROUP ALIAS NOT ADDED - you cannot use reserved words in group aliases")."\n";}
			else
				{
				if ( (strlen($group_alias_id) < 1) or (strlen($group_alias_name) < 2) )
					{echo "<br>"._QXZ("GROUP ALIAS NOT ADDED - Please go back and look at the data you entered")."\n";}
				else
					{
					echo "<br>"._QXZ("GROUP ALIAS ADDED")."\n";

					$stmt="INSERT INTO groups_alias (group_alias_id,group_alias_name,caller_id_number,caller_id_name,active,user_group) values('$group_alias_id','$group_alias_name','$caller_id_number','$caller_id_name','$active','$user_group');";
					$rslt=mysql_to_mysqli($stmt, $link);

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$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='GROUPALIASES', event_type='ADD', record_id='$group_alias_id', event_code='ADMIN ADD GROUP ALIAS', event_sql=\"$SQL_log\", event_notes='';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	$ADD=33111111111;
	}


######################
# ADD=211111111111 adds new server to the system
######################
if ($ADD==211111111111)
	{
	if ( ($LOGmodify_servers!=1) or ($add_copy_disabled > 0) )
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from servers where server_id='$server_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("SERVER NOT ADDED - there is already a server in the system with this ID")."\n";}
		else
			{
			if ( (strlen($server_id) < 1) or (strlen($server_ip) < 7) )
				{echo "<br>"._QXZ("SERVER NOT ADDED - Please go back and look at the data you entered")."\n";}
			else
				{
				echo "<br>"._QXZ("SERVER ADDED")."\n";

				$stmt="INSERT INTO servers (server_id,server_description,server_ip,active,asterisk_version,conf_secret,local_gmt,user_group) values('$server_id','$server_description','$server_ip','$active','$asterisk_version','$SSdefault_server_password','$SSdefault_local_gmt','$user_group');";
				$rslt=mysql_to_mysqli($stmt, $link);

				$stmtA="UPDATE servers SET rebuild_conf_files='Y',rebuild_music_on_hold='Y',sounds_update='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';";
				$rslt=mysql_to_mysqli($stmtA, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtA|";
				$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='SERVERS', event_type='ADD', record_id='$server_id', event_code='ADMIN ADD SERVER', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=311111111111;
	}


######################
# ADD=221111111111 adds the new vicidial server trunk record to the system
######################
if ($ADD==221111111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT max_vicidial_trunks from servers where server_ip='$server_ip';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$rowx=mysqli_fetch_row($rslt);
		$MAXvicidial_trunks = $rowx[0];
		
		$stmt="SELECT sum(dedicated_trunks) from vicidial_server_trunks where server_ip='$server_ip' and campaign_id !='$campaign_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$rowx=mysqli_fetch_row($rslt);
		$SUMvicidial_trunks = ($rowx[0] + $dedicated_trunks);
		
		if ($SUMvicidial_trunks > $MAXvicidial_trunks)
			{
			echo "<br>"._QXZ("SERVER TRUNK RECORD NOT ADDED - the number of trunks is too high").": $SUMvicidial_trunks / $MAXvicidial_trunks\n";
			}
		else
			{
			$stmt="SELECT count(*) from vicidial_server_trunks where campaign_id='$campaign_id' and server_ip='$server_ip';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] > 0)
				{echo "<br>"._QXZ("SERVER TRUNK RECORD NOT ADDED - there is already a server-trunk record for this campaign")."\n";}
			else
				{
				if ( (strlen($campaign_id) < 2) or (strlen($server_ip) < 7) or (strlen($dedicated_trunks) < 1) or (strlen($trunk_restriction) < 1) )
					{
					echo "<br>"._QXZ("SERVER TRUNK RECORD NOT ADDED - Please go back and look at the data you entered")."\n";
					echo "<br>"._QXZ("campaign must be between 3 and 8 characters in length")."\n";
					echo "<br>"._QXZ("server_ip delay must be at least 7 characters")."\n";
					echo "<br>"._QXZ("trunks must be a digit from 0 to 9999")."\n";
					}
				else
					{
					echo "<br><B>"._QXZ("SERVER TRUNK RECORD ADDED").": $campaign_id - $server_ip - $dedicated_trunks - $trunk_restriction</B>\n";

					$stmt="INSERT INTO vicidial_server_trunks(server_ip,campaign_id,dedicated_trunks,trunk_restriction) values('$server_ip','$campaign_id','$dedicated_trunks','$trunk_restriction');";
					$rslt=mysql_to_mysqli($stmt, $link);

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$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='SERVERS_TRUNK', event_type='ADD', record_id='$server_ip', event_code='ADMIN ADD SERVER TRUNK', event_sql=\"$SQL_log\", event_notes='campaign: $campaign_id';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	$ADD=311111111111;
	}


######################
# ADD=231111111111 adds new conf template to the system
######################
if ($ADD==231111111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_conf_templates where template_id='$template_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("CONF TEMPLATE NOT ADDED - there is already a template in the system with this ID")."\n";}
		else
			{
			if (strlen($template_id) < 2)
				{echo "<br>"._QXZ("CONF TEMPLATE NOT ADDED - Please go back and look at the data you entered")."\n";}
			else
				{
				echo "<br>"._QXZ("CONF TEMPLATE ADDED")."\n";

				$stmt="INSERT INTO vicidial_conf_templates (template_id,template_name,template_contents,user_group) values('$template_id','$template_name','$template_contents','$user_group');";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='CONFTEMPLATES', event_type='ADD', record_id='$template_id', event_code='ADMIN ADD CONF TEMPLATE', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=331111111111;
	}


######################
# ADD=241111111111 adds new server carrier to the system
######################
if ($ADD==241111111111)
	{
	if ( ($add_copy_disabled > 0) or ($x_ra_carrier > 0) )
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_server_carriers where carrier_id='$carrier_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("CARRIER NOT ADDED - there is already a carrier in the system with this ID")."\n";}
		else
			{
			if ( (strlen($carrier_id) < 2) or (strlen($server_ip) < 7) )
				{echo "<br>"._QXZ("CARRIER NOT ADDED - Please go back and look at the data you entered")."\n";}
			else
				{
				echo "<br>"._QXZ("CARRIER ADDED")."\n";

				$stmt="INSERT INTO vicidial_server_carriers (carrier_id,carrier_name,registration_string,template_id,account_entry,protocol,globals_string,dialplan_entry,server_ip,active,carrier_description,user_group) values('$carrier_id','$carrier_name','$registration_string','$template_id','$account_entry','$protocol','$globals_string','$dialplan_entry','$server_ip','N','$carrier_description','$user_group');";
				$rslt=mysql_to_mysqli($stmt, $link);

				$stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';";
				$rslt=mysql_to_mysqli($stmtA, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtA|";
				$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='CARRIERS', event_type='ADD', record_id='$carrier_id', event_code='ADMIN ADD CARRIER', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=341111111111;
	}


######################
# ADD=240111111111 adds copied server carrier to the system
######################
if ($ADD==240111111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_server_carriers where carrier_id='$carrier_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("CARRIER NOT ADDED - there is already a carrier in the system with this ID")."\n";}
		else
			{
			if ( (strlen($carrier_id) < 2) or (strlen($server_ip) < 7) )
				{echo "<br>"._QXZ("CARRIER NOT ADDED - Please go back and look at the data you entered")."\n";}
			else
				{
				echo "<br>"._QXZ("COPIED CARRIER ADDED")."\n";

				$stmt="INSERT INTO vicidial_server_carriers (carrier_id,carrier_name,registration_string,template_id,account_entry,protocol,globals_string,dialplan_entry,server_ip,active,carrier_description,user_group) SELECT \"$carrier_id\",\"$carrier_name\",registration_string,template_id,account_entry,protocol,globals_string,dialplan_entry,\"$server_ip\",\"N\",carrier_description,user_group from vicidial_server_carriers where carrier_id=\"$source_carrier\";";
				$rslt=mysql_to_mysqli($stmt, $link);
				if ($DB) {echo "|$stmt|\n";}

				$stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';";
				if ($server_ip == '0.0.0.0')
					{$stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y';";}
				$rslt=mysql_to_mysqli($stmtA, $link);
				if ($DB) {echo "|$stmt|\n";}

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtA|";
				$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='CARRIERS', event_type='COPY', record_id='$carrier_id', event_code='ADMIN COPY CARRIER', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=341111111111;
	}


######################
# ADD=251111111111 adds new tts entry to the system
######################
if ($ADD==251111111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_tts_prompts where tts_id='$tts_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("TTS ENTRY NOT ADDED - there is already a tts entry in the system with this ID")."\n";}
		else
			{
			if ( (strlen($tts_id) < 2) or (strlen($tts_name) < 3) )
				{echo "<br>"._QXZ("TTS ENTRY NOT ADDED - Please go back and look at the data you entered")."\n";}
			else
				{
				echo "<br>"._QXZ("TTS ENTRY ADDED")."\n";

				$stmt="INSERT INTO vicidial_tts_prompts SET tts_id='$tts_id',tts_name='$tts_name',active='$active',user_group='$user_group';";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='TTS', event_type='ADD', record_id='$tts_id', event_code='ADMIN ADD TTS', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=351111111111;
	}


######################
# ADD=261111111111 adds new music on hold entry to the system
######################
if ($ADD==261111111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_music_on_hold where moh_id='$moh_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("MUSIC ON HOLD ENTRY NOT ADDED - there is already a moh entry in the system with this ID")."\n";}
		else
			{
			if ( (strlen($moh_id) < 2) or (strlen($moh_name) < 3) or ($moh_id=='sounds') or ($moh_id=='agi-bin') or ($moh_id=='astdb') or ($moh_id=='keys') )
				{echo "<br>"._QXZ("MUSIC ON HOLD ENTRY NOT ADDED - Please go back and look at the data you entered")."\n";}
			else
				{
				echo "<br>"._QXZ("MUSIC ON HOLD ENTRY ADDED")."\n";

				$stmt="INSERT INTO vicidial_music_on_hold SET moh_id='$moh_id',moh_name='$moh_name',random='$random',user_group='$user_group';";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='MOH', event_type='ADD', record_id='$moh_id', event_code='ADMIN ADD MOH', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=361111111111;
	}


######################
# ADD=271111111111 adds new voicemail box to the system
######################
if ($ADD==271111111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_voicemail where voicemail_id='$voicemail_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("VOICEMAIL BOX NOT ADDED - there is already a voicemail box in the system with this ID")."\n";}
		else
			{
			$stmt="SELECT count(*) from phones where voicemail_id='$voicemail_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] > 0)
				{echo "<br>"._QXZ("VOICEMAIL BOX NOT ADDED - there is already a phone in the system with this voicemail ID")."\n";}
			else
				{
				if ( (strlen($voicemail_id) < 2) or (strlen($pass) < 2) or (strlen($fullname) < 3) )
					{echo "<br>"._QXZ("VOICEMAIL BOX NOT ADDED - Please go back and look at the data you entered")."\n";}
				else
					{
					echo "<br>"._QXZ("VOICEMAIL BOX ADDED")."\n";

					$stmtA="INSERT INTO vicidial_voicemail SET voicemail_id='$voicemail_id',pass='$pass',email='$email',fullname='$fullname',active='$active',voicemail_timezone='$SSdefault_voicemail_timezone',user_group='$user_group';";
					$rslt=mysql_to_mysqli($stmtA, $link);

					$stmt="SELECT active_voicemail_server from system_settings;";
					$rslt=mysql_to_mysqli($stmt, $link);
					$row=mysqli_fetch_row($rslt);
					$active_voicemail_server = $row[0];

					$stmtB="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$active_voicemail_server';";
					$rslt=mysql_to_mysqli($stmtB, $link);

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$stmtA|$stmtB|";
					$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='VOICEMAIL', event_type='ADD', record_id='$voicemail_id', event_code='ADMIN ADD VOICEMAIL', event_sql=\"$SQL_log\", event_notes='';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	$ADD=371111111111;
	}


######################
# ADD=281111111111 adds new screen label to the system
######################
if ($ADD==281111111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_screen_labels where label_id='$label_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("SCREEN LABEL NOT ADDED - there is already a label in the system with this ID")."\n";}
		else
			{
			if ( (strlen($label_id) < 2) or (strlen($label_name) < 2) )
				{echo "<br>"._QXZ("SCREEN LABEL NOT ADDED - Please go back and look at the data you entered")."\n";}
			else
				{
				echo "<br>"._QXZ("SCREEN LABEL ADDED")."\n";

				$stmt="INSERT INTO vicidial_screen_labels SET label_id='$label_id',label_name='$label_name',active='N',user_group='$user_group';";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='LABELS', event_type='ADD', record_id='$label_id', event_code='ADMIN ADD LABEL', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=381111111111;
	}


######################
# ADD=282111111111 adds new screen colors to the system
######################
if ($ADD==282111111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_screen_colors where colors_id='$colors_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("SCREEN COLORS NOT ADDED - there is already a colors entry in the system with this ID")."\n";}
		else
			{
			if ( (strlen($colors_id) < 2) or (strlen($colors_name) < 2) )
				{echo "<br>"._QXZ("SCREEN COLORS NOT ADDED - Please go back and look at the data you entered")."\n";}
			else
				{
				echo "<br>"._QXZ("SCREEN COLORS ADDED")."\n";

				$stmt="INSERT INTO vicidial_screen_colors SET colors_id='$colors_id',colors_name='$colors_name',active='N',user_group='$user_group';";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='COLORS', event_type='ADD', record_id='$colors_id', event_code='ADMIN ADD COLORS', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=382111111111;
	}


######################
# ADD=291111111111 adds new contact to the system
######################
if ($ADD==291111111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		if ( (preg_match("/contact_information/",$SStables_use_alt_log_db)) and (strlen($SSalt_log_server_ip)>4) and (strlen($SSalt_log_dbname)>0) )
			{
			$linkALT=mysqli_connect("$SSalt_log_server_ip", "$SSalt_log_login", "$SSalt_log_pass", "$SSalt_log_dbname");
				if (!$linkALT) 
					{
					die('MySQL '._QXZ("connect ERROR").': ' . mysqli_connect_error());
					}
			}
		else
			{$linkALT = $link;}
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from contact_information where first_name='$first_name' and last_name='$last_name' and office_num='$office_num';";
		$rslt=mysql_to_mysqli($stmt, $linkALT);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("CONTACT NOT ADDED - there is already a contact in the system with this name and number")."\n";}
		else
			{
			if (strlen($last_name) < 2)
				{echo "<br>"._QXZ("CONTACT NOT ADDED - Please go back and look at the data you entered")."\n";}
			else
				{
				echo "<br>"._QXZ("CONTACT ADDED")."\n";

				$stmt="INSERT INTO contact_information SET first_name='$first_name',last_name='$last_name',office_num='$office_num',cell_num='$cell_num',other_num1='$other_num1',other_num2='$other_num2',bu_name='$bu_name',department='$department',group_name='$group_name',job_title='$job_title',location='$location';";
				$rslt=mysql_to_mysqli($stmt, $linkALT);
				$contact_id = mysqli_insert_id($linkALT);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='CONTACTS', event_type='ADD', record_id='$contact_id', event_code='ADMIN ADD CONTACT', event_sql=\"$SQL_log\", event_notes='$first_name $last_name $office_num';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=391111111111;
	}


######################
# ADD=292111111111 adds new settings container to the system
######################
if ($ADD==292111111111)
	{
	if ( ($LOGmodify_servers!=1) or ($add_copy_disabled > 0) )
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_settings_containers where container_id='$container_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("SETTINGS CONTAINER NOT ADDED - there is already a container in the system with this ID")."\n";}
		else
			{
			if ( (strlen($container_id) < 2) or (strlen($container_notes) < 2) )
				{echo "<br>"._QXZ("SETTINGS CONTAINER NOT ADDED - Please go back and look at the data you entered")."\n";}
			else
				{
				echo "<br>"._QXZ("SETTINGS CONTAINER ADDED")."\n";

				$stmt="INSERT INTO vicidial_settings_containers SET container_id='$container_id',container_notes='$container_notes',container_type='$container_type',user_group='$user_group';";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='CONTAINERS', event_type='ADD', record_id='$container_id', event_code='ADMIN ADD CONTAINER', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=392111111111;
	}


######################
# ADD=293111111111 adds new status group to the system
######################
if ($ADD==293111111111)
	{
	if ( ($LOGmodify_statuses!=1) or ($add_copy_disabled > 0) )
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_status_groups where status_group_id='$status_group_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("STATUS GROUP NOT ADDED - there is already a group in the system with this ID")."\n";}
		else
			{
			$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$status_group_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] > 0)
				{echo "<br>"._QXZ("STATUS GROUP NOT ADDED - there is already a campaign in the system with this ID")."\n";}
			else
				{

				if ( (strlen($status_group_id) < 2) or (strlen($status_group_notes) < 2) )
					{echo "<br>"._QXZ("STATUS GROUP NOT ADDED - Please go back and look at the data you entered")."\n";}
				else
					{
					echo "<br>"._QXZ("STATUS GROUP ADDED")."\n";

					$stmt="INSERT INTO vicidial_status_groups SET status_group_id='$status_group_id',status_group_notes='$status_group_notes',user_group='$user_group';";
					$rslt=mysql_to_mysqli($stmt, $link);

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$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='STATUSGROUPS', event_type='ADD', record_id='$status_group_id', event_code='ADMIN ADD STATUS GROUP', event_sql=\"$SQL_log\", event_notes='';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	$ADD=393111111111;
	}


######################
# ADD=294111111111 adds new automated report to the system
######################
if ($ADD==294111111111)
	{
	if ( ($LOGmodify_auto_reports!=1) or ($add_copy_disabled > 0) )
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_automated_reports where report_id='$report_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("AUTOMATED REPORT NOT ADDED - there is already a report in the system with this ID")."\n";}
		else
			{
			if ( (strlen($report_id) < 2) or (strlen($report_name) < 2) )
				{echo "<br>"._QXZ("AUTOMATED REPORT NOT ADDED - Please go back and look at the data you entered")."\n";}
			else
				{
				echo "<br>"._QXZ("AUTOMATED REPORT ADDED")."\n";

				$stmt="INSERT INTO vicidial_automated_reports SET report_id='$report_id',report_name='$report_name',report_url='',user_group='$user_group';";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='AUTOREPORTS', event_type='ADD', record_id='$report_id', event_code='ADMIN ADD AUTO REPORT', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=394111111111;
	}


######################
# ADD=295111111111 adds new ip list to the system
######################
if ($ADD==295111111111)
	{
	if ( ($LOGmodify_ip_lists!=1) or ($add_copy_disabled > 0) )
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_ip_lists where ip_list_id='$ip_list_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("IP LIST NOT ADDED - there is already a list in the system with this ID")."\n";}
		else
			{
			if ( (strlen($ip_list_id) < 2) or (strlen($ip_list_name) < 2) )
				{echo "<br>"._QXZ("IP LIST NOT ADDED - Please go back and look at the data you entered")."\n";}
			else
				{
				echo "<br>"._QXZ("IP LIST ADDED")."\n";

				$stmt="INSERT INTO vicidial_ip_lists SET ip_list_id='$ip_list_id',ip_list_name='$ip_list_name',active='N',user_group='$user_group';";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='IPLISTS', event_type='ADD', record_id='$ip_list_id', event_code='ADMIN ADD IP LIST', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=395111111111;
	}



######################
# ADD=296111111111 adds new CID group to the system
######################
if ($ADD==296111111111)
	{
	if ( ($LOGmodify_statuses!=1) or ($add_copy_disabled > 0) )
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_cid_groups where cid_group_id='$cid_group_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("CID GROUP NOT ADDED - there is already a CID group in the system with this ID")."\n";}
		else
			{
			$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$cid_group_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] > 0)
				{echo "<br>"._QXZ("CID GROUP NOT ADDED - there is already a campaign in the system with this ID")."\n";}
			else
				{
				if ( (strlen($cid_group_id) < 2) or (strlen($cid_group_notes) < 2) or (strlen($cid_group_type) < 2) )
					{echo "<br>"._QXZ("CID GROUP NOT ADDED - Please go back and look at the data you entered")."\n";}
				else
					{
					echo "<br>"._QXZ("CID GROUP ADDED")."\n";

					$stmt="INSERT INTO vicidial_cid_groups SET cid_group_id='$cid_group_id',cid_group_notes='$cid_group_notes',cid_group_type='$cid_group_type',user_group='$user_group',cid_auto_rotate_minutes='0',cid_auto_rotate_minimum='0',cid_auto_rotate_calls='0',cid_last_auto_rotate='2020-01-01 00:00:01';";
					$rslt=mysql_to_mysqli($stmt, $link);

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$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='CIDGROUPS', event_type='ADD', record_id='$cid_group_id', event_code='ADMIN ADD CID GROUP', event_sql=\"$SQL_log\", event_notes='';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	$ADD=396111111111;
	}


######################
# ADD=297111111111 adds new VM Message group to the system
######################
if ($ADD==297111111111)
	{
	if ( ($LOGmodify_statuses!=1) or ($add_copy_disabled > 0) )
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from leave_vm_message_groups where leave_vm_message_group_id='$leave_vm_message_group_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("VM MESSAGE GROUP NOT ADDED - there is already a VM MESSAGE GROUP in the system with this ID")."\n";}
		else
			{
			if ( (strlen($leave_vm_message_group_id) < 2) or (strlen($leave_vm_message_group_notes) < 2) or (strlen($active) < 1) )
				{echo "<br>"._QXZ("VM MESSAGE GROUP NOT ADDED - Please go back and look at the data you entered")."\n";}
			else
				{
				echo "<br>"._QXZ("VM MESSAGE GROUP ADDED")."\n";

				$stmt="INSERT INTO leave_vm_message_groups SET leave_vm_message_group_id='$leave_vm_message_group_id',leave_vm_message_group_notes='$leave_vm_message_group_notes',active='$active',user_group='$user_group';";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='VMMGROUPS', event_type='ADD', record_id='$leave_vm_message_group_id', event_code='ADMIN ADD VMM GROUP', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=397111111111;
	}


######################
# ADD=298111111111 adds new Queue Group to the system
######################
if ($ADD==298111111111)
	{
	if ( ($LOGmodify_statuses!=1) or ($add_copy_disabled > 0) )
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		$ADD=198111111111;
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_queue_groups where queue_group='$queue_group';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{
			echo "<br>"._QXZ("VM MESSAGE GROUP NOT ADDED - there is already a VM MESSAGE GROUP in the system with this ID")."\n";
			$ADD=198111111111;
			}
		else
			{
			if ( (strlen($queue_group) < 2) or (strlen($queue_group_name) < 5) or (strlen($active) < 1) )
				{
				echo "<br>"._QXZ("VM MESSAGE GROUP NOT ADDED - Please go back and look at the data you entered")."\n";
				$ADD=198111111111;
				}
			else
				{
				echo "<br>"._QXZ("VM MESSAGE GROUP ADDED")."\n";

				$stmt="INSERT INTO vicidial_queue_groups SET queue_group='$queue_group',queue_group_name='$queue_group_name',active='$active',user_group='$user_group';";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='QUEUEGROUPS', event_type='ADD', record_id='$queue_group', event_code='ADMIN ADD QUEUE GROUP', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=398111111111;
	}


######################
# ADD=2111111111111 adds new conference to the system
######################
if ($ADD==2111111111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("CONFERENCE NOT ADDED - there is already a conference in the system with this ID and server")."\n";}
		else
			{
			if ( (strlen($conf_exten) < 1) or (strlen($server_ip) < 7) )
				{echo "<br>"._QXZ("CONFERENCE NOT ADDED - Please go back and look at the data you entered")."\n";}
			else
				{
				echo "<br>"._QXZ("CONFERENCE ADDED")."\n";

				$stmt="INSERT INTO conferences (conf_exten,server_ip) values('$conf_exten','$server_ip');";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='CONF', event_type='ADD', record_id='$conf_exten', event_code='ADMIN ADD CONFERENCE', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=3111111111111;
	}


######################
# ADD=21111111111111 adds new vicidial conference to the system
######################
if ($ADD==21111111111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_conferences where conf_exten='$conf_exten' and server_ip='$server_ip';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("AGENT CONFERENCE NOT ADDED - there is already an agent conference in the system with this ID and server")."\n";}
		else
			{
			if ( (strlen($conf_exten) < 1) or (strlen($server_ip) < 7) )
				{echo "<br>"._QXZ("AGENT CONFERENCE NOT ADDED - Please go back and look at the data you entered")."\n";}
			else
				{
				echo "<br>"._QXZ("AGENT CONFERENCE ADDED")."\n";

				$stmt="INSERT INTO vicidial_conferences (conf_exten,server_ip) values('$conf_exten','$server_ip');";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='VICICONF', event_type='ADD', record_id='$conf_exten', event_code='ADMIN ADD VICIDIAL CONFERENCE', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=31111111111111;
	}


######################
# ADD=22111111111111 adds new vicidial confbridge to the system
######################
if ($ADD==22111111111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_confbridges where conf_exten='$conf_exten' and server_ip='$server_ip';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("AGENT CONFBRIDGE NOT ADDED - there is already an agent conference in the system with this ID and server")."\n";}
		else
			{
			if ( (strlen($conf_exten) < 1) or (strlen($server_ip) < 7) )
				{echo "<br>"._QXZ("AGENT CONFBRIDGE NOT ADDED - Please go back and look at the data you entered")."\n";}
			else
				{
				echo "<br>"._QXZ("AGENT CONFBRIDGE ADDED")."\n";

				$stmt="INSERT INTO vicidial_confbridges (conf_exten,server_ip) values('$conf_exten','$server_ip');";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='VICICONF', event_type='ADD', record_id='$conf_exten', event_code='ADMIN ADD VICIDIAL CONFBRIDGE', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=32111111111111;
	}


######################
# ADD=221111111111111 adds the new system status to the system
######################
if ($ADD==221111111111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_campaign_statuses where status='$status_id' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("SYSTEM STATUS NOT ADDED - there is already a campaign-status in the system with this name").": $row[0]\n";}
		else
			{
			$stmt="SELECT count(*) from vicidial_statuses where status='$status_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] > 0)
				{echo "<br>"._QXZ("SYSTEM STATUS NOT ADDED - there is already a global-status in the system with this name")."\n";}
			else
				{
				if ( (strlen($status_id) < 1) or (strlen($status_name) < 2) )
					{
					echo "<br>"._QXZ("SYSTEM STATUS NOT ADDED - Please go back and look at the data you entered")."\n";
					echo "<br>"._QXZ("status must be between 1 and 8 characters in length")."\n";
					echo "<br>"._QXZ("status name must be between 2 and 30 characters in length")."\n";
					}
				else
					{
					echo "<br><B>"._QXZ("SYSTEM STATUS ADDED").": $status_name - $status_id</B>\n";

					$stmt="INSERT INTO vicidial_statuses (status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable,scheduled_callback,completed,min_sec,max_sec,answering_machine) values('$status_id','$status_name','$selectable','$human_answered','$category','$sale','$dnc','$customer_contact','$not_interested','$unworkable','$scheduled_callbacks','$completed','$min_sec','$max_sec','$answering_machine');";
					$rslt=mysql_to_mysqli($stmt, $link);

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$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='SYSTEMSTATUSES', event_type='ADD', record_id='$status_id', event_code='ADMIN ADD SYSTEM STATUS', event_sql=\"$SQL_log\", event_notes='';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	$ADD=321111111111111;
	}


######################
# ADD=231111111111111 adds the new status category to the system
######################
if ($ADD==231111111111111)
	{
	if ($add_copy_disabled > 0)
		{
		echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
		}
	else
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_status_categories where vsc_id='$vsc_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] > 0)
			{echo "<br>"._QXZ("STATUS CATEGORY NOT ADDED - there is already a status category in the system with this ID").": $row[0]\n";}
		else
			{
			if ( (strlen($vsc_id) < 2) or (mb_strlen($vsc_id,'utf-8') > 20) or (strlen($vsc_name) < 2) )
				{
				echo "<br>"._QXZ("STATUS CATEGORY NOT ADDED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("ID must be between 2 and 20 characters in length")."\n";
				echo "<br>"._QXZ("name name must be between 2 and 50 characters in length")."\n";
				}
			else
				{
				echo "<br><B>"._QXZ("STATUS CATEGORY ADDED").": $vsc_id - $vsc_name</B>\n";

				$stmt="SELECT count(*) from vicidial_status_categories where tovdad_display='Y' and vsc_id NOT IN('$vsc_id');";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				if ( ($row[0] > 3) and (preg_match('/Y/',$tovdad_display)) )
					{
					$tovdad_display = 'N';
					echo "<br><B>"._QXZ("ERROR: There are already 4 Status Categories set to TimeOnVDAD Display")."</B>\n";
					}

				$stmt="INSERT INTO vicidial_status_categories (vsc_id,vsc_name,vsc_description,tovdad_display,sale_category,dead_lead_category) values('$vsc_id','$vsc_name','$vsc_description','$tovdad_display','$sale_category','$dead_lead_category');";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='STATUSCATEGORIES', event_type='ADD', record_id='$vsc_id', event_code='ADMIN ADD STATUS CATEGORY', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	$ADD=331111111111111;
	}





######################################################################################################
######################################################################################################
#######   4 series, record modifications submitted and DB is modified, then on to 3 series forms below
######################################################################################################
######################################################################################################



######################
# ADD=4A submit user modifications to the system - ADMIN
######################
if ($ADD=="4A")
	{
	if ($LOGmodify_users==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$enc_pass_nochange=0;
		if ( ($SSpass_hash_enabled > 0) and (strlen($pass) < 1) ) {$enc_pass_nochange=1;}

		if ( ( (strlen($pass) < 2) and ($SSpass_hash_enabled < 1) ) or (strlen($full_name) < 2) or (strlen($user_level) < 1) or ( ($SSrequire_password_length > 0) and ($SSrequire_password_length > strlen($pass)) and ($enc_pass_nochange < 1) ) )
			{
			echo "<br>"._QXZ("USER NOT MODIFIED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("Password and Full Name each need to be at least 2 characters in length")."\n";
			if ($SSrequire_password_length > 0)
				{
				echo "<br>"._QXZ("Password must be at least $SSrequire_password_length characters long")."\n";
				}
			}
		else
			{
			if ($SSoutbound_autodial_active < 1)
				{
				$closer_default_blended =	'0';
				$delete_filters =			'0';
				$load_leads =				'0';
				}
			if (strlen($agent_choose_territories) < 1) 
				{$agent_choose_territories=0;}
			$pass_hash='';
			$pass_hashSQL='';
			if ($SSpass_hash_enabled > 0)
				{
				if (strlen($pass) > 1)
					{
					$pass = preg_replace("/\'|\"|\\\\|;|<|>| /","",$pass);
					$pass_hash = exec("../agc/bp.pl --pass=$pass");
					$pass_hash = preg_replace("/PHASH: |\n|\r|\t| /",'',$pass_hash);
					$pass_hashSQL = ",pass_hash='$pass_hash'";
					}
				$pass='';
				}

			$k=0;   $new_field_value='';
			if (is_array($api_allowed_functions)) {$multi_count = count($api_allowed_functions);} else {$multi_count=0;}
			$multi_array = $api_allowed_functions;
			while ($k < $multi_count)
				{
				$new_field_value .= "$multi_array[$k] ";
				$k++;
				}
			$api_allowed_functions = " $new_field_value";

			$k=0;   $new_field_value='';
			if (is_array($max_inbound_filter_statuses)) {$multi_count = count($max_inbound_filter_statuses);} else {$multi_count=0;}
			$multi_array = $max_inbound_filter_statuses;
			while ($k < $multi_count)
				{
				$new_field_value .= "$multi_array[$k],";
				$k++;
				}
			$new_field_value = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$new_field_value);
			$max_inbound_filter_statuses = preg_replace("/,$/","",$new_field_value);

			$k=0;   $new_field_value='';
			if (is_array($max_inbound_filter_ingroups)) {$multi_count = count($max_inbound_filter_ingroups);} else {$multi_count=0;}
			$multi_array = $max_inbound_filter_ingroups;
			while ($k < $multi_count)
				{
				$new_field_value .= "$multi_array[$k],";
				$k++;
				}
			$new_field_value = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$new_field_value);
			$max_inbound_filter_ingroups = preg_replace("/,$/","",$new_field_value);

			$user_codeSQL = ",user_code='$user_code'";
			if ($SSuser_codes_admin > 0)
				{
				$user_codeSQL='';
				if ($LOGuser_level >= 9) {$user_codeSQL = ",user_code='$user_code'";}
				}

			echo "<br><B>"._QXZ("USER MODIFIED - ADMIN").": $user</B>\n";

			$stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',delete_users='$delete_users',delete_user_groups='$delete_user_groups',delete_lists='$delete_lists',delete_campaigns='$delete_campaigns',delete_ingroups='$delete_ingroups',delete_remote_agents='$delete_remote_agents',load_leads='$load_leads',campaign_detail='$campaign_detail',ast_admin_access='$ast_admin_access',ast_delete_phones='$ast_delete_phones',delete_scripts='$delete_scripts',modify_leads='$modify_leads',hotkeys_active='$hotkeys_active',change_agent_campaign='$change_agent_campaign',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',delete_filters='$delete_filters',alter_agent_interface_options='$alter_agent_interface_options',closer_default_blended='$closer_default_blended',delete_call_times='$delete_call_times',modify_call_times='$modify_call_times',modify_users='$modify_users',modify_campaigns='$modify_campaigns',modify_lists='$modify_lists',modify_scripts='$modify_scripts',modify_filters='$modify_filters',modify_ingroups='$modify_ingroups',modify_usergroups='$modify_usergroups',modify_remoteagents='$modify_remoteagents',modify_servers='$modify_servers',view_reports='$view_reports',vicidial_recording_override='$vicidial_recording_override',alter_custdata_override='$alter_custdata_override',qc_enabled='$qc_enabled',qc_user_level='$qc_user_level',qc_pass='$qc_pass',qc_finish='$qc_finish',qc_commit='$qc_commit',add_timeclock_log='$add_timeclock_log',modify_timeclock_log='$modify_timeclock_log',delete_timeclock_log='$delete_timeclock_log',alter_custphone_override='$alter_custphone_override',vdc_agent_api_access='$vdc_agent_api_access',modify_inbound_dids='$modify_inbound_dids',delete_inbound_dids='$delete_inbound_dids',active='$active',download_lists='$download_lists',agent_shift_enforcement_override='$agent_shift_enforcement_override',manager_shift_enforcement_override='$manager_shift_enforcement_override',export_reports='$export_reports',delete_from_dnc='$delete_from_dnc',email='$email',territory='$territory',allow_alerts='$allow_alerts',agent_choose_territories='$agent_choose_territories',custom_one='$custom_one',custom_two='$custom_two',custom_three='$custom_three',custom_four='$custom_four',custom_five='$custom_five',voicemail_id='$voicemail_id',agent_call_log_view_override='$agent_call_log_view_override',callcard_admin='$callcard_admin',agent_choose_blended='$agent_choose_blended',realtime_block_user_info='$realtime_block_user_info',custom_fields_modify='$custom_fields_modify',force_change_password='$force_change_password',agent_lead_search_override='$agent_lead_search',modify_shifts='$modify_shifts',modify_phones='$modify_phones',modify_carriers='$modify_carriers',modify_labels='$modify_labels',modify_statuses='$modify_statuses',modify_voicemail='$modify_voicemail',modify_audiostore='$modify_audiostore',modify_moh='$modify_moh',modify_tts='$modify_tts',preset_contact_search='$preset_contact_search',modify_contacts='$modify_contacts',modify_same_user_level='$modify_same_user_level',admin_hide_lead_data='$admin_hide_lead_data',admin_hide_phone_data='$admin_hide_phone_data',agentcall_email='$agentcall_email',agentcall_chat='$agentcall_chat',modify_email_accounts='$modify_email_accounts',failed_login_count=0,alter_admin_interface_options='$alter_admin_interface_options',max_inbound_calls='$max_inbound_calls',modify_custom_dialplans='$modify_custom_dialplans',wrapup_seconds_override='$wrapup_seconds_override',modify_languages='$modify_languages',selected_language='$selected_language',user_choose_language='$user_choose_language',ignore_group_on_search='$ignore_group_on_search',api_list_restrict='$api_list_restrict',api_allowed_functions='$api_allowed_functions',lead_filter_id='$lead_filter_id',admin_cf_show_hidden='$admin_cf_show_hidden',user_hide_realtime='$user_hide_realtime',access_recordings='$access_recordings',modify_colors='$modify_colors',user_nickname='$user_nickname',user_new_lead_limit='$user_new_lead_limit',api_only_user='$api_only_user',modify_auto_reports='$modify_auto_reports',modify_ip_lists='$modify_ip_lists',ignore_ip_list='$ignore_ip_list',ready_max_logout='$ready_max_logout',export_gdpr_leads='$export_gdpr_leads',pause_code_approval='$pause_code_approval',max_hopper_calls='$max_hopper_calls',max_hopper_calls_hour='$max_hopper_calls_hour',mute_recordings='$mute_recordings',hide_call_log_info='$hide_call_log_info',next_dial_my_callbacks='$next_dial_my_callbacks',user_admin_redirect_url='" . mysqli_real_escape_string($link, $user_admin_redirect_url) . "',max_inbound_filter_enabled='$max_inbound_filter_enabled',max_inbound_filter_statuses='$max_inbound_filter_statuses',max_inbound_filter_ingroups='$max_inbound_filter_ingroups',max_inbound_filter_min_sec='$max_inbound_filter_min_sec',status_group_id='$status_group_id',mobile_number='$mobile_number',two_factor_override='$two_factor_override',manual_dial_filter='$manual_dial_filter',user_location='$user_location',download_invalid_files='$download_invalid_files',user_group_two='$user_group_two',modify_dial_prefix='$modify_dial_prefix',inbound_credits='$inbound_credits',hci_enabled='$hci_enabled',manual_dial_lead_id='$manual_dial_lead_id' $user_codeSQL $pass_hashSQL where user='$user' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmt_grp_values|";
			$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='$user', event_code='ADMIN MODIFY USER', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			###############################################################
			##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP #####
			$stmt = "SELECT enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url FROM system_settings;";
			$rslt=mysql_to_mysqli($stmt, $link);
			if ($DB) {echo "$stmt\n";}
			$ss_conf_ct = mysqli_num_rows($rslt);
			if ($ss_conf_ct > 0)
				{
				$row=mysqli_fetch_row($rslt);
				$enable_vtiger_integration =	$row[0];
				$vtiger_server_ip	=			$row[1];
				$vtiger_dbname =				$row[2];
				$vtiger_login =					$row[3];
				$vtiger_pass =					$row[4];
				$vtiger_url =					$row[5];
				}
			##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP #####
			#############################################################

			if ($enable_vtiger_integration > 0)
				{
				### connect to your vtiger database
				#$linkV=mysql_connect("$vtiger_server_ip", "$vtiger_login","$vtiger_pass");
				#if (!$linkV) {die("Could not connect: $vtiger_server_ip|$vtiger_dbname|$vtiger_login|$vtiger_pass" . mysqli_error());}
				#echo 'Connected successfully';
				#mysql_select_db("$vtiger_dbname", $linkV);
				$linkV=mysqli_connect("$vtiger_server_ip", "$vtiger_login", "$vtiger_pass", "$vtiger_dbname");
				if (!$linkV) 
					{
					die('MySQL '._QXZ("connect ERROR").': ' . mysqli_connect_error());
					}

				$user_name =		$user;
				$user_password =	$pass;
				$last_name =		$full_name;
				$is_admin =			'off';
				$roleid =			'H5';
				$status =			'Active';
				$groupid =			'1';
					if ($user_level >= 7) {$roleid = 'H3';}
					if ($user_level >= 8) {$roleid = 'H4';}
					if ($user_level >= 9) {$roleid = 'H2';}
					if ($user_level >= 9) {$is_admin = 'on';}
				$salt = substr($user_name, 0, 2);
				$salt = '$1$' . $salt . '$';
				$encrypted_password = crypt($user_password, $salt);
				### search for role in ViciDial
				$stmt = "SELECT vtiger_role FROM vtiger_vicidial_roles where user_level='$user_level';";
				$rslt=mysql_to_mysqli($stmt, $link);
				if ($DB) {echo "$stmt\n";}
				$vvr_ct = mysqli_num_rows($rslt);
				if ($vvr_ct > 0)
					{
					$row=mysqli_fetch_row($rslt);
					$roleid =	$row[0];
					}

				######################################
				##### BEGIN Add/Update group info in Vtiger
				$stmt="SELECT count(*) from vtiger_groups where groupname='$user_group';";
				$rslt=mysql_to_mysqli($stmt, $linkV);
				if ($DB) {echo "$stmt\n";}
				if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
				$row=mysqli_fetch_row($rslt);
				$group_found_count = $row[0];

				### group exists in vtiger, update it
				if ($group_found_count > 0)
					{
					$stmt="SELECT groupid from vtiger_groups where groupname='$user_group';";
					$rslt=mysql_to_mysqli($stmt, $linkV);
					if ($DB) {echo "$stmt\n";}
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
					$row=mysqli_fetch_row($rslt);
					$groupid = $row[0];
					}

				### user doesn't exist in vtiger, insert it
				else
					{
					#### BEGIN CREATE NEW GROUP RECORD IN VTIGER
					# Get next available id from vtiger_users_seq to use as groupid
					$stmt="SELECT id from vtiger_users_seq;";
					if ($DB) {echo "$stmt\n";}
					$rslt=mysql_to_mysqli($stmt, $linkV);
					$row=mysqli_fetch_row($rslt);
					$groupid = ($row[0] + 1);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					# Increase next available groupid with 1 so next record gets proper id
					$stmt="UPDATE vtiger_users_seq SET id = '$groupid';";
					if ($DB) {echo "$stmt\n";}
					$rslt=mysql_to_mysqli($stmt, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					$stmtA = "INSERT INTO vtiger_groups SET groupid='$groupid',groupname='$user_group',description='';";
					if ($DB) {echo "|$stmtA|\n";}
					$rslt=mysql_to_mysqli($stmtA, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					#### END CREATE NEW GROUP RECORD IN VTIGER
					}
				##### END Add/Update group info in Vtiger
				######################################

				######################################
				##### BEGIN Add/Update user info in Vtiger
				$stmt="SELECT count(*) from vtiger_users where user_name='$user_name';";
				$rslt=mysql_to_mysqli($stmt, $linkV);
				if ($DB) {echo "$stmt\n";}
				if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
				$row=mysqli_fetch_row($rslt);
				$found_count = $row[0];

				### user exists in vtiger, update it
				if ($found_count > 0)
					{
					$stmt="SELECT id from vtiger_users where user_name='$user_name';";
					$rslt=mysql_to_mysqli($stmt, $linkV);
					if ($DB) {echo "$stmt\n";}
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
					$row=mysqli_fetch_row($rslt);
					$userid = $row[0];

					$stmt="SELECT count(*) from vtiger_users2group WHERE userid='$userid' and groupid='$groupid';";
					$rslt=mysql_to_mysqli($stmt, $linkV);
					if ($DB) {echo "$stmt\n";}
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
					$row=mysqli_fetch_row($rslt);
					$usergroupcount = $row[0];

					$stmtA = "UPDATE vtiger_users SET user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status' where id='$userid';";
					if ($DB) {echo "|$stmtA|\n";}
					$rslt=mysql_to_mysqli($stmtA, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					$stmtB = "UPDATE vtiger_user2role SET roleid='$roleid' where userid='$userid';";
					if ($DB) {echo "|$stmtB|\n";}
					$rslt=mysql_to_mysqli($stmtB, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					if ($usergroupcount < 1)
						{
						$stmt="SELECT user_group FROM vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;";
						$rslt=mysql_to_mysqli($stmt, $link);
						if ($DB) {echo "$stmt\n";}
						$VD_groups_ct = mysqli_num_rows($rslt);
						$k=0;
						$VD_groups_list='';
						while ($k < $VD_groups_ct)
							{
							$row=mysqli_fetch_row($rslt);
							$VD_groups_list .= "'$row[0]',";
							$k++;
							}
						$VD_groups_list = preg_replace("/.$/",'',$VD_groups_list);

						$stmtC = "DELETE FROM vtiger_users2group WHERE userid='$userid' and groupid IN(SELECT groupid from vtiger_groups where groupname IN($VD_groups_list));";
						if ($DB) {echo "|$stmtC|\n";}
						$rslt=mysql_to_mysqli($stmtC, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						$stmtD = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';";
						if ($DB) {echo "|$stmtD|\n";}
						$rslt=mysql_to_mysqli($stmtD, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
						}
					}

				### user doesn't exist in vtiger, insert it
				else
					{
					#### BEGIN CREATE NEW USER RECORD IN VTIGER
					$stmtA = "INSERT INTO vtiger_users SET user_name='$user_name',user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status',date_format='yyyy-mm-dd',first_name='',reports_to_id='',description='',title='',department='',phone_home='',phone_mobile='',phone_work='',phone_other='',phone_fax='',email1='',email2='',yahoo_id='',signature='',address_street='',address_city='',address_state='',address_country='',address_postalcode='',user_preferences='',imagename='';";
					if ($DB) {echo "|$stmtA|\n";}
					$rslt=mysql_to_mysqli($stmtA, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
					$userid = mysqli_insert_id($linkV);
				
					$stmtB = "INSERT INTO vtiger_user2role SET userid='$userid',roleid='$roleid';";
					if ($DB) {echo "|$stmtB|\n";}
					$rslt=mysql_to_mysqli($stmtB, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					$stmtC = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';";
					if ($DB) {echo "|$stmtC|\n";}
					$rslt=mysql_to_mysqli($stmtC, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					$stmtD = "UPDATE vtiger_users_seq SET id='$userid';";
					if ($DB) {echo "|$stmtD|\n";}
					$rslt=mysql_to_mysqli($stmtD, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					#### END CREATE NEW USER RECORD IN VTIGER
					}
				##### END Add/Update user info in Vtiger
				######################################
				}
			### END vtiger integration
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=3;		# go to user modification below
	}


######################
# ADD=4B submit user modifications to the system - ADMIN
######################
if ($ADD=="4B")
	{
	if ($LOGmodify_users==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$enc_pass_nochange=0;
		if ( ($SSpass_hash_enabled > 0) and (strlen($pass) < 1) ) {$enc_pass_nochange=1;}

		if ( ( (strlen($pass) < 2) and ($SSpass_hash_enabled < 1) ) or (strlen($full_name) < 2) or (strlen($user_level) < 1) or ( ($SSrequire_password_length > 0) and ($SSrequire_password_length > strlen($pass)) and ($enc_pass_nochange < 1) ) )
			{
			echo "<br>"._QXZ("USER NOT MODIFIED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("Password and Full Name each need to be at least 2 characters in length")."\n";
			if ($SSrequire_password_length > 0)
				{
				echo "<br>"._QXZ("Password must be at least $SSrequire_password_length characters long")."\n";
				}
			}
		else
			{
			if ($SSoutbound_autodial_active < 1)
				{
				$closer_default_blended =	'0';
				$delete_filters =			'0';
				$load_leads =				'0';
				}
			if (strlen($agent_choose_territories) < 1) 
				{$agent_choose_territories=0;}
			$pass_hash='';
			$pass_hashSQL='';
			if ($SSpass_hash_enabled > 0)
				{
				if (strlen($pass) > 1)
					{
					$pass = preg_replace("/\'|\"|\\\\|;|<|>| /","",$pass);
					$pass_hash = exec("../agc/bp.pl --pass=$pass");
					$pass_hash = preg_replace("/PHASH: |\n|\r|\t| /",'',$pass_hash);
					$pass_hashSQL = ",pass_hash='$pass_hash'";
					}
				$pass='';
				}

			$k=0;   $new_field_value='';
			if (is_array($max_inbound_filter_statuses)) {$multi_count = count($max_inbound_filter_statuses);} else {$multi_count=0;}
			$multi_array = $max_inbound_filter_statuses;
			while ($k < $multi_count)
				{
				$new_field_value .= "$multi_array[$k],";
				$k++;
				}
			$new_field_value = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$new_field_value);
			$max_inbound_filter_statuses = preg_replace("/,$/","",$new_field_value);

			$k=0;   $new_field_value='';
			if (is_array($max_inbound_filter_ingroups)) {$multi_count = count($max_inbound_filter_ingroups);} else {$multi_count=0;}
			$multi_array = $max_inbound_filter_ingroups;
			while ($k < $multi_count)
				{
				$new_field_value .= "$multi_array[$k],";
				$k++;
				}
			$new_field_value = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$new_field_value);
			$max_inbound_filter_ingroups = preg_replace("/,$/","",$new_field_value);

			$user_codeSQL = ",user_code='$user_code'";
			if ($SSuser_codes_admin > 0)
				{
				$user_codeSQL='';
				if ($LOGuser_level >= 9) {$user_codeSQL = ",user_code='$user_code'";}
				}

			echo "<br><B>"._QXZ("USER MODIFIED - ADMIN").": $user</B>\n";

			$stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',hotkeys_active='$hotkeys_active',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',closer_default_blended='$closer_default_blended',vicidial_recording_override='$vicidial_recording_override',alter_custdata_override='$alter_custdata_override',qc_enabled='$qc_enabled',qc_user_level='$qc_user_level',qc_pass='$qc_pass',qc_finish='$qc_finish',qc_commit='$qc_commit',alter_custphone_override='$alter_custphone_override',active='$active',agent_shift_enforcement_override='$agent_shift_enforcement_override',email='$email',territory='$territory',allow_alerts='$allow_alerts',agent_choose_territories='$agent_choose_territories',custom_one='$custom_one',custom_two='$custom_two',custom_three='$custom_three',custom_four='$custom_four',custom_five='$custom_five',voicemail_id='$voicemail_id',agent_call_log_view_override='$agent_call_log_view_override',agent_choose_blended='$agent_choose_blended',agent_lead_search_override='$agent_lead_search',preset_contact_search='$preset_contact_search',max_inbound_calls='$max_inbound_calls',wrapup_seconds_override='$wrapup_seconds_override',lead_filter_id='$lead_filter_id',user_hide_realtime='$user_hide_realtime',user_nickname='$user_nickname',user_new_lead_limit='$user_new_lead_limit',ready_max_logout='$ready_max_logout',failed_login_count=0,max_hopper_calls='$max_hopper_calls',max_hopper_calls_hour='$max_hopper_calls_hour',hide_call_log_info='$hide_call_log_info',next_dial_my_callbacks='$next_dial_my_callbacks',max_inbound_filter_enabled='$max_inbound_filter_enabled',max_inbound_filter_statuses='$max_inbound_filter_statuses',max_inbound_filter_ingroups='$max_inbound_filter_ingroups',max_inbound_filter_min_sec='$max_inbound_filter_min_sec',status_group_id='$status_group_id',mobile_number='$mobile_number',user_location='$user_location',user_group_two='$user_group_two',hci_enabled='$hci_enabled' $user_codeSQL $pass_hashSQL where user='$user' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);


			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmt_grp_values|";
			$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='$user', event_code='ADMIN MODIFY USER', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			###############################################################
			##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP #####
			$stmt = "SELECT enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url FROM system_settings;";
			$rslt=mysql_to_mysqli($stmt, $link);
			if ($DB) {echo "$stmt\n";}
			$ss_conf_ct = mysqli_num_rows($rslt);
			if ($ss_conf_ct > 0)
				{
				$row=mysqli_fetch_row($rslt);
				$enable_vtiger_integration =	$row[0];
				$vtiger_server_ip	=			$row[1];
				$vtiger_dbname =				$row[2];
				$vtiger_login =					$row[3];
				$vtiger_pass =					$row[4];
				$vtiger_url =					$row[5];
				}
			##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP #####
			#############################################################

			if ($enable_vtiger_integration > 0)
				{
				### connect to your vtiger database
				#$linkV=mysql_connect("$vtiger_server_ip", "$vtiger_login","$vtiger_pass");
				#if (!$linkV) {die("Could not connect: $vtiger_server_ip|$vtiger_dbname|$vtiger_login|$vtiger_pass" . mysqli_error());}
				#echo 'Connected successfully';
				#mysql_select_db("$vtiger_dbname", $linkV);
				$linkV=mysqli_connect("$vtiger_server_ip", "$vtiger_login", "$vtiger_pass", "$vtiger_dbname");
				if (!$linkV) 
					{
					die('MySQL '._QXZ("connect ERROR").': ' . mysqli_connect_error());
					}

				$user_name =		$user;
				$user_password =	$pass;
				$last_name =		$full_name;
				$is_admin =			'off';
				$roleid =			'H5';
				$status =			'Active';
				$groupid =			'1';
					if ($user_level >= 7) {$roleid = 'H3';}
					if ($user_level >= 8) {$roleid = 'H4';}
					if ($user_level >= 9) {$roleid = 'H2';}
					if ($user_level >= 9) {$is_admin = 'on';}
				$salt = substr($user_name, 0, 2);
				$salt = '$1$' . $salt . '$';
				$encrypted_password = crypt($user_password, $salt);
				### search for role in ViciDial
				$stmt = "SELECT vtiger_role FROM vtiger_vicidial_roles where user_level='$user_level';";
				$rslt=mysql_to_mysqli($stmt, $link);
				if ($DB) {echo "$stmt\n";}
				$vvr_ct = mysqli_num_rows($rslt);
				if ($vvr_ct > 0)
					{
					$row=mysqli_fetch_row($rslt);
					$roleid =	$row[0];
					}

				######################################
				##### BEGIN Add/Update group info in Vtiger
				$stmt="SELECT count(*) from vtiger_groups where groupname='$user_group';";
				$rslt=mysql_to_mysqli($stmt, $linkV);
				if ($DB) {echo "$stmt\n";}
				if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
				$row=mysqli_fetch_row($rslt);
				$group_found_count = $row[0];

				### group exists in vtiger, update it
				if ($group_found_count > 0)
					{
					$stmt="SELECT groupid from vtiger_groups where groupname='$user_group';";
					$rslt=mysql_to_mysqli($stmt, $linkV);
					if ($DB) {echo "$stmt\n";}
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
					$row=mysqli_fetch_row($rslt);
					$groupid = $row[0];
					}

				### user doesn't exist in vtiger, insert it
				else
					{
					#### BEGIN CREATE NEW GROUP RECORD IN VTIGER
					# Get next available id from vtiger_users_seq to use as groupid
					$stmt="SELECT id from vtiger_users_seq;";
					if ($DB) {echo "$stmt\n";}
					$rslt=mysql_to_mysqli($stmt, $linkV);
					$row=mysqli_fetch_row($rslt);
					$groupid = ($row[0] + 1);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					# Increase next available groupid with 1 so next record gets proper id
					$stmt="UPDATE vtiger_users_seq SET id = '$groupid';";
					if ($DB) {echo "$stmt\n";}
					$rslt=mysql_to_mysqli($stmt, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					$stmtA = "INSERT INTO vtiger_groups SET groupid='$groupid',groupname='$user_group',description='';";
					if ($DB) {echo "|$stmtA|\n";}
					$rslt=mysql_to_mysqli($stmtA, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					#### END CREATE NEW GROUP RECORD IN VTIGER
					}
				##### END Add/Update group info in Vtiger
				######################################

				######################################
				##### BEGIN Add/Update user info in Vtiger
				$stmt="SELECT count(*) from vtiger_users where user_name='$user_name';";
				$rslt=mysql_to_mysqli($stmt, $linkV);
				if ($DB) {echo "$stmt\n";}
				if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
				$row=mysqli_fetch_row($rslt);
				$found_count = $row[0];

				### user exists in vtiger, update it
				if ($found_count > 0)
					{
					$stmt="SELECT id from vtiger_users where user_name='$user_name';";
					$rslt=mysql_to_mysqli($stmt, $linkV);
					if ($DB) {echo "$stmt\n";}
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
					$row=mysqli_fetch_row($rslt);
					$userid = $row[0];

					$stmt="SELECT count(*) from vtiger_users2group WHERE userid='$userid' and groupid='$groupid';";
					$rslt=mysql_to_mysqli($stmt, $linkV);
					if ($DB) {echo "$stmt\n";}
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
					$row=mysqli_fetch_row($rslt);
					$usergroupcount = $row[0];

					$stmtA = "UPDATE vtiger_users SET user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status' where id='$userid';";
					if ($DB) {echo "|$stmtA|\n";}
					$rslt=mysql_to_mysqli($stmtA, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					$stmtB = "UPDATE vtiger_user2role SET roleid='$roleid' where userid='$userid';";
					if ($DB) {echo "|$stmtB|\n";}
					$rslt=mysql_to_mysqli($stmtB, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					if ($usergroupcount < 1)
						{
						$stmt="SELECT user_group FROM vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;";
						$rslt=mysql_to_mysqli($stmt, $link);
						if ($DB) {echo "$stmt\n";}
						$VD_groups_ct = mysqli_num_rows($rslt);
						$k=0;
						$VD_groups_list='';
						while ($k < $VD_groups_ct)
							{
							$row=mysqli_fetch_row($rslt);
							$VD_groups_list .= "'$row[0]',";
							$k++;
							}
						$VD_groups_list = preg_replace("/.$/",'',$VD_groups_list);

						$stmtC = "DELETE FROM vtiger_users2group WHERE userid='$userid' and groupid IN(SELECT groupid from vtiger_groups where groupname IN($VD_groups_list));";
						if ($DB) {echo "|$stmtC|\n";}
						$rslt=mysql_to_mysqli($stmtC, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						$stmtD = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';";
						if ($DB) {echo "|$stmtD|\n";}
						$rslt=mysql_to_mysqli($stmtD, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
						}
					}

				### user doesn't exist in vtiger, insert it
				else
					{
					#### BEGIN CREATE NEW USER RECORD IN VTIGER
					$stmtA = "INSERT INTO vtiger_users SET user_name='$user_name',user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status',date_format='yyyy-mm-dd',first_name='',reports_to_id='',description='',title='',department='',phone_home='',phone_mobile='',phone_work='',phone_other='',phone_fax='',email1='',email2='',yahoo_id='',signature='',address_street='',address_city='',address_state='',address_country='',address_postalcode='',user_preferences='',imagename='';";
					if ($DB) {echo "|$stmtA|\n";}
					$rslt=mysql_to_mysqli($stmtA, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
					$userid = mysqli_insert_id($linkV);
				
					$stmtB = "INSERT INTO vtiger_user2role SET userid='$userid',roleid='$roleid';";
					if ($DB) {echo "|$stmtB|\n";}
					$rslt=mysql_to_mysqli($stmtB, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					$stmtC = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';";
					if ($DB) {echo "|$stmtC|\n";}
					$rslt=mysql_to_mysqli($stmtC, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					$stmtD = "UPDATE vtiger_users_seq SET id='$userid';";
					if ($DB) {echo "|$stmtD|\n";}
					$rslt=mysql_to_mysqli($stmtD, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					#### END CREATE NEW USER RECORD IN VTIGER
					}
				##### END Add/Update user info in Vtiger
				######################################
				}
			### END vtiger integration
			}
		}
		else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=3;		# go to user modification below
	}


######################
# ADD=4 submit user modifications to the system
######################
if ($ADD==4)
	{
	if ($LOGmodify_users==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$enc_pass_nochange=0;
		if ( ($SSpass_hash_enabled > 0) and (strlen($pass) < 1) ) {$enc_pass_nochange=1;}

		if ( ( (strlen($pass) < 2) and ($SSpass_hash_enabled < 1) ) or (strlen($full_name) < 2) or (strlen($user_level) < 1) or ( ($SSrequire_password_length > 0) and ($SSrequire_password_length > strlen($pass)) and ($enc_pass_nochange < 1) ) )
			{
			echo "<br>"._QXZ("USER NOT MODIFIED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("Password and Full Name each need to be at least 2 characters in length")."\n";
			if ($SSrequire_password_length > 0)
				{
				echo "<br>"._QXZ("Password must be at least $SSrequire_password_length characters long")."\n";
				}
			}
		else
			{
			$pass_hash='';
			$pass_hashSQL='';
			if ($SSpass_hash_enabled > 0)
				{
				if (strlen($pass) > 1)
					{
					$pass = preg_replace("/\'|\"|\\\\|;|<|>| /","",$pass);
					$pass_hash = exec("../agc/bp.pl --pass=$pass");
					$pass_hash = preg_replace("/PHASH: |\n|\r|\t| /",'',$pass_hash);
					$pass_hashSQL = ",pass_hash='$pass_hash'";
					}
				$pass='';
				}

			$user_codeSQL = ",user_code='$user_code'";
			if ($SSuser_codes_admin > 0)
				{
				$user_codeSQL='';
				if ($LOGuser_level >= 9) {$user_codeSQL = ",user_code='$user_code'";}
				}

			echo "<br><B>"._QXZ("USER MODIFIED").": $user</B>\n";

			$stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',active='$active',email='$email',territory='$territory',user_nickname='$user_nickname',user_new_lead_limit='$user_new_lead_limit',failed_login_count=0,mobile_number='$mobile_number',user_location='$user_location',user_group_two='$user_group_two' $user_codeSQL $pass_hashSQL where user='$user' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='$user', event_code='ADMIN MODIFY USER', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			###############################################################
			##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP #####
			$stmt = "SELECT enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url FROM system_settings;";
			$rslt=mysql_to_mysqli($stmt, $link);
			if ($DB) {echo "$stmt\n";}
			$ss_conf_ct = mysqli_num_rows($rslt);
			if ($ss_conf_ct > 0)
				{
				$row=mysqli_fetch_row($rslt);
				$enable_vtiger_integration =	$row[0];
				$vtiger_server_ip	=			$row[1];
				$vtiger_dbname =				$row[2];
				$vtiger_login =					$row[3];
				$vtiger_pass =					$row[4];
				$vtiger_url =					$row[5];
				}
			##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP #####
			#############################################################

			if ($enable_vtiger_integration > 0)
				{
				### connect to your vtiger database
				#$linkV=mysql_connect("$vtiger_server_ip", "$vtiger_login","$vtiger_pass");
				#if (!$linkV) {die("Could not connect: $vtiger_server_ip|$vtiger_dbname|$vtiger_login|$vtiger_pass" . mysqli_error());}
				#echo 'Connected successfully';
				#mysql_select_db("$vtiger_dbname", $linkV);
				$linkV=mysqli_connect("$vtiger_server_ip", "$vtiger_login", "$vtiger_pass", "$vtiger_dbname");
				if (!$linkV) 
					{
					die('MySQL '._QXZ("connect ERROR").': ' . mysqli_connect_error());
					}

				$user_name =		$user;
				$user_password =	$pass;
				$last_name =		$full_name;
				$is_admin =			'off';
				$roleid =			'H5';
				$status =			'Active';
				$groupid =			'1';
					if ($user_level >= 7) {$roleid = 'H3';}
					if ($user_level >= 8) {$roleid = 'H4';}
					if ($user_level >= 9) {$roleid = 'H2';}
					if ($user_level >= 9) {$is_admin = 'on';}
				$salt = substr($user_name, 0, 2);
				$salt = '$1$' . $salt . '$';
				$encrypted_password = crypt($user_password, $salt);
				### search for role in ViciDial
				$stmt = "SELECT vtiger_role FROM vtiger_vicidial_roles where user_level='$user_level';";
				$rslt=mysql_to_mysqli($stmt, $link);
				if ($DB) {echo "$stmt\n";}
				$vvr_ct = mysqli_num_rows($rslt);
				if ($vvr_ct > 0)
					{
					$row=mysqli_fetch_row($rslt);
					$roleid =	$row[0];
					}

				######################################
				##### BEGIN Add/Update group info in Vtiger
				$stmt="SELECT count(*) from vtiger_groups where groupname='$user_group';";
				$rslt=mysql_to_mysqli($stmt, $linkV);
				if ($DB) {echo "$stmt\n";}
				if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
				$row=mysqli_fetch_row($rslt);
				$group_found_count = $row[0];

				### group exists in vtiger, update it
				if ($group_found_count > 0)
					{
					$stmt="SELECT groupid from vtiger_groups where groupname='$user_group';";
					$rslt=mysql_to_mysqli($stmt, $linkV);
					if ($DB) {echo "$stmt\n";}
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
					$row=mysqli_fetch_row($rslt);
					$groupid = $row[0];
					}

				### user doesn't exist in vtiger, insert it
				else
					{
					#### BEGIN CREATE NEW GROUP RECORD IN VTIGER
					# Get next available id from vtiger_users_seq to use as groupid
					$stmt="SELECT id from vtiger_users_seq;";
					if ($DB) {echo "$stmt\n";}
					$rslt=mysql_to_mysqli($stmt, $linkV);
					$row=mysqli_fetch_row($rslt);
					$groupid = ($row[0] + 1);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					# Increase next available groupid with 1 so next record gets proper id
					$stmt="UPDATE vtiger_users_seq SET id = '$groupid';";
					if ($DB) {echo "$stmt\n";}
					$rslt=mysql_to_mysqli($stmt, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					$stmtA = "INSERT INTO vtiger_groups SET groupid='$groupid',groupname='$user_group',description='';";
					if ($DB) {echo "|$stmtA|\n";}
					$rslt=mysql_to_mysqli($stmtA, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					#### END CREATE NEW GROUP RECORD IN VTIGER
					}
				##### END Add/Update group info in Vtiger
				######################################

				######################################
				##### BEGIN Add/Update user info in Vtiger
				$stmt="SELECT count(*) from vtiger_users where user_name='$user_name';";
				$rslt=mysql_to_mysqli($stmt, $linkV);
				if ($DB) {echo "$stmt\n";}
				if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
				$row=mysqli_fetch_row($rslt);
				$found_count = $row[0];

				### user exists in vtiger, update it
				if ($found_count > 0)
					{
					$stmt="SELECT id from vtiger_users where user_name='$user_name';";
					$rslt=mysql_to_mysqli($stmt, $linkV);
					if ($DB) {echo "$stmt\n";}
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
					$row=mysqli_fetch_row($rslt);
					$userid = $row[0];

					$stmt="SELECT count(*) from vtiger_users2group WHERE userid='$userid' and groupid='$groupid';";
					$rslt=mysql_to_mysqli($stmt, $linkV);
					if ($DB) {echo "$stmt\n";}
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
					$row=mysqli_fetch_row($rslt);
					$usergroupcount = $row[0];

					$stmtA = "UPDATE vtiger_users SET user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status' where id='$userid';";
					if ($DB) {echo "|$stmtA|\n";}
					$rslt=mysql_to_mysqli($stmtA, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					$stmtB = "UPDATE vtiger_user2role SET roleid='$roleid' where userid='$userid';";
					if ($DB) {echo "|$stmtB|\n";}
					$rslt=mysql_to_mysqli($stmtB, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					if ($usergroupcount < 1)
						{
						$stmt="SELECT user_group FROM vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;";
						$rslt=mysql_to_mysqli($stmt, $link);
						if ($DB) {echo "$stmt\n";}
						$VD_groups_ct = mysqli_num_rows($rslt);
						$k=0;
						$VD_groups_list='';
						while ($k < $VD_groups_ct)
							{
							$row=mysqli_fetch_row($rslt);
							$VD_groups_list .= "'$row[0]',";
							$k++;
							}
						$VD_groups_list = preg_replace("/.$/",'',$VD_groups_list);

						$stmtC = "DELETE FROM vtiger_users2group WHERE userid='$userid' and groupid IN(SELECT groupid from vtiger_groups where groupname IN($VD_groups_list));";
						if ($DB) {echo "|$stmtC|\n";}
						$rslt=mysql_to_mysqli($stmtC, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						$stmtD = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';";
						if ($DB) {echo "|$stmtD|\n";}
						$rslt=mysql_to_mysqli($stmtD, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
						}
					}

				### user doesn't exist in vtiger, insert it
				else
					{
					#### BEGIN CREATE NEW USER RECORD IN VTIGER
					$stmtA = "INSERT INTO vtiger_users SET user_name='$user_name',user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status',date_format='yyyy-mm-dd',first_name='',reports_to_id='',description='',title='',department='',phone_home='',phone_mobile='',phone_work='',phone_other='',phone_fax='',email1='',email2='',yahoo_id='',signature='',address_street='',address_city='',address_state='',address_country='',address_postalcode='',user_preferences='',imagename='';";
					if ($DB) {echo "|$stmtA|\n";}
					$rslt=mysql_to_mysqli($stmtA, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
					$userid = mysqli_insert_id($linkV);
				
					$stmtB = "INSERT INTO vtiger_user2role SET userid='$userid',roleid='$roleid';";
					if ($DB) {echo "|$stmtB|\n";}
					$rslt=mysql_to_mysqli($stmtB, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					$stmtC = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';";
					if ($DB) {echo "|$stmtC|\n";}
					$rslt=mysql_to_mysqli($stmtC, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					$stmtD = "UPDATE vtiger_users_seq SET id='$userid';";
					if ($DB) {echo "|$stmtD|\n";}
					$rslt=mysql_to_mysqli($stmtD, $linkV);
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

					#### END CREATE NEW USER RECORD IN VTIGER
					}
				##### END Add/Update user info in Vtiger
				######################################
				}
			### END vtiger integration
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=3;		# go to user modification below
	}


######################
# ADD=41 submit campaign modifications to the system - DETAIL
######################
if ($ADD==41)
	{
	if ($LOGmodify_campaigns==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ($SSoutbound_autodial_active < 1)
			{
			$adaptive_dl_diff_target =		'0';
			$dl_diff_target_method =		'ADAPT_CALC_ONLY';
			$adaptive_dropped_percentage =	'99';
			$adaptive_intensity =			'0';
			$adaptive_latest_server_time =	'2359';
			$adaptive_maximum_level =		'1.0';
			$agent_extended_alt_dial =		'N';
			$alt_number_dialing =			'N';
			$timer_alt_seconds =			'0';
			$am_message_exten =				'8320';
			$vmm_daily_limit =				'0';
			$amd_send_to_vmx =				'N';
			$auto_alt_dial =				'NONE';
			$auto_dial_level =				'1.0';
			$available_only_ratio_tally =	'Y';
			$campaign_allow_inbound =		'Y';
			$campaign_vdad_exten =			'8368';
			$concurrent_transfers =			'AUTO';
			$dial_method =					'RATIO';
			$dial_status =					'';
			$dial_timeout =					'60';
			$drop_action =					'HANGUP';
			$drop_call_seconds =			'5';
			$drop_inbound_group =			'---NONE---';
			$force_reset_hopper =			'N';
			$hopper_level =					'5';
			$lead_filter_id =				'NONE';
			$lead_order =					'DOWN';
			$list_order_mix =				'DISABLED';
			$no_hopper_leads_logins =		'Y';
			$queue_priority =				'50';
			$safe_harbor_exten =			'8300';
			$safe_harbor_audio =			'buzz';
			$safe_harbor_audio_field =		'DISABLED';
			$safe_harbor_menu_id =			'';
			$survey_camp_record_dir =		'/home/survey';
			$survey_dtmf_digits =			'1238';
			$survey_wait_sec =				'10';
			$survey_first_audio_file =		'US_pol_survey_hello';
			$survey_method =				'AGENT_XFER';
			$survey_ni_audio_file =			'US_thanks_no_contact';
			$survey_ni_digit =				'8';
			$survey_ni_status =				'NI';
			$survey_no_response_action =	'OPTIN';
			$survey_opt_in_audio_file =		'US_pol_survey_transfer';
			$survey_response_digit_map =	'1-DEMOCRAT|2-REPUBLICAN|3-INDEPENDANT|8-OPTOUT|X-NO RESPONSE|';
			$survey_xfer_exten =			'8300';
			$survey_third_audio_file =		'US_thanks_no_contact';
			$survey_fourth_audio_file =		'US_thanks_no_contact';
			$voicemail_ext =				'';
			$cpd_amd_action =				'DISABLED';
			$cpd_unknown_action =			'DISABLED';
			$drop_lockout_time =			'0';
			$call_count_limit =				'0';
			$call_count_target =			'0';
			$lead_order_randomize =			'N';
			$lead_order_secondary =			'LEAD_ASCEND';
			$amd_inbound_group =			'';
			$amd_callmenu =					'';
			}
		if ( (preg_match('/list_activation/',$stage)) or (preg_match('/test_call/',$stage)) )
			{
			if (preg_match('/test_call/',$stage))
				{
				$p=0;
				echo "<BR>"._QXZ("TEST CALL").":";

				if (strlen($phone_number)<6)
					{
					echo " "._QXZ("NOT PLACED, number too small")." - $phone_number";
					}
				else
					{
					### insert a new lead in the system with this phone number
					$stmtA = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$manual_dial_list_id',status='CTCALL',user='VDAD',called_since_last_reset='Y',entry_date='$SQLdate',last_local_call_time='$SQLdate',called_count='1',first_name='Test',last_name='Call',address1='Test Call',address2='2',address3='3',city='Springfield',state='IL',vendor_lead_code='999999',comments='$campaign_id test call placed $SQLdate',rank='99',owner='Test Outbound Call';";
					if ($DB) {echo "$stmtA\n";}
					$rslt=mysql_to_mysqli($stmtA, $link);
					$affected_rows = mysqli_affected_rows($link);
					$lead_id = mysqli_insert_id($link);

					### LOG INSERTION Admin Log Table, for lead ###
					$SQL_log = "$stmtA|";
					$SQL_log = preg_replace('/;/', '', $SQL_log);
					$SQL_log = addslashes($SQL_log);
					$stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LEADS', event_type='ADD', record_id='$lead_id', event_code='ADMIN ADD TEST LEAD', event_sql=\"$SQL_log\", event_notes='';";
					$rslt=mysql_to_mysqli($stmt, $link);

					### gather list_id overrides
					$stmt="SELECT campaign_cid_override,cid_group_id FROM vicidial_lists where list_id='$manual_dial_list_id' $LOGallowed_campaignsSQL;";
					$rslt=mysql_to_mysqli($stmt, $link);
					if ($DB) {echo "$stmt\n";}
					$CIDor_ct = mysqli_num_rows($rslt);
					$campaign_cid_override='';
					if ($CIDor_ct > 0)
						{
						$row=mysqli_fetch_row($rslt);
						$campaign_cid_override =		$row[0];
						$campaign_cid_group_override =	$row[1];
						}

					### gather server information
					$stmt="SELECT asterisk_version,routing_prefix,server_id FROM servers where server_ip='$old_server_ip';";
					$rslt=mysql_to_mysqli($stmt, $link);
					if ($DB) {echo "$stmt\n";}
					$srv_ct = mysqli_num_rows($rslt);
					$asterisk_version='';
					$routing_prefix='';
					if ($srv_ct > 0)
						{
						$row=mysqli_fetch_row($rslt);
						$asterisk_version =		$row[0];
						$routing_prefix =		$row[1];
						$server_id =			$row[2];
						}

					$CCID_on=0;   $CCID='';
					$local_DEF = 'Local/';
					$local_AMP = '@';
					$Local_out_prefix = '9';
					$Local_dial_timeout = '60';
					if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;}
					$Local_dial_timeout = ($Local_dial_timeout * 1000);
					if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";}
					if (strlen($campaign_vdad_exten) > 0) {$VDAD_dial_exten = "$campaign_vdad_exten";}
					else {$VDAD_dial_exten = "$SSanswer_transfer_agent";}
					$major_version = explode('.',$asterisk_version);
					if ($major_version[0] >= 12)
						{
						$VDAD_dial_exten = "$routing_prefix$VDAD_dial_exten";
						}
					if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid";   $CCID_on++;}
					if (strlen($campaign_cid_override) > 6) {$CCID = "$campaign_cid_override";   $CCID_on++;}
					if (preg_match("/x/",$dial_prefix)) {$Local_out_prefix = '';}
					if (strlen($ext_context) < 1) {$ext_context='default';}
					if (preg_match('/Y/i', $omit_phone_code)) {$Ndialstring = "$Local_out_prefix$phone_number";}
					else {$Ndialstring = "$Local_out_prefix$phone_code$phone_number";}

					# generate callerID for unique identifier in xfer_log file
					$PADlead_id = sprintf("%010s", $lead_id);	while (strlen($PADlead_id) > 10) {$PADlead_id = substr("$PADlead_id", 1);}
					# Create unique calleridname to track the call: VmddhhmmssLLLLLLLLLL
					$VqueryCID = "V$CIDdate$PADlead_id";

					if ($CCID_on) {$CIDstring = "\"$VqueryCID\" <$CCID>";}
					else {$CIDstring = "$VqueryCID";}

					### insert a NEW record to the vicidial_manager table to be processed
					$stmtB = "INSERT INTO vicidial_manager(uniqueid,entry_date,status,response,server_ip,channel,action,callerid,cmd_line_b,cmd_line_c,cmd_line_d,cmd_line_e,cmd_line_f,cmd_line_g,cmd_line_h,cmd_line_i,cmd_line_j,cmd_line_k) values('','$SQLdate','NEW','N','$old_server_ip','','Originate','$VqueryCID','Exten: $VDAD_dial_exten','Context: $ext_context','Channel: $local_DEF$Ndialstring$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','VDACnote: $campaign_id|$lead_id|$phone_code|$phone_number|OUT|MAIN|99')";
					$rslt=mysql_to_mysqli($stmtB, $link);

					### insert a SENT record to the vicidial_auto_calls table 
					$stmtC = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,callerid,phone_code,phone_number,call_time,call_type,alt_dial,queue_priority) values('$old_server_ip','$campaign_id','SENT','$lead_id','$VqueryCID','$phone_code','$phone_number','$SQLdate','OUT','MAIN','99')";
					$rslt=mysql_to_mysqli($stmtC, $link);

					### insert a record in the vicidial_dial_log table 
					$stmtD = "INSERT INTO vicidial_dial_log SET caller_code='$VqueryCID',lead_id='$lead_id',server_ip='$old_server_ip',call_date='$SQLdate',extension='$VDAD_dial_exten',channel='$local_DEF$Ndialstring$local_AMP$ext_context',timeout='$Local_dial_timeout',outbound_cid='$CIDstring',context='$ext_context';";
					$rslt=mysql_to_mysqli($stmtD, $link);

					### log outbound call in the dial cid log
					$stmt = "INSERT INTO vicidial_dial_cid_log SET caller_code='$VqueryCID',call_date='$SQLdate',call_type='MANUAL',call_alt='MAIN', outbound_cid='$CCID',outbound_cid_type='CAMPAIGN_TEST';";
					if ($DB) {echo "$stmt\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
						if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);}

					### log outbound call in the user dial log
					$stmt = "INSERT INTO vicidial_user_dial_log SET caller_code='$VqueryCID',user='$PHP_AUTH_USER',call_date='$SQLdate',call_type='M',notes='Admin test call CAMPAIGN_TEST';";
					if ($DB) {echo "$stmt\n";}
					$rslt=mysql_to_mysqli($stmt, $link);

					### log outbound call in the user call log
					$stmt = "INSERT INTO user_call_log (user,call_date,call_type,server_ip,phone_number,number_dialed,lead_id,callerid,group_alias_id,preset_name) values('$PHP_AUTH_USER','$SQLdate','ADMIN','$old_server_ip','$phone_number','$Ndialstring','$lead_id','$CCID','','')";
					if ($DB) {echo "$stmt\n";}
					$rslt=mysql_to_mysqli($stmt, $link);

					### LOG INSERTION Admin Log Table, for campaign ###
					$SQL_log = "$stmtA|$stmtB|$stmtC|";
					$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='CAMPAIGNS', event_type='OTHER', record_id='$campaign_id', event_code='ADMIN CAMPAIGN TEST CALL', event_sql=\"$SQL_log\", event_notes='Placed call to $phone_code $phone_number from $old_server_ip - $server_id';";
					$rslt=mysql_to_mysqli($stmt, $link);

					if ($DB > 0) {echo "|$stmtA|\n|$stmtB|\n|$stmtC|\n";}
					echo " "._QXZ("PLACED TO")." $phone_code $phone_number "._QXZ("FROM")." $old_server_ip - $server_id \n<BR>";
					}
				}

			if (preg_match('/list_activation/',$stage))
				{
				$p=0;
				echo "<BR>"._QXZ("ACTIVE LISTS CHANGED");
				if(!is_array($list_active_change)) {$list_active_change=array();}
				$list_active_change_ct = count($list_active_change);
				while ($p < $list_active_change_ct)
					{
					$list_active_change[$p] = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$list_active_change[$p]);
					$LIST_ACTIVATE .= "'$list_active_change[$p]',";
					$p++;
					}
				
				$stmt = "UPDATE vicidial_lists SET active='Y' where list_id IN($LIST_ACTIVATE'') and campaign_id='$campaign_id';";
				$stmtB = "UPDATE vicidial_lists SET active='N' where list_id NOT IN($LIST_ACTIVATE'') and campaign_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$rslt=mysql_to_mysqli($stmtB, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtB|";
				$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='CAMPAIGNS', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN ACTIVE LISTS', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);

				if ($DB > 0) {echo "|$stmt|\n|$stmtB|\n";}
				}
			}
		else
			{
			if ( (strlen($campaign_name) < 6) or (strlen($active) < 1) )
				{
				echo "<br>"._QXZ("CAMPAIGN NOT MODIFIED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("the campaign name needs to be at least 6 characters in length")."\n";
				echo "<br>|$campaign_name|$active|\n";
				}
			else
				{
				if ($form_end != 'END')
					{
					echo "<br>"._QXZ("CAMPAIGN NOT MODIFIED - Please wait for the whole page to load before submitting the form")."\n";
					}
				else
					{
					if ($campaign_rec_filename == $stereo_rec_filename)
						{
						$stereo_rec_filename = "X".$stereo_rec_filename;
						echo "<br><B><font color='red'>"._QXZ("Stereo Recording Filename identical to Recording Filename, so it has been appended ").": $stereo_rec_filename ($campaign_rec_filename)</font></B>\n";
						}
					if ( (strlen($parallel_rec_co_filename) > 0) and ( ($campaign_rec_filename == $parallel_rec_co_filename) or ($stereo_rec_filename == $parallel_rec_co_filename) or ($parallel_rec_cm_filename == $parallel_rec_co_filename) or ($parallel_rec_fr_filename == $parallel_rec_co_filename) ) )
						{
						$parallel_rec_co_filename = "CO".$parallel_rec_co_filename;
						echo "<br><B><font color='red'>"._QXZ("Parallel Customer-Only Recording Filename identical to another Recording Filename, so it has been appended ").": $parallel_rec_co_filename</font></B>\n";
						}
					if ( (strlen($parallel_rec_cm_filename) > 0) and ( ($campaign_rec_filename == $parallel_rec_cm_filename) or ($stereo_rec_filename == $parallel_rec_cm_filename) or ($parallel_rec_co_filename == $parallel_rec_cm_filename) or ($parallel_rec_fr_filename == $parallel_rec_cm_filename) ) )
						{
						$parallel_rec_cm_filename = "CM".$parallel_rec_cm_filename;
						echo "<br><B><font color='red'>"._QXZ("Parallel Customer-Muted Recording Filename identical to another Recording Filename, so it has been appended ").": $parallel_rec_cm_filename</font></B>\n";
						}
					if ( (strlen($parallel_rec_fr_filename) > 0) and ( ($campaign_rec_filename == $parallel_rec_fr_filename) or ($stereo_rec_filename == $parallel_rec_fr_filename) or ($parallel_rec_co_filename == $parallel_rec_fr_filename) or ($parallel_rec_cm_filename == $parallel_rec_fr_filename) ) )
						{
						$parallel_rec_fr_filename = "FR".$parallel_rec_fr_filename;
						echo "<br><B><font color='red'>"._QXZ("Parallel Full-Recording Recording Filename identical to another Recording Filename, so it has been appended ").": $parallel_rec_fr_filename</font></B>\n";
						}

					echo "<br><B>"._QXZ("CAMPAIGN MODIFIED").": $campaign_id</B>\n";

					if ( ($dial_method == 'MANUAL') or ($dial_method == 'INBOUND_MAN') )
						{
						$auto_alt_dial = 'NONE';
						}
					if ( ($dial_method != 'MANUAL') and ($dial_method != 'INBOUND_MAN') )
						{
						$no_hopper_dialing='N';
						$agent_dial_owner_only='NONE';
						}
					if ($no_hopper_dialing == 'Y')
						{
						$use_auto_hopper='N';
						$auto_alt_dial='NONE';
						$list_order_mix='DISABLED';
						}
					if ($dial_method == 'MANUAL') 
						{
						$auto_dial_level='0';
						$use_auto_hopper='N';
						$adlSQL = "auto_dial_level='0',";
						$campaign_allow_inbound='N';
						}
					else
						{
						if ($dial_level_override > 0)
							{
							$adlSQL = "auto_dial_level='$auto_dial_level',";
							}
						else
							{
							if ( ($dial_method == 'RATIO') or ($dial_method == 'SHARED_RATIO') )
								{
								if ($auto_dial_level < 1) {$auto_dial_level = "1.0";}
								$adlSQL = "auto_dial_level='$auto_dial_level',";
								}
							else
								{
								$adlSQL = "";
								if ($auto_dial_level < 1) 
									{
									$auto_dial_level = "1.0";
									$adlSQL = "auto_dial_level='$auto_dial_level',";
									}
								}
							}
						}
					if ( (!preg_match('/DISABLED/', $list_order_mix)) and ($hopper_level < 100) )
						{$hopper_level='100';}
					$closer_campaignsSQL = "'$groups_value'";
					if ( ($campaign_allow_inbound == 'N') or ($old_campaign_allow_inbound == 'N') )
						{
						$closer_campaignsSQL = 'closer_campaigns';
						$groups_list='';

						$stmt="SELECT closer_campaigns from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
						$rslt=mysql_to_mysqli($stmt, $link);
						$row=mysqli_fetch_row($rslt);
						$Mcloser_campaigns =	$row[0];
						$Mcloser_campaigns = preg_replace("/ -$/","",$Mcloser_campaigns);
						$groups = explode(" ", $Mcloser_campaigns);

						$o=0;
						while ($groups_to_print > $o)
							{
							$groups_list .= "<input type=\"checkbox\" name=\"groups[]\" value=\"$group_id_values[$o]\"";
							$p=0;
							$group_ct = count($groups);
							while ($p < $group_ct)
								{
								if ($group_id_values[$o] === $groups[$p]) 
									{
									$groups_list .= " CHECKED";
									$groups_value .= " $group_id_values[$o]";
									}
								$p++;
								}
							$stmt="SELECT queue_priority from vicidial_inbound_groups where group_id='$group_id_values[$o]' $LOGadmin_viewable_groupsSQL;";
							$rslt=mysql_to_mysqli($stmt, $link);
							$row=mysqli_fetch_row($rslt);
							$VIG_priority =			$row[0];
							$groups_list .= "> <a href=\"$PHP_SELF?ADD=3111&group_id=$group_id_values[$o]\">$group_id_values[$o]</a> - $group_name_values[$o] - $VIG_priority <BR>\n";

							$o++;
							}
						if (strlen($groups_value)>2) {$groups_value .= " -";}
						}
					if ( ($amd_agent_route_options == 'ENABLED') or ($amd_agent_route_options == 'PENDING') )
						{
						$stmt="SELECT count(*) from vicidial_settings_containers where container_id='AMD_AGENT_OPT_$campaign_id';";
						$rslt=mysql_to_mysqli($stmt, $link);
						$row=mysqli_fetch_row($rslt);
						$AMDAOcount =	$row[0];

						if ($AMDAOcount < 1)
							{
							$stmt = "INSERT INTO vicidial_settings_containers SET container_id='AMD_AGENT_OPT_$campaign_id',container_type='AMD_AGENT_OPTIONS',container_entry='',container_notes='AMD agent options for $campaign_id campaign';";
							$rslt=mysql_to_mysqli($stmt, $link);

							### LOG INSERTION Admin Log Table ###
							$SQL_log = "$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='CONTAINERS', event_type='ADD', record_id='AMD_AGENT_OPT_$campaign_id', event_code='ADMIN ADD CONTAINER', event_sql=\"$SQL_log\", event_notes='';";
							if ($DB) {echo "|$stmt|\n";}
							$rslt=mysql_to_mysqli($stmt, $link);

							if ($DB > 0) {echo "|$stmt|\n";}
							}
						}

					if ( ($pause_max < 10) or (strlen($pause_max)<2) )
						{$pause_max=0;}
					if ( ($ready_max_logout < 10) or (strlen($ready_max_logout)<2) )
						{$ready_max_logout=0;}
					if ( ($pause_max > 9) and ($pause_max <= $dial_timeout) )
						{$pause_max = ($dial_timeout + 10);}
					if ($dial_timeout < 4) {$dial_timeout='30';}
					if ( ($manual_auto_next > 0) and ($manual_auto_next < 5) ) {$manual_auto_next='5';}
					if ( ($agent_select_territories != 'Y') and ($agent_select_territories != 'N') ) {$agent_select_territories='N';}
					if (strlen($max_inbound_calls_outcome) < 1) {$max_inbound_calls_outcome='DEFAULT';}
					$hdrtSQL='';   $hdrtMESSAGE='';
					if ($hopper_drop_run_trigger == 'Y')
						{
						$hdrtSQL = ",hopper_drop_run_trigger='Y'";
						$hdrtMESSAGE='Hopper Drop-Run Triggered';
						}
					if ($hopper_drop_run_trigger_all == 'A')
						{
						$hdrtSQL = ",hopper_drop_run_trigger='A'";
						$hdrtMESSAGE='Hopper All-Drops-Run Triggered';
						}
					if ($demographic_quotas == 'ENABLED') {$use_auto_hopper='N';}
					$prefixSQL='';
					if ($LOGmodify_dial_prefix > 0)
						{$prefixSQL = ",dial_prefix='$dial_prefix',manual_dial_prefix='$manual_dial_prefix',three_way_dial_prefix='$three_way_dial_prefix'";}

					$stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',allow_closers='$allow_closers',hopper_level='$hopper_level', auto_trim_hopper='$auto_trim_hopper', use_auto_hopper='$use_auto_hopper', auto_hopper_multi='$auto_hopper_multi', $adlSQL next_agent_call='$next_agent_call', local_call_time='$local_call_time', voicemail_ext='$voicemail_ext', dial_timeout='$dial_timeout', campaign_cid='$campaign_cid', campaign_vdad_exten='$campaign_vdad_exten', web_form_address='" . mysqli_real_escape_string($link, $web_form_address) . "', park_ext='$park_ext', park_file_name='$park_file_name', campaign_rec_exten='$campaign_rec_exten', campaign_recording='$campaign_recording', campaign_rec_filename='$campaign_rec_filename', campaign_script='$script_id', get_call_launch='$get_call_launch', am_message_exten='$am_message_exten', amd_send_to_vmx='$amd_send_to_vmx', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number',xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',lead_filter_id='$lead_filter_id',alt_number_dialing='$alt_number_dialing',scheduled_callbacks='$scheduled_callbacks',drop_action='$drop_action',drop_call_seconds='$drop_call_seconds',safe_harbor_exten='$safe_harbor_exten',wrapup_seconds='$wrapup_seconds',wrapup_message='$wrapup_message',closer_campaigns=$closer_campaignsSQL,use_internal_dnc='$use_internal_dnc',allcalls_delay='$allcalls_delay',omit_phone_code='$omit_phone_code',dial_method='$dial_method',available_only_ratio_tally='$available_only_ratio_tally',adaptive_dropped_percentage='$adaptive_dropped_percentage',adaptive_maximum_level='$adaptive_maximum_level',adaptive_latest_server_time='$adaptive_latest_server_time',adaptive_intensity='$adaptive_intensity',adaptive_dl_diff_target='$adaptive_dl_diff_target',concurrent_transfers='$concurrent_transfers',auto_alt_dial='$auto_alt_dial',agent_pause_codes_active='$agent_pause_codes_active',campaign_description='$campaign_description',campaign_changedate='$SQLdate',campaign_stats_refresh='$campaign_stats_refresh',disable_alter_custdata='$disable_alter_custdata',no_hopper_leads_logins='$no_hopper_leads_logins',list_order_mix='$list_order_mix',campaign_allow_inbound='$campaign_allow_inbound',manual_dial_list_id='$manual_dial_list_id',default_xfer_group='$default_xfer_group',xfer_groups='$XFERgroups_value',queue_priority='$queue_priority',drop_inbound_group='$drop_inbound_group',disable_alter_custphone='$disable_alter_custphone',display_queue_count='$display_queue_count',manual_dial_filter='$manual_dial_filter',agent_clipboard_copy='$agent_clipboard_copy',agent_extended_alt_dial='$agent_extended_alt_dial',use_campaign_dnc='$use_campaign_dnc',three_way_call_cid='$three_way_call_cid',web_form_target='$web_form_target',vtiger_search_category='$vtiger_search_category',vtiger_create_call_record='$vtiger_create_call_record',vtiger_create_lead_record='$vtiger_create_lead_record',vtiger_screen_login='$vtiger_screen_login',cpd_amd_action='$cpd_amd_action',agent_allow_group_alias='$agent_allow_group_alias',default_group_alias='$default_group_alias',vtiger_search_dead='$vtiger_search_dead',vtiger_status_call='$vtiger_status_call',drop_lockout_time='$drop_lockout_time',quick_transfer_button='$quick_transfer_button',prepopulate_transfer_preset='$prepopulate_transfer_preset',drop_rate_group='$drop_rate_group',view_calls_in_queue='$view_calls_in_queue',view_calls_in_queue_launch='$view_calls_in_queue_launch',grab_calls_in_queue='$grab_calls_in_queue',call_requeue_button='$call_requeue_button',pause_after_each_call='$pause_after_each_call',no_hopper_dialing='$no_hopper_dialing',agent_dial_owner_only='$agent_dial_owner_only',agent_display_dialable_leads='$agent_display_dialable_leads',web_form_address_two='" . mysqli_real_escape_string($link, $web_form_address_two) . "',waitforsilence_options='$waitforsilence_options',agent_select_territories='$agent_select_territories',crm_popup_login='$crm_popup_login',crm_login_address='" . mysqli_real_escape_string($link, $crm_login_address) . "',timer_action='$timer_action',timer_action_message='$timer_action_message',timer_action_seconds='$timer_action_seconds',start_call_url='" . mysqli_real_escape_string($link, $start_call_url) . "',dispo_call_url='" . mysqli_real_escape_string($link, $dispo_call_url) . "',xferconf_c_number='$xferconf_c_number',xferconf_d_number='$xferconf_d_number',xferconf_e_number='$xferconf_e_number',use_custom_cid='$use_custom_cid',scheduled_callbacks_alert='$scheduled_callbacks_alert',queuemetrics_callstatus_override='$queuemetrics_callstatus',extension_appended_cidname='$extension_appended_cidname',scheduled_callbacks_count='$scheduled_callbacks_count',manual_dial_override='$manual_dial_override',blind_monitor_warning='$blind_monitor_warning',blind_monitor_message='" . mysqli_real_escape_string($link, $blind_monitor_message) . "',blind_monitor_filename='$blind_monitor_filename',inbound_queue_no_dial='$inbound_queue_no_dial',timer_action_destination='$timer_action_destination',enable_xfer_presets='$enable_xfer_presets',hide_xfer_number_to_dial='$hide_xfer_number_to_dial',customer_3way_hangup_logging='$customer_3way_hangup_logging',customer_3way_hangup_seconds='$customer_3way_hangup_seconds',customer_3way_hangup_action='$customer_3way_hangup_action',ivr_park_call='$ivr_park_call',ivr_park_call_agi='$ivr_park_call_agi',manual_preview_dial='$manual_preview_dial',realtime_agent_time_stats='$realtime_agent_time_stats',api_manual_dial='$api_manual_dial',manual_dial_call_time_check='$manual_dial_call_time_check',lead_order_randomize='$lead_order_randomize',lead_order_secondary='$lead_order_secondary',per_call_notes='$per_call_notes',my_callback_option='$my_callback_option',agent_lead_search='$agent_lead_search',agent_lead_search_method='$agent_lead_search_method',queuemetrics_phone_environment='$queuemetrics_phone_environment',auto_pause_precall='$auto_pause_precall',auto_resume_precall='$auto_resume_precall',auto_pause_precall_code='$auto_pause_precall_code',manual_dial_cid='$manual_dial_cid',post_phone_time_diff_alert='$post_phone_time_diff_alert',custom_3way_button_transfer='$custom_3way_button_transfer',available_only_tally_threshold='$available_only_tally_threshold',available_only_tally_threshold_agents='$available_only_tally_threshold_agents',dial_level_threshold='$dial_level_threshold',dial_level_threshold_agents='$dial_level_threshold_agents',safe_harbor_audio='$safe_harbor_audio',safe_harbor_menu_id='$safe_harbor_menu_id',callback_days_limit='$callback_days_limit',dl_diff_target_method='$dl_diff_target_method',disable_dispo_screen='$disable_dispo_screen',disable_dispo_status='$disable_dispo_status',screen_labels='$screen_labels',status_display_fields='$status_display_fields',na_call_url='" . mysqli_real_escape_string($link, $na_call_url) . "',pllb_grouping='$pllb_grouping',pllb_grouping_limit='$pllb_grouping_limit',call_count_limit='$call_count_limit',call_count_target='$call_count_target',callback_hours_block='$callback_hours_block',callback_list_calltime='$callback_list_calltime',user_group='$user_group',hopper_vlc_dup_check='$hopper_vlc_dup_check',in_group_dial='$in_group_dial',in_group_dial_select='$in_group_dial_select',safe_harbor_audio_field='$safe_harbor_audio_field',pause_after_next_call='$pause_after_next_call',owner_populate='$owner_populate',use_other_campaign_dnc='$use_other_campaign_dnc',allow_emails='$allow_emails',allow_chats='$allow_chats',amd_inbound_group='$amd_inbound_group',amd_callmenu='$amd_callmenu',manual_dial_lead_id='$manual_dial_lead_id',dead_max='$dead_max',dispo_max='$dispo_max',pause_max='$pause_max',dead_max_dispo='$dead_max_dispo',dispo_max_dispo='$dispo_max_dispo',max_inbound_calls='$max_inbound_calls',manual_dial_search_checkbox='$manual_dial_search_checkbox',hide_call_log_info='$hide_call_log_info',timer_alt_seconds='$timer_alt_seconds',wrapup_bypass='$wrapup_bypass',wrapup_after_hotkey='$wrapup_after_hotkey',callback_active_limit='$callback_active_limit',callback_active_limit_override='$callback_active_limit_override',comments_all_tabs='$comments_all_tabs',comments_dispo_screen='$comments_dispo_screen',comments_callback_screen='$comments_callback_screen',qc_comment_history='$qc_comment_history',show_previous_callback='$show_previous_callback',clear_script='$clear_script',cpd_unknown_action='$cpd_unknown_action',manual_dial_search_filter='$manual_dial_search_filter',web_form_address_three='" . mysqli_real_escape_string($link, $web_form_address_three) . "',manual_dial_override_field='$manual_dial_override_field',status_display_ingroup='$status_display_ingroup',customer_gone_seconds='$customer_gone_seconds',agent_display_fields='$agent_display_fields',am_message_wildcards='$am_message_wildcards',manual_dial_timeout='$manual_dial_timeout',routing_initiated_recordings='$routing_initiated_recordings',manual_dial_hopper_check='$manual_dial_hopper_check',callback_useronly_move_minutes='$callback_useronly_move_minutes',ofcom_uk_drop_calc='$ofcom_uk_drop_calc',manual_auto_next='$manual_auto_next',manual_auto_show='$manual_auto_show',allow_required_fields='$allow_required_fields',dead_to_dispo='$dead_to_dispo',agent_xfer_validation='$agent_xfer_validation',ready_max_logout='$ready_max_logout',callback_display_days='$callback_display_days',three_way_record_stop='$three_way_record_stop',hangup_xfer_record_start='$hangup_xfer_record_start',scheduled_callbacks_email_alert='$scheduled_callbacks_email_alert',max_inbound_calls_outcome='$max_inbound_calls_outcome',manual_auto_next_options='$manual_auto_next_options',agent_screen_time_display='$agent_screen_time_display',next_dial_my_callbacks='$next_dial_my_callbacks',inbound_no_agents_no_dial_container='$inbound_no_agents_no_dial_container',inbound_no_agents_no_dial_threshold='$inbound_no_agents_no_dial_threshold',cid_group_id='$cid_group_id',pause_max_dispo='$pause_max_dispo',script_top_dispo='$script_top_dispo',dead_trigger_seconds='$dead_trigger_seconds',dead_trigger_action='$dead_trigger_action',dead_trigger_repeat='$dead_trigger_repeat',dead_trigger_filename='$dead_trigger_filename',dead_trigger_url='" . mysqli_real_escape_string($link, $dead_trigger_url) . "',scheduled_callbacks_force_dial='$scheduled_callbacks_force_dial',scheduled_callbacks_auto_reschedule='$scheduled_callbacks_auto_reschedule',scheduled_callbacks_timezones_container='$scheduled_callbacks_timezones_container',three_way_volume_buttons='$three_way_volume_buttons',callback_dnc='$callback_dnc',manual_dial_validation='$manual_dial_validation',mute_recordings='$mute_recordings',auto_active_list_new='$auto_active_list_new',call_quota_lead_ranking='$call_quota_lead_ranking',sip_event_logging='$sip_event_logging',campaign_script_two='$campaign_script_two',leave_vm_no_dispo='$leave_vm_no_dispo',leave_vm_message_group_id='$leave_vm_message_group_id',dial_timeout_lead_container='$dial_timeout_lead_container',amd_type='$amd_type',vmm_daily_limit='$vmm_daily_limit',opensips_cid_name='$opensips_cid_name',amd_agent_route_options='$amd_agent_route_options',browser_alert_sound='$browser_alert_sound',browser_alert_volume='$browser_alert_volume',three_way_record_stop_exception='$three_way_record_stop_exception',pause_max_exceptions='$pause_max_exceptions',daily_call_count_limit='$daily_call_count_limit',daily_limit_manual='$daily_limit_manual',transfer_button_launch='$transfer_button_launch',shared_dial_rank='$shared_dial_rank',agent_search_method='$agent_search_method',clear_form='$clear_form',leave_3way_start_recording='$leave_3way_start_recording',leave_3way_start_recording_exception='$leave_3way_start_recording_exception',calls_waiting_vl_one='$calls_waiting_vl_one',calls_waiting_vl_two='$calls_waiting_vl_two',calls_inqueue_count_one='$calls_inqueue_count_one',calls_inqueue_count_two='$calls_inqueue_count_two',in_man_dial_next_ready_seconds='$in_man_dial_next_ready_seconds',in_man_dial_next_ready_seconds_override='$in_man_dial_next_ready_seconds_override',transfer_no_dispo='$transfer_no_dispo',call_limit_24hour_method='$call_limit_24hour_method',call_limit_24hour_scope='$call_limit_24hour_scope',call_limit_24hour='$call_limit_24hour',call_limit_24hour_override='$call_limit_24hour_override',cid_group_id_two='$cid_group_id_two',incall_tally_threshold_seconds='$incall_tally_threshold_seconds',auto_alt_threshold='$auto_alt_threshold',pause_max_url='$pause_max_url',agent_hide_hangup='$agent_hide_hangup',ig_xfer_list_sort='$ig_xfer_list_sort',script_tab_frame_size='$script_tab_frame_size',max_logged_in_agents='$max_logged_in_agents',user_group_script='$user_group_script',agent_hangup_route='$agent_hangup_route',agent_hangup_value='$agent_hangup_value',agent_hangup_ig_override='$agent_hangup_ig_override',show_confetti='$show_confetti',demographic_quotas='$demographic_quotas',demographic_quotas_container='$demographic_quotas_container',demographic_quotas_rerank='$demographic_quotas_rerank',demographic_quotas_list_resets='$demographic_quotas_list_resets',custom_one='$custom_one',custom_two='$custom_two',custom_three='$custom_three',custom_four='$custom_four',custom_five='$custom_five',dead_stop_recording='$dead_stop_recording',manual_vm_status_updates='$manual_vm_status_updates',force_per_call_notes='$force_per_call_notes',agent_search_ingroup_list='$agent_search_ingroup_list',hopper_hold_inserts='$hopper_hold_inserts',daily_phone_number_call_limit='$daily_phone_number_call_limit',state_descriptions='$state_descriptions',script_tab_height='$script_tab_height',call_log_days='$call_log_days',leave_3way_stop_recording='$leave_3way_stop_recording',manual_minimum_ring_seconds='$manual_minimum_ring_seconds',manual_minimum_attempt_seconds='$manual_minimum_attempt_seconds',manual_minimum_answer_seconds='$manual_minimum_answer_seconds',khomp_settings_container='$khomp_settings_container',stereo_recording='$stereo_recording',stereo_rec_filename='$stereo_rec_filename',stereo_parallel_recording='$stereo_parallel_recording',recording_dtmf_muting='$recording_dtmf_muting',stereo_recording_agent='$stereo_recording_agent',parallel_rec_co_filename='$parallel_rec_co_filename',parallel_rec_cm_filename='$parallel_rec_cm_filename',parallel_rec_fr_filename='$parallel_rec_fr_filename',call_count_limit_restrict='$call_count_limit_restrict' $prefixSQL $hdrtSQL where campaign_id='$campaign_id';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmtA, $link);

					if ($reset_hopper == 'Y')
						{
						echo "<br>"._QXZ("RESETTING CAMPAIGN LEAD HOPPER")."\n";
						echo "<br> - "._QXZ("Wait 1 minute before dialing next number")."\n";
						$stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id' and status IN('READY','QUEUE','DONE','RHOLD','RQUEUE');";
						$rslt=mysql_to_mysqli($stmt, $link);

						### LOG INSERTION Admin Log Table ###
						$SQL_log = "$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='CAMPAIGNS', event_type='RESET', record_id='$campaign_id', event_code='ADMIN RESET CAMPAIGN LEAD HOPPER', event_sql=\"$SQL_log\", event_notes='';";
						if ($DB) {echo "|$stmt|\n";}
						$rslt=mysql_to_mysqli($stmt, $link);
						}

					if ($hopper_drop_run_trigger_all == 'A')
						{
						echo "<br>"._QXZ("Hopper All-Drops-Run Triggered")."\n";
						}
					else
						{
						if ($hopper_drop_run_trigger == 'Y')
							{
							echo "<br>"._QXZ("Hopper Drop-Run Triggered")."\n";
							}
						}

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$stmtA|";
					$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='CAMPAIGNS', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN DETAIL', event_sql=\"$SQL_log\", event_notes='$hdrtMESSAGE';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=31;	# go to campaign modification form below
	}


######################
# ADD=42 modify/delete campaign status in the system
######################
if ($ADD==42)
	{
	if ($LOGmodify_campaigns==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) )
			{
			echo "<br>"._QXZ("CAMPAIGN STATUS NOT MODIFIED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("the campaign id needs to be at least 2 characters in length")."\n";
			echo "<br>"._QXZ("the campaign status needs to be at least 1 characters in length")."\n";
			}
		else
			{
			if (preg_match('/delete/',$stage))
				{
				echo "<br><B>"._QXZ("CUSTOM CAMPAIGN STATUS DELETED").": $campaign_id - $status</B>\n";

				$stmt="DELETE FROM vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status';";
				$rslt=mysql_to_mysqli($stmt, $link);

				$stmtA="DELETE FROM vicidial_campaign_hotkeys where campaign_id='$campaign_id' and status='$status';";
				$rslt=mysql_to_mysqli($stmtA, $link);

				$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmtB, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtA|$stmtB|";
				$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='CAMPAIGN_STATUS', event_type='DELETE', record_id='$campaign_id', event_code='ADMIN DELETE CAMPAIGN STATUS', event_sql=\"$SQL_log\", event_notes='Status: $status';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			if (preg_match('/modify/', $stage))
				{
				echo "<br><B>"._QXZ("CUSTOM CAMPAIGN STATUS MODIFIED").": $campaign_id - $status</B>\n";

				$stmt="UPDATE vicidial_campaign_statuses SET status_name='$status_name',selectable='$selectable',human_answered='$human_answered',category='$category',sale='$sale',dnc='$dnc',customer_contact='$customer_contact',not_interested='$not_interested',unworkable='$unworkable',scheduled_callback='$scheduled_callbacks',completed='$completed',min_sec='$min_sec',max_sec='$max_sec',answering_machine='$answering_machine' where campaign_id='$campaign_id' and status='$status';";
				$rslt=mysql_to_mysqli($stmt, $link);

				$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmtB, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtB|";
				$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='CAMPAIGN_STATUS', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN STATUS', event_sql=\"$SQL_log\", event_notes='Status: $status';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$SUB=22;
	$ADD=31;	# go to campaign modification form below
	}


######################
# ADD=43 delete campaign hotkey in the system
######################
if ($ADD==43)
	{
	if ($LOGmodify_campaigns==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($hotkey) < 1) )
			{
			echo "<br>"._QXZ("CAMPAIGN HOT KEY NOT MODIFIED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("the campaign id needs to be at least 2 characters in length")."\n";
			echo "<br>"._QXZ("the campaign status needs to be at least 1 characters in length")."\n";
			echo "<br>"._QXZ("the campaign hotkey needs to be at least 1 characters in length")."\n";
			}
		else
			{
			echo "<br><B>"._QXZ("CUSTOM CAMPAIGN HOT KEY DELETED").": $campaign_id - $status - $hotkey</B>\n";

			$stmt="DELETE FROM vicidial_campaign_hotkeys where campaign_id='$campaign_id' and status='$status' and hotkey='$hotkey';";
			$rslt=mysql_to_mysqli($stmt, $link);

			$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
			$rslt=mysql_to_mysqli($stmtB, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmtB|";
			$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='CAMPAIGN_HOTKEY', event_type='DELETE', record_id='$campaign_id', event_code='ADMIN DELETE CAMPAIGN HOTKEY', event_sql=\"$SQL_log\", event_notes='Status: $status|HotKey: $hotkey';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$SUB=23;
	$ADD=31;	# go to campaign modification form below
	}


######################
# ADD=44 submit campaign modifications to the system - Basic View
######################
if ($ADD==44)
	{
	if ($LOGmodify_campaigns==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ($SSoutbound_autodial_active < 1)
			{
			$adaptive_dl_diff_target =		'0';
			$adaptive_dropped_percentage =	'99';
			$adaptive_intensity =			'0';
			$adaptive_latest_server_time =	'2359';
			$adaptive_maximum_level =		'1.0';
			$agent_extended_alt_dial =		'N';
			$alt_number_dialing =			'N';
			$timer_alt_seconds =			'0';
			$am_message_exten =				'8320';
			$vmm_daily_limit =				'0';
			$amd_send_to_vmx =				'N';
			$auto_alt_dial =				'NONE';
			$auto_dial_level =				'1.0';
			$available_only_ratio_tally =	'Y';
			$campaign_allow_inbound =		'Y';
			$campaign_vdad_exten =			'8368';
			$concurrent_transfers =			'AUTO';
			$dial_method =					'RATIO';
			$dial_status =					'';
			$dial_timeout =					'60';
			$drop_action =					'HANGUP';
			$drop_call_seconds =			'5';
			$drop_inbound_group =			'---NONE---';
			$force_reset_hopper =			'N';
			$hopper_level =					'5';
			$lead_filter_id =				'NONE';
			$lead_order =					'DOWN';
			$list_order_mix =				'DISABLED';
			$no_hopper_leads_logins =		'Y';
			$queue_priority =				'50';
			$safe_harbor_exten =			'8300';
			$safe_harbor_audio =			'buzz';
			$safe_harbor_audio_field =		'DISABLED';
			$safe_harbor_menu_id =			'';
			$voicemail_ext =				'';
			}
		if (preg_match('/list_activation/',$stage))
			{
			$p=0;
			echo "<BR>"._QXZ("ACTIVE LISTS CHANGED");
			if (!is_array($list_active_change)) {$list_active_change=array();}
			$list_active_change_ct = count($list_active_change);
			while ($p < $list_active_change_ct)
				{
				$list_active_change[$p] = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$list_active_change[$p]);
				$LIST_ACTIVATE .= "'$list_active_change[$p]',";
				$p++;
				}
			
			$stmt = "UPDATE vicidial_lists SET active='Y' where list_id IN($LIST_ACTIVATE'') and campaign_id='$campaign_id';";
			$stmtB = "UPDATE vicidial_lists SET active='N' where list_id NOT IN($LIST_ACTIVATE'') and campaign_id='$campaign_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$rslt=mysql_to_mysqli($stmtB, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmtB|";
			$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='CAMPAIGNS', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN ACTIVE LISTS', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			if ($DB > 0) {echo "|$stmt|\n|$stmtB|\n";}
			}
		else
			{
			if ( (strlen($campaign_name) < 6) or (strlen($active) < 1) )
				{
				echo "<br>"._QXZ("CAMPAIGN NOT MODIFIED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("the campaign name needs to be at least 6 characters in length")."\n";
				}
			else
				{
				echo "<br><B>"._QXZ("CAMPAIGN MODIFIED").": $campaign_id</B>\n";

				if ( ($dial_method == 'RATIO') or ($dial_method == 'SHARED_RATIO') )
					{
					if ($auto_dial_level < 1) {$auto_dial_level = "1.0";}
					$adlSQL = "auto_dial_level='$auto_dial_level',";
					}
				else
					{
					if ($dial_method == 'MANUAL') 
						{
						$auto_dial_level='0';
						$adlSQL = "auto_dial_level='0',";
						}
					else
						{
						$adlSQL = "";
						if ($auto_dial_level < 1) 
							{
							$auto_dial_level = "1.0";
							$adlSQL = "auto_dial_level='$auto_dial_level',";
							}
						}
					}
				if ( ($dial_method == 'MANUAL') or ($dial_method == 'INBOUND_MAN') )
					{
					$adlSQL .= "auto_alt_dial='NONE',";
					}
				if ( (!preg_match('/DISABLED/', $list_order_mix)) and ($hopper_level < 100) )
					{$hopper_level='100';}

				$stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',hopper_level='$hopper_level', $adlSQL lead_filter_id='$lead_filter_id',dial_method='$dial_method',adaptive_intensity='$adaptive_intensity',campaign_changedate='$SQLdate',list_order_mix='$list_order_mix' where campaign_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmtA, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmtA|";
				$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='CAMPAIGNS', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN BASIC', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);

				if ($reset_hopper == 'Y')
					{
					echo "<br>"._QXZ("RESETTING CAMPAIGN LEAD HOPPER")."\n";
					echo "<br> - "._QXZ("Wait 1 minute before dialing next number")."\n";
					$stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id' and status IN('READY','QUEUE','DONE','RHOLD','RQUEUE');";
					$rslt=mysql_to_mysqli($stmt, $link);

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$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='CAMPAIGNS', event_type='RESET', record_id='$campaign_id', event_code='ADMIN RESET CAMPAIGN LEAD HOPPER', event_sql=\"$SQL_log\", event_notes='';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=34;	# go to campaign modification form below
	}


######################
# ADD=45 modify campaign lead recycle in the system
######################
if ($ADD==45)
	{
	if ($LOGmodify_campaigns==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or ($attempt_delay < 120) or ($attempt_delay >= 43200) or ($attempt_maximum < 1) or ($attempt_maximum > 10) )
			{
			echo "<br>"._QXZ("CAMPAIGN LEAD RECYCLE NOT MODIFIED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("status must be between 1 and 6 characters in length")."\n";
			echo "<br>"._QXZ("attempt delay must be at least 120 seconds and less than 43200 seconds or 12 hours")."\n";
			echo "<br>"._QXZ("maximum attempts must be from 1 to 10")."\n";
			}
		else
			{
			echo "<br><B>"._QXZ("CAMPAIGN LEAD MODIFIED").": $campaign_id - $status - $attempt_delay</B>\n";

			$stmt="UPDATE vicidial_lead_recycle SET attempt_delay='$attempt_delay',attempt_maximum='$attempt_maximum',active='$active' where campaign_id='$campaign_id' and status='$status';";
			$rslt=mysql_to_mysqli($stmt, $link);

			$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
			$rslt=mysql_to_mysqli($stmtB, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmtB|";
			$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='CAMPAIGN_RECYCLE', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN LEAD RECYCLE', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$SUB=25;
	$ADD=31;	# go to campaign modification form below
	}


######################
# ADD=47 modify agent pause code in the system
######################
if ($ADD==47)
	{
	if ($LOGmodify_campaigns==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";


		if ( (strlen($campaign_id) < 2) or (strlen($pause_code) < 1) or (mb_strlen($pause_code,'utf-8') > 6) or (strlen($pause_code_name) < 2) )
			{
			echo "<br>"._QXZ("AGENT PAUSE CODE NOT MODIFIED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("pause_code must be between 1 and 6 characters in length")."\n";
			echo "<br>"._QXZ("pause_code name must be between 2 and 30 characters in length")."\n";
			}
		else
			{
			echo "<br><B>"._QXZ("AGENT PAUSE CODE MODIFIED").": $campaign_id - $pause_code - $pause_code_name</B>\n";

			if (strlen($time_limit) < 1) {$time_limit='65000';}
			$stmt="UPDATE vicidial_pause_codes SET pause_code_name='$pause_code_name',billable='$billable',time_limit='$time_limit',require_mgr_approval='$require_mgr_approval' where campaign_id='$campaign_id' and pause_code='$pause_code';";
			$rslt=mysql_to_mysqli($stmt, $link);

			$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
			$rslt=mysql_to_mysqli($stmtB, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmtB|";
			$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='CAMPAIGN_PAUSECODE', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN PAUSE CODE', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$SUB=27;
	$ADD=31;	# go to campaign modification form below
	}


######################
# ADD=48 modify campaign QC settings in the system
######################
if ($ADD==48)
	{
	if ( ($LOGmodify_campaigns==1) and ($SSqc_features_active) )
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if (strlen($campaign_id) < 2)
			{
			echo "<br>"._QXZ("QC SETTINGS NOT MODIFIED - Please go back and look at the data you entered")."\n";
			}
		else
			{
			$p=0;
			if (!is_array($qc_statuses)) $qc_statuses = array();
			$qc_statuses_ct = count($qc_statuses);
			while ($p < $qc_statuses_ct)
				{
				$QC_statuses .= " $qc_statuses[$p]";
				$p++;
				}
			$p=0;
			if (!is_array($qc_lists)) $qc_lists = array();
			$qc_lists_ct = count($qc_lists);
			while ($p < $qc_lists_ct)
				{
				$QC_lists .= " $qc_lists[$p]";
				$p++;
				}
			
			if (strlen($QC_statuses)>0) {$QC_statuses .= " -";}
			if (strlen($QC_lists)>0) {$QC_lists .= " -";}
			$QC_statuses = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$QC_statuses);
			$QC_lists = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$QC_lists);

			echo "<br><B>"._QXZ("QC SETTINGS MODIFIED").": $campaign_id</B>\n";

			$stmt="UPDATE vicidial_campaigns SET qc_enabled='$qc_enabled',qc_statuses='$QC_statuses',qc_lists='$QC_lists',qc_web_form_address='" . mysqli_real_escape_string($link, $qc_web_form_address) . "',qc_script='$qc_script',qc_get_record_launch='$qc_get_record_launch',qc_show_recording='$qc_show_recording',qc_shift_id='$qc_shift_id',qc_scorecard_id='$qc_scorecard_id',qc_statuses_id='$qc_statuses_id',campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='CAMPAIGN_QC', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN QC SETTINGS', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$SUB=28;
	$ADD=31;	# go to campaign modification form below
	}


######################
# ADD=40A modify campaign survey settings in the system
######################
if ($ADD=='40A')
	{
	if ($LOGmodify_campaigns==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if (strlen($campaign_id) < 2)
			{
			echo "<br>"._QXZ("SURVEY SETTINGS NOT MODIFIED - Please go back and look at the data you entered")."\n";
			}
		else
			{
			echo "<br><B>"._QXZ("SURVEY SETTINGS MODIFIED").": $campaign_id</B>\n";

			$stmt="UPDATE vicidial_campaigns SET survey_first_audio_file='$survey_first_audio_file',survey_dtmf_digits='$survey_dtmf_digits',survey_ni_digit='$survey_ni_digit',survey_opt_in_audio_file='$survey_opt_in_audio_file',survey_ni_audio_file='$survey_ni_audio_file',survey_method='$survey_method',survey_no_response_action='$survey_no_response_action',survey_ni_status='$survey_ni_status',survey_response_digit_map='$survey_response_digit_map',survey_xfer_exten='$survey_xfer_exten',survey_camp_record_dir='$survey_camp_record_dir',voicemail_ext='$voicemail_ext',survey_third_digit='$survey_third_digit',survey_fourth_digit='$survey_fourth_digit',survey_third_audio_file='$survey_third_audio_file',survey_fourth_audio_file='$survey_fourth_audio_file',survey_third_status='$survey_third_status',survey_fourth_status='$survey_fourth_status',survey_third_exten='$survey_third_exten',survey_fourth_exten='$survey_fourth_exten',survey_menu_id='$survey_menu_id',survey_recording='$survey_recording',survey_wait_sec='$survey_wait_sec',campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='CAMPAIGN_SURVEY', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN SURVEY', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$SUB='20A';
	$ADD=31;	# go to campaign modification form below
	}


######################
# ADD=49 modify campaign list mix in the system
######################
if ($ADD==49)
	{
	if ($LOGmodify_campaigns==1)
		{
		##### MODIFY a list mix container entry #####
		if ($stage=='MODIFY')
			{
			echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

			$Flist_mix_container = "list_mix_container_$vcl_id";
			$Fmix_method = "mix_method_$vcl_id";
			$Fstatus = "status_$vcl_id";
			$Fvcl_name = "vcl_name_$vcl_id";

			if (isset($_GET[$Flist_mix_container]))				{$list_mix_container=$_GET[$Flist_mix_container];}
				elseif (isset($_POST[$Flist_mix_container]))	{$list_mix_container=$_POST[$Flist_mix_container];}
			if (isset($_GET[$Fmix_method]))						{$mix_method=$_GET[$Fmix_method];}
				elseif (isset($_POST[$Fmix_method]))			{$mix_method=$_POST[$Fmix_method];}
			if (isset($_GET[$Fstatus]))							{$status=$_GET[$Fstatus];}
				elseif (isset($_POST[$Fstatus]))				{$status=$_POST[$Fstatus];}
			if (isset($_GET[$Fvcl_name]))						{$vcl_name=$_GET[$Fvcl_name];}
				elseif (isset($_POST[$Fvcl_name]))				{$vcl_name=$_POST[$Fvcl_name];}
			$list_mix_container = preg_replace("/:$/","",$list_mix_container);
			$list_mix_container = preg_replace("/\<|\>|\'|\"|\\\\|;/", '', $list_mix_container);
			$mix_method = preg_replace("/\<|\>|\'|\"|\\\\|;/", '', $mix_method);
			$status = preg_replace("/\<|\>|\'|\"|\\\\|;/", '', $status);
			$vcl_name = preg_replace("/\<|\>|\'|\"|\\\\|;/", '', $vcl_name);

			 if ( (strlen($campaign_id) < 2) or (strlen($vcl_id) < 1) or (strlen($list_mix_container) < 6) or (strlen($vcl_name) < 2) )
				{
				echo "<br>"._QXZ("LIST MIX NOT MODIFIED - Please go back and look at the data you entered")."\n";
				echo "<br>vcl_id "._QXZ("must be between 1 and 20 characters in length")."\n";
				echo "<br>vcl_name "._QXZ("name must be between 2 and 30 characters in length")."\n";
				}
			 else
				{
				$stmt="UPDATE vicidial_campaigns_list_mix SET vcl_name='$vcl_name',mix_method='$mix_method',list_mix_container='$list_mix_container' where campaign_id='$campaign_id' and vcl_id='$vcl_id';";
				$rslt=mysql_to_mysqli($stmt, $link);

				$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmtB, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtB|";
				$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='CAMPAIGN_LISTMIX', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN LIST MIX', event_sql=\"$SQL_log\", event_notes='List Mix: $vcl_id';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);

				echo "<br><B>"._QXZ("LIST MIX MODIFIED").": $campaign_id - $vcl_id - $vcl_name</B>\n";
				}
			}

		##### ADD a list mix container entry #####
			if ($stage=='ADD')
			{
			echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

			if ( (strlen($campaign_id) < 2) or (strlen($vcl_id) < 1) or (strlen($list_id) < 1) )
				{
				echo "<br>"._QXZ("LIST MIX NOT MODIFIED - Please go back and look at the data you entered")."\n";
				echo "<br>vcl_id "._QXZ("must be between 1 and 20 characters in length")."\n";
				echo "<br>list_id "._QXZ("must be at least 2 characters in length")."\n";
				}
			else
				{
				$stmt="SELECT list_mix_container from vicidial_campaigns_list_mix where campaign_id='$campaign_id' and vcl_id='$vcl_id' $LOGallowed_campaignsSQL;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				$OLDlist_mix_container =	$row[0];
				$NEWlist_mix_container = "$OLDlist_mix_container:$list_id|10|0| -|";

				$stmt="UPDATE vicidial_campaigns_list_mix SET list_mix_container='$NEWlist_mix_container' where campaign_id='$campaign_id' and vcl_id='$vcl_id';";
				$rslt=mysql_to_mysqli($stmt, $link);

				$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmtB, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtB|";
				$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='CAMPAIGN_LISTMIX', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN LIST MIX', event_sql=\"$SQL_log\", event_notes='List Mix: $vcl_id';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);

				echo "<br><B>"._QXZ("LIST MIX MODIFIED").": $campaign_id - $vcl_id - $list_id</B>\n";
				}
			}

		##### REMOVE a list mix container entry #####
			if ($stage=='REMOVE')
			{
			echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

			if ( (strlen($campaign_id) < 2) or (strlen($vcl_id) < 1) or (strlen($list_id) < 1) )
				{
				echo "<br>"._QXZ("LIST MIX NOT MODIFIED - Please go back and look at the data you entered")."\n";
				echo "<br>vcl_id "._QXZ("must be between 1 and 20 characters in length")."\n";
				echo "<br>list_id "._QXZ("must be at least 2 characters in length")."\n";
				}
			else
				{
				$stmt="SELECT list_mix_container from vicidial_campaigns_list_mix where campaign_id='$campaign_id' and vcl_id='$vcl_id' $LOGallowed_campaignsSQL;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				$MIXentries = $MT;
				$MIXentries = explode(":", $row[0]);
				$Ms_to_print = (count($MIXentries) - 0);

				if ($Ms_to_print < 2)
					{
					echo "<br><B>"._QXZ("LIST MIX NOT MODIFIED: You cannot delete the last list_id entry from a list mix")."</B>\n";
					}
				else
					{
					$MIXdetailsPCT = explode('|', $MIXentries[$mix_container_item]);
					$MIXpercentPCT = $MIXdetailsPCT[2];

					$q=0;
					while ($Ms_to_print > $q) 
						{
						if ( ($mix_container_item > $q) or ($mix_container_item < $q) )
							{
							if ( ($q==0) and ($mix_container_item > 0) )
								{
								$MIXdetailsONE = explode('|', $MIXentries[$q]);
								$MIXpercentONE = ($MIXdetailsONE[2] + $MIXpercentPCT);
								$NEWlist_mix_container .= "$MIXdetailsONE[0]|$MIXdetailsONE[1]|$MIXpercentONE|$MIXdetailsONE[3]|:";
								}
							else
								{
								if ( ($q==1) and ($mix_container_item < 1) )
									{
									$MIXdetailsONE = explode('|', $MIXentries[$q]);
									$MIXpercentONE = ($MIXdetailsONE[2] + $MIXpercentPCT);
									$NEWlist_mix_container .= "$MIXdetailsONE[0]|$MIXdetailsONE[1]|$MIXpercentONE|$MIXdetailsONE[3]|:";
									}
								else
									{
									$NEWlist_mix_container .= "$MIXentries[$q]:";
									}
								}
							}
						$q++;
						}
					$NEWlist_mix_container = preg_replace("/.$/",'',$NEWlist_mix_container);

					$stmt="UPDATE vicidial_campaigns_list_mix SET list_mix_container='$NEWlist_mix_container' where campaign_id='$campaign_id' and vcl_id='$vcl_id';";
					$rslt=mysql_to_mysqli($stmt, $link);

					$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
					$rslt=mysql_to_mysqli($stmtB, $link);

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$stmt|$stmtB|";
					$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='CAMPAIGN_LISTMIX', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN LIST MIX', event_sql=\"$SQL_log\", event_notes='List Mix: $vcl_id';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);

					echo "<br><B>"._QXZ("LIST MIX MODIFIED").": $campaign_id - $vcl_id - $list_id - $mix_container_item</B>\n";
					}
				}
			}

		##### ADD a NEW list mix #####
			if ($stage=='NEWMIX')
			{
			if ($add_copy_disabled > 0)
				{
				echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
				}
			else
				{
				echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

				if ( (strlen($campaign_id) < 2) or (strlen($vcl_id) < 1) or (strlen($vcl_name) < 2) )
					{
					echo "<br>"._QXZ("LIST MIX NOT ADDED - Please go back and look at the data you entered")."\n";
					echo "<br>vcl_id "._QXZ("must be between 1 and 20 characters in length")."\n";
					echo "<br>vcl_name "._QXZ("must be at least 2 characters in length")."\n";
					}
				else
					{
					$stmt="SELECT count(*) from vicidial_campaigns_list_mix where vcl_id='$vcl_id' $LOGallowed_campaignsSQL;";
					$rslt=mysql_to_mysqli($stmt, $link);
					$row=mysqli_fetch_row($rslt);
					if ($row[0] > 0)
						{
						echo "<br>"._QXZ("LIST MIX NOT ADDED - There is already a list mix with this ID in the system")."\n";
						}
					else
						{
						$stmt="INSERT INTO vicidial_campaigns_list_mix SET list_mix_container='$list_id|1|100| $status -|',campaign_id='$campaign_id',vcl_id='$vcl_id',vcl_name='$vcl_name',mix_method='$mix_method',status='INACTIVE';";
						$rslt=mysql_to_mysqli($stmt, $link);

						$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
						$rslt=mysql_to_mysqli($stmtB, $link);

						### LOG INSERTION Admin Log Table ###
						$SQL_log = "$stmt|$stmtB|";
						$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='CAMPAIGN_LISTMIX', event_type='ADD', record_id='$campaign_id', event_code='ADMIN ADD CAMPAIGN LIST MIX', event_sql=\"$SQL_log\", event_notes='List Mix: $vcl_id';";
						if ($DB) {echo "|$stmt|\n";}
						$rslt=mysql_to_mysqli($stmt, $link);

						echo "<br><B>"._QXZ("LIST MIX ADDED").": $campaign_id - $vcl_id - $vcl_name</B>\n";
						}
					}
				}
			}

		##### DELETE an existing list mix #####
			if ($stage=='DELMIX')
			{
			echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

			if ( (strlen($campaign_id) < 2) or (strlen($vcl_id) < 1) )
				{
				echo "<br>"._QXZ("LIST MIX NOT DELETED - Please go back and look at the data you entered")."\n";
				echo "<br>vcl_id "._QXZ("must be between 1 and 20 characters in length")."\n";
				}
			else
				{
				$stmt="DELETE from vicidial_campaigns_list_mix where vcl_id='$vcl_id' and campaign_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmt, $link);

				$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmtB, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtB|";
				$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='CAMPAIGN_LISTMIX', event_type='DELETE', record_id='$campaign_id', event_code='ADMIN DELETE CAMPAIGN LIST MIX', event_sql=\"$SQL_log\", event_notes='List Mix: $vcl_id';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);

				echo "<br><B>"._QXZ("LIST MIX DELETED").": $campaign_id - $vcl_id - $vcl_name</B>\n";
				}
			}

		##### Set list mix entry to active #####
			if ($stage=='SETACTIVE')
			{
			echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

			if ( (strlen($campaign_id) < 2) or (strlen($vcl_id) < 1) )
				{
				echo "<br>"._QXZ("LIST MIX NOT ACTIVATED - Please go back and look at the data you entered")."\n";
				echo "<br>vcl_id "._QXZ("must be between 1 and 20 characters in length")."\n";
				}
			else
				{
				$stmt="UPDATE vicidial_campaigns_list_mix SET status='INACTIVE' where campaign_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmt, $link);

				$stmtA="UPDATE vicidial_campaigns_list_mix SET status='ACTIVE' where vcl_id='$vcl_id' and campaign_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmtA, $link);

				$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmtB, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtA|$stmtB|";
				$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='CAMPAIGN_LISTMIX', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN LIST MIX ACTIVE', event_sql=\"$SQL_log\", event_notes='List Mix: $vcl_id';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);

				echo "<br><B>"._QXZ("LIST MIX ACTIVATED").": $campaign_id - $vcl_id - $vcl_name</B>\n";
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$SUB=29;
	$ADD=31;	# go to campaign modification form below
	}


######################
# ADD=401 modify campaign preset in the system
######################
if ($ADD==401)
	{
	if ($LOGmodify_campaigns==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($campaign_id) < 2) or (strlen($preset_name) < 1) or (strlen($preset_number) < 1) )
			{
			echo "<br>"._QXZ("PRESET NOT MODIFIED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("preset name must be between 1 and 40 characters in length")."\n";
			echo "<br>"._QXZ("preset number must be between 2 and 50 characters in length")."\n";
			}
		else
			{
			echo "<br><B>"._QXZ("PRESET MODIFIED").": $campaign_id - $preset_name - $preset_number</B>\n";

			$stmt="UPDATE vicidial_xfer_presets SET preset_dtmf='$preset_dtmf',preset_number='$preset_number',preset_hide_number='$preset_hide_number' where campaign_id='$campaign_id' and preset_name='$preset_name';";
			$rslt=mysql_to_mysqli($stmt, $link);

			$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
			$rslt=mysql_to_mysqli($stmtB, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmtB|";
			$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='CAMPAIGN_PRESET', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN PRESET', event_sql=\"$SQL_log\", event_notes='Preset: $preset_name - $preset_number';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$SUB=201;
	$ADD=31;	# go to campaign modification form below
	}


######################
# ADD=411 submit list modifications to the system
######################
if ($ADD==411)
	{
	if ( ($LOGmodify_lists==1) and (strlen($list_id) > 1) )
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ($stage == 'territory_reset')
			{
			$p=0;
			echo "<BR>"._QXZ("TERRITORIES RESET");
			if (!is_array($territory_reset)) $territory_reset = array();
			$territory_reset_ct = count($territory_reset);
			while ($p < $territory_reset_ct)
				{
				$TERR_RESET .= "'$territory_reset[$p]',";
				$p++;
				}
			$TERR_RESET = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$TERR_RESET);
			$TERR_RESET = preg_replace("/,$/",'',$TERR_RESET);
			if (strlen($TERR_RESET) > 1)
				{
				$stmt = "UPDATE vicidial_list SET called_since_last_reset='N' where list_id='$list_id' and owner IN($TERR_RESET);";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='LISTS', event_type='MODIFY', record_id='$list_id', event_code='ADMIN MODIFY LIST TERRITORY RESET', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);

				if ($DB > 0) {echo "|$stmt|\n";}
				}
			}
		else
			{
			if ( (strlen($list_name) < 2) or (strlen($campaign_id) < 2) )
				{
				echo "<br>"._QXZ("LIST NOT MODIFIED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("list name must be at least 2 characters in length")."\n";
				}
			else
				{
				if (strlen($reset_time) < 4) {$reset_time='';}
				if (strlen($expiration_date) < 10) {$expiration_date='2099-12-31';}


				$daily_reset_limitSQL='';
				if ($LOGuser_level >= 9) {$daily_reset_limitSQL = ",daily_reset_limit='$daily_reset_limit'";}
				$prefixSQL='';
				if ($LOGmodify_dial_prefix > 0)
					{$prefixSQL = ",dial_prefix='$dial_prefix'";}

				echo "<br><B>"._QXZ("LIST MODIFIED").": $list_id</B>\n";

				# update the apinewlead_url value for the list
				$apinewlead_url_ct=0;   $affected_rowsD=0;   $stmtD='';
				$stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$list_id' and entry_type='list' and url_type='apinewlead';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$urls_to_print = mysqli_num_rows($rslt);
				if ($urls_to_print > 0) 
					{
					$rowx=mysqli_fetch_row($rslt);
					$apinewlead_url_ct = $rowx[0];
					}
				if ( ($apinewlead_url_ct > 0) or (strlen($apinewlead_url) > 0) )
					{
					if ($apinewlead_url_ct > 0)
						{
						$stmtD="UPDATE vicidial_url_multi SET url_address='" . mysqli_real_escape_string($link, $apinewlead_url) . "' WHERE campaign_id='$list_id' and entry_type='list' and url_type='apinewlead';";
						}
					else
						{
						$stmtD="INSERT INTO vicidial_url_multi SET campaign_id='$list_id', entry_type='list', url_type='apinewlead', active='Y',url_address='" . mysqli_real_escape_string($link, $apinewlead_url) . "';";
						}
					$rslt=mysql_to_mysqli($stmtD, $link);
					$affected_rowsD = mysqli_affected_rows($link);
					}

				# update the list entry
				$stmt="UPDATE vicidial_lists set list_name='$list_name',campaign_id='$campaign_id',active='$active',list_description='$list_description',list_changedate='$SQLdate',reset_time='$reset_time',agent_script_override='$agent_script_override',inbound_list_script_override='$inbound_list_script_override',campaign_cid_override='$campaign_cid_override',am_message_exten_override='$am_message_exten_override',drop_inbound_group_override='$drop_inbound_group_override',xferconf_a_number='$xferconf_a_number',xferconf_b_number='$xferconf_b_number',xferconf_c_number='$xferconf_c_number',xferconf_d_number='$xferconf_d_number',xferconf_e_number='$xferconf_e_number',web_form_address='" . mysqli_real_escape_string($link, $web_form_address) . "',web_form_address_two='" . mysqli_real_escape_string($link, $web_form_address_two) . "',time_zone_setting='$time_zone_setting',inventory_report='$inventory_report',expiration_date='$expiration_date',na_call_url='" . mysqli_real_escape_string($link, $na_call_url) . "',local_call_time='$local_call_time',web_form_address_three='" . mysqli_real_escape_string($link, $web_form_address_three) . "',status_group_id='$status_group_id',user_new_lead_limit='$user_new_lead_limit',default_xfer_group='$default_xfer_group',qc_scorecard_id='$qc_scorecard_id' $daily_reset_limitSQL,auto_active_list_rank='$auto_active_list_rank',qc_statuses_id='$qc_statuses_id',qc_web_form_address='" . mysqli_real_escape_string($link, $qc_web_form_address) . "',inbound_drop_voicemail='$inbound_drop_voicemail',inbound_after_hours_voicemail='$inbound_after_hours_voicemail',auto_alt_threshold='$auto_alt_threshold',cid_group_id='$cid_group_id',weekday_resets_container='$weekday_resets_container' $prefixSQL where list_id='$list_id';";
				$rslt=mysql_to_mysqli($stmt, $link);

				## QC Addition for Audited Comments
				$stmtQC="INSERT INTO vicidial_lists_custom (audit_comments, list_id) VALUES ('" . mysqli_real_escape_string($link, $audit_comments) . "','$list_id') ON DUPLICATE KEY UPDATE audit_comments='" . mysqli_real_escape_string($link, $audit_comments) . "';";
				$rslt=mysql_to_mysqli($stmtQC, $link);
                if ($DB) {echo "|$stmt|$stmtQC|\n";}

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtQC|$stmtD|";
				$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='LISTS', event_type='MODIFY', record_id='$list_id', event_code='ADMIN MODIFY LIST', event_sql=\"$SQL_log\", event_notes='$affected_rowsD';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);

				if ($reset_list == 'Y')
					{
					$stmt="SELECT daily_reset_limit,resets_today from vicidial_lists where list_id='$list_id';";
					$rslt=mysql_to_mysqli($stmt, $link);
					$row=mysqli_fetch_row($rslt);
					if ( ($row[0] > $row[1]) or ($row[0] < 0) )
						{
						echo "<br>"._QXZ("RESETTING LIST-CALLED-STATUS")."\n";
						$stmtB="UPDATE vicidial_lists set resets_today=(resets_today + 1) where list_id='$list_id';";
						$rslt=mysql_to_mysqli($stmtB, $link);

						$stmtC="UPDATE vicidial_list set called_since_last_reset='N' where list_id='$list_id';";
						$rslt=mysql_to_mysqli($stmtC, $link);
						$affected_rowsC = mysqli_affected_rows($link);

						$row[1] = ($row[1] + 1);

						### LOG INSERTION Admin Log Table ###
						$SQL_log = "$stmtB|$stmtC|";
						$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='LISTS', event_type='RESET', record_id='$list_id', event_code='ADMIN RESET LIST', event_sql=\"$SQL_log\", event_notes='leads reset: $affected_rowsC  list resets today: $row[1]  limit: $row[0]';";
						if ($DB) {echo "|$stmt|\n";}
						$rslt=mysql_to_mysqli($stmt, $link);
						}
					else
						{
						echo "<br>"._QXZ("CANNOT RESET LIST, LIMIT REACHED").": $row[0] / $row[1]\n";
						}
					}
				if ($campaign_id != "$old_campaign_id")
					{
					echo "<br>"._QXZ("REMOVING LIST HOPPER LEADS FROM OLD CAMPAIGN HOPPER")." ($old_campaign_id)\n";
					$stmtC="DELETE from vicidial_hopper where list_id='$list_id' and campaign_id='$old_campaign_id';";
					$rslt=mysql_to_mysqli($stmtC, $link);
					}
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=311;	# go to list modification form below
	}


######################
# ADD=4111 modify in-group info in the system
######################
if ($ADD==4111 || $ADD==4811 || $ADD==4911)
	{
	if ($SUB=='agents_select')
		{
		if ($LOGmodify_users==1)
			{
			echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

			if ( (strlen($OLDuser_group) < 2) or (strlen($group_id) < 2) )
				{
				echo "<br>"._QXZ("USERS NOT MODIFIED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("group id and user group must be at least 2 characters in length")."\n";
				}
			else
				{
				$stmt="SELECT user,closer_campaigns from vicidial_users where active='Y' and user_group='$OLDuser_group' $LOGadmin_viewable_groupsSQL order by user;";
				$rsltx=mysql_to_mysqli($stmt, $link);
				$users_to_print = mysqli_num_rows($rsltx);
				$ARIUG_changenotes='';
				$o=0;
				while ($users_to_print > $o) 
					{
					$rowx=mysqli_fetch_row($rsltx);
					$ARIUG_user[$o] =	$rowx[0];
					$ARIUG_close[$o] =	$rowx[1];
					$ARIUG_check[$o] =	'';
					if (preg_match("/ $group_id /",$ARIUG_close[$o]))
						{$ARIUG_check[$o] = 'CHECKED';}
					if ( ($ARIUG_check[$o]=='') and ($stage=='add') )
						{
						if (strlen($ARIUG_close[$o]) < 4) {$ARIUG_close[$o]=' - ';}
						$stmtA="UPDATE vicidial_users set closer_campaigns=' $group_id$ARIUG_close[$o]' where user='$ARIUG_user[$o]';";
						$rslt=mysql_to_mysqli($stmtA, $link);
						if ($DB > 0) {echo "|$stmtA|";}
						$ARIUG_changenotes .= "added $group_id to selected in-groups|";
						$ARIUG_code = "USER INGROUP VIGA ADD";
						}
					if ( ($ARIUG_check[$o]=='CHECKED') and ($stage=='remove') )
						{
						$ARIUG_close[$o] = preg_replace("/ $group_id /",' ',$ARIUG_close[$o]);
						$stmtB="UPDATE vicidial_users set closer_campaigns='$ARIUG_close[$o]' where user='$ARIUG_user[$o]';";
						$rslt=mysql_to_mysqli($stmtB, $link);
						if ($DB > 0) {echo "|$stmtB|";}
						$ARIUG_changenotes .= "removed $group_id from selected in-groups|";
						$ARIUG_code = "USER INGROUP VIGA REMOVE";
						}
					if (strlen($ARIUG_changenotes) > 10)
						{
						### LOG INSERTION Admin Log Table ###
						$SQL_log = "$stmtDlog|$stmtA|$stmtB|";
						$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='$ARIUG_user[$o]', event_code='$ARIUG_code', event_sql=\"$SQL_log\", event_notes='$ARIUG_changenotes';";
						if ($DB) {echo "|$stmt|\n";}
						$rslt=mysql_to_mysqli($stmt, $link);
						}
					$o++;
					}
				}
			}
		else
			{
			echo _QXZ("You do not have permission to view this page")."\n";
			exit;
			}
		}
	else
		{
		if ($LOGmodify_ingroups==1)
			{
			echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

			if ( (strlen($group_name) < 2) or (strlen($group_color) < 2) )
				{
				echo "<br>"._QXZ("GROUP NOT MODIFIED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("group name and group color must be at least 2 characters in length")."\n";
				}
			else
				{
				if ( (!preg_match("/\|$group_color,/i",$HTMLcolors)) and ( (strlen($group_color) > 7) or (strlen($group_color) < 7) or (!preg_match("/^#/",$group_color)) ) )
					{
					if (!preg_match("/^#/",$group_color)) {$group_color = "#$group_color";}
					if (strlen($group_color) > 7) {$group_color = substr($group_color,0,7);}
					while (strlen($group_color) < 7) {$group_color .= '0';}
					}
				if ($form_end != 'END')
					{
					echo "<br>"._QXZ("GROUP NOT MODIFIED - Please wait for the whole page to load before submitting the form")."\n";
					}
				else
					{
					$p=0;
					if (!is_array($qc_statuses)) $qc_statuses = array();
					$qc_statuses_ct = count($qc_statuses);
					while ($p < $qc_statuses_ct)
						{
						$QC_statuses .= " $qc_statuses[$p]";
						$p++;
						}
					$p=0;
					if (!is_array($qc_lists)) $qc_lists = array();
					$qc_lists_ct = count($qc_lists);
					while ($p < $qc_lists_ct)
						{
						$QC_lists .= " $qc_lists[$p]";
						$p++;
						}
					
					if (strlen($QC_statuses)>0) {$QC_statuses .= " -";}
					if (strlen($QC_lists)>0) {$QC_lists .= " -";}
					$QC_statuses = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$QC_statuses);
					$QC_lists = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$QC_lists);

					if ($no_agent_action == "INGROUP")
						{
						if (isset($_GET["IGgroup_id_no_agent_action"]))					{$IGgroup_id=$_GET["IGgroup_id_no_agent_action"];}
							elseif (isset($_POST["IGgroup_id_no_agent_action"]))		{$IGgroup_id=$_POST["IGgroup_id_no_agent_action"];}
						if (isset($_GET["IGhandle_method_no_agent_action"]))			{$IGhandle_method=$_GET["IGhandle_method_no_agent_action"];}
							elseif (isset($_POST["IGhandle_method_no_agent_action"]))	{$IGhandle_method=$_POST["IGhandle_method_no_agent_action"];}
						if (isset($_GET["IGsearch_method_no_agent_action"]))			{$IGsearch_method=$_GET["IGsearch_method_no_agent_action"];}
							elseif (isset($_POST["IGsearch_method_no_agent_action"]))	{$IGsearch_method=$_POST["IGsearch_method_no_agent_action"];}
						if (isset($_GET["IGlist_id_no_agent_action"]))					{$IGlist_id=$_GET["IGlist_id_no_agent_action"];}
							elseif (isset($_POST["IGlist_id_no_agent_action"]))			{$IGlist_id=$_POST["IGlist_id_no_agent_action"];}
						if (isset($_GET["IGcampaign_id_no_agent_action"]))				{$IGcampaign_id=$_GET["IGcampaign_id_no_agent_action"];}
							elseif (isset($_POST["IGcampaign_id_no_agent_action"]))		{$IGcampaign_id=$_POST["IGcampaign_id_no_agent_action"];}
						if (isset($_GET["IGphone_code_no_agent_action"]))				{$IGphone_code=$_GET["IGphone_code_no_agent_action"];}
							elseif (isset($_POST["IGphone_code_no_agent_action"]))		{$IGphone_code=$_POST["IGphone_code_no_agent_action"];}
						if (strlen($IGhandle_method)<1)
							{
							if (isset($_GET["IGhandle_method_"]))			{$IGhandle_method=$_GET["IGhandle_method_"];}
								elseif (isset($_POST["IGhandle_method_"]))	{$IGhandle_method=$_POST["IGhandle_method_"];}
							}
						if (strlen($IGsearch_method)<1)
							{
							if (isset($_GET["IGsearch_method_"]))			{$IGsearch_method=$_GET["IGsearch_method_"];}
								elseif (isset($_POST["IGsearch_method_"]))	{$IGsearch_method=$_POST["IGsearch_method_"];}
							}
						if (strlen($IGlist_id)<1)
							{
							if (isset($_GET["IGlist_id_"]))				{$IGlist_id=$_GET["IGlist_id_"];}
								elseif (isset($_POST["IGlist_id_"]))	{$IGlist_id=$_POST["IGlist_id_"];}
							}
						if (strlen($IGcampaign_id)<1)
							{
							if (isset($_GET["IGcampaign_id_"]))				{$IGcampaign_id=$_GET["IGcampaign_id_"];}
								elseif (isset($_POST["IGcampaign_id_"]))	{$IGcampaign_id=$_POST["IGcampaign_id_"];}
							}
						if (strlen($IGphone_code)<1)
							{
							if (isset($_GET["IGphone_code_"]))			{$IGphone_code=$_GET["IGphone_code_"];}
								elseif (isset($_POST["IGphone_code_"]))	{$IGphone_code=$_POST["IGphone_code_"];}
							}

						$no_agent_action_value = "$IGgroup_id,$IGhandle_method,$IGsearch_method,$IGlist_id,$IGcampaign_id,$IGphone_code";
						if ($DB) {echo "\nNANQUE:     |$no_agent_action_value|$no_agent_action|\n";}
						}

					if ($no_agent_action == "EXTENSION")
						{
						if (isset($_GET["EXextension_no_agent_action"]))			{$EXextension=$_GET["EXextension_no_agent_action"];}
							elseif (isset($_POST["EXextension_no_agent_action"]))	{$EXextension=$_POST["EXextension_no_agent_action"];}
						if (isset($_GET["EXcontext_no_agent_action"]))				{$EXcontext=$_GET["EXcontext_no_agent_action"];}
							elseif (isset($_POST["EXcontext_no_agent_action"]))		{$EXcontext=$_POST["EXcontext_no_agent_action"];}

						$no_agent_action_value = "$EXextension,$EXcontext";
						}
					if ($non_latin < 1)
						{
						$no_agent_action_value = preg_replace('/[^-\/\|\_\#\*\,\.\_0-9a-zA-Z]/','',$no_agent_action_value);
						}
					else
						{
						$no_agent_action_value = preg_replace('/[^-\/\|\_\#\*\,\.\_0-9\p{L}]/u','',$no_agent_action_value);
						}
					if ($areacode_filter_action == "INGROUP")
						{
						if (isset($_GET["IGgroup_id_areacode_filter_action"]))					{$IGgroup_id=$_GET["IGgroup_id_areacode_filter_action"];}
							elseif (isset($_POST["IGgroup_id_areacode_filter_action"]))			{$IGgroup_id=$_POST["IGgroup_id_areacode_filter_action"];}
						if (isset($_GET["IGhandle_method_areacode_filter_action"]))				{$IGhandle_method=$_GET["IGhandle_method_areacode_filter_action"];}
							elseif (isset($_POST["IGhandle_method_areacode_filter_action"]))	{$IGhandle_method=$_POST["IGhandle_method_areacode_filter_action"];}
						if (isset($_GET["IGsearch_method_areacode_filter_action"]))				{$IGsearch_method=$_GET["IGsearch_method_areacode_filter_action"];}
							elseif (isset($_POST["IGsearch_method_areacode_filter_action"]))	{$IGsearch_method=$_POST["IGsearch_method_areacode_filter_action"];}
						if (isset($_GET["IGlist_id_areacode_filter_action"]))					{$IGlist_id=$_GET["IGlist_id_areacode_filter_action"];}
							elseif (isset($_POST["IGlist_id_areacode_filter_action"]))			{$IGlist_id=$_POST["IGlist_id_areacode_filter_action"];}
						if (isset($_GET["IGcampaign_id_areacode_filter_action"]))				{$IGcampaign_id=$_GET["IGcampaign_id_areacode_filter_action"];}
							elseif (isset($_POST["IGcampaign_id_areacode_filter_action"]))		{$IGcampaign_id=$_POST["IGcampaign_id_areacode_filter_action"];}
						if (isset($_GET["IGphone_code_areacode_filter_action"]))				{$IGphone_code=$_GET["IGphone_code_areacode_filter_action"];}
							elseif (isset($_POST["IGphone_code_areacode_filter_action"]))		{$IGphone_code=$_POST["IGphone_code_areacode_filter_action"];}
						if (strlen($IGhandle_method)<1)
							{
							if (isset($_GET["IGhandle_method_"]))			{$IGhandle_method=$_GET["IGhandle_method_"];}
								elseif (isset($_POST["IGhandle_method_"]))	{$IGhandle_method=$_POST["IGhandle_method_"];}
							}
						if (strlen($IGsearch_method)<1)
							{
							if (isset($_GET["IGsearch_method_"]))			{$IGsearch_method=$_GET["IGsearch_method_"];}
								elseif (isset($_POST["IGsearch_method_"]))	{$IGsearch_method=$_POST["IGsearch_method_"];}
							}
						if (strlen($IGlist_id)<1)
							{
							if (isset($_GET["IGlist_id_"]))				{$IGlist_id=$_GET["IGlist_id_"];}
								elseif (isset($_POST["IGlist_id_"]))	{$IGlist_id=$_POST["IGlist_id_"];}
							}
						if (strlen($IGcampaign_id)<1)
							{
							if (isset($_GET["IGcampaign_id_"]))				{$IGcampaign_id=$_GET["IGcampaign_id_"];}
								elseif (isset($_POST["IGcampaign_id_"]))	{$IGcampaign_id=$_POST["IGcampaign_id_"];}
							}
						if (strlen($IGphone_code)<1)
							{
							if (isset($_GET["IGphone_code_"]))			{$IGphone_code=$_GET["IGphone_code_"];}
								elseif (isset($_POST["IGphone_code_"]))	{$IGphone_code=$_POST["IGphone_code_"];}
							}

						$areacode_filter_action_value = "$IGgroup_id,$IGhandle_method,$IGsearch_method,$IGlist_id,$IGcampaign_id,$IGphone_code";
						if ($DB) {echo "\nNANQUE:     |$areacode_filter_action_value|$areacode_filter_action|\n";}
						}

					if ($areacode_filter_action == "EXTENSION")
						{
						if (isset($_GET["EXextension_areacode_filter_action"]))				{$EXextension=$_GET["EXextension_areacode_filter_action"];}
							elseif (isset($_POST["EXextension_areacode_filter_action"]))	{$EXextension=$_POST["EXextension_areacode_filter_action"];}
						if (isset($_GET["EXcontext_areacode_filter_action"]))				{$EXcontext=$_GET["EXcontext_areacode_filter_action"];}
							elseif (isset($_POST["EXcontext_areacode_filter_action"]))		{$EXcontext=$_POST["EXcontext_areacode_filter_action"];}

						$areacode_filter_action_value = "$EXextension,$EXcontext";
						}
					if ($non_latin < 1)
						{
						$areacode_filter_action_value = preg_replace('/[^-\/\|\_\#\*\,\.\_0-9a-zA-Z]/','',$areacode_filter_action_value);
						}
					else
						{
						$areacode_filter_action_value = preg_replace('/[^-\/\|\_\#\*\,\.\_0-9\p{L}]/u','',$areacode_filter_action_value);
						}
					if ($ingroup_rec_filename == $stereo_rec_filename)
						{
						$stereo_rec_filename = "X".$stereo_rec_filename;
						echo "<br><B><font color='red'>"._QXZ("Stereo Recording Filename identical to Recording Filename, so it has been appended ").": $stereo_rec_filename ($ingroup_rec_filename)</font></B>\n";
						}
					if ( (strlen($parallel_rec_co_filename) > 0) and ( ($ingroup_rec_filename == $parallel_rec_co_filename) or ($stereo_rec_filename == $parallel_rec_co_filename) or ($parallel_rec_cm_filename == $parallel_rec_co_filename) or ($parallel_rec_fr_filename == $parallel_rec_co_filename) ) )
						{
						$parallel_rec_co_filename = "CO".$parallel_rec_co_filename;
						echo "<br><B><font color='red'>"._QXZ("Parallel Customer-Only Recording Filename identical to another Recording Filename, so it has been appended ").": $parallel_rec_co_filename</font></B>\n";
						}
					if ( (strlen($parallel_rec_cm_filename) > 0) and ( ($ingroup_rec_filename == $parallel_rec_cm_filename) or ($stereo_rec_filename == $parallel_rec_cm_filename) or ($parallel_rec_co_filename == $parallel_rec_cm_filename) or ($parallel_rec_fr_filename == $parallel_rec_cm_filename) ) )
						{
						$parallel_rec_cm_filename = "CM".$parallel_rec_cm_filename;
						echo "<br><B><font color='red'>"._QXZ("Parallel Customer-Muted Recording Filename identical to another Recording Filename, so it has been appended ").": $parallel_rec_cm_filename</font></B>\n";
						}
					if ( (strlen($parallel_rec_fr_filename) > 0) and ( ($ingroup_rec_filename == $parallel_rec_fr_filename) or ($stereo_rec_filename == $parallel_rec_fr_filename) or ($parallel_rec_co_filename == $parallel_rec_fr_filename) or ($parallel_rec_cm_filename == $parallel_rec_fr_filename) ) )
						{
						$parallel_rec_fr_filename = "FR".$parallel_rec_fr_filename;
						echo "<br><B><font color='red'>"._QXZ("Parallel Full-Recording Recording Filename identical to another Recording Filename, so it has been appended ").": $parallel_rec_fr_filename</font></B>\n";
						}

					echo "<br><B>"._QXZ("GROUP MODIFIED ").": $group_id</B>\n";

					$stmt="UPDATE vicidial_inbound_groups set group_name='$group_name', group_color='$group_color', active='$active', web_form_address='" . mysqli_real_escape_string($link, $web_form_address) . "', voicemail_ext='$voicemail_ext', next_agent_call='$next_agent_call', fronter_display='$fronter_display', ingroup_script='$script_id', get_call_launch='$get_call_launch', group_handling='$group_handling', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number', xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',drop_action='$drop_action',drop_call_seconds='$drop_call_seconds',drop_exten='$drop_exten',call_time_id='$call_time_id',after_hours_action='$after_hours_action',after_hours_message_filename='$after_hours_message_filename',after_hours_exten='$after_hours_exten',after_hours_voicemail='$after_hours_voicemail',welcome_message_filename='$welcome_message_filename',moh_context='$moh_context',onhold_prompt_filename='$onhold_prompt_filename',prompt_interval='$prompt_interval',agent_alert_exten='$agent_alert_exten',agent_alert_delay='$agent_alert_delay',default_xfer_group='$default_xfer_group',queue_priority='$queue_priority',drop_inbound_group='$drop_inbound_group',ingroup_recording_override='$ingroup_recording_override',ingroup_rec_filename='$ingroup_rec_filename',afterhours_xfer_group='$afterhours_xfer_group',qc_enabled='$qc_enabled',qc_statuses='$QC_statuses',qc_shift_id='$qc_shift_id',qc_get_record_launch='$qc_get_record_launch',qc_show_recording='$qc_show_recording',qc_web_form_address='" . mysqli_real_escape_string($link, $qc_web_form_address) . "',qc_scorecard_id='$qc_scorecard_id',qc_script='$qc_script',play_place_in_line='$play_place_in_line',play_estimate_hold_time='$play_estimate_hold_time',hold_time_option='$hold_time_option',hold_time_option_seconds='$hold_time_option_seconds',hold_time_option_exten='$hold_time_option_exten',hold_time_option_voicemail='$hold_time_option_voicemail',hold_time_option_xfer_group='$hold_time_option_xfer_group',hold_time_option_callback_filename='$hold_time_option_callback_filename',hold_time_option_callback_list_id='$hold_time_option_callback_list_id',hold_recall_xfer_group='$hold_recall_xfer_group',no_delay_call_route='$no_delay_call_route',play_welcome_message='$play_welcome_message',answer_sec_pct_rt_stat_one='$answer_sec_pct_rt_stat_one',answer_sec_pct_rt_stat_two='$answer_sec_pct_rt_stat_two',default_group_alias='$default_group_alias',no_agent_no_queue='$no_agent_no_queue',no_agent_action='$no_agent_action',no_agent_action_value='$no_agent_action_value',web_form_address_two='" . mysqli_real_escape_string($link, $web_form_address_two) . "',timer_action='$timer_action',timer_action_message='$timer_action_message',timer_action_seconds='$timer_action_seconds',start_call_url='" . mysqli_real_escape_string($link, $start_call_url) . "',dispo_call_url='" . mysqli_real_escape_string($link, $dispo_call_url) . "',xferconf_c_number='$xferconf_c_number',xferconf_d_number='$xferconf_d_number',xferconf_e_number='$xferconf_e_number',ignore_list_script_override='$ignore_list_script_override',extension_appended_cidname='$extension_appended_cidname',uniqueid_status_display='$uniqueid_status_display',uniqueid_status_prefix='$uniqueid_status_prefix',hold_time_option_minimum='$hold_time_option_minimum',hold_time_option_press_filename='$hold_time_option_press_filename',hold_time_option_callmenu='$hold_time_option_callmenu',onhold_prompt_no_block='$onhold_prompt_no_block',onhold_prompt_seconds='$onhold_prompt_seconds',hold_time_option_no_block='$hold_time_option_no_block',hold_time_option_prompt_seconds='$hold_time_option_prompt_seconds',hold_time_second_option='$hold_time_second_option',hold_time_third_option='$hold_time_third_option',wait_hold_option_priority='$wait_hold_option_priority',wait_time_option='$wait_time_option',wait_time_second_option='$wait_time_second_option',wait_time_third_option='$wait_time_third_option',wait_time_option_seconds='$wait_time_option_seconds',wait_time_option_exten='$wait_time_option_exten',wait_time_option_voicemail='$wait_time_option_voicemail',wait_time_option_xfer_group='$wait_time_option_xfer_group',wait_time_option_callmenu='$wait_time_option_callmenu',wait_time_option_callback_filename='$wait_time_option_callback_filename',wait_time_option_callback_list_id='$wait_time_option_callback_list_id',wait_time_option_press_filename='$wait_time_option_press_filename',wait_time_option_no_block='$wait_time_option_no_block',wait_time_option_prompt_seconds='$wait_time_option_prompt_seconds',timer_action_destination='$timer_action_destination',calculate_estimated_hold_seconds='$calculate_estimated_hold_seconds',add_lead_url='" . mysqli_real_escape_string($link, $add_lead_url) . "',eht_minimum_prompt_filename='$eht_minimum_prompt_filename',eht_minimum_prompt_no_block='$eht_minimum_prompt_no_block',eht_minimum_prompt_seconds='$eht_minimum_prompt_seconds',on_hook_ring_time='$on_hook_ring_time',na_call_url='" . mysqli_real_escape_string($link, $na_call_url) . "',on_hook_cid='$on_hook_cid',action_xfer_cid='$action_xfer_cid',drop_callmenu='$drop_callmenu',after_hours_callmenu='$after_hours_callmenu',user_group='$user_group',max_calls_method='$max_calls_method',max_calls_count='$max_calls_count',max_calls_action='$max_calls_action',dial_ingroup_cid='$dial_ingroup_cid',web_form_address_three='" . mysqli_real_escape_string($link, $web_form_address_three) . "',populate_lead_ingroup='$populate_lead_ingroup',drop_lead_reset='$drop_lead_reset',after_hours_lead_reset='$after_hours_lead_reset',nanq_lead_reset='$nanq_lead_reset',wait_time_lead_reset='$wait_time_lead_reset',hold_time_lead_reset='$hold_time_lead_reset',status_group_id='$status_group_id',routing_initiated_recordings='$routing_initiated_recordings',on_hook_cid_number='$on_hook_cid_number',customer_chat_screen_colors='$customer_chat_screen_colors',customer_chat_survey_link='" . mysqli_real_escape_string($link, $customer_chat_survey_link) . "',customer_chat_survey_text='$customer_chat_survey_text',populate_lead_province='$populate_lead_province',areacode_filter='$areacode_filter',areacode_filter_seconds='$areacode_filter_seconds',areacode_filter_action='$areacode_filter_action',areacode_filter_action_value='$areacode_filter_action_value',populate_state_areacode='$populate_state_areacode',inbound_survey='$inbound_survey',inbound_survey_filename='$inbound_survey_filename',inbound_survey_accept_digit='$inbound_survey_accept_digit',inbound_survey_question_filename='$inbound_survey_question_filename',inbound_survey_callmenu='$inbound_survey_callmenu',icbq_expiration_hours='$icbq_expiration_hours',closing_time_action='$closing_time_action',closing_time_now_trigger='$closing_time_now_trigger',closing_time_filename='$closing_time_filename',closing_time_end_filename='$closing_time_end_filename',closing_time_lead_reset='$closing_time_lead_reset',closing_time_option_exten='$closing_time_option_exten',closing_time_option_callmenu='$closing_time_option_callmenu',closing_time_option_voicemail='$closing_time_option_voicemail',closing_time_option_xfer_group='$closing_time_option_xfer_group',closing_time_option_callback_list_id='$closing_time_option_callback_list_id',icbq_call_time_id='$icbq_call_time_id',add_lead_timezone='$add_lead_timezone',icbq_dial_filter='$icbq_dial_filter',populate_lead_source='$populate_lead_source',populate_lead_vendor='$populate_lead_vendor',park_file_name='$park_file_name',waiting_call_url_on='" . mysqli_real_escape_string($link, $waiting_call_url_on) . "',waiting_call_url_off='" . mysqli_real_escape_string($link, $waiting_call_url_off) . "',enter_ingroup_url='" . mysqli_real_escape_string($link, $enter_ingroup_url) . "',cid_cb_confirm_number='$cid_cb_confirm_number',cid_cb_invalid_filter_phone_group='$cid_cb_invalid_filter_phone_group',cid_cb_valid_length='$cid_cb_valid_length',cid_cb_valid_filename='$cid_cb_valid_filename',cid_cb_confirmed_filename='$cid_cb_confirmed_filename',cid_cb_enter_filename='$cid_cb_enter_filename',cid_cb_you_entered_filename='$cid_cb_you_entered_filename',cid_cb_press_to_confirm_filename='$cid_cb_press_to_confirm_filename',cid_cb_invalid_filename='$cid_cb_invalid_filename',cid_cb_reenter_filename='$cid_cb_reenter_filename',cid_cb_error_filename='$cid_cb_error_filename',place_in_line_caller_number_filename='$place_in_line_caller_number_filename',place_in_line_you_next_filename='$place_in_line_you_next_filename', ingroup_script_two='$ingroup_script_two',browser_alert_sound='$browser_alert_sound',browser_alert_volume='$browser_alert_volume',answer_signal='$answer_signal',qc_statuses_id='$qc_statuses_id',no_agent_delay='$no_agent_delay',agent_search_method='$agent_search_method',populate_lead_comments='$populate_lead_comments',drop_call_seconds_override='$drop_call_seconds_override',populate_lead_owner='$populate_lead_owner',in_queue_nanque='$in_queue_nanque',in_queue_nanque_exceptions='$in_queue_nanque_exceptions',custom_one='$custom_one',custom_two='$custom_two',custom_three='$custom_three',custom_four='$custom_four',custom_five='$custom_five',second_alert_trigger='$second_alert_trigger',second_alert_trigger_seconds='$second_alert_trigger_seconds',second_alert_filename='$second_alert_filename',second_alert_delay='$second_alert_delay',second_alert_container='$second_alert_container',second_alert_only='$second_alert_only',third_alert_trigger='$third_alert_trigger',third_alert_trigger_seconds='$third_alert_trigger_seconds',third_alert_filename='$third_alert_filename',third_alert_delay='$third_alert_delay',third_alert_container='$third_alert_container',third_alert_only='$third_alert_only',agent_search_list='$agent_search_list',state_descriptions='$state_descriptions',stereo_recording='$stereo_recording',stereo_rec_filename='$stereo_rec_filename',stereo_parallel_recording='$stereo_parallel_recording',recording_dtmf_muting='$recording_dtmf_muting',stereo_recording_agent='$stereo_recording_agent',parallel_rec_co_filename='$parallel_rec_co_filename',parallel_rec_cm_filename='$parallel_rec_cm_filename',parallel_rec_fr_filename='$parallel_rec_fr_filename' where group_id='$group_id';";
					$rslt=mysql_to_mysqli($stmt, $link);

					switch($group_handling) 
						{
						case "PHONE":
							$ADD="4111";
							break;
						case "EMAIL":
							$ADD="4811";
							break;
						case "CHAT":
							$ADD="4911";
							break;
						default:
							$ADD="4111";
						}

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$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='INGROUPS', event_type='MODIFY', record_id='$group_id', event_code='ADMIN MODIFY INGROUP', event_sql=\"$SQL_log\", event_notes='';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		else
			{
			echo _QXZ("You do not have permission to view this page")."\n";
			exit;
			}
		}
	$ADD-=1000; #$ADD=3111;	# go to in-group modification form below
	}


######################
# ADD=4311 modify did info in the system
######################
if ($ADD==4311)
	{
	if ($LOGmodify_dids==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($did_id) < 1) or (strlen($did_pattern) < 1) )
			{
			echo "<br>"._QXZ("DID NOT MODIFIED - Please go back and look at the data you entered")."\n";
			echo "<br>did_extension "._QXZ("must be at least 1 character in length")."\n";
			}
		else
			{
			$did_entry_list_idSQL='';
			if ($SSenable_did_entry_list_id > 0)
				{
				$did_entry_list_idSQL=",entry_list_id='$entry_list_id',filter_entry_list_id='$filter_entry_list_id'";
				}
			echo "<br><B>"._QXZ("DID MODIFIED").": $did_pattern</B>\n";

			$k=0;   $new_field_value='';
			if (is_array($filter_phone_group_id)) {$multi_count = count($filter_phone_group_id);} else {$multi_count=0;}
			$multi_array = $filter_phone_group_id;
			while ($k < $multi_count)
				{
				$new_field_value .= "$multi_array[$k],";
				$k++;
				}
			$new_field_value = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$new_field_value);
			$filter_phone_group_id = preg_replace("/,$/","",$new_field_value);

			$k=0;   $new_field_value='';
			if (is_array($pre_filter_phone_group_id)) {$multi_count = count($pre_filter_phone_group_id);} else {$multi_count=0;}
			$multi_array = $pre_filter_phone_group_id;
			while ($k < $multi_count)
				{
				$new_field_value .= "$multi_array[$k],";
				$k++;
				}
			$new_field_value = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$new_field_value);
			$pre_filter_phone_group_id = preg_replace("/,$/","",$new_field_value);

			$stmt="UPDATE vicidial_inbound_dids set did_pattern='$did_pattern',did_description='$did_description',did_active='$did_active',did_route='$did_route',extension='$extension',exten_context='$exten_context',voicemail_ext='$voicemail_ext',phone='$phone',server_ip='$server_ip',user='$user',user_unavailable_action='$user_unavailable_action',user_route_settings_ingroup='$user_route_settings_ingroup',group_id='$group_id',call_handle_method='$call_handle_method',agent_search_method='$agent_search_method',list_id='$list_id',campaign_id='$campaign_id',phone_code='$phone_code',menu_id='$menu_id',record_call='$record_call',filter_inbound_number='$filter_inbound_number',filter_phone_group_id='$filter_phone_group_id',filter_url='" . mysqli_real_escape_string($link, $filter_url) . "',filter_action='$filter_action',filter_extension='$filter_extension',filter_exten_context='$filter_exten_context',filter_voicemail_ext='$filter_voicemail_ext',filter_phone='$filter_phone',filter_server_ip='$filter_server_ip',filter_user='$filter_user',filter_user_unavailable_action='$filter_user_unavailable_action',filter_user_route_settings_ingroup='$filter_user_route_settings_ingroup',filter_group_id='$filter_group_id',filter_call_handle_method='$filter_call_handle_method',filter_agent_search_method='$filter_agent_search_method',filter_list_id='$filter_list_id',filter_campaign_id='$filter_campaign_id',filter_phone_code='$filter_phone_code',filter_menu_id='$filter_menu_id',filter_clean_cid_number='$filter_clean_cid_number',custom_one='$custom_one',custom_two='$custom_two',custom_three='$custom_three',custom_four='$custom_four',custom_five='$custom_five',user_group='$user_group',filter_dnc_campaign='$filter_dnc_campaign',filter_url_did_redirect='$filter_url_did_redirect',no_agent_ingroup_redirect='$no_agent_ingroup_redirect',no_agent_ingroup_id='$no_agent_ingroup_id',no_agent_ingroup_extension='$no_agent_ingroup_extension',pre_filter_phone_group_id='$pre_filter_phone_group_id',pre_filter_extension='$pre_filter_extension',max_queue_ingroup_calls='$max_queue_ingroup_calls',max_queue_ingroup_id='$max_queue_ingroup_id',max_queue_ingroup_extension='$max_queue_ingroup_extension',did_carrier_description='$did_carrier_description',inbound_route_answer='$inbound_route_answer',pre_filter_recent_call='$pre_filter_recent_call',pre_filter_recent_extension='$pre_filter_recent_extension'$did_entry_list_idSQL where did_id='$did_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='DIDS', event_type='MODIFY', record_id='$did_id', event_code='ADMIN MODIFY DID', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=3311;	# go to did modification form below
	}


######################
# ADD=4511 modify call menu info in the system
######################
if ($ADD==4511)
	{
	if ($LOGmodify_dids==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if (strlen($menu_id) < 1 || strlen($menu_prompt) < 1)
			{
			echo "<br>"._QXZ("CALL MENU NOT MODIFIED - Please go back and look at the data you entered")."\n";
			if (strlen($menu_id) < 1) {echo "<br>menu_id "._QXZ("must be at least 1 character in length")."\n";}
			if (strlen($menu_prompt) < 1) {echo "<br>"._QXZ("Call Menu Prompt must be populated. Use sip-silence if you do not actually want to play a prompt")."\n";}
			}
		else
			{
			echo "<br><B>"._QXZ("CALL MENU MODIFIED").": $menu_id</B>\n";

			$custom_dialplanSQL='';
			if ($LOGmodify_custom_dialplans > 0)
				{$custom_dialplanSQL = ",custom_dialplan_entry='$custom_dialplan_entry'";}
			$stmt="UPDATE vicidial_call_menu set menu_name='$menu_name',menu_prompt='$menu_prompt',menu_timeout='$menu_timeout',menu_timeout_prompt='$menu_timeout_prompt',menu_invalid_prompt='$menu_invalid_prompt',menu_repeat='$menu_repeat',menu_time_check='$menu_time_check',call_time_id='$call_time_id',track_in_vdac='$track_in_vdac',tracking_group='$tracking_group',dtmf_log='$dtmf_log',dtmf_field='$dtmf_field',user_group='$user_group',qualify_sql='$qualify_sql',alt_dtmf_log='$alt_dtmf_log',question='$question',answer_signal='$answer_signal'$custom_dialplanSQL where menu_id='$menu_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			$h=0;
			$option_value_list='|';
			while ($h <= 20)
				{
				$option_value=''; $option_description=''; $option_route=''; $option_route_value=''; $option_route_value_context='';

				if (isset($_GET["option_value_$h"]))				{$option_value=$_GET["option_value_$h"];}
					elseif (isset($_POST["option_value_$h"]))		{$option_value=$_POST["option_value_$h"];}
				if (isset($_GET["option_description_$h"]))			{$option_description=$_GET["option_description_$h"];}
					elseif (isset($_POST["option_description_$h"]))	{$option_description=$_POST["option_description_$h"];}
				if (isset($_GET["option_route_$h"]))				{$option_route=$_GET["option_route_$h"];}
					elseif (isset($_POST["option_route_$h"]))		{$option_route=$_POST["option_route_$h"];}
				if (isset($_GET["option_route_value_$h"]))			{$option_route_value=$_GET["option_route_value_$h"];}
					elseif (isset($_POST["option_route_value_$h"]))	{$option_route_value=$_POST["option_route_value_$h"];}
				if (isset($_GET["option_route_value_context_$h"]))	{$option_route_value_context=$_GET["option_route_value_context_$h"];}
					elseif (isset($_POST["option_route_value_context_$h"]))	{$option_route_value_context=$_POST["option_route_value_context_$h"];}

				if ($option_route == "INGROUP")
					{
					if (isset($_GET["IGhandle_method_$h"]))						{$IGhandle_method=$_GET["IGhandle_method_$h"];}
						elseif (isset($_POST["IGhandle_method_$h"]))			{$IGhandle_method=$_POST["IGhandle_method_$h"];}
					if (isset($_GET["IGsearch_method_$h"]))						{$IGsearch_method=$_GET["IGsearch_method_$h"];}
						elseif (isset($_POST["IGsearch_method_$h"]))			{$IGsearch_method=$_POST["IGsearch_method_$h"];}
					if (isset($_GET["IGlist_id_$h"]))							{$IGlist_id=$_GET["IGlist_id_$h"];}
						elseif (isset($_POST["IGlist_id_$h"]))					{$IGlist_id=$_POST["IGlist_id_$h"];}
					if (isset($_GET["IGcampaign_id_$h"]))						{$IGcampaign_id=$_GET["IGcampaign_id_$h"];}
						elseif (isset($_POST["IGcampaign_id_$h"]))				{$IGcampaign_id=$_POST["IGcampaign_id_$h"];}
					if (isset($_GET["IGphone_code_$h"]))						{$IGphone_code=$_GET["IGphone_code_$h"];}
						elseif (isset($_POST["IGphone_code_$h"]))				{$IGphone_code=$_POST["IGphone_code_$h"];}
					if (isset($_GET["IGvid_enter_filename_$h"]))				{$IGvid_enter_filename=$_GET["IGvid_enter_filename_$h"];}
						elseif (isset($_POST["IGvid_enter_filename_$h"]))		{$IGvid_enter_filename=$_POST["IGvid_enter_filename_$h"];}
					if (isset($_GET["IGvid_id_number_filename_$h"]))			{$IGvid_id_number_filename=$_GET["IGvid_id_number_filename_$h"];}
						elseif (isset($_POST["IGvid_id_number_filename_$h"]))	{$IGvid_id_number_filename=$_POST["IGvid_id_number_filename_$h"];}
					if (isset($_GET["IGvid_confirm_filename_$h"]))				{$IGvid_confirm_filename=$_GET["IGvid_confirm_filename_$h"];}
						elseif (isset($_POST["IGvid_confirm_filename_$h"]))		{$IGvid_confirm_filename=$_POST["IGvid_confirm_filename_$h"];}
					if (isset($_GET["IGvid_validate_digits_$h"]))				{$IGvid_validate_digits=$_GET["IGvid_validate_digits_$h"];}
						elseif (isset($_POST["IGvid_validate_digits_$h"]))		{$IGvid_validate_digits=$_POST["IGvid_validate_digits_$h"];}
					if (isset($_GET["IGvid_container_$h"]))						{$IGvid_container=$_GET["IGvid_container_$h"];}
						elseif (isset($_POST["IGvid_container_$h"]))			{$IGvid_container=$_POST["IGvid_container_$h"];}

					$option_route_value_context = "$IGhandle_method,$IGsearch_method,$IGlist_id,$IGcampaign_id,$IGphone_code,$IGvid_enter_filename,$IGvid_id_number_filename,$IGvid_confirm_filename,$IGvid_validate_digits,$IGvid_container";
					}

				if ($non_latin < 1)
					{
					$option_value = preg_replace('/[^-\_0-9A-Z]/','',$option_value);
					$option_description = preg_replace('/[^- \:\/\_0-9a-zA-Z]/','',$option_description);
					$option_route = preg_replace('/[^-\_0-9a-zA-Z]/', '',$option_route);
					$option_route_value = preg_replace('/[^-\/\|\_\#\*\,\.\_0-9a-zA-Z]/','',$option_route_value);
					$option_route_value_context = preg_replace('/[^-\,\_0-9a-zA-Z]/','',$option_route_value_context);
					}
				else
					{
					$option_value = preg_replace('/[^-\_0-9A-Z]/','',$option_value);
					$option_description = preg_replace('/[^- \:\/\_0-9\p{L}]/u','',$option_description);
					$option_route = preg_replace('/[^-\_0-9\p{L}]/u', '',$option_route);
					$option_route_value = preg_replace('/[^-\/\|\_\#\*\,\.\_0-9\p{L}]/u','',$option_route_value);
					$option_route_value_context = preg_replace('/[^-\,\_0-9\p{L}]/u','',$option_route_value_context);
					}

				if (strlen($option_route) > 0)
					{
					$stmtA="SELECT count(*) from vicidial_call_menu_options where menu_id='$menu_id' and option_value='$option_value';";
					$rslt=mysql_to_mysqli($stmtA, $link);
					$row=mysqli_fetch_row($rslt);
					$option_exists = $row[0];

					if ($option_exists > 0)
						{
						$stmtA="UPDATE vicidial_call_menu_options SET option_description='$option_description',option_route='$option_route',option_route_value='$option_route_value',option_route_value_context='$option_route_value_context' where menu_id='$menu_id' and option_value='$option_value';";
						$rslt=mysql_to_mysqli($stmtA, $link);
						$stmtAX .= "$stmtA|";
						}
					else
						{
						$stmtA="INSERT INTO vicidial_call_menu_options SET menu_id='$menu_id',option_value='$option_value',option_description='$option_description',option_route='$option_route',option_route_value='$option_route_value',option_route_value_context='$option_route_value_context';";
						$rslt=mysql_to_mysqli($stmtA, $link);
						$stmtAX .= "$stmtA|";
						}
					}
				else
					{
					$stmtA="SELECT count(*) from vicidial_call_menu_options where menu_id='$menu_id' and option_value='$option_value';";
					$rslt=mysql_to_mysqli($stmtA, $link);
					$row=mysqli_fetch_row($rslt);
					$option_exists_db = $row[0];

					if ($option_exists_db > 0)
						{
						$stmtA="DELETE FROM vicidial_call_menu_options where menu_id='$menu_id' and option_value='$option_value';";
						$rslt=mysql_to_mysqli($stmtA, $link);
						$stmtAX .= "$stmtA|";
						}
					}
				$option_value_list .= "$option_value|";
				$h++;
				}
			## delete existing database records that were not in the submit
			while ($h <= 20)
				{
				if (!preg_match("/\|$dtmf[$h]\|/i",$option_value_list))
					{
					$stmtA="SELECT count(*) from vicidial_call_menu_options where menu_id='$menu_id' and option_value='$dtmf[$h]';";
					$rslt=mysql_to_mysqli($stmtA, $link);
					$row=mysqli_fetch_row($rslt);
					$option_exists_db = $row[0];

					if ($option_exists_db > 0)
						{
						$stmtA="DELETE FROM vicidial_call_menu_options where menu_id='$menu_id' and option_value='$dtmf[$h]';";
						$rslt=mysql_to_mysqli($stmtA, $link);
						$stmtAX .= "$stmtA|";
						}
					}
				$h++;
				}

			$stmtA="UPDATE servers set rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y';";
			$rslt=mysql_to_mysqli($stmtA, $link);
			$stmtAX .= "$stmtA|";

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmtAX";
			$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='CALLMENUS', event_type='MODIFY', record_id='$menu_id', event_code='ADMIN MODIFY CALL MENU', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=3511;	# go to call menu modification form below
	}


######################
# ADD=4711 modify filter phone group info in the system
######################
if ($ADD==4711)
	{
	if ($LOGmodify_dids==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($filter_phone_group_id) < 2) or (strlen($filter_phone_group_name) < 2) or (mb_strlen($filter_phone_group_name,'utf-8') > 40) )
			{
			echo "<br>"._QXZ("FILTER PHONE GROUP NOT MODIFIED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("Filter Phone Group Name and ID must be at least 2 characters in length")."\n";
			}
		else
			{
			$stmt="UPDATE vicidial_filter_phone_groups set filter_phone_group_name='$filter_phone_group_name', filter_phone_group_description='$filter_phone_group_description',user_group='$user_group' where filter_phone_group_id='$filter_phone_group_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("FILTER PHONE GROUP MODIFIED")."</B>\n";

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='FILTERPHONEGROUPS', event_type='MODIFY', record_id='$filter_phone_group_id', event_code='ADMIN FILTER PHONE GROUP', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=3711;	# go to filter phone group modification form below
	}


######################
# ADD=41111 modify remote agents info in the system
######################
if ($ADD==41111)
	{
	if ($LOGmodify_remoteagents==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT count(*) from vicidial_users where user='$user_start' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ( ($row[0] < 1) and ($stage != 'ORPHAN') )
			{echo "<br>"._QXZ("REMOTE AGENTS NOT MODIFIED - you must use a valid user as the user_start for remote agents")."\n";}
		else
			{
			if ($row[0] < 1)
				{echo "<br><b>"._QXZ("This Remote Agent does not have a valid User")."</b><br>\n";}
			### check for closest remote agents to this account to ensure no overlapping
			$user_finish = ($user_start + $number_of_lines);
			$user_finish_length = strlen($user_finish);
			$stmt="SELECT count(*) from vicidial_remote_agents where user_start > '$user_start' and user_start < '$user_finish' and user_start != '$user_start' and (char_length(user_start) <= $user_finish_length);";
			if ($DB > 0) {echo "|$stmt|";}
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] > 0)
				{echo "<br>"._QXZ("REMOTE AGENTS NOT MODIFIED - your number of lines overlaps with another remote agent")."\n";}
			else
				{
				if ( (strlen($server_ip) < 2) or (strlen($user_start) < 2)  or (strlen($campaign_id) < 2) or (strlen($conf_exten) < 2) )
					{
					echo "<br>"._QXZ("REMOTE AGENTS NOT MODIFIED - Please go back and look at the data you entered")."\n";
					echo "<br>"._QXZ("User ID Start and External Extension must be at least 2 characters in length")."\n";
					}
				else
					{
					if ($number_of_lines < 1) {$status='INACTIVE';}
					$stmt="UPDATE vicidial_remote_agents set user_start='$user_start', number_of_lines='$number_of_lines', server_ip='$server_ip', conf_exten='$conf_exten', status='$status', campaign_id='$campaign_id', closer_campaigns='$groups_value',extension_group='$extension_group',on_hook_agent='$on_hook_agent',on_hook_ring_time='$on_hook_ring_time' where remote_agent_id='$remote_agent_id';";
					$rslt=mysql_to_mysqli($stmt, $link);

					echo "<br><B>"._QXZ("REMOTE AGENTS MODIFIED")."</B>\n";

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$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='REMOTEAGENTS', event_type='MODIFY', record_id='$remote_agent_id', event_code='ADMIN MODIFY REMOTE AGENT', event_sql=\"$SQL_log\", event_notes='';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=31111;	# go to remote agents modification form below
	}


######################
# ADD=42111 modify extenison group entry in the system
######################
if ($ADD==42111)
	{
	if ($LOGmodify_remoteagents==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($extension_id) < 1) or (strlen($extension_group_id) < 2)  or (strlen($extension) < 2) or (strlen($rank) < 1) )
			{
			echo "<br>"._QXZ("EXTENSION GROUP ENTRY NOT MODIFIED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("Extension group id and extension must be at least 2 characters in length")."\n";
			}
		else
			{
			$stmt="UPDATE vicidial_extension_groups set extension_group_id='$extension_group_id', extension='$extension', rank='$rank', campaign_groups='$campaign_groups' where extension_id='$extension_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("EXTENSION GROUP ENTRY MODIFIED")."</B>\n";

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='EXTENGROUP', event_type='MODIFY', record_id='$extension_id', event_code='ADMIN MODIFY EXTENSION GROUP', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=32111;	# go to extension group modification form below
	}


######################
# ADD=411111 modify user group info in the system
######################
if ($ADD==411111)
	{
	if ($LOGmodify_usergroups==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($user_group) < 2) or (strlen($group_name) < 2) )
			{
			echo "<br>"._QXZ("USER GROUP NOT MODIFIED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("Group name and description must be at least 2 characters in length")."\n";
			}
		else
			{
			if ( ($LOGmodify_same_user_level < 1) and ($user_group=="$LOGuser_group") )
				{
				echo _QXZ("You are not allowed to edit your own user group")."\n";
				exit;
				}
			else
				{
				$p=0;
				$GROUP_shifts=' ';
				$group_shifts_ct = (is_array($group_shifts) ? count($group_shifts) : -1);
				while ($p <= $group_shifts_ct)
					{
					if ($non_latin < 1)
						{
						$group_shifts[$p] = preg_replace('/[^- \_0-9a-zA-Z]/','',$group_shifts[$p]);
						}
					else
						{
						$group_shifts[$p] = preg_replace('/[^- \_0-9\p{L}]/u','',$group_shifts[$p]);
						}
					$GROUP_shifts .= "$group_shifts[$p] ";
					$p++;
					}
				$p=0;
				$VGROUP_vgroups=' ';
				$vgroup_vgroups_ct = (is_array($agent_status_viewable_groups) ? count($agent_status_viewable_groups) : -1);
				while ($p <= $vgroup_vgroups_ct)
					{
					if ($non_latin < 1)
						{
						$agent_status_viewable_groups[$p] = preg_replace('/[^- \_0-9a-zA-Z]/','',$agent_status_viewable_groups[$p]);
						}
					else
						{
						$agent_status_viewable_groups[$p] = preg_replace('/[^- \_0-9\p{L}]/u','',$agent_status_viewable_groups[$p]);
						}
					$VGROUP_vgroups .= "$agent_status_viewable_groups[$p] ";
					$p++;
					}
				$p=0;
				$VGROUP_chatgroups=' ';
				$vgroup_chatgroups_ct = (is_array($agent_allowed_chat_groups) ? count($agent_allowed_chat_groups) : -1);
				while ($p <= $vgroup_chatgroups_ct)
					{
					if ($non_latin < 1)
						{
						$agent_allowed_chat_groups[$p] = preg_replace('/[^- \_0-9a-zA-Z]/','',$agent_allowed_chat_groups[$p]);
						}
					else
						{
						$agent_allowed_chat_groups[$p] = preg_replace('/[^- \_0-9\p{L}]/u','',$agent_allowed_chat_groups[$p]);
						}
					$VGROUP_chatgroups .= "$agent_allowed_chat_groups[$p] ";
					$p++;
					}
				$p=0;
				$Vadmin_viewable_groups=' ';
				$admin_viewable_groups_ct = (is_array($admin_viewable_groups) ? count($admin_viewable_groups) : -1);
				while ($p <= $admin_viewable_groups_ct)
					{
					if ($non_latin < 1)
						{
						$admin_viewable_groups[$p] = preg_replace('/[^- \_0-9a-zA-Z]/','',$admin_viewable_groups[$p]);
						}
					else
						{
						$admin_viewable_groups[$p] = preg_replace('/[^- \_0-9\p{L}]/u','',$admin_viewable_groups[$p]);
						}
					$Vadmin_viewable_groups .= "$admin_viewable_groups[$p] ";
					$p++;
					}
				$p=0;
				$Vadmin_viewable_call_times=' ';
				$admin_viewable_call_times_ct = (is_array($admin_viewable_call_times) ? count($admin_viewable_call_times) : -1);
				while ($p <= $admin_viewable_call_times_ct)
					{
					if ($non_latin < 1)
						{
						$admin_viewable_call_times[$p] = preg_replace('/[^- \_0-9a-zA-Z]/','',$admin_viewable_call_times[$p]);
						}
					else
						{
						$admin_viewable_call_times[$p] = preg_replace('/[^- \_0-9\p{L}]/u','',$admin_viewable_call_times[$p]);
						}
					$Vadmin_viewable_call_times .= "$admin_viewable_call_times[$p] ";
					$p++;
					}
				$k=0;
				$multi_count = (is_array($allowed_reports) ? count($allowed_reports) : -1);
				$multi_array = $allowed_reports;
				while ($k < $multi_count)
					{
					$new_field_value .= "$multi_array[$k],";
					$k++;
					}
				$new_field_value = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$new_field_value);
				$allowed_reports = preg_replace("/,$/","",$new_field_value);

				# update allowed_camapigns with values that the editor cant see http://www.vicidial.org/VICIDIALforum/viewtopic.php?f=5&t=26101
				if ( (!preg_match('/\-ALL/i', $LOGallowed_campaigns)) )
					{
					$changer_allowed_campaigns = preg_replace("/ -/",'',$LOGallowed_campaigns);
					$changer_allowed_campaigns = explode(" ", $changer_allowed_campaigns);

					$stmt="SELECT allowed_campaigns FROM vicidial_user_groups WHERE user_group='$OLDuser_group';";
					$rslt=mysql_to_mysqli($stmt, $link);
					if ($DB) {echo "$stmt\n";}
					$old_allowed_rows = mysqli_num_rows($rslt);
					if ($old_allowed_rows > 0)
						{
						$row=mysqli_fetch_row($rslt);
						$old_allowed =  $row[0];  
						}
					if ( (!preg_match('/-ALL/',$old_allowed)) )
						{
						$invis_campaigns="";
						$campaigns_value = preg_replace("/ -/",'',$campaigns_value);
						$old_allowed = preg_replace("/ -/",'',$old_allowed);
						$old_allowed = explode(" ", $old_allowed);

						foreach ($old_allowed as $oac) 
							{
							if (!in_array($oac, $changer_allowed_campaigns))
								{
								$invis_campaigns .= "$oac ";
								}
							}
						$campaigns_value .= " $invis_campaigns-";
						}
					}

				$custom_rpt_SQL='';
				$custom_stmt="show tables like 'vicidial_custom_reports'";
				$custom_rslt=mysql_to_mysqli($custom_stmt, $link);
				if (mysqli_num_rows($custom_rslt)>0) 
					{
		
					$custom_report_str="";
					if (is_array($allowed_custom_reports) && count($allowed_custom_reports)>0) 
						{
						for ($q=0; $q<count($allowed_custom_reports); $q++) 
							{
							$custom_report_str.=$allowed_custom_reports[$q]."|";
							}
						}
					if (preg_match('/\-\-NONE\-\-/i', $custom_report_str)) {$custom_report_str='';}
					else if (preg_match('/\-\-ALL\-\-/i', $custom_report_str)) 
						{
						$custom_report_str='';
						$custom_report_stmt="SELECT report_name from vicidial_custom_reports";
						$custom_report_rslt=mysql_to_mysqli($custom_report_stmt, $link);
						while ($custom_rpt_row=mysqli_fetch_row($custom_report_rslt)) 
							{
							$custom_report_str.=$custom_rpt_row[0]."|";
							}
						}
					$custom_report_str = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$custom_report_str);
					$custom_rpt_SQL=",allowed_custom_reports='$custom_report_str'";
					}
				$stmt="UPDATE vicidial_user_groups set user_group='$user_group', group_name='$group_name',allowed_campaigns='$campaigns_value',qc_allowed_campaigns='$qc_campaigns_value',qc_allowed_inbound_groups='$qc_groups_value',group_shifts='$GROUP_shifts',forced_timeclock_login='$forced_timeclock_login',shift_enforcement='$shift_enforcement',agent_status_viewable_groups='$VGROUP_vgroups',agent_status_view_time='$agent_status_view_time',agent_call_log_view='$agent_call_log_view',agent_xfer_consultative='$agent_xfer_consultative',agent_xfer_dial_override='$agent_xfer_dial_override',agent_xfer_vm_transfer='$agent_xfer_vm_transfer',agent_xfer_blind_transfer='$agent_xfer_blind_transfer',agent_xfer_dial_with_customer='$agent_xfer_dial_with_customer',agent_xfer_park_customer_dial='$agent_xfer_park_customer_dial',agent_fullscreen='$agent_fullscreen',allowed_reports='$allowed_reports'$custom_rpt_SQL,webphone_url_override='" . mysqli_real_escape_string($link, $webphone_url_override) . "',webphone_systemkey_override='$webphone_systemkey_override',webphone_dialpad_override='$webphone_dialpad_override',admin_viewable_groups='$Vadmin_viewable_groups',admin_viewable_call_times='$Vadmin_viewable_call_times',agent_allowed_chat_groups='$VGROUP_chatgroups',agent_xfer_park_3way='$agent_xfer_park_3way',admin_ip_list='$admin_ip_list',agent_ip_list='$agent_ip_list',api_ip_list='$api_ip_list',webphone_layout='" . mysqli_real_escape_string($link, $webphone_layout) . "',reports_header_override='$reports_header_override',admin_home_url='" . mysqli_real_escape_string($link, $admin_home_url) . "',allowed_queue_groups='$queue_groups_value',script_id='$script_id' where user_group='$OLDuser_group';";
				$rslt=mysql_to_mysqli($stmt, $link);

				echo "<br><B>"._QXZ("USER GROUP MODIFIED")."</B>\n";

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='USERGROUPS', event_type='MODIFY', record_id='$user_group', event_code='ADMIN MODIFY USER GROUP', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);

				###############################################################
				##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP #####
				$stmt = "SELECT enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url FROM system_settings;";
				$rslt=mysql_to_mysqli($stmt, $link);
				if ($DB) {echo "$stmt\n";}
				$ss_conf_ct = mysqli_num_rows($rslt);
				if ($ss_conf_ct > 0)
					{
					$row=mysqli_fetch_row($rslt);
					$enable_vtiger_integration =	$row[0];
					$vtiger_server_ip	=			$row[1];
					$vtiger_dbname =				$row[2];
					$vtiger_login =					$row[3];
					$vtiger_pass =					$row[4];
					$vtiger_url =					$row[5];
					}
				##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP #####
				#############################################################

				if ($enable_vtiger_integration > 0)
					{
					### connect to your vtiger database
					#$linkV=mysql_connect("$vtiger_server_ip", "$vtiger_login","$vtiger_pass");
					#if (!$linkV) {die("Could not connect: $vtiger_server_ip|$vtiger_dbname|$vtiger_login|$vtiger_pass" . mysqli_error());}
					#echo 'Connected successfully';
					#mysql_select_db("$vtiger_dbname", $linkV);
					$linkV=mysqli_connect("$vtiger_server_ip", "$vtiger_login", "$vtiger_pass", "$vtiger_dbname");
					if (!$linkV) 
						{
						die('MySQL '._QXZ("connect ERROR").': ' . mysqli_connect_error());
						}

					######################################
					##### BEGIN Add/Update group info in Vtiger
					$stmt="SELECT count(*) from vtiger_groups where groupname='$user_group';";
					$rslt=mysql_to_mysqli($stmt, $linkV);
					if ($DB) {echo "$stmt\n";}
					if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
					$row=mysqli_fetch_row($rslt);
					$group_found_count = $row[0];

					### group exists in vtiger, update it
					if ($group_found_count > 0)
						{
						$stmt="SELECT groupid from vtiger_groups where groupname='$user_group';";
						$rslt=mysql_to_mysqli($stmt, $linkV);
						if ($DB) {echo "$stmt\n";}
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
						$row=mysqli_fetch_row($rslt);
						$groupid = $row[0];

						$stmtA = "UPDATE vtiger_groups SET description='$group_name' where groupid='$groupid';";
						if ($DB) {echo "|$stmtA|\n";}
						$rslt=mysql_to_mysqli($stmtA, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}
						}

					### user doesn't exist in vtiger, insert it
					else
						{
						#### BEGIN CREATE NEW GROUP RECORD IN VTIGER
						# Get next available id from vtiger_users_seq to use as groupid
						$stmt="SELECT id from vtiger_users_seq;";
						if ($DB) {echo "$stmt\n";}
						$rslt=mysql_to_mysqli($stmt, $linkV);
						$row=mysqli_fetch_row($rslt);
						$groupid = ($row[0] + 1);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						# Increase next available groupid with 1 so next record gets proper id
						$stmt="UPDATE vtiger_users_seq SET id = '$groupid';";
						if ($DB) {echo "$stmt\n";}
						$rslt=mysql_to_mysqli($stmt, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						$stmtA = "INSERT INTO vtiger_groups SET groupid='$groupid',groupname='$user_group',description='$group_name';";
						if ($DB) {echo "|$stmtA|\n";}
						$rslt=mysql_to_mysqli($stmtA, $linkV);
						if (!$rslt) {die(_QXZ("Could not execute").': ' . mysqli_error());}

						#### END CREATE NEW GROUP RECORD IN VTIGER
						}
					##### END Add/Update group info in Vtiger
					######################################
					}
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=311111;	# go to user group modification form below
	}


######################
# ADD=4111111 modify script in the system
######################
if ($ADD==4111111)
	{
	if ($LOGmodify_scripts==1)
		{
		echo "<!-- $script_text -->\n";
		echo "<!--" . mysqli_real_escape_string($link, $script_text) . " -->\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($script_id) < 2) or (strlen($script_name) < 2) or (strlen($script_text) < 2) )
			{
			echo "<br>"._QXZ("SCRIPT NOT MODIFIED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("Script name, description and text must be at least 2 characters in length")."\n";
			}
		else
			{
			if ( (!preg_match("/\|$script_color,/i",$HTMLcolors)) and ( (strlen($script_color) > 7) or (strlen($script_color) < 7) or (!preg_match("/^#/",$script_color)) ) )
				{
				if (!preg_match("/^#/",$script_color)) {$script_color = "#$script_color";}
				if (strlen($script_color) > 7) {$script_color = substr($rowx[1],0,7);}
				while (strlen($script_color) < 7) {$script_color .= '0';}
				}
			$stmt="UPDATE vicidial_scripts set script_name='$script_name', script_comments='$script_comments', script_text='" . mysqli_real_escape_string($link, $script_text) . "', active='$active',user_group='$user_group',script_color='$script_color' where script_id='$script_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("SCRIPT MODIFIED")."</B>$rjs_debug\n";

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='SCRIPTS', event_type='MODIFY', record_id='$script_id', event_code='ADMIN MODIFY SCRIPT', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=3111111;	# go to script modification form below
	}


######################
# ADD=41111111 modify filter in the system
######################
if ($ADD==41111111)
	{
	if ($LOGmodify_filters==1)
		{
		echo "<!-- $lead_filter_sql -->\n";
		echo "<!--" . mysqli_real_escape_string($link, $lead_filter_sql) . " -->\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($lead_filter_id) < 2) or (strlen($lead_filter_name) < 2) or (strlen($lead_filter_sql) < 2) )
			{
			echo "<br>"._QXZ("FILTER NOT MODIFIED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("Filter ID, name and SQL must be at least 2 characters in length")."\n";
			}
		else
			{
			$stmt="UPDATE vicidial_lead_filters set lead_filter_name='$lead_filter_name', lead_filter_comments='$lead_filter_comments', lead_filter_sql='" . mysqli_real_escape_string($link, $lead_filter_sql) . "',user_group='$user_group' where lead_filter_id='$lead_filter_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("FILTER MODIFIED")."</B>\n";

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='FILTERS', event_type='MODIFY', record_id='$lead_filter_id', event_code='ADMIN MODIFY FILTER', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=31111111;	# go to filter modification form below
	}


######################
# ADD=411111111 modify call time in the system
######################
if ($ADD==411111111)
	{
	if ($LOGmodify_call_times==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) )
			{
			echo "<br>"._QXZ("CALL TIME NOT MODIFIED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("Call Time ID and name must be at least 2 characters in length")."\n";
			}
		else
			{
			$ct_default_start = preg_replace('/\D/', '', $ct_default_start);
			$ct_default_stop = preg_replace('/\D/', '', $ct_default_stop);
			$ct_sunday_start = preg_replace('/\D/', '', $ct_sunday_start);
			$ct_sunday_stop = preg_replace('/\D/', '', $ct_sunday_stop);
			$ct_monday_start = preg_replace('/\D/', '', $ct_monday_start);
			$ct_monday_stop = preg_replace('/\D/', '', $ct_monday_stop);
			$ct_tuesday_start = preg_replace('/\D/', '', $ct_tuesday_start);
			$ct_tuesday_stop = preg_replace('/\D/', '', $ct_tuesday_stop);
			$ct_wednesday_start = preg_replace('/\D/', '', $ct_wednesday_start);
			$ct_wednesday_stop = preg_replace('/\D/', '', $ct_wednesday_stop);
			$ct_thursday_start = preg_replace('/\D/', '', $ct_thursday_start);
			$ct_thursday_stop = preg_replace('/\D/', '', $ct_thursday_stop);
			$ct_friday_start = preg_replace('/\D/', '', $ct_friday_start);
			$ct_friday_stop = preg_replace('/\D/', '', $ct_friday_stop);
			$ct_saturday_start = preg_replace('/\D/', '', $ct_saturday_start);
			$ct_saturday_stop = preg_replace('/\D/', '', $ct_saturday_stop);
			$stmt="UPDATE vicidial_call_times set call_time_name='$call_time_name', call_time_comments='$call_time_comments', ct_default_start='$ct_default_start', ct_default_stop='$ct_default_stop', ct_sunday_start='$ct_sunday_start', ct_sunday_stop='$ct_sunday_stop', ct_monday_start='$ct_monday_start', ct_monday_stop='$ct_monday_stop', ct_tuesday_start='$ct_tuesday_start', ct_tuesday_stop='$ct_tuesday_stop', ct_wednesday_start='$ct_wednesday_start', ct_wednesday_stop='$ct_wednesday_stop', ct_thursday_start='$ct_thursday_start', ct_thursday_stop='$ct_thursday_stop', ct_friday_start='$ct_friday_start', ct_friday_stop='$ct_friday_stop', ct_saturday_start='$ct_saturday_start', ct_saturday_stop='$ct_saturday_stop', default_afterhours_filename_override='$default_afterhours_filename_override', sunday_afterhours_filename_override='$sunday_afterhours_filename_override', monday_afterhours_filename_override='$monday_afterhours_filename_override', tuesday_afterhours_filename_override='$tuesday_afterhours_filename_override', wednesday_afterhours_filename_override='$wednesday_afterhours_filename_override', thursday_afterhours_filename_override='$thursday_afterhours_filename_override', friday_afterhours_filename_override='$friday_afterhours_filename_override', saturday_afterhours_filename_override='$saturday_afterhours_filename_override',user_group='$user_group' where call_time_id='$call_time_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("CALL TIME MODIFIED")."</B>\n";

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='CALLTIMES', event_type='MODIFY', record_id='$call_time_id', event_code='ADMIN MODIFY CALL TIME', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=311111111;	# go to call time modification form below
	}


######################
# ADD=4111111111 modify state call time in the system
######################
if ($ADD==4111111111)
	{
	if ($LOGmodify_call_times==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) or (strlen($state_call_time_state) < 2) )
			{
			echo "<br>"._QXZ("STATE CALL TIME NOT MODIFIED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("State Call Time ID, name and state must be at least 2 characters in length")."\n";
			}
		else
			{
			$ct_default_start = preg_replace('/\D/', '', $ct_default_start);
			$ct_default_stop = preg_replace('/\D/', '', $ct_default_stop);
			$ct_sunday_start = preg_replace('/\D/', '', $ct_sunday_start);
			$ct_sunday_stop = preg_replace('/\D/', '', $ct_sunday_stop);
			$ct_monday_start = preg_replace('/\D/', '', $ct_monday_start);
			$ct_monday_stop = preg_replace('/\D/', '', $ct_monday_stop);
			$ct_tuesday_start = preg_replace('/\D/', '', $ct_tuesday_start);
			$ct_tuesday_stop = preg_replace('/\D/', '', $ct_tuesday_stop);
			$ct_wednesday_start = preg_replace('/\D/', '', $ct_wednesday_start);
			$ct_wednesday_stop = preg_replace('/\D/', '', $ct_wednesday_stop);
			$ct_thursday_start = preg_replace('/\D/', '', $ct_thursday_start);
			$ct_thursday_stop = preg_replace('/\D/', '', $ct_thursday_stop);
			$ct_friday_start = preg_replace('/\D/', '', $ct_friday_start);
			$ct_friday_stop = preg_replace('/\D/', '', $ct_friday_stop);
			$ct_saturday_start = preg_replace('/\D/', '', $ct_saturday_start);
			$ct_saturday_stop = preg_replace('/\D/', '', $ct_saturday_stop);
			$stmt="UPDATE vicidial_state_call_times set state_call_time_name='$call_time_name', state_call_time_comments='$call_time_comments', sct_default_start='$ct_default_start', sct_default_stop='$ct_default_stop', sct_sunday_start='$ct_sunday_start', sct_sunday_stop='$ct_sunday_stop', sct_monday_start='$ct_monday_start', sct_monday_stop='$ct_monday_stop', sct_tuesday_start='$ct_tuesday_start', sct_tuesday_stop='$ct_tuesday_stop', sct_wednesday_start='$ct_wednesday_start', sct_wednesday_stop='$ct_wednesday_stop', sct_thursday_start='$ct_thursday_start', sct_thursday_stop='$ct_thursday_stop', sct_friday_start='$ct_friday_start', sct_friday_stop='$ct_friday_stop', sct_saturday_start='$ct_saturday_start', sct_saturday_stop='$ct_saturday_stop', state_call_time_state='$state_call_time_state',user_group='$user_group' where state_call_time_id='$call_time_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("STATE CALL TIME MODIFIED")."</B>\n";

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='CALLTIMES_STATE', event_type='MODIFY', record_id='$call_time_id', event_code='ADMIN MODIFY STATE CALL TIME', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=3111111111;	# go to state call time modification form below
	}


######################
# ADD=4211111111 modify holiday in the system
######################
if ($ADD==4211111111)
	{
	if ($LOGmodify_call_times==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($holiday_id) < 2) or (strlen($holiday_name) < 2) or (strlen($holiday_date) < 10) )
			{
			echo "<br>"._QXZ("HOLIDAY NOT MODIFIED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("Holiday ID, name and date must be populated")."\n";
			}
		else
			{
			$ct_default_start = preg_replace('/\D/', '', $ct_default_start);
			$ct_default_stop = preg_replace('/\D/', '', $ct_default_stop);
			$stmt="UPDATE vicidial_call_time_holidays set holiday_name='$holiday_name', holiday_comments='$holiday_comments', holiday_date='$holiday_date', holiday_status='$holiday_status', ct_default_start='$ct_default_start', ct_default_stop='$ct_default_stop',user_group='$user_group', default_afterhours_filename_override='$default_afterhours_filename_override',holiday_method='$holiday_method' where holiday_id='$holiday_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("HOLIDAY MODIFIED")."</B>\n";

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='HOLIDAYS', event_type='MODIFY', record_id='$holiday_id', event_code='ADMIN MODIFY HOLIDAY', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=3211111111;	# go to holiday modification form below
	}


######################
# ADD=431111111 modify shift in the system
######################
if ($ADD==431111111)
	{
	if ( ($LOGmodify_call_times==1) or ($LOGmodify_shifts==1) )
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$shift_length_test = preg_replace('/:/i', '',$shift_length);
		if ( (strlen($shift_id) < 2) or (strlen($shift_name) < 2) or (strlen($shift_start_time) < 4) or (strlen($shift_start_time) > 4) or (strlen($shift_length) < 5) or (strlen($shift_length) > 5) or ($shift_start_time > 2359) or ($shift_length_test > 2400) or (!is_array($shift_weekdays)) )
			{
			echo "<br>"._QXZ("SHIFT DEFINITION NOT MODIFIED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("Shift ID and name must be at least 2 characters in length")."\n";
			echo "<br>"._QXZ("Shift Start Time must be 4 digits in length and be a valid time")."\n";
			echo "<br>"._QXZ("Shift Length must be 5 characters in length and be 24 hours or less")."\n";
			echo "<br>"._QXZ("At least one weekday must be selected")."\n";
			}
		else
			{
			$p=0;
			$shift_weekdays_ct = count($shift_weekdays);
			while ($p <= $shift_weekdays_ct)
				{
				$SHIFT_weekdays .= "$shift_weekdays[$p]";
				$p++;
				}
			$SHIFT_weekdays = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$SHIFT_weekdays);
			$shift_start_time = preg_replace('/\D/', '', $shift_start_time);
			$stmt="UPDATE vicidial_shifts set shift_name='$shift_name', shift_start_time='$shift_start_time', shift_length='$shift_length', shift_weekdays='$SHIFT_weekdays',report_option='$report_option',user_group='$user_group',report_rank='$report_rank' where shift_id='$shift_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("SHIFT MODIFIED")."</B>\n";

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='SHIFTS', event_type='MODIFY', record_id='$shift_id', event_code='ADMIN MODIFY SHIFT', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=331111111;	# go to shift modification form below
	}


######################
# ADD=41111111111 modify phone record in the system
######################
if ($ADD==41111111111)
	{
	if ( ($LOGast_admin_access==1) or ($LOGmodify_phones==1) )
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT count(*) from phones where extension='$extension' and server_ip='$server_ip' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ( ($row[0] > 0) and ( ($extension != $old_extension) or ($server_ip != $old_server_ip) ) )
			{echo "<br>"._QXZ("PHONE NOT MODIFIED - there is already a Phone in the system with this extension/server")."\n";}
		else
			{
			if ( (strlen($extension) < 1) or (strlen($server_ip) < 7) or (strlen($dialplan_number) < 1) or (strlen($voicemail_id) < 1) or (strlen($login) < 1)  or (strlen($pass) < 1) or ( ($SSrequire_password_length > 0) and ($SSrequire_password_length > strlen($conf_secret)) ))
				{
				echo "<br>"._QXZ("PHONE NOT MODIFIED - Please go back and look at the data you entered")."\n";
				if ($SSrequire_password_length > 0)
					{
					echo "<br>"._QXZ("registration password must be at least $SSrequire_password_length characters long")."\n";
					}
				}
			else
				{
				$stmt="SELECT count(*) from vicidial_voicemail where voicemail_id='$voicemail_id';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				if ($row[0] > 0)
					{echo "<br>"._QXZ("PHONE NOT MODIFIED - there is already a Voicemail ID in the system with this ID")."\n";}
				else
					{
					echo "<br>"._QXZ("PHONE MODIFIED").": $extension\n";

					if ( ($voicemail_greeting == '') and (strlen($old_voicemail_greeting) > 0) )
						{$voicemail_greeting = '---DELETE---';}

					$stmt="UPDATE phones set extension='$extension', dialplan_number='$dialplan_number', voicemail_id='$voicemail_id', phone_ip='$phone_ip', computer_ip='$computer_ip', server_ip='$server_ip', login='$login', pass='$pass', status='$status', active='$active', phone_type='$phone_type', fullname='$fullname', company='$company', picture='$picture', protocol='$protocol', local_gmt='$local_gmt', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', login_user='$login_user', login_pass='$login_pass', login_campaign='$login_campaign', park_on_extension='$park_on_extension', conf_on_extension='$conf_on_extension', VICIDIAL_park_on_extension='$VICIDIAL_park_on_extension', VICIDIAL_park_on_filename='$VICIDIAL_park_on_filename', monitor_prefix='$monitor_prefix', recording_exten='$recording_exten', voicemail_exten='$voicemail_exten', voicemail_dump_exten='$voicemail_dump_exten', ext_context='$ext_context', dtmf_send_extension='$dtmf_send_extension', call_out_number_group='$call_out_number_group', client_browser='$client_browser', install_directory='$install_directory', local_web_callerID_URL='" . mysqli_real_escape_string($link, $local_web_callerID_URL) . "', VICIDIAL_web_URL='" . mysqli_real_escape_string($link, $VICIDIAL_web_URL) . "', AGI_call_logging_enabled='$AGI_call_logging_enabled', user_switching_enabled='$user_switching_enabled', conferencing_enabled='$conferencing_enabled', admin_hangup_enabled='$admin_hangup_enabled', admin_hijack_enabled='$admin_hijack_enabled', admin_monitor_enabled='$admin_monitor_enabled', call_parking_enabled='$call_parking_enabled', updater_check_enabled='$updater_check_enabled', AFLogging_enabled='$AFLogging_enabled', QUEUE_ACTION_enabled='$QUEUE_ACTION_enabled', CallerID_popup_enabled='$CallerID_popup_enabled', voicemail_button_enabled='$voicemail_button_enabled', enable_fast_refresh='$enable_fast_refresh', fast_refresh_rate='$fast_refresh_rate', enable_persistant_mysql='$enable_persistant_mysql', auto_dial_next_number='$auto_dial_next_number', VDstop_rec_after_each_call='$VDstop_rec_after_each_call', DBX_server='$DBX_server', DBX_database='$DBX_database', DBX_user='$DBX_user', DBX_pass='$DBX_pass', DBX_port='$DBX_port', DBY_server='$DBY_server', DBY_database='$DBY_database', DBY_user='$DBY_user', DBY_pass='$DBY_pass', DBY_port='$DBY_port', outbound_cid='$outbound_cid', enable_sipsak_messages='$enable_sipsak_messages', email='$email', template_id='$template_id', conf_override='$conf_override',phone_context='$phone_context',phone_ring_timeout='$phone_ring_timeout',conf_secret='$conf_secret', delete_vm_after_email='$delete_vm_after_email',is_webphone='$is_webphone',use_external_server_ip='$use_external_server_ip',codecs_list='$codecs_list',codecs_with_template='$codecs_with_template',webphone_dialpad='$webphone_dialpad',on_hook_agent='$on_hook_agent',webphone_auto_answer='$webphone_auto_answer',voicemail_timezone='$voicemail_timezone',voicemail_options='$voicemail_options',user_group='$user_group',voicemail_greeting='$voicemail_greeting',voicemail_dump_exten_no_inst='$voicemail_dump_exten_no_inst',voicemail_instructions='$voicemail_instructions',on_login_report='$show_vm_on_summary',unavail_dialplan_fwd_exten='$unavail_dialplan_fwd_exten',unavail_dialplan_fwd_context='$unavail_dialplan_fwd_context', nva_call_url='" . mysqli_real_escape_string($link, $nva_call_url) . "', nva_search_method='$nva_search_method', nva_error_filename='$nva_error_filename',nva_new_list_id='$nva_new_list_id',nva_new_phone_code='$nva_new_phone_code',nva_new_status='$nva_new_status',webphone_dialbox='$webphone_dialbox',webphone_mute='$webphone_mute',webphone_volume='$webphone_volume',webphone_debug='$webphone_debug',outbound_alt_cid='$outbound_alt_cid',conf_qualify='$conf_qualify',webphone_layout='" . mysqli_real_escape_string($link, $webphone_layout) . "',mohsuggest='$mohsuggest',webphone_settings='$webphone_settings' where extension='$old_extension' and server_ip='$old_server_ip';";
					$rslt=mysql_to_mysqli($stmt, $link);

					$stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';";
					$rslt=mysql_to_mysqli($stmtA, $link);

					$stmtB="UPDATE servers SET rebuild_conf_files='Y',sounds_update='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$SSactive_voicemail_server';";
					$rslt=mysql_to_mysqli($stmtB, $link);

					if ($server_ip != $old_server_ip)
						{
						$stmtC="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$old_server_ip';";
						$rslt=mysql_to_mysqli($stmtC, $link);
						}

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$stmt|$stmtA|$stmtB|$stmtC|";
					$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='PHONES', event_type='MODIFY', record_id='$extension', event_code='ADMIN MODIFY PHONE', event_sql=\"$SQL_log\", event_notes='Server IP: $server_ip   Old Server IP: $old_server_ip';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=31111111111;	# go to phone modification form below
	}


######################
# ADD=42111111111 modify phone alias record in the system
######################
if ($ADD==42111111111)
	{
	if ( ($LOGast_admin_access==1) or ($LOGmodify_phones==1) )
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT count(*) from phones_alias where alias_id='$alias_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ( (strlen($alias_id) < 1) or (strlen($alias_name) < 2) )
			{echo "<br>"._QXZ("PHONE ALIAS NOT MODIFIED - Please go back and look at the data you entered")."\n";}
		else
			{
			echo "<br>"._QXZ("PHONE ALIAS MODIFIED").": $alias_id\n";

			$stmt="UPDATE phones_alias set alias_name='$alias_name', logins_list='$logins_list', user_group='$user_group' where alias_id='$alias_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='PHONEALIASES', event_type='MODIFY', record_id='$alias_id', event_code='ADMIN MODIFY PHONE ALIAS', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=32111111111;	# go to phone alias modification form below
	}


######################
# ADD=43111111111 modify group alias record in the system
######################
if ($ADD==43111111111)
	{
	if ( ($LOGast_admin_access==1) or ($LOGmodify_phones==1) )
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT count(*) from groups_alias where group_alias_id='$group_alias_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ( (strlen($group_alias_id) < 1) or (strlen($group_alias_name) < 2) )
			{echo "<br>"._QXZ("GROUP ALIAS NOT MODIFIED - Please go back and look at the data you entered")."\n";}
		else
			{
			echo "<br>"._QXZ("GROUP ALIAS MODIFIED").": $alias_id\n";

			$stmt="UPDATE groups_alias set group_alias_name='$group_alias_name', caller_id_number='$caller_id_number', caller_id_name='$caller_id_name', active='$active',user_group='$user_group' where group_alias_id='$group_alias_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='GROUPALIASES', event_type='MODIFY', record_id='$group_alias_id', event_code='ADMIN MODIFY GROUP ALIAS', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=33111111111;	# go to group alias modification form below
	}


######################
# ADD=411111111111 modify server record in the system
######################
if ($ADD==411111111111)
	{
	if ($LOGmodify_servers==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT count(*) from servers where server_id='$server_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ( ($row[0] > 0) and ($server_id != $old_server_id) )
			{echo "<br>"._QXZ("SERVER NOT MODIFIED - there is already a server in the system with this")." server_id\n";}
		else
			{
			$stmt="SELECT count(*) from servers where server_ip='$server_ip';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ( ($row[0] > 0) and ($server_ip != $old_server_ip) )
				{echo "<br>"._QXZ("SERVER NOT MODIFIED - there is already a server in the system with this")." server_ip\n";}
			else
				{
				if ( (strlen($server_id) < 1) or (strlen($server_ip) < 7) or ( ($SSrequire_password_length > 0) and ($SSrequire_password_length > strlen($conf_secret)) ) )
					{
					echo "<br>"._QXZ("SERVER NOT MODIFIED - Please go back and look at the data you entered")."\n";
					if ($SSrequire_password_length > 0)
						{
						echo "<br>"._QXZ("Conf File Secret must be at least $SSrequire_password_length characters long")."\n";
						}
					}
				else
					{
					if (preg_match("/_MXCS/",$SShosted_settings))
						{
						$maxcps_set = $SShosted_settings;
						$maxcps_set = preg_replace("/MXAG\d+|_BUILD_|DRA|_MXTR\d+|.*_MXCS| /",'',$maxcps_set);
						$maxcps_set = preg_replace('/[^0-9]/','',$maxcps_set);
						if (strlen($maxcps_set)>0)
							{
							if ($outbound_calls_per_second > $maxcps_set)
								{
								if ($DB > 0) {echo "MAX CPS: |$outbound_calls_per_second|$maxcps_set|\n";}
								$outbound_calls_per_second = $maxcps_set;
								}
							}
						}
					if (preg_match("/_MXTR/",$SShosted_settings))
						{
						$maxtrunk_set = $SShosted_settings;
						$maxtrunk_set = preg_replace("/MXAG\d+|_BUILD_|DRA|_MXCS\d+|.*_MXTR| /",'',$maxtrunk_set);
						$maxtrunk_set = preg_replace('/[^0-9]/','',$maxtrunk_set);
						if (strlen($maxtrunk_set)>0)
							{
							if ($max_vicidial_trunks > $maxtrunk_set)
								{
								if ($DB > 0) {echo "MAX TRUNK: |$max_vicidial_trunks|$maxtrunk_set|\n";}
								$max_vicidial_trunks = $maxtrunk_set;
								}
							}
						}
					$custom_dialplanSQL='';
					if ($LOGmodify_custom_dialplans > 0)
						{$custom_dialplanSQL = ",custom_dialplan_entry='$custom_dialplan_entry'";}
					$stmt="UPDATE servers set server_id='$server_id',server_description='$server_description',server_ip='$server_ip',active='$active',asterisk_version='$asterisk_version', max_vicidial_trunks='$max_vicidial_trunks', telnet_host='$telnet_host', telnet_port='$telnet_port', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', ASTmgrUSERNAMEupdate='$ASTmgrUSERNAMEupdate', ASTmgrUSERNAMElisten='$ASTmgrUSERNAMElisten', ASTmgrUSERNAMEsend='$ASTmgrUSERNAMEsend', local_gmt='$local_gmt', voicemail_dump_exten='$voicemail_dump_exten', answer_transfer_agent='$answer_transfer_agent', ext_context='$ext_context', sys_perf_log='$sys_perf_log', vd_server_logs='$vd_server_logs', agi_output='$agi_output', vicidial_balance_active='$vicidial_balance_active',balance_trunks_offlimits='$balance_trunks_offlimits',recording_web_link='$recording_web_link',alt_server_ip='$alt_server_ip',active_asterisk_server='$active_asterisk_server',generate_vicidial_conf='$generate_vicidial_conf',rebuild_conf_files='$rebuild_conf_files',outbound_calls_per_second='$outbound_calls_per_second',sounds_update='$sounds_update',vicidial_recording_limit='$vicidial_recording_limit',carrier_logging_active='$carrier_logging_active',vicidial_balance_rank='$vicidial_balance_rank',rebuild_music_on_hold='$rebuild_music_on_hold',active_agent_login_server='$active_agent_login_server',conf_secret='$conf_secret',external_server_ip='$external_server_ip',active_twin_server_ip='$active_twin_server_ip',user_group='$user_group',auto_restart_asterisk='$auto_restart_asterisk',asterisk_temp_no_restart='$asterisk_temp_no_restart',voicemail_dump_exten_no_inst='$voicemail_dump_exten_no_inst',gather_asterisk_output='$gather_asterisk_output',conf_qualify='$conf_qualify',web_socket_url='" . mysqli_real_escape_string($link, $web_socket_url) . "',routing_prefix='$routing_prefix',external_web_socket_url='" . mysqli_real_escape_string($link, $external_web_socket_url) . "',conf_engine='$conf_engine',conf_update_interval='$conf_update_interval',ara_url='" . mysqli_real_escape_string($link, $ara_url) . "'$custom_dialplanSQL where server_id='$old_server_id';";
					$rslt=mysql_to_mysqli($stmt, $link);

					$stmtA="UPDATE servers SET rebuild_conf_files='Y',rebuild_music_on_hold='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y';";
					$rslt=mysql_to_mysqli($stmtA, $link);

					echo "<br>"._QXZ("SERVER MODIFIED").": $server_ip\n";

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$stmt|$stmtA|";
					$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='SERVERS', event_type='MODIFY', record_id='$server_id', event_code='ADMIN MODIFY SERVER', event_sql=\"$SQL_log\", event_notes='';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=311111111111;	# go to server modification form below
	}


######################
# ADD=421111111111 modify vicidial server trunks record in the system
######################
if ($ADD==421111111111)
	{
	if ($LOGmodify_servers==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT max_vicidial_trunks from servers where server_ip='$server_ip';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$rowx=mysqli_fetch_row($rslt);
		$MAXvicidial_trunks = $rowx[0];
		
		$stmt="SELECT sum(dedicated_trunks) from vicidial_server_trunks where server_ip='$server_ip' and campaign_id !='$campaign_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$rowx=mysqli_fetch_row($rslt);
		$SUMvicidial_trunks = ($rowx[0] + $dedicated_trunks);
		
		if ($SUMvicidial_trunks > $MAXvicidial_trunks)
			{
			echo "<br>"._QXZ("SERVER TRUNK RECORD NOT ADDED - the number of trunks is too high").": $SUMvicidial_trunks / $MAXvicidial_trunks\n";
			}
		else
			{
			if ( (strlen($campaign_id) < 2) or (strlen($server_ip) < 7) or (strlen($dedicated_trunks) < 1) or (strlen($trunk_restriction) < 1) )
				{
				echo "<br>"._QXZ("SERVER TRUNK RECORD NOT MODIFIED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("campaign must be between 3 and 8 characters in length")."\n";
				echo "<br>server_ip "._QXZ("delay must be at least 7 characters")."\n";
				echo "<br>"._QXZ("trunks must be a digit from 0 to 9999")."\n";
				}
			else
				{
				$stmt="UPDATE vicidial_server_trunks SET dedicated_trunks='$dedicated_trunks',trunk_restriction='$trunk_restriction' where campaign_id='$campaign_id' and server_ip='$server_ip';";
				$rslt=mysql_to_mysqli($stmt, $link);

				echo "<br><B>"._QXZ("SERVER TRUNK RECORD MODIFIED").": $campaign_id - $server_ip - $dedicated_trunks - $trunk_restriction</B>\n";

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='SERVERTRUNKS', event_type='MODIFY', record_id='$server_ip', event_code='ADMIN MODIFY SERVER TRUNK', event_sql=\"$SQL_log\", event_notes='Campaign: $campaign_id';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=311111111111;	# go to server modification form below
	}


######################
# ADD=431111111111 modify conf template record in the system
###################### '$template_id','$template_name','$template_contents'

if ($ADD==431111111111)
	{
	if ($LOGmodify_servers==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($template_id) < 1) or (strlen($template_name) < 1) )
			{echo "<br>"._QXZ("CONF TEMPLATE NOT MODIFIED - Please go back and look at the data you entered")."\n";}
		else
			{
			$stmt="UPDATE vicidial_conf_templates set template_name='$template_name',template_contents='$template_contents',user_group='$user_group' where template_id='$template_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			$stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and user_group='$user_group';";
			$rslt=mysql_to_mysqli($stmtA, $link);

			echo "<br>"._QXZ("CONF TEMPLATE MODIFIED").": $template_id\n";

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmtA|";
			$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='CONFTEMPLATES', event_type='MODIFY', record_id='$template_id', event_code='ADMIN MODIFY CONF TEMPLATE', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=331111111111;	# go to conf template modification form below
	}


######################
# ADD=441111111111 modify carrier record in the system
######################
if ($ADD==441111111111)
	{
	if ( ($LOGmodify_servers==1) or ($LOGmodify_carriers==1) )
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($carrier_id) < 1) or (strlen($server_ip) < 7) or (strlen($protocol) < 1) )
			{echo "<br>"._QXZ("CARRIER NOT MODIFIED - Please go back and look at the data you entered")."\n";}
		else
			{
			$stmt="UPDATE vicidial_server_carriers set carrier_name='$carrier_name',registration_string='$registration_string',template_id='$template_id',account_entry='$account_entry',protocol='$protocol',globals_string='$globals_string',dialplan_entry='$dialplan_entry',server_ip='$server_ip',active='$active',carrier_description='$carrier_description',user_group='$user_group' where carrier_id='$carrier_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			$stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';";
			if ($server_ip == '0.0.0.0')
				{$stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y';";}
			$rslt=mysql_to_mysqli($stmtA, $link);

			echo "<br>"._QXZ("CARRIER MODIFIED").": $carrier_id\n";

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmtA|";
			$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='CARRIERS', event_type='MODIFY', record_id='$carrier_id', event_code='ADMIN MODIFY CARRIER', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=341111111111;	# go to carrier modification form below
	}


######################
# ADD=451111111111 modify tts record in the system
######################
if ($ADD==451111111111)
	{
	if ( ($LOGmodify_servers==1) or ($LOGmodify_tts==1) )
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($tts_id) < 2) or (strlen($tts_name) < 5) )
			{echo "<br>"._QXZ("TTS ENTRY NOT MODIFIED - Please go back and look at the data you entered")."\n";}
		else
			{
			$stmt="UPDATE vicidial_tts_prompts set tts_name='$tts_name',active='$active',tts_voice='$tts_voice',tts_text=\"$tts_text\",user_group='$user_group' where tts_id='$tts_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br>"._QXZ("TTS ENTRY MODIFIED").": $tts_id\n";

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='TTS', event_type='MODIFY', record_id='$tts_id', event_code='ADMIN MODIFY TTS', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=351111111111;	# go to tts entry modification form below
	}


######################
# ADD=461111111111 modify music on hold record in the system
######################
if ($ADD==461111111111)
	{
	if ( ($LOGmodify_servers==1) or ($LOGmodify_moh==1) )
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ($stage == "FILEDELETE")
			{
			if ( (strlen($moh_id) < 2) or (strlen($filename) < 1) or ($moh_id=='sounds') or ($moh_id=='agi-bin') or ($moh_id=='astdb') or ($moh_id=='keys') )
				{echo "<br>"._QXZ("MUSIC ON HOLD ENTRY NOT MODIFIED - Please go back and look at the data you entered")."\n";}
			else
				{
				$stmt="DELETE FROM vicidial_music_on_hold_files where moh_id='$moh_id' and filename='$filename';";
				$rslt=mysql_to_mysqli($stmt, $link);

				$stmtA="UPDATE servers SET rebuild_conf_files='Y',rebuild_music_on_hold='Y',sounds_update='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y';";
				$rslt=mysql_to_mysqli($stmtA, $link);

				echo "<br>"._QXZ("MUSIC ON HOLD ENTRY MODIFIED").": $moh_id - $filename\n";

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtA|";
				$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='MOH', event_type='MODIFY', record_id='$moh_id', event_code='ADMIN MODIFY MOH', event_sql=\"$SQL_log\", event_notes='FILE DELETE';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		else
			{
			if ( (strlen($moh_id) < 2) or (strlen($moh_name) < 5) or ($moh_id=='sounds') or ($moh_id=='agi-bin') or ($moh_id=='astdb') or ($moh_id=='keys') )
				{echo "<br>MUSIC ON HOLD ENTRY NOT MODIFIED - Please go back and look at the data you entered\n";}
			else
				{
				$stmt="UPDATE vicidial_music_on_hold set moh_name='$moh_name',active='$active',random='$random',user_group='$user_group' where moh_id='$moh_id';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$stmtLIST = $stmt;

				$mohfiles = $MT;
				$mohranks = $MT;

				$stmt="SELECT filename,rank from vicidial_music_on_hold_files where moh_id='$moh_id' order by rank;";
				$rsltx=mysql_to_mysqli($stmt, $link);
				$mohfiles_to_print = mysqli_num_rows($rsltx);
				$ranks = ($mohfiles_to_print + 1);
				$o=0;
				while ($mohfiles_to_print > $o)
					{
					$rowx=mysqli_fetch_row($rsltx);
					$mohfiles[$o] = $rowx[0];
					$mohranks[$o] = $rowx[1];
					$o++;
					}

				$o=0;
				while ($mohfiles_to_print > $o)
					{
					$new_rank=0;
					$Ffilename = $mohfiles[$o];
					if (isset($_GET[$Ffilename]))			{$new_rank=$_GET[$Ffilename];}
						elseif (isset($_POST[$Ffilename]))	{$new_rank=$_POST[$Ffilename];}
					$new_rank = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$new_rank);

					$stmt="UPDATE vicidial_music_on_hold_files set rank='$new_rank' where moh_id='$moh_id' and filename='$mohfiles[$o]';";
					$rslt=mysql_to_mysqli($stmt, $link);
					$stmtLIST .= "|$stmt";
					$o++;
					}

				if (strlen($filename) > 0)
					{
					$stmt="INSERT INTO vicidial_music_on_hold_files set filename='$filename',rank='$ranks',moh_id='$moh_id';";
					$rslt=mysql_to_mysqli($stmt, $link);
					$stmtLIST .= "|$stmt";
					}

				$stmtA="UPDATE servers SET rebuild_conf_files='Y',rebuild_music_on_hold='Y',sounds_update='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y';";
				$rslt=mysql_to_mysqli($stmtA, $link);

				echo "<br>"._QXZ("MUSIC ON HOLD ENTRY MODIFIED").": $moh_id\n";

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmtLIST|$stmtA|";
				$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='MOH', event_type='MODIFY', record_id='$moh_id', event_code='ADMIN MODIFY MOH', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=361111111111;	# go to music on hold entry modification form below
	}


######################
# ADD=497111111111 modify VM Message Group record in the system
######################
if ($ADD==497111111111)
	{
	if ($LOGmodify_statuses==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ($stage == "FILEDELETE")
			{
			if ( (strlen($leave_vm_message_group_id) < 2) or (strlen($audio_filename) < 1) or ($leave_vm_message_group_id=='sounds') or ($leave_vm_message_group_id=='agi-bin') or ($leave_vm_message_group_id=='astdb') or ($leave_vm_message_group_id=='keys') )
				{echo "<br>"._QXZ("VM MESSAGE GROUP ENTRY NOT MODIFIED - Please go back and look at the data you entered")."\n";}
			else
				{
				$stmt="DELETE FROM leave_vm_message_groups_entries where leave_vm_message_group_id='$leave_vm_message_group_id' and audio_filename='$audio_filename';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$affected_rowsA = mysqli_affected_rows($link);
				if ($DB > 0) {echo "|$affected_rowsA|$stmt|\n";}

				echo "<br>"._QXZ("VM MESSAGE GROUP ENTRY MODIFIED").": $leave_vm_message_group_id - $filename\n";

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtA|";
				$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='VMMGROUP', event_type='MODIFY', record_id='$leave_vm_message_group_id', event_code='ADMIN MODIFY VMM GROUP', event_sql=\"$SQL_log\", event_notes='FILE DELETE $affected_rowsA';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		else
			{
			if ( (strlen($leave_vm_message_group_id) < 2) or (strlen($leave_vm_message_group_notes) < 5) or ($leave_vm_message_group_id=='sounds') or ($leave_vm_message_group_id=='agi-bin') or ($leave_vm_message_group_id=='astdb') or ($leave_vm_message_group_id=='keys') )
				{echo "<br>VM MESSAGE GROUP ENTRY NOT MODIFIED - Please go back and look at the data you entered\n";}
			else
				{
				$stmt="UPDATE leave_vm_message_groups set leave_vm_message_group_notes='$leave_vm_message_group_notes',active='$active',user_group='$user_group' where leave_vm_message_group_id='$leave_vm_message_group_id';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$affected_rowsA = mysqli_affected_rows($link);
				if ($DB > 0) {echo "|$affected_rowsA|$stmt|\n";}
				$stmtLIST = $stmt;

				$vmmgfiles = $MT;
				$vmmgname = $MT;
				$vmmgrank = $MT;
				$vmmgstart = $MT;
				$vmmgend = $MT;

				$stmt="SELECT audio_filename,audio_name,rank,time_start,time_end from leave_vm_message_groups_entries where leave_vm_message_group_id='$leave_vm_message_group_id' order by rank;";
				$rsltx=mysql_to_mysqli($stmt, $link);
				$vmmgfiles_to_print = mysqli_num_rows($rsltx);
				$ranks = ($vmmgfiles_to_print + 1);
				$o=0;
				while ($vmmgfiles_to_print > $o)
					{
					$rowx=mysqli_fetch_row($rsltx);
					$vmmgfiles[$o] =	$rowx[0];
					$vmmgname[$o] =		$rowx[1];
					$vmmgrank[$o] =		$rowx[2];
					$vmmgstart[$o] =	$rowx[3];
					$vmmgend[$o] =		$rowx[4];
					$o++;
					}

				$o=0;
				while ($vmmgfiles_to_print > $o)
					{
					$new_rank=0;
					$Ffilename = $vmmgfiles[$o];
					$Ffilename_start = "TM_START_$vmmgfiles[$o]";
					$Ffilename_end = "TM_END_$vmmgfiles[$o]";
					$Ffilename_name = "DS_NAME_$vmmgfiles[$o]";
					if (isset($_GET[$Ffilename]))			{$new_rank=$_GET[$Ffilename];}
						elseif (isset($_POST[$Ffilename]))	{$new_rank=$_POST[$Ffilename];}
					if (isset($_GET[$Ffilename_start]))				{$new_start=$_GET[$Ffilename_start];}
						elseif (isset($_POST[$Ffilename_start]))	{$new_start=$_POST[$Ffilename_start];}
					if (isset($_GET[$Ffilename_end]))			{$new_end=$_GET[$Ffilename_end];}
						elseif (isset($_POST[$Ffilename_end]))	{$new_end=$_POST[$Ffilename_end];}
					if (isset($_GET[$Ffilename_name]))			{$new_name=$_GET[$Ffilename_name];}
						elseif (isset($_POST[$Ffilename_name]))	{$new_name=$_POST[$Ffilename_name];}
					$new_rank = preg_replace('/[^0-9]/','',$new_rank);
					$new_start = preg_replace('/[^0-9]/','',$new_start);
					$new_end = preg_replace('/[^0-9]/','',$new_end);
					if ($non_latin < 1)
						{
						$new_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$new_name);
						}
					else
						{
						$new_name = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$new_name);
						}

					$stmt="UPDATE leave_vm_message_groups_entries set rank='$new_rank',time_start='$new_start',time_end='$new_end',audio_name='$new_name' where leave_vm_message_group_id='$leave_vm_message_group_id' and audio_filename='$vmmgfiles[$o]';";
					$rslt=mysql_to_mysqli($stmt, $link);
					$affected_rowsB = mysqli_affected_rows($link);
					if ($DB > 0) {echo "|$affected_rowsB|$stmt|\n";}
					$stmtLIST .= "|$stmt";
					$o++;
					}

				if (strlen($audio_filename) > 0)
					{
					$stmt="INSERT INTO leave_vm_message_groups_entries set audio_filename='$audio_filename',rank='$ranks',leave_vm_message_group_id='$leave_vm_message_group_id',audio_name='$audio_name',time_start='$time_start',time_end='$time_end';";
					$rslt=mysql_to_mysqli($stmt, $link);
					$affected_rowsC = mysqli_affected_rows($link);
					if ($DB > 0) {echo "|$affected_rowsC|$stmt|\n";}
					$stmtLIST .= "|$stmt";
					}

				echo "<br>"._QXZ("VM MESSAGE GROUP ENTRY MODIFIED").": $leave_vm_message_group_id\n";

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmtLIST|$stmtA|";
				$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='VMMGROUP', event_type='MODIFY', record_id='$leave_vm_message_group_id', event_code='ADMIN MODIFY VMM GROUP', event_sql=\"$SQL_log\", event_notes='$affected_rowsA $affected_rowsB $affected_rowsC';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=397111111111;	# go to VM Message Group entry modification form below
	}


######################
# ADD=498111111111 modify Queue Group record in the system
######################
if ($ADD==498111111111)
	{
	if ($LOGmodify_statuses==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($queue_group) < 2) or (strlen($queue_group_name) < 5) )
			{echo "<br>QUEUE GROUP ENTRY NOT MODIFIED - Please go back and look at the data you entered\n";}
		else
			{
			$stmt="UPDATE vicidial_queue_groups set queue_group_name='$queue_group_name',active='$active',user_group='$user_group',included_inbound_groups='$qg_groups_value',included_campaigns='$qg_campaigns_value' where queue_group='$queue_group';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$affected_rowsA = mysqli_affected_rows($link);
			if ($DB > 0) {echo "|$affected_rowsA|$stmt|\n";}
			$stmtLIST = $stmt;


			echo "<br>"._QXZ("QUEUE GROUP ENTRY MODIFIED").": $queue_group\n";

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmtLIST|$stmtA|";
			$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='QUEUEGROUP', event_type='MODIFY', record_id='$queue_group', event_code='ADMIN MODIFY QUEUE GROUP', event_sql=\"$SQL_log\", event_notes='$affected_rowsA $affected_rowsB $affected_rowsC';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=398111111111;	# go to Queue Group entry modification form below
	}


######################
# ADD=471111111111 modify voicemail record in the system
######################
if ($ADD==471111111111)
	{
	if ( ($LOGmodify_servers==1) or ($LOGmodify_voicemail==1) )
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($voicemail_id) < 2) or (strlen($fullname) < 2) )
			{echo "<br>"._QXZ("VOICEMAIL BOX NOT MODIFIED - Please go back and look at the data you entered")."\n";}
		else
			{
			if ( ($voicemail_greeting == '') and (strlen($old_voicemail_greeting) > 0) )
				{$voicemail_greeting = '---DELETE---';}
			$stmtA="UPDATE vicidial_voicemail set fullname='$fullname',active='$active',pass='$pass',email='$email',delete_vm_after_email='$delete_vm_after_email',voicemail_timezone='$voicemail_timezone',voicemail_options='$voicemail_options',user_group='$user_group',voicemail_greeting='$voicemail_greeting',on_login_report='$show_vm_on_summary' where voicemail_id='$voicemail_id';";
			$rslt=mysql_to_mysqli($stmtA, $link);
			if ($DB) {echo "|$stmtA|";}

			$stmtB="SELECT active_voicemail_server from system_settings;";
			$rslt=mysql_to_mysqli($stmtB, $link);
			$row=mysqli_fetch_row($rslt);
			$active_voicemail_server = $row[0];

			$sounds_updateSQL='';
			if ($SSallow_voicemail_greeting > 0) {$sounds_updateSQL = ",sounds_update='Y'";}
			$stmtC="UPDATE servers SET rebuild_conf_files='Y'$sounds_updateSQL where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$active_voicemail_server';";
			$rslt=mysql_to_mysqli($stmtC, $link);

			echo "<br>"._QXZ("VOICEMAIL BOX MODIFIED").": $voicemail_id\n";

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmtA|$stmtB|$stmtC|";
			$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='VOICEMAIL', event_type='MODIFY', record_id='$voicemail_id', event_code='ADMIN MODIFY VOICEMAIL', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=371111111111;	# go to voicemail entry modification form below
	}


######################
# ADD=481111111111 modify screen label record in the system
######################
if ($ADD==481111111111)
	{
	if ( ($LOGmodify_servers==1) or ($LOGmodify_labels==1) )
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($label_id) < 2) or (strlen($label_name) < 2) )
			{echo "<br>"._QXZ("SCREEN LABEL NOT MODIFIED - Please go back and look at the data you entered")."\n";}
		else
			{
			$stmt="UPDATE vicidial_screen_labels set label_name='$label_name',active='$active',label_hide_field_logs='$label_hide_field_logs',label_title='$label_title',label_first_name='$label_first_name',label_middle_initial='$label_middle_initial',label_last_name='$label_last_name',label_address1='$label_address1',label_address2='$label_address2',label_address3='$label_address3',label_city='$label_city',label_state='$label_state',label_province='$label_province',label_postal_code='$label_postal_code',label_vendor_lead_code='$label_vendor_lead_code',label_gender='$label_gender',label_phone_number='$label_phone_number',label_phone_code='$label_phone_code',label_alt_phone='$label_alt_phone',label_security_phrase='$label_security_phrase',label_email='$label_email',label_comments='$label_comments',user_group='$user_group',label_lead_id='$label_lead_id',label_list_id='$label_list_id',label_entry_date='$label_entry_date',label_gmt_offset_now='$label_gmt_offset_now',label_source_id='$label_source_id',label_called_since_last_reset='$label_called_since_last_reset',label_status='$label_status',label_user='$label_user',label_date_of_birth='$label_date_of_birth',label_country_code='$label_country_code',label_last_local_call_time='$label_last_local_call_time',label_called_count='$label_called_count',label_rank='$label_rank',label_owner='$label_owner',label_entry_list_id='$label_entry_list_id' where label_id='$label_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br>"._QXZ("SCREEN LABEL MODIFIED").": $label_id\n";

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='LABEL', event_type='MODIFY', record_id='$label_id', event_code='ADMIN MODIFY LABEL', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=381111111111;	# go to screen label entry modification form below
	}


######################
# ADD=482111111111 modify screen colors record in the system
######################
if ($ADD==482111111111)
	{
	if ( ($LOGmodify_servers==1) or ($LOGmodify_colors==1) )
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($colors_id) < 2) or (strlen($colors_name) < 2) )
			{echo "<br>"._QXZ("SCREEN COLORS NOT MODIFIED - Please go back and look at the data you entered")."\n";}
		else
			{
			if ( (strlen($menu_background) > 6) or (strlen($menu_background) < 6) )
				{
				if (strlen($menu_background) > 6) {$menu_background = substr($menu_background,0,6);}
				while (strlen($menu_background) < 6) {$menu_background .= '0';}
				}
			if ( (strlen($frame_background) > 6) or (strlen($frame_background) < 6) )
				{
				if (strlen($frame_background) > 6) {$frame_background = substr($frame_background,0,6);}
				while (strlen($frame_background) < 6) {$frame_background .= '0';}
				}
			if ( (strlen($std_row1_background) > 6) or (strlen($std_row1_background) < 6) )
				{
				if (strlen($std_row1_background) > 6) {$std_row1_background = substr($std_row1_background,0,6);}
				while (strlen($std_row1_background) < 6) {$std_row1_background .= '0';}
				}
			if ( (strlen($std_row2_background) > 6) or (strlen($std_row2_background) < 6) )
				{
				if (strlen($std_row2_background) > 6) {$std_row2_background = substr($std_row2_background,0,6);}
				while (strlen($std_row2_background) < 6) {$std_row2_background .= '0';}
				}
			if ( (strlen($std_row3_background) > 6) or (strlen($std_row3_background) < 6) )
				{
				if (strlen($std_row3_background) > 6) {$std_row3_background = substr($std_row3_background,0,6);}
				while (strlen($std_row3_background) < 6) {$std_row3_background .= '0';}
				}
			if ( (strlen($std_row4_background) > 6) or (strlen($std_row4_background) < 6) )
				{
				if (strlen($std_row4_background) > 6) {$std_row4_background = substr($std_row4_background,0,6);}
				while (strlen($std_row4_background) < 6) {$std_row4_background .= '0';}
				}
			if ( (strlen($std_row5_background) > 6) or (strlen($std_row5_background) < 6) )
				{
				if (strlen($std_row5_background) > 6) {$std_row5_background = substr($std_row5_background,0,6);}
				while (strlen($std_row5_background) < 6) {$std_row5_background .= '0';}
				}
			if ( (strlen($alt_row1_background) > 6) or (strlen($alt_row1_background) < 6) )
				{
				if (strlen($alt_row1_background) > 6) {$alt_row1_background = substr($alt_row1_background,0,6);}
				while (strlen($alt_row1_background) < 6) {$alt_row1_background .= '0';}
				}
			if ( (strlen($alt_row2_background) > 6) or (strlen($alt_row2_background) < 6) )
				{
				if (strlen($alt_row2_background) > 6) {$alt_row2_background = substr($alt_row2_background,0,6);}
				while (strlen($alt_row2_background) < 6) {$alt_row2_background .= '0';}
				}
			if ( (strlen($alt_row3_background) > 6) or (strlen($alt_row3_background) < 6) )
				{
				if (strlen($alt_row3_background) > 6) {$alt_row3_background = substr($alt_row3_background,0,6);}
				while (strlen($alt_row3_background) < 6) {$alt_row3_background .= '0';}
				}
			if ( (strlen($button_color) > 6) or (strlen($button_color) < 6) )
				{
				if (strlen($button_color) > 6) {$button_color = substr($button_color,0,6);}
				while (strlen($button_color) < 6) {$button_color .= '0';}
				}

			$stmt="UPDATE vicidial_screen_colors set colors_name='$colors_name',active='$active',menu_background='$menu_background',frame_background='$frame_background',std_row1_background='$std_row1_background',std_row2_background='$std_row2_background',std_row3_background='$std_row3_background',std_row4_background='$std_row4_background',std_row5_background='$std_row5_background',alt_row1_background='$alt_row1_background',alt_row2_background='$alt_row2_background',alt_row3_background='$alt_row3_background',button_color='$button_color',user_group='$user_group',web_logo='$web_logo' where colors_id='$colors_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br>"._QXZ("SCREEN COLORS MODIFIED").": $colors_id\n";

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='COLORS', event_type='MODIFY', record_id='$colors_id', event_code='ADMIN MODIFY COLORS', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=382111111111;	# go to screen colors entry modification form below
	}


######################
# ADD=491111111111 modify contact record in the system
######################
if ($ADD==491111111111)
	{
	if ( ($LOGmodify_servers==1) or ($LOGmodify_contacts==1) )
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if (strlen($contact_id) < 1)
			{echo "<br>"._QXZ("CONTACT NOT MODIFIED - Please go back and look at the data you entered")."\n";}
		else
			{
			if ( (preg_match("/contact_information/",$SStables_use_alt_log_db)) and (strlen($SSalt_log_server_ip)>4) and (strlen($SSalt_log_dbname)>0) )
				{
				$linkALT=mysqli_connect("$SSalt_log_server_ip", "$SSalt_log_login", "$SSalt_log_pass", "$SSalt_log_dbname");
				if (!$linkALT) 
					{
					die('MySQL '._QXZ("connect ERROR").': ' . mysqli_connect_error());
					}
				}
			else
				{$linkALT = $link;}
			$stmt="UPDATE contact_information set first_name='$first_name',last_name='$last_name',office_num='$office_num',cell_num='$cell_num',other_num1='$other_num1',other_num2='$other_num2',bu_name='$bu_name',department='$department',group_name='$group_name',job_title='$job_title',location='$location' where contact_id='$contact_id';";
			$rslt=mysql_to_mysqli($stmt, $linkALT);

			echo "<br>"._QXZ("CONTACT MODIFIED").": $contact_id\n";

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='CONTACTS', event_type='MODIFY', record_id='$contact_id', event_code='ADMIN MODIFY CONTACT', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=391111111111;	# go to contact entry modification form below
	}


######################
# ADD=492111111111 modify settings container record in the system
######################
if ($ADD==492111111111)
	{
	if ($LOGmodify_servers==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($container_id) < 2) or (strlen($container_notes) < 2) )
			{echo "<br>"._QXZ("SETTINGS CONTAINER NOT MODIFIED - Please go back and look at the data you entered")."\n";}
		else
			{
			$container_entrySQL = ",container_entry='" . mysqli_real_escape_string($link, $container_entry) ."'";
			if ( ($container_type == 'READ_ONLY') or ($stage == 'READ_ONLY') )
				{$container_entrySQL = '';}
			$stmt="UPDATE vicidial_settings_containers set container_notes='$container_notes',container_type='$container_type',user_group='$user_group' $container_entrySQL where container_id='$container_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br>"._QXZ("SETTINGS CONTAINER MODIFIED").": $container_id\n";

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='CONTAINERS', event_type='MODIFY', record_id='$container_id', event_code='ADMIN MODIFY CONTAINER', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=392111111111;	# go to settings container entry modification form below
	}


######################
# ADD=493111111111 modify status group record in the system
######################
if ($ADD==493111111111)
	{
	if ($LOGmodify_statuses==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if (strlen($status_group_id) < 2)
			{echo "<br>"._QXZ("STATUS GROUP NOT MODIFIED - Please go back and look at the data you entered")."\n";}
		else
			{
			if ($stage == 'add')
				{
				if ($add_copy_disabled > 0)
					{
					echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
					}
				else
					{
					echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
					$stmt="SELECT count(*) from vicidial_campaign_statuses where campaign_id='$status_group_id' and status='$status_id';";
					$rslt=mysql_to_mysqli($stmt, $link);
					$row=mysqli_fetch_row($rslt);
					if ($row[0] > 0)
						{echo "<br>"._QXZ("STATUS GROUP STATUS NOT ADDED - there is already a status in the status group with this name")."\n";}
					else
						{
						$stmt="SELECT count(*) from vicidial_statuses where status='$status_id';";
						$rslt=mysql_to_mysqli($stmt, $link);
						$row=mysqli_fetch_row($rslt);
						if ($row[0] > 0)
							{echo "<br>"._QXZ("STATUS GROUP STATUS NOT ADDED - there is already a global-status in the system with this name")."\n";}
						else
							{
							if ( (strlen($status_group_id) < 2) or (strlen($status_id) < 1) or (strlen($status_name) < 2) )
								{
								echo "<br>"._QXZ("STATUS GROUP STATUS NOT ADDED - Please go back and look at the data you entered")."\n";
								echo "<br>"._QXZ("status must be between 1 and 8 characters in length")."\n";
								echo "<br>"._QXZ("status name must be between 2 and 30 characters in length")."\n";
								}
							else
								{
								echo "<br><B>"._QXZ("STATUS GROUP STATUS ADDED").": $status_group_id - $status_id</B>\n";

								$stmt="INSERT INTO vicidial_campaign_statuses (status,status_name,selectable,campaign_id,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable,scheduled_callback,completed,min_sec,max_sec,answering_machine) values('$status_id','$status_name','$selectable','$status_group_id','$human_answered','$category','$sale','$dnc','$customer_contact','$not_interested','$unworkable','$scheduled_callbacks','$completed','$min_sec','$max_sec','$answering_machine');";
								$rslt=mysql_to_mysqli($stmt, $link);

								$stmtB="UPDATE vicidial_status_groups set modify_stamp='$SQLdate' where status_group_id='$status_group_id';";
								$rslt=mysql_to_mysqli($stmtA, $link);

								### LOG INSERTION Admin Log Table ###
								$SQL_log = "$stmt|$stmtB|";
								$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='STATUSGROUPS', event_type='ADD', record_id='$status_group_id', event_code='ADMIN ADD STATUS GROUP STATUS', event_sql=\"$SQL_log\", event_notes='Status: $status_id';";
								if ($DB) {echo "|$stmt|\n";}
								$rslt=mysql_to_mysqli($stmt, $link);
								}
							}
						}
					}
				}
			elseif ($stage == 'delete')
				{
				echo "<br><B>"._QXZ("STATUS GROUP STATUS DELETED").": $status_group_id - $status</B>\n";

				$stmt="DELETE FROM vicidial_campaign_statuses where campaign_id='$status_group_id' and status='$status';";
				$rslt=mysql_to_mysqli($stmt, $link);

				$stmtB="UPDATE vicidial_status_groups set modify_stamp='$SQLdate' where status_group_id='$status_group_id';";
				$rslt=mysql_to_mysqli($stmtA, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtB|";
				$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='STATUSGROUPS', event_type='DELETE', record_id='$status_group_id', event_code='ADMIN DELETE STATUS GROUP STATUS', event_sql=\"$SQL_log\", event_notes='Status: $status';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			elseif ($stage == 'modify')
				{
				echo "<br><B>"._QXZ("STATUS GROUP STATUS MODIFIED").": $status_group_id - $status</B>\n";

				$stmt="UPDATE vicidial_campaign_statuses SET status_name='$status_name',selectable='$selectable',human_answered='$human_answered',category='$category',sale='$sale',dnc='$dnc',customer_contact='$customer_contact',not_interested='$not_interested',unworkable='$unworkable',scheduled_callback='$scheduled_callbacks',completed='$completed',min_sec='$min_sec',max_sec='$max_sec',answering_machine='$answering_machine' where campaign_id='$status_group_id' and status='$status';";
				$rslt=mysql_to_mysqli($stmt, $link);

				$stmtB="UPDATE vicidial_status_groups set modify_stamp='$SQLdate' where status_group_id='$status_group_id';";
				$rslt=mysql_to_mysqli($stmtA, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtB|";
				$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='STATUSGROUPS', event_type='MODIFY', record_id='$status_group_id', event_code='ADMIN MODIFY STATUS GROUP STATUS', event_sql=\"$SQL_log\", event_notes='Status: $status';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			else
				{
				if (strlen($status_group_notes) < 2)
					{echo "<br>"._QXZ("STATUS GROUP NOT MODIFIED - Please go back and look at the data you entered")."\n";}
				else
					{
					$stmt="UPDATE vicidial_status_groups set status_group_notes='$status_group_notes',user_group='$user_group' where status_group_id='$status_group_id';";
					$rslt=mysql_to_mysqli($stmt, $link);

					echo "<br>"._QXZ("STATUS GROUP MODIFIED").": $status_group_id\n";

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$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='STATUSGROUPS', event_type='MODIFY', record_id='$status_group_id', event_code='ADMIN MODIFY STATUS GROUP', event_sql=\"$SQL_log\", event_notes='';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=393111111111;	# go to status group entry modification form below
	}



######################
# ADD=494111111111 modify automated report record in the system
######################
if ($ADD==494111111111)
	{
	if ($LOGmodify_auto_reports==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($report_id) < 2) or (strlen($report_name) < 2) )
			{echo "<br>"._QXZ("AUTOMATED REPORT NOT MODIFIED - Please go back and look at the data you entered")."\n";}
		else
			{
			$p=0;
			$REPORT_weekdays='';
			if(!is_array($report_weekdays)) {$report_weekdays=array();}
			$report_weekdays_ct = count($report_weekdays);
			while ($p <= $report_weekdays_ct)
				{
				$REPORT_weekdays .= "$report_weekdays[$p]";
				$p++;
				}

			$stmt="UPDATE vicidial_automated_reports set report_name='$report_name',report_server='$report_server',report_times='$report_times',report_weekdays='$REPORT_weekdays',report_monthdays='$report_monthdays',report_destination='$report_destination',email_from='$email_from',email_to='$email_to',email_subject='$email_subject',ftp_server='$ftp_server',ftp_user='" . mysqli_real_escape_string($link, $ftp_user) ."',ftp_pass='" . mysqli_real_escape_string($link, $ftp_pass) ."',ftp_directory='$ftp_directory',report_url='" . mysqli_real_escape_string($link, $report_url) ."',run_now_trigger='$run_now_trigger',active='$active',user_group='$user_group',filename_override='$filename_override' where report_id='$report_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br>"._QXZ("AUTOMATED REPORT MODIFIED").": $report_id\n";

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|";
			$SQL_log = preg_replace("/;|\\\\/", '', $SQL_log);
			$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='AUTOREPORTS', event_type='MODIFY', record_id='$report_id', event_code='ADMIN MODIFY AUTO REPORT', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=394111111111;	# go to automated report entry modification form below
	}


######################
# ADD=496111111111 modify CID group record in the system
######################
if ($ADD==496111111111)
	{
	if ($LOGmodify_statuses==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if (strlen($cid_group_id) < 2)
			{echo "<br>"._QXZ("CID GROUP NOT MODIFIED - Please go back and look at the data you entered")."\n";}
		else
			{
			if ($stage == 'SKIP')
				{
				$stmt="SELECT count(*) from vicidial_campaign_cid_areacodes where campaign_id='$cid_group_id' and outbound_cid='$outbound_cid' and active='Y' and cid_description NOT IN('NOROTATE','NO-ROTATE','NO_ROTATE','INACTIVE','DONOTUSE') and cid_description NOT LIKE \"%NOROTATE%\";";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				if ($row[0] < 1)
					{echo "<br>"._QXZ("CID GROUP CID IS NOT ACTIVE - you cannot skip a CID that is not active")."<br>\n";}
				else
					{
					if ( (strlen($cid_group_id) < 2) or (strlen($outbound_cid) < 6) )
						{
						echo "<br>"._QXZ("CID GROUP CID NOT SKIPPED - Please go back and look at the data you entered")."<br>\n";
						if ($DB) {echo "|$cid_group_id|$outbound_cid|\n";}
						}
					else
						{
						### BEGIN set the next CID to active and the current one to inactive ###
						$outbound_cid_next='';
						$stmt="SELECT outbound_cid from vicidial_campaign_cid_areacodes where campaign_id='$cid_group_id' and outbound_cid!='$outbound_cid' and cid_description NOT IN('NOROTATE','NO-ROTATE','NO_ROTATE','INACTIVE','DONOTUSE') and cid_description NOT LIKE \"%NOROTATE%\" order by CAST(cid_description as SIGNED INTEGER) limit 1;";
						$rslt=mysql_to_mysqli($stmt, $link);
						$accids_to_print = mysqli_num_rows($rslt);
						if ($accids_to_print > 0) 
							{
							$rowx=mysqli_fetch_row($rslt);
							$outbound_cid_next =			$rowx[0];
							}

						if (strlen($outbound_cid_next) < 6) 
							{
							if ($DB) {echo "     skip CID Group rotate, next CID could not be found: $cid_group_id   ($stmt)\n";}
							}
						else
							{
							$stmtA="UPDATE vicidial_campaign_cid_areacodes SET cid_description='$dateint',active='Y' where campaign_id='$cid_group_id' and outbound_cid='$outbound_cid_next';";
							$rslt=mysql_to_mysqli($stmtA, $link);
							$affected_rowsA=mysqli_affected_rows($link);

							$stmtB="UPDATE vicidial_cid_groups SET cid_auto_rotate_calls='0',cid_last_auto_rotate=NOW(),cid_auto_rotate_cid='$outbound_cid_next' where cid_group_id='$cid_group_id';";
							$rslt=mysql_to_mysqli($stmtB, $link);
							$affected_rowsB=mysqli_affected_rows($link);

							$stmtC="UPDATE vicidial_campaign_cid_areacodes SET cid_description='NOROTATE',active='N' where campaign_id='$cid_group_id' and outbound_cid='$outbound_cid';";
							$rslt=mysql_to_mysqli($stmtC, $link);
							$affected_rowsC=mysqli_affected_rows($link);
							### END set the next CID to active and the current one to inactive ###

							echo "<br><B>"._QXZ("CID GROUP CID SKIPPED").": $cid_group_id - $outbound_cid - "._QXZ("NEXT CID").": $outbound_cid_next</B><br>\n";

							### LOG INSERTION Admin Log Table ###
							$SQL_log = "$stmtA|$stmtB|$stmtC|";
							$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='CIDGROUPS', event_type='MODIFY', record_id='$cid_group_id', event_code='ADMIN SKIP CID GROUP ENTRY', event_sql=\"$SQL_log\", event_notes='CID: $outbound_cid - NEXT CID: $outbound_cid_next - affected rows: $affected_rowsA|$affected_rowsB|$affected_rowsC|';";
							if ($DB) {echo "|$stmt|\n";}
							$rslt=mysql_to_mysqli($stmt, $link);
							}
						}
					}
				}
			elseif ($stage == 'ADD')
				{
				$stmt="SELECT count(*) from vicidial_campaign_cid_areacodes where campaign_id='$cid_group_id' and areacode='$areacode' and outbound_cid='$outbound_cid';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				if ($row[0] > 0)
					{echo "<br>"._QXZ("CID GROUP CID NOT ADDED - there is already an entry for this group with this CID")."<br>\n";}
				else
					{
					if ( (strlen($cid_group_id) < 2) or (strlen($areacode) < 2) or (strlen($outbound_cid) < 6) )
						{
						echo "<br>"._QXZ("CID GROUP CID NOT ADDED - Please go back and look at the data you entered")."<br>\n";
						if ($DB) {echo "|$cid_group_id|$areacode|$outbound_cid|\n";}
						}
					else
						{
						echo "<br><B>"._QXZ("CID GROUP CID ADDED").": $cid_group_id - $areacode - $outbound_cid</B><br>\n";

						$stmt="INSERT INTO vicidial_campaign_cid_areacodes(campaign_id,areacode,outbound_cid,cid_description) values('$cid_group_id','$areacode','$outbound_cid','$cid_description');";
						$rslt=mysql_to_mysqli($stmt, $link);

						$stmtB="UPDATE vicidial_cid_groups set modify_stamp='$SQLdate' where cid_group_id='$cid_group_id';";
						$rslt=mysql_to_mysqli($stmtB, $link);

						### LOG INSERTION Admin Log Table ###
						$SQL_log = "$stmt|$stmtB|";
						$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='CIDGROUPS', event_type='ADD', record_id='$cid_group_id', event_code='ADMIN ADD CID GROUP ENTRY', event_sql=\"$SQL_log\", event_notes='CID: $areacode - $outbound_cid';";
						if ($DB) {echo "|$stmt|\n";}
						$rslt=mysql_to_mysqli($stmt, $link);
						}
					}
				}
			elseif ($stage == 'DELETE')
				{
				$not_allowed_campaigns_ct=0;
				$stmt="SELECT count(*) from vicidial_campaigns where cid_group_id='$cid_group_id' $notLOGallowed_campaignsSQL;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$accidsX_to_print = mysqli_num_rows($rslt);
				if ($accidsX_to_print > 0) 
					{
					$rowx=mysqli_fetch_row($rslt);
					$not_allowed_campaigns_ct = $rowx[0];
					}

				$stmt="SELECT count(*) from vicidial_campaign_cid_areacodes where campaign_id='$cid_group_id' and areacode='$areacode' and outbound_cid='$outbound_cid';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				if ( ($row[0] < 1) or ($not_allowed_campaigns_ct > 0) )
					{echo "<br>"._QXZ("CID GROUP CID NOT DELETED - this entry does not exist")."<br>\n";}
				else
					{
					if ( (strlen($cid_group_id) < 2) or (strlen($areacode) < 2) or (strlen($outbound_cid) < 6) )
						{
						echo "<br>"._QXZ("CID GROUP CID NOT DELETED - Please go back and look at the data you entered")."<br>\n";
						}
					else
						{
						echo "<br><B>"._QXZ("CID GROUP CID DELETED").": $cid_group_id - $areacode - $outbound_cid</B><br>\n";

						$stmt="DELETE FROM vicidial_campaign_cid_areacodes WHERE campaign_id='$cid_group_id' and areacode='$areacode' and outbound_cid='$outbound_cid';";
						$rslt=mysql_to_mysqli($stmt, $link);

						$stmtB="UPDATE vicidial_cid_groups set modify_stamp='$SQLdate' where cid_group_id='$cid_group_id';";
						$rslt=mysql_to_mysqli($stmtB, $link);

						### LOG INSERTION Admin Log Table ###
						$SQL_log = "$stmt|$stmtB|";
						$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='CIDGROUPS', event_type='DELETE', record_id='$cid_group_id', event_code='ADMIN DELETE CID GROUP ENTRY', event_sql=\"$SQL_log\", event_notes='CID: $areacode - $outbound_cid';";
						if ($DB) {echo "|$stmt|\n";}
						$rslt=mysql_to_mysqli($stmt, $link);
						}
					}
				}
			elseif ($stage == 'MODIFY')
				{
				$not_allowed_campaigns_ct=0;
				$stmt="SELECT count(*) from vicidial_campaigns where cid_group_id='$cid_group_id' $notLOGallowed_campaignsSQL;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$accidsX_to_print = mysqli_num_rows($rslt);
				if ($accidsX_to_print > 0) 
					{
					$rowx=mysqli_fetch_row($rslt);
					$not_allowed_campaigns_ct = $rowx[0];
					}

				if ($not_allowed_campaigns_ct > 0)
					{echo "<br>"._QXZ("CID GROUP CID NOT MODIFIED - this entry does not exist")."<br>\n";}
				else
					{
					$stmt="SELECT areacode,outbound_cid,active,cid_description,call_count_today from vicidial_campaign_cid_areacodes where campaign_id='$cid_group_id' order by areacode,outbound_cid";
					$rslt=mysql_to_mysqli($stmt, $link);
					$accids_to_print = mysqli_num_rows($rslt);
					$o=0;
					while ($accids_to_print > $o) 
						{
						$rowx=mysqli_fetch_row($rslt);
						$Xareacode[$o] =			$rowx[0];
						$Xoutbound_cid[$o] =		$rowx[1];
						$Xactive[$o] =				$rowx[2];
						$Xcid_description[$o] =		$rowx[3];
						$Xcall_count_today[$o] =	$rowx[4];
						$o++;
						}

					$accid_modified=0;
					$stmt_log='';
					$accid_log='';
					$o=0;
					while ($accids_to_print > $o) 
						{
						$Factive_value='';
						$Fcid_description_value='';
						$Factive = "active_$Xareacode[$o]_$Xoutbound_cid[$o]";
						$Fcid_description = "cid_description_$Xareacode[$o]_$Xoutbound_cid[$o]";

						if (isset($_GET[$Factive]))						{$Factive_value=$_GET[$Factive];}
							elseif (isset($_POST[$Factive]))			{$Factive_value=$_POST[$Factive];}
						if (isset($_GET[$Fcid_description]))			{$Fcid_description_value=$_GET[$Fcid_description];}
							elseif (isset($_POST[$Fcid_description]))	{$Fcid_description_value=$_POST[$Fcid_description];}
						if ($non_latin < 1)
							{
							$Fcid_description_value = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$Fcid_description_value);
							}
						else
							{
							$Fcid_description_value = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$Fcid_description_value);
							}
						$Factive_value = preg_replace('/[^A-Z]/','',$Factive_value);

					#	echo "$cid_group_id - $Xareacode[$o] - $Xoutbound_cid[$o] - $Factive($Factive_value|$Xactive[$o]) - $Fcid_description($Fcid_description_value|$Xcid_description[$o])<BR>";

						if ( ($Factive_value == $Xactive[$o]) and ($Fcid_description_value == $Xcid_description[$o]) )
							{
						#	echo "<br>AREACODE CID NOT MODIFIED - Please go back and look at the data you entered<br>\n";
							}
						else
							{
							$accid_modified++;
							echo "<B>"._QXZ("CID GROUP CID MODIFIED").": $Xareacode[$o] - $Xoutbound_cid[$o]</B><br>\n";

							$stmt="UPDATE vicidial_campaign_cid_areacodes SET active='$Factive_value',cid_description='$Fcid_description_value' WHERE campaign_id='$cid_group_id' and areacode='$Xareacode[$o]' and outbound_cid='$Xoutbound_cid[$o]';";
							$rslt=mysql_to_mysqli($stmt, $link);

							$stmtB="UPDATE vicidial_cid_groups set modify_stamp='$SQLdate' where cid_group_id='$cid_group_id';";
							$rslt=mysql_to_mysqli($stmtB, $link);

							$stmt_log .= "$stmt|$stmtB|";
							$accid_log .= "CID: $Xareacode[$o] - $Xoutbound_cid[$o] - $Factive_value - $Fcid_description_value|";
							}
						$o++;
						}
					if ($accid_modified > 0)
						{
						### LOG INSERTION Admin Log Table ###
						$SQL_log = "$stmt_log|";
						$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='CIDGROUPS', event_type='MODIFY', record_id='$cid_group_id', event_code='ADMIN MODIFY CID GROUP ENTRY', event_sql=\"$SQL_log\", event_notes='$accid_modified CIDs MODIFIED. CHANGES: $accid_log';";
						if ($DB) {echo "|$stmt|\n";}
						$rslt=mysql_to_mysqli($stmt, $link);
						}
					}
				}
			else
				{
				if (strlen($cid_group_notes) < 2)
					{echo "<br>"._QXZ("CID GROUP NOT MODIFIED - Please go back and look at the data you entered")."\n";}
				else
					{
					$stmt="UPDATE vicidial_cid_groups set cid_group_notes='$cid_group_notes',user_group='$user_group',cid_auto_rotate_minutes='$cid_auto_rotate_minutes',cid_auto_rotate_minimum='$cid_auto_rotate_minimum' where cid_group_id='$cid_group_id';";
					$rslt=mysql_to_mysqli($stmt, $link);

					echo "<br>"._QXZ("CID GROUP MODIFIED").": $cid_group_id\n";

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$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='CIDGROUPS', event_type='MODIFY', record_id='$cid_group_id', event_code='ADMIN MODIFY CID GROUP', event_sql=\"$SQL_log\", event_notes='';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=396111111111;	# go to CID group entry modification form below
	}


######################
# ADD=4111111111111 modify conference record in the system
######################
if ($ADD==4111111111111)
	{
	if ($LOGast_admin_access==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT count(*) from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ( ($row[0] > 0) and ( ($conf_exten != $old_conf_exten) or ($server_ip != $old_server_ip) ) )
			{echo "<br>"._QXZ("CONFERENCE NOT MODIFIED - there is already a Conference in the system with this extension-server")."\n";}
		else
			{
			if ( (strlen($conf_exten) < 1) or (strlen($server_ip) < 7) )
				{echo "<br>"._QXZ("CONFERENCE NOT MODIFIED - Please go back and look at the data you entered")."\n";}
			else
				{
				echo "<br>"._QXZ("CONFERENCE MODIFIED").": $conf_exten\n";

				$stmt="UPDATE conferences set conf_exten='$conf_exten',server_ip='$server_ip',extension='$extension' where conf_exten='$old_conf_exten' and server_ip='$server_ip';";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='CONF', event_type='MODIFY', record_id='$conf_exten', event_code='ADMIN MODIFY CONFERENCE', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=3111111111111;	# go to conference modification form below
	}


######################
# ADD=41111111111111 modify vicidial conference record in the system
######################
if ($ADD==41111111111111)
	{
	if ($LOGast_admin_access==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT count(*) from vicidial_conferences where conf_exten='$conf_exten' and server_ip='$server_ip';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ( ($row[0] > 0) and ( ($conf_exten != $old_conf_exten) or ($server_ip != $old_server_ip) ) )
			{echo "<br>"._QXZ("AGENT CONFERENCE NOT MODIFIED - there is already a Conference in the system with this extension-server")."\n";}
		else
			{
			if ( (strlen($conf_exten) < 1) or (strlen($server_ip) < 7) )
				{echo "<br>"._QXZ("AGENT CONFERENCE NOT MODIFIED - Please go back and look at the data you entered")."\n";}
			else
				{
				echo "<br>"._QXZ("AGENT CONFERENCE MODIFIED").": $conf_exten\n";

				$stmt="UPDATE vicidial_conferences set conf_exten='$conf_exten',extension='$extension' where conf_exten='$old_conf_exten' and server_ip='$server_ip';";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='VICICONF', event_type='MODIFY', record_id='$conf_exten', event_code='ADMIN MODIFY VICIDIAL CONFERENCE', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=31111111111111;	# go to vicidial conference modification form below
	}


######################
# ADD=42111111111111 modify vicidial confbridge record in the system
######################
if ($ADD==42111111111111)
	{
	if ($LOGast_admin_access==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT count(*) from vicidial_confbridges where conf_exten='$conf_exten' and server_ip='$server_ip';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ( ($row[0] > 0) and ( ($conf_exten != $old_conf_exten) or ($server_ip != $old_server_ip) ) )
			{echo "<br>"._QXZ("AGENT CONFBRIDGE NOT MODIFIED - there is already a Conference in the system with this extension-server")."\n";}
		else
			{
			if ( (strlen($conf_exten) < 1) or (strlen($server_ip) < 7) )
				{echo "<br>"._QXZ("AGENT CONFBRIDGE NOT MODIFIED - Please go back and look at the data you entered")."\n";}
			else
				{
				echo "<br>"._QXZ("AGENT CONFBRIDGE MODIFIED").": $conf_exten\n";

				$stmt="UPDATE vicidial_confbridges set conf_exten='$conf_exten',extension='$extension' where conf_exten='$old_conf_exten' and server_ip='$server_ip';";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='VICICONF', event_type='MODIFY', record_id='$conf_exten', event_code='ADMIN MODIFY VICIDIAL CONFBRIDGE', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=32111111111111;	# go to vicidial confbridge modification form below
	}


######################
# ADD=411111111111111 modify vicidial system settings
######################
if ($ADD==411111111111111)
	{
	if ($LOGmodify_servers==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( ($SSrequire_password_length > 0) and ( ($SSrequire_password_length > strlen($default_phone_registration_password)) or ( ($SSrequire_password_length > strlen($default_phone_login_password)) or ( ($SSrequire_password_length > strlen($default_server_password)) ) ) ) )
			{
			echo "<br>"._QXZ("SYSTEM SETTINGS NOT MODIFIED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("The default passwords must be at least $SSrequire_password_length characters long")."\n";
			}
		else
			{
			echo "<br>"._QXZ("SYSTEM SETTINGS MODIFIED")."\n";

			$k=0;
			if (is_array($reports_use_slave_db)) {$multi_count = count($reports_use_slave_db);} else {$multi_count=0;}
			$multi_array = $reports_use_slave_db;
			while ($k < $multi_count)
				{
				$new_field_value .= "$multi_array[$k],";
				$k++;
				}
			$new_field_value = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$new_field_value);
			$reports_use_slave_db = preg_replace("/,$/","",$new_field_value);

			$m=0;
			if (is_array($tables_use_alt_log_db)) {$altlog_count = count($tables_use_alt_log_db);} else {$altlog_count=0;}
			$altlog_array = $tables_use_alt_log_db;
			while ($m < $altlog_count)
				{
				$new_altlog_value .= "$altlog_array[$m],";
				$m++;
				}
			$new_altlog_value = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$new_altlog_value);
			$tables_use_alt_log_db = preg_replace("/,$/","",$new_altlog_value);

			$custom_dialplanSQL='';
			if ($LOGmodify_custom_dialplans > 0)
				{$custom_dialplanSQL = ",custom_dialplan_entry='$custom_dialplan_entry'";}

			$custom_stmt="show tables like 'vicidial_custom_reports'";
			$custom_rslt=mysql_to_mysqli($custom_stmt, $link);
			$custom_reports_slave_SQL='';
			if (mysqli_num_rows($custom_rslt)>0) 
				{
				if (is_array($custom_reports_use_slave_db)) 
					{
					for ($q=0; $q<count($custom_reports_use_slave_db); $q++) 
						{
						$custom_reports_slave_SQL.=$custom_reports_use_slave_db[$q].",";
						}
					}
				if (preg_match('/\-\-NONE\-\-/i', $custom_reports_slave_SQL))
					{
					$custom_reports_slave_SQL='';
					}
				$custom_reports_slave_SQL=substr($custom_reports_slave_SQL,0,-1);
				$custom_reports_slave_SQL = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$custom_reports_slave_SQL);
				$custom_reports_slave_SQL=",custom_reports_use_slave_db='$custom_reports_slave_SQL'";
				}
			$stmt="SELECT count(*) from servers where active='Y' and active_asterisk_server='Y';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			$active_asterisk_servers = $row[0];
			if ($row[0] < 1) {$row[0] = '1';}
			if (preg_match("/_MXCS/",$SShosted_settings))
				{
				$maxcps_set = $SShosted_settings;
				$maxcps_set = preg_replace("/MXAG\d+|_BUILD_|DRA|_MXTR\d+|.*_MXCS| /",'',$maxcps_set);
				$maxcps_set = preg_replace('/[^0-9]/','',$maxcps_set);
				$maxcps_set = ($maxcps_set * $row[0]);
				if (strlen($maxcps_set)>0)
					{
					if ($outbound_calls_per_second > $maxcps_set)
						{
						if ($DB > 0) {echo "MAX CPS: |$outbound_calls_per_second|$maxcps_set|\n";}
						$outbound_calls_per_second = $maxcps_set;
						}
					}
				}

			# update the apinewlead_url value for the system
			$stmtD="UPDATE vicidial_url_multi SET url_address='" . mysqli_real_escape_string($link, $apinewlead_url) . "' WHERE campaign_id='-SYSTEM-API-NEWLEAD-' and entry_type='system' and url_type='apinewlead';";
			$rslt=mysql_to_mysqli($stmtD, $link);
			$update_apinewlead_rows=mysqli_affected_rows($link);

			# update the system settings
			$stmt="UPDATE system_settings set use_non_latin='$use_non_latin',webroot_writable='$webroot_writable',enable_queuemetrics_logging='$enable_queuemetrics_logging',queuemetrics_server_ip='$queuemetrics_server_ip',queuemetrics_dbname='$queuemetrics_dbname',queuemetrics_login='$queuemetrics_login',queuemetrics_pass='$queuemetrics_pass',queuemetrics_url='" . mysqli_real_escape_string($link, $queuemetrics_url) . "',queuemetrics_log_id='$queuemetrics_log_id',queuemetrics_eq_prepend='$queuemetrics_eq_prepend',vicidial_agent_disable='$vicidial_agent_disable',allow_sipsak_messages='$allow_sipsak_messages',admin_home_url='" . mysqli_real_escape_string($link, $admin_home_url) . "',enable_agc_xfer_log='$enable_agc_xfer_log',timeclock_end_of_day='$timeclock_end_of_day',vdc_header_date_format='$vdc_header_date_format',vdc_customer_date_format='$vdc_customer_date_format',vdc_header_phone_format='$vdc_header_phone_format',vdc_agent_api_active='$vdc_agent_api_active',enable_vtiger_integration='$enable_vtiger_integration',vtiger_server_ip='$vtiger_server_ip',vtiger_dbname='$vtiger_dbname',vtiger_login='$vtiger_login',vtiger_pass='$vtiger_pass',vtiger_url='" . mysqli_real_escape_string($link, $vtiger_url) . "',qc_features_active='$qc_features_active',outbound_autodial_active='$outbound_autodial_active',outbound_calls_per_second='$outbound_calls_per_second',enable_tts_integration='$enable_tts_integration',agentonly_callback_campaign_lock='$agentonly_callback_campaign_lock',sounds_central_control_active='$sounds_central_control_active',sounds_web_server='$sounds_web_server',sounds_web_directory='$sounds_web_directory',active_voicemail_server='$active_voicemail_server',auto_dial_limit='$auto_dial_limit',user_territories_active='$user_territories_active',allow_custom_dialplan='$allow_custom_dialplan',enable_second_webform='$enable_second_webform',default_webphone='$default_webphone',default_external_server_ip='$default_external_server_ip',webphone_url='" . mysqli_real_escape_string($link, $webphone_url) . "',enable_agc_dispo_log='$enable_agc_dispo_log',queuemetrics_loginout='$queuemetrics_loginout',callcard_enabled='$callcard_enabled',queuemetrics_callstatus='$queuemetrics_callstatus',default_codecs='$default_codecs',admin_web_directory='$admin_web_directory',label_title='$label_title',label_first_name='$label_first_name',label_middle_initial='$label_middle_initial',label_last_name='$label_last_name',label_address1='$label_address1',label_address2='$label_address2',label_address3='$label_address3',label_city='$label_city',label_state='$label_state',label_province='$label_province',label_postal_code='$label_postal_code',label_vendor_lead_code='$label_vendor_lead_code',label_gender='$label_gender',label_phone_number='$label_phone_number',label_phone_code='$label_phone_code',label_alt_phone='$label_alt_phone',label_security_phrase='$label_security_phrase',label_email='$label_email',label_comments='$label_comments',label_lead_id='$label_lead_id',label_list_id='$label_list_id',label_entry_date='$label_entry_date',label_gmt_offset_now='$label_gmt_offset_now',label_source_id='$label_source_id',label_called_since_last_reset='$label_called_since_last_reset',label_status='$label_status',label_user='$label_user',label_date_of_birth='$label_date_of_birth',label_country_code='$label_country_code',label_last_local_call_time='$label_last_local_call_time',label_called_count='$label_called_count',label_rank='$label_rank',label_owner='$label_owner',label_entry_list_id='$label_entry_list_id',custom_fields_enabled='$custom_fields_enabled',slave_db_server='$slave_db_server',reports_use_slave_db='$reports_use_slave_db'$custom_reports_slave_SQL,webphone_systemkey='$webphone_systemkey',first_login_trigger='$first_login_trigger',default_phone_registration_password='$default_phone_registration_password',default_phone_login_password='$default_phone_login_password',default_server_password='$default_server_password',admin_modify_refresh='$admin_modify_refresh',nocache_admin='$nocache_admin',generate_cross_server_exten='$generate_cross_server_exten',queuemetrics_addmember_enabled='$queuemetrics_addmember_enabled',queuemetrics_dispo_pause='$queuemetrics_dispo_pause',label_hide_field_logs='$label_hide_field_logs',queuemetrics_pe_phone_append='$queuemetrics_pe_phone_append',test_campaign_calls='$test_campaign_calls',agents_calls_reset='$agents_calls_reset',default_voicemail_timezone='$default_voicemail_timezone',default_local_gmt='$default_local_gmt',noanswer_log='$noanswer_log',alt_log_server_ip='$alt_log_server_ip',alt_log_dbname='$alt_log_dbname',alt_log_login='$alt_log_login',alt_log_pass='$alt_log_pass',tables_use_alt_log_db='$tables_use_alt_log_db',did_agent_log='$did_agent_log',campaign_cid_areacodes_enabled='$campaign_cid_areacodes_enabled',pllb_grouping_limit='$pllb_grouping_limit',did_ra_extensions_enabled='$did_ra_extensions_enabled',expanded_list_stats='$expanded_list_stats',contacts_enabled='$contacts_enabled',call_menu_qualify_enabled='$call_menu_qualify_enabled',admin_list_counts='$admin_list_counts',allow_voicemail_greeting='$allow_voicemail_greeting',queuemetrics_socket='$queuemetrics_socket',queuemetrics_socket_url='$queuemetrics_socket_url',enhanced_disconnect_logging='$enhanced_disconnect_logging',allow_emails='$allow_emails',level_8_disable_add='$level_8_disable_add',queuemetrics_record_hold='$queuemetrics_record_hold',country_code_list_stats='$country_code_list_stats',queuemetrics_pause_type='$queuemetrics_pause_type',frozen_server_call_clear='$frozen_server_call_clear',callback_time_24hour='$callback_time_24hour',enable_languages='$enable_languages',language_method='$language_method',meetme_enter_login_filename='$meetme_enter_login_filename',meetme_enter_leave3way_filename='$meetme_enter_leave3way_filename',enable_did_entry_list_id='$enable_did_entry_list_id',enable_third_webform='$enable_third_webform',allow_chats='$allow_chats',chat_url='" . mysqli_real_escape_string($link, $chat_url) . "',chat_timeout='$chat_timeout',agent_debug_logging='$agent_debug_logging',default_language='$default_language',agent_whisper_enabled='$agent_whisper_enabled',user_hide_realtime_enabled='$user_hide_realtime_enabled',usacan_phone_dialcode_fix='$usacan_phone_dialcode_fix',cache_carrier_stats_realtime='$cache_carrier_stats_realtime',log_recording_access='$log_recording_access',report_default_format='$report_default_format',alt_ivr_logging='$alt_ivr_logging',default_phone_code='$default_phone_code',admin_row_click='$admin_row_click',admin_screen_colors='$admin_screen_colors',ofcom_uk_drop_calc='$ofcom_uk_drop_calc',agent_screen_colors='$agent_screen_colors',script_remove_js='$script_remove_js',manual_auto_next='$manual_auto_next',user_new_lead_limit='$user_new_lead_limit',agent_xfer_park_3way='$agent_xfer_park_3way',agent_soundboards='$agent_soundboards',web_loader_phone_length='$web_loader_phone_length',agent_script='$agent_script',agent_chat_screen_colors='$agent_chat_screen_colors',enable_auto_reports='$enable_auto_reports',enable_pause_code_limits='$enable_pause_code_limits',enable_drop_lists='$enable_drop_lists',allow_ip_lists='$allow_ip_lists',system_ip_blacklist='$system_ip_blacklist',agent_push_events='$agent_push_events',agent_push_url='$agent_push_url',hide_inactive_lists='$hide_inactive_lists',allow_manage_active_lists='$allow_manage_active_lists',expired_lists_inactive='$expired_lists_inactive',did_system_filter='$did_system_filter',anyone_callback_inactive_lists='$anyone_callback_inactive_lists',enable_gdpr_download_deletion='$enable_gdpr_download_deletion',source_id_display='$source_id_display',agent_logout_link='$agent_logout_link',manual_dial_validation='$manual_dial_validation',mute_recordings='$mute_recordings',user_admin_redirect='$user_admin_redirect',list_status_modification_confirmation='$list_status_modification_confirmation',sip_event_logging='$sip_event_logging',call_quota_lead_ranking='$call_quota_lead_ranking',enable_second_script='$enable_second_script',enable_first_webform='$enable_first_webform',recording_buttons='$recording_buttons',opensips_cid_name='$opensips_cid_name',require_password_length='$require_password_length',user_account_emails='$user_account_emails',outbound_cid_any='$outbound_cid_any',entries_per_page='$entries_per_page',browser_call_alerts='$browser_call_alerts',queuemetrics_pausereason='$queuemetrics_pausereason',inbound_answer_config='$inbound_answer_config',enable_international_dncs='$enable_international_dncs',web_loader_phone_strip='$web_loader_phone_strip',manual_dial_phone_strip='$manual_dial_phone_strip',daily_call_count_limit='$daily_call_count_limit',allow_shared_dial='$allow_shared_dial',agent_search_method='$agent_search_method',phone_defaults_container='$phone_defaults_container',qc_claim_limit='$qc_claim_limit',qc_expire_days='$qc_expire_days',two_factor_auth_hours='$two_factor_auth_hours',two_factor_container='$two_factor_container',agent_hidden_sound='$agent_hidden_sound',agent_hidden_sound_volume='$agent_hidden_sound_volume',agent_hidden_sound_seconds='$agent_hidden_sound_seconds',agent_screen_timer='$agent_screen_timer',call_limit_24hour='$call_limit_24hour',allowed_sip_stacks='$allowed_sip_stacks',agent_hide_hangup='$agent_hide_hangup',allow_web_debug='$allow_web_debug',max_logged_in_agents='$max_logged_in_agents',user_codes_admin='$user_codes_admin',login_kickall='$login_kickall',abandon_check_queue='$abandon_check_queue',agent_notifications='$agent_notifications',demographic_quotas='$demographic_quotas',log_latency_gaps='$log_latency_gaps',inbound_credits='$inbound_credits',weekday_resets='$weekday_resets',two_factor_auth_agent_hours='$two_factor_auth_agent_hours',hopper_hold_inserts='$hopper_hold_inserts',coldstorage_server_ip='$coldstorage_server_ip',coldstorage_dbname='$coldstorage_dbname',coldstorage_login='$coldstorage_login',coldstorage_pass='$coldstorage_pass',coldstorage_port='$coldstorage_port',enhanced_agent_monitoring='$enhanced_agent_monitoring',agent_hide_dial_fail='$agent_hide_dial_fail',agent_man_dial_filter='$agent_man_dial_filter',agent_3way_dial_filter='$agent_3way_dial_filter',stereo_recording='$stereo_recording',recording_dtmf_detection='$recording_dtmf_detection',recording_dtmf_muting='$recording_dtmf_muting',stereo_parallel_recording='$stereo_parallel_recording'$custom_dialplanSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$update_main_rows=mysqli_affected_rows($link);
			if ($DB) {echo "$update_main_rows|$stmt|\n";}
			$event_notes="Updated: $update_main_rows|";

			if ( ($meetme_enter_login_filename != $SSmeetme_enter_login_filename) or ($meetme_enter_leave3way_filename != $SSmeetme_enter_leave3way_filename) )
				{$reload_dialplan_on_servers=1;}

			if ($reload_dialplan_on_servers > 0)
				{
				$stmtB="UPDATE system_settings set reload_timestamp=NOW();";
				$rslt=mysql_to_mysqli($stmtB, $link);

				$stmtC="UPDATE servers set rebuild_conf_files='Y' where active='Y' and active_asterisk_server='Y' and generate_vicidial_conf='Y';";
				$rslt=mysql_to_mysqli($stmtC, $link);
				}

			$update_gdpr_users_stmt="update vicidial_users set export_gdpr_leads='$enable_gdpr_download_deletion' where export_gdpr_leads>$enable_gdpr_download_deletion";
			$update_gdpr_users_rslt=mysql_to_mysqli($update_gdpr_users_stmt, $link);
			$update_gdpr_rows=mysqli_affected_rows($link);
			if ($update_gdpr_rows>0) 
				{
				$event_notes.="   $update_gdpr_rows "._QXZ("GDPR-enabled users downgraded due to setting change");
				}

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmtB|$stmtC|$stmtD|";
			$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='SYSTEMSETTINGS', event_type='MODIFY', record_id='system_settings', event_code='ADMIN MODIFY SYSTEM SETTINGS', event_sql=\"$SQL_log\", event_notes='$event_notes|$update_apinewlead_rows';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=311111111111111;	# go to vicidial system settings form below
	}


######################
# ADD=421111111111111 modify/delete system status in the system
######################
if ($ADD==421111111111111)
	{
	if ( ($LOGmodify_servers==1) or ($LOGmodify_statuses==1) )
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if (preg_match('/delete/',$stage))
			{
			if ( (strlen($status) < 1) or (preg_match("/^B$|^NA$|^DNC$|^NA$|^DROP$|^INCALL$|^QUEUE$|^NEW$/i",$status)) )
				{
				echo "<br>"._QXZ("SYSTEM STATUS NOT DELETED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("the system status cannot be a reserved status").": B,NA,DNC,NA,DROP,INCALL,QUEUE,NEW\n";
				echo "<br>"._QXZ("the system status needs to be at least 1 characters in length")."\n";
				}
			else
				{
				echo "<br><B>"._QXZ("SYSTEM STATUS DELETED").": $status</B>\n";

				$stmt="DELETE FROM vicidial_statuses where status='$status';";
				$rslt=mysql_to_mysqli($stmt, $link);

				$stmtA="DELETE FROM vicidial_campaign_hotkeys where status='$status';";
				$rslt=mysql_to_mysqli($stmtA, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtA|";
				$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='SYSTEMSTATUSES', event_type='DELETE', record_id='$status', event_code='ADMIN DELETE SYSTEM STATUS', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		if (preg_match('/modify/', $stage))
			{
			if ( (strlen($status) < 1) or (strlen($status_name) < 2) )
				{
				echo "<br>"._QXZ("SYSTEM STATUS NOT MODIFIED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("the system status needs to be at least 1 characters in length")."\n";
				echo "<br>"._QXZ("the system status name needs to be at least 1 characters in length")."\n";
				}
			else
				{
				echo "<br><B>"._QXZ("SYSTEM STATUS MODIFIED").": $status</B>\n";

				$stmt="UPDATE vicidial_statuses SET status_name='$status_name',selectable='$selectable',human_answered='$human_answered',category='$category',sale='$sale',dnc='$dnc',customer_contact='$customer_contact',not_interested='$not_interested',unworkable='$unworkable',scheduled_callback='$scheduled_callbacks',completed='$completed',min_sec='$min_sec',max_sec='$max_sec',answering_machine='$answering_machine' where status='$status';";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='SYSTEMSTATUSES', event_type='MODIFY', record_id='$status', event_code='ADMIN MODIFY SYSTEM STATUS', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=321111111111111;	# go to system settings modification form below
	}


######################
# ADD=431111111111111 modify/delete status category in the system
######################
if ($ADD==431111111111111)
	{
	if ( ($LOGmodify_servers==1) or ($LOGmodify_statuses==1) )
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($vsc_id) < 2)  or (preg_match("/^UNDEFINED$/i",$vsc_id)) )
			{
			echo "<br>"._QXZ("STATUS CATEGORY NOT MODIFIED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("the status category cannot be a reserved category").": UNDEFINED\n";
			echo "<br>"._QXZ("the status category needs to be at least 2 characters in length")."\n";
			}
		else
			{
			if (preg_match('/delete/',$stage))
				{
				echo "<br><B>"._QXZ("STATUS CATEGORY DELETED").": $vsc_id</B>\n";

				$stmt="DELETE FROM vicidial_status_categories where vsc_id='$vsc_id';";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='STATUSCATEGORIES', event_type='DELETE', record_id='$vsc_id', event_code='ADMIN DELETE STATUS CATEGORY', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			if (preg_match('/modify/', $stage))
				{
				echo "<br><B>"._QXZ("STATUS CATEGORY MODIFIED").": $vsc_id</B>\n";

				$stmt="SELECT count(*) from vicidial_status_categories where tovdad_display='Y' and vsc_id NOT IN('$vsc_id');";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				if ( ($row[0] > 3) and (preg_match('/Y/',$tovdad_display)) )
					{
					$tovdad_display = 'N';
					echo "<br><B>"._QXZ("ERROR: There are already 4 Status Categories set to TimeOnVDAD Display")."</B>\n";
					}

				$stmt="UPDATE vicidial_status_categories SET vsc_name='$vsc_name',vsc_description='$vsc_description',tovdad_display='$tovdad_display',sale_category='$sale_category',dead_lead_category='$dead_lead_category' where vsc_id='$vsc_id';";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='STATUSCATEGORIES', event_type='MODIFY', record_id='$vsc_id', event_code='ADMIN MODIFY STATUS CATEGORY', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=331111111111111;	# go to system settings modification form below
	}


######################
# ADD=441111111111111 modify/delete qc status code in the system
######################
if ($ADD==441111111111111)
	{
	if ( ($LOGmodify_servers==1) and ($SSqc_features_active > 0) )
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if (preg_match('/delete/',$stage))
			{
			if ( (strlen($code) < 1) or (preg_match("/^B$|^NA$|^DNC$|^NA$|^DROP$|^INCALL$|^QUEUE$|^NEW$/i",$code)) )
				{
				echo "<br>"._QXZ("QC STATUS CODE NOT DELETED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("the qc status code cannot be a reserved status").": B,NA,DNC,NA,DROP,INCALL,QUEUE,NEW\n";
				echo "<br>"._QXZ("the qc status code needs to be at least 1 characters in length")."\n";
				}
			else
				{
				echo "<br><B>"._QXZ("QC STATUS CODE DELETED").": $code</B>\n";

				$stmt="DELETE FROM vicidial_qc_codes where code='$code';";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='QCCODES', event_type='DELETE', record_id='$vsc_id', event_code='ADMIN DELETE QC CODES', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		if (preg_match('/modify/', $stage))
			{
			if ( (strlen($code) < 1) or (strlen($code_name) < 2) )
				{
				echo "<br>"._QXZ("QC STATUS CODE NOT MODIFIED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("the qc status code needs to be at least 1 characters in length")."\n";
				echo "<br>"._QXZ("the qc status code name needs to be at least 1 characters in length")."\n";
				}
			else
				{
				echo "<br><B>"._QXZ("QC STATUS CODE MODIFIED").": $code</B>\n";

				$stmt="UPDATE vicidial_qc_codes SET code_name='$code_name' where code='$code';";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='QCCODES', event_type='MODIFY', record_id='$vsc_id', event_code='ADMIN MODIFY QC CODES', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=341111111111111;	# go to qc status code modification form below
	}





######################################################################################################
######################################################################################################
#######   5 series, delete records confirmation
######################################################################################################
######################################################################################################


######################
# ADD=5 confirmation before deletion of user
######################
if ($ADD==5)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($user) < 2) or ($LOGdelete_users < 1) )
		{
		echo "<br>"._QXZ("USER NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("User be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("USER DELETION CONFIRMATION").": $user</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=6&user=$user&CoNfIrM=YES\">"._QXZ("Click here to delete user")." $user</a><br><br><br>\n";
		}

	$ADD='3';		# go to user modification below
	}


######################
# ADD=51 confirmation before deletion of campaign
######################
if ($ADD==51)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($campaign_id) < 2) or ($LOGdelete_campaigns < 1) )
		{
		echo "<br>"._QXZ("CAMPAIGN NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Campaign_id be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("CAMPAIGN DELETION CONFIRMATION").": $campaign_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=61&campaign_id=$campaign_id&CoNfIrM=YES\">"._QXZ("Click here to delete campaign")." $campaign_id</a><br><br><br>\n";
		}

	$ADD='31';		# go to campaign modification below
	}


######################
# ADD=52 confirmation before logging all agents out of campaign of campaign
######################
if ($ADD==52)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if (strlen($campaign_id) < 2)
		{
		echo "<br>"._QXZ("AGENTS NOT LOGGED OUT OF CAMPAIGN - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Campaign_id be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("AGENT LOGOUT CONFIRMATION").": $campaign_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=62&campaign_id=$campaign_id&CoNfIrM=YES&DB=$DB\">"._QXZ("Click here to log all agents out of")." $campaign_id</a><br><br><br>\n";
		}

	$ADD='31';		# go to campaign modification below
	}


######################
# ADD=53 confirmation before Emergency VDAC Jam Clear - deletes oldest LIVE vicidial_auto_call record
######################
if ($ADD==53)
	{
	if (preg_match('/IN/i', $stage))
		{$group_id=$campaign_id;}
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if (strlen($campaign_id) < 2)
		{
		echo "<br>"._QXZ("VDAC NOT CLEARED FOR CAMPAIGN - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Campaign_id be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("VDAC CLEAR CONFIRMATION").": $campaign_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=63&campaign_id=$campaign_id&CoNfIrM=YES&stage=$stage\">"._QXZ("Click here to delete the oldest LIVE record in VDAC for")." $campaign_id</a><br><br><br>\n";
		}

	# go to campaign modification below
	if (preg_match('/IN/i', $stage))
		{$ADD='3111';}
	else
		{$ADD='31';}	
	}


######################
# ADD=511 confirmation before deletion of list
######################
if ($ADD==511)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($list_id) < 2) or ($LOGdelete_lists < 1) )
		{
		echo "<br>"._QXZ("LIST NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("List_id be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("LIST DELETION CONFIRMATION").": $list_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=611&list_id=$list_id&CoNfIrM=YES\">"._QXZ("Click here to delete list and all of its leads")." $list_id</a><br><br><br>\n";
		}

	$ADD='311';		# go to list modification below
	}


######################
# ADD=531 confirmation before deletion of drop list
######################
if ($ADD==531)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($dl_id) < 2) or ($LOGdelete_lists < 1) )
		{
		echo "<br>"._QXZ("DROP LIST NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("dl_id be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("DROP LIST DELETION CONFIRMATION").": $dl_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=631&dl_id=$dl_id&CoNfIrM=YES\">"._QXZ("Click here to delete drop list")." $dl_id</a><br><br><br>\n";
		}

	$ADD='331';		# go to drop list modification below
	}


######################
# ADD=512 confirmation before clearing of list
######################
if ($ADD==512)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
	if ( (strlen($list_id) < 2) or ($LOGuser_level < 9) or ($LOGdelete_lists < 1) or ($LOGmodify_lists < 1) or ($LOGmodify_leads < 1) )
		{
		echo "<br>"._QXZ("LIST NOT CLEARED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("List_id must be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("LIST CLEAR CONFIRMATION").": $list_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=612&list_id=$list_id&CoNfIrM=YES\">"._QXZ("Click here to clear list and all of its leads")." $list_id</a><br><br><br>\n";
		}
	$ADD='311';		# go to list modification below
	}


######################
# ADD=5111 confirmation before deletion of in-group
######################
if ($ADD==5111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($group_id) < 2) or ($LOGdelete_ingroups < 1) )
		{
		echo "<br>"._QXZ("IN-GROUP NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>Group_id "._QXZ("must be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("IN-GROUP DELETION CONFIRMATION").": $group_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=6111&group_id=$group_id&CoNfIrM=YES&group_handling=$group_handling\">"._QXZ("Click here to delete in-group")." $group_id</a><br><br><br>\n";
		}

	$ADD='3111';		# go to in-group modification below
	}


######################
# ADD=5311 confirmation before deletion of did
######################
if ($ADD==5311)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($did_id) < 1) or ($LOGdelete_dids < 1) )
		{
		echo "<br>"._QXZ("DID NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>did_id "._QXZ("must be at least 1 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("DID DELETION CONFIRMATION").": $menu_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=6311&did_id=$did_id&CoNfIrM=YES\">"._QXZ("Click here to delete DID")." $did_id</a><br><br><br>\n";
		}

	$ADD='3311';		# go to did modification below
	}


######################
# ADD=5511 confirmation before deletion of call menu
######################
if ($ADD==5511)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($menu_id) < 2) or ($LOGdelete_dids < 1) )
		{
		echo "<br>"._QXZ("CALL MENU NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>menu_id "._QXZ("must be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("CALL MENU DELETION CONFIRMATION").": $menu_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=6511&menu_id=$menu_id&CoNfIrM=YES\">"._QXZ("Click here to delete CALL MENU")." $menu_id</a><br><br><br>\n";
		}

	$ADD='3511';		# go to call menu modification below
	}


######################
# ADD=5711 confirmation before deletion of filter phone group
######################
if ($ADD==5711)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($filter_phone_group_id) < 2) or ($LOGdelete_dids < 1) )
		{
		echo "<br>"._QXZ("FILTER PHONE GROUP NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>filter_phone_group_id "._QXZ("must be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("FILTER PHONE GROUP DELETION CONFIRMATION").": $filter_phone_group_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=6711&filter_phone_group_id=$filter_phone_group_id&CoNfIrM=YES\">"._QXZ("Click here to delete FILTER PHONE GROUP")." $filter_phone_group_id</a><br><br><br>\n";
		}

	$ADD='3711';		# go to filter phone group modification below
	}


######################
# ADD=51111 confirmation before deletion of remote agent record
######################
if ($ADD==51111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($remote_agent_id) < 1) or ($LOGdelete_remote_agents < 1) )
		{
		echo "<br>"._QXZ("REMOTE AGENT NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>Remote_agent_id "._QXZ("must be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("REMOTE AGENT DELETION CONFIRMATION").": $remote_agent_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=61111&remote_agent_id=$remote_agent_id&CoNfIrM=YES\">"._QXZ("Click here to delete remote agent")." $remote_agent_id</a><br><br><br>\n";
		}

	$ADD='31111';		# go to remote agent modification below
	}


######################
# ADD=52111 confirmation before deletion of extension group record
######################
if ($ADD==52111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($extension_id) < 1) or ($LOGdelete_remote_agents < 1) )
		{
		echo "<br>"._QXZ("EXTENSION GROUP ENTRY NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>extension_id "._QXZ("must be at least 1 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("EXTENSION GROUP ENTRY DELETION CONFIRMATION").": $extension_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=62111&extension_id=$extension_id&CoNfIrM=YES\">"._QXZ("Click here to delete extension group entry")." $extension_id</a><br><br><br>\n";
		}

	$ADD='32111';		# go to extension group modification below
	}


######################
# ADD=511111 confirmation before deletion of user group record
######################
if ($ADD==511111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($user_group) < 2) or ($LOGdelete_user_groups < 1) )
		{
		echo "<br>"._QXZ("USER GROUP NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>User_group "._QXZ("must be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("USER GROUP DELETION CONFIRMATION").": $user_group</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=611111&user_group=$user_group&CoNfIrM=YES\">"._QXZ("Click here to delete user group")." $user_group</a><br><br><br>\n";
		}

	$ADD='311111';		# go to user group modification below
	}


######################
# ADD=5111111 confirmation before deletion of script record
######################
if ($ADD==5111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($script_id) < 2) or ($LOGdelete_scripts < 1) )
		{
		echo "<br>"._QXZ("SCRIPT NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>Script_id "._QXZ("must be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("SCRIPT DELETION CONFIRMATION").": $script_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=6111111&script_id=$script_id&CoNfIrM=YES\">"._QXZ("Click here to delete script")." $script_id</a><br><br><br>\n";
		}

	$ADD='3111111';		# go to script modification below
	}


######################
# ADD=51111111 confirmation before deletion of filter record
######################
if ($ADD==51111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($lead_filter_id) < 2) or ($LOGdelete_filters < 1) )
		{
		echo "<br>"._QXZ("FILTER NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Filter ID must be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("FILTER DELETION CONFIRMATION").": $lead_filter_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=61111111&lead_filter_id=$lead_filter_id&CoNfIrM=YES\">"._QXZ("Click here to delete filter")." $lead_filter_id</a><br><br><br>\n";
		}

	$ADD='31111111';		# go to filter modification below
	}


######################
# ADD=511111111 confirmation before deletion of call time record
######################
if ($ADD==511111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) )
		{
		echo "<br>"._QXZ("CALL TIME NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Call Time ID must be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("CALL TIME DELETION CONFIRMATION").": $call_time_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=611111111&call_time_id=$call_time_id&CoNfIrM=YES\">"._QXZ("Click here to delete call time")." $call_time_id</a><br><br><br>\n";
		}

	$ADD='311111111';		# go to call time modification below
	}


######################
# ADD=5111111111 confirmation before deletion of state call time record
######################
if ($ADD==5111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) )
		{
		echo "<br>"._QXZ("STATE CALL TIME NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Call Time ID must be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("STATE CALL TIME DELETION CONFIRMATION").": $call_time_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=6111111111&call_time_id=$call_time_id&CoNfIrM=YES\">"._QXZ("Click here to delete state call time")." $call_time_id</a><br><br><br>\n";
		}

	$ADD='3111111111';		# go to state call time modification below
	}


######################
# ADD=5211111111 confirmation before deletion of holiday record
######################
if ($ADD==5211111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($holiday_id) < 2) or ($LOGdelete_call_times < 1) )
		{
		echo "<br>"._QXZ("HOLIDAY NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Holiday ID must be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("HOLIDAY DELETION CONFIRMATION").": $holiday_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=6211111111&holiday_id=$holiday_id&CoNfIrM=YES\">"._QXZ("Click here to delete holiday")." $holiday_id</a><br><br><br>\n";
		}

	$ADD='3211111111';		# go to holiday modification below
	}


######################
# ADD=531111111 confirmation before deletion of shift record
######################
if ($ADD==531111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($shift_id) < 2) or ($LOGdelete_call_times < 1) )
		{
		echo "<br>"._QXZ("SHIFT NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Shift ID must be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("SHIFT DELETION CONFIRMATION").": $shift_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=631111111&shift_id=$shift_id&CoNfIrM=YES\">"._QXZ("Click here to delete shift")." $shift_id</a><br><br><br>\n";
		}

	$ADD='331111111';		# go to call time modification below
	}


######################
# ADD=51111111111 confirmation before deletion of phone record
######################
if ($ADD==51111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($extension) < 2) or (strlen($server_ip) < 7) or ($LOGast_delete_phones < 1) )
		{
		echo "<br>"._QXZ("PHONE NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Extension be at least 2 characters in length")."\n";
		echo "<br>"._QXZ("Server IP be at least 7 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("PHONE DELETION CONFIRMATION").": $extension - $server_ip</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=61111111111&extension=$extension&server_ip=$server_ip&CoNfIrM=YES\">"._QXZ("Click here to delete phone")." $extension - $server_ip</a><br><br><br>\n";
		}
	$ADD='31111111111';		# go to phone modification below
	}


######################
# ADD=52111111111 confirmation before deletion of phone alias record
######################
if ($ADD==52111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($alias_id) < 1) or ($LOGast_delete_phones < 1) )
		{
		echo "<br>"._QXZ("PHONE ALIAS NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Alias ID must be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("PHONE ALIAS DELETION CONFIRMATION").": $alias_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=62111111111&alias_id=$alias_id&CoNfIrM=YES\">"._QXZ("Click here to delete phone alias")." $alias_id</a><br><br><br>\n";
		}
	$ADD='32111111111';		# go to phone alias modification below
	}


######################
# ADD=53111111111 confirmation before deletion of group alias record
######################
if ($ADD==53111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($group_alias_id) < 1) or ($LOGast_delete_phones < 1) )
		{
		echo "<br>"._QXZ("GROUP ALIAS NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Group Alias ID must be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("GROUP ALIAS DELETION CONFIRMATION").": $group_alias_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=63111111111&group_alias_id=$group_alias_id&CoNfIrM=YES\">"._QXZ("Click here to delete group alias")." $group_alias_id</a><br><br><br>\n";
		}
	$ADD='33111111111';		# go to group alias modification below
	}


######################
# ADD=511111111111 confirmation before deletion of server record
######################
if ($ADD==511111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($server_id) < 2) or (strlen($server_ip) < 7) or ($LOGast_delete_phones < 1) )
		{
		echo "<br>"._QXZ("SERVER NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Server ID be at least 2 characters in length")."\n";
		echo "<br>"._QXZ("Server IP be at least 7 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("SERVER DELETION CONFIRMATION").": $server_id - $server_ip</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=611111111111&server_id=$server_id&server_ip=$server_ip&CoNfIrM=YES\">"._QXZ("Click here to delete server")." $server_id - $server_ip</a><br><br><br>\n";
		}
	$ADD='311111111111';		# go to server modification below
	}


######################
# ADD=521111111111 confirmation before clearing agent conferences
######################
if ($ADD==521111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($server_id) < 2) or (strlen($server_ip) < 7) or ($LOGast_delete_phones < 1) )
		{
		echo "<br>"._QXZ("AGENT CONFERENCES NOT CLEARED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Server ID be at least 2 characters in length")."\n";
		echo "<br>"._QXZ("Server IP be at least 7 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("AGENT CONFERENCES CLEARING CONFIRMATION").": $server_id - $server_ip</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=622111111111&server_id=$server_id&server_ip=$server_ip&CoNfIrM=YES\">"._QXZ("Click here to clear agent conferences")." $server_id - $server_ip</a><br><br><br>\n";
		}
	$ADD='311111111111';		# go to server modification below
	}


######################
# ADD=531111111111 confirmation before deletion of conf template record
######################
if ($ADD==531111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if (strlen($template_id) < 2)
		{
		echo "<br>"._QXZ("CONF TEMPLATE NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Template ID be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("CONF TEMPLATE DELETION CONFIRMATION").": $template_id - $template_name</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=631111111111&template_id=$template_id&server_ip=$server_ip&CoNfIrM=YES\">"._QXZ("Click here to delete conf template")." $template_id - $template_name</a><br><br><br>\n";
		}
	$ADD='331111111111';		# go to conf template modification below
	}


######################
# ADD=541111111111 confirmation before deletion of carrier record
######################
if ($ADD==541111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if (strlen($carrier_id) < 2)
		{
		echo "<br>"._QXZ("CARRIER NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Carrier ID be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("CARRIER DELETION CONFIRMATION").": $carrier_id - $carrier_name</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=641111111111&carrier_id=$carrier_id&CoNfIrM=YES\">"._QXZ("Click here to delete carrier")." $carrier_id - $carrier_name</a><br><br><br>\n";
		}
	$ADD='341111111111';		# go to carrier modification below
	}


######################
# ADD=551111111111 confirmation before deletion of tts record
######################
if ($ADD==551111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if (strlen($tts_id) < 2)
		{
		echo "<br>"._QXZ("TTS ENTRY NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("TTS ID be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("TTS ENTRY DELETION CONFIRMATION").": $tts_id - $tts_name</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=651111111111&tts_id=$tts_id&CoNfIrM=YES\">"._QXZ("Click here to delete tts entry")." $tts_id - $tts_name</a><br><br><br>\n";
		}
	$ADD='351111111111';		# go to tts entry modification below
	}


######################
# ADD=561111111111 confirmation before deletion of music on hold record
######################
if ($ADD==561111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if (strlen($moh_id) < 2)
		{
		echo "<br>"._QXZ("MUSIC ON HOLD ENTRY NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("MOH ID be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("MUSIC ON HOLD ENTRY DELETION CONFIRMATION").": $moh_id - $moh_name</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=661111111111&moh_id=$moh_id&CoNfIrM=YES\">"._QXZ("Click here to delete music on hold entry")." $moh_id - $moh_name</a><br><br><br>\n";
		}
	$ADD='361111111111';		# go to music on hold entry modification below
	}


######################
# ADD=571111111111 confirmation before deletion of voicemail record
######################
if ($ADD==571111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if (strlen($voicemail_id) < 2)
		{
		echo "<br>"._QXZ("VOICEMAIL BOX NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Voicemail ID be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("VOICEMAIL BOX DELETION CONFIRMATION").": $voicemail_id - $fullname</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=671111111111&voicemail_id=$voicemail_id&CoNfIrM=YES\">"._QXZ("Click here to delete voicemail box")." $voicemail_id - $fullname</a><br><br><br>\n";
		}
	$ADD='371111111111';		# go to voicemail entry modification below
	}


######################
# ADD=581111111111 confirmation before deletion of screen label record
######################
if ($ADD==581111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if (strlen($label_id) < 2)
		{
		echo "<br>"._QXZ("SCREEN LABEL NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Label ID be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("SCREEN LABEL DELETION CONFIRMATION").": $label_id - $label_name</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=681111111111&label_id=$label_id&CoNfIrM=YES\">"._QXZ("Click here to delete screen label")." $label_id - $label_name</a><br><br><br>\n";
		}
	$ADD='381111111111';		# go to screen label entry modification below
	}


######################
# ADD=582111111111 confirmation before deletion of screen colors record
######################
if ($ADD==582111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if (strlen($colors_id) < 2)
		{
		echo "<br>"._QXZ("SCREEN COLROS NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Colors ID be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("SCREEN COLORS DELETION CONFIRMATION").": $colors_id - $colors_name</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=682111111111&colors_id=$colors_id&CoNfIrM=YES\">"._QXZ("Click here to delete screen colors")." $colors_id - $colors_name</a><br><br><br>\n";
		}
	$ADD='382111111111';		# go to screen colors entry modification below
	}


######################
# ADD=591111111111 confirmation before deletion of contact record
######################
if ($ADD==591111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if (strlen($contact_id) < 1)
		{
		echo "<br>"._QXZ("CONTACT NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Contact ID must be at least 1 character in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("CONTACT DELETION CONFIRMATION").": $contact_id - $first_name - $last_name</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=691111111111&contact_id=$contact_id&CoNfIrM=YES\">"._QXZ("Click here to delete contact")." $contact_id - $first_name - $last_name</a><br><br><br>\n";
		}
	$ADD='391111111111';		# go to contact entry modification below
	}


######################
# ADD=592111111111 confirmation before deletion of settings container record
######################
if ($ADD==592111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if (strlen($container_id) < 2)
		{
		echo "<br>"._QXZ("SETTINGS CONTAINER NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Container ID be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("SETTINGS CONTAINER DELETION CONFIRMATION").": $container_id - $container_notes</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=692111111111&container_id=$container_id&CoNfIrM=YES\">"._QXZ("Click here to delete settings container")." $container_id - $container_notes</a><br><br><br>\n";
		}
	$ADD='392111111111';		# go to settings container entry modification below
	}


######################
# ADD=593111111111 confirmation before deletion of status group record
######################
if ($ADD==593111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if (strlen($status_group_id) < 2)
		{
		echo "<br>"._QXZ("STATUS GROUP NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Status Group ID be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("STATUS GROUP DELETION CONFIRMATION").": $status_group_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=693111111111&status_group_id=$status_group_id&CoNfIrM=YES\">"._QXZ("Click here to delete status group")." $status_group_id</a><br><br><br>\n";
		}
	$ADD='393111111111';		# go to status groups entry modification below
	}



######################
# ADD=594111111111 confirmation before deletion of automated report record
######################
if ($ADD==594111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if (strlen($report_id) < 2)
		{
		echo "<br>"._QXZ("AUTOMATED REPORT NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Report ID be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("AUTOMATED REPORT DELETION CONFIRMATION").": $report_id - $report_name</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=694111111111&report_id=$report_id&CoNfIrM=YES\">"._QXZ("Click here to delete automated report")." $report_id - $report_name</a><br><br><br>\n";
		}
	$ADD='394111111111';		# go to automated report entry modification below
	}


######################
# ADD=595111111111 confirmation before deletion of IP List record
######################
if ($ADD==595111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if (strlen($ip_list_id) < 2)
		{
		echo "<br>"._QXZ("IP LIST NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("IP LIST ID must be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("IP LIST DELETION CONFIRMATION").": $ip_list_id - $ip_list_name</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=695111111111&ip_list_id=$ip_list_id&CoNfIrM=YES\">"._QXZ("Click here to delete IP List")." $ip_list_id - $ip_list_name</a><br><br><br>\n";
		}
	$ADD='395111111111';		# go to IP LIST entry modification below
	}


######################
# ADD=596111111111 confirmation before deletion of CID group record
######################
if ($ADD==596111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if (strlen($cid_group_id) < 2)
		{
		echo "<br>"._QXZ("CID GROUP NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("CID Group ID be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("CID GROUP DELETION CONFIRMATION").": $cid_group_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=696111111111&cid_group_id=$cid_group_id&CoNfIrM=YES\">"._QXZ("Click here to delete CID group")." $cid_group_id</a><br><br><br>\n";
		}
	$ADD='396111111111';		# go to CID Group entry modification below
	}


######################
# ADD=597111111111 confirmation before deletion of VM Message group record
######################
if ($ADD==597111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if (strlen($leave_vm_message_group_id) < 2)
		{
		echo "<br>"._QXZ("VM MESSAGE GROUP NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("VM Message Group ID be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("VM MESSAGE GROUP DELETION CONFIRMATION").": $leave_vm_message_group_id</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=697111111111&leave_vm_message_group_id=$leave_vm_message_group_id&CoNfIrM=YES\">"._QXZ("Click here to delete VM Message group")." $leave_vm_message_group_id</a><br><br><br>\n";
		}
	$ADD='397111111111';		# go to VM Message Group entry modification below
	}


######################
# ADD=598111111111 confirmation before deletion of Queue Group record
######################
if ($ADD==598111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if (strlen($queue_group) < 2)
		{
		echo "<br>"._QXZ("QUEUE GROUP NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("QUEUE Group ID be at least 2 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("QUEUE GROUP DELETION CONFIRMATION").": $queue_group</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=698111111111&queue_group=$queue_group&CoNfIrM=YES\">"._QXZ("Click here to delete Queue Group")." $queue_group</a><br><br><br>\n";
		}
	$ADD='398111111111';		# go to Queue Group entry modification below
	}


######################
# ADD=5111111111111 confirmation before deletion of conference record
######################
if ($ADD==5111111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($conf_exten) < 2) or (strlen($server_ip) < 7) or ($LOGast_delete_phones < 1) )
		{
		echo "<br>"._QXZ("CONFERENCE NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Conference must be at least 2 characters in length")."\n";
		echo "<br>"._QXZ("Server IP be at least 7 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("CONFERENCE DELETION CONFIRMATION").": $conf_exten - $server_ip</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=6111111111111&conf_exten=$conf_exten&server_ip=$server_ip&CoNfIrM=YES\">"._QXZ("Click here to delete phone")." $conf_exten - $server_ip</a><br><br><br>\n";
		}
	$ADD='3111111111111';		# go to conference modification below
	}


######################
# ADD=51111111111111 confirmation before deletion of vicidial conference record
######################
if ($ADD==51111111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($conf_exten) < 2) or (strlen($server_ip) < 7) or ($LOGast_delete_phones < 1) )
		{
		echo "<br>"._QXZ("AGENT CONFERENCE NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Conference must be at least 2 characters in length")."\n";
		echo "<br>"._QXZ("Server IP be at least 7 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("AGENT CONFERENCE DELETION CONFIRMATION").": $conf_exten - $server_ip</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=61111111111111&conf_exten=$conf_exten&server_ip=$server_ip&CoNfIrM=YES\">"._QXZ("Click here to delete Conference")." $conf_exten - $server_ip</a><br><br><br>\n";
		}
	$ADD='31111111111111';		# go to vicidial conference modification below
	}


######################
# ADD=52111111111111 confirmation before deletion of vicidial confbridge record
######################
if ($ADD==52111111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($conf_exten) < 2) or (strlen($server_ip) < 7) or ($LOGast_delete_phones < 1) )
		{
		echo "<br>"._QXZ("AGENT CONFBRIDGE NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("ConfBridge must be at least 2 characters in length")."\n";
		echo "<br>"._QXZ("Server IP be at least 7 characters in length")."\n";
		}
	else
		{
		echo "<br><B>"._QXZ("AGENT CONFBRIDGE DELETION CONFIRMATION").": $conf_exten - $server_ip</B>\n";
		echo "<br><br><a href=\"$PHP_SELF?ADD=62111111111111&conf_exten=$conf_exten&server_ip=$server_ip&CoNfIrM=YES\">"._QXZ("Click here to delete ConfBridge")." $conf_exten - $server_ip</a><br><br><br>\n";
		}
	$ADD='32111111111111';		# go to vicidial confbridge modification below
	}





######################################################################################################
######################################################################################################
#######   6 series, delete records
######################################################################################################
######################################################################################################


######################
# ADD=6 delete user record
######################
if ($ADD==6)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( ( strlen($user) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_users < 1) )
		{
		echo "<br>"._QXZ("USER NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("User be at least 2 characters in length")."\n";
		}
	else
		{
		if ( ($LOGmodify_same_user_level < 1) and ($user=='$PHP_AUTH_USER') )
			{
			echo _QXZ("You are not allowed to edit your own user")."\n";
			exit;
			}
		else
			{
			$stmt="SELECT count(*) from vicidial_users where user='$user' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] < 1)
				{echo "<br>"._QXZ("USER NOT FOUND").": $user\n";}
			else
				{
				$stmtA="DELETE from vicidial_users where user='$user' $LOGadmin_viewable_groupsSQL limit 1;";
				$rslt=mysql_to_mysqli($stmtA, $link);

				$stmtB="DELETE from vicidial_campaign_agents where user='$user';";
				$rslt=mysql_to_mysqli($stmtB, $link);

				$stmtC="DELETE from vicidial_inbound_group_agents where user='$user';";
				$rslt=mysql_to_mysqli($stmtC, $link);

				$stmtD="UPDATE vicidial_remote_agents SET status='INACTIVE' where user_start='$user';";
				$rslt=mysql_to_mysqli($stmtD, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmtA|$stmtB|$stmtC|$stmtD|";
				$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='DELETE', record_id='$user', event_code='ADMIN DELETE USER', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);

				echo "<br><B>"._QXZ("USER DELETION COMPLETED").": $user</B>\n";
				echo "<br><br>\n";
				}
			}
		}
	$ADD='0';		# go to user list
	}


######################
# ADD=61 delete campaign record
######################
if ($ADD==61)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( ( strlen($campaign_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_campaigns < 1) )
		{
		echo "<br>"._QXZ("CAMPAIGN NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>Campaign_id "._QXZ("must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("CAMPAIGN NOT FOUND").": $campaign_id\n";}
		else
			{
			$stmtA="DELETE from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL limit 1;";
			$rslt=mysql_to_mysqli($stmtA, $link);
			$affected_rowsA = mysqli_affected_rows($link);

			$stmtB="DELETE from vicidial_campaign_agents where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmtB, $link);
			$affected_rowsB = mysqli_affected_rows($link);

			$stmtC="DELETE from vicidial_live_agents where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmtC, $link);
			$affected_rowsC = mysqli_affected_rows($link);

			$stmtD="DELETE from vicidial_campaign_statuses where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmtD, $link);
			$affected_rowsD = mysqli_affected_rows($link);

			$stmtE="DELETE from vicidial_campaign_hotkeys where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmtE, $link);
			$affected_rowsE = mysqli_affected_rows($link);

			$stmtF="INSERT INTO vicidial_callbacks_archive SELECT * from vicidial_callbacks where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmtF, $link);
			$affected_rowsF = mysqli_affected_rows($link);

			$stmtG="DELETE from vicidial_callbacks where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmtG, $link);
			$affected_rowsG = mysqli_affected_rows($link);

			$stmtH="DELETE from vicidial_campaign_stats where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmtH, $link);
			$affected_rowsH = mysqli_affected_rows($link);

			$stmtI="DELETE from vicidial_campaign_stats_debug where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmtI, $link);
			$affected_rowsI = mysqli_affected_rows($link);

			$stmtJ="DELETE from vicidial_lead_recycle where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmtJ, $link);
			$affected_rowsJ = mysqli_affected_rows($link);

			$stmtK="DELETE from vicidial_campaign_server_stats where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmtK, $link);
			$affected_rowsK = mysqli_affected_rows($link);

			$stmtL="DELETE from vicidial_server_trunks where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmtL, $link);
			$affected_rowsL = mysqli_affected_rows($link);

			$stmtM="DELETE from vicidial_pause_codes where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmtM, $link);
			$affected_rowsM = mysqli_affected_rows($link);

			$stmtN="DELETE from vicidial_campaigns_list_mix where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmtN, $link);
			$affected_rowsN = mysqli_affected_rows($link);

			$stmtO="DELETE from vicidial_xfer_presets where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmtO, $link);
			$affected_rowsO = mysqli_affected_rows($link);

			$stmtP="DELETE from vicidial_xfer_stats where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmtP, $link);		
			$affected_rowsP = mysqli_affected_rows($link);

			$stmtQ="DELETE from vicidial_campaign_cid_areacodes where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmtQ, $link);		
			$affected_rowsQ = mysqli_affected_rows($link);

			$stmtR="DELETE from vicidial_url_multi where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmtR, $link);		
			$affected_rowsR = mysqli_affected_rows($link);

			echo "<br>"._QXZ("REMOVING LIST HOPPER LEADS FROM OLD CAMPAIGN HOPPER")." ($campaign_id)\n";
			$stmtS="DELETE from vicidial_hopper where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmtS, $link);
			$affected_rowsS = mysqli_affected_rows($link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmtA|$stmtB|$stmtC|$stmtD|$stmtE|$stmtF|$stmtG|$stmtH|$stmtI|$stmtJ|$stmtK|$stmtL|$stmtM|$stmtN|$stmtO|$stmtP|$stmtQ|$stmtR|$stmtS|";
			$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='CAMPAIGNS', event_type='DELETE', record_id='$campaign_id', event_code='ADMIN DELETE CAMPAIGN', event_sql=\"$SQL_log\", event_notes='$affected_rowsA|$affected_rowsB|$affected_rowsC|$affected_rowsD|$affected_rowsE|$affected_rowsF|$affected_rowsG|$affected_rowsH|$affected_rowsI|$affected_rowsJ|$affected_rowsK|$affected_rowsL|$affected_rowsM|$affected_rowsN|$affected_rowsO|$affected_rowsP|$affected_rowsQ|$affected_rowsR|$affected_rowsS';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("CAMPAIGN DELETION COMPLETED").": $campaign_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='10';		# go to campaigns list
	}


######################
# ADD=62 Logout all agents from a campaign
######################
if ($ADD==62)
	{
	if ($LOGmodify_campaigns==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if (strlen($campaign_id) < 2)
			{
			echo "<br>"._QXZ("AGENTS NOT LOGGED OUT OF CAMPAIGN - Please go back and look at the data you entered")."\n";
			echo "<br>Campaign_id "._QXZ("must be at least 2 characters in length")."\n";
			}
		else
			{
			$stmtLOG='';
			$usersLOG='';
			$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] < 1)
				{echo "<br>"._QXZ("CAMPAIGN NOT FOUND").": $campaign_id\n";}
			else
				{
				$now_date_epoch = date('U');
				$inactive_epoch = ($now_date_epoch - 60);
				$stmt = "SELECT user,campaign_id,UNIX_TIMESTAMP(last_update_time),extension,status,conf_exten,server_ip from vicidial_live_agents where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
				$rslt=mysql_to_mysqli($stmt, $link);
				if ($DB) {echo "<BR>$stmt\n";}
				$vla_ct = mysqli_num_rows($rslt);
				$k=0;
				while ($vla_ct > $k)
					{
					$row=mysqli_fetch_row($rslt);
					$VLA_user[$k] =			$row[0];
					$VLA_campaign_id[$k] =	$row[1];
					$VLA_update_time[$k] =	$row[2];
					$VLA_extension[$k] =	$row[3];
					$VLA_status[$k] =		$row[4];
					$VLA_conf_exten[$k] =	$row[5];
					$VLA_server_ip[$k] =	$row[6];
					$k++;
					}

				$k=0;
				while ($vla_ct > $k)
					{
					if ($VLA_update_time[$k] > $inactive_epoch)
						{
						$lead_active=0;
						$stmt = "SELECT agent_log_id,user,server_ip,event_time,lead_id,campaign_id,pause_epoch,pause_sec,wait_epoch,wait_sec,talk_epoch,talk_sec,dispo_epoch,dispo_sec,status,user_group,comments,sub_status,dead_epoch,dead_sec from vicidial_agent_log where user='$VLA_user[$k]' order by agent_log_id desc LIMIT 1;";
						$rslt=mysql_to_mysqli($stmt, $link);
						if ($DB) {echo "<BR>$stmt\n";}
						$val_ct = mysqli_num_rows($rslt);
						if ($val_ct > 0)
							{
							$row=mysqli_fetch_row($rslt);
							$VAL_agent_log_id =		$row[0];
							$VAL_user =				$row[1];
							$VAL_server_ip =		$row[2];
							$VAL_event_time =		$row[3];
							$VAL_lead_id =			$row[4];
							$VAL_campaign_id =		$row[5];
							$VAL_pause_epoch =		$row[6];
							$VAL_pause_sec =		$row[7];
							$VAL_wait_epoch =		$row[8];
							$VAL_wait_sec =			$row[9];
							$VAL_talk_epoch =		$row[10];
							$VAL_talk_sec =			$row[11];
							$VAL_dispo_epoch =		$row[12];
							$VAL_dispo_sec =		$row[13];
							$VAL_status =			$row[14];
							$VAL_user_group =		$row[15];
							$VAL_comments =			$row[16];
							$VAL_sub_status =		$row[17];
							$VAL_dead_epoch =		$row[18];
							$VAL_dead_sec =			$row[19];

							if ($DB) {echo "\n<BR>"._QXZ("VAL VALUES").": $VAL_agent_log_id|$VAL_status|$VAL_lead_id\n";}

							if ( ($VAL_wait_epoch < 1) or ( ($VAL_status == 'PAUSE') and ($VAL_dispo_epoch < 1) ) )
								{
								$VAL_pause_sec = ( ($now_date_epoch - $VAL_pause_epoch) + $VAL_pause_sec);
								$stmt = "UPDATE vicidial_agent_log SET wait_epoch='$now_date_epoch', pause_sec='$VAL_pause_sec', pause_type='ADMIN' where agent_log_id='$VAL_agent_log_id';";
								$stmtLOG .= "$stmt|";
								}
							else
								{
								if ($VAL_talk_epoch < 1)
									{
									$VAL_wait_sec = ( ($now_date_epoch - $VAL_wait_epoch) + $VAL_wait_sec);
									$stmt = "UPDATE vicidial_agent_log SET talk_epoch='$now_date_epoch', wait_sec='$VAL_wait_sec' where agent_log_id='$VAL_agent_log_id';";
									$stmtLOG .= "$stmt|";
									}
								else
									{
									$lead_active++;
									$status_update_SQL='';
									if ( ( (strlen($VAL_status) < 1) or ($VAL_status == 'NULL') ) and ($VAL_lead_id > 0) )
										{
										$status_update_SQL = ", status='PU'";
										$stmt="UPDATE vicidial_list SET status='PU' where lead_id='$VAL_lead_id';";
										if ($DB) {echo "<BR>$stmt\n";}
										$rslt=mysql_to_mysqli($stmt, $link);
										$stmtLOG .= "$stmt|";
										}
									if ($VAL_dispo_epoch < 1)
										{
										$VAL_talk_sec = ($now_date_epoch - $VAL_talk_epoch);
										$stmt = "UPDATE vicidial_agent_log SET dispo_epoch='$now_date_epoch', talk_sec='$VAL_talk_sec'$status_update_SQL where agent_log_id='$VAL_agent_log_id';";
										$stmtLOG .= "$stmt|";
										}
									else
										{
										if ($VAL_dispo_sec < 1)
											{
											$VAL_dispo_sec = ($now_date_epoch - $VAL_dispo_epoch);
											$stmt = "UPDATE vicidial_agent_log SET dispo_sec='$VAL_dispo_sec' where agent_log_id='$VAL_agent_log_id';";
											$stmtLOG .= "$stmt|";
											}
										}
									}
								}

							if ($DB) {echo "<BR>$stmt\n";}
							$rslt=mysql_to_mysqli($stmt, $link);
							}
						}

					$stmt="DELETE from vicidial_live_agents where user='$VLA_user[$k]';";
					if ($DB) {echo "<BR>$stmt\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					$stmtLOG .= "$stmt|";

					if (strlen($VAL_user_group) < 1)
						{
						$stmt = "SELECT user_group FROM vicidial_users where user='$VLA_user[$k]' $LOGadmin_viewable_groupsSQL;";
						$rslt=mysql_to_mysqli($stmt, $link);
						if ($DB) {echo "<BR>$stmt\n";}
						$val_ct = mysqli_num_rows($rslt);
						if ($val_ct > 0)
							{
							$row=mysqli_fetch_row($rslt);
							$VAL_user_group =		$row[0];
							}
						}

					$local_DEF = 'Local/5555';
					$local_AMP = '@';
					$ext_context = 'default';
					$kick_local_channel = "$local_DEF$VLA_conf_exten[$k]$local_AMP$ext_context";
					$queryCID = "ULGH3457$StarTtimE";

					$stmtC="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$VLA_server_ip[$k]','','Originate','$queryCID','Channel: $kick_local_channel','Context: $ext_context','Exten: 8300','Priority: 1','Callerid: $queryCID','','','','$channel','$exten');";
					if ($DB) {echo "<BR>$stmtC\n";}
					$rslt=mysql_to_mysqli($stmtC, $link);

					$stmt = "INSERT INTO vicidial_user_log (user,event,campaign_id,event_date,event_epoch,user_group,extension) values('$VLA_user[$k]','LOGOUT','$VLA_campaign_id[$k]','$SQLdate','$now_date_epoch','$VAL_user_group','MGR LOGOUT: $PHP_AUTH_USER');";
					if ($DB) {echo "<BR>$stmt\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					$stmtLOG .= "$stmt|";
					$usersLOG .= "$VLA_user[$k]|";


					#############################################
					##### START QUEUEMETRICS LOGGING LOOKUP #####
					$stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,queuemetrics_loginout,queuemetrics_addmember_enabled,queuemetrics_dispo_pause,queuemetrics_pe_phone_append,queuemetrics_pause_type,queuemetrics_pausereason FROM system_settings;";
					$rslt=mysql_to_mysqli($stmt, $link);
					if ($DB) {echo "<BR>$stmt\n";}
					$qm_conf_ct = mysqli_num_rows($rslt);
					if ($qm_conf_ct > 0)
						{
						$row=mysqli_fetch_row($rslt);
						$enable_queuemetrics_logging =		$row[0];
						$queuemetrics_server_ip	=			$row[1];
						$queuemetrics_dbname =				$row[2];
						$queuemetrics_login	=				$row[3];
						$queuemetrics_pass =				$row[4];
						$queuemetrics_log_id =				$row[5];
						$queuemetrics_loginout =			$row[6];
						$queuemetrics_addmember_enabled =	$row[7];
						$queuemetrics_dispo_pause =			$row[8];
						$queuemetrics_pe_phone_append =		$row[9];
						$queuemetrics_pause_type =			$row[10];
						$queuemetrics_pausereason =			$row[11];
						}
					##### END QUEUEMETRICS LOGGING LOOKUP #####
					###########################################
					if ($enable_queuemetrics_logging > 0)
						{
						$QM_LOGOFF = 'AGENTLOGOFF';
						if ($queuemetrics_loginout=='CALLBACK')
							{$QM_LOGOFF = 'AGENTCALLBACKLOGOFF';}

						$linkB=mysqli_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass","$queuemetrics_dbname");
						if (!$linkB) 
							{
							die('MySQL '._QXZ("connect ERROR").': ' . mysqli_connect_error());
							}
						$agents='@agents';
						$agent_logged_in='';
						$time_logged_in='0';

						$stmtB = "SELECT agent,time_id,data1 FROM queue_log where agent='Agent/$VLA_user[$k]' and verb IN('AGENTLOGIN','AGENTCALLBACKLOGIN') and time_id > $check_time order by time_id desc limit 1;";
						$rsltB=mysql_to_mysqli($stmtB, $linkB);
						if ($DB) {echo "<BR>$stmtB\n";}
						$qml_ct = mysqli_num_rows($rsltB);
						if ($qml_ct > 0)
							{
							$row=mysqli_fetch_row($rsltB);
							$agent_logged_in =		$row[0];
							$time_logged_in =		$row[1];
							$RAWtime_logged_in =	$row[1];
							$phone_logged_in =		$row[2];
							}

						$time_logged_in = ($now_date_epoch - $time_logged_in);
						if ($time_logged_in > 1000000) {$time_logged_in=1;}

						if ($queuemetrics_loginout == 'NONE')
							{
							$pause_typeSQL='';
							if ($queuemetrics_pause_type > 0)
								{$pause_typeSQL=",data5='ADMIN'";}
							$stmt = "INSERT INTO queue_log SET `partition`='P01',time_id='$now_date_epoch',call_id='NONE',queue='NONE',agent='Agent/$VLA_user[$k]',verb='PAUSEREASON',serverid='$queuemetrics_log_id',data1='LOGOFF'$pause_typeSQL;";
							if ($DB) {echo "$stmt\n";}
							$rslt=mysql_to_mysqli($stmt, $linkB);
							$affected_rows = mysqli_affected_rows($linkB);
							}

						if ($queuemetrics_addmember_enabled > 0)
							{
							$queuemetrics_phone_environment='';
							$stmt = "SELECT queuemetrics_phone_environment FROM vicidial_campaigns where campaign_id='$VLA_campaign_id[$k]' $LOGallowed_campaignsSQL;";
							$rslt=mysql_to_mysqli($stmt, $link);
							if ($DB) {echo "<BR>$stmt\n";}
							$cqpe_ct = mysqli_num_rows($rslt);
							if ($cqpe_ct > 0)
								{
								$row=mysqli_fetch_row($rslt);
								$queuemetrics_phone_environment =	$row[0];
								}

							if ( ($time_logged_in < 1) or ($queuemetrics_loginout == 'NONE') )
								{
								$stmtB = "SELECT agent,time_id,data3 FROM queue_log where agent='Agent/$VLA_user[$k]' and verb='PAUSEREASON' and data1='LOGIN' order by time_id desc limit 1;";
								$rsltB=mysql_to_mysqli($stmtB, $linkB);
								if ($DB) {echo "<BR>$stmtB\n";}
								$qml_ct = mysqli_num_rows($rsltB);
								if ($qml_ct > 0)
									{
									$row=mysqli_fetch_row($rsltB);
									$agent_logged_in =		$row[0];
									$time_logged_in =		$row[1];
									$RAWtime_logged_in =	$row[1];
									$phone_logged_in =		$row[2];
									}
								$time_logged_in = ($now_date_epoch - $time_logged_in);
								if ($time_logged_in > 1000000) {$time_logged_in=1;}
								}
							$stmt = "SELECT distinct queue FROM queue_log where time_id >= $RAWtime_logged_in and agent='$agent_logged_in' and verb IN('ADDMEMBER','ADDMEMBER2')  and queue != '$VLA_campaign_id[$k]' order by time_id desc;";
							$rslt=mysql_to_mysqli($stmt, $linkB);
							if ($DB) {echo "$stmt\n";}
							$amq_conf_ct = mysqli_num_rows($rslt);
							$i=0;
							while ($i < $amq_conf_ct)
								{
								$row=mysqli_fetch_row($rslt);
								$AMqueue[$i] =	$row[0];
								$i++;
								}

							### add the logged-in campaign as well
							$AMqueue[$i] = $VLA_campaign_id[$k];
							$i++;
							$amq_conf_ct++;

							$i=0;
							while ($i < $amq_conf_ct)
								{
								$pe_append='';
								if ( ($queuemetrics_pe_phone_append > 0) and (strlen($queuemetrics_phone_environment)>0) )
									{
									$qm_extension = explode('/',$phone_logged_in);
									$pe_append = "-$qm_extension[1]";
									}
								$stmt = "INSERT INTO queue_log SET `partition`='P01',time_id='$now_date_epoch',call_id='NONE',queue='$AMqueue[$i]',agent='$agent_logged_in',verb='REMOVEMEMBER',data1='$phone_logged_in',serverid='$queuemetrics_log_id',data4='$queuemetrics_phone_environment$pe_append';";
								$rslt=mysql_to_mysqli($stmt, $linkB);
								$affected_rows = mysqli_affected_rows($linkB);
								$i++;
								}
							}

						if ($queuemetrics_loginout != 'NONE')
							{
							$stmtB = "INSERT INTO queue_log SET `partition`='P01',time_id='$now_date_epoch',call_id='NONE',queue='NONE',agent='$agent_logged_in',verb='$QM_LOGOFF',serverid='$queuemetrics_log_id',data1='$phone_logged_in',data2='$time_logged_in';";
							if ($DB) {echo "<BR>$stmtB\n";}
							$rsltB=mysql_to_mysqli($stmtB, $linkB);
							}
						}

					echo "<!-- Agent $VLA_user[$k] has been emergency logged out, make sure they close their web browser<BR> -->\n";

					$k++;
					}

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmtLOG";
				$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='CAMPAIGNS', event_type='LOGOUT', record_id='$campaign_id', event_code='ADMIN LOGOUT CAMPAIGN AGENTS', event_sql=\"$SQL_log\", event_notes='Users logged out: $usersLOG';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);

				echo "<br><B>"._QXZ("AGENT LOGOUT COMPLETED").": $campaign_id</B>\n";
				echo "<br><br>\n";
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD='31';		# go to campaign modification below
	}


######################
# ADD=63 Emergency VDAC Jam Clear
######################
if ($ADD==63)
	{
	if ($LOGmodify_campaigns==1)
		{
		if (preg_match('/IN/i', $stage))
			{$group_id=$campaign_id;}
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if (strlen($campaign_id) < 2)
			{
			echo "<br>"._QXZ("VDAC NOT CLEARED FOR CAMPAIGN - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("Campaign_id be at least 2 characters in length")."\n";
			}
		else
			{
			$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] < 1)
				{echo "<br>"._QXZ("CAMPAIGN NOT FOUND").": $campaign_id\n";}
			else
				{
				$stmt="DELETE from vicidial_auto_calls where status='LIVE' and campaign_id='$campaign_id' $LOGallowed_campaignsSQL order by call_time limit 1;";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='CAMPAIGNS', event_type='RESET', record_id='$campaign_id', event_code='ADMIN RESET CAMPAIGN JAM', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);

				echo "<br><B>"._QXZ("LAST VDAC RECORD CLEARED FOR CAMPAIGN").": $campaign_id</B>\n";
				echo "<br><br>\n";
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	# go to campaign modification below
	if (preg_match('/IN/i', $stage))
		{$ADD='3111';}
	else
		{$ADD='31';}
	}


######################
# ADD=65 delete campaign lead recycle in the system
######################
if ($ADD==65)
	{
	if ($LOGmodify_campaigns==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) )
			{
			echo "<br>"._QXZ("CAMPAIGN LEAD RECYCLE NOT DELETED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("status must be between 1 and 6 characters in length")."\n";
			echo "<br>"._QXZ("attempt delay must be at least 120 seconds")."\n";
			echo "<br>"._QXZ("maximum attempts must be from 1 to 10")."\n";
			}
		else
			{
			$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] < 1)
				{echo "<br>"._QXZ("CAMPAIGN NOT FOUND").": $campaign_id\n";}
			else
				{
				echo "<br><B>"._QXZ("CAMPAIGN LEAD RECYCLE DELETED").": $campaign_id - $status - $attempt_delay</B>\n";

				$stmt="DELETE FROM vicidial_lead_recycle where campaign_id='$campaign_id' and status='$status' $LOGallowed_campaignsSQL;";
				$rslt=mysql_to_mysqli($stmt, $link);

				$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmtB, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtB|";
				$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='CAMPAIGN_RECYCLE', event_type='DELETE', record_id='$campaign_id', event_code='ADMIN DELETE CAMPAIGN LEAD RECYCLE', event_sql=\"$SQL_log\", event_notes='Status: $status';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$SUB=25;
	$ADD=31;	# go to campaign modification form below
	}


######################
# ADD=66 delete auto alt dial status from the campaign
######################
if ($ADD==66)
	{
	if ($LOGmodify_campaigns==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id' and auto_alt_dial_statuses LIKE \"% $status %\" $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("AUTO ALT DIAL STATUS NOT DELETED - this auto alt dial status is not in this campaign")."\n";}
		else
			{
			if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) )
				{
				echo "<br>"._QXZ("AUTO ALT DIAL STATUS NOT DELETED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("status must be between 1 and 6 characters in length")."\n";
				}
			else
				{
				$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				if ($row[0] < 1)
					{echo "<br>"._QXZ("CAMPAIGN NOT FOUND").": $campaign_id\n";}
				else
					{
					echo "<br><B>"._QXZ("AUTO ALT DIAL STATUS DELETED").": $campaign_id - $status</B>\n";

					$stmt="SELECT auto_alt_dial_statuses from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
					$rslt=mysql_to_mysqli($stmt, $link);
					$row=mysqli_fetch_row($rslt);

					$auto_alt_dial_statuses = preg_replace("/\s$status\s/i", " ",$row[0]);
					$stmt="UPDATE vicidial_campaigns set auto_alt_dial_statuses='$auto_alt_dial_statuses',campaign_changedate='$SQLdate' where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
					$rslt=mysql_to_mysqli($stmt, $link);

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$stmt|$stmtB|";
					$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='CAMPAIGN_ALTDIALS', event_type='DELETE', record_id='$campaign_id', event_code='ADMIN DELETE CAMPAIGN ALT DIAL', event_sql=\"$SQL_log\", event_notes='Status: $status';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$SUB=26;
	$ADD=31;	# go to campaign modification form below
	}


######################
# ADD=67 delete agent pause code in the system
######################
if ($ADD==67)
	{
	if ($LOGmodify_campaigns==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($campaign_id) < 2) or (strlen($pause_code) < 1) )
			{
			echo "<br>"._QXZ("CAMPAIGN PAUSE CODE NOT DELETED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("pause code must be between 1 and 6 characters in length")."\n";
			}
		else
			{
			$stmt="SELECT count(*) from vicidial_pause_codes where campaign_id='$campaign_id' and pause_code='$pause_code' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] < 1)
				{echo "<br>"._QXZ("CAMPAIGN PAUSE CODE NOT FOUND").": $campaign_id - $pause_code\n";}
			else
				{
				echo "<br><B>"._QXZ("CAMPAIGN PAUSE CODE DELETED").": $campaign_id - $pause_code</B>\n";

				$stmt="DELETE FROM vicidial_pause_codes where campaign_id='$campaign_id' and pause_code='$pause_code' $LOGallowed_campaignsSQL;";
				$rslt=mysql_to_mysqli($stmt, $link);

				$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmtB, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtB|";
				$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='CAMPAIGN_PAUSECODES', event_type='DELETE', record_id='$campaign_id', event_code='ADMIN DELETE CAMPAIGN PAUSE CODE', event_sql=\"$SQL_log\", event_notes='Status: $pause_code';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$SUB=27;
	$ADD=31;	# go to campaign modification form below
	}


######################
# ADD=68 remove campaign dial status
######################
if ($ADD==68)
	{
	if ($LOGmodify_campaigns==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id' and dial_statuses LIKE \"% $status %\" $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("CAMPAIGN DIAL STATUS NOT REMOVED - this dial status is not selected for this campaign")."\n";}
		else
			{
			if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) )
				{
				echo "<br>"._QXZ("CAMPAIGN DIAL STATUS NOT REMOVED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("status must be between 1 and 6 characters in length")."\n";
				}
			else
				{
				$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				if ($row[0] < 1)
					{echo "<br>"._QXZ("CAMPAIGN NOT FOUND").": $campaign_id\n";}
				else
					{
					echo "<br><B>"._QXZ("CAMPAIGN DIAL STATUS REMOVED").": $campaign_id - $status</B>\n";

					$stmt="SELECT dial_statuses from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
					$rslt=mysql_to_mysqli($stmt, $link);
					$row=mysqli_fetch_row($rslt);

					$dial_statuses = preg_replace("/\s$status\s/i", " ",$row[0]);
					$stmt="UPDATE vicidial_campaigns set dial_statuses='$dial_statuses',campaign_changedate='$SQLdate' where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
					$rslt=mysql_to_mysqli($stmt, $link);

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$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='CAMPAIGN_DIALSTATUSES', event_type='DELETE', record_id='$campaign_id', event_code='ADMIN DELETE CAMPAIGN DIAL STATUS', event_sql=\"$SQL_log\", event_notes='Status: $status';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	#$SUB=28;
	$ADD=31;	# go to campaign modification form below
	}


######################
# ADD=601 delete preset in the system
######################
if ($ADD==601)
	{
	if ($LOGmodify_campaigns==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($campaign_id) < 2) or (strlen($preset_name) < 1) )
			{
			echo "<br>"._QXZ("CAMPAIGN PRESET NOT DELETED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("preset name must be between 1 and 40 characters in length")."\n";
			}
		else
			{
			$stmt="SELECT count(*) from vicidial_xfer_presets where campaign_id='$campaign_id' and preset_name='$preset_name' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] < 1)
				{echo "<br>"._QXZ("CAMPAIGN PRESET NOT FOUND").": $campaign_id - $preset_name\n";}
			else
				{
				echo "<br><B>"._QXZ("CAMPAIGN PRESET DELETED").": $campaign_id - $preset_name</B>\n";

				$stmt="DELETE FROM vicidial_xfer_presets where campaign_id='$campaign_id' and preset_name='$preset_name' $LOGallowed_campaignsSQL;";
				$rslt=mysql_to_mysqli($stmt, $link);

				$stmtA="DELETE FROM vicidial_xfer_stats where campaign_id='$campaign_id' and preset_name='$preset_name' $LOGallowed_campaignsSQL;";
				$rslt=mysql_to_mysqli($stmt, $link);

				$stmtB="UPDATE vicidial_campaigns set campaign_changedate='$SQLdate' where campaign_id='$campaign_id';";
				$rslt=mysql_to_mysqli($stmtB, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt|$stmtA|$stmtB|";
				$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='CAMPAIGN_PRESETS', event_type='DELETE', record_id='$campaign_id', event_code='ADMIN DELETE CAMPAIGN PRESET', event_sql=\"$SQL_log\", event_notes='Preset: $preset_name';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$SUB=201;
	$ADD=31;	# go to campaign modification form below
	}


######################
# ADD=611 delete list record and all leads within it
######################
if ($ADD==611)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( ( strlen($list_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_lists < 1) )
		{
		echo "<br>"._QXZ("LIST NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>List_id "._QXZ("must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_lists where list_id='$list_id' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("LIST NOT FOUND").": $list_id\n";}
		else
			{
			$stmt="DELETE from vicidial_lists where list_id='$list_id' $LOGallowed_campaignsSQL limit 1;";
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br>"._QXZ("REMOVING LIST HOPPER LEADS FROM OLD CAMPAIGN HOPPER")." ($list_id)\n";
			$stmtA="DELETE from vicidial_hopper where list_id='$list_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmtA, $link);

			echo "<br>"._QXZ("REMOVING LIST LEADS FROM LIST TABLE")."\n";
			$stmtB="DELETE from vicidial_list where list_id='$list_id';";
			$rslt=mysql_to_mysqli($stmtB, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmtA|$stmtB|";
			$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='LISTS', event_type='DELETE', record_id='$list_id', event_code='ADMIN DELETE LIST', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("LIST DELETION COMPLETED").": $list_id</B>\n";
			echo "<br><br>\n";
			}
		}

	$ADD='100';		# go to lists list
	}


######################
# ADD=612 clear list record and all leads within it
######################
if ($ADD==612)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( ( strlen($list_id) < 2) or ($CoNfIrM != 'YES') or ($LOGuser_level < 9) or ($LOGdelete_lists < 1) or ($LOGmodify_lists < 1) or ($LOGmodify_leads < 1) )
		{
		echo "<br>"._QXZ("LIST NOT Cleared - Please go back and look at the data you entered")."\n";
		echo "<br>List_id "._QXZ("must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_lists where list_id='$list_id' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("LIST NOT FOUND").": $list_id\n";}
		else
			{
			echo "<br>"._QXZ("REMOVING LIST HOPPER LEADS FROM OLD CAMPAIGN HOPPER")." ($list_id)\n";
			$stmt="DELETE from vicidial_hopper where list_id='$list_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$affected_rowsH = mysqli_affected_rows($link);
			echo ": $affected_rowsH "._QXZ("records")."\n";
			
			# If custom fields are enabled, go through each lead looking for custom data to delete before deleting all standard lead data in this list
			$custom_records_deleted=0;
			if ($SScustom_fields_enabled > 0) 
				{
				echo "<br>"._QXZ("REMOVING LEADS CUSTOM FIELDS RECORDS")."\n";
				$cld_lead_id=array();
				$cld_entry_list_id=array();
				$stmt="SELECT lead_id,entry_list_id from vicidial_list where list_id='$list_id';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$cld_to_print = mysqli_num_rows($rslt);
				$o=0;
				while ($cld_to_print > $o) 
					{
					$rowx=mysqli_fetch_row($rslt);
					$cld_lead_id[$o] =			$rowx[0];
					$cld_entry_list_id[$o] =	$rowx[1];
					$cld_entry_list_id[$o] = preg_replace('/[^0-9]/','',$cld_entry_list_id[$o]);
					$o++;
					}
				$o=0;
				while ($cld_to_print > $o) 
					{
					if (strlen($cld_entry_list_id[$o]) > 0)
						{
						$stmtC="SHOW TABLES LIKE \"custom_$cld_entry_list_id[$o]\";";
						if ($DB>0) {echo "$stmt";}
						$rsltC=mysql_to_mysqli($stmtC, $link);
						$tablecount_to_print = mysqli_num_rows($rsltC);
						if ($tablecount_to_print > 0) 
							{
							$stmtC="DELETE from custom_$cld_entry_list_id[$o] where lead_id='$cld_lead_id[$o]';";
							$rsltC=mysql_to_mysqli($stmtC, $link);
							$affected_rowsC = mysqli_affected_rows($link);
							$custom_records_deleted = ($custom_records_deleted + $affected_rowsC);
							}
						}
					$o++;
					}
				echo ": $custom_records_deleted "._QXZ("records")."\n";
				}

			echo "<br>"._QXZ("REMOVING LEADS FROM LIST TABLE")."\n";
			$stmtA="DELETE from vicidial_list where list_id='$list_id';";
			$rslt=mysql_to_mysqli($stmtA, $link);
			$affected_rowsA = mysqli_affected_rows($link);
			echo ": $affected_rowsA "._QXZ("records")."\n";

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmtA|$stmtC|";
			$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='LISTS', event_type='CLEAR', record_id='$list_id', event_code='ADMIN CLEARED LIST', event_sql=\"$SQL_log\", event_notes='Leads removed: $affected_rowsA   Custom Fields records removed: $custom_records_deleted   Hopper records removed: $affected_rowsH';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("LIST CLEARING COMPLETED").": $list_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='311';		# go to list modify page
	}


######################
# ADD=631 delete drop list record
######################
if ($ADD==631)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( ( strlen($dl_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_lists < 1) )
		{
		echo "<br>"._QXZ("DROP LIST NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>dl_id "._QXZ("must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_drop_lists where dl_id='$dl_id' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("DROP LIST NOT FOUND").": $dl_id\n";}
		else
			{
			$stmt="DELETE from vicidial_drop_lists where dl_id='$dl_id' $LOGallowed_campaignsSQL limit 1;";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmtA|$stmtB|";
			$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='DROPLISTS', event_type='DELETE', record_id='$dl_id', event_code='ADMIN DELETE DROP LIST', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("DROP LIST DELETION COMPLETED").": $dl_id</B>\n";
			echo "<br><br>\n";
			}
		}

	$ADD='130';		# go to drop lists list
	}


######################
# ADD=6111 delete in-group record
######################
if ($ADD==6111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($group_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_ingroups < 1) )
		{
		echo "<br>"._QXZ("IN-GROUP NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>Group_id "._QXZ("must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$group_id' and group_id NOT IN('AGENTDIRECT') $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("IN-GROUP NOT FOUND").": $group_id\n";}
		else
			{
			$stmtA="DELETE from vicidial_inbound_groups where group_id='$group_id' and group_id NOT IN('AGENTDIRECT') $LOGadmin_viewable_groupsSQL limit 1;";
			$rslt=mysql_to_mysqli($stmtA, $link);
			$affected_rowsA = mysqli_affected_rows($link);

			$stmtB="DELETE from vicidial_inbound_group_agents where group_id='$group_id';";
			$rslt=mysql_to_mysqli($stmtB, $link);
			$affected_rowsB = mysqli_affected_rows($link);

			$stmtC="DELETE from vicidial_live_inbound_agents where group_id='$group_id';";
			$rslt=mysql_to_mysqli($stmtC, $link);
			$affected_rowsC = mysqli_affected_rows($link);

			$stmtD="DELETE from vicidial_campaign_stats where campaign_id='$group_id';";
			$rslt=mysql_to_mysqli($stmtD, $link);
			$affected_rowsD = mysqli_affected_rows($link);

			$stmtE="DELETE from vicidial_campaign_stats_debug where campaign_id='$group_id';";
			$rslt=mysql_to_mysqli($stmtE, $link);
			$affected_rowsE = mysqli_affected_rows($link);

			$stmtF="DELETE from vicidial_url_multi where campaign_id='$group_id';";
			$rslt=mysql_to_mysqli($stmtF, $link);		
			$affected_rowsF = mysqli_affected_rows($link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmtA|$stmtB|$stmtC|$stmtD|$stmtE|$stmtF|";
			$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='INGROUPS', event_type='DELETE', record_id='$group_id', event_code='ADMIN DELETE INGROUP', event_sql=\"$SQL_log\", event_notes='$affected_rowsA|$affected_rowsB|$affected_rowsC|$affected_rowsD|$affected_rowsE|$affected_rowsF';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("IN-GROUP DELETION COMPLETED").": $group_id</B>\n";
			echo "<br><br>\n";
			}
		}

	switch($group_handling) 
		{
		case "EMAIL":
			$ADD="1800";
			break;
		case "CHAT":
			$ADD="1900";
			break;
		case "PHONE":
			$ADD="1000";
			break;
		default:
			$ADD="1000";
		}
	}


######################
# ADD=6311 delete did record
######################
if ($ADD==6311)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($did_id) < 1) or ($CoNfIrM != 'YES') or ($LOGdelete_dids < 1) )
		{
		echo "<br>"._QXZ("DID NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>did_id "._QXZ("must be at least 1 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_inbound_dids where did_id='$did_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("DID NOT FOUND").": $did_id\n";}
		else
			{
			$stmt="DELETE from vicidial_inbound_dids where did_id='$did_id' $LOGadmin_viewable_groupsSQL limit 1;";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='DIDS', event_type='DELETE', record_id='$did_id', event_code='ADMIN DELETE DID', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("DID DELETION COMPLETED").": $did_id</B>\n";
			echo "<br><br>\n";
			}
		}

	$ADD='1300';		# go to did list
	}


######################
# ADD=6511 delete call menu record
######################
if ($ADD==6511)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($menu_id) < 1) or ($CoNfIrM != 'YES') or ($LOGdelete_dids < 1) )
		{
		echo "<br>"._QXZ("CALL MENU NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>menu_id "._QXZ("must be at least 1 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_call_menu where menu_id='$menu_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("CALL MENU NOT FOUND").": $menu_id\n";}
		else
			{
			$stmt="DELETE from vicidial_call_menu where menu_id='$menu_id' $LOGadmin_viewable_groupsSQL limit 1;";
			$rslt=mysql_to_mysqli($stmt, $link);

			$stmtA="DELETE from vicidial_call_menu_options where menu_id='$menu_id' limit 17;";
			$rslt=mysql_to_mysqli($stmtA, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmtA";
			$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='CALLMENUS', event_type='DELETE', record_id='$menu_id', event_code='ADMIN DELETE CALL MENU', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("CALL MENU DELETION COMPLETED").": $menu_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='1500';		# go to call menu list
	}


######################
# ADD=6711 delete filter phone group record
######################
if ($ADD==6711)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($filter_phone_group_id) < 1) or ($CoNfIrM != 'YES') or ($LOGdelete_dids < 1) )
		{
		echo "<br>"._QXZ("FILTER PHONE GROUP NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>filter_phone_group_id "._QXZ("must be at least 1 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_filter_phone_groups where filter_phone_group_id='$filter_phone_group_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("FILTER PHONE GROUP NOT FOUND").": $filter_phone_group_id\n";}
		else
			{
			$stmt="DELETE from vicidial_filter_phone_groups where filter_phone_group_id='$filter_phone_group_id' $LOGadmin_viewable_groupsSQL limit 1;";
			$rslt=mysql_to_mysqli($stmt, $link);

			$stmtA="DELETE from vicidial_filter_phone_numbers where filter_phone_group_id='$filter_phone_group_id';";
			$rslt=mysql_to_mysqli($stmtA, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmtA";
			$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='FILTERPHONEGROUPS', event_type='DELETE', record_id='$filter_phone_group_id', event_code='ADMIN DELETE FILTER PHONE GROUP', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("FILTER PHONE GROUP DELETION COMPLETED").": $filter_phone_group_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='1700';		# go to filter phone group list
	}


######################
# ADD=61111 delete remote agent record
######################
if ($ADD==61111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($remote_agent_id) < 1) or ($CoNfIrM != 'YES') or ($LOGdelete_remote_agents < 1) )
		{
		echo "<br>"._QXZ("REMOTE AGENT NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>Remote_agent_id "._QXZ("must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="DELETE from vicidial_remote_agents where remote_agent_id='$remote_agent_id' limit 1;";
		$rslt=mysql_to_mysqli($stmt, $link);

		### LOG INSERTION Admin Log Table ###
		$SQL_log = "$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='REMOTEAGENTS', event_type='DELETE', record_id='$remote_agent_id', event_code='ADMIN DELETE REMOTE AGENT', event_sql=\"$SQL_log\", event_notes='';";
		if ($DB) {echo "|$stmt|\n";}
		$rslt=mysql_to_mysqli($stmt, $link);

		echo "<br><B>"._QXZ("REMOTE AGENT DELETION COMPLETED").": $remote_agent_id</B>\n";
		echo "<br><br>\n";
		}

	$ADD='10000';		# go to remote agents list
	}


######################
# ADD=62111 delete extension group record
######################
if ($ADD==62111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($extension_id) < 1) or ($CoNfIrM != 'YES') or ($LOGdelete_remote_agents < 1) )
		{
		echo "<br>"._QXZ("EXTENSION GROUP ENTRY NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>extension_id "._QXZ("must be at least 1 characters in length")."\n";
		}
	else
		{
		$stmt="DELETE from vicidial_extension_groups where extension_id='$extension_id' limit 1;";
		$rslt=mysql_to_mysqli($stmt, $link);

		### LOG INSERTION Admin Log Table ###
		$SQL_log = "$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='EXTENGROUP', event_type='DELETE', record_id='$extension_id', event_code='ADMIN DELETE EXTENSION GROUP', event_sql=\"$SQL_log\", event_notes='';";
		if ($DB) {echo "|$stmt|\n";}
		$rslt=mysql_to_mysqli($stmt, $link);

		echo "<br><B>"._QXZ("EXTENSION GROUP ENTRY DELETION COMPLETED").": $extension_id</B>\n";
		echo "<br><br>\n";
		}

	$ADD='12000';		# go to extension group list
	}


######################
# ADD=611111 delete user group record
######################
if ($ADD==611111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($user_group) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_user_groups < 1) )
		{
		echo "<br>"._QXZ("USER GROUP NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>User_group "._QXZ("must be at least 2 characters in length")."\n";
		}
	else
		{
		if ( ($LOGmodify_same_user_level < 1) and ($user_group=="$LOGuser_group") )
			{
			echo _QXZ("You are not allowed to edit your own user group")."\n";
			exit;
			}
		else
			{
			$stmt="SELECT count(*) from vicidial_user_groups where user_group='$user_group' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] < 1)
				{echo "<br>"._QXZ("USER GROUP NOT FOUND").": $user_group\n";}
			else
				{
				$stmt="DELETE from vicidial_user_groups where user_group='$user_group' $LOGadmin_viewable_groupsSQL limit 1;";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='USERGROUPS', event_type='DELETE', record_id='$user_group', event_code='ADMIN DELETE USER GROUP', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);

				echo "<br><B>"._QXZ("USER GROUP DELETION COMPLETED").": $user_group</B>\n";
				echo "<br><br>\n";
				}
			}
		}
	$ADD='100000';		# go to user group list
	}


######################
# ADD=6111111 delete script record
######################
if ($ADD==6111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($script_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_scripts < 1) )
		{
		echo "<br>"._QXZ("SCRIPT NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>Script_id "._QXZ("must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_scripts where script_id='$script_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("SCRIPT NOT FOUND").": $script_id\n";}
		else
			{
			$stmt="DELETE from vicidial_scripts where script_id='$script_id' $LOGadmin_viewable_groupsSQL limit 1;";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='SCRIPTS', event_type='DELETE', record_id='$script_id', event_code='ADMIN DELETE SCRIPT', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("SCRIPT DELETION COMPLETED").": $script_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='1000000';		# go to script list
	}


######################
# ADD=61111111 delete filter record
######################
if ($ADD==61111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($lead_filter_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_filters < 1) )
		{
		echo "<br>"._QXZ("FILTER NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Filter ID must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_lead_filters where lead_filter_id='$lead_filter_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("LEAD FILTER NOT FOUND").": $lead_filter_id\n";}
		else
			{
			$stmt="DELETE from vicidial_lead_filters where lead_filter_id='$lead_filter_id' $LOGadmin_viewable_groupsSQL limit 1;";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='FILTERS', event_type='DELETE', record_id='$lead_filter_id', event_code='ADMIN DELETE FILTERS', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("FILTER DELETION COMPLETED").": $lead_filter_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='10000000';		# go to filter list
	}


######################
# ADD=611111111 delete call times record
######################
if ($ADD==611111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) )
		{
		echo "<br>"._QXZ("CALL TIME NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Call Time ID must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_call_times where call_time_id='$call_time_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("CALL TIME NOT FOUND").": $call_time_id\n";}
		else
			{
			$stmtA="UPDATE vicidial_lists set local_call_time='campaign' where local_call_time='$call_time_id';";
			$rslt=mysql_to_mysqli($stmtA, $link);

			$stmt="DELETE from vicidial_call_times where call_time_id='$call_time_id' $LOGadmin_viewable_groupsSQL limit 1;";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmtA|";
			$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='CALLTIMES', event_type='DELETE', record_id='$call_time_id', event_code='ADMIN DELETE CALL TIME', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("CALL TIME DELETION COMPLETED").": $call_time_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='100000000';		# go to call times list
	}


######################
# ADD=6111111111 delete state call times record
######################
if ($ADD==6111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) )
		{
		echo "<br>"._QXZ("STATE CALL TIME NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Call Time ID must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_state_call_times where state_call_time_id='$call_time_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("CALL TIME NOT FOUND").": $call_time_id\n";}
		else
			{
			$stmtA="DELETE from vicidial_state_call_times where state_call_time_id='$call_time_id' $LOGadmin_viewable_groupsSQL limit 1;";
			$rslt=mysql_to_mysqli($stmtA, $link);

			$stmt="SELECT call_time_id,ct_state_call_times from vicidial_call_times where ct_state_call_times LIKE \"%|$call_time_id|%\" order by call_time_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$sct_to_print = mysqli_num_rows($rslt);
			$sct_list='';

			$o=0;
			while ($sct_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$sct_ids[$o] = "$rowx[0]";
				$sct_states[$o] = "$rowx[1]";
				$o++;
				}
			$o=0;
			while ($sct_to_print > $o) 
				{
				$sct_states[$o] = preg_replace("/\|$call_time_id\|/i", '|',$sct_states[$o]);
				$stmtB="UPDATE vicidial_call_times set ct_state_call_times='$sct_states[$o]' where call_time_id='$sct_ids[$o]';";
				$rslt=mysql_to_mysqli($stmtB, $link);
				echo "$stmtB\n";
				echo "State Rule Removed: $sct_ids[$o]<BR>\n";
				$o++;
				}

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmtA|$stmtB|";
			$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='CALLTIMES', event_type='DELETE', record_id='$call_time_id', event_code='ADMIN DELETE STATE CALL TIME', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("STATE CALL TIME DELETION COMPLETED").": $call_time_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='1000000000';		# go to call times list
	}


######################
# ADD=6211111111 delete holiday record
######################
if ($ADD==6211111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($holiday_id) < 2) or ($LOGdelete_call_times < 1) )
		{
		echo "<br>"._QXZ("HOLIDAY NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Holiday ID must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_call_time_holidays where holiday_id='$holiday_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("HOLIDAY NOT FOUND").": $holiday_id\n";}
		else
			{
			$stmtA="DELETE from vicidial_call_time_holidays where holiday_id='$holiday_id' $LOGadmin_viewable_groupsSQL limit 1;";
			$rslt=mysql_to_mysqli($stmtA, $link);

			$stmt="SELECT call_time_id,ct_holidays from vicidial_call_times where ct_holidays LIKE \"%|$holiday_id|%\" order by call_time_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$hct_to_print = mysqli_num_rows($rslt);
			$hct_list='';

			$o=0;
			while ($hct_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$hct_ids[$o] = "$rowx[0]";
				$hct_holidays[$o] = "$rowx[1]";
				$o++;
				}
			$o=0;
			while ($hct_to_print > $o) 
				{
				$hct_holidays[$o] = preg_replace("/\|$holiday_id\|/i", '|',$hct_holidays[$o]);
				$stmtB="UPDATE vicidial_call_times set ct_holidays='$hct_holidays[$o]' where call_time_id='$hct_ids[$o]';";
				$rslt=mysql_to_mysqli($stmtB, $link);
				if ($DB) {echo "|$stmtB|\n";}
				echo "<font class='arial,helvetica' size='2'>Holiday Rule Removed: $hct_ids[$o]</font><BR>\n";
				$o++;
				}

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmtA|$stmtB|";
			$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='HOLIDAYS', event_type='DELETE', record_id='$holiday_id', event_code='ADMIN DELETE HOLIDAY', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B><font class='arial,helvetica' size='2'>"._QXZ("HOLIDAY DELETION COMPLETED").": $holiday_id</font></B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='1200000000';		# go to holidays list
	}


######################
# ADD=631111111 delete shift record
######################
if ($ADD==631111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($shift_id) < 2) or ($LOGdelete_call_times < 1) )
		{
		echo "<br>"._QXZ("SHIFT NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Shift ID must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_shifts where shift_id='$shift_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("SHIFT NOT FOUND").": $shift_id\n";}
		else
			{
			$stmt="DELETE from vicidial_shifts where shift_id='$shift_id' $LOGadmin_viewable_groupsSQL limit 1;";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='SHIFTS', event_type='DELETE', record_id='$shift_id', event_code='ADMIN DELETE SHIFT', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("SHIFT DELETION COMPLETED").": $shift_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='130000000';		# go to shifts list
	}


######################
# ADD=61111111111 delete phone record
######################
if ($ADD==61111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($extension) < 2) or (strlen($server_ip) < 7) or ($CoNfIrM != 'YES') or ($LOGast_delete_phones < 1) )
		{
		echo "<br>"._QXZ("PHONE NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Extension must be at least 2 characters in length")."\n";
		echo "<br>"._QXZ("Server IP must be at least 7 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from phones where extension='$extension' and server_ip='$server_ip' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("PHONE NOT FOUND").": $extension - $server_ip\n";}
		else
			{
			$stmt="DELETE from phones where extension='$extension' and server_ip='$server_ip' $LOGadmin_viewable_groupsSQL limit 1;";
			$rslt=mysql_to_mysqli($stmt, $link);

			$stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';";
			$rslt=mysql_to_mysqli($stmtA, $link);

			$stmtB="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$SSactive_voicemail_server';";
			$rslt=mysql_to_mysqli($stmtB, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmtA|$stmtB|";
			$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='PHONES', event_type='DELETE', record_id='$extension', event_code='ADMIN DELETE PHONE', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("PHONE DELETION COMPLETED").": $extension - $server_ip</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='10000000000';		# go to phone list
	}


######################
# ADD=62111111111 delete phone alias record
######################
if ($ADD==62111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($alias_id) < 2) or ($CoNfIrM != 'YES') or ($LOGast_delete_phones < 1) )
		{
		echo "<br>"._QXZ("PHONE ALIAS NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Alias ID must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from phones_alias where alias_id='$alias_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("PHONE ALIAS NOT FOUND").": $alias_id\n";}
		else
			{
			$stmt="DELETE from phones_alias where alias_id='$alias_id' $LOGadmin_viewable_groupsSQL limit 1;";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='PHONEALIASES', event_type='DELETE', record_id='$alias_id', event_code='ADMIN DELETE PHONE ALIAS', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("PHONE ALIAS DELETION COMPLETED").": $alias_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='12000000000';		# go to phone alias list
	}


######################
# ADD=63111111111 delete group alias record
######################
if ($ADD==63111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($group_alias_id) < 2) or ($CoNfIrM != 'YES') or ($LOGast_delete_phones < 1) )
		{
		echo "<br>"._QXZ("GROUP ALIAS NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Group Alias ID must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from groups_alias where group_alias_id='$group_alias_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("GROUP ALIAS NOT FOUND").": $group_alias_id\n";}
		else
			{
			$stmt="DELETE from groups_alias where group_alias_id='$group_alias_id' $LOGadmin_viewable_groupsSQL limit 1;";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='GROUPALIASES', event_type='DELETE', record_id='$group_alias_id', event_code='ADMIN DELETE GROUP ALIAS', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("GROUP ALIAS DELETION COMPLETED").": $group_alias_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='13000000000';		# go to group alias list
	}


######################
# ADD=611111111111 delete server record
######################
if ($ADD==611111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($server_id) < 2) or (strlen($server_ip) < 7) or ($CoNfIrM != 'YES') or ($LOGast_delete_phones < 1) or ($LOGmodify_servers!=1) )
		{
		echo "<br>"._QXZ("SERVER NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Server ID must be at least 2 characters in length")."\n";
		echo "<br>"._QXZ("Server IP must be at least 7 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from servers where server_id='$server_id' and server_ip='$server_ip' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("SERVER NOT FOUND").": $server_id - $server_ip\n";}
		else
			{
			$stmt="DELETE from servers where server_id='$server_id' and server_ip='$server_ip' $LOGadmin_viewable_groupsSQL limit 1;";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='SERVERS', event_type='DELETE', record_id='$server_id', event_code='ADMIN DELETE SERVER', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("SERVER DELETION COMPLETED").": $server_id - $server_ip</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='100000000000';		# go to server list
	}



######################
# ADD=622111111111 clear agent conferences
######################
if ($ADD==622111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($server_id) < 2) or (strlen($server_ip) < 7) or ($CoNfIrM != 'YES') or ($LOGast_delete_phones < 1) or ($LOGmodify_servers!=1) )
		{
		echo "<br>"._QXZ("AGENT CONFERENCES NOT CLEARED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Server ID must be at least 2 characters in length")."\n";
		echo "<br>"._QXZ("Server IP must be at least 7 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_conferences where server_ip='$server_ip';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("CONFERENCES NOT FOUND").": $server_id - $server_ip\n";}
		else
			{
			$stmt="UPDATE vicidial_conferences SET extension='' where server_ip='$server_ip';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$VCaffected_rows = mysqli_affected_rows($link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='SERVERS', event_type='CLEAR', record_id='$server_id', event_code='ADMIN CONF CLEAR', event_sql=\"$SQL_log\", event_notes='$VCaffected_rows entries cleared';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("AGENT CONFERENCES CLEAR COMPLETED").": $server_id - $server_ip</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD=311111111111;	# go to server modification form below
	}


######################
# ADD=621111111111 delete vicidial server trunk record in the system
######################
if ($ADD==621111111111)
	{
	if ($LOGmodify_servers==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (strlen($campaign_id) < 2) or (strlen($server_ip) < 7) )
			{
			echo "<br>"._QXZ("SERVER TRUNK RECORD NOT DELETED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("campaign must be between 3 and 8 characters in length")."\n";
			echo "<br>"._QXZ("Server IP must be at least 7 characters")."\n";
			}
		else
			{
			$stmt="SELECT count(*) from vicidial_server_trunks where campaign_id='$campaign_id' and server_ip='$server_ip' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] < 1)
				{echo "<br>"._QXZ("SERVER TRUNK NOT FOUND").": $campaign_id - $server_ip\n";}
			else
				{
				echo "<br><B>"._QXZ("SERVER TRUNK RECORD DELETED").": $campaign_id - $server_ip</B>\n";

				$stmt="DELETE FROM vicidial_server_trunks where campaign_id='$campaign_id' and server_ip='$server_ip';";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='SERVERTRUNKS', event_type='DELETE', record_id='$server_ip', event_code='ADMIN DELETE SERVER TRUNK', event_sql=\"$SQL_log\", event_notes='Campaign: $campaign_id';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=311111111111;	# go to server modification form below
	}


######################
# ADD=631111111111 delete conf template record
######################
if ($ADD==631111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($template_id) < 2) or ($CoNfIrM != 'YES') )
		{
		echo "<br>"._QXZ("CONF TEMPLATE NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Template ID must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_conf_templates where template_id='$template_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("TEMPLATE NOT FOUND").": $template_id\n";}
		else
			{
			$stmtA="UPDATE phones SET template_id='' where template_id='$template_id';";
			$rslt=mysql_to_mysqli($stmtA, $link);
			
			$stmtB="UPDATE vicidial_server_carriers SET template_id='' where template_id='$template_id';";
			$rslt=mysql_to_mysqli($stmtB, $link);

			$stmtC="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y';";
			$rslt=mysql_to_mysqli($stmtC, $link);

			$stmtD="DELETE from vicidial_conf_templates where template_id='$template_id' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmtD, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmtA|$stmtB|$stmtC|$stmtD|";
			$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='CONFTEMPLATES', event_type='DELETE', record_id='$template_id', event_code='ADMIN DELETE CONF TEMPLATE', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("CONF TEMPLATE DELETION COMPLETED").": $server_id - $server_ip</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='130000000000';		# go to conf template list
	}


######################
# ADD=641111111111 delete carrier record
######################
if ($ADD==641111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($carrier_id) < 2) or ($CoNfIrM != 'YES') )
		{
		echo "<br>"._QXZ("CARRIER NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Carrier ID must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_server_carriers where carrier_id='$carrier_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("CARRIER NOT FOUND").": $carrier_id\n";}
		else
			{
			$stmt="SELECT server_ip from vicidial_server_carriers where carrier_id='$carrier_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			$CARRIERserver_ip =	$row[0];

			$stmt="DELETE from vicidial_server_carriers where carrier_id='$carrier_id' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);

			$stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$CARRIERserver_ip';";
			if ($CARRIERserver_ip == '0.0.0.0')
				{$stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y';";}
			$rslt=mysql_to_mysqli($stmtA, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmtA|";
			$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='CARRIERS', event_type='DELETE', record_id='$carrier_id', event_code='ADMIN DELETE CARRIER', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("CARRIER DELETION COMPLETED").": $carrier_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='140000000000';		# go to carrier list
	}


######################
# ADD=651111111111 delete tts record
######################
if ($ADD==651111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($tts_id) < 2) or ($CoNfIrM != 'YES') )
		{
		echo "<br>"._QXZ("TTS ENTRY NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("TTS ID must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_tts_prompts where tts_id='$tts_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("TTS NOT FOUND").": $tts_id\n";}
		else
			{
			$stmt="DELETE from vicidial_tts_prompts where tts_id='$tts_id' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='TTS', event_type='DELETE', record_id='$tts_id', event_code='ADMIN DELETE TTS', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("TTS DELETION COMPLETED").": $tts_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='150000000000';		# go to tts entry list
	}


######################
# ADD=661111111111 delete music on hold record
######################
if ($ADD==661111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($moh_id) < 2) or ($CoNfIrM != 'YES') )
		{
		echo "<br>"._QXZ("MUSIC ON HOLD ENTRY NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("MOH ID must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_music_on_hold where moh_id='$moh_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("MUSIC ON HOLD NOT FOUND").": $moh_id\n";}
		else
			{
			$stmt="UPDATE vicidial_music_on_hold SET remove='Y' where moh_id='$moh_id' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);

			$stmtA="DELETE from vicidial_music_on_hold_files where moh_id='$moh_id';";
			$rslt=mysql_to_mysqli($stmtA, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmtA|";
			$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='MOH', event_type='DELETE', record_id='$moh_id', event_code='ADMIN DELETE MOH', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("MUSIC ON HOLD DELETION COMPLETED").": $moh_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='160000000000';		# go to music on hold entry list
	}


######################
# ADD=671111111111 delete voicemail record
######################
if ($ADD==671111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($voicemail_id) < 2) or ($CoNfIrM != 'YES') )
		{
		echo "<br>"._QXZ("VOICEMAIL BOX NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Voicemail ID be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_voicemail where voicemail_id='$voicemail_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("VOICEMAIL BOX NOT FOUND").": $voicemail_id\n";}
		else
			{
			$stmt="DELETE from vicidial_voicemail where voicemail_id='$voicemail_id' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);

			$stmt="SELECT active_voicemail_server from system_settings;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			$active_voicemail_server = $row[0];

			$stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$active_voicemail_server';";
			$rslt=mysql_to_mysqli($stmtA, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmtA|";
			$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='VOICEMAIL', event_type='DELETE', record_id='$voicemail_id', event_code='ADMIN DELETE VOICEMAIL', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("VOICEMAIL BOX DELETION COMPLETED").": $voicemail_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='170000000000';		# go to voicemail entry list
	}


######################
# ADD=681111111111 delete screen labels record
######################
if ($ADD==681111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($label_id) < 2) or ($CoNfIrM != 'YES') )
		{
		echo "<br>"._QXZ("SCREEN LABEL NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Label ID must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_screen_labels where label_id='$label_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("SCREEN LABEL NOT FOUND").": $label_id\n";}
		else
			{
			$stmt="DELETE from vicidial_screen_labels where label_id='$label_id' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='LABEL', event_type='DELETE', record_id='$label_id', event_code='ADMIN DELETE LABEL', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("SCREEN LABEL DELETION COMPLETED").": $label_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='180000000000';		# go to screen labels entry list
	}


######################
# ADD=682111111111 delete screen colors record
######################
if ($ADD==682111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($colors_id) < 2) or ($CoNfIrM != 'YES') )
		{
		echo "<br>"._QXZ("SCREEN COLORS NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Colors ID must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_screen_colors where colors_id='$colors_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("SCREEN COLORS NOT FOUND").": $colors_id\n";}
		else
			{
			$stmt="DELETE from vicidial_screen_colors where colors_id='$colors_id' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='COLORS', event_type='DELETE', record_id='$colors_id', event_code='ADMIN DELETE COLORS', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("SCREEN COLORS DELETION COMPLETED").": $label_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='182000000000';		# go to screen colors entry list
	}


######################
# ADD=691111111111 delete contact record
######################
if ($ADD==691111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($contact_id) < 1) or ($CoNfIrM != 'YES') )
		{
		echo "<br>"._QXZ("CONTACT NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Contact ID must be at least 1 character in length")."\n";
		}
	else
		{
		if ( (preg_match("/contact_information/",$SStables_use_alt_log_db)) and (strlen($SSalt_log_server_ip)>4) and (strlen($SSalt_log_dbname)>0) )
			{
			$linkALT=mysqli_connect("$SSalt_log_server_ip", "$SSalt_log_login", "$SSalt_log_pass", "$SSalt_log_dbname");
				if (!$linkALT) 
					{
					die('MySQL '._QXZ("connect ERROR").': ' . mysqli_connect_error());
					}
			}
		else
			{$linkALT = $link;}
		$stmt="DELETE from contact_information where contact_id='$contact_id';";
		$rslt=mysql_to_mysqli($stmt, $linkALT);

		### LOG INSERTION Admin Log Table ###
		$SQL_log = "$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='CONTACTS', event_type='DELETE', record_id='$contact_id', event_code='ADMIN DELETE CONTACT', event_sql=\"$SQL_log\", event_notes='';";
		if ($DB) {echo "|$stmt|\n";}
		$rslt=mysql_to_mysqli($stmt, $link);

		echo "<br><B>"._QXZ("CONTACT DELETION COMPLETED").": $contact_id</B>\n";
		echo "<br><br>\n";
		}
	$ADD='190000000000';		# go to contacts entry list
	}


######################
# ADD=692111111111 delete settings container record
######################
if ($ADD==692111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($container_id) < 2) or ($CoNfIrM != 'YES') or ($LOGmodify_servers!=1) )
		{
		echo "<br>"._QXZ("SETTINGS CONTAINER NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Container ID must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_settings_containers where container_id='$container_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("SETTINGS CONTAINER NOT FOUND").": $container_id\n";}
		else
			{
			$stmt="DELETE from vicidial_settings_containers where container_id='$container_id' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='CONTAINERS', event_type='DELETE', record_id='$container_id', event_code='ADMIN DELETE CONTAINER', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("SETTINGS CONTAINER DELETION COMPLETED").": $container_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='192000000000';		# go to settings container entry list
	}


######################
# ADD=693111111111 delete status groups record
######################
if ($ADD==693111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($status_group_id) < 2) or ($CoNfIrM != 'YES') or ($LOGmodify_statuses!=1) )
		{
		echo "<br>"._QXZ("STATUS GROUP NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Status Group ID must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_status_groups where status_group_id='$status_group_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("STATUS GROUP NOT FOUND").": $status_group_id\n";}
		else
			{
			$stmt="DELETE from vicidial_status_groups where status_group_id='$status_group_id' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='STATUSGROUPS', event_type='DELETE', record_id='$status_group_id', event_code='ADMIN DELETE STATUS GROUP', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("STATUS GROUP DELETION COMPLETED").": $status_group_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='193000000000';		# go to status groups entry list
	}


######################
# ADD=694111111111 delete automated report record
######################
if ($ADD==694111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($report_id) < 2) or ($CoNfIrM != 'YES') or ($LOGmodify_auto_reports!=1) )
		{
		echo "<br>"._QXZ("AUTOMATED REPORT NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Report ID must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_automated_reports where report_id='$report_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("AUTOMATED REPORT NOT FOUND").": $report_id\n";}
		else
			{
			$stmt="DELETE from vicidial_automated_reports where report_id='$report_id' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='AUTOREPORTS', event_type='DELETE', record_id='$report_id', event_code='ADMIN DELETE AUTO REPORT', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("AUTOMATED REPORT DELETION COMPLETED").": $report_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='194000000000';		# go to automated report entry list
	}


######################
# ADD=695111111111 delete IP List record
######################
if ($ADD==695111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($ip_list_id) < 2) or ($CoNfIrM != 'YES') or ($LOGmodify_ip_lists!=1) )
		{
		echo "<br>"._QXZ("IP LIST NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("IP LIST ID must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_ip_lists where ip_list_id='$ip_list_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("IP LIST NOT FOUND").": $report_id\n";}
		else
			{
			$stmt="DELETE from vicidial_ip_lists where ip_list_id='$ip_list_id' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='IPLISTS', event_type='DELETE', record_id='$ip_list_id', event_code='ADMIN DELETE IP LIST', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("IP LIST DELETION COMPLETED").": $ip_list_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='195000000000';		# go to IP List entry list
	}


######################
# ADD=696111111111 delete CID groups record
######################
if ($ADD==696111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($cid_group_id) < 2) or ($CoNfIrM != 'YES') or ($LOGmodify_statuses!=1) )
		{
		echo "<br>"._QXZ("CID GROUP NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("CID Group ID must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_cid_groups where cid_group_id='$cid_group_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("CID GROUP NOT FOUND").": $cid_group_id\n";}
		else
			{
			$stmt="DELETE from vicidial_cid_groups where cid_group_id='$cid_group_id' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);

			$stmtB="DELETE from vicidial_campaign_cid_areacodes WHERE campaign_id='$cid_group_id';";
			$rslt=mysql_to_mysqli($stmtB, $link);
			$affected_rowsB = mysqli_affected_rows($link);
			if ($DB) {echo "$affected_rowsB|$stmtB|\n";}

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmtB|";
			$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='CIDGROUPS', event_type='DELETE', record_id='$cid_group_id', event_code='ADMIN DELETE CID GROUP', event_sql=\"$SQL_log\", event_notes='$affected_rowsB CIDS deleted';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("CID GROUP DELETION COMPLETED").": $cid_group_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='196000000000';		# go to CID groups entry list
	}


######################
# ADD=697111111111 delete VM Message groups record
######################
if ($ADD==697111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($leave_vm_message_group_id) < 2) or ($CoNfIrM != 'YES') or ($LOGmodify_statuses!=1) )
		{
		echo "<br>"._QXZ("VM MESSAGE GROUP NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("VM Message Group ID must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from leave_vm_message_groups where leave_vm_message_group_id='$leave_vm_message_group_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("VM MESSAGE GROUP NOT FOUND").": $leave_vm_message_group_id\n";}
		else
			{
			$stmt="DELETE from leave_vm_message_groups where leave_vm_message_group_id='$leave_vm_message_group_id' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);

			$stmtB="DELETE from leave_vm_message_groups_entries WHERE leave_vm_message_group_id='$leave_vm_message_group_id';";
			$rslt=mysql_to_mysqli($stmtB, $link);
			$affected_rowsB = mysqli_affected_rows($link);
			if ($DB) {echo "$affected_rowsB|$stmtB|\n";}

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmt|$stmtB|";
			$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='VMMGROUPS', event_type='DELETE', record_id='$leave_vm_message_group_id', event_code='ADMIN DELETE VMM GROUP', event_sql=\"$SQL_log\", event_notes='$affected_rowsB VMMS deleted';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("VM MESSAGE GROUP DELETION COMPLETED").": $leave_vm_message_group_id</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='197000000000';		# go to VM Message groups entry list
	}


######################
# ADD=698111111111 delete Queue Groups record
######################
if ($ADD==698111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($queue_group) < 2) or ($CoNfIrM != 'YES') or ($LOGmodify_statuses!=1) )
		{
		echo "<br>"._QXZ("QUEUE GROUP NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Queue Group ID must be at least 2 characters in length")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_queue_groups where queue_group='$queue_group' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("QUEUE GROUP NOT FOUND").": $queue_group\n";}
		else
			{
			$stmt="DELETE from vicidial_queue_groups where queue_group='$queue_group' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='QUEUEGROUPS', event_type='DELETE', record_id='$queue_group', event_code='ADMIN DELETE QUEUE GROUP', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><B>"._QXZ("QUEUE GROUP DELETION COMPLETED").": $queue_group</B>\n";
			echo "<br><br>\n";
			}
		}
	$ADD='198000000000';		# go to Queue Groups entry list
	}


######################
# ADD=6111111111111 delete conference record
######################
if ($ADD==6111111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($conf_exten) < 2) or (strlen($server_ip) < 7) or ($CoNfIrM != 'YES') or ($LOGast_delete_phones < 1) )
		{
		echo "<br>"._QXZ("CONFERENCE NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Conference must be at least 2 characters in length")."\n";
		echo "<br>"._QXZ("Server IP must be at least 7 characters in length")."\n";
		}
	else
		{
		$stmt="DELETE from conferences where conf_exten='$conf_exten' and server_ip='$server_ip' limit 1;";
		$rslt=mysql_to_mysqli($stmt, $link);

		### LOG INSERTION Admin Log Table ###
		$SQL_log = "$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='CONFERENCES', event_type='DELETE', record_id='$conf_exten', event_code='ADMIN DELETE CONFERENCE', event_sql=\"$SQL_log\", event_notes='';";
		if ($DB) {echo "|$stmt|\n";}
		$rslt=mysql_to_mysqli($stmt, $link);

		echo "<br><B>"._QXZ("CONFERENCE DELETION COMPLETED").": $conf_exten - $server_ip</B>\n";
		echo "<br><br>\n";
		}
	$ADD='1000000000000';		# go to conference list
	}


######################
# ADD=61111111111111 delete vicidial conference record
######################
if ($ADD==61111111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($conf_exten) < 2) or (strlen($server_ip) < 7) or ($CoNfIrM != 'YES') or ($LOGast_delete_phones < 1) )
		{
		echo "<br>"._QXZ("AGENT CONFERENCE NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("Conference must be at least 2 characters in length")."\n";
		echo "<br>"._QXZ("Server IP must be at least 7 characters in length")."\n";
		}
	else
		{
		$stmt="DELETE from vicidial_conferences where conf_exten='$conf_exten' and server_ip='$server_ip' limit 1;";
		$rslt=mysql_to_mysqli($stmt, $link);

		### LOG INSERTION Admin Log Table ###
		$SQL_log = "$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='CONFERENCES', event_type='DELETE', record_id='$conf_exten', event_code='ADMIN DELETE CONFERENCE', event_sql=\"$SQL_log\", event_notes='';";
		if ($DB) {echo "|$stmt|\n";}
		$rslt=mysql_to_mysqli($stmt, $link);

		echo "<br><B>"._QXZ("AGENT CONFERENCE DELETION COMPLETED").": $conf_exten - $server_ip</B>\n";
		echo "<br><br>\n";
		}
	$ADD='10000000000000';		# go to vicidial conference list
	}


######################
# ADD=62111111111111 delete vicidial confbridge record
######################
if ($ADD==62111111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (strlen($conf_exten) < 2) or (strlen($server_ip) < 7) or ($CoNfIrM != 'YES') or ($LOGast_delete_phones < 1) )
		{
		echo "<br>"._QXZ("AGENT CONFBRIDGE NOT DELETED - Please go back and look at the data you entered")."\n";
		echo "<br>"._QXZ("ConfBridge must be at least 2 characters in length")."\n";
		echo "<br>"._QXZ("Server IP must be at least 7 characters in length")."\n";
		}
	else
		{
		$stmt="DELETE from vicidial_confbridges where conf_exten='$conf_exten' and server_ip='$server_ip' limit 1;";
		$rslt=mysql_to_mysqli($stmt, $link);

		### LOG INSERTION Admin Log Table ###
		$SQL_log = "$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='CONFERENCES', event_type='DELETE', record_id='$conf_exten', event_code='ADMIN DELETE CONFBRIDGE', event_sql=\"$SQL_log\", event_notes='';";
		if ($DB) {echo "|$stmt|\n";}
		$rslt=mysql_to_mysqli($stmt, $link);

		echo "<br><B>"._QXZ("AGENT CONFBRIDGE DELETION COMPLETED").": $conf_exten - $server_ip</B>\n";
		echo "<br><br>\n";
		}
	$ADD='12000000000000';		# go to vicidial confbridge list
	}





######################################################################################################
######################################################################################################
#######   3 series, record modification forms
######################################################################################################
######################################################################################################




######################
# ADD=3 modify user info in the system
######################
if ($ADD==3)
	{
	if ($LOGmodify_users==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=3&user=$user";
			$modify_footer_refresh=1;
			}

		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT user_id,user,pass,full_name,user_level,user_group,phone_login,phone_pass,delete_users,delete_user_groups,delete_lists,delete_campaigns,delete_ingroups,delete_remote_agents,load_leads,campaign_detail,ast_admin_access,ast_delete_phones,delete_scripts,modify_leads,hotkeys_active,change_agent_campaign,agent_choose_ingroups,closer_campaigns,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,delete_filters,alter_agent_interface_options,closer_default_blended,delete_call_times,modify_call_times,modify_users,modify_campaigns,modify_lists,modify_scripts,modify_filters,modify_ingroups,modify_usergroups,modify_remoteagents,modify_servers,view_reports,vicidial_recording_override,alter_custdata_override,qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit,add_timeclock_log,modify_timeclock_log,delete_timeclock_log,alter_custphone_override,vdc_agent_api_access,modify_inbound_dids,delete_inbound_dids,active,alert_enabled,download_lists,agent_shift_enforcement_override,manager_shift_enforcement_override,shift_override_flag,export_reports,delete_from_dnc,email,user_code,territory,allow_alerts,agent_choose_territories,custom_one,custom_two,custom_three,custom_four,custom_five,voicemail_id,agent_call_log_view_override,callcard_admin,agent_choose_blended,realtime_block_user_info,custom_fields_modify,force_change_password,agent_lead_search_override,modify_shifts,modify_phones,modify_carriers,modify_labels,modify_statuses,modify_voicemail,modify_audiostore,modify_moh,modify_tts,preset_contact_search,modify_contacts,modify_same_user_level,admin_hide_lead_data,admin_hide_phone_data,agentcall_email,modify_email_accounts,failed_login_count,last_login_date,last_ip,alter_admin_interface_options,max_inbound_calls,modify_custom_dialplans,wrapup_seconds_override,modify_languages,selected_language,user_choose_language,ignore_group_on_search,api_list_restrict,api_allowed_functions,lead_filter_id,agentcall_chat,admin_cf_show_hidden,user_hide_realtime,access_recordings,modify_colors,user_nickname,user_new_lead_limit,api_only_user,modify_auto_reports,modify_ip_lists,ignore_ip_list,ready_max_logout,export_gdpr_leads,pause_code_approval,max_hopper_calls,max_hopper_calls_hour,mute_recordings,hide_call_log_info,next_dial_my_callbacks,user_admin_redirect_url,max_inbound_filter_enabled,max_inbound_filter_statuses,max_inbound_filter_ingroups,max_inbound_filter_min_sec,status_group_id,mobile_number,two_factor_override,manual_dial_filter,user_location,download_invalid_files,user_group_two,failed_login_attempts_today,failed_login_count_today,failed_last_ip_today,failed_last_type_today,modify_dial_prefix,inbound_credits,hci_enabled,manual_dial_lead_id from vicidial_users where user='$user' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$user_id =				$row[0];
		$user =					$row[1];
		$pass =					$row[2];
		$full_name =			$row[3];
		$user_level =			$row[4];
		$user_group =			$row[5];
		$phone_login =			$row[6];
		$phone_pass =			$row[7];
		$delete_users =			$row[8];
		$delete_user_groups =	$row[9];
		$delete_lists =			$row[10];
		$delete_campaigns =		$row[11];
		$delete_ingroups =		$row[12];
		$delete_remote_agents =	$row[13];
		$load_leads =			$row[14];
		$campaign_detail =		$row[15];
		$ast_admin_access =		$row[16];
		$ast_delete_phones =	$row[17];
		$delete_scripts =		$row[18];
		$modify_leads =			$row[19];
		$hotkeys_active =		$row[20];
		$change_agent_campaign =$row[21];
		$agent_choose_ingroups =$row[22];
		$scheduled_callbacks =	$row[24];
		$agentonly_callbacks =	$row[25];
		$agentcall_manual =		$row[26];
		$vicidial_recording =	$row[27];
		$vicidial_transfers =	$row[28];
		$delete_filters =		$row[29];
		$alter_agent_interface_options =$row[30];
		$closer_default_blended =		$row[31];
		$delete_call_times =	$row[32];
		$modify_call_times =	$row[33];
		$modify_users =			$row[34];
		$modify_campaigns =		$row[35];
		$modify_lists =			$row[36];
		$modify_scripts =		$row[37];
		$modify_filters =		$row[38];
		$modify_ingroups =		$row[39];
		$modify_usergroups =	$row[40];
		$modify_remoteagents =	$row[41];
		$modify_servers =		$row[42];
		$view_reports =			$row[43];
		$vicidial_recording_override =	$row[44];
		$alter_custdata_override = $row[45];
		$qc_enabled =			$row[46];
		$qc_user_level =		$row[47];
		$qc_pass =				$row[48];
		$qc_finish =			$row[49];
		$qc_commit =			$row[50];
		$add_timeclock_log =	$row[51];
		$modify_timeclock_log = $row[52];
		$delete_timeclock_log = $row[53];
		$alter_custphone_override = $row[54];
		$vdc_agent_api_access = $row[55];
		$modify_inbound_dids =	$row[56];
		$delete_inbound_dids =	$row[57];
		$active =				$row[58];
		$alert_enabled =		$row[59];
		$download_lists =		$row[60];
		$agent_shift_enforcement_override =	$row[61];
		$manager_shift_enforcement_override =	$row[62];
		$export_reports =		$row[64];
		$delete_from_dnc =		$row[65];
		$email =				$row[66];
		$user_code =			$row[67];
		$territory =			$row[68];
		$allow_alerts =			$row[69];
		$agent_choose_territories = $row[70];
		$user_custom_one =		$row[71];
		$user_custom_two =		$row[72];
		$user_custom_three =	$row[73];
		$user_custom_four =		$row[74];
		$user_custom_five =		$row[75];
		$voicemail_id =			$row[76];
		$agent_call_log_view_override = $row[77];
		$callcard_admin =		$row[78];
		$agent_choose_blended = $row[79];
		$realtime_block_user_info = $row[80];
		$custom_fields_modify =	$row[81];
		$force_change_password = $row[82];
		$agent_lead_search_override = $row[83];
		$modify_shifts =		$row[84];
		$modify_phones =		$row[85];
		$modify_carriers =		$row[86];
		$modify_labels =		$row[87];
		$modify_statuses =		$row[88];
		$modify_voicemail =		$row[89];
		$modify_audiostore =	$row[90];
		$modify_moh =			$row[91];
		$modify_tts =			$row[92];
		$preset_contact_search =	$row[93];
		$modify_contacts =		$row[94];
		$modify_same_user_level =	$row[95];
		$admin_hide_lead_data =	$row[96];
		$admin_hide_phone_data =	$row[97];
		$agentcall_email =	$row[98];
		$modify_email_accounts =	$row[99];
		$failed_login_count =	$row[100];
		$last_login_date =		$row[101];
		$last_ip =				$row[102];
		$alter_admin_interface_options = $row[103];
		$max_inbound_calls =	$row[104];
		$modify_custom_dialplans =	$row[105];
		$wrapup_seconds_override = $row[106];
		$modify_languages =		$row[107];
		$selected_language =	$row[108];
		$user_choose_language = $row[109];
		$ignore_group_on_search = $row[110];
		$api_list_restrict =	$row[111];
		$api_allowed_functions = $row[112];
		$lead_filter_id =		$row[113];
		$agentcall_chat =		$row[114];
		$admin_cf_show_hidden = $row[115];
		$user_hide_realtime =	$row[116];
		$access_recordings =	$row[117];
		$modify_colors =		$row[118];
		$user_nickname =		$row[119];
		$user_new_lead_limit =	$row[120];
		$api_only_user =		$row[121];
		$modify_auto_reports =	$row[122];
		$modify_ip_lists =		$row[123];
		$ignore_ip_list =		$row[124];
		$ready_max_logout =		$row[125];
		$export_gdpr_leads =	$row[126];
		$pause_code_approval =	$row[127];
		$max_hopper_calls =		$row[128];
		$max_hopper_calls_hour =$row[129];
		$mute_recordings =		$row[130];
		$hide_call_log_info =	$row[131];
		$next_dial_my_callbacks=$row[132];
		$user_admin_redirect_url=$row[133];
		$max_inbound_filter_enabled=$row[134];
		$max_inbound_filter_statuses=$row[135];
		$max_inbound_filter_ingroups=$row[136];
		$max_inbound_filter_min_sec=$row[137];
		$status_group_id =		$row[138];
		$mobile_number =		$row[139];
		$two_factor_override =	$row[140];
		$manual_dial_filter =	$row[141];
		$user_location =		$row[142];
		$download_invalid_files=$row[143];
		$user_group_two =		$row[144];
		$failed_login_attempts_today=$row[145];
		$failed_login_count_today=$row[146];
		$failed_last_ip_today = $row[147];
		$failed_last_type_today=$row[148];
		$modify_dial_prefix =	$row[149];
		$inbound_credits =		$row[150];
		$hci_enabled =			$row[151];
		$manual_dial_lead_id =	$row[152];

		##### latest 2FA auth record data
		$last_auth='';
		$stmt="SELECT auth_exp_date,auth_stage,auth_attempts from vicidial_two_factor_auth where user='$user' order by auth_date desc limit 1";
		$rslt=mysql_to_mysqli($stmt, $link);
		$auths_to_print = mysqli_num_rows($rslt);
		if ($auths_to_print > 0)
			{
			$rowx=mysqli_fetch_row($rslt);
			$auth_exp_date =	$rowx[0];
			$auth_stage =		$rowx[1];
			$auth_attempts =	$rowx[2];
			$last_auth = " &nbsp; &nbsp; $auth_exp_date - $auth_stage - $auth_attempts";
			}

		if ( ( ($user_level >= $LOGuser_level) and ($LOGuser_level < 9) ) or ( ($LOGmodify_same_user_level < 1) and ($LOGuser_level > 8) and ($user_level > 8) ) )
			{
			echo "<br>"._QXZ("You do not have permissions to modify this user").": $user\n";
			}
		else
			{
			echo "<br>"._QXZ("MODIFY A USERS RECORD").": $user<form action=$PHP_SELF method=POST>\n";
			if ( ($LOGuser_level > 8) and ($LOGalter_admin_interface > 0) )
				{echo "<input type=hidden name=ADD value=4A>\n";}
			else
				{
				if ($LOGalter_agent_interface == "1")
					{echo "<input type=hidden name=ADD value=4B>\n";}
				else
					{echo "<input type=hidden name=ADD value=4>\n";}
				}
			if ($SScustom_fields_enabled < 1)
				{
				echo "<input type=hidden name=custom_fields_modify value=\"$custom_fields_modify\">\n";
				}

			echo "<input type=hidden name=user value=\"$user\">\n";
			echo "<input type=hidden name=DB value=\"$DB\">\n";
			echo "<center><TABLE width=980 cellspacing=3>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User Number").": </td><td align=left><b>$user</b>$NWB#users-user$NWE</td></tr>\n";

			if ($SSpass_hash_enabled > 0)
				{
				echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><b>"._QXZ("PASSWORD IS ENCRYPTED, ONLY ENTER IN A PASSWORD BELOW IF YOU WANT TO CHANGE IT")."!</b></td></tr>\n";
				}
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Password").": </td><td align=left style=\"display:table-cell; vertical-align:middle;\" NOWRAP><input type=text id=reg_pass name=pass size=50 maxlength=100 value=\"$pass\" onkeyup=\"return pwdChanged('reg_pass','reg_pass_img','pass_length','$SSrequire_password_length');\">$NWB#users-pass$NWE &nbsp; &nbsp; <font size=1>"._QXZ("Strength").":</font> <IMG id=reg_pass_img src='images/pixel.gif' style=\"vertical-align:middle;\" onLoad=\"return pwdChanged('reg_pass','reg_pass_img','pass_length','$SSrequire_password_length');\"> &nbsp; <font size=1> "._QXZ("Length").": <span id=pass_length name=pass_length>0</span></font></td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Force Change Password").": </td><td align=left><select size=1 name=force_change_password><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value=\"$force_change_password\" SELECTED>"._QXZ("$force_change_password")."</option></select>$NWB#users-force_change_password$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Last Login Info").": </td><td align=left><b>$last_login_date - $failed_login_count - $last_ip $last_auth</b>$NWB#users-last_login_date$NWE &nbsp; ";
			if ($LOGuser_level > 8)
				{
				if ($failed_login_attempts_today > 0)
					{
					echo "<font size=2> <a href=\"user_logins_report.php?user=$user\">"._QXZ("Failed logins today")."</a>: $failed_login_attempts_today - $failed_login_count_today - $failed_last_ip_today - $failed_last_type_today</font>";
					}
				else
					{
					echo "<font size=2> <a href=\"user_logins_report.php?user=$user\">"._QXZ("Logins summary")."</a></font>";
					}
				}
			echo "</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Full Name").": </td><td align=left><input type=text name=full_name size=30 maxlength=30 value=\"$full_name\">$NWB#users-full_name$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User Level").": </td><td align=left><select size=1 name=user_level>";
			$h=1;
			$count_user_level=$LOGuser_level;
			if ( ($LOGmodify_same_user_level < 1) and ($LOGuser_level > 8) )
				{$count_user_level=($LOGuser_level - 1);}
			while ($h<=$count_user_level)
				{
				echo "<option>$h</option>";
				$h++;
				}
			echo "<option SELECTED>$user_level</option></select>$NWB#users-user_level$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><A HREF=\"$PHP_SELF?ADD=311111&user_group=$user_group\">"._QXZ("User Group")."</A>: </td><td align=left><select size=1 name=user_group>\n";

			$stmt="SELECT user_group,group_name from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$Ugroups_to_print = mysqli_num_rows($rslt);
			$Ugroups_list='';
			$o=0;
			while ($Ugroups_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$Ugroups_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$o++;
				}
			echo "$Ugroups_list";
			echo "<option SELECTED>$user_group</option>\n";
			echo "</select>$NWB#users-user_group$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Phone Login").": </td><td align=left><input type=text name=phone_login size=20 maxlength=20 value=\"$phone_login\">$NWB#users-phone_login$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Phone Pass").": </td><td align=left><input type=text name=phone_pass size=40 maxlength=100 value=\"$phone_pass\">$NWB#users-phone_pass$NWE\n";
			if ( ($SSuser_account_emails == 'SEND_NO_PASS') or ($SSuser_account_emails == 'SEND_WITH_PASS') )
				{echo " &nbsp; <a href=\"email_agent_login_link.php?preview=1&agent_id=$user\">"._QXZ("send this user a login link email")."</a>";}
			echo "</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$active' SELECTED>"._QXZ("$active")."</option></select>$NWB#users-active$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Voicemail ID").": </td><td align=left><input type=text name=voicemail_id id=voicemail_id size=12 maxlength=10 value=\"$voicemail_id\"> <a href=\"javascript:launch_vm_chooser('voicemail_id','vm');\">"._QXZ("voicemail chooser")."</a>$NWB#users-voicemail_id$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Email").": </td><td align=left><input type=text name=email size=40 maxlength=100 value=\"$email\">$NWB#users-email$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Mobile Number").": </td><td align=left><input type=text name=mobile_number size=20 maxlength=20 value=\"$mobile_number\">$NWB#users-mobile_number$NWE</td></tr>\n";

			if ($SSuser_codes_admin > 0)
				{
				$user_codes_ct=0;
				$raw_user_codes_admin_data="|empty\n";
				$user_code_container_menu='';
				$uc_selected=0;
				if ($SSuser_codes_admin == '2')
					{
					if (file_exists('user_codes_admin.txt'))
					$user_codes_admin_ARY = file('user_codes_admin.txt');
					}
				else
					{
					$stmt="SELECT container_entry from vicidial_settings_containers where container_id='USER_CODES_SYSTEM';";
					$rslt=mysql_to_mysqli($stmt, $link);
					$uc_to_print = mysqli_num_rows($rslt);
					if ($uc_to_print > 0)
						{
						$rowx=mysqli_fetch_row($rslt);
						$raw_user_codes_admin_data = $rowx[0];
						}
					$user_codes_admin_ARY = explode("\n",$raw_user_codes_admin_data);
					}
				$user_codes_admin_ct = count($user_codes_admin_ARY);
				$o=0;
				while ($user_codes_admin_ct > $o) 
					{
					if ( (!preg_match("/^;/",$user_codes_admin_ARY[$o])) and (strlen($user_codes_admin_ARY[$o]) > 0) )
						{
						$user_codes_ct++;

						$user_code_item_ARY = explode('|',$user_codes_admin_ARY[$o]);
						$user_code_item_ARY[0] = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$user_code_item_ARY[0]);
						$user_code_item_ARY[1] = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$user_code_item_ARY[1]);
						if (mb_strlen($user_code_item_ARY[1],'utf-8')>50)
							{$user_code_item_ARY[1] = mb_substr($user_code_item_ARY[1],0,50,'utf-8') . '...';}
						$user_code_container_menu .= "<option ";
						if ($user_code == "$user_code_item_ARY[0]") 
							{
							$user_code_container_menu .= "SELECTED ";
							$uc_selected++;
							}
						if (strlen($user_code_item_ARY[1]) > 0)
							{
							$user_code_container_menu .= "value=\"$user_code_item_ARY[0]\">$user_code_item_ARY[0] - $user_code_item_ARY[1]</option>\n";
							}
						else
							{
							$user_code_container_menu .= "value=\"$user_code_item_ARY[0]\">$user_code_item_ARY[0]</option>\n";
							}
						}
					$o++;
					}
				if ($uc_selected < 1)
					{$user_code_container_menu .= "<option SELECTED value=\"$user_code\">$user_code</option>\n";}

				if ($LOGuser_level >= 9)
					{
					echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User Code").": </td><td align=left><select size=1 name=user_code>$user_code_container_menu</select>$NWB#users-optional$NWE</td></tr>\n";
					}
				else
					{
					echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User Code").": </td><td align=left><input type=hidden name=user_code value=\"$user_code\">$user_code &nbsp; $NWB#users-optional$NWE</td></tr>\n";
					}
				}
			else
				{
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User Code").": </td><td align=left><input type=text name=user_code size=40 maxlength=100 value=\"$user_code\">$NWB#users-optional$NWE</td></tr>\n";
				}

			##### get container entry for USER_LOCATIONS_SYSTEM for pulldown menu
			$raw_location_data=";location|description\n|default\n";
			$stmt="SELECT container_entry from vicidial_settings_containers where container_id='USER_LOCATIONS_SYSTEM';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$loc_to_print = mysqli_num_rows($rslt);
			if ($loc_to_print > 0)
				{
				$rowx=mysqli_fetch_row($rslt);
				$raw_location_data = $rowx[0];
				}
			$location_ARY = explode("\n",$raw_location_data);
			$location_ct = count($location_ARY);
			$location_container_menu='';
			$loc_selected=0;
			$o=0;
			while ($location_ct > $o) 
				{
				if ( (!preg_match("/^;/",$location_ARY[$o])) and (strlen($location_ARY[$o]) > 2) and (preg_match("/\|/",$location_ARY[$o])) )
					{
					$location_item_ARY = explode('|',$location_ARY[$o]);
					if (mb_strlen($location_item_ARY[1],'utf-8')>50)
						{$location_item_ARY[1] = mb_substr($location_item_ARY[1],0,50,'utf-8') . '...';}
					$location_container_menu .= "<option ";
					if ($user_location == "$location_item_ARY[0]") 
						{
						$location_container_menu .= "SELECTED ";
						$loc_selected++;
						}
					$location_container_menu .= "value=\"$location_item_ARY[0]\">$location_item_ARY[0] - $location_item_ARY[1]</option>\n";
					}
				$o++;
				}
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User Location").": </td><td align=left><select size=1 name=user_location>$location_container_menu</select>$NWB#users-user_location$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>";
			if (strlen($user_group_two) > 0)
				{
				echo "<A HREF=\"$PHP_SELF?ADD=311111&user_group=$user_group_two\">"._QXZ("VERM Secondary User Group")."</A>";
				echo ": </td><td align=left><select size=1 name=user_group_two><option value=\"\">--UNDEFINED--</option>\n";
				}
			else
				{
				echo ""._QXZ("VERM Secondary User Group")."";
				echo ": </td><td align=left><select size=1 name=user_group_two><option value=\"\" SELECTED>--UNDEFINED--</option>\n";
				}

			$stmt="SELECT user_group,group_name from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$Ugroups_to_print = mysqli_num_rows($rslt);
			$Ugroups_list='';
			$o=0;
			while ($Ugroups_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$Ugroups_list .= "<option value=\"$rowx[0]\"";
				if ($rowx[0] == $user_group_two) {$Ugroups_list .= " SELECTED";}
				$Ugroups_list .= ">$rowx[0] - $rowx[1]</option>\n";
				$o++;
				}
			echo "$Ugroups_list";
			echo "</select>$NWB#users-user_group_two$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Main Territory").": </td><td align=left><input type=text name=territory size=40 maxlength=100 value=\"$territory\">$NWB#users-optional$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User Nickname").": </td><td align=left><input type=text name=user_nickname size=40 maxlength=50 value=\"$user_nickname\">$NWB#users-user_nickname$NWE</td></tr>\n";

			if ($SSuser_territories_active > 0)
				{
				$stmt="SELECT vut.territory,vt.territory_description from vicidial_user_territories vut,vicidial_territories vt where user='$user' and vut.territory=vt.territory;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$Uterrs_to_print = mysqli_num_rows($rslt);
				$Uterrs_list='';
				$o=0;
				while ($Uterrs_to_print > $o) 
					{
					$rowx=mysqli_fetch_row($rslt);
					$Uterrs_list .= "$rowx[0] - $rowx[1]<BR>\n";
					$o++;
					}
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"user_territories.php\">"._QXZ("User Territories")."</a>: </td><td align=left>$Uterrs_list</tr>\n";
				}
			if ($SSuser_new_lead_limit > 0)
				{
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right rowspan=2>"._QXZ("User New Lead Limits").": </td><td align=left><a href=\"admin_user_list_new.php?user=$user&list_id=---ALL---\">"._QXZ("User List Limit Overrides for this user")."</a></td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=left>"._QXZ("Overall Limit").": <input type=text name=user_new_lead_limit size=5 maxlength=5 value=\"$user_new_lead_limit\">$NWB#users-user_new_lead_limit$NWE</td></tr>\n";
				}
			else
				{
				echo "<tr bgcolor=#$SSstd_row4_background><td><input type=hidden name=user_new_lead_limit value=\"$user_new_lead_limit\"></td></tr>\n";
				}
			if ( ($LOGuser_level > 7) and ( ($LOGalter_agent_interface == "1") or ($LOGalter_admin_interface > 0) ) )
				{
				echo "<tr bgcolor=#$SSmenu_background><td colspan=2 align=center><font color=white><B>"._QXZ("AGENT INTERFACE OPTIONS").":</B></td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Choose Ingroups").": </td><td align=left><select size=1 name=agent_choose_ingroups><option>0</option><option>1</option><option SELECTED>$agent_choose_ingroups</option></select>$NWB#users-agent_choose_ingroups$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Choose Blended").": </td><td align=left><select size=1 name=agent_choose_blended><option>0</option><option>1</option><option SELECTED>$agent_choose_blended</option></select>$NWB#users-agent_choose_blended$NWE</td></tr>\n";
				if ($SSuser_territories_active > 0)
					{
					echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Choose Territories").": </td><td align=left><select size=1 name=agent_choose_territories><option>0</option><option>1</option><option SELECTED>$agent_choose_territories</option></select>$NWB#users-agent_choose_territories$NWE</td></tr>\n";
					}
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Hot Keys Active").": </td><td align=left><select size=1 name=hotkeys_active><option>0</option><option>1</option><option SELECTED>$hotkeys_active</option></select>$NWB#users-hotkeys_active$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Scheduled Callbacks").": </td><td align=left><select size=1 name=scheduled_callbacks><option>0</option><option>1</option><option SELECTED>$scheduled_callbacks</option></select>$NWB#users-scheduled_callbacks$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent-Only Callbacks").": </td><td align=left><select size=1 name=agentonly_callbacks><option>0</option><option>1</option><option SELECTED>$agentonly_callbacks</option></select>$NWB#users-agentonly_callbacks$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Next-Dial My Callbacks Override").": </td><td align=left><select size=1 name=next_dial_my_callbacks><option value='NOT_ACTIVE'>"._QXZ("NOT_ACTIVE")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$next_dial_my_callbacks' SELECTED>"._QXZ("$next_dial_my_callbacks")."</option></select>$NWB#users-next_dial_my_callbacks$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Call Manual").": </td><td align=left><select size=1 name=agentcall_manual><option>0</option><option>1</option><option>2</option><option SELECTED>$agentcall_manual</option></select>$NWB#users-agentcall_manual$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Manual Dial Filter Override").": </td><td align=left><select size=1 name=manual_dial_filter>
				<option value='DISABLED'>"._QXZ("DISABLED")."</option>
				<option value='NONE'>"._QXZ("NONE")."</option>
				<option value='DNC_ONLY'>"._QXZ("DNC_ONLY")."</option>
				<option value='CAMPDNC_ONLY'>"._QXZ("CAMPDNC_ONLY")."</option>
				<option value='INTERNALDNC_ONLY'>"._QXZ("INTERNALDNC_ONLY")."</option>
				<option value='DNC_AND_CAMPDNC'>"._QXZ("DNC_AND_CAMPDNC")."</option>
				<option value='CAMPLISTS_ONLY'>"._QXZ("CAMPLISTS_ONLY")."</option>
				<option value='CAMPLISTS_ALL'>"._QXZ("CAMPLISTS_ALL")."</option>
				<option value='SYSTEM'>"._QXZ("SYSTEM")."</option>
				<option value='DNC_AND_CAMPLISTS'>"._QXZ("DNC_AND_CAMPLISTS")."</option>
				<option value='CAMPDNC_ONLY_AND_CAMPLISTS'>"._QXZ("CAMPDNC_ONLY_AND_CAMPLISTS")."</option>
				<option value='INTERNALDNC_ONLY_AND_CAMPLISTS'>"._QXZ("INTERNALDNC_ONLY_AND_CAMPLISTS")."</option>
				<option value='DNC_AND_CAMPDNC_AND_CAMPLISTS'>"._QXZ("DNC_AND_CAMPDNC_AND_CAMPLISTS")."</option>
				<option value='DNC_AND_CAMPLISTS_ALL'>"._QXZ("DNC_AND_CAMPLISTS_ALL")."</option>
				<option value='CAMPDNC_ONLY_AND_CAMPLISTS_ALL'>"._QXZ("CAMPDNC_ONLY_AND_CAMPLISTS_ALL")."</option>
				<option value='INTERNALDNC_ONLY_AND_CAMPLISTS_ALL'>"._QXZ("INTERNALDNC_ONLY_AND_CAMPLISTS_ALL")."</option>
				<option value='DNC_AND_CAMPDNC_AND_CAMPLISTS_ALL'>"._QXZ("DNC_AND_CAMPDNC_AND_CAMPLISTS_ALL")."</option>
				<option value='DNC_AND_SYSTEM'>"._QXZ("DNC_AND_SYSTEM")."</option>
				<option value='CAMPDNC_ONLY_AND_SYSTEM'>"._QXZ("CAMPDNC_ONLY_AND_SYSTEM")."</option>
				<option value='INTERNALDNC_ONLY_AND_SYSTEM'>"._QXZ("INTERNALDNC_ONLY_AND_SYSTEM")."</option>
				<option value='DNC_AND_CAMPDNC_AND_SYSTEM'>"._QXZ("DNC_AND_CAMPDNC_AND_SYSTEM")."</option>
				<option value='NONE_WITH_ALT'>"._QXZ("NONE_WITH_ALT")."</option>
				<option value='DNC_ONLY_WITH_ALT'>"._QXZ("DNC_ONLY_WITH_ALT")."</option>
				<option value='CAMPDNC_ONLY_WITH_ALT'>"._QXZ("CAMPDNC_ONLY_WITH_ALT")."</option>
				<option value='INTERNALDNC_ONLY_WITH_ALT'>"._QXZ("INTERNALDNC_ONLY_WITH_ALT")."</option>
				<option value='DNC_AND_CAMPDNC_WITH_ALT'>"._QXZ("DNC_AND_CAMPDNC_WITH_ALT")."</option>
				<option value='CAMPLISTS_ONLY_WITH_ALT'>"._QXZ("CAMPLISTS_ONLY_WITH_ALT")."</option>
				<option value='CAMPLISTS_ALL_WITH_ALT'>"._QXZ("CAMPLISTS_ALL_WITH_ALT")."</option>
				<option value='SYSTEM_WITH_ALT'>"._QXZ("SYSTEM_WITH_ALT")."</option>
				<option value='DNC_AND_CAMPLISTS_WITH_ALT'>"._QXZ("DNC_AND_CAMPLISTS_WITH_ALT")."</option>
				<option value='CAMPDNC_ONLY_AND_CAMPLISTS_WITH_ALT'>"._QXZ("CAMPDNC_ONLY_AND_CAMPLISTS_WITH_ALT")."</option>
				<option value='INTERNALDNC_ONLY_AND_CAMPLISTS_WITH_ALT'>"._QXZ("INTERNALDNC_ONLY_AND_CAMPLISTS_WITH_ALT")."</option>
				<option value='DNC_AND_CAMPDNC_AND_CAMPLISTS_WITH_ALT'>"._QXZ("DNC_AND_CAMPDNC_AND_CAMPLISTS_WITH_ALT")."</option>
				<option value='DNC_AND_CAMPLISTS_ALL_WITH_ALT'>"._QXZ("DNC_AND_CAMPLISTS_ALL_WITH_ALT")."</option>
				<option value='CAMPDNC_ONLY_AND_CAMPLISTS_ALL_WITH_ALT'>"._QXZ("CAMPDNC_ONLY_AND_CAMPLISTS_ALL_WITH_ALT")."</option>
				<option value='INTERNALDNC_ONLY_AND_CAMPLISTS_ALL_WITH_ALT'>"._QXZ("INTERNALDNC_ONLY_AND_CAMPLISTS_ALL_WITH_ALT")."</option>
				<option value='DNC_AND_CAMPDNC_AND_CAMPLISTS_ALL_WITH_ALT'>"._QXZ("DNC_AND_CAMPDNC_AND_CAMPLISTS_ALL_WITH_ALT")."</option>
				<option value='DNC_AND_SYSTEM_WITH_ALT'>"._QXZ("DNC_AND_SYSTEM_WITH_ALT")."</option>
				<option value='CAMPDNC_ONLY_AND_SYSTEM_WITH_ALT'>"._QXZ("CAMPDNC_ONLY_AND_SYSTEM_WITH_ALT")."</option>
				<option value='INTERNALDNC_ONLY_AND_SYSTEM_WITH_ALT'>"._QXZ("INTERNALDNC_ONLY_AND_SYSTEM_WITH_ALT")."</option>
				<option value='DNC_AND_CAMPDNC_AND_SYSTEM_WITH_ALT'>"._QXZ("DNC_AND_CAMPDNC_AND_SYSTEM_WITH_ALT")."</option>
				<option value='NONE_WITH_ALT_ADDR3'>"._QXZ("NONE_WITH_ALT_ADDR3")."</option>
				<option value='DNC_ONLY_WITH_ALT_ADDR3'>"._QXZ("DNC_ONLY_WITH_ALT_ADDR3")."</option>
				<option value='CAMPDNC_ONLY_WITH_ALT_ADDR3'>"._QXZ("CAMPDNC_ONLY_WITH_ALT_ADDR3")."</option>
				<option value='INTERNALDNC_ONLY_WITH_ALT_ADDR3'>"._QXZ("INTERNALDNC_ONLY_WITH_ALT_ADDR3")."</option>
				<option value='DNC_AND_CAMPDNC_WITH_ALT_ADDR3'>"._QXZ("DNC_AND_CAMPDNC_WITH_ALT_ADDR3")."</option>
				<option value='CAMPLISTS_ONLY_WITH_ALT_ADDR3'>"._QXZ("CAMPLISTS_ONLY_WITH_ALT_ADDR3")."</option>
				<option value='CAMPLISTS_ALL_WITH_ALT_ADDR3'>"._QXZ("CAMPLISTS_ALL_WITH_ALT_ADDR3")."</option>
				<option value='SYSTEM_WITH_ALT_ADDR3'>"._QXZ("SYSTEM_WITH_ALT_ADDR3")."</option>
				<option value='DNC_AND_CAMPLISTS_WITH_ALT_ADDR3'>"._QXZ("DNC_AND_CAMPLISTS_WITH_ALT_ADDR3")."</option>
				<option value='CAMPDNC_ONLY_AND_CAMPLISTS_WITH_ALT_ADDR3'>"._QXZ("CAMPDNC_ONLY_AND_CAMPLISTS_WITH_ALT_ADDR3")."</option>
				<option value='INTERNALDNC_ONLY_AND_CAMPLISTS_WITH_ALT_ADDR3'>"._QXZ("INTERNALDNC_ONLY_AND_CAMPLISTS_WITH_ALT_ADDR3")."</option>
				<option value='DNC_AND_CAMPDNC_AND_CAMPLISTS_WITH_ALT_ADDR3'>"._QXZ("DNC_AND_CAMPDNC_AND_CAMPLISTS_WITH_ALT_ADDR3")."</option>
				<option value='DNC_AND_CAMPLISTS_ALL_WITH_ALT_ADDR3'>"._QXZ("DNC_AND_CAMPLISTS_ALL_WITH_ALT_ADDR3")."</option>
				<option value='CAMPDNC_ONLY_AND_CAMPLISTS_ALL_WITH_ALT_ADDR3'>"._QXZ("CAMPDNC_ONLY_AND_CAMPLISTS_ALL_WITH_ALT_ADDR3")."</option>
				<option value='INTERNALDNC_ONLY_AND_CAMPLISTS_ALL_WITH_ALT_ADDR3'>"._QXZ("INTERNALDNC_ONLY_AND_CAMPLISTS_ALL_WITH_ALT_ADDR3")."</option>
				<option value='DNC_AND_CAMPDNC_AND_CAMPLISTS_ALL_WITH_ALT_ADDR3'>"._QXZ("DNC_AND_CAMPDNC_AND_CAMPLISTS_ALL_WITH_ALT_ADDR3")."</option>
				<option value='DNC_AND_SYSTEM_WITH_ALT_ADDR3'>"._QXZ("DNC_AND_SYSTEM_WITH_ALT_ADDR3")."</option>
				<option value='CAMPDNC_ONLY_AND_SYSTEM_WITH_ALT_ADDR3'>"._QXZ("CAMPDNC_ONLY_AND_SYSTEM_WITH_ALT_ADDR3")."</option>
				<option value='INTERNALDNC_ONLY_AND_SYSTEM_WITH_ALT_ADDR3'>"._QXZ("INTERNALDNC_ONLY_AND_SYSTEM_WITH_ALT_ADDR3")."</option>
				<option value='DNC_AND_CAMPDNC_AND_SYSTEM_WITH_ALT_ADDR3'>"._QXZ("DNC_AND_CAMPDNC_AND_SYSTEM_WITH_ALT_ADDR3")."</option>
				<option value='CALLBACK'>"._QXZ("CALLBACK")."</option>
				<option value='DNC_AND_CALLBACK'>"._QXZ("DNC_AND_CALLBACK")."</option>
				<option value='CAMPDNC_ONLY_AND_CALLBACK'>"._QXZ("CAMPDNC_ONLY_AND_CALLBACK")."</option>
				<option value='INTERNALDNC_ONLY_AND_CALLBACK'>"._QXZ("INTERNALDNC_ONLY_AND_CALLBACK")."</option>
				<option value='DNC_AND_CAMPDNC_AND_CALLBACK'>"._QXZ("DNC_AND_CAMPDNC_AND_CALLBACK")."</option>
				<option value='NONE_WITH_ALT_AND_CALLBACK'>"._QXZ("NONE_WITH_ALT_AND_CALLBACK")."</option>
				<option value='DNC_ONLY_WITH_ALT_AND_CALLBACK'>"._QXZ("DNC_ONLY_WITH_ALT_AND_CALLBACK")."</option>
				<option value='CAMPDNC_ONLY_WITH_ALT_AND_CALLBACK'>"._QXZ("CAMPDNC_ONLY_WITH_ALT_AND_CALLBACK")."</option>
				<option value='INTERNALDNC_ONLY_WITH_ALT_AND_CALLBACK'>"._QXZ("INTERNALDNC_ONLY_WITH_ALT_AND_CALLBACK")."</option>
				<option value='DNC_AND_CAMPDNC_WITH_ALT_AND_CALLBACK'>"._QXZ("DNC_AND_CAMPDNC_WITH_ALT_AND_CALLBACK")."</option>
				<option value='NONE_WITH_ALT_ADDR3_AND_CALLBACK'>"._QXZ("NONE_WITH_ALT_ADDR3_AND_CALLBACK")."</option>
				<option value='DNC_ONLY_WITH_ALT_ADDR3_AND_CALLBACK'>"._QXZ("DNC_ONLY_WITH_ALT_ADDR3_AND_CALLBACK")."</option>
				<option value='CAMPDNC_ONLY_WITH_ALT_ADDR3_AND_CALLBACK'>"._QXZ("CAMPDNC_ONLY_WITH_ALT_ADDR3_AND_CALLBACK")."</option>
				<option value='INTERNALDNC_ONLY_WITH_ALT_ADDR3_AND_CALLBACK'>"._QXZ("INTERNALDNC_ONLY_WITH_ALT_ADDR3_AND_CALLBACK")."</option>
				<option value='DNC_AND_CAMPDNC_WITH_ALT_ADDR3_AND_CALLBACK'>"._QXZ("DNC_AND_CAMPDNC_WITH_ALT_ADDR3_AND_CALLBACK")."</option>
				<option value='$manual_dial_filter' SELECTED>"._QXZ("$manual_dial_filter")."</option>
				</select>$NWB#users-manual_dial_filter$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Manual Dial by Lead ID Override").": </td><td align=left><select size=1 name=manual_dial_lead_id><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='ONLY'>"._QXZ("ONLY")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$manual_dial_lead_id' SELECTED>"._QXZ("$manual_dial_lead_id")."</option></select>$NWB#users-manual_dial_lead_id$NWE</td></tr>\n";

				if ($SSallow_emails > 0) {
					echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Call Email").": </td><td align=left><select size=1 name=agentcall_email><option>0</option><option>1</option><option SELECTED>$agentcall_email</option></select>$NWB#users-agentcall_email$NWE</td></tr>\n";
					}
				else
					{
					echo "<tr bgcolor=#$SSstd_row4_background><td align=right></td><td align=left><input type=hidden name=agentcall_email value=$agentcall_email></td></tr>\n";
					}
				if ($SSallow_chats > 0) {
					echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Call Chat").": </td><td align=left><select size=1 name=agentcall_chat><option>0</option><option>1</option><option SELECTED>$agentcall_chat</option></select>$NWB#users-agentcall_chat$NWE</td></tr>\n";
					}
				else
					{
					echo "<tr bgcolor=#$SSstd_row4_background><td align=right></td><td align=left><input type=hidden name=agentcall_chat value=$agentcall_chat></td></tr>\n";
					}
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Recording").": </td><td align=left><select size=1 name=vicidial_recording><option>0</option><option>1</option><option SELECTED>$vicidial_recording</option></select>$NWB#users-agent_recording$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Transfers").": </td><td align=left><select size=1 name=vicidial_transfers><option>0</option><option>1</option><option SELECTED>$vicidial_transfers</option></select>$NWB#users-agent_transfers$NWE</td></tr>\n";
				if ($SSoutbound_autodial_active > 0)
					{
					echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Closer Default Blended").": </td><td align=left><select size=1 name=closer_default_blended><option>0</option><option>1</option><option SELECTED>$closer_default_blended</option></select>$NWB#users-closer_default_blended$NWE</td></tr>\n";
					}
				if ($SSenable_languages > 0)
					{
					echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User Choose Language").": </td><td align=left><select size=1 name=user_choose_language><option>0</option><option>1</option><option SELECTED>$user_choose_language</option></select>$NWB#users-user_choose_language$NWE</td></tr>\n";
					echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Selected Language").": </td><td align=left><select size=1 name=selected_language><option value=\"default English\">"._QXZ("default English")."</option>\n";
					$stmt="SELECT language_id,language_description from vicidial_languages where active='Y' $LOGadmin_viewable_groupsSQL order by language_id;";
					$rslt=mysql_to_mysqli($stmt, $link);
					$languages_to_print = mysqli_num_rows($rslt);
					$languages_list='';
					$o=0;
					while ($languages_to_print > $o) 
						{
						$rowx=mysqli_fetch_row($rslt);
						$languages_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
						$o++;
						}
					echo "$languages_list";
					echo "<option SELECTED>$selected_language</option></select>$NWB#users-selected_language$NWE</td></tr>\n";
					}
				else
					{
					echo "<tr bgcolor=#$SSstd_row4_background><td align=right></td><td align=left><input type=hidden name=user_choose_language value=$user_choose_language><input type=hidden name=selected_language value=\"$selected_language\"></td></tr>\n";
					}
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Recording Override").": </td><td align=left><select size=1 name=vicidial_recording_override><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='NEVER'>"._QXZ("NEVER")."</option><option value='ONDEMAND'>"._QXZ("ONDEMAND")."</option><option value='ALLCALLS'>"._QXZ("ALLCALLS")."</option><option value='ALLFORCE'>"._QXZ("ALLFORCE")."</option><option value='$vicidial_recording_override' SELECTED>"._QXZ("$vicidial_recording_override")."</option></select>$NWB#users-agent_recording_override$NWE</td></tr>\n";

				if ($SSmute_recordings > 0)
					{
					echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Mute Recordings Override").": </td><td align=left><select size=1 name=mute_recordings><option value=\"DISABLED\">"._QXZ("DISABLED")."</option><option value=\"Y\">"._QXZ("Y")."</option><option value=\"N\">"._QXZ("N")."</option><option SELECTED value=\"$mute_recordings\">"._QXZ("$mute_recordings")."</option></select>$NWB#users-mute_recordings$NWE</td></tr>\n";
					}
				else
					{
					echo "<tr bgcolor=#$SSstd_row4_background><td colspan=2><input type=hidden name=mute_recordings value=\"$mute_recordings\"></td></tr>\n";
					}

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Alter Customer Data Override").": </td><td align=left><select size=1 name=alter_custdata_override><option value='NOT_ACTIVE'>"._QXZ("NOT_ACTIVE")."</option><option value='ALLOW_ALTER'>"._QXZ("ALLOW_ALTER")."</option><option value='$alter_custdata_override'  SELECTED>"._QXZ("$alter_custdata_override")."</option></select>$NWB#users-alter_custdata_override$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Alter Customer Phone Override").": </td><td align=left><select size=1 name=alter_custphone_override><option value='NOT_ACTIVE'>"._QXZ("NOT_ACTIVE")."</option><option value='ALLOW_ALTER'>"._QXZ("ALLOW_ALTER")."</option><option value='$alter_custphone_override' SELECTED>"._QXZ("$alter_custphone_override")."</option></select>$NWB#users-alter_custphone_override$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Shift Enforcement Override").": </td><td align=left><select size=1 name=agent_shift_enforcement_override><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='OFF'>"._QXZ("OFF")."</option><option value='START'>"._QXZ("START")."</option><option value='ALL'>"._QXZ("ALL")."</option><option value='$agent_shift_enforcement_override' SELECTED>"._QXZ("$agent_shift_enforcement_override")."</option></select>$NWB#users-agent_shift_enforcement_override$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Call Log View Override").": </td><td align=left><select size=1 name=agent_call_log_view_override><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$agent_call_log_view_override' SELECTED>"._QXZ("$agent_call_log_view_override")."</option></select>$NWB#users-agent_call_log_view_override$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign Hide Call Log Override").": </td><td align=left><select size=1 name=hide_call_log_info><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='SHOW_1'>"._QXZ("SHOW")."_1</option><option value='SHOW_2'>"._QXZ("SHOW")."_2</option><option value='SHOW_3'>"._QXZ("SHOW")."_3</option><option value='SHOW_4'>"._QXZ("SHOW")."_4</option><option value='SHOW_5'>"._QXZ("SHOW")."_5</option><option value='SHOW_6'>"._QXZ("SHOW")."_6</option><option value='SHOW_7'>"._QXZ("SHOW")."_7</option><option value='SHOW_8'>"._QXZ("SHOW")."_8</option><option value='SHOW_9'>"._QXZ("SHOW")."_9</option><option value='SHOW_10'>"._QXZ("SHOW")."_10</option><option value='$hide_call_log_info' SELECTED>"._QXZ("$hide_call_log_info")."</option></select>$NWB#users-hide_call_log_info$NWE</td></tr>\n";
				
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Lead Search Override").": </td><td align=left><select size=1 name=agent_lead_search><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='LIVE_CALL_INBOUND'>"._QXZ("LIVE_CALL_INBOUND")."</option><option value='LIVE_CALL_INBOUND_AND_MANUAL'>"._QXZ("LIVE_CALL_INBOUND_AND_MANUAL")."</option><option value='NOT_ACTIVE'>"._QXZ("NOT_ACTIVE")."</option><option value='$agent_lead_search_override' SELECTED>"._QXZ("$agent_lead_search_override")."</option></select>$NWB#users-agent_lead_search_override$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=31111111&lead_filter_id=$lead_filter_id\">"._QXZ("Lead Filter")."</a>: </td><td align=left>";
				echo "<select size=1 name=lead_filter_id>\n";
				echo "$filters_list";
				echo "<option selected value=\"$lead_filter_id\">".(preg_match('/^NONE$/', $lead_filter_id) ? _QXZ("$lead_filter_id") : $lead_filter_id)." - $filtername_list[$lead_filter_id]</option>\n";
				echo "</select>$NWB#users-lead_filter_id$NWE <i>"._QXZ("only enabled with no-hopper manual dialing")."</i>";
				echo "</td></tr>\n";

				if ($SSuser_hide_realtime_enabled > 0)
					{
					$red_enabledBEGIN='';   $red_enabledEND='';
					if ($user_hide_realtime > 0)
						{$red_enabledBEGIN='<font color=red><B>';   $red_enabledEND='</B></font>';}
					echo "<tr bgcolor=#$SSstd_row4_background><td align=right>$red_enabledBEGIN"._QXZ("User Hide in RealTime").": $red_enabledEND</td><td align=left><select size=1 name=user_hide_realtime><option>0</option><option>1</option><option SELECTED>$user_hide_realtime</option></select>$NWB#users-user_hide_realtime$NWE</td></tr>\n";
					}
				else
					{
					echo "<tr bgcolor=#$SSstd_row4_background><td colspan=2><input type=hidden name=user_hide_realtime value=\"$user_hide_realtime\"></td></tr>\n";
					}

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Alert Enabled").": </td><td align=left>$alert_enabled $NWB#users-alert_enabled$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Allow Alerts").": </td><td align=left><select size=1 name=allow_alerts><option>0</option><option>1</option><option SELECTED>$allow_alerts</option></select>$NWB#users-allow_alerts$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Preset Contact Search").": </td><td align=left><select size=1 name=preset_contact_search><option value='NOT_ACTIVE'>"._QXZ("NOT_ACTIVE")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option SELECTED value='$preset_contact_search'>"._QXZ("$preset_contact_search")."</option></select>$NWB#users-preset_contact_search$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Max Inbound Calls").": </td><td align=left><input type=text name=max_inbound_calls size=6 maxlength=5 value=\"$max_inbound_calls\">$NWB#users-max_inbound_calls$NWE &nbsp; &nbsp; <i>"._QXZ("inbound calls today").": $USER_inbound_calls_today</i></td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Max Inbound Calls Filtering Enabled").": </td><td align=left><select size=1 name=max_inbound_filter_enabled><option>0</option><option>1</option><option SELECTED>$max_inbound_filter_enabled</option></select>$NWB#users-max_inbound_filter_enabled$NWE &nbsp; &nbsp; <i>"._QXZ("inbound filtered calls today").": $USER_inbound_calls_today_filtered</i></td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=center valign=top colspan=2>"._QXZ("Max Inbound Calls Filtering Options").": </td></tr>\n";
				echo "<tr><td colspan=2 align=right><table border=0 cellspacing=3><tr>";

				echo "<td align=left>"._QXZ("Filter Statuses").":$NWB#users-max_inbound_filter_statuses$NWE &nbsp; <br>";
				echo "<select MULTIPLE size=6 name=max_inbound_filter_statuses[]>";
				$max_inbound_filter_statuses_ARY = explode(',',$max_inbound_filter_statuses);
				$max_inbound_filter_statuses_ct = count($max_inbound_filter_statuses_ARY);
				##### get status listings for dynamic pulldown
				$stmt="SELECT distinct(status) from vicidial_statuses where status NOT IN('QUEUE','INCALL') order by status";
				$rslt=mysql_to_mysqli($stmt, $link);
				$statuses_to_print = mysqli_num_rows($rslt);
				$o=0;
				while ($statuses_to_print > $o) 
					{
					$rowx=mysqli_fetch_row($rslt);
					$b=0;
					$field_selected='';
					while ($b < $max_inbound_filter_statuses_ct)
						{
						trim($max_inbound_filter_statuses_ARY[$b]);
						if ($max_inbound_filter_statuses_ARY[$b] === $rowx[0])
							{
							$field_selected = 'SELECTED';
							echo "<option value=\"$rowx[0]\" $field_selected>$rowx[0]</option>\n";
							}
						$b++;
						}
					if (strlen($field_selected) < 5) {echo "<option value=\"$rowx[0]\" >$rowx[0]</option>\n";}
					$o++;
					}
				$stmt="SELECT distinct(status),status_name from vicidial_campaign_statuses $whereLOGallowed_campaignsSQL order by status;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$Cstatuses_to_print = mysqli_num_rows($rslt);
				$o=0;
				while ($Cstatuses_to_print > $o) 
					{
					$rowx=mysqli_fetch_row($rslt);
					$b=0;
					$field_selected='';
					while ($b < $max_inbound_filter_statuses_ct)
						{
						trim($max_inbound_filter_statuses_ARY[$b]);
						if ($max_inbound_filter_statuses_ARY[$b] === $rowx[0])
							{
							$field_selected = 'SELECTED';
							echo "<option value=\"$rowx[0]\" $field_selected>$rowx[0]</option>\n";
							}
						$b++;
						}
					if (strlen($field_selected) < 5) {echo "<option value=\"$rowx[0]\" >$rowx[0]</option>\n";}
					$o++;
					}
				echo "</select></td>\n";

				echo "<td align=left>"._QXZ("Filter In-Groups").":$NWB#users-max_inbound_filter_ingroups$NWE &nbsp; <br>";
				echo "<select MULTIPLE size=6 name=max_inbound_filter_ingroups[]>";
				$max_inbound_filter_ingroups_ARY = explode(',',$max_inbound_filter_ingroups);
				$max_inbound_filter_ingroups_ct = count($max_inbound_filter_ingroups_ARY);
				##### get status listings for dynamic pulldown
				$stmt="SELECT group_id,group_name from vicidial_inbound_groups order by group_id;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$ingroups_to_print = mysqli_num_rows($rslt);
				$o=0;
				while ($ingroups_to_print > $o) 
					{
					$rowx=mysqli_fetch_row($rslt);
					$b=0;
					$field_selected='';
					while ($b < $max_inbound_filter_ingroups_ct)
						{
						trim($max_inbound_filter_ingroups_ARY[$b]);
						if ($max_inbound_filter_ingroups_ARY[$b] === $rowx[0])
							{
							$field_selected = 'SELECTED';
							echo "<option value=\"$rowx[0]\" $field_selected>$rowx[0] - $rowx[1]</option>\n";
							}
						$b++;
						}
					if (strlen($field_selected) < 5) {echo "<option value=\"$rowx[0]\" >$rowx[0] - $rowx[1]</option>\n";}
					$o++;
					}
				echo "</select></td>\n";

				echo "<td align=center width=80>"._QXZ("Filter Minimum Seconds").":$NWB#users-max_inbound_filter_min_sec$NWE &nbsp; <br>";
				echo "<input type=text name=max_inbound_filter_min_sec size=6 maxlength=5 value=\"$max_inbound_filter_min_sec\"></td></tr></table></td></tr>\n";

				if ($SSinbound_credits > 0)
					{
					$ICC_triggered='';
					if ($inbound_credits == '0') {$ICC_triggered = " &nbsp; &nbsp; <b><font color=red>"._QXZ("Inbound Calls Credits Zero Balance")."</font></b>";}
					echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Inbound Calls Credits").": </td><td align=left><input type=text name=inbound_credits size=7 maxlength=6 value=\"$inbound_credits\">$NWB#users-inbound_credits$NWE$ICC_triggered</td></tr>\n";
					}
				else
					{
					echo "<tr bgcolor=#$SSstd_row4_background><td colspan=2><input type=hidden name=inbound_credits value=\"$inbound_credits\"></td></tr>\n";
					}

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Max Manual Dial Hopper Calls").": </td><td align=left><input type=text name=max_hopper_calls size=6 maxlength=5 value=\"$max_hopper_calls\">$NWB#users-max_hopper_calls$NWE &nbsp; &nbsp; <i>"._QXZ("hopper calls today").": $USER_hopper_calls_today</i></td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Max Manual Dial Hopper Calls Per Hour").": </td><td align=left><input type=text name=max_hopper_calls_hour size=6 maxlength=5 value=\"$max_hopper_calls_hour\">$NWB#users-max_hopper_calls_hour$NWE &nbsp; &nbsp; <i>"._QXZ("hopper calls this hour").": $USER_hopper_calls_hour</i></td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Wrap Seconds Override").": </td><td align=left><input type=text name=wrapup_seconds_override size=6 maxlength=5 value=\"$wrapup_seconds_override\">$NWB#users-wrapup_seconds_override$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Ready Max Logout Override").": </td><td align=left><input type=text name=ready_max_logout size=7 maxlength=6 value=\"$ready_max_logout\">$NWB#users-ready_max_logout$NWE</td></tr>\n";

				### BEGIN get status group listings for dynamic pulldown menu ###
				$stmt="SELECT status_group_id,status_group_notes from vicidial_status_groups $whereLOGadmin_viewable_groupsSQL order by status_group_id;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$status_groups_to_print = mysqli_num_rows($rslt);
				$status_groups_menu='';
				$status_groups_selected=0;
				$o=0;
				while ($status_groups_to_print > $o) 
					{
					$rowx=mysqli_fetch_row($rslt);
					$status_groups_menu .= "<option ";
					if ($status_group_id == "$rowx[0]") 
						{
						$status_groups_menu .= "SELECTED ";
						$status_groups_selected++;
						}
					$status_groups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
					$o++;
					}
				$sglinkB='';   $sglinkE='';
				if (strlen($status_group_id)>1)
					{
					$sglinkB="<a href=\"$PHP_SELF?ADD=393111111111&status_group_id=$status_group_id\">";
					$sglinkE='</a>';
					}

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>$sglinkB"._QXZ("Additional Status Group")."$sglinkE: </td><td align=left><select size=1 name=status_group_id>";
				echo "<option value=\"\">"._QXZ("NONE")."</option>";
				echo "$status_groups_menu";
				echo "</select>$NWB#users-status_group_id$NWE</td></tr>\n";
				### END get status group listings for dynamic pulldown menu ###


				if (strlen($campaign_js_rank) < 2) {$campaign_js_rank="''";}
				if (strlen($campaign_js_grade) < 2) {$campaign_js_grade="''";}
				if (strlen($ingroup_js_rank) < 2) {$ingroup_js_rank="''";}
				if (strlen($ingroup_js_grade) < 2) {$ingroup_js_grade="''";}
				echo "<script language=\"JavaScript\">\n";
				echo "ARYcampaign_js_rank = new Array($campaign_js_rank);\n";
				echo "ARYcampaign_js_grade = new Array($campaign_js_grade);\n";
				echo "ARYingroup_js_rank = new Array($ingroup_js_rank);\n";
				echo "ARYingroup_js_grade = new Array($ingroup_js_grade);\n";
				echo "var campaign_js_rank_ct = '$campaign_js_rank_ct';\n";
				echo "var campaign_js_grade_ct = '$campaign_js_grade_ct';\n";
				echo "var ingroup_js_rank_ct = '$ingroup_js_rank_ct';\n";
				echo "var ingroup_js_grade_ct = '$ingroup_js_grade_ct';\n";
				echo "\n";
				echo "function campaign_rank_val_change()\n";
				echo "	{\n";
				echo "	var camp_rank_select = document.getElementById(\"campaign_js_rank_select\");\n";
				echo "	var camp_rank_selected = camp_rank_select.value\n";
				echo "	if (camp_rank_selected.length > 0)\n";
				echo "		{\n";
				echo "		var loop_ct=0;\n";
				echo "		while(loop_ct < campaign_js_rank_ct)\n";
				echo "			{\n";
				echo "			document.getElementById(ARYcampaign_js_rank[loop_ct]).value = camp_rank_selected;\n";
				echo "			loop_ct++;\n";
				echo "			}\n";
				echo "		}\n";
				echo "	}\n";
				echo "function campaign_grade_val_change()\n";
				echo "	{\n";
				echo "	var camp_grade_select = document.getElementById(\"campaign_js_grade_select\");\n";
				echo "	var camp_grade_selected = camp_grade_select.value\n";
				echo "	if (camp_grade_selected.length > 0)\n";
				echo "		{\n";
				echo "		var loop_ct=0;\n";
				echo "		while(loop_ct < campaign_js_grade_ct)\n";
				echo "			{\n";
				echo "			document.getElementById(ARYcampaign_js_grade[loop_ct]).value = camp_grade_selected;\n";
				echo "			loop_ct++;\n";
				echo "			}\n";
				echo "		}\n";
				echo "	}\n";
				echo "function ingroup_rank_val_change()\n";
				echo "	{\n";
				echo "	var camp_rank_select = document.getElementById(\"ingroup_js_rank_select\");\n";
				echo "	var camp_rank_selected = camp_rank_select.value\n";
				echo "	if (camp_rank_selected.length > 0)\n";
				echo "		{\n";
				echo "		var loop_ct=0;\n";
				echo "		while(loop_ct < ingroup_js_rank_ct)\n";
				echo "			{\n";
				echo "			document.getElementById(ARYingroup_js_rank[loop_ct]).value = camp_rank_selected;\n";
				echo "			loop_ct++;\n";
				echo "			}\n";
				echo "		}\n";
				echo "	}\n";
				echo "function ingroup_grade_val_change()\n";
				echo "	{\n";
				echo "	var camp_grade_select = document.getElementById(\"ingroup_js_grade_select\");\n";
				echo "	var camp_grade_selected = camp_grade_select.value\n";
				echo "	if (camp_grade_selected.length > 0)\n";
				echo "		{\n";
				echo "		var loop_ct=0;\n";
				echo "		while(loop_ct < ingroup_js_grade_ct)\n";
				echo "			{\n";
				echo "			document.getElementById(ARYingroup_js_grade[loop_ct]).value = camp_grade_selected;\n";
				echo "			loop_ct++;\n";
				echo "			}\n";
				echo "		}\n";
				echo "	}\n";
				echo "</script>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>"._QXZ("Campaign Ranks").": $NWB#users-campaign_ranks$NWE<BR>\n";
				echo "<table border=0 width=850>\n";
				echo "$RANKcampaigns_list";
				echo "</table>\n";
				echo "</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>"._QXZ("Inbound Groups").": $NWB#users-closer_campaigns$NWE<BR>\n";
				echo "<table border=0 width=950>\n";
				echo "$RANKgroups_list";
				echo "</table>\n";
				echo "</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom")." 1: </td><td align=left><input type=text name=custom_one size=50 maxlength=100 value=\"$user_custom_one\">$NWB#users-custom_one$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom")." 2: </td><td align=left><input type=text name=custom_two size=50 maxlength=100 value=\"$user_custom_two\">$NWB#users-custom_one$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom")." 3: </td><td align=left><input type=text name=custom_three size=50 maxlength=100 value=\"$user_custom_three\">$NWB#users-custom_one$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom")." 4: </td><td align=left><input type=text name=custom_four size=50 maxlength=100 value=\"$user_custom_four\">$NWB#users-custom_one$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom")." 5: </td><td align=left><input type=text name=custom_five size=50 maxlength=100 value=\"$user_custom_five\">$NWB#users-custom_one$NWE</td></tr>\n";

				if ($SSqc_features_active > 0)
					{
					echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("QC Enabled").": </td><td align=left><select size=1 name=qc_enabled><option>0</option><option>1</option><option SELECTED>$qc_enabled</option></select>$NWB#users-qc_enabled$NWE</td></tr>\n";
					echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("QC User Level").": </td><td align=left><select size=1 name=qc_user_level><option value=1>1 - "._QXZ("Modify Nothing")."</option><option value=2>2 - "._QXZ("Modify Nothing Except Status")."</option><option value=3>3 - "._QXZ("Modify All Fields")."</option><option value=4>4 - "._QXZ("Verify First Round of QC")."</option><option value=5>5 - "._QXZ("View QC Statistics")."</option><option value=6>6 - "._QXZ("Ability to Modify FINISHed records")."</option><option value=7>7 - "._QXZ("Manager Level")."</option><option SELECTED>$qc_user_level</option></select>$NWB#users-qc_user_level$NWE</td></tr>\n";
					echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("QC Pass").": </td><td align=left><select size=1 name=qc_pass><option>0</option><option>1</option><option SELECTED>$qc_pass</option></select>$NWB#users-qc_pass$NWE</td></tr>\n";
					echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("QC Finish").": </td><td align=left><select size=1 name=qc_finish><option>0</option><option>1</option><option SELECTED>$qc_finish</option></select>$NWB#users-qc_finish$NWE</td></tr>\n";
					echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("QC Commit").": </td><td align=left><select size=1 name=qc_commit><option>0</option><option>1</option><option SELECTED>$qc_commit</option></select>$NWB#users-qc_commit$NWE</td></tr>\n";
					}
				else
					{
					echo "<tr bgcolor=#$SSstd_row1_background><td align=right>";
					echo "<input type=hidden name=qc_enabled value=\"$qc_enabled\">";
					echo "<input type=hidden name=qc_user_level value=\"$qc_user_level\">";
					echo "<input type=hidden name=qc_pass value=\"$qc_pass\">";
					echo "<input type=hidden name=qc_finish value=\"$qc_finish\">";
					echo "<input type=hidden name=qc_commit value=\"$qc_commit\">";
					echo "</td></tr>\n";
					}

				if ($SShopper_hold_inserts > 0)
					{
					echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("HCI Enabled").": </td><td align=left><select size=1 name=hci_enabled><option>0</option><option>1</option>";
					if ($SShopper_hold_inserts > 1)
						{
						echo "<option>2</option>";
						}
					echo "<option SELECTED>$hci_enabled</option></select>$NWB#users-hci_enabled$NWE</td></tr>\n";

					}
				else
					{
					echo "<tr bgcolor=#$SSstd_row1_background><td align=right>";
					echo "<input type=hidden name=hci_enabled value=\"$hci_enabled\">";
					echo "</td></tr>\n";
					}

				}
			if ( ($LOGuser_level > 8) and ($LOGalter_admin_interface > 0) )
				{
				echo "<tr bgcolor=#$SSmenu_background><td colspan=2 align=center><font color=white><B>"._QXZ("ADMIN REPORT OPTIONS").":</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Realtime Block User Info").": </td><td align=left><select size=1 name=realtime_block_user_info><option>0</option><option>1</option><option SELECTED>$realtime_block_user_info</option></select>$NWB#users-realtime_block_user_info$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Admin Hide Lead Data").": </td><td align=left><select size=1 name=admin_hide_lead_data><option>0</option><option>1</option><option SELECTED>$admin_hide_lead_data</option></select>$NWB#users-admin_hide_lead_data$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Admin Hide Phone Data").": </td><td align=left><select size=1 name=admin_hide_phone_data><option>0</option><option>1</option><option value='2_DIGITS'>"._QXZ("2_DIGITS")."</option><option value='3_DIGITS'>"._QXZ("3_DIGITS")."</option><option value='4_DIGITS'>"._QXZ("4_DIGITS")."</option><option SELECTED>$admin_hide_phone_data</option></select>$NWB#users-admin_hide_phone_data$NWE</td></tr>\n";

				if ( (preg_match('/\-ALL/i', $LOGallowed_campaigns)) )
					{
					echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Search Lead Ignore Group Restrictions").": </td><td align=left><select size=1 name=ignore_group_on_search><option>0</option><option>1</option><option SELECTED>$ignore_group_on_search</option></select>$NWB#users-ignore_group_on_search$NWE</td></tr>\n";
					}
				else
					{
					echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Search Lead Ignore Group Restrictions").": </td><td align=left><input type=hidden name=ignore_group_on_search value=\"$ignore_group_on_search\"> $ignore_group_on_search $NWB#users-ignore_group_on_search$NWE</td></tr>\n";
					}

				if ($SSuser_admin_redirect > 0)
					{
					echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("User Admin Redirect URL").": </td><td align=left><input type=text name=user_admin_redirect_url size=70 maxlength=5000 value=\"$user_admin_redirect_url\">$NWB#users-user_admin_redirect_url$NWE</td></tr>\n";
					}
				else
					{
					echo "<tr bgcolor=#$SSstd_row1_background><td align=right></td><td align=left><input type=hidden name=user_admin_redirect_url value=\"$user_admin_redirect_url\"></td></tr>\n";
					}

				echo "<tr bgcolor=#$SSmenu_background><td colspan=2 align=center><font color=white><B>"._QXZ("ADMIN INTERFACE OPTIONS").":</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("View Reports").": </td><td align=left><select size=1 name=view_reports><option>0</option><option>1</option><option SELECTED>$view_reports</option></select>$NWB#users-view_reports$NWE</td></tr>\n";

				if ($SSlog_recording_access > 0)
					{
					echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Access Recordings").": </td><td align=left><select size=1 name=access_recordings><option>0</option><option>1</option><option SELECTED>$access_recordings</option></select>$NWB#users-access_recordings$NWE</td></tr>\n";
					}
				else
					{
					echo "<tr bgcolor=#$SSstd_row1_background><td align=right></td><td align=left><input type=hidden name=access_recordings value=\"$access_recordings\"></td></tr>\n";
					}
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Alter Agent Interface Options").": </td><td align=left><select size=1 name=alter_agent_interface_options><option>0</option><option>1</option><option SELECTED>$alter_agent_interface_options</option></select>$NWB#users-alter_agent_interface_options$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify Users").": </td><td align=left><select size=1 name=modify_users><option>0</option><option>1</option><option SELECTED>$modify_users</option></select>$NWB#users-modify_sections$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Change Agent Campaign").": </td><td align=left><select size=1 name=change_agent_campaign><option>0</option><option>1</option><option SELECTED>$change_agent_campaign</option></select>$NWB#users-change_agent_campaign$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Delete Users").": </td><td align=left><select size=1 name=delete_users><option>0</option><option>1</option><option SELECTED>$delete_users</option></select>$NWB#users-delete_users$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Modify User Groups").": </td><td align=left><select size=1 name=modify_usergroups><option>0</option><option>1</option><option SELECTED>$modify_usergroups</option></select>$NWB#users-modify_sections$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Delete User Groups").": </td><td align=left><select size=1 name=delete_user_groups><option>0</option><option>1</option><option SELECTED>$delete_user_groups</option></select>$NWB#users-delete_user_groups$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify Lists").": </td><td align=left><select size=1 name=modify_lists><option>0</option><option>1</option><option SELECTED>$modify_lists</option></select>$NWB#users-modify_sections$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Delete Lists").": </td><td align=left><select size=1 name=delete_lists><option>0</option><option>1</option><option SELECTED>$delete_lists</option></select>$NWB#users-delete_lists$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Load Leads").": </td><td align=left><select size=1 name=load_leads><option>0</option><option>1</option><option SELECTED>$load_leads</option></select>$NWB#users-load_leads$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify Leads").": </td><td align=left><select size=1 name=modify_leads><option>0</option><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option SELECTED>$modify_leads</option></select>$NWB#users-modify_leads$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("GDPR-Compliant Export Delete Leads").": </td><td align=left><select size=1 name=export_gdpr_leads>";
				for ($i=0; $i<=$SSenable_gdpr_download_deletion; $i++) 
					{
					echo "<option>$i</option>";
					}
				echo "<option SELECTED>$export_gdpr_leads</option></select>$NWB#users-export_gdpr_leads$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Download Lists").": </td><td align=left><select size=1 name=download_lists><option>0</option><option>1</option><option SELECTED>$download_lists</option></select>$NWB#users-download_lists$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Export Reports").": </td><td align=left><select size=1 name=export_reports><option>0</option><option>1</option><option SELECTED>$export_reports</option></select>$NWB#users-export_reports$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Delete From DNC Lists").": </td><td align=left><select size=1 name=delete_from_dnc><option>0</option><option>1</option><option SELECTED>$delete_from_dnc</option></select>$NWB#users-delete_from_dnc$NWE</td></tr>\n";

				if ($SScustom_fields_enabled > 0)
					{
					echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Custom Fields Modify").": </td><td align=left><select size=1 name=custom_fields_modify><option>0</option><option>1</option><option SELECTED>$custom_fields_modify</option></select>$NWB#users-custom_fields_modify$NWE</td></tr>\n";
					}

				echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Modify Campaigns").": </td><td align=left><select size=1 name=modify_campaigns><option>0</option><option>1</option><option SELECTED>$modify_campaigns</option></select>$NWB#users-modify_sections$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Campaign Detail").": </td><td align=left><select size=1 name=campaign_detail><option>0</option><option>1</option><option SELECTED>$campaign_detail</option></select>$NWB#users-campaign_detail$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Modify Campaign Dial Prefix").": </td><td align=left><select size=1 name=modify_dial_prefix><option>0</option><option>1</option><option SELECTED>$modify_dial_prefix</option></select>$NWB#users-modify_dial_prefix$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Delete Campaigns").": </td><td align=left><select size=1 name=delete_campaigns><option>0</option><option>1</option><option SELECTED>$delete_campaigns</option></select>$NWB#users-delete_campaigns$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify In-Groups").": </td><td align=left><select size=1 name=modify_ingroups><option>0</option><option>1</option><option SELECTED>$modify_ingroups</option></select>$NWB#users-modify_sections$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Delete In-Groups").": </td><td align=left><select size=1 name=delete_ingroups><option>0</option><option>1</option><option SELECTED>$delete_ingroups</option></select>$NWB#users-delete_ingroups$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify DIDs").": </td><td align=left><select size=1 name=modify_inbound_dids><option>0</option><option>1</option><option SELECTED>$modify_inbound_dids</option></select>$NWB#users-modify_sections$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Delete DIDs").": </td><td align=left><select size=1 name=delete_inbound_dids><option>0</option><option>1</option><option SELECTED>$delete_inbound_dids</option></select>$NWB#users-delete_ingroups$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify Custom Dialplans").": </td><td align=left><select size=1 name=modify_custom_dialplans><option>0</option><option>1</option><option SELECTED>$modify_custom_dialplans</option></select>$NWB#users-modify_custom_dialplans$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Modify Remote Agents").": </td><td align=left><select size=1 name=modify_remoteagents><option>0</option><option>1</option><option SELECTED>$modify_remoteagents</option></select>$NWB#users-modify_sections$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Delete Remote Agents").": </td><td align=left><select size=1 name=delete_remote_agents><option>0</option><option>1</option><option SELECTED>$delete_remote_agents</option></select>$NWB#users-delete_remote_agents$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify Scripts").": </td><td align=left><select size=1 name=modify_scripts><option>0</option><option>1</option><option SELECTED>$modify_scripts</option></select>$NWB#users-modify_sections$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Delete Scripts").": </td><td align=left><select size=1 name=delete_scripts><option>0</option><option>1</option><option SELECTED>$delete_scripts</option></select>$NWB#users-delete_scripts$NWE</td></tr>\n";

				if ($SSoutbound_autodial_active > 0)
					{
					echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Modify Filters").": </td><td align=left><select size=1 name=modify_filters><option>0</option><option>1</option><option SELECTED>$modify_filters</option></select>$NWB#users-modify_sections$NWE</td></tr>\n";
					echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Delete Filters").": </td><td align=left><select size=1 name=delete_filters><option>0</option><option>1</option><option SELECTED>$delete_filters</option></select>$NWB#users-delete_filters$NWE</td></tr>\n";
					}
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("AGC Admin Access").": </td><td align=left><select size=1 name=ast_admin_access><option>0</option><option>1</option><option SELECTED>$ast_admin_access</option></select>$NWB#users-ast_admin_access$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("AGC Delete Phones").": </td><td align=left><select size=1 name=ast_delete_phones><option>0</option><option>1</option><option SELECTED>$ast_delete_phones</option></select>$NWB#users-ast_delete_phones$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify Call Times").": </td><td align=left><select size=1 name=modify_call_times><option>0</option><option>1</option><option SELECTED>$modify_call_times</option></select>$NWB#users-modify_call_times$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Delete Call Times").": </td><td align=left><select size=1 name=delete_call_times><option>0</option><option>1</option><option SELECTED>$delete_call_times</option></select>$NWB#users-delete_call_times$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify Servers").": </td><td align=left><select size=1 name=modify_servers><option>0</option><option>1</option><option SELECTED>$modify_servers</option></select>$NWB#users-modify_servers$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify Shifts").": </td><td align=left><select size=1 name=modify_shifts><option>0</option><option>1</option><option SELECTED>$modify_shifts</option></select>$NWB#users-modify_sections$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify Phones").": </td><td align=left><select size=1 name=modify_phones><option>0</option><option>1</option><option SELECTED>$modify_phones</option></select>$NWB#users-modify_phones$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify Carriers").": </td><td align=left><select size=1 name=modify_carriers><option>0</option><option>1</option><option SELECTED>$modify_carriers</option></select>$NWB#users-modify_sections$NWE</td></tr>\n";
				if ($SSallow_emails > 0) 
					{
					echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify Email Accounts").": </td><td align=left><select size=1 name=modify_email_accounts><option>0</option><option>1</option><option SELECTED>$modify_email_accounts</option></select>$NWB#users-modify_email_accounts$NWE</td></tr>\n";
					}
				else
					{
					echo "<tr bgcolor=#$SSstd_row2_background><td align=right></td><td align=left><input type=hidden name=modify_email_accounts value=$modify_email_accounts></td></tr>\n";
					}
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify Labels").": </td><td align=left><select size=1 name=modify_labels><option>0</option><option>1</option><option SELECTED>$modify_labels</option></select>$NWB#users-modify_sections$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify Colors").": </td><td align=left><select size=1 name=modify_colors><option>0</option><option>1</option><option SELECTED>$modify_colors</option></select>$NWB#users-modify_sections$NWE</td></tr>\n";
				if ($SSenable_languages > 0)
					{
					echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify Languages").": </td><td align=left><select size=1 name=modify_languages><option>0</option><option>1</option><option SELECTED>$modify_languages</option></select>$NWB#users-modify_sections$NWE</td></tr>\n";
					}
				else
					{
					echo "<tr bgcolor=#$SSstd_row2_background><td align=right></td><td align=left><input type=hidden name=modify_languages value=$modify_languages></td></tr>\n";
					}
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify Statuses").": </td><td align=left><select size=1 name=modify_statuses><option>0</option><option>1</option><option SELECTED>$modify_statuses</option></select>$NWB#users-modify_statuses$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify Voicemail").": </td><td align=left><select size=1 name=modify_voicemail><option>0</option><option>1</option><option SELECTED>$modify_voicemail</option></select>$NWB#users-modify_sections$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify Audio Store").": </td><td align=left><select size=1 name=modify_audiostore><option>0</option><option>1</option><option SELECTED>$modify_audiostore</option></select>$NWB#users-modify_sections$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify Music On Hold").": </td><td align=left><select size=1 name=modify_moh><option>0</option><option>1</option><option SELECTED>$modify_moh</option></select>$NWB#users-modify_sections$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify TTS").": </td><td align=left><select size=1 name=modify_tts><option>0</option><option>1</option><option SELECTED>$modify_tts</option></select>$NWB#users-modify_sections$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify Contacts").": </td><td align=left><select size=1 name=modify_contacts><option>0</option><option>1</option><option SELECTED>$modify_contacts</option></select>$NWB#users-modify_sections$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("CallCard Access").": </td><td align=left><select size=1 name=callcard_admin><option>0</option><option>1</option><option SELECTED>$callcard_admin</option></select>$NWB#users-modify_sections$NWE</td></tr>\n";
				if ($SSenable_auto_reports > 0)
					{
					echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify Automated Reports").": </td><td align=left><select size=1 name=modify_auto_reports><option>0</option><option>1</option><option SELECTED>$modify_auto_reports</option></select>$NWB#users-modify_sections$NWE</td></tr>\n";
					}
				else
					{
					echo "<tr bgcolor=#$SSstd_row2_background><td align=right></td><td align=left><input type=hidden name=modify_auto_reports value=$modify_auto_reports></td></tr>\n";
					}

				echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Add Timeclock Log Record").": </td><td align=left><select size=1 name=add_timeclock_log><option>0</option><option>1</option><option SELECTED>$add_timeclock_log</option></select>$NWB#users-add_timeclock_log$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Modify Timeclock Log Record").": </td><td align=left><select size=1 name=modify_timeclock_log><option>0</option><option>1</option><option SELECTED>$modify_timeclock_log</option></select>$NWB#users-modify_timeclock_log$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Delete Timeclock Log Record").": </td><td align=left><select size=1 name=delete_timeclock_log><option>0</option><option>1</option><option SELECTED>$delete_timeclock_log</option></select>$NWB#users-delete_timeclock_log$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Manager Shift Enforcement Override").": </td><td align=left><select size=1 name=manager_shift_enforcement_override><option>0</option><option>1</option><option SELECTED>$manager_shift_enforcement_override</option></select>$NWB#users-manager_shift_enforcement_override$NWE</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Manager Pause Code Approval").": </td><td align=left><select size=1 name=pause_code_approval><option>0</option><option>1</option><option SELECTED>$pause_code_approval</option></select>$NWB#users-pause_code_approval$NWE</td></tr>\n";

				if (preg_match("/cf_encrypt/",$SSactive_modules))
					{echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Admin Custom Fields Show Hidden").": </td><td align=left><select size=1 name=admin_cf_show_hidden><option>0</option><option>1</option><option SELECTED>$admin_cf_show_hidden</option></select>$NWB#users-admin_cf_show_hidden$NWE</td></tr>\n";}
				else
					{echo "<tr bgcolor=#$SSstd_row2_background><td colspan=2><input type=hidden name=admin_cf_show_hidden value=\"$admin_cf_show_hidden\"></td></tr>\n";}

				echo "<tr bgcolor=#$SSmenu_background><td colspan=2 align=center><font color=white><B>"._QXZ("SECURITY OPTIONS, Only enable if needed").":</td></tr>\n";
				if ($SSallow_ip_lists > 0)
					{
					echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Modify IP Lists").": </td><td align=left><select size=1 name=modify_ip_lists><option>0</option><option>1</option><option SELECTED>$modify_ip_lists</option></select>$NWB#users-modify_ip_lists$NWE</td></tr>\n";
					echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Ignore IP List").": </td><td align=left><select size=1 name=ignore_ip_list><option>0</option><option>1</option><option SELECTED>$ignore_ip_list</option></select>$NWB#users-ignore_ip_lists$NWE</td></tr>\n";
					# <option value=\"ENABLED\">"._QXZ("ENABLED")."</option>
					}
				else
					{
					echo "<tr bgcolor=#$SSstd_row2_background><td align=right></td><td align=left><input type=hidden name=modify_ip_lists value=$modify_ip_lists><input type=hidden name=ignore_ip_list value=$ignore_ip_list></td></tr>\n";
					}
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Two Factor Auth Override").": </td><td align=left><select size=1 name=two_factor_override><option value=\"NOT_ACTIVE\">"._QXZ("NOT_ACTIVE")."</option><option value=\"DISABLED\">"._QXZ("DISABLED")."</option><option SELECTED value=\"$two_factor_override\">"._QXZ("$two_factor_override")."</option></select>$NWB#users-two_factor_override$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSmenu_background><td colspan=2 align=center><font color=white><B>"._QXZ("API USER OPTIONS, Only enable if needed").":</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Agent API Access").": </td><td align=left><select size=1 name=vdc_agent_api_access><option>0</option><option>1</option><option SELECTED>$vdc_agent_api_access</option></select>$NWB#users-vdc_agent_api_access$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("API List Restrict").": </td><td align=left><select size=1 name=api_list_restrict><option>0</option><option>1</option><option SELECTED>$api_list_restrict</option></select>$NWB#users-api_list_restrict$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("API Allowed Functions").": </td><td align=left><select MULTIPLE size=8 name=api_allowed_functions[]>\n";
				$Afunctions_ARY = explode(' ',$APIfunctions);
				$Afunctions_ct = count($Afunctions_ARY);
				$b=0;
				while ($b < $Afunctions_ct)
					{
					$field_selected='';
					trim($Afunctions_ARY[$b]);
					if (preg_match("/ $Afunctions_ARY[$b] /",$api_allowed_functions))
						{$field_selected = 'SELECTED';}
					echo "<option value=\"$Afunctions_ARY[$b]\" $field_selected>"._QXZ("$Afunctions_ARY[$b]")."</option>\n";
					$b++;
					}
				echo "</select>$NWB#users-api_allowed_functions$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSmenu_background><td colspan=2 align=center><font color=white><B>"._QXZ("DISABLE ADMIN AND AGENT SCREEN OPTIONS").":</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("API Only User").": </td><td align=left><select size=1 name=api_only_user><option>0</option><option>1</option><option SELECTED>$api_only_user</option></select>$NWB#users-api_only_user$NWE</td></tr>\n";

				if ( ( ($LOGmodify_same_user_level > 0) or ($LOGalter_admin_interface > 0) ) and ($LOGuser_level > 8) )
					{
					echo "<tr bgcolor=#$SSmenu_background><td colspan=2 align=center><font color=white><B>"._QXZ("LEVEL 9 ADMIN OPTIONS").":</td></tr>\n";
					}

				if ( ($LOGmodify_same_user_level < 1) or ($LOGuser_level < 9) )
					{
					echo "<input type=hidden name=modify_same_user_level id=modify_same_user_level value=\"0\">\n";
					echo "<input type=hidden name=download_invalid_files id=download_invalid_files value=\"0\">\n";
					}
				else
					{
					echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Modify Same User Level").": </td><td align=left><select size=1 name=modify_same_user_level><option>0</option><option>1</option><option SELECTED>$modify_same_user_level</option></select>$NWB#users-modify_same_user_level$NWE</td></tr>\n";

					echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Download Invalid Files").": </td><td align=left><select size=1 name=download_invalid_files><option>0</option><option>1</option><option SELECTED>$download_invalid_files</option></select>$NWB#users-download_invalid_files$NWE</td></tr>\n";
					}

				if ( ($LOGalter_admin_interface < 1) or ($LOGuser_level < 9) )
					{
					echo "<input type=hidden name=alter_admin_interface_options id=alter_admin_interface_options value=\"0\">\n";
					}
				else
					{
					echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Alter Admin Interface Options").": </td><td align=left><select size=1 name=alter_admin_interface_options><option>0</option><option>1</option><option SELECTED>$alter_admin_interface_options</option></select>$NWB#users-alter_admin_interface_options$NWE</td></tr>\n";
					}
				}
			echo "<tr bgcolor=#$SSstd_row1_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
			echo "</TABLE></center>\n";

			if ($LOGdelete_users > 0)
				{
				echo "<br><br><a href=\"$PHP_SELF?ADD=5&user=$user\">"._QXZ("DELETE THIS USER")."</a>\n";
				}
			echo "<br><br><a href=\"./AST_agent_time_sheet.php?agent=$user\">"._QXZ("Click here for user time sheet")."</a>\n";
			echo "<br><br><a href=\"./user_status.php?user=$user\">"._QXZ("Click here for user status")."</a>\n";
			echo "<br><br><a href=\"./user_stats.php?user=$user\">"._QXZ("Click here for user stats")."</a>\n";
			echo "<br><br><a href=\"./AST_agent_days_detail.php?user=$user&query_date=$REPORTdate&end_date=$REPORTdate&group[]=--ALL--&shift=ALL\">"._QXZ("Click here for user multiple day status detail report")."</a>\n";
			echo "<br><br><a href=\"$PHP_SELF?ADD=8&user=$user\">"._QXZ("Click here for user CallBack Holds")."</a>\n";
			if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
				{
				echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=USERS&stage=$user\">"._QXZ("Click here to see Admin changes to this record")."</FONT>\n";
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=31 modify campaign info in the system - Detail view
######################

if ( ($LOGcampaign_detail < 1) and ($ADD==31) ) {$ADD=34;}	# send to Basic if not allowed

if ( ($ADD==31) and ( (!preg_match("/$campaign_id/i", $LOGallowed_campaigns)) and (!preg_match("/ALL-CAMPAIGNS/i",$LOGallowed_campaigns)) ) ) 
	{$ADD=30;}	# send to not allowed screen if not in vicidial_user_groups allowed_campaigns list

if ($ADD==31)
	{
	if ($LOGmodify_campaigns==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=31&campaign_id=$campaign_id&SUB=$SUB";
			$modify_footer_refresh=1;
			}
		if ($stage=='show_dialable')
			{
			$stmt="UPDATE vicidial_campaigns set display_dialable_count='Y' where campaign_id='$campaign_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		if ($stage=='hide_dialable')
			{
			$stmt="UPDATE vicidial_campaigns set display_dialable_count='N' where campaign_id='$campaign_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		if ($stage=='show_leadscount')
			{
			$stmt="UPDATE vicidial_campaigns set display_leads_count='Y' where campaign_id='$campaign_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		if ($stage=='hide_leadscount')
			{
			$stmt="UPDATE vicidial_campaigns set display_leads_count='N' where campaign_id='$campaign_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}

		$stmt="SELECT enable_vtiger_integration,vtiger_url from system_settings;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$enable_vtiger_integration_LU =		$row[0];
		$vtiger_url_LU =					$row[1];

		$stmt="SELECT campaign_id,campaign_name,active,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,list_order_mix,campaign_allow_inbound,manual_dial_list_id,default_xfer_group,xfer_groups,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_third_audio_file,survey_third_status,survey_third_exten,survey_fourth_digit,survey_fourth_audio_file,survey_fourth_status,survey_fourth_exten,drop_lockout_time,quick_transfer_button,prepopulate_transfer_preset,drop_rate_group,view_calls_in_queue,view_calls_in_queue_launch,grab_calls_in_queue,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,waitforsilence_options,agent_select_territories,campaign_calldate,crm_popup_login,crm_login_address,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,use_custom_cid,scheduled_callbacks_alert,queuemetrics_callstatus_override,extension_appended_cidname,scheduled_callbacks_count,manual_dial_override,blind_monitor_warning,blind_monitor_message,blind_monitor_filename,inbound_queue_no_dial,timer_action_destination,enable_xfer_presets,hide_xfer_number_to_dial,manual_dial_prefix,customer_3way_hangup_logging,customer_3way_hangup_seconds,customer_3way_hangup_action,ivr_park_call,ivr_park_call_agi,manual_preview_dial,realtime_agent_time_stats,use_auto_hopper,auto_hopper_multi,auto_trim_hopper,api_manual_dial,manual_dial_call_time_check,display_leads_count,lead_order_randomize,lead_order_secondary,per_call_notes,my_callback_option,agent_lead_search,agent_lead_search_method,queuemetrics_phone_environment,auto_pause_precall,auto_resume_precall,auto_pause_precall_code,manual_dial_cid,post_phone_time_diff_alert,custom_3way_button_transfer,available_only_tally_threshold,available_only_tally_threshold_agents,dial_level_threshold,dial_level_threshold_agents,safe_harbor_audio,safe_harbor_menu_id,survey_menu_id,callback_days_limit,dl_diff_target_method,disable_dispo_screen,disable_dispo_status,screen_labels,status_display_fields,na_call_url,survey_recording,pllb_grouping,pllb_grouping_limit,call_count_limit,call_count_target,callback_hours_block,callback_list_calltime,user_group,hopper_vlc_dup_check,in_group_dial,in_group_dial_select,safe_harbor_audio_field,pause_after_next_call,owner_populate,use_other_campaign_dnc,allow_emails,amd_inbound_group,amd_callmenu,survey_wait_sec,manual_dial_lead_id,dead_max,dispo_max,pause_max,dead_max_dispo,dispo_max_dispo,max_inbound_calls,manual_dial_search_checkbox,hide_call_log_info,timer_alt_seconds,wrapup_bypass,wrapup_after_hotkey,callback_active_limit,callback_active_limit_override,allow_chats,comments_all_tabs,comments_dispo_screen,comments_callback_screen,qc_comment_history,show_previous_callback,clear_script,cpd_unknown_action,manual_dial_search_filter,web_form_address_three,manual_dial_override_field,status_display_ingroup,customer_gone_seconds,agent_display_fields,am_message_wildcards,manual_dial_timeout,routing_initiated_recordings,manual_dial_hopper_check,callback_useronly_move_minutes,ofcom_uk_drop_calc,manual_auto_next,manual_auto_show,allow_required_fields,dead_to_dispo,agent_xfer_validation,ready_max_logout,callback_display_days,three_way_record_stop,hangup_xfer_record_start,scheduled_callbacks_email_alert,max_inbound_calls_outcome,manual_auto_next_options,agent_screen_time_display,next_dial_my_callbacks,inbound_no_agents_no_dial_container,inbound_no_agents_no_dial_threshold,cid_group_id,pause_max_dispo,script_top_dispo,dead_trigger_seconds,dead_trigger_action,dead_trigger_repeat,dead_trigger_filename,dead_trigger_url,scheduled_callbacks_force_dial,scheduled_callbacks_auto_reschedule,scheduled_callbacks_timezones_container,three_way_volume_buttons,callback_dnc,manual_dial_validation,mute_recordings,auto_active_list_new,call_quota_lead_ranking,call_quota_process_running,sip_event_logging,campaign_script_two,leave_vm_no_dispo,leave_vm_message_group_id,dial_timeout_lead_container,amd_type,vmm_daily_limit,opensips_cid_name,amd_agent_route_options,browser_alert_sound,browser_alert_volume,three_way_record_stop_exception,pause_max_exceptions,hopper_drop_run_trigger,daily_call_count_limit,daily_limit_manual,transfer_button_launch,shared_dial_rank,agent_search_method,qc_scorecard_id,qc_statuses_id,clear_form,leave_3way_start_recording,leave_3way_start_recording_exception,calls_waiting_vl_one,calls_waiting_vl_two,calls_inqueue_count_one,calls_inqueue_count_two,in_man_dial_next_ready_seconds,in_man_dial_next_ready_seconds_override,transfer_no_dispo,call_limit_24hour_method,call_limit_24hour_scope,call_limit_24hour,call_limit_24hour_override,cid_group_id_two,incall_tally_threshold_seconds,auto_alt_threshold,pause_max_url,agent_hide_hangup,ig_xfer_list_sort,script_tab_frame_size,max_logged_in_agents,user_group_script,agent_hangup_route,agent_hangup_value,agent_hangup_ig_override,show_confetti,demographic_quotas,demographic_quotas_container,demographic_quotas_rerank,demographic_quotas_list_resets,demographic_quotas_last_rerank,custom_one,custom_two,custom_three,custom_four,custom_five,dead_stop_recording,manual_vm_status_updates,force_per_call_notes,agent_search_ingroup_list,hopper_hold_inserts,daily_phone_number_call_limit,state_descriptions,script_tab_height,call_log_days,leave_3way_stop_recording,manual_minimum_ring_seconds,manual_minimum_attempt_seconds,manual_minimum_answer_seconds,khomp_settings_container,stereo_recording,stereo_rec_filename,stereo_parallel_recording,recording_dtmf_muting,stereo_recording_agent,parallel_rec_co_filename,parallel_rec_cm_filename,parallel_rec_fr_filename,call_count_limit_restrict from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$campaign_name = $row[1];
		$campaign_active = $row[2];
		$dial_status_a = $row[3];
		$dial_status_b = $row[4];
		$dial_status_c = $row[5];
		$dial_status_d = $row[6];
		$dial_status_e = $row[7];
		$lead_order = $row[8];
		$park_ext = $row[9];
		$park_file_name = $row[10];
		$web_form_address = stripslashes($row[11]);
		$allow_closers = $row[12];
		$hopper_level = $row[13];
		$auto_dial_level = $row[14];
		$next_agent_call = $row[15];
		$local_call_time = $row[16];
		$voicemail_ext = $row[17];
		$dial_timeout = $row[18];
		$dial_prefix = $row[19];
		$campaign_cid = $row[20];
		$campaign_vdad_exten = $row[21];
		$campaign_rec_exten = $row[22];
		$campaign_recording = $row[23];
		$campaign_rec_filename = $row[24];
		$script_id = $row[25];
		$get_call_launch = $row[26];
		$am_message_exten = $row[27];
		$amd_send_to_vmx = $row[28];
		$xferconf_a_dtmf = $row[29];
		$xferconf_a_number = $row[30];
		$xferconf_b_dtmf = $row[31];
		$xferconf_b_number = $row[32];
		$alt_number_dialing = $row[33];
		$scheduled_callbacks = $row[34];
		$lead_filter_id = $row[35];
			if ($lead_filter_id=='') {$lead_filter_id='NONE';}
		$drop_call_seconds = $row[36];
		$drop_action = $row[37];
		$safe_harbor_exten = $row[38];
		$display_dialable_count = $row[39];
		$wrapup_seconds = $row[40];
		$wrapup_message = $row[41];
		$closer_campaigns = $row[42];
		$use_internal_dnc = $row[43];
		$allcalls_delay = $row[44];
		$omit_phone_code = $row[45];
		$dial_method = $row[46];
		$available_only_ratio_tally = $row[47];
		$adaptive_dropped_percentage = $row[48];
		$adaptive_maximum_level = $row[49];
		$adaptive_latest_server_time = $row[50];
		$adaptive_intensity = $row[51];
		$adaptive_dl_diff_target = $row[52];
		$concurrent_transfers = $row[53];
		$auto_alt_dial = $row[54];
		$auto_alt_dial_statuses = $row[55];
		$agent_pause_codes_active = $row[56];
		$campaign_description = $row[57];
		$campaign_changedate = $row[58];
		$campaign_stats_refresh = $row[59];
		$campaign_logindate = $row[60];
		$dial_statuses = $row[61];
		$disable_alter_custdata = $row[62];
		$no_hopper_leads_logins = $row[63];
		$list_order_mix = $row[64];
		$campaign_allow_inbound = $row[65];
		$manual_dial_list_id = $row[66];
		$default_xfer_group = $row[67];
		$queue_priority = $row[69];
		$drop_inbound_group = $row[70];
		$qc_enabled = $row[71];
		$qc_statuses = $row[72];
		$qc_lists = $row[73];
		$qc_shift_id = $row[74];
		$qc_get_record_launch = $row[75];
		$qc_show_recording = $row[76];
		$qc_web_form_address = stripslashes($row[77]);
		$qc_script = $row[78];
		$survey_first_audio_file = $row[79];
		$survey_dtmf_digits = $row[80];
		$survey_ni_digit = $row[81];
		$survey_opt_in_audio_file = $row[82];
		$survey_ni_audio_file = $row[83];
		$survey_method = $row[84];
		$survey_no_response_action = $row[85];
		$survey_ni_status = $row[86];
		$survey_response_digit_map = $row[87];
		$survey_xfer_exten = $row[88];
		$survey_camp_record_dir = $row[89];
		$disable_alter_custphone = $row[90];
		$display_queue_count = $row[91];
		$manual_dial_filter = $row[92];
		$agent_clipboard_copy = $row[93];
		$agent_extended_alt_dial = $row[94];
		$use_campaign_dnc = $row[95];
		$three_way_call_cid = $row[96];
		$three_way_dial_prefix = $row[97];
		$web_form_target = $row[98];
		$vtiger_search_category = $row[99];
		$vtiger_create_call_record = $row[100];
		$vtiger_create_lead_record = $row[101];
		$vtiger_screen_login = $row[102];
		$cpd_amd_action = $row[103];
		$agent_allow_group_alias = $row[104];
		$default_group_alias = $row[105];
		$vtiger_search_dead = $row[106];
		$vtiger_status_call = $row[107];
		$survey_third_digit = $row[108];
		$survey_third_audio_file = $row[109];
		$survey_third_status = $row[110];
		$survey_third_exten = $row[111];
		$survey_fourth_digit = $row[112];
		$survey_fourth_audio_file = $row[113];
		$survey_fourth_status = $row[114];
		$survey_fourth_exten = $row[115];
		$drop_lockout_time = $row[116];
		$quick_transfer_button = $row[117];
		$prepopulate_transfer_preset = $row[118];
		$drop_rate_group = $row[119];
		$view_calls_in_queue = $row[120];
		$view_calls_in_queue_launch = $row[121];
		$grab_calls_in_queue = $row[122];
		$call_requeue_button = $row[123];
		$pause_after_each_call = $row[124];
		$no_hopper_dialing = $row[125];
		$agent_dial_owner_only = $row[126];
		$agent_display_dialable_leads = $row[127];
		$web_form_address_two = $row[128];
		$waitforsilence_options = $row[129];
		$agent_select_territories = $row[130];
		$campaign_calldate = $row[131];
		$crm_popup_login = $row[132];
		$crm_login_address = $row[133];
		$timer_action = $row[134];
		$timer_action_message = $row[135];
		$timer_action_seconds = $row[136];
		$start_call_url = $row[137];
		$dispo_call_url = $row[138];
		$xferconf_c_number = $row[139];
		$xferconf_d_number = $row[140];
		$xferconf_e_number = $row[141];
		$use_custom_cid = $row[142];
		$scheduled_callbacks_alert = $row[143];
		$queuemetrics_callstatus = $row[144];
		$extension_appended_cidname = $row[145];
		$scheduled_callbacks_count = $row[146];
		$manual_dial_override = $row[147];
		$blind_monitor_warning = $row[148];
		$blind_monitor_message = $row[149];
		$blind_monitor_filename = $row[150];
		$inbound_queue_no_dial = $row[151];
		$timer_action_destination = $row[152];
		$enable_xfer_presets = $row[153];
		$hide_xfer_number_to_dial = $row[154];
		$manual_dial_prefix = $row[155];
		$customer_3way_hangup_logging = $row[156];
		$customer_3way_hangup_seconds = $row[157];
		$customer_3way_hangup_action = $row[158];
		$ivr_park_call = $row[159];
		$ivr_park_call_agi = $row[160];
		$manual_preview_dial = $row[161];
		$realtime_agent_time_stats = $row[162];
		$use_auto_hopper = $row[163];
		$auto_hopper_multi = $row[164];
		$auto_trim_hopper = $row[165];
		$api_manual_dial = $row[166];
		$manual_dial_call_time_check = $row[167];
		$display_leads_count = $row[168];
		$lead_order_randomize = $row[169];
		$lead_order_secondary = $row[170];
		$per_call_notes = $row[171];
		$my_callback_option = $row[172];
		$agent_lead_search = $row[173];
		$agent_lead_search_method = $row[174];
		$queuemetrics_phone_environment = $row[175];
		$auto_pause_precall = $row[176];
		$auto_resume_precall = $row[177];
		$auto_pause_precall_code = $row[178];
		$manual_dial_cid = $row[179];
		$post_phone_time_diff_alert = $row[180];
		$custom_3way_button_transfer = $row[181];
		$available_only_tally_threshold = $row[182];
		$available_only_tally_threshold_agents = $row[183];
		$dial_level_threshold = $row[184];
		$dial_level_threshold_agents = $row[185];
		$safe_harbor_audio = $row[186];
		$safe_harbor_menu_id = $row[187];
		$survey_menu_id = $row[188];
		$callback_days_limit = $row[189];
		$dl_diff_target_method = $row[190];
		$disable_dispo_screen = $row[191];
		$disable_dispo_status = $row[192];
		$screen_labels = $row[193];
		$status_display_fields = $row[194];
		$na_call_url = $row[195];
		$survey_recording = $row[196];
		$pllb_grouping = $row[197];
		$pllb_grouping_limit = $row[198];
		$call_count_limit = $row[199];
		$call_count_target = $row[200];
		$callback_hours_block = $row[201];
		$callback_list_calltime = $row[202];
		$user_group = $row[203];
		$hopper_vlc_dup_check = $row[204];
		$in_group_dial = $row[205];
		$in_group_dial_select = $row[206];
		$safe_harbor_audio_field = $row[207];
		$pause_after_next_call = $row[208];
		$owner_populate = $row[209];
		$use_other_campaign_dnc = $row[210];
		$allow_emails =	$row[211];
		$amd_inbound_group = $row[212];
		$amd_callmenu =	$row[213];
		$survey_wait_sec = $row[214];
		$manual_dial_lead_id = $row[215];
		$dead_max = $row[216];
		$dispo_max = $row[217];
		$pause_max = $row[218];
		$dead_max_dispo = $row[219];
		$dispo_max_dispo = $row[220];
		$max_inbound_calls = $row[221];
		$manual_dial_search_checkbox = $row[222];
		$hide_call_log_info = $row[223];
		$timer_alt_seconds = $row[224];
		$wrapup_bypass = $row[225];
		$wrapup_after_hotkey = $row[226];
		$callback_active_limit = $row[227];
		$callback_active_limit_override = $row[228];
		$allow_chats = $row[229];
		$comments_all_tabs = $row[230];
		$comments_dispo_screen = $row[231];
		$comments_callback_screen = $row[232];
		$qc_comment_history = $row[233];
		$show_previous_callback = $row[234];
		$clear_script = $row[235];
		$cpd_unknown_action = $row[236];
		$manual_dial_search_filter=$row[237];
		$web_form_address_three=$row[238];
		$manual_dial_override_field=$row[239];
		$status_display_ingroup=$row[240];
		$customer_gone_seconds=$row[241];
		$agent_display_fields=$row[242];
		$am_message_wildcards=$row[243];
		$manual_dial_timeout=$row[244];
		$routing_initiated_recordings=$row[245];
		$manual_dial_hopper_check=$row[246];
		$callback_useronly_move_minutes=$row[247];
		$ofcom_uk_drop_calc=$row[248];
		$manual_auto_next=$row[249];
		$manual_auto_show=$row[250];
		$allow_required_fields=$row[251];
		$dead_to_dispo=$row[252];
		$agent_xfer_validation=$row[253];
		$ready_max_logout=$row[254];
		$callback_display_days=$row[255];
		$three_way_record_stop=$row[256];
		$hangup_xfer_record_start=$row[257];
		$scheduled_callbacks_email_alert=$row[258];
		$max_inbound_calls_outcome=$row[259];
		$manual_auto_next_options=$row[260];
		$agent_screen_time_display=$row[261];
		$next_dial_my_callbacks=$row[262];
		$inbound_no_agents_no_dial_container=$row[263];
		$inbound_no_agents_no_dial_threshold=$row[264];
		$cid_group_id=$row[265];
		$pause_max_dispo=$row[266];
		$script_top_dispo=$row[267];
		$dead_trigger_seconds=$row[268];
		$dead_trigger_action=$row[269];
		$dead_trigger_repeat=$row[270];
		$dead_trigger_filename=$row[271];
		$dead_trigger_url=$row[272];
		$scheduled_callbacks_force_dial=$row[273];
		$scheduled_callbacks_auto_reschedule=$row[274];
		$scheduled_callbacks_timezones_container=$row[275];
		$three_way_volume_buttons=$row[276];
		$callback_dnc=$row[277];
		$manual_dial_validation=$row[278];
		$mute_recordings=$row[279];
		$auto_active_list_new=$row[280];
		$call_quota_lead_ranking=$row[281];
		$call_quota_process_running=$row[282];
		$sip_event_logging=$row[283];
		$campaign_script_two=$row[284];
		$leave_vm_no_dispo=$row[285];
		$leave_vm_message_group_id=$row[286];
		$dial_timeout_lead_container=$row[287];
		$amd_type=$row[288];
		$vmm_daily_limit=$row[289];
		$opensips_cid_name=$row[290];
		$amd_agent_route_options=$row[291];
		$browser_alert_sound=$row[292];
		$browser_alert_volume=$row[293];
		$three_way_record_stop_exception=$row[294];
		$pause_max_exceptions=$row[295];
		$hopper_drop_run_trigger=$row[296];
		$daily_call_count_limit=$row[297];
		$daily_limit_manual=$row[298];
		$transfer_button_launch=$row[299];
		$shared_dial_rank=$row[300];
		$agent_search_method=$row[301];
		$qc_scorecard_id=$row[302];
		$qc_statuses_id=$row[303];
		$clear_form=$row[304];
		$leave_3way_start_recording=$row[305];
		$leave_3way_start_recording_exception=$row[306];
		$calls_waiting_vl_one=$row[307];
		$calls_waiting_vl_two=$row[308];
		$calls_inqueue_count_one=$row[309];
		$calls_inqueue_count_two=$row[310];
		$in_man_dial_next_ready_seconds=$row[311];
		$in_man_dial_next_ready_seconds_override=$row[312];
		$transfer_no_dispo=$row[313];
		$call_limit_24hour_method=$row[314];
		$call_limit_24hour_scope=$row[315];
		$call_limit_24hour=$row[316];
		$call_limit_24hour_override=$row[317];
		$cid_group_id_two=$row[318];
		$incall_tally_threshold_seconds=$row[319];
		$auto_alt_threshold=$row[320];
		$pause_max_url=$row[321];
		$agent_hide_hangup=$row[322];
		$ig_xfer_list_sort=$row[323];
		$script_tab_frame_size=$row[324];
		$max_logged_in_agents=$row[325];
		$user_group_script=$row[326];
		$agent_hangup_route=$row[327];
		$agent_hangup_value=$row[328];
		$agent_hangup_ig_override=$row[329];
		$show_confetti=$row[330];
		$demographic_quotas=$row[331];
		$demographic_quotas_container=$row[332];
		$demographic_quotas_rerank=$row[333];
		$demographic_quotas_list_resets=$row[334];
		$demographic_quotas_last_rerank=$row[335];
		$custom_one = $row[336];
		$custom_two = $row[337];
		$custom_three = $row[338];
		$custom_four = $row[339];
		$custom_five = $row[340];
		$dead_stop_recording = $row[341];
		$manual_vm_status_updates = $row[342];
		$force_per_call_notes = $row[343];
		$agent_search_ingroup_list = $row[344];
		$hopper_hold_inserts = $row[345];
		$daily_phone_number_call_limit = $row[346];
		$state_descriptions = $row[347];
		$script_tab_height = $row[348];
		$call_log_days = $row[349];
		$leave_3way_stop_recording = $row[350];
		$manual_minimum_ring_seconds = $row[351];
		$manual_minimum_attempt_seconds = $row[352];
		$manual_minimum_answer_seconds = $row[353];
		$khomp_settings_container = $row[354];
		$stereo_recording = $row[355];
		$stereo_rec_filename = $row[356];
		$stereo_parallel_recording = $row[357];
		$recording_dtmf_muting = $row[358];
		$stereo_recording_agent = $row[359];
		$parallel_rec_co_filename = $row[360];
		$parallel_rec_cm_filename = $row[361];
		$parallel_rec_fr_filename = $row[362];
		$call_count_limit_restrict = $row[363];

	if (preg_match('/DISABLED/', $list_order_mix))
		{$DEFlistDISABLE = '';	$DEFstatusDISABLED=0;}
	else
		{$DEFlistDISABLE = 'disabled';	$DEFstatusDISABLED=1;}

	if ($auto_alt_dial == 'MULTI_LEAD')
		{$ALTmultiDISABLE=1;	$ALTmultiLINK="<a href=\"./admin_campaign_multi_alt.php?campaign_id=$campaign_id\">"._QXZ("Multi-Alt-Settings")."</a>";}
	else
		{$ALTmultiDISABLE=0;	$ALTmultiLINK='';}


	$stmt="SELECT count(*) from vicidial_campaigns_list_mix where campaign_id='$campaign_id' and status='ACTIVE' $LOGallowed_campaignsSQL;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$rowx=mysqli_fetch_row($rslt);
	if ($rowx[0] < 1)
		{
		$mixes_list="<option SELECTED value=\"DISABLED\">"._QXZ("DISABLED")."</option>\n";
		$mixname_list["DISABLED"] = "DISABLED";
		}
	else
		{
		##### get list_mix listings for dynamic pulldown
		$stmt="SELECT vcl_id,vcl_name from vicidial_campaigns_list_mix where campaign_id='$campaign_id' and status='ACTIVE' $LOGallowed_campaignsSQL limit 1";
		$rslt=mysql_to_mysqli($stmt, $link);
		$mixes_to_print = mysqli_num_rows($rslt);
		$mixes_list="<option value=\"DISABLED\">"._QXZ("DISABLED")."</option>\n";

		$o=0;
		while ($mixes_to_print > $o)
			{
			$rowx=mysqli_fetch_row($rslt);
			$mixes_list .= "<option value=\"ACTIVE\">"._QXZ("ACTIVE")." ($rowx[0] - $rowx[1])</option>\n";
			$mixname_list["ACTIVE"] = "$rowx[0] - $rowx[1]";
			$o++;
			}
		}

	##### get in-groups listings for dynamic drop in-group pulldown
	$stmt="SELECT group_id,group_name from vicidial_inbound_groups $whereLOGadmin_viewable_groupsSQL order by group_id;";
#	$stmt="SELECT group_id,group_name from vicidial_inbound_groups where group_id NOT IN('AGENTDIRECT') order by group_id";
	$rslt=mysql_to_mysqli($stmt, $link);
	$Dgroups_to_print = mysqli_num_rows($rslt);
	$Dgroups_menu='';
	$Dgroups_selected=0;
	$o=0;
	while ($Dgroups_to_print > $o) 
		{
		$rowx=mysqli_fetch_row($rslt);
		$Dgroups_menu .= "<option ";
		if ($drop_inbound_group == "$rowx[0]") 
			{
			$Dgroups_menu .= "SELECTED ";
			$Dgroups_selected++;
			}
		$Dgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
		$o++;
		}
	if ($Dgroups_selected < 1) 
		{$Dgroups_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
	else 
		{$Dgroups_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}

	$nxLOGadmin_viewable_groupsSQL = $LOGadmin_viewable_groupsSQL;
	if (strlen($xfer_groupsSQL) < 6)
			{$nxLOGadmin_viewable_groupsSQL = $whereLOGadmin_viewable_groupsSQL;}

	##### get in-groups listings for dynamic transfer group pulldown list menu
	$stmt="SELECT group_id,group_name from vicidial_inbound_groups $xfer_groupsSQL $nxLOGadmin_viewable_groupsSQL order by group_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$Xgroups_to_print = mysqli_num_rows($rslt);
	$Xgroups_menu='';
	$Xgroups_selected=0;
	$o=0;
	while ($Xgroups_to_print > $o) 
		{
		$rowx=mysqli_fetch_row($rslt);
		$Xgroups_menu .= "<option ";
		if ($default_xfer_group == "$rowx[0]") 
			{
			$Xgroups_menu .= "SELECTED ";
			$Xgroups_selected++;
			}
		$Xgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
		$o++;
		}
	if ($Xgroups_selected < 1) 
		{$Xgroups_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
	else 
		{$Xgroups_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}

	##### get in-groups listings for dynamic AMD inbound group pulldown list menu
	$stmt="SELECT group_id,group_name from vicidial_inbound_groups $whereLOGadmin_viewable_groupsSQL order by group_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$AMDgroups_to_print = mysqli_num_rows($rslt);
	$AMDgroups_menu='';
	$AMDgroups_selected=0;
	$o=0;
	while ($AMDgroups_to_print > $o) 
		{
		$rowx=mysqli_fetch_row($rslt);
		$AMDgroups_menu .= "<option ";
		if ($amd_inbound_group == "$rowx[0]") 
			{
			$AMDgroups_menu .= "SELECTED ";
			$AMDgroups_selected++;
			}
		$AMDgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
		$o++;
		}
	if ($AMDgroups_selected < 1) 
		{$AMDgroups_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
	else 
		{$AMDgroups_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}

	##### get callmenus listings for dynamic AMD callmenu pulldown list menu
	$stmt="SELECT menu_id from vicidial_call_menu $whereLOGadmin_viewable_groupsSQL order by menu_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$AMDmenus_to_print = mysqli_num_rows($rslt);
	$AMDmenus_menu='';
	$AMDmenus_selected=0;
	$o=0;
	while ($AMDmenus_to_print > $o) 
		{
		$rowx=mysqli_fetch_row($rslt);
		$AMDmenus_menu .= "<option ";
		if ($amd_callmenu == "$rowx[0]") 
			{
			$AMDmenus_menu .= "SELECTED ";
			$AMDmenus_selected++;
			}
		$AMDmenus_menu .= "value=\"$rowx[0]\">$rowx[0]</option>\n";
		$o++;
		}
	if ($AMDmenus_selected < 1) 
		{$AMDmenus_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
	else 
		{$AMDmenus_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}

	##### get agent screen label listings for dynamic pulldown list menu
	$stmt="SELECT label_id,label_name from vicidial_screen_labels where active='Y' $LOGadmin_viewable_groupsSQL order by label_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$labels_to_print = mysqli_num_rows($rslt);
	$labels_menu='';
	$o=0;
	while ($labels_to_print > $o) 
		{
		$rowx=mysqli_fetch_row($rslt);
		$labels_menu .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
		$o++;
		}

	##### get status groups for the lists and in-groups within this campaign
	$stmt="SELECT status_group_id from vicidial_lists where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$lists_to_print = mysqli_num_rows($rslt);
	$camp_status_groups='';
	if ($DB) {echo "$lists_to_print|$stmt|\n";}
	$o=0;
	while ($lists_to_print > $o) 
		{
		$rowx=mysqli_fetch_row($rslt);
		if (strlen($rowx[0]) > 0) {$camp_status_groups .= "'$rowx[0]',";}
		$o++;
		}
	$closer_campaigns = preg_replace("/ -$/","",$closer_campaigns);
	$closer_campaigns = preg_replace("/ /","','",$closer_campaigns);
	$stmt="SELECT status_group_id from vicidial_inbound_groups where status_group_id NOT IN('','NONE') and group_id IN('$closer_campaigns') $LOGadmin_viewable_groupsSQL ;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$lists_to_print = mysqli_num_rows($rslt);
	if ($DB) {echo "$lists_to_print|$stmt|\n";}
	$o=0;
	while ($lists_to_print > $o) 
		{
		$rowx=mysqli_fetch_row($rslt);
		if (strlen($rowx[0]) > 0) {$camp_status_groups .= "'$rowx[0]',";}
		$o++;
		}
#	$camp_status_groups = preg_replace('/.$/i','',$camp_status_groups);

	$dial_statuses = preg_replace("/ -$/","",$dial_statuses);
	$Dstatuses = explode(" ", $dial_statuses);
	$Ds_to_print = (count($Dstatuses) -1);

	$qc_statuses = preg_replace("/^ | -$/","",$qc_statuses);
	$QCstatuses = explode(" ", $qc_statuses);
	$QCs_to_print = (count($QCstatuses) -0);

	$qc_lists = preg_replace("/^ | -$/","",$qc_lists);
	$QClists = explode(" ", $qc_lists);
	$QCL_to_print = (count($QClists) -0);

	##### get status listings for dynamic pulldown
	$stmt="SELECT status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable,scheduled_callback,completed,min_sec,max_sec,answering_machine from vicidial_statuses where status NOT IN('INCALL','QUEUE') order by status;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$statuses_to_print = mysqli_num_rows($rslt);
	$statuses_list='';
	$dial_statuses_list='';
	$qc_statuses_list='';
	$survey_ni_status_list='';
	$o=0;
	while ($statuses_to_print > $o) 
		{
		$rowx=mysqli_fetch_row($rslt);
		$statuses_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
		if ($rowx[0] != 'CBHOLD') 
			{
			$dial_statuses_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			if ($survey_ni_status == $rowx[0])
				{
				$survey_ni_status_list .= "<option value=\"$rowx[0]\" SELECTED>$rowx[0] - $rowx[1]</option>\n";
				}
			else
				{
				$survey_ni_status_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				}
			}
		$statname_list["$rowx[0]"] = "$rowx[1]";
		$LRstatuses_list .= "<option value=\"$rowx[0]-----$rowx[1]\">$rowx[0] - $rowx[1]</option>\n";
		if (preg_match('/Y/i', $rowx[2]))
			{$HKstatuses_list .= "<option value=\"$rowx[0]-----$rowx[1]\">$rowx[0] - $rowx[1]</option>\n";}

		$qc_statuses_list .= "<input type=\"checkbox\" name=\"qc_statuses[]\" value=\"$rowx[0]\"";
		$p=0;
		while ($p < $QCs_to_print)
			{
			if ($rowx[0] == $QCstatuses[$p]) 
				{
				$qc_statuses_list .= " CHECKED";
				}
			$p++;
			}
		$qc_statuses_list .= "> $rowx[0] - $rowx[1]<BR>\n";

		$o++;
		}

	##### get VM Message Groups listings for dynamic pulldown menu
	$stmt="SELECT leave_vm_message_group_id,leave_vm_message_group_notes from leave_vm_message_groups where active='Y' $LOGadmin_viewable_groupsSQL order by leave_vm_message_group_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$VMMGmenus_to_print = mysqli_num_rows($rslt);
	$VMMGmenus_menu='';
	$VMMGmenus_selected=0;
	$o=0;
	while ($VMMGmenus_to_print > $o) 
		{
		$rowx=mysqli_fetch_row($rslt);
		$VMMGmenus_menu .= "<option ";
		if ($leave_vm_message_group_id == "$rowx[0]") 
			{
			$VMMGmenus_menu .= "SELECTED ";
			$VMMGmenus_selected++;
			}
		$VMMGmenus_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
		$o++;
		}
	if ($VMMGmenus_selected < 1) 
		{$VMMGmenus_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
	else 
		{$VMMGmenus_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}


	$stmt="SELECT status,status_name,selectable,campaign_id,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable,scheduled_callback,completed,min_sec,max_sec,answering_machine from vicidial_campaign_statuses where campaign_id IN($camp_status_groups'$campaign_id') and status NOT IN('INCALL','QUEUE') $LOGallowed_campaignsSQL order by status;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$Cstatuses_to_print = mysqli_num_rows($rslt);
	if ($DB) {echo "$Cstatuses_to_print|$stmt|\n";}

	$o=0;
	while ($Cstatuses_to_print > $o) 
		{
		$rowx=mysqli_fetch_row($rslt);
		$statuses_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
		if ($rowx[0] != 'CBHOLD') {$dial_statuses_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";}
		$statname_list["$rowx[0]"] = "$rowx[1]";
		$LRstatuses_list .= "<option value=\"$rowx[0]-----$rowx[1]\">$rowx[0] - $rowx[1]</option>\n";
		if (preg_match('/Y/i', $rowx[2]))
			{$HKstatuses_list .= "<option value=\"$rowx[0]-----$rowx[1]\">$rowx[0] - $rowx[1]</option>\n";}

		$qc_statuses_list .= "<input type=\"checkbox\" name=\"qc_statuses[]\" value=\"$rowx[0]\"";
		$p=0;
		while ($p < $QCs_to_print)
			{
			if ($rowx[0] == $QCstatuses[$p]) 
				{
				$qc_statuses_list .= " CHECKED";
				}
			$p++;
			}
		$qc_statuses_list .= "> $rowx[0] - $rowx[1]<BR>\n";

		$o++;
		}

	$stmt="SELECT count(*) from servers where active='Y' and active_agent_login_server='Y';";
	if ($DB) {echo "|$stmt|\n";}
	$rslt=mysql_to_mysqli($stmt, $link);
	$row=mysqli_fetch_row($rslt);
	$agent_servers_count=$row[0];

	$stmt="SELECT count(*) from phones_alias $whereLOGadmin_viewable_groupsSQL;";
	if ($DB) {echo "|$stmt|\n";}
	$rslt=mysql_to_mysqli($stmt, $link);
	$row=mysqli_fetch_row($rslt);
	$phones_alias_count=$row[0];


	if ($SUB<1)		{$camp_detail_color=$subcamp_color;}
		else		{$camp_detail_color=$campaigns_color;}
	if ($SUB==22)	{$camp_statuses_color=$subcamp_color;}
		else		{$camp_statuses_color=$campaigns_color;}
	if ($SUB==23)	{$camp_hotkeys_color=$subcamp_color;}
		else		{$camp_hotkeys_color=$campaigns_color;}
	if ($SUB==25)	{$camp_recycle_color=$subcamp_color;}
		else		{$camp_recycle_color=$campaigns_color;}
	if ($SUB==26)	{$camp_autoalt_color=$subcamp_color;}
		else		{$camp_autoalt_color=$campaigns_color;}
	if ($SUB==27)	{$camp_pause_color=$subcamp_color;}
		else		{$camp_pause_color=$campaigns_color;}
	if ($SUB==28)	{$camp_qc_color=$subcamp_color;}
		else		{$camp_qc_color=$campaigns_color;}
	if ($SUB==29)	{$camp_listmix_color=$subcamp_color;}
		else		{$camp_listmix_color=$campaigns_color;}
	if ($SUB=='20A')	{$camp_survey_color=$subcamp_color;}
		else		{$camp_survey_color=$campaigns_color;}
	if ($SUB==201)	{$camp_preset_color=$subcamp_color;}
		else		{$camp_preset_color=$campaigns_color;}
	if ($SUB==202)	{$camp_accid_color=$subcamp_color;}
		else		{$camp_accid_color=$campaigns_color;}
	echo "<font size=2 color=$subcamp_font face=\"ARIAL,HELVETICA\"> <B>$campaign_id</B>: </font><BR>";
	echo "<TABLE WIDTH=930 CELLPADDING=2 CELLSPACING=0><TR BGCOLOR=\"$campaigns_color\">\n";
	echo "<TD ALIGN=CENTER><font size=0> &nbsp; <a href=\"$PHP_SELF?ADD=34&campaign_id=$campaign_id\" STYLE=\"text-decoration:none;\"><font class=\"sub_sub_head_links\">"._QXZ("Basic")."</font></a></TD>";
	echo "<TD ALIGN=CENTER BGCOLOR=\"$camp_detail_color\"> <a href=\"$PHP_SELF?ADD=31&campaign_id=$campaign_id\" STYLE=\"text-decoration:none;\"><font class=\"sub_sub_head_links\">"._QXZ("Detail")." </font></a> </TD>";
	echo "<TD ALIGN=CENTER BGCOLOR=\"$camp_statuses_color\"><a href=\"$PHP_SELF?ADD=31&SUB=22&campaign_id=$campaign_id\" STYLE=\"text-decoration:none;\"><font class=\"sub_sub_head_links\">"._QXZ("Statuses")."</font></a></TD>";
	echo "<TD ALIGN=CENTER BGCOLOR=\"$camp_hotkeys_color\"><a href=\"$PHP_SELF?ADD=31&SUB=23&campaign_id=$campaign_id\" STYLE=\"text-decoration:none;\"><font class=\"sub_sub_head_links\">"._QXZ("HotKeys")."</font></a></TD>";

	if ($SSoutbound_autodial_active > 0)
		{
		echo "<TD ALIGN=CENTER BGCOLOR=\"$camp_recycle_color\"><a href=\"$PHP_SELF?ADD=31&SUB=25&campaign_id=$campaign_id\" STYLE=\"text-decoration:none;\"><font class=\"sub_sub_head_links\">"._QXZ("Lead Recycling")."</font></a></TD>";
		echo "<TD ALIGN=CENTER BGCOLOR=\"$camp_autoalt_color\"><a href=\"$PHP_SELF?ADD=31&SUB=26&campaign_id=$campaign_id\" STYLE=\"text-decoration:none;\"><font class=\"sub_sub_head_links\">"._QXZ("Auto Alt Dial")."</font></a></TD>";
		echo "<TD ALIGN=CENTER BGCOLOR=\"$camp_listmix_color\"><a href=\"$PHP_SELF?ADD=31&SUB=29&campaign_id=$campaign_id\" STYLE=\"text-decoration:none;\"><font class=\"sub_sub_head_links\">"._QXZ("List Mix")."</font></a></TD>";
		echo "<TD ALIGN=CENTER BGCOLOR=\"$camp_survey_color\"><a href=\"$PHP_SELF?ADD=31&SUB=20A&campaign_id=$campaign_id\" STYLE=\"text-decoration:none;\"><font class=\"sub_sub_head_links\">"._QXZ("Survey")."</font></a></TD>";
		}
	echo "<TD ALIGN=CENTER BGCOLOR=\"$camp_pause_color\"><a href=\"$PHP_SELF?ADD=31&SUB=27&campaign_id=$campaign_id\" STYLE=\"text-decoration:none;\"><font class=\"sub_sub_head_links\">"._QXZ("Pause Codes")."</font></a></TD>";
	if ( ($enable_xfer_presets == 'ENABLED') or ($enable_xfer_presets == 'STAGING') )
		{
		echo "<TD ALIGN=CENTER BGCOLOR=\"$camp_preset_color\"><a href=\"$PHP_SELF?ADD=31&SUB=201&campaign_id=$campaign_id\" STYLE=\"text-decoration:none;\"><font class=\"sub_sub_head_links\">"._QXZ("Presets")."</font></a></TD>";
		}
	if ($SScampaign_cid_areacodes_enabled == '1')
		{
		echo "<TD ALIGN=CENTER BGCOLOR=\"$camp_accid_color\"><a href=\"$PHP_SELF?ADD=31&SUB=202&campaign_id=$campaign_id\" STYLE=\"text-decoration:none;\"><font class=\"sub_sub_head_links\">"._QXZ("AC-CID")."</font></a></TD>";
		}
	if ($SSqc_features_active > 0)
		{
		echo "<TD ALIGN=CENTER BGCOLOR=\"$camp_qc_color\"><a href=\"$PHP_SELF?ADD=31&SUB=28&campaign_id=$campaign_id\" STYLE=\"text-decoration:none;\"><font class=\"sub_sub_head_links\">"._QXZ("QC")."</font></a></TD>";
		}
	if ($SSoutbound_autodial_active < 1)
		{
		echo "<TD></TD><TD></TD><TD></TD><TD></TD>\n";
		}
	echo "<TD ALIGN=CENTER> <a href=\"./realtime_report.php?RR=4&DB=0&group=$campaign_id\" STYLE=\"text-decoration:none;\"><font class=\"sub_sub_head_links\">"._QXZ("Real-Time")."</font></a></TD>\n";
	echo "</TR></TABLE>\n";

	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	echo "<center>\n";

	if ($SUB < 1)
		{
		echo "<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=41>\n";
		echo "<input type=hidden name=DB value=\"$DB\">\n";
		echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
		echo "<input type=hidden name=park_ext value=\"$park_ext\">\n";
		echo "<input type=hidden name=old_campaign_allow_inbound value=\"$campaign_allow_inbound\">\n";
		echo "<input type=hidden name=agent_extended_alt_dial value=\"$agent_extended_alt_dial\">\n";
		echo "<TABLE width=910 cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign ID").": </td><td align=left><b>$campaign_id</b>$NWB#campaigns-campaign_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign Name").": </td><td align=left><input type=text name=campaign_name size=40 maxlength=40 value=\"$campaign_name\">$NWB#campaigns-campaign_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign Description").": </td><td align=left><input type=text name=campaign_description size=40 maxlength=255 value=\"$campaign_description\">$NWB#campaigns-campaign_description$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign Change Date").": </td><td align=left>$campaign_changedate &nbsp; $NWB#campaigns-campaign_changedate$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign Login Date").": </td><td align=left>$campaign_logindate &nbsp; $NWB#campaigns-campaign_logindate$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign Call Date").": </td><td align=left>$campaign_calldate &nbsp; $NWB#campaigns-campaign_calldate$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>\n";
			$temp_chart_title = _QXZ("8 Day outbound call count for this campaign");
			horizontal_bar_chart($campaign_id,'8','campaign',$link,'total_calls','call count',1,'','',$temp_chart_title);
		echo "</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value=\"$campaign_active\" SELECTED>"._QXZ("$campaign_active")."</option></select>$NWB#campaigns-active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">".(preg_match('/\-\-ALL\-\-/', $user_group) ? _QXZ("$user_group") : $user_group)."</option>\n";
		echo "</select>$NWB#campaigns-user_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Park Music-on-Hold").": </td><td align=left><input type=text name=park_file_name id=park_file_name size=20 maxlength=100 value=\"$park_file_name\"> <a href=\"javascript:launch_moh_chooser('park_file_name','moh');\">"._QXZ("moh chooser")."</a> $NWB#campaigns-park_ext$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Web Form").": </td><td align=left><input type=text name=web_form_address size=70 maxlength=9999 value=\"$web_form_address\">$NWB#campaigns-web_form_address$NWE"; if ($SSenable_first_webform < 1) {echo " <font color=red><b>"._QXZ("DISABLED")."</b></font>";} echo "</td></tr>\n";
		if ($SSenable_second_webform > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Web Form Two").": </td><td align=left><input type=text name=web_form_address_two size=70 maxlength=9999 value=\"$web_form_address_two\">$NWB#campaigns-web_form_address$NWE</td></tr>\n";
			}
		if ($SSenable_third_webform > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Web Form Three").": </td><td align=left><input type=text name=web_form_address_three size=70 maxlength=9999 value=\"$web_form_address_three\">$NWB#campaigns-web_form_address$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Web Form Target").": </td><td align=left><input type=text name=web_form_target size=25 maxlength=255 value=\"$web_form_target\">$NWB#campaigns-web_form_target$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Allow Closers").": </td><td align=left><select size=1 name=allow_closers><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$allow_closers' SELECTED>"._QXZ("$allow_closers")."</option></select>$NWB#campaigns-allow_closers$NWE</td></tr>\n";
		if ($SSallow_emails > 0) 
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Allow Emails").": </td><td align=left><select size=1 name=allow_emails><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$allow_emails' SELECTED>"._QXZ("$allow_emails")."</option></select>$NWB#campaigns-allow_emails$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right></td><td align=left><input type=hidden name=allow_emails value=$allow_emails></td></tr>\n";
			}
		if ($SSallow_chats > 0) 
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Allow Chats").": </td><td align=left><select size=1 name=allow_chats><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value=\"$allow_chats\" SELECTED>"._QXZ("$allow_chats")."</option></select>$NWB#campaigns-allow_chats$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right></td><td align=left><input type=hidden name=allow_chats value=$allow_chats></td></tr>\n";
			}
		if ($SSoutbound_autodial_active > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Allow Inbound and Blended").": </td><td align=left><select size=1 name=campaign_allow_inbound><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$campaign_allow_inbound' SELECTED>"._QXZ("$campaign_allow_inbound")."</option></select>$NWB#campaigns-campaign_allow_inbound$NWE</td></tr>\n";

			$o=0;
			while ($Ds_to_print > $o) 
				{
				$o++;
				$Dstatus = $Dstatuses[$o];

				echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Dial Status")." $o: </td><td align=left> \n";

				if ($DEFstatusDISABLED > 0)
					{
					echo "<font color=grey><DEL><b>$Dstatus</b> - $statname_list[$Dstatus] &nbsp; &nbsp; &nbsp; &nbsp; <font size=2>\n";
					echo "REMOVE</DEL></td></tr>\n";
					}
				else
					{
					echo "<b>$Dstatus</b> - $statname_list[$Dstatus] &nbsp; &nbsp; &nbsp; &nbsp; <font size=2>\n";
					echo "<a href=\"$PHP_SELF?ADD=68&campaign_id=$campaign_id&status=$Dstatuses[$o]\">"._QXZ("REMOVE")."</a></td></tr>\n";
					}
				}

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Add A Dial Status to Call").": </td><td align=left><select size=1 name=dial_status $DEFlistDISABLE>\n";
			echo "<option value=\"\"> - "._QXZ("NONE")." - </option>\n";

			echo "$dial_statuses_list";
			echo "</select> &nbsp; \n";
			echo "<input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("ADD")."'> &nbsp; &nbsp; $NWB#campaigns-dial_status$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("List Order").": </td><td align=left>";
			if ($ALTmultiDISABLE > 0)
				{
				echo "<input type=hidden name=lead_order value=\"$lead_order\"> $ALTmultiLINK";
				}
			else
				{
				if (file_exists('options.php'))
					{require('options.php');}
				if ($camp_lead_order_random > 0)
					{
					echo "<select size=1 name=lead_order>
					<option value='$lead_order' SELECTED>"._QXZ("$lead_order")."</option>
					<option value='DOWN'>"._QXZ("DOWN")."</option>
					<option value='UP'>"._QXZ("UP")."</option>
					<option value='DOWN PHONE'>"._QXZ("DOWN PHONE")."</option>
					<option value='UP PHONE'>"._QXZ("UP PHONE")."</option>
					<option value='DOWN LAST NAME'>"._QXZ("DOWN LAST NAME")."</option>
					<option value='UP LAST NAME'>"._QXZ("UP LAST NAME")."</option>
					<option value='DOWN COUNT'>"._QXZ("DOWN COUNT")."</option>
					<option value='UP COUNT'>"._QXZ("UP COUNT")."</option>
					<option value='RANDOM'>"._QXZ("RANDOM")."</option>
					<option value='DOWN LAST CALL TIME'>"._QXZ("DOWN LAST CALL TIME")."</option>
					<option value='UP LAST CALL TIME'>"._QXZ("UP LAST CALL TIME")."</option>
					<option value='DOWN RANK'>"._QXZ("DOWN RANK")."</option>
					<option value='UP RANK'>"._QXZ("UP RANK")."</option>
					<option value='DOWN OWNER'>"._QXZ("DOWN OWNER")."</option>
					<option value='UP OWNER'>"._QXZ("UP OWNER")."</option>
					<option value='DOWN TIMEZONE'>"._QXZ("DOWN TIMEZONE")."</option>
					<option value='UP TIMEZONE'>"._QXZ("UP TIMEZONE")."</option>
					<option value='DOWN 2nd NEW'>"._QXZ("DOWN 2nd NEW")."</option>
					<option value='DOWN 3rd NEW'>"._QXZ("DOWN 3rd NEW")."</option>
					<option value='DOWN 4th NEW'>"._QXZ("DOWN 4th NEW")."</option>
					<option value='DOWN 5th NEW'>"._QXZ("DOWN 5th NEW")."</option>
					<option value='DOWN 6th NEW'>"._QXZ("DOWN 6th NEW")."</option>
					<option value='UP 2nd NEW'>"._QXZ("UP 2nd NEW")."</option>
					<option value='UP 3rd NEW'>"._QXZ("UP 3rd NEW")."</option>
					<option value='UP 4th NEW'>"._QXZ("UP 4th NEW")."</option>
					<option value='UP 5th NEW'>"._QXZ("UP 5th NEW")."</option>
					<option value='UP 6th NEW'>"._QXZ("UP 6th NEW")."</option>
					<option value='DOWN PHONE 2nd NEW'>"._QXZ("DOWN PHONE 2nd NEW")."</option>
					<option value='DOWN PHONE 3rd NEW'>"._QXZ("DOWN PHONE 3rd NEW")."</option>
					<option value='DOWN PHONE 4th NEW'>"._QXZ("DOWN PHONE 4th NEW")."</option>
					<option value='DOWN PHONE 5th NEW'>"._QXZ("DOWN PHONE 5th NEW")."</option>
					<option value='DOWN PHONE 6th NEW'>"._QXZ("DOWN PHONE 6th NEW")."</option>
					<option value='UP PHONE 2nd NEW'>"._QXZ("UP PHONE 2nd NEW")."</option>
					<option value='UP PHONE 3rd NEW'>"._QXZ("UP PHONE 3rd NEW")."</option>
					<option value='UP PHONE 4th NEW'>"._QXZ("UP PHONE 4th NEW")."</option>
					<option value='UP PHONE 5th NEW'>"._QXZ("UP PHONE 5th NEW")."</option>
					<option value='UP PHONE 6th NEW'>"._QXZ("UP PHONE 6th NEW")."</option>
					<option value='DOWN LAST NAME 2nd NEW'>"._QXZ("DOWN LAST NAME 2nd NEW")."</option>
					<option value='DOWN LAST NAME 3rd NEW'>"._QXZ("DOWN LAST NAME 3rd NEW")."</option>
					<option value='DOWN LAST NAME 4th NEW'>"._QXZ("DOWN LAST NAME 4th NEW")."</option>
					<option value='DOWN LAST NAME 5th NEW'>"._QXZ("DOWN LAST NAME 5th NEW")."</option>
					<option value='DOWN LAST NAME 6th NEW'>"._QXZ("DOWN LAST NAME 6th NEW")."</option>
					<option value='UP LAST NAME 2nd NEW'>"._QXZ("UP LAST NAME 2nd NEW")."</option>
					<option value='UP LAST NAME 3rd NEW'>"._QXZ("UP LAST NAME 3rd NEW")."</option>
					<option value='UP LAST NAME 4th NEW'>"._QXZ("UP LAST NAME 4th NEW")."</option>
					<option value='UP LAST NAME 5th NEW'>"._QXZ("UP LAST NAME 5th NEW")."</option>
					<option value='UP LAST NAME 6th NEW'>"._QXZ("UP LAST NAME 6th NEW")."</option>
					<option value='DOWN COUNT 2nd NEW'>"._QXZ("DOWN COUNT 2nd NEW")."</option>
					<option value='DOWN COUNT 3rd NEW'>"._QXZ("DOWN COUNT 3rd NEW")."</option>
					<option value='DOWN COUNT 4th NEW'>"._QXZ("DOWN COUNT 4th NEW")."</option>
					<option value='DOWN COUNT 5th NEW'>"._QXZ("DOWN COUNT 5th NEW")."</option>
					<option value='DOWN COUNT 6th NEW'>"._QXZ("DOWN COUNT 6th NEW")."</option>
					<option value='UP COUNT 2nd NEW'>"._QXZ("UP COUNT 2nd NEW")."</option>
					<option value='UP COUNT 3rd NEW'>"._QXZ("UP COUNT 3rd NEW")."</option>
					<option value='UP COUNT 4th NEW'>"._QXZ("UP COUNT 4th NEW")."</option>
					<option value='UP COUNT 5th NEW'>"._QXZ("UP COUNT 5th NEW")."</option>
					<option value='UP COUNT 6th NEW'>"._QXZ("UP COUNT 6th NEW")."</option>
					<option value='RANDOM 2nd NEW'>"._QXZ("RANDOM 2nd NEW")."</option>
					<option value='RANDOM 3rd NEW'>"._QXZ("RANDOM 3rd NEW")."</option>
					<option value='RANDOM 4th NEW'>"._QXZ("RANDOM 4th NEW")."</option>
					<option value='RANDOM 5th NEW'>"._QXZ("RANDOM 5th NEW")."</option>
					<option value='RANDOM 6th NEW'>"._QXZ("RANDOM 6th NEW")."</option>
					<option value='DOWN LAST CALL TIME 2nd NEW'>"._QXZ("DOWN LAST CALL TIME 2nd NEW")."</option>
					<option value='DOWN LAST CALL TIME 3rd NEW'>"._QXZ("DOWN LAST CALL TIME 3rd NEW")."</option>
					<option value='DOWN LAST CALL TIME 4th NEW'>"._QXZ("DOWN LAST CALL TIME 4th NEW")."</option>
					<option value='DOWN LAST CALL TIME 5th NEW'>"._QXZ("DOWN LAST CALL TIME 5th NEW")."</option>
					<option value='DOWN LAST CALL TIME 6th NEW'>"._QXZ("DOWN LAST CALL TIME 6th NEW")."</option>
					<option value='UP LAST CALL TIME 2nd NEW'>"._QXZ("UP LAST CALL TIME 2nd NEW")."</option>
					<option value='UP LAST CALL TIME 3rd NEW'>"._QXZ("UP LAST CALL TIME 3rd NEW")."</option>
					<option value='UP LAST CALL TIME 4th NEW'>"._QXZ("UP LAST CALL TIME 4th NEW")."</option>
					<option value='UP LAST CALL TIME 5th NEW'>"._QXZ("UP LAST CALL TIME 5th NEW")."</option>
					<option value='UP LAST CALL TIME 6th NEW'>"._QXZ("UP LAST CALL TIME 6th NEW")."</option>
					<option value='DOWN RANK 2nd NEW'>"._QXZ("DOWN RANK 2nd NEW")."</option>
					<option value='DOWN RANK 3rd NEW'>"._QXZ("DOWN RANK 3rd NEW")."</option>
					<option value='DOWN RANK 4th NEW'>"._QXZ("DOWN RANK 4th NEW")."</option>
					<option value='DOWN RANK 5th NEW'>"._QXZ("DOWN RANK 5th NEW")."</option>
					<option value='DOWN RANK 6th NEW'>"._QXZ("DOWN RANK 6th NEW")."</option>
					<option value='UP RANK 2nd NEW'>"._QXZ("UP RANK 2nd NEW")."</option>
					<option value='UP RANK 3rd NEW'>"._QXZ("UP RANK 3rd NEW")."</option>
					<option value='UP RANK 4th NEW'>"._QXZ("UP RANK 4th NEW")."</option>
					<option value='UP RANK 5th NEW'>"._QXZ("UP RANK 5th NEW")."</option>
					<option value='UP RANK 6th NEW'>"._QXZ("UP RANK 6th NEW")."</option>
					<option value='DOWN OWNER 2nd NEW'>"._QXZ("DOWN OWNER 2nd NEW")."</option>
					<option value='DOWN OWNER 3rd NEW'>"._QXZ("DOWN OWNER 3rd NEW")."</option>
					<option value='DOWN OWNER 4th NEW'>"._QXZ("DOWN OWNER 4th NEW")."</option>
					<option value='DOWN OWNER 5th NEW'>"._QXZ("DOWN OWNER 5th NEW")."</option>
					<option value='DOWN OWNER 6th NEW'>"._QXZ("DOWN OWNER 6th NEW")."</option>
					<option value='UP OWNER 2nd NEW'>"._QXZ("UP OWNER 2nd NEW")."</option>
					<option value='UP OWNER 3rd NEW'>"._QXZ("UP OWNER 3rd NEW")."</option>
					<option value='UP OWNER 4th NEW'>"._QXZ("UP OWNER 4th NEW")."</option>
					<option value='UP OWNER 5th NEW'>"._QXZ("UP OWNER 5th NEW")."</option>
					<option value='UP OWNER 6th NEW'>"._QXZ("UP OWNER 6th NEW")."</option>
					<option value='DOWN TIMEZONE 2nd NEW'>"._QXZ("DOWN TIMEZONE 2nd NEW")."</option>
					<option value='DOWN TIMEZONE 3rd NEW'>"._QXZ("DOWN TIMEZONE 3rd NEW")."</option>
					<option value='DOWN TIMEZONE 4th NEW'>"._QXZ("DOWN TIMEZONE 4th NEW")."</option>
					<option value='DOWN TIMEZONE 5th NEW'>"._QXZ("DOWN TIMEZONE 5th NEW")."</option>
					<option value='DOWN TIMEZONE 6th NEW'>"._QXZ("DOWN TIMEZONE 6th NEW")."</option>
					<option value='UP TIMEZONE 2nd NEW'>"._QXZ("UP TIMEZONE 2nd NEW")."</option>
					<option value='UP TIMEZONE 3rd NEW'>"._QXZ("UP TIMEZONE 3rd NEW")."</option>
					<option value='UP TIMEZONE 4th NEW'>"._QXZ("UP TIMEZONE 4th NEW")."</option>
					<option value='UP TIMEZONE 5th NEW'>"._QXZ("UP TIMEZONE 5th NEW")."</option>
					<option value='UP TIMEZONE 6th NEW'>"._QXZ("UP TIMEZONE 6th NEW")."</option>
					</select>$NWB#campaigns-lead_order$NWE\n";
					}
				else
					{
					echo "<select size=1 name=lead_order>
					<option value='$lead_order' SELECTED>"._QXZ("$lead_order")."</option>
					<option value='DOWN'>"._QXZ("DOWN")."</option>
					<option value='UP'>"._QXZ("UP")."</option>
					<option value='DOWN PHONE'>"._QXZ("DOWN PHONE")."</option>
					<option value='UP PHONE'>"._QXZ("UP PHONE")."</option>
					<option value='DOWN LAST NAME'>"._QXZ("DOWN LAST NAME")."</option>
					<option value='UP LAST NAME'>"._QXZ("UP LAST NAME")."</option>
					<option value='DOWN COUNT'>"._QXZ("DOWN COUNT")."</option>
					<option value='UP COUNT'>"._QXZ("UP COUNT")."</option>
					<option value='DOWN LAST CALL TIME'>"._QXZ("DOWN LAST CALL TIME")."</option>
					<option value='UP LAST CALL TIME'>"._QXZ("UP LAST CALL TIME")."</option>
					<option value='DOWN RANK'>"._QXZ("DOWN RANK")."</option>
					<option value='UP RANK'>"._QXZ("UP RANK")."</option>
					<option value='DOWN OWNER'>"._QXZ("DOWN OWNER")."</option>
					<option value='UP OWNER'>"._QXZ("UP OWNER")."</option>
					<option value='DOWN TIMEZONE'>"._QXZ("DOWN TIMEZONE")."</option>
					<option value='UP TIMEZONE'>"._QXZ("UP TIMEZONE")."</option>
					<option value='DOWN 2nd NEW'>"._QXZ("DOWN 2nd NEW")."</option>
					<option value='DOWN 3rd NEW'>"._QXZ("DOWN 3rd NEW")."</option>
					<option value='DOWN 4th NEW'>"._QXZ("DOWN 4th NEW")."</option>
					<option value='DOWN 5th NEW'>"._QXZ("DOWN 5th NEW")."</option>
					<option value='DOWN 6th NEW'>"._QXZ("DOWN 6th NEW")."</option>
					<option value='UP 2nd NEW'>"._QXZ("UP 2nd NEW")."</option>
					<option value='UP 3rd NEW'>"._QXZ("UP 3rd NEW")."</option>
					<option value='UP 4th NEW'>"._QXZ("UP 4th NEW")."</option>
					<option value='UP 5th NEW'>"._QXZ("UP 5th NEW")."</option>
					<option value='UP 6th NEW'>"._QXZ("UP 6th NEW")."</option>
					<option value='DOWN PHONE 2nd NEW'>"._QXZ("DOWN PHONE 2nd NEW")."</option>
					<option value='DOWN PHONE 3rd NEW'>"._QXZ("DOWN PHONE 3rd NEW")."</option>
					<option value='DOWN PHONE 4th NEW'>"._QXZ("DOWN PHONE 4th NEW")."</option>
					<option value='DOWN PHONE 5th NEW'>"._QXZ("DOWN PHONE 5th NEW")."</option>
					<option value='DOWN PHONE 6th NEW'>"._QXZ("DOWN PHONE 6th NEW")."</option>
					<option value='UP PHONE 2nd NEW'>"._QXZ("UP PHONE 2nd NEW")."</option>
					<option value='UP PHONE 3rd NEW'>"._QXZ("UP PHONE 3rd NEW")."</option>
					<option value='UP PHONE 4th NEW'>"._QXZ("UP PHONE 4th NEW")."</option>
					<option value='UP PHONE 5th NEW'>"._QXZ("UP PHONE 5th NEW")."</option>
					<option value='UP PHONE 6th NEW'>"._QXZ("UP PHONE 6th NEW")."</option>
					<option value='DOWN LAST NAME 2nd NEW'>"._QXZ("DOWN LAST NAME 2nd NEW")."</option>
					<option value='DOWN LAST NAME 3rd NEW'>"._QXZ("DOWN LAST NAME 3rd NEW")."</option>
					<option value='DOWN LAST NAME 4th NEW'>"._QXZ("DOWN LAST NAME 4th NEW")."</option>
					<option value='DOWN LAST NAME 5th NEW'>"._QXZ("DOWN LAST NAME 5th NEW")."</option>
					<option value='DOWN LAST NAME 6th NEW'>"._QXZ("DOWN LAST NAME 6th NEW")."</option>
					<option value='UP LAST NAME 2nd NEW'>"._QXZ("UP LAST NAME 2nd NEW")."</option>
					<option value='UP LAST NAME 3rd NEW'>"._QXZ("UP LAST NAME 3rd NEW")."</option>
					<option value='UP LAST NAME 4th NEW'>"._QXZ("UP LAST NAME 4th NEW")."</option>
					<option value='UP LAST NAME 5th NEW'>"._QXZ("UP LAST NAME 5th NEW")."</option>
					<option value='UP LAST NAME 6th NEW'>"._QXZ("UP LAST NAME 6th NEW")."</option>
					<option value='DOWN COUNT 2nd NEW'>"._QXZ("DOWN COUNT 2nd NEW")."</option>
					<option value='DOWN COUNT 3rd NEW'>"._QXZ("DOWN COUNT 3rd NEW")."</option>
					<option value='DOWN COUNT 4th NEW'>"._QXZ("DOWN COUNT 4th NEW")."</option>
					<option value='DOWN COUNT 5th NEW'>"._QXZ("DOWN COUNT 5th NEW")."</option>
					<option value='DOWN COUNT 6th NEW'>"._QXZ("DOWN COUNT 6th NEW")."</option>
					<option value='UP COUNT 2nd NEW'>"._QXZ("UP COUNT 2nd NEW")."</option>
					<option value='UP COUNT 3rd NEW'>"._QXZ("UP COUNT 3rd NEW")."</option>
					<option value='UP COUNT 4th NEW'>"._QXZ("UP COUNT 4th NEW")."</option>
					<option value='UP COUNT 5th NEW'>"._QXZ("UP COUNT 5th NEW")."</option>
					<option value='UP COUNT 6th NEW'>"._QXZ("UP COUNT 6th NEW")."</option>
					<option value='DOWN LAST CALL TIME 2nd NEW'>"._QXZ("DOWN LAST CALL TIME 2nd NEW")."</option>
					<option value='DOWN LAST CALL TIME 3rd NEW'>"._QXZ("DOWN LAST CALL TIME 3rd NEW")."</option>
					<option value='DOWN LAST CALL TIME 4th NEW'>"._QXZ("DOWN LAST CALL TIME 4th NEW")."</option>
					<option value='DOWN LAST CALL TIME 5th NEW'>"._QXZ("DOWN LAST CALL TIME 5th NEW")."</option>
					<option value='DOWN LAST CALL TIME 6th NEW'>"._QXZ("DOWN LAST CALL TIME 6th NEW")."</option>
					<option value='UP LAST CALL TIME 2nd NEW'>"._QXZ("UP LAST CALL TIME 2nd NEW")."</option>
					<option value='UP LAST CALL TIME 3rd NEW'>"._QXZ("UP LAST CALL TIME 3rd NEW")."</option>
					<option value='UP LAST CALL TIME 4th NEW'>"._QXZ("UP LAST CALL TIME 4th NEW")."</option>
					<option value='UP LAST CALL TIME 5th NEW'>"._QXZ("UP LAST CALL TIME 5th NEW")."</option>
					<option value='UP LAST CALL TIME 6th NEW'>"._QXZ("UP LAST CALL TIME 6th NEW")."</option>
					<option value='DOWN RANK 2nd NEW'>"._QXZ("DOWN RANK 2nd NEW")."</option>
					<option value='DOWN RANK 3rd NEW'>"._QXZ("DOWN RANK 3rd NEW")."</option>
					<option value='DOWN RANK 4th NEW'>"._QXZ("DOWN RANK 4th NEW")."</option>
					<option value='DOWN RANK 5th NEW'>"._QXZ("DOWN RANK 5th NEW")."</option>
					<option value='DOWN RANK 6th NEW'>"._QXZ("DOWN RANK 6th NEW")."</option>
					<option value='UP RANK 2nd NEW'>"._QXZ("UP RANK 2nd NEW")."</option>
					<option value='UP RANK 3rd NEW'>"._QXZ("UP RANK 3rd NEW")."</option>
					<option value='UP RANK 4th NEW'>"._QXZ("UP RANK 4th NEW")."</option>
					<option value='UP RANK 5th NEW'>"._QXZ("UP RANK 5th NEW")."</option>
					<option value='UP RANK 6th NEW'>"._QXZ("UP RANK 6th NEW")."</option>
					<option value='DOWN OWNER 2nd NEW'>"._QXZ("DOWN OWNER 2nd NEW")."</option>
					<option value='DOWN OWNER 3rd NEW'>"._QXZ("DOWN OWNER 3rd NEW")."</option>
					<option value='DOWN OWNER 4th NEW'>"._QXZ("DOWN OWNER 4th NEW")."</option>
					<option value='DOWN OWNER 5th NEW'>"._QXZ("DOWN OWNER 5th NEW")."</option>
					<option value='DOWN OWNER 6th NEW'>"._QXZ("DOWN OWNER 6th NEW")."</option>
					<option value='UP OWNER 2nd NEW'>"._QXZ("UP OWNER 2nd NEW")."</option>
					<option value='UP OWNER 3rd NEW'>"._QXZ("UP OWNER 3rd NEW")."</option>
					<option value='UP OWNER 4th NEW'>"._QXZ("UP OWNER 4th NEW")."</option>
					<option value='UP OWNER 5th NEW'>"._QXZ("UP OWNER 5th NEW")."</option>
					<option value='UP OWNER 6th NEW'>"._QXZ("UP OWNER 6th NEW")."</option>
					<option value='DOWN TIMEZONE 2nd NEW'>"._QXZ("DOWN TIMEZONE 2nd NEW")."</option>
					<option value='DOWN TIMEZONE 3rd NEW'>"._QXZ("DOWN TIMEZONE 3rd NEW")."</option>
					<option value='DOWN TIMEZONE 4th NEW'>"._QXZ("DOWN TIMEZONE 4th NEW")."</option>
					<option value='DOWN TIMEZONE 5th NEW'>"._QXZ("DOWN TIMEZONE 5th NEW")."</option>
					<option value='DOWN TIMEZONE 6th NEW'>"._QXZ("DOWN TIMEZONE 6th NEW")."</option>
					<option value='UP TIMEZONE 2nd NEW'>"._QXZ("UP TIMEZONE 2nd NEW")."</option>
					<option value='UP TIMEZONE 3rd NEW'>"._QXZ("UP TIMEZONE 3rd NEW")."</option>
					<option value='UP TIMEZONE 4th NEW'>"._QXZ("UP TIMEZONE 4th NEW")."</option>
					<option value='UP TIMEZONE 5th NEW'>"._QXZ("UP TIMEZONE 5th NEW")."</option>
					<option value='UP TIMEZONE 6th NEW'>"._QXZ("UP TIMEZONE 6th NEW")."</option>
					</select>$NWB#campaigns-lead_order$NWE\n";
					}
				}

			echo "</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("List Order Randomize").": </td><td align=left>";
			if ($ALTmultiDISABLE > 0)
				{
				echo "<input type=hidden name=lead_order_randomize value=\"$lead_order_randomize\"> $ALTmultiLINK";
				}
			else
				{
				echo "<select size=1 name=lead_order_randomize><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$lead_order_randomize' SELECTED>"._QXZ("$lead_order_randomize")."</option></select>$NWB#campaigns-lead_order_randomize$NWE";
				}
			echo "</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("List Order Secondary").": </td><td align=left>";
			if ($ALTmultiDISABLE > 0)
				{
				echo "<input type=hidden name=lead_order_secondary value=\"$lead_order_secondary\"> $ALTmultiLINK";
				}
			else
				{
				echo "<select size=1 name=lead_order_secondary><option value='LEAD_ASCEND'>"._QXZ("LEAD_ASCEND")."</option><option value='LEAD_DESCEND'>"._QXZ("LEAD_DESCEND")."</option><option value='CALLTIME_ASCEND'>"._QXZ("CALLTIME_ASCEND")."</option><option value='CALLTIME_DESCEND'>"._QXZ("CALLTIME_DESCEND")."</option><option value='VENDOR_ASCEND'>"._QXZ("VENDOR_ASCEND")."</option><option value='VENDOR_DESCEND'>"._QXZ("VENDOR_DESCEND")."</option><option value='$lead_order_secondary' SELECTED>"._QXZ("$lead_order_secondary")."</option></select>$NWB#campaigns-lead_order_secondary$NWE";
				}
			echo "</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=31&SUB=29&campaign_id=$campaign_id&vcl_id=$list_order_mix\">"._QXZ("List Mix")."</a>: </td><td align=left>";
			if ($ALTmultiDISABLE > 0)
				{
				echo "<input type=hidden name=list_order_mix value=\"$list_order_mix\"> $ALTmultiLINK";
				}
			else
				{
				echo "<select size=1 name=list_order_mix>\n";
				echo "$mixes_list";
				if (preg_match('/DISABLED/', $list_order_mix))
					{echo "<option selected value=\"$list_order_mix\">"._QXZ("$list_order_mix")." - "._QXZ("$mixname_list[$list_order_mix]")."</option>\n";}
				else
					{echo "<option selected value=\"ACTIVE\">"._QXZ("ACTIVE")." ($mixname_list[ACTIVE])</option>\n";}
				echo "</select>$NWB#campaigns-list_order_mix$NWE";
				}
			echo "</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=31111111&lead_filter_id=$lead_filter_id\">"._QXZ("Lead Filter")."</a>: </td><td align=left>";
			if ($ALTmultiDISABLE > 0)
				{
				echo "<input type=hidden name=lead_filter_id value=\"$lead_filter_id\"> $ALTmultiLINK";
				}
			else
				{
				echo "<select size=1 name=lead_filter_id>\n";
				echo "$filters_list";
				echo "<option selected value=\"$lead_filter_id\">"._QXZ("$lead_filter_id")." - $filtername_list[$lead_filter_id]</option>\n";
				echo "</select>$NWB#campaigns-lead_filter_id$NWE";
				}
			echo "</td></tr>\n";

			if ($SScall_quota_lead_ranking > 0)
				{
				##### get container listings for dynamic call quota lead ranking pulldown menu
				$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='CALL_QUOTA' $LOGadmin_viewable_groupsSQL order by container_id;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$cqlr_to_print = mysqli_num_rows($rslt);
				$call_quota_container_menu='';
				$cqlr_selected=0;
				$o=0;
				while ($cqlr_to_print > $o) 
					{
					$rowx=mysqli_fetch_row($rslt);
					if (mb_strlen($rowx[1],'utf-8')>40)
						{$rowx[1] = mb_substr($rowx[1],0,40,'utf-8') . '...';}
					$call_quota_container_menu .= "<option ";
					if ($call_quota_lead_ranking == "$rowx[0]") 
						{
						$call_quota_container_menu .= "SELECTED ";
						$cqlr_selected++;
						}
					$call_quota_container_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
					$o++;
					}

				echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Auto Active List New").": </td><td align=left><select size=1 name=auto_active_list_new><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$auto_active_list_new' SELECTED>"._QXZ("$auto_active_list_new")."</option><option>1</option><option>5</option><option>10</option><option>25</option><option>50</option><option>75</option><option>100</option><option>150</option><option>200</option><option>250</option><option>300</option><option>350</option><option>400</option><option>450</option><option>500</option><option>550</option><option>600</option><option>650</option><option>700</option><option>750</option><option>800</option><option>850</option><option>900</option><option>950</option><option>1000</option><option>1100</option><option>1200</option><option>1300</option><option>1400</option><option>1500</option><option>1600</option><option>1700</option><option>1800</option><option>1900</option><option>2000</option><option>3000</option><option>4000</option><option>5000</option><option>6000</option><option>7000</option><option>8000</option><option>9000</option><option>10000</option><option>15000</option><option>20000</option><option>30000</option><option>40000</option><option>50000</option><option>60000</option><option>70000</option><option>80000</option><option>90000</option><option>100000</option></select>$NWB#campaigns-auto_active_list_new$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row3_background><td align=right>";
				if ($cqlr_selected > 0)
					{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$call_quota_lead_ranking\">"._QXZ("Call Quota Lead Ranking")."</a>";}
				else
					{echo _QXZ("Call Quota Lead Ranking");}
				echo ": </td><td align=left><select size=1 name=call_quota_lead_ranking><option value='DISABLED'>"._QXZ("DISABLED")."</option>$call_quota_container_menu</select>$NWB#campaigns-call_quota_lead_ranking$NWE</td></tr>\n";
				}
			else
				{
				echo "<tr bgcolor=#$SSstd_row4_background><td colspan=2><input type=hidden name=auto_active_list_new value='$auto_active_list_new'><input type=hidden name=call_quota_lead_ranking value='$call_quota_lead_ranking'></td></tr>\n";
				}

			if ($SSdemographic_quotas > 0)
				{
				##### get container listings for demographic quotas pulldown menu
				$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='DEMOGRAPHIC_QUOTAS' $LOGadmin_viewable_groupsSQL order by container_id;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$cqlr_to_print = mysqli_num_rows($rslt);
				$demo_quota_container_menu='';
				$cqlr_selected=0;
				$o=0;
				while ($cqlr_to_print > $o) 
					{
					$rowx=mysqli_fetch_row($rslt);
					if (mb_strlen($rowx[1],'utf-8')>40)
						{$rowx[1] = mb_substr($rowx[1],0,40,'utf-8') . '...';}
					$demo_quota_container_menu .= "<option ";
					if ($demographic_quotas_container == "$rowx[0]") 
						{
						$demo_quota_container_menu .= "SELECTED ";
						$cqlr_selected++;
						}
					$demo_quota_container_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
					$o++;
					}
				
				$DQdebug = " &nbsp; <font size=1><a href=\"campaign_debug.php?group=$campaign_id\">"._QXZ("DQ Debug")."</a> | <a href=\"demographic_quotas_report.php?group=$campaign_id\">"._QXZ("DQ Report")."</a></font>";
				if ($demographic_quotas == 'INVALID')
					{$DQdebug = " &nbsp; <font color=red><b>"._QXZ("DQ configuration invalid")."<b></font>$DQdebug";}
				if ($demographic_quotas == 'COMPLETE')
					{$DQdebug = " &nbsp; <b>"._QXZ("DQ goals have been met")."<b>$DQdebug";}

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Demographic Quotas").": </td><td align=left><select size=1 name=demographic_quotas><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$demographic_quotas' SELECTED>"._QXZ("$demographic_quotas")."</option></select>$NWB#campaigns-demographic_quotas$NWE $DQdebug</td></tr>\n";

				if ($demographic_quotas == 'COMPLETE')
					{
					echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><font color=red><b>"._QXZ("All Demographic Quota goals have been filled for this campaign")."</b></font></td></tr>\n";
					}

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Demographic Quotas Force Re-Rank").": </td><td align=left><select size=1 name=demographic_quotas_rerank><option value='NO'>"._QXZ("NO")."</option><option value='NOW'>"._QXZ("NOW")."</option><option value='HOUR'>"._QXZ("HOUR")."</option><option value='MINUTE'>"._QXZ("MINUTE")."</option><option value='NOW_HOUR'>"._QXZ("NOW_HOUR")."</option><option value='$demographic_quotas_rerank' SELECTED>"._QXZ("$demographic_quotas_rerank")."</option></select>$NWB#campaigns-demographic_quotas_rerank$NWE &nbsp; <i>"._QXZ("last re-rank").": $demographic_quotas_last_rerank</i></td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Demographic Quotas List Resets").": </td><td align=left><select size=1 name=demographic_quotas_list_resets><option value='MANUAL'>"._QXZ("MANUAL")."</option><option value='AUTO'>"._QXZ("AUTO")."</option><option value='$demographic_quotas_list_resets' SELECTED>"._QXZ("$demographic_quotas_list_resets")."</option></select>$NWB#campaigns-demographic_quotas_list_resets$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>";
				if ($cqlr_selected > 0)
					{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$demographic_quotas_container\">"._QXZ("Demographic Quotas Container")."</a>";}
				else
					{echo _QXZ("Demographic Quotas Container");}
				echo ": </td><td align=left><select size=1 name=demographic_quotas_container><option value='DISABLED'>"._QXZ("DISABLED")."</option>$demo_quota_container_menu</select>$NWB#campaigns-demographic_quotas_container$NWE</td></tr>\n";
				}
			else
				{
				echo "<tr bgcolor=#$SSstd_row3_background><td colspan=2><input type=hidden name=demographic_quotas value='$demographic_quotas'><input type=hidden name=demographic_quotas_container value='$demographic_quotas_container'><input type=hidden name=demographic_quotas_rerank value='$demographic_quotas_rerank'><input type=hidden name=demographic_quotas_list_resets value='$demographic_quotas_list_resets'></td></tr>\n";
				}

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Hopper Drop-Run Trigger").": </td><td align=left><input type=checkbox name=hopper_drop_run_trigger value=\"Y\"> &nbsp; "._QXZ("All Drops").": <input type=checkbox name=hopper_drop_run_trigger_all value=\"A\">$NWB#campaigns-hopper_drop_run_trigger$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Drop Lockout Time").": </td><td align=left><input type=text name=drop_lockout_time size=6 maxlength=6 value=\"$drop_lockout_time\"> $NWB#campaigns-drop_lockout_time$NWE</td></tr>\n";

			if ($SSofcom_uk_drop_calc > 0)
				{
				echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("UK OFCOM Drop Calculation").": </td><td align=left><select size=1 name=ofcom_uk_drop_calc><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$ofcom_uk_drop_calc' SELECTED>"._QXZ("$ofcom_uk_drop_calc")."</option></select>$NWB#settings-ofcom_uk_drop_calc$NWE</td></tr>\n";
				}
			else
				{
				echo "<tr bgcolor=#$SSstd_row3_background><td colspan=2><input type=hidden name=ofcom_uk_drop_calc value='$ofcom_uk_drop_calc'></td></tr>\n";
				}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Call Count Limit").": </td><td align=left><input type=text name=call_count_limit size=4 maxlength=5 value=\"$call_count_limit\"> $NWB#campaigns-call_count_limit$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Call Count Target").": </td><td align=left><input type=text name=call_count_target size=4 maxlength=5 value=\"$call_count_target\"> $NWB#campaigns-call_count_target$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Call Count Limit Manual Restrict").": </td><td align=left><select size=1 name=call_count_limit_restrict>";
			echo "<option value='DISABLED'>"._QXZ("DISABLED")."</option>";
			echo "<option value='RESTRICT_ALL'>"._QXZ("RESTRICT_ALL")."</option>";
			echo "<option value='$call_count_limit_restrict' SELECTED>"._QXZ("$call_count_limit_restrict")."</option></select>$NWB#campaigns-call_count_limit_restrict$NWE</td></tr>\n";

			if ($SSdaily_call_count_limit > 0)
				{
				echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Daily Call Count Limit").": </td><td align=left><input type=text name=daily_call_count_limit size=4 maxlength=5 value=\"$daily_call_count_limit\"> $NWB#campaigns-daily_call_count_limit$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Daily Call Limit Manual").": </td><td align=left><select size=1 name=daily_limit_manual>";
				echo "<option value='DISABLED'>"._QXZ("DISABLED")."</option>";
				echo "<option value='COUNT_ONLY'>"._QXZ("COUNT_ONLY")."</option>";
				echo "<option value='RESTRICT_ONLY'>"._QXZ("RESTRICT_ONLY")."</option>";
				echo "<option value='COUNT_AND_RESTRICT'>"._QXZ("COUNT_AND_RESTRICT")."</option>";
				echo "<option value='$daily_limit_manual' SELECTED>"._QXZ("$daily_limit_manual")."</option></select>$NWB#settings-daily_limit_manual$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Daily Phone Number Call Limit System-wide").": </td><td align=left><input type=text name=daily_phone_number_call_limit size=4 maxlength=5 value=\"$daily_phone_number_call_limit\"> $NWB#campaigns-daily_phone_number_call_limit$NWE</td></tr>\n";
				}
			else
				{
				echo "<tr bgcolor=#$SSstd_row4_background><td colspan=2><input type=hidden name=daily_call_count_limit value='$daily_call_count_limit'><input type=hidden name=daily_limit_manual value='$daily_limit_manual'><input type=hidden name=daily_phone_number_call_limit value='$daily_phone_number_call_limit'></td></tr>\n";
				}

			if ($SScall_limit_24hour > 0)
				{
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("24-Hour Called Count Limit Method").": </td><td align=left><select size=1 name=call_limit_24hour_method>";
				echo "<option value='DISABLED'>"._QXZ("DISABLED")."</option>";
				echo "<option value='PHONE_NUMBER'>"._QXZ("PHONE_NUMBER")."</option>";
				echo "<option value='LEAD'>"._QXZ("LEAD")."</option>";
				echo "<option value='$call_limit_24hour_method' SELECTED>"._QXZ("$call_limit_24hour_method")."</option></select>$NWB#campaigns-call_limit_24hour_method$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("24-Hour Called Count Limit Scope").": </td><td align=left><select size=1 name=call_limit_24hour_scope>";
				echo "<option value='SYSTEM_WIDE'>"._QXZ("SYSTEM_WIDE")."</option>";
				echo "<option value='CAMPAIGN_LISTS'>"._QXZ("CAMPAIGN_LISTS")."</option>";
				echo "<option value='$call_limit_24hour_scope' SELECTED>"._QXZ("$call_limit_24hour_scope")."</option></select>$NWB#campaigns-call_limit_24hour_scope$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("24-Hour Called Count Limit").": </td><td align=left><input type=text name=call_limit_24hour size=4 maxlength=5 value=\"$call_limit_24hour\"> $NWB#campaigns-call_limit_24hour$NWE</td></tr>\n";

				##### get container listings for 24-hour call limit override pulldown menu
				$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='CALL_LIMITS_OVERRIDE' $LOGadmin_viewable_groupsSQL order by container_id;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$clo_to_print = mysqli_num_rows($rslt);
				$call_limit_24hour_override_container_menu='';
				$clo_selected=0;
				$o=0;
				while ($clo_to_print > $o) 
					{
					$rowx=mysqli_fetch_row($rslt);
					if (mb_strlen($rowx[1],'utf-8')>40)
						{$rowx[1] = mb_substr($rowx[1],0,40,'utf-8') . '...';}
					$call_limit_24hour_override_container_menu .= "<option ";
					if ($call_limit_24hour_override == "$rowx[0]") 
						{
						$call_limit_24hour_override_container_menu .= "SELECTED ";
						$clo_selected++;
						}
					$call_limit_24hour_override_container_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
					$o++;
					}

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>";
				if ($clo_selected > 0)
					{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$call_limit_24hour_override\">"._QXZ("24-Hour Called Count Limit Override")."</a>";}
				else
					{echo _QXZ("24-Hour Called Count Limit Override");}
				echo ": </td><td align=left><select size=1 name=call_limit_24hour_override>";
				echo "<option value=\"\">---"._QXZ("DISABLED")."---</option>";
				echo "$call_limit_24hour_override_container_menu";
				echo "</select>$NWB#campaigns-call_limit_24hour_override$NWE</td></tr>\n";
				}
			else
				{
				echo "<tr bgcolor=#$SSstd_row4_background><td colspan=2><input type=hidden name=call_limit_24hour_method value='$call_limit_24hour_method'><input type=hidden name=call_limit_24hour_scope value='$call_limit_24hour_scope'><input type=hidden name=call_limit_24hour value='$call_limit_24hour'><input type=hidden name=call_limit_24hour_override value='$call_limit_24hour_override'></td></tr>\n";
				}

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Minimum Hopper Level").": </td><td align=left><select size=1 name=hopper_level><option>1</option><option>5</option><option>10</option><option>20</option><option>50</option><option>100</option><option>200</option><option>500</option><option>700</option><option>1000</option><option>2000</option><option>3000</option><option>4000</option><option>5000</option><option SELECTED>$hopper_level</option></select>$NWB#campaigns-hopper_level$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Automatic Hopper Level").": </td><td align=left><select size=1 name=use_auto_hopper><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$use_auto_hopper' SELECTED>"._QXZ("$use_auto_hopper")."</option></select>$NWB#campaigns-use_auto_hopper$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Automatic Hopper Multiplier").": </td><td align=left><select size=1 name=auto_hopper_multi><option>0.1</option><option>0.2</option><option>0.3</option><option>0.4</option><option>0.5</option><option>0.6</option><option>0.7</option><option>0.8</option><option>0.9</option><option>1.0</option><option>1.1</option><option>1.2</option><option>1.3</option><option>1.4</option><option>1.5</option><option>1.6</option><option>1.7</option><option>1.8</option><option>1.9</option><option>2.0</option><option>2.2</option><option>2.4</option><option>2.6</option><option>2.8</option><option>3.0</option><option>3.5</option><option>4.0</option><option SELECTED>$auto_hopper_multi</option></select>$NWB#campaigns-auto_hopper_multi$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Auto Trim Hopper").": </td><td align=left><select size=1 name=auto_trim_hopper><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$auto_trim_hopper' SELECTED>"._QXZ("$auto_trim_hopper")."</option></select>$NWB#campaigns-auto_trim_hopper$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Hopper VLC Dup Check").": </td><td align=left><select size=1 name=hopper_vlc_dup_check><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$hopper_vlc_dup_check' SELECTED>"._QXZ("$hopper_vlc_dup_check")."</option></select>$NWB#campaigns-hopper_vlc_dup_check$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Manual Dial Hopper Check").": </td><td align=left><select size=1 name=manual_dial_hopper_check><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$manual_dial_hopper_check' SELECTED>"._QXZ("$manual_dial_hopper_check")."</option></select>$NWB#campaigns-manual_dial_hopper_check$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Force Reset of Hopper").": </td><td align=left><select size=1 name=reset_hopper><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select>$NWB#campaigns-force_reset_hopper$NWE</td></tr>\n";

			if ($SShopper_hold_inserts > 0)
				{
				echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Hopper Hold Inserts").": </td><td align=left><select size=1 name=hopper_hold_inserts><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option>";
				if ($SShopper_hold_inserts > 1)
					{
					echo "<option value='AUTONEXT'>"._QXZ("AUTONEXT")."</option>";
					}
				echo "<option value='$hopper_hold_inserts' SELECTED>"._QXZ("$hopper_hold_inserts")."</option></select>$NWB#campaigns-hopper_hold_inserts$NWE</td></tr>\n";
				}
			else
				{
				echo "<tr bgcolor=#$SSstd_row3_background><td colspan=2><input type=hidden name=hopper_hold_inserts value='$hopper_hold_inserts'></td></tr>\n";
				}

			if ( (preg_match("/RATIO|ADAPT/",$dial_method)) and ($SSdisable_auto_dial > 0) )
				{
				echo "<tr bgcolor=#$SSalt_row1_background><td align=center colspan=2><b>"._QXZ("Auto-dialing has been disabled on this system")."</b></td></tr>\n";
				}
			$shared_options='';
			if ($SSallow_shared_dial > 0)
				{$shared_options="<option value='SHARED_RATIO'>"._QXZ("SHARED_RATIO")."</option><option value='SHARED_ADAPT_HARD_LIMIT'>"._QXZ("SHARED_ADAPT_HARD_LIMIT")."</option><option value='SHARED_ADAPT_TAPERED'>"._QXZ("SHARED_ADAPT_TAPERED")."</option><option value='SHARED_ADAPT_AVERAGE'>"._QXZ("SHARED_ADAPT_AVERAGE")."</option>";}

			echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Dial Method").": </td><td align=left><select size=1 name=dial_method><option value='MANUAL'>"._QXZ("MANUAL")."</option><option value='RATIO'>"._QXZ("RATIO")."</option><option value='ADAPT_HARD_LIMIT'>"._QXZ("ADAPT_HARD_LIMIT")."</option><option value='ADAPT_TAPERED'>"._QXZ("ADAPT_TAPERED")."</option><option value='ADAPT_AVERAGE'>"._QXZ("ADAPT_AVERAGE")."</option><option value='INBOUND_MAN'>"._QXZ("INBOUND_MAN")."</option>$shared_options<option value='$dial_method' SELECTED>"._QXZ("$dial_method")."</option></select>$NWB#campaigns-dial_method$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Auto Dial Level").": </td><td align=left><select size=1 name=auto_dial_level><option selected>$auto_dial_level</option><option>0</option>\n";
			$adl=0;
			while($adl <= $SSauto_dial_limit)
				{
				if ($adl < 1)
					{$adl = ($adl + 1);}
				else
					{
					if ($adl < 3)
						{$adl = ($adl + 0.1);}
					else
						{
						if ($adl < 4)
							{$adl = ($adl + 0.25);}
						else
							{
							if ($adl < 5)
								{$adl = ($adl + 0.5);}
							else
								{
								if ($adl < 20)
									{$adl = ($adl + 1);}
								else
									{
									if ($adl < 40)
										{$adl = ($adl + 2);}
									else
										{
										if ($adl < 100)
											{$adl = ($adl + 5);}
										else
											{
											if ($adl < 200)
												{$adl = ($adl + 10);}
											else
												{
												if ($adl < 400)
													{$adl = ($adl + 50);}
												else
													{
													if ($adl < 1000)
														{$adl = ($adl + 100);}
													else
														{$adl = ($adl + 1);}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				if ($adl > $SSauto_dial_limit) {$hmm=1;}
				else {echo "<option>$adl</option>\n";}
				}
			echo "</select>(0 = "._QXZ("off").")$NWB#campaigns-auto_dial_level$NWE &nbsp; &nbsp; &nbsp; <input type=checkbox name=dial_level_override value=\"1\">"._QXZ("ADAPT OVERRIDE")."</td></tr>\n";

			echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Auto Dial Level Threshold").": </td><td align=left><select size=1 name=dial_level_threshold><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='LOGGED-IN_AGENTS'>"._QXZ("LOGGED-IN_AGENTS")."</option><option value='NON-PAUSED_AGENTS'>"._QXZ("NON-PAUSED_AGENTS")."</option><option value='WAITING_AGENTS'>"._QXZ("WAITING_AGENTS")."</option><option value='$dial_level_threshold' SELECTED>"._QXZ("$dial_level_threshold")."</option></select>$NWB#campaigns-dial_level_threshold$NWE &nbsp; &nbsp; &nbsp; "._QXZ("agents").": <select size=1 name=dial_level_threshold_agents><option SELECTED>$dial_level_threshold_agents</option><option>0</option><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option><option>10</option><option>11</option><option>12</option><option>13</option><option>14</option><option>15</option><option>16</option><option>17</option><option>18</option><option>19</option><option>20</option><option>25</option><option>30</option><option>35</option><option>40</option><option>50</option></select></td></tr>\n";

			echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Available Only Tally").": </td><td align=left><select size=1 name=available_only_ratio_tally><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$available_only_ratio_tally' SELECTED>"._QXZ("$available_only_ratio_tally")."</option></select>$NWB#campaigns-available_only_ratio_tally$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Available Only Tally Threshold").": </td><td align=left><select size=1 name=available_only_tally_threshold><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='LOGGED-IN_AGENTS'>"._QXZ("LOGGED-IN_AGENTS")."</option><option value='NON-PAUSED_AGENTS'>"._QXZ("NON-PAUSED_AGENTS")."</option><option value='WAITING_AGENTS'>"._QXZ("WAITING_AGENTS")."</option><option value='$available_only_tally_threshold' SELECTED>"._QXZ("$available_only_tally_threshold")."</option></select>$NWB#campaigns-available_only_tally_threshold$NWE &nbsp; &nbsp; &nbsp; "._QXZ("agents").": <select size=1 name=available_only_tally_threshold_agents><option SELECTED>$available_only_tally_threshold_agents</option><option>0</option><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option><option>10</option><option>11</option><option>12</option><option>13</option><option>14</option><option>15</option><option>16</option><option>17</option><option>18</option><option>19</option><option>20</option><option>25</option><option>30</option><option>35</option><option>40</option><option>50</option></select></td></tr>\n";

			echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Agent In-Call Tally Seconds Threshold").": </td><td align=left><input type=text name=incall_tally_threshold_seconds size=6 maxlength=4 value=\"$incall_tally_threshold_seconds\"><i>"._QXZ("digits only")."</i> $NWB#campaigns-incall_tally_threshold_seconds$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Drop Percentage Limit").": </td><td align=left><select size=1 name=adaptive_dropped_percentage>\n";
			$n=101;
			while ($n>=0.1)
				{
				if ($n <= 3)
					{$n = ($n - 0.1);}
				else
					{$n--;}
				echo "<option>$n</option>\n";
				}
			echo "<option SELECTED>$adaptive_dropped_percentage</option></select>% $NWB#campaigns-adaptive_dropped_percentage$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Maximum Adapt Dial Level").": </td><td align=left><input type=text name=adaptive_maximum_level size=6 maxlength=6 value=\"$adaptive_maximum_level\"><i>"._QXZ("number only")."</i> $NWB#campaigns-adaptive_maximum_level$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Latest Server Time").": </td><td align=left><input type=text name=adaptive_latest_server_time size=6 maxlength=4 value=\"$adaptive_latest_server_time\"><i>4 "._QXZ("digits only")."</i> $NWB#campaigns-adaptive_latest_server_time$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Adapt Intensity Modifier").": </td><td align=left><select size=1 name=adaptive_intensity>\n";
			$n=40;
			while ($n>=-40)
				{
				$dtl = _QXZ("Balanced");
				if ($n<0) {$dtl = _QXZ("Less Intense");}
				if ($n>0) {$dtl = _QXZ("More Intense");}
				if ($n == $adaptive_intensity) 
					{echo "<option SELECTED value=\"$n\">$n - $dtl</option>\n";}
				else
					{echo "<option value=\"$n\">$n - $dtl</option>\n";}
				$n--;
				}
			echo "</select> $NWB#campaigns-adaptive_intensity$NWE</td></tr>\n";



			echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Dial Level Difference Target").": </td><td align=left><select size=1 name=adaptive_dl_diff_target>\n";
			$n=40;
			while ($n>=-40)
				{
				$nabs = abs($n);
				$dtl = _QXZ("Balanced");
				if ($n<0) {$dtl = _QXZ("Agents Waiting for Calls");}
				if ($n>0) {$dtl = _QXZ("Calls Waiting for Agents");}
				if ($n == $adaptive_dl_diff_target) 
					{echo "<option SELECTED value=\"$n\">$n --- $nabs $dtl</option>\n";}
				else
					{echo "<option value=\"$n\">$n --- $nabs $dtl</option>\n";}
				$n--;
				}
			echo "</select> $NWB#campaigns-adaptive_dl_diff_target$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Dial Level Difference Target Method").": </td><td align=left><select size=1 name=dl_diff_target_method><option value='ADAPT_CALC_ONLY'>"._QXZ("ADAPT_CALC_ONLY")."</option><option value='CALLS_PLACED'>"._QXZ("CALLS_PLACED")."</option><option value='$dl_diff_target_method' SELECTED>"._QXZ("$dl_diff_target_method")."</option></select>$NWB#campaigns-dl_diff_target_method$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Concurrent Transfers").": </td><td align=left><select size=1 name=concurrent_transfers><option value='AUTO'>"._QXZ("AUTO")."</option><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option><option>10</option><option>15</option><option>20</option><option>25</option><option>30</option><option>40</option><option>50</option><option>60</option><option>80</option><option>100</option><option>1000</option><option>10000</option><option value=\"$concurrent_transfers\" SELECTED>"._QXZ("$concurrent_transfers")."</option></select>$NWB#campaigns-concurrent_transfers$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Queue Priority").": </td><td align=left><select size=1 name=queue_priority>\n";
			$n=99;
			while ($n>=-99)
				{
				$dtl = _QXZ("Even");
				if ($n<0) {$dtl = _QXZ("Lower");}
				if ($n>0) {$dtl = _QXZ("Higher");}
				if ($n == $queue_priority) 
					{echo "<option SELECTED value=\"$n\">$n - $dtl</option>\n";}
				else
					{echo "<option value=\"$n\">$n - $dtl</option>\n";}
				$n--;
				}
			echo "</select> $NWB#campaigns-queue_priority$NWE</td></tr>\n";

			if ($SSallow_shared_dial > 0)
				{
				echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Shared Dial Rank").": </td><td align=left><select size=1 name=shared_dial_rank>\n";
				$n=0;
				while ($n <= 99)
					{
					if ($n == $shared_dial_rank) 
						{echo "<option SELECTED value=\"$n\">$n</option>\n";}
					else
						{echo "<option value=\"$n\">$n</option>\n";}
					$n++;
					}
				echo "</select> $NWB#campaigns-shared_dial_rank$NWE</td></tr>\n";
				}
			else
				{echo "<tr bgcolor=#$SSstd_row3_background><td align=right><input type=hidden name=shared_dial_rank value=\"$shared_dial_rank\"></td></tr>";}

			echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Multiple Campaign Drop Rate Group").": </td><td align=left><select size=1 name=drop_rate_group>";
			##### get list_mix listings for dynamic pulldown
			$stmt="SELECT group_id from vicidial_drop_rate_groups;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$DRgroups_to_print = mysqli_num_rows($rslt);
			$DRgroups_list="<option value=\"DISABLED\">"._QXZ("DISABLED")."</option>\n";

			$o=0;
			while ($DRgroups_to_print > $o)
				{
				$rowx=mysqli_fetch_row($rslt);
				$DRgroups[$o] = "$rowx[0]";
				$o++;
				}

			$o=0;
			while ($DRgroups_to_print > $o)
				{
				$DRcampaigns='';
				$stmt="SELECT campaign_id from vicidial_campaigns where drop_rate_group='$DRgroups[$o]' $LOGallowed_campaignsSQL;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$DRcampaigns_to_print = mysqli_num_rows($rslt);
				$p=0;
				while ($DRcampaigns_to_print > $p)
					{
					$rowx=mysqli_fetch_row($rslt);
					$DRcampaigns .= "$rowx[0] ";
					$p++;
					}
				if (strlen($DRcampaigns)<2)
					{$DRcampaigns='-'._QXZ("EMPTY").'- ';}
				while(mb_strlen($DRcampaigns,'utf-8') > 45) {$DRcampaigns = mb_substr("$DRcampaigns", 0, -1,'utf-8');}
				if(mb_strlen($DRcampaigns,'utf-8') > 42) {$DRcampaigns = "$DRcampaigns...";}

				$DRgroups_list .= "<option value=\"$DRgroups[$o]\">$DRgroups[$o] ( $DRcampaigns)</option>\n";
				$o++;
				}
			echo "$DRgroups_list<option value=\"$drop_rate_group\" SELECTED>"._QXZ("$drop_rate_group")."</option></select>$NWB#campaigns-drop_rate_group$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Inbound Queue No Dial").": </td><td align=left><select size=1 name=inbound_queue_no_dial><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='ALL_SERVERS'>"._QXZ("ALL_SERVERS")."</option><option value='ENABLED_WITH_CHAT'>"._QXZ("ENABLED_WITH_CHAT")."</option><option value='ALL_SERVERS_WITH_CHAT'>"._QXZ("ALL_SERVERS_WITH_CHAT")."</option><option value='$inbound_queue_no_dial' SELECTED>"._QXZ("$inbound_queue_no_dial")."</option></select>$NWB#campaigns-inbound_queue_no_dial$NWE</td></tr>\n";

			##### get container listings for dynamic in-group list pulldown menu
			$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='INGROUP_LIST' $LOGadmin_viewable_groupsSQL order by container_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$inand_to_print = mysqli_num_rows($rslt);
			$inbound_no_agents_no_dial_container_menu='';
			$inand_selected=0;
			$o=0;
			while ($inand_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				if (mb_strlen($rowx[1],'utf-8')>40)
					{$rowx[1] = mb_substr($rowx[1],0,40,'utf-8') . '...';}
				$inbound_no_agents_no_dial_container_menu .= "<option ";
				if ($inbound_no_agents_no_dial_container == "$rowx[0]") 
					{
					$inbound_no_agents_no_dial_container_menu .= "SELECTED ";
					$inand_selected++;
					}
				$inbound_no_agents_no_dial_container_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$o++;
				}

			echo "<tr bgcolor=#$SSalt_row1_background><td align=right>";
			if ($inand_selected > 0)
				{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$inbound_no_agents_no_dial_container\">"._QXZ("Inbound No-Agents No-Dial")."</a>";}
			else
				{echo _QXZ("Inbound No-Agents No-Dial");}
			echo ": </td><td align=left><select size=1 name=inbound_no_agents_no_dial_container>";
			echo "<option value=\"\">---"._QXZ("DISABLED")."---</option>";
			echo "$inbound_no_agents_no_dial_container_menu";
			echo "</select>$NWB#campaigns-inbound_no_agents_no_dial_container$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Inbound No-Agents No-Dial Threshold").": </td><td align=left><input type=text name=inbound_no_agents_no_dial_threshold size=3 maxlength=3 value=\"$inbound_no_agents_no_dial_threshold\"><i>"._QXZ("number only")."</i> $NWB#campaigns-inbound_no_agents_no_dial_threshold$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Auto Alt-Number Dialing").": </td><td align=left><select size=1 name=auto_alt_dial><option value='NONE'>"._QXZ("NONE")."</option><option value='ALT_ONLY'>"._QXZ("ALT_ONLY")."</option><option value='ADDR3_ONLY'>"._QXZ("ADDR3_ONLY")."</option><option value='ALT_AND_ADDR3'>"._QXZ("ALT_AND_ADDR3")."</option><option value='ALT_AND_EXTENDED'>"._QXZ("ALT_AND_EXTENDED")."</option><option value='ALT_AND_ADDR3_AND_EXTENDED'>"._QXZ("ALT_AND_ADDR3_AND_EXTENDED")."</option><option value='EXTENDED_ONLY'>"._QXZ("EXTENDED_ONLY")."</option><option value='MULTI_LEAD'>"._QXZ("MULTI_LEAD")."</option><option value='$auto_alt_dial' SELECTED>"._QXZ("$auto_alt_dial")."</option></select>$NWB#campaigns-auto_alt_dial$NWE $ALTmultiLINK</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Auto Alt-Number Dialing Threshold").": </td><td align=left><input type=text name=auto_alt_threshold size=3 maxlength=3 value=\"$auto_alt_threshold\"><i>"._QXZ("number only")."</i> $NWB#campaigns-auto_alt_threshold$NWE</td></tr>\n";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Next Agent Call").": </td><td align=left><select size=1 name=next_agent_call><option value='random'>"._QXZ("random")."</option><option value='oldest_call_start'>"._QXZ("oldest_call_start")."</option><option value='oldest_call_finish'>"._QXZ("oldest_call_finish")."</option><option value='overall_user_level'>"._QXZ("overall_user_level")."</option><option value='campaign_rank'>"._QXZ("campaign_rank")."</option><option value='campaign_grade_random'>"._QXZ("campaign_grade_random")."</option><option value='fewest_calls'>"._QXZ("fewest_calls")."</option><option value='longest_wait_time'>"._QXZ("longest_wait_time")."</option><option value='overall_user_level_wait_time'>"._QXZ("overall_user_level_wait_time")."</option><option value='campaign_rank_wait_time'>"._QXZ("campaign_rank_wait_time")."</option><option value='fewest_calls_wait_time'>"._QXZ("fewest_calls_wait_time")."</option><option value='$next_agent_call' SELECTED>"._QXZ("$next_agent_call")."</option></select>$NWB#campaigns-next_agent_call$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=311111111&call_time_id=$local_call_time\">"._QXZ("Local Call Time").": </a></td><td align=left><select size=1 name=local_call_time>\n";
		echo "$call_times_list";
		echo "<option selected value=\"$local_call_time\">$local_call_time - $call_timename_list[$local_call_time]</option>\n";
		echo "</select>$NWB#campaigns-local_call_time$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>\n";
		$stmt="SELECT ct_state_call_times,ct_holidays from vicidial_call_times where call_time_id='$local_call_time';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$call_times_to_print = mysqli_num_rows($rslt);
		if ($call_times_to_print > 0) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$ct_state_call_times =	$rowx[0];
			$ct_holidays =			$rowx[1];
			$state_rules = explode('|',$ct_state_call_times);
			$holidays = explode('|',$ct_holidays);
			$ct_srs = ((count($state_rules)) - 2);
			$ct_hld = ((count($holidays)) - 2);
			if ($ct_srs < 0) {$ct_srs=0;}
			if ($ct_hld < 0) {$ct_hld=0;}
			echo "<font size=2>"._QXZ("State rules defined for this call time").": $ct_srs &nbsp; &nbsp; "._QXZ("Holidays defined for this call time").": $ct_hld\n";
			}
		else
			{echo "<BLINK><B><font color=red>"._QXZ("Call time not found")."!: $local_call_time</font></B></BLINK>\n";}
		echo "</td></tr>\n";

		if ($SSoutbound_autodial_active > 0)
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Dial Timeout").": </td><td align=left><input type=text name=dial_timeout size=3 maxlength=3 value=\"$dial_timeout\"> <i>"._QXZ("in seconds")."</i>$NWB#campaigns-dial_timeout$NWE</td></tr>\n";
			}

		##### get container listings for dynamic dial timeout lead container pulldown menu
		$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='DIAL_TIMEOUTS' $LOGadmin_viewable_groupsSQL order by container_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$dtlc_to_print = mysqli_num_rows($rslt);
		$dial_timeout_lead_container_menu='';
		$dtlc_selected=0;
		$o=0;
		while ($dtlc_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			if (mb_strlen($rowx[1],'utf-8')>40)
				{$rowx[1] = mb_substr($rowx[1],0,40,'utf-8') . '...';}
			$dial_timeout_lead_container_menu .= "<option ";
			if ($dial_timeout_lead_container == "$rowx[0]") 
				{
				$dial_timeout_lead_container_menu .= "SELECTED ";
				$dtlc_selected++;
				}
			$dial_timeout_lead_container_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>";
		if ($dtlc_selected > 0)
			{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$dial_timeout_lead_container\">"._QXZ("Dial Timeout Lead Container")."</a>";}
		else
			{echo _QXZ("Dial Timeout Lead Container");}
		echo ": </td><td align=left><select size=1 name=dial_timeout_lead_container><option value='DISABLED'>"._QXZ("DISABLED")."</option>$dial_timeout_lead_container_menu</select>$NWB#campaigns-dial_timeout_lead_container$NWE</td></tr>\n";

		if ($LOGmodify_dial_prefix > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Dial Prefix").": </td><td align=left><input type=text name=dial_prefix size=20 maxlength=20 value=\"$dial_prefix\"> <font size=1>"._QXZ("for")." 91NXXNXXXXXX "._QXZ("value would be 9, for no dial prefix use X")."</font>$NWB#campaigns-dial_prefix$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Manual Dial Prefix").": </td><td align=left><input type=text name=manual_dial_prefix size=20 maxlength=20 value=\"$manual_dial_prefix\"> $NWB#campaigns-manual_dial_prefix$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><input type=hidden name=dial_prefix value=\"$dial_prefix\"><input type=hidden name=manual_dial_prefix value=\"$manual_dial_prefix\"></td></tr>";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Omit Phone Code").": </td><td align=left><select size=1 name=omit_phone_code><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$omit_phone_code' SELECTED>"._QXZ("$omit_phone_code")."</option></select>$NWB#campaigns-omit_phone_code$NWE</td></tr>\n";

		$DID_edit_link_BEGIN='';
		$DID_edit_link_END='';
		if (strlen($campaign_cid) > 0)
			{
			$stmt="SELECT did_id from vicidial_inbound_dids where did_pattern='$campaign_cid' $LOGadmin_viewable_groupsSQL limit 1;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$dids_to_print = mysqli_num_rows($rslt);
			if ($dids_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$DID_edit_link_BEGIN = "<a href=\"$PHP_SELF?ADD=3311&did_id=$rowx[0]\">";
				$DID_edit_link_END='</a>';
				}
			}
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>$DID_edit_link_BEGIN"._QXZ("Campaign CallerID")."$DID_edit_link_END: </td><td align=left><input type=text name=campaign_cid size=20 maxlength=20 value=\"$campaign_cid\">$NWB#campaigns-campaign_cid$NWE\n";
		$stmt="SELECT count(*) from vicidial_lists where campaign_id='$campaign_id' and campaign_cid_override != '' and active='Y' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$rowx=mysqli_fetch_row($rslt);
		if ($rowx[0] > 0) 
			{echo " <font color=red>"._QXZ("LIST OVERRIDE ACTIVE")."</font>";}
		echo "</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Custom CallerID").": </td><td align=left><select size=1 name=use_custom_cid><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='AREACODE'>"._QXZ("AREACODE")."</option><option value='USER_CUSTOM_1'>"._QXZ("USER_CUSTOM_1")."</option><option value='USER_CUSTOM_2'>"._QXZ("USER_CUSTOM_2")."</option><option value='USER_CUSTOM_3'>"._QXZ("USER_CUSTOM_3")."</option><option value='USER_CUSTOM_4'>"._QXZ("USER_CUSTOM_4")."</option><option value='USER_CUSTOM_5'>"._QXZ("USER_CUSTOM_5")."</option><option value='$use_custom_cid' SELECTED>"._QXZ("$use_custom_cid")."</option></select>$NWB#campaigns-use_custom_cid$NWE</td></tr>\n";

		if ($SScampaign_cid_areacodes_enabled == '1')
			{
			##### get vicidial_cid_groups listings for dynamic pulldown list
			$stmt="SELECT cid_group_id,cid_group_type,cid_group_notes from vicidial_cid_groups $whereLOGadmin_viewable_groupsSQL order by cid_group_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$cid_groups_to_print = mysqli_num_rows($rslt);
			$cid_groups_menu='';   $cid_groups_two_menu='';
			$cid_groups_selected=0;   $cid_groups_two_selected=0;
			$o=0;
			while ($cid_groups_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$cid_groups_menu .= "<option ";
				if ($cid_group_id == "$rowx[0]") 
					{
					$cid_groups_menu .= "SELECTED ";
					$cid_groups_selected++;
					}
				$cid_groups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1] - $rowx[2]</option>\n";
				$cid_groups_two_menu .= "<option ";
				if ($cid_group_id_two == "$rowx[0]") 
					{
					$cid_groups_two_menu .= "SELECTED ";
					$cid_groups_two_selected++;
					}
				$cid_groups_two_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1] - $rowx[2]</option>\n";
				$o++;
				}

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>";
			if ($cid_groups_selected > 0)
				{echo "<a href=\"$PHP_SELF?ADD=396111111111&cid_group_id=$cid_group_id\">"._QXZ("CID Group")."</a>";}
			else
				{echo _QXZ("CID Group");}
			echo ": </td><td align=left><select size=1 name=cid_group_id>";
			echo "<option value=\"---DISABLED---\">---"._QXZ("DISABLED")."---</option>";
			echo "$cid_groups_menu";
			echo "</select>$NWB#campaigns-cid_group_id$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>";
			if ($cid_groups_two_selected > 0)
				{echo "<a href=\"$PHP_SELF?ADD=396111111111&cid_group_id=$cid_group_id_two\">"._QXZ("CID Group Failover")."</a>";}
			else
				{echo _QXZ("CID Group Failover");}
			echo ": </td><td align=left><select size=1 name=cid_group_id_two>";
			echo "<option value=\"---DISABLED---\">---"._QXZ("DISABLED")."---</option>";
			echo "$cid_groups_two_menu";
			echo "</select>$NWB#campaigns-cid_group_id_two$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right><input type=hidden name=cid_group_id value=\"$cid_group_id\"><input type=hidden name=cid_group_id_two value=\"$cid_group_id_two\"></td></tr>";
			}

		if ($SSopensips_cid_name == '1')
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Campaign CID Name").": </td><td align=left><input type=text name=opensips_cid_name size=17 maxlength=15 value=\"$opensips_cid_name\">$NWB#campaigns-opensips_cid_name$NWE\n";
			}
		else
			{echo "<tr bgcolor=#$SSstd_row3_background><td align=right><input type=hidden name=opensips_cid_name value=\"$opensips_cid_name\"></td></tr>";}

		if ($SSoutbound_autodial_active > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Routing Extension").": </td><td align=left><input type=text name=campaign_vdad_exten size=10 maxlength=20 value=\"$campaign_vdad_exten\">$NWB#campaigns-campaign_vdad_exten$NWE</td></tr>\n";
			if ( ($SSagent_search_method == 1) or ($SSagent_search_method == 3) )
				{
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Search Method Override").": </td><td align=left><select size=1 name=agent_search_method>\n";
				echo "<option value=\"LB\""; if ($agent_search_method == 'LB') {echo " SELECTED";}
				echo ">LB - "._QXZ("Load Balanced")."</option>\n";
				echo "<option value=\"LO\""; if ($agent_search_method == 'LO') {echo " SELECTED";}
				echo ">LO - "._QXZ("Load Balanced Overflow")."</option>\n";
				echo "<option value=\"SO\""; if ($agent_search_method == 'SO') {echo " SELECTED";}
				echo ">SO - "._QXZ("Server Only")."</option>\n";
				echo "<option value=\"\""; if ($agent_search_method == '') {echo " SELECTED";}
				echo ">"._QXZ("DISABLED")."</option>\n";
				echo "</select>$NWB#campaigns-agent_search_method$NWE</td></tr>\n";
				}
			else
				{
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right><input type=hidden name=agent_search_method value=\"$agent_search_method\"></td></tr>";
				}
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><input type=hidden name=campaign_vdad_exten value=\"$campaign_vdad_exten\"></td></tr>";
			}
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Campaign Rec exten").": </td><td align=left><input type=text name=campaign_rec_exten size=10 maxlength=10 value=\"$campaign_rec_exten\">$NWB#campaigns-campaign_rec_exten$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Campaign Recording").": </td><td align=left><select size=1 name=campaign_recording><option value='NEVER'>"._QXZ("NEVER")."</option><option value='ONDEMAND'>"._QXZ("ONDEMAND")."</option><option value='ALLCALLS'>"._QXZ("ALLCALLS")."</option><option value='ALLFORCE'>"._QXZ("ALLFORCE")."</option><option value='$campaign_recording' SELECTED>"._QXZ("$campaign_recording")."</option></select>$NWB#campaigns-campaign_recording$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Campaign Rec Filename").": </td><td align=left><input type=text name=campaign_rec_filename size=50 maxlength=50 value=\"$campaign_rec_filename\">$NWB#campaigns-campaign_rec_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Recording Delay").": </td><td align=left><input type=text name=allcalls_delay size=3 maxlength=3 value=\"$allcalls_delay\"> <i>"._QXZ("in seconds")."</i>$NWB#campaigns-allcalls_delay$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Routing Initiated Recording").": </td><td align=left><select size=1 name=routing_initiated_recordings><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$routing_initiated_recordings' SELECTED>"._QXZ("$routing_initiated_recordings")."</option></select>$NWB#campaigns-routing_initiated_recordings$NWE</td></tr>\n";

		if ($SSmute_recordings =='1')
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Mute Recording Button").": </td><td align=left><select size=1 name=mute_recordings><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$mute_recordings' SELECTED>"._QXZ("$mute_recordings")."</option></select> $NWB#campaigns-mute_recordings$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right></td><td align=left><input type=hidden name=mute_recordings value='$mute_recordings'></td></tr>\n";
			}

		if ( ($SSstereo_recording =='1') or ($SSstereo_recording =='2') or ($SSstereo_recording =='3') or ($SSstereo_recording =='4') or ($SSstereo_recording =='5') )
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Stereo Call Recordings").": </td><td align=left><select size=1 name=stereo_recording><option value='BOTH_CHANNELS'>"._QXZ("BOTH_CHANNELS")."</option><option value='CUSTOMER_ONLY'>"._QXZ("CUSTOMER_ONLY")."</option><option value='CUSTOMER_MUTE'>"._QXZ("CUSTOMER_MUTE")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$stereo_recording' SELECTED>"._QXZ("$stereo_recording")."</option></select> $NWB#campaigns-stereo_recording$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Stereo Recording Agent Control").": </td><td align=left><select size=1 name=stereo_recording_agent><option value='NEVER'>"._QXZ("NEVER")."</option><option value='ONDEMAND'>"._QXZ("ONDEMAND")."</option><option value='ALLCALLS'>"._QXZ("ALLCALLS")."</option><option value='ALLFORCE'>"._QXZ("ALLFORCE")."</option><option value='$stereo_recording_agent' SELECTED>"._QXZ("$stereo_recording_agent")."</option></select> $NWB#campaigns-stereo_recording_agent$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Stereo Rec Filename").": </td><td align=left><input type=text name=stereo_rec_filename size=50 maxlength=50 value=\"$stereo_rec_filename\">$NWB#campaigns-stereo_rec_filename$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right></td><td align=left><input type=hidden name=stereo_recording value='$stereo_recording'><input type=hidden name=stereo_rec_filename value='$stereo_rec_filename'><input type=hidden name=stereo_recording_agent value='$stereo_recording_agent'></td></tr>\n";
			}
		if ( ( ($SSstereo_recording =='1') or ($SSstereo_recording =='2') or ($SSstereo_recording =='3') or ($SSstereo_recording =='4') or ($SSstereo_recording =='5') ) and ($SSstereo_parallel_recording == '1') )
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Parallel Stereo Recordings").": </td><td align=left><select size=1 name=stereo_parallel_recording><option value='CUSTOMER-ONLY'>"._QXZ("CUSTOMER-ONLY")."</option><option value='CUSTOMER-MUTED'>"._QXZ("CUSTOMER-MUTED")."</option><option value='CUSTOMER-ONLY_CUSTOMER-MUTED'>"._QXZ("CUSTOMER-ONLY_CUSTOMER-MUTED")."</option><option value='FULL-RECORDING'>"._QXZ("FULL-RECORDING")."</option><option value='CUSTOMER-ONLY_FULL-RECORDING'>"._QXZ("CUSTOMER-ONLY_FULL-RECORDING")."</option><option value='CUSTOMER-MUTED_FULL-RECORDING'>"._QXZ("CUSTOMER-MUTED_FULL-RECORDING")."</option><option value='CUSTOMER-ONLY_CUSTOMER-MUTED_FULL-RECORDING'>"._QXZ("CUSTOMER-ONLY_CUSTOMER-MUTED_FULL-RECORDING")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$stereo_parallel_recording' SELECTED>"._QXZ("$stereo_parallel_recording")."</option></select> $NWB#campaigns-stereo_parallel_recording$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Parallel Customer-Only Rec Filename").": </td><td align=left><input type=text name=parallel_rec_co_filename size=50 maxlength=50 value=\"$parallel_rec_co_filename\">$NWB#inbound_groups-parallel_rec_xx_filename$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Parallel Customer-Muted Rec Filename").": </td><td align=left><input type=text name=parallel_rec_cm_filename size=50 maxlength=50 value=\"$parallel_rec_cm_filename\">$NWB#inbound_groups-parallel_rec_xx_filename$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Parallel Full-Recording Rec Filename").": </td><td align=left><input type=text name=parallel_rec_fr_filename size=50 maxlength=50 value=\"$parallel_rec_fr_filename\">$NWB#inbound_groups-parallel_rec_xx_filename$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right></td><td align=left><input type=hidden name=stereo_parallel_recording value='$stereo_parallel_recording'><input type=hidden name=parallel_rec_co_filename value='$parallel_rec_co_filename'><input type=hidden name=parallel_rec_cm_filename value='$parallel_rec_cm_filename'><input type=hidden name=parallel_rec_fr_filename value='$parallel_rec_fr_filename'></td></tr>\n";
			}
		if ( ( ($SSrecording_dtmf_muting =='1') or ($SSrecording_dtmf_muting =='2') or ($SSrecording_dtmf_muting =='3') ) and ($SSrecording_dtmf_detection == '1') )
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Recording DTMF Muting").": </td><td align=left><input type=text name=recording_dtmf_muting size=2 maxlength=3 value=\"$recording_dtmf_muting\"> $NWB#campaigns-recording_dtmf_muting$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right></td><td align=left><input type=hidden name=recording_dtmf_muting value='$recording_dtmf_muting'></td></tr>\n";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Call Notes Per Call").": </td><td align=left><select size=1 name=per_call_notes><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$per_call_notes' SELECTED>"._QXZ("$per_call_notes")."</option></select>$NWB#campaigns-per_call_notes$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Per Call Notes Required").": </td><td align=left><select size=1 name=force_per_call_notes><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='5_CHARACTERS'>"._QXZ("5_CHARACTERS")."</option><option value='15_CHARACTERS'>"._QXZ("15_CHARACTERS")."</option><option value='30_CHARACTERS'>"._QXZ("30_CHARACTERS")."</option><option value='100_CHARACTERS'>"._QXZ("100_CHARACTERS")."</option><option value='$force_per_call_notes' SELECTED>"._QXZ("$force_per_call_notes")."</option></select>$NWB#campaigns-force_per_call_notes$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Comments All Tabs").": </td><td align=left><select size=1 name=comments_all_tabs><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$comments_all_tabs' SELECTED>"._QXZ("$comments_all_tabs")."</option></select>$NWB#campaigns-comments_all_tabs$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Comments Dispo Screen").": </td><td align=left><select size=1 name=comments_dispo_screen><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='REPLACE_CALL_NOTES'>"._QXZ("REPLACE_CALL_NOTES")."</option><option value='$comments_dispo_screen' SELECTED>"._QXZ("$comments_dispo_screen")."</option></select>$NWB#campaigns-comments_dispo_screen$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Comments Callback Screen").": </td><td align=left><select size=1 name=comments_callback_screen><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='REPLACE_CB_NOTES'>"._QXZ("REPLACE_CB_NOTES")."</option><option value='$comments_callback_screen' SELECTED>"._QXZ("$comments_callback_screen")."</option></select>$NWB#campaigns-comments_callback_screen$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("QC Comments History").": </td><td align=left><select size=1 name=qc_comment_history><option value='CLICK'>"._QXZ("CLICK")."</option><option value='AUTO_OPEN'>"._QXZ("AUTO_OPEN")."</option><option value='CLICK_ALLOW_MINIMIZE'>"._QXZ("CLICK_ALLOW_MINIMIZE")."</option><option value='AUTO_OPEN_ALLOW_MINIMIZE'>"._QXZ("AUTO_OPEN_ALLOW_MINIMIZE")."</option><option value='$qc_comment_history' SELECTED>"._QXZ("$qc_comment_history")."</option></select>$NWB#campaigns-qc_comment_history$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Hide Call Log Info").": </td><td align=left><select size=1 name=hide_call_log_info><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='SHOW_1'>"._QXZ("SHOW")."_1</option><option value='SHOW_2'>"._QXZ("SHOW")."_2</option><option value='SHOW_3'>"._QXZ("SHOW")."_3</option><option value='SHOW_4'>"._QXZ("SHOW")."_4</option><option value='SHOW_5'>"._QXZ("SHOW")."_5</option><option value='SHOW_6'>"._QXZ("SHOW")."_6</option><option value='SHOW_7'>"._QXZ("SHOW")."_7</option><option value='SHOW_8'>"._QXZ("SHOW")."_8</option><option value='SHOW_9'>"._QXZ("SHOW")."_9</option><option value='SHOW_10'>"._QXZ("SHOW")."_10</option><option value='$hide_call_log_info' SELECTED>"._QXZ("$hide_call_log_info")."</option></select>$NWB#campaigns-hide_call_log_info$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Call Log View Days").": </td><td align=left><input type=text name=call_log_days size=4 maxlength=4 value=\"$call_log_days\"> $NWB#campaigns-call_log_days$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Lead Search").": </td><td align=left><select size=1 name=agent_lead_search><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='LIVE_CALL_INBOUND'>"._QXZ("LIVE_CALL_INBOUND")."</option><option value='LIVE_CALL_INBOUND_AND_MANUAL'>"._QXZ("LIVE_CALL_INBOUND_AND_MANUAL")."</option><option value='$agent_lead_search' SELECTED>"._QXZ("$agent_lead_search")."</option></select>$NWB#campaigns-agent_lead_search$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Lead Search Method").": </td><td align=left><select size=1 name=agent_lead_search_method><option value='SYSTEM'>"._QXZ("SYSTEM")."</option><option value='CAMPAIGNLISTS'>"._QXZ("CAMPAIGNLISTS")."</option><option value='CAMPLISTS_ALL'>"._QXZ("CAMPLISTS_ALL")."</option><option value='LIST'>"._QXZ("LIST")."</option><option value='USER_CAMPAIGNLISTS'>"._QXZ("USER_CAMPAIGNLISTS")."</option><option value='USER_CAMPLISTS_ALL'>"._QXZ("USER_CAMPLISTS_ALL")."</option><option value='USER_LIST'>"._QXZ("USER_LIST")."</option><option value='GROUP_SYSTEM'>"._QXZ("GROUP_SYSTEM")."</option><option value='GROUP_CAMPAIGNLISTS'>"._QXZ("GROUP_CAMPAIGNLISTS")."</option><option value='GROUP_CAMPLISTS_ALL'>"._QXZ("GROUP_CAMPLISTS_ALL")."</option><option value='GROUP_LIST'>"._QXZ("GROUP_LIST")."</option><option value='TERRITORY_SYSTEM'>"._QXZ("TERRITORY_SYSTEM")."</option><option value='TERRITORY_CAMPAIGNLISTS'>"._QXZ("TERRITORY_CAMPAIGNLISTS")."</option><option value='TERRITORY_CAMPLISTS_ALL'>"._QXZ("TERRITORY_CAMPLISTS_ALL")."</option><option value='TERRITORY_LIST'>"._QXZ("TERRITORY_LIST")."<option value='$agent_lead_search_method' SELECTED>"._QXZ("$agent_lead_search_method")."</option></select>$NWB#campaigns-agent_lead_search_method$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Search In-Group List Restrict").": </td><td align=left><select size=1 name=agent_search_ingroup_list><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='ENABLED_OVERRIDE'>"._QXZ("ENABLED_OVERRIDE")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$agent_search_ingroup_list' SELECTED>"._QXZ("$agent_search_ingroup_list")."</option></select>$NWB#campaigns-agent_search_ingroup_list$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right><a href=\"$PHP_SELF?ADD=3111111&script_id=$script_id\">"._QXZ("Script")."</a>: </td><td align=left><select size=1 name=script_id>\n";
		echo "$scripts_list";
		echo "<option selected value=\"$script_id\">"._QXZ("$script_id")." - $scriptname_list[$script_id]</option>\n";
		echo "</select>$NWB#campaigns-campaign_script$NWE\n";
		$stmt="SELECT count(*) from vicidial_lists where campaign_id='$campaign_id' and agent_script_override != '' and active='Y' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$rowx=mysqli_fetch_row($rslt);
		if ($rowx[0] > 0) 
			{echo " <font color=red>"._QXZ("LIST OVERRIDE ACTIVE")."</font>";}
		echo "</td></tr>\n";

		if ($SSenable_second_script > 0)
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right><a href=\"$PHP_SELF?ADD=3111111&script_id=$campaign_script_two\">"._QXZ("Script Two").": </td><td align=left><select size=1 name=campaign_script_two>\n";
			echo "$scripts_list";
			echo "<option selected value=\"$campaign_script_two\">"._QXZ("$campaign_script_two")." - $scriptname_list[$campaign_script_two]</option>\n";
			echo "</select>$NWB#campaigns-campaign_script$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right></td><td align=left><input type=hidden name=campaign_script_two value='$campaign_script_two'></td></tr>\n";
			}

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Clear Script").": </td><td align=left><select size=1 name=clear_script><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='$clear_script' SELECTED>"._QXZ("$clear_script")."</option></select>$NWB#campaigns-clear_script$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("User Group Script Override").": </td><td align=left><select size=1 name=user_group_script><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='$user_group_script' SELECTED>"._QXZ("$user_group_script")."</option></select>$NWB#campaigns-user_group_script$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Script Tab Frame Location").": </td><td align=left><select size=1 name=script_tab_frame_size><option value='DEFAULT'>"._QXZ("DEFAULT")."</option><option value='LEFT_EDGE'>"._QXZ("LEFT_EDGE")."</option><option value='$script_tab_frame_size' SELECTED>"._QXZ("$script_tab_frame_size")."</option></select>$NWB#campaigns-script_tab_frame_size$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Script Tab Height Override").": </td><td align=left><input type=text name=script_tab_height size=5 maxlength=4 value=\"$script_tab_height\"> $NWB#campaigns-script_tab_height$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Clear Form Tab").": </td><td align=left><select size=1 name=clear_form><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='ACKNOWLEDGE'>"._QXZ("ACKNOWLEDGE")."</option><option value='$clear_form' SELECTED>"._QXZ("$clear_form")."</option></select>$NWB#campaigns-clear_form$NWE</td></tr>\n";

		$eswHTML=''; $cfwHTML=''; $aemHTML=''; $achHTML='';
		if ($SSenable_second_script > 0)
			{$eswHTML .= "<option value='SCRIPTTWO'>"._QXZ("SCRIPTTWO")."</option><option value='PREVIEW_SCRIPTTWO'>"._QXZ("PREVIEW_SCRIPTTWO")."</option>";}
		if ($SSenable_second_webform > 0)
			{$eswHTML .= '<option value="WEBFORMTWO">'._QXZ("WEBFORMTWO").'</option><option value="PREVIEW_WEBFORMTWO">'._QXZ("PREVIEW_WEBFORMTWO").'</option>';}
		if ($SSenable_third_webform > 0)
			{$eswHTML .= "<option value='WEBFORMTHREE'>"._QXZ("WEBFORMTHREE")."</option><option value='PREVIEW_WEBFORMTHREE'>"._QXZ("PREVIEW_WEBFORMTHREE")."</option>";}
		if ($SScustom_fields_enabled > 0)
			{$cfwHTML .= '<option value="FORM">'._QXZ("FORM").'</option><option value="PREVIEW_FORM">'._QXZ("PREVIEW_FORM").'</option>';}
		if ($SSallow_emails > 0)
			{$aemHTML .= "<option value='EMAIL'>"._QXZ("EMAIL")."</option>";}
		if ($SSallow_chats > 0)
			{$achHTML .= '<option value="CHAT">'._QXZ("CHAT").'</option>';}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Get Call Launch").": </td><td align=left><select size=1 name=get_call_launch><option value='NONE' selected>"._QXZ("NONE")."</option><option value='SCRIPT'>"._QXZ("SCRIPT")."</option><option value='PREVIEW_SCRIPT'>"._QXZ("PREVIEW_SCRIPT")."</option><option value='WEBFORM'>"._QXZ("WEBFORM")."</option><option value='PREVIEW_WEBFORM'>"._QXZ("PREVIEW_WEBFORM")."</option>$eswHTML$cfwHTML$aemHTML$achHTML<option value='$get_call_launch' selected>"._QXZ("$get_call_launch")."</option></select>$NWB#campaigns-get_call_launch$NWE</td></tr>\n";

		if ($SSbrowser_call_alerts > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Browser Call Alert Sound").": </td><td align=left><select size=1 name='browser_alert_sound' id='browser_alert_sound'>\n";
			$browser_alert_sounds_listARY = explode(',',$browser_alert_sounds_list);
			$browser_alert_sounds_listARY_ct = count($browser_alert_sounds_listARY);
			$bas=0;   $bas_output='';
			while ($browser_alert_sounds_listARY_ct > $bas)
				{
				$bas_output .= "<option value='$browser_alert_sounds_listARY[$bas]'>"._QXZ("$browser_alert_sounds_listARY[$bas]")."</option>";
				$bas++;
				}
			echo "$bas_output";
			echo "<option value='---NONE---'>---"._QXZ("NONE")."---</option>";
			echo "<option value='$browser_alert_sound' selected>"._QXZ("$browser_alert_sound")."</option>";
			echo "</select> &nbsp; \n";
			echo " "._QXZ("volume").": <select size=1 name='browser_alert_volume' id='browser_alert_volume'>";
			$bav=100;
			while ($bav >= 0)
				{
				echo "<option>$bav</option>";
				$bav = ($bav - 5);
				}
			echo "<option selected>$browser_alert_volume</option></select> &nbsp; ";
			echo "<a href=\"#\" onclick=\"play_browser_sound('browser_alert_sound','browser_alert_volume');return false;\"><font size=2 color=black>"._QXZ("play selected sound")."</font></a> $NWB#campaigns-browser_alert_sound$NWE &nbsp; </td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right></td><td align=left><input type=hidden name=browser_alert_sound value=\"$browser_alert_sound\"><input type=hidden name=browser_alert_volume value=\"$browser_alert_volume\"></td></tr>\n";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Show Confetti").": </td><td align=left><select size=1 name='show_confetti' id='show_confetti'>\n";
		echo "<option selected value=\"$show_confetti\">"._QXZ("$show_confetti")."</option>\n";
		echo "<option value='DISABLED'>"._QXZ("DISABLED")."</option>";
		echo "<option value='SALES'>"._QXZ("SALES")."</option>";
		echo "<option value='CALLBACKS'>"._QXZ("CALLBACKS")."</option>";
		echo "<option value='SALES_AND_CALLBACKS'>"._QXZ("SALES_AND_CALLBACKS")."</option>";
		echo "</select> $NWB#campaigns-show_confetti$NWE</td></tr>";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Answering Machine Message").": </td><td><input type=text size=50 maxlength=100 name=am_message_exten id=am_message_exten value=\"$am_message_exten\"> <a href=\"javascript:launch_chooser('am_message_exten','date');\">"._QXZ("audio chooser")."</a>  $NWB#campaigns-am_message_exten$NWE\n";
		$stmt="SELECT count(*) from vicidial_lists where campaign_id='$campaign_id' and am_message_exten_override != '' and active='Y' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$rowx=mysqli_fetch_row($rslt);
		if ($rowx[0] > 0) 
			{echo " <font color=red>"._QXZ("LIST OVERRIDE ACTIVE")."</font>";}
		echo "</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Voicemail Message Daily Limit").": </td><td align=left><input type=text name=vmm_daily_limit size=4 maxlength=3 value=\"$vmm_daily_limit\">$NWB#campaigns-vmm_daily_limit$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("WaitForSilence Options").": </td><td align=left><input type=text name=waitforsilence_options size=20 maxlength=25 value=\"$waitforsilence_options\">$NWB#campaigns-waitforsilence_options$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Manual VM Status Updates").": </td><td align=left><select size=1 name=manual_vm_status_updates><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$manual_vm_status_updates' SELECTED>"._QXZ("$manual_vm_status_updates")."</option></select>$NWB#campaigns-manual_vm_status_updates$NWE</td></tr>\n";

		if ($am_message_wildcards == 'Y')
			{
			$vam_count=0;
			$stmt="SELECT count(*) from vicidial_amm_multi where campaign_id='$campaign_id' and entry_type='campaign';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$vam_to_print = mysqli_num_rows($rslt);
			if ($vam_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$vam_count = $rowx[0]; 
				}

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("AM Message Wildcards").": </td><td align=left><select size=1 name=am_message_wildcards><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option selected>"._QXZ("$am_message_wildcards")."</option></select>$NWB#campaigns-am_message_wildcards$NWE <a href=\"admin_amm_multi.php?DB=$DB&campaign_id=$campaign_id&entry_type=campaign\"> "._QXZ("AM Message Wildcards Defined").": $vam_count</a></td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("AM Message Wildcards").": </td><td align=left><select size=1 name=am_message_wildcards><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$am_message_wildcards' selected>"._QXZ("$am_message_wildcards")."</option></select>$NWB#campaigns-am_message_wildcards$NWE</td></tr>\n";
			}

		if ($SSoutbound_autodial_active > 0)
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("AMD Type").": </td><td align=left><select size=1 name=amd_type><option value='AMD'>"._QXZ("AMD built-in")."</option><option value='KHOMP'>"._QXZ("KHOMP Gateway")."</option><option value='CPD'>"._QXZ("Sangoma CPD")."</option><option value='$amd_type' SELECTED>"._QXZ("$amd_type")."</option></select>$NWB#campaigns-amd_type$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("AMD send to Action").": </td><td align=left><select size=1 name=amd_send_to_vmx><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$amd_send_to_vmx' SELECTED>"._QXZ("$amd_send_to_vmx")."</option></select>$NWB#campaigns-amd_send_to_vmx$NWE</td></tr>\n";

			$amdaro_B='';   $amdaro_E='';
			if ( ($amd_agent_route_options == 'ENABLED') or ($amd_agent_route_options == 'PENDING') )
				{
				$amdaro_B="<a href=\"$PHP_SELF?ADD=392111111111&container_id=AMD_AGENT_OPT_$campaign_id\">";
				$amdaro_E="</a>";
				}
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>$amdaro_B"._QXZ("AMD Agent Route Options")."$amdaro_E: </td><td align=left><select size=1 name=amd_agent_route_options><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='PENDING'>"._QXZ("PENDING")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$amd_agent_route_options' SELECTED>"._QXZ("$amd_agent_route_options")."</option></select>$NWB#campaigns-amd_agent_route_options$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("CPD AMD Action").": </td><td align=left><select size=1 name=cpd_amd_action><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='DISPO'>"._QXZ("DISPO")."</option><option value='MESSAGE'>"._QXZ("MESSAGE")."</option><option value='INGROUP'>"._QXZ("INGROUP")."</option><option value='CALLMENU'>"._QXZ("CALLMENU")."</option><option value='$cpd_amd_action' SELECTED>"._QXZ("$cpd_amd_action")."</option></select>$NWB#campaigns-cpd_amd_action$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("CPD Unknown Action").": </td><td align=left><select size=1 name=cpd_unknown_action><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='DISPO'>"._QXZ("DISPO")."</option><option value='MESSAGE'>"._QXZ("MESSAGE")."</option><option value='INGROUP'>"._QXZ("INGROUP")."</option><option value='CALLMENU'>"._QXZ("CALLMENU")."</option><option value='$cpd_unknown_action' SELECTED>"._QXZ("$cpd_unknown_action")."</option></select>$NWB#campaigns-cpd_unknown_action$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("AMD Inbound Group").": </td><td align=left><select size=1 name=amd_inbound_group>";
			echo "$AMDgroups_menu";
			echo "</select>$NWB#campaigns-amd_inbound_group$NWE\n";
			echo "</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right><a href=\"$PHP_SELF?ADD=3511&menu_id=$amd_callmenu\">"._QXZ("AMD Call Menu")."</a>: </td><td align=left><select size=1 name=amd_callmenu>";
			echo "$AMDmenus_menu";
			echo "</select>$NWB#campaigns-amd_callmenu$NWE\n";
			echo "</td></tr>\n";

			if ($KHOMP_enabled > 0)
				{
				##### get container listings for dynamic khomp settings container for khomp_settings_container pulldown menu
				$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='KHOMP_SETTINGS' $LOGadmin_viewable_groupsSQL order by container_id;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$twrse_to_print = mysqli_num_rows($rslt);
				$khomp_settings_menu='';
				$twrse_selected=0;
				$o=0;
				while ($twrse_to_print > $o) 
					{
					$rowx=mysqli_fetch_row($rslt);
					if (mb_strlen($rowx[1],'utf-8')>40)
						{$rowx[1] = mb_substr($rowx[1],0,40,'utf-8') . '...';}
					$khomp_settings_menu .= "<option ";
					if ($khomp_settings_container == "$rowx[0]") 
						{
						$khomp_settings_menu .= "SELECTED ";
						$twrse_selected++;
						}
					$khomp_settings_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
					$o++;
					}

				echo "<tr bgcolor=#$SSstd_row3_background><td align=right>";
				if ($twrse_selected > 0)
					{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$khomp_settings_container\">"._QXZ("KHOMP Settings")."</a>";}
				else
					{echo _QXZ("KHOMP Settings");}
				echo ": </td><td align=left><select size=1 name=khomp_settings_container><option value='KHOMPSETTINGS'>"._QXZ("KHOMPSETTINGS")."</option>$khomp_settings_menu</select>$NWB#campaigns-khomp_settings_container$NWE</td></tr>\n";
				}
			else
				{echo "<tr bgcolor=#$SSstd_row3_background><td colspan=2><input type=hidden name=khomp_settings_container value=\"$khomp_settings_container\"></td></tr>\n";}
			}

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right><a href=\"$PHP_SELF?ADD=397111111111&leave_vm_message_group_id=$leave_vm_message_group_id\">"._QXZ("VM Message Group")."</a>: </td><td align=left><select size=1 name=leave_vm_message_group_id>";
		echo "$VMMGmenus_menu";
		echo "</select>$NWB#campaigns-leave_vm_message_group_id$NWE\n";
		echo "</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Leave VM No Dispo")."</a>: </td><td align=left><select size=1 name=leave_vm_no_dispo>";
		echo "<option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='$leave_vm_no_dispo' SELECTED>"._QXZ("$leave_vm_no_dispo")."</option>";
		echo "</select>$NWB#campaigns-leave_vm_no_dispo$NWE\n";
		echo "</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Transfer-Conf DTMF")." 1: </td><td align=left><input type=text name=xferconf_a_dtmf size=20 maxlength=50 value=\"$xferconf_a_dtmf\">$NWB#campaigns-xferconf_a_dtmf$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Transfer-Conf Number")." 1: </td><td align=left><input type=text name=xferconf_a_number size=20 maxlength=50 value=\"$xferconf_a_number\">$NWB#campaigns-xferconf_a_dtmf$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Transfer-Conf DTMF")." 2: </td><td align=left><input type=text name=xferconf_b_dtmf size=20 maxlength=50 value=\"$xferconf_b_dtmf\">$NWB#campaigns-xferconf_a_dtmf$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Transfer-Conf Number")." 2: </td><td align=left><input type=text name=xferconf_b_number size=20 maxlength=50 value=\"$xferconf_b_number\">$NWB#campaigns-xferconf_a_dtmf$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Transfer-Conf Number")." 3: </td><td align=left><input type=text name=xferconf_c_number size=20 maxlength=50 value=\"$xferconf_c_number\">$NWB#campaigns-xferconf_a_dtmf$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Transfer-Conf Number")." 4: </td><td align=left><input type=text name=xferconf_d_number size=20 maxlength=50 value=\"$xferconf_d_number\">$NWB#campaigns-xferconf_a_dtmf$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Transfer-Conf Number")." 5: </td><td align=left><input type=text name=xferconf_e_number size=20 maxlength=50 value=\"$xferconf_e_number\">$NWB#campaigns-xferconf_a_dtmf$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Enable Transfer Presets").": </td><td align=left><select size=1 name=enable_xfer_presets><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='STAGING'>"._QXZ("STAGING")."</option><option value='CONTACTS'>"._QXZ("CONTACTS")."</option><option value='$enable_xfer_presets' SELECTED>"._QXZ("$enable_xfer_presets")."</option></select>$NWB#campaigns-enable_xfer_presets$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Hide Transfer Number to Dial").": </td><td align=left><select size=1 name=hide_xfer_number_to_dial><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='$hide_xfer_number_to_dial' SELECTED>"._QXZ("$hide_xfer_number_to_dial")."</option></select>$NWB#campaigns-hide_xfer_number_to_dial$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("PrePopulate Transfer Preset").": </td><td align=left><select size=1 name=prepopulate_transfer_preset><option value='N'>"._QXZ("N")."</option><option value='PRESET_1'>"._QXZ("PRESET_1")."</option><option value='PRESET_2'>"._QXZ("PRESET_2")."</option><option value='PRESET_3'>"._QXZ("PRESET_3")."</option><option value='PRESET_4'>"._QXZ("PRESET_4")."</option><option value='PRESET_5'>"._QXZ("PRESET_5")."</option><option value='$prepopulate_transfer_preset' SELECTED>"._QXZ("$prepopulate_transfer_preset")."</option></select>$NWB#campaigns-prepopulate_transfer_preset$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Quick Transfer Button").": </td><td align=left><select size=1 name=quick_transfer_button><option value='N'>"._QXZ("N")."</option><option value='IN_GROUP'>"._QXZ("IN_GROUP")."</option><option value='PRESET_1'>"._QXZ("PRESET_1")."</option><option value='PRESET_2'>"._QXZ("PRESET_2")."</option><option value='PRESET_3'>"._QXZ("PRESET_3")."</option><option value='PRESET_4'>"._QXZ("PRESET_4")."</option><option value='PRESET_5'>"._QXZ("PRESET_5")."</option><option value='$quick_transfer_button' SELECTED>"._QXZ("$quick_transfer_button")."</option><option value='LOCKED_IN_GROUP'>"._QXZ("LOCKED_IN_GROUP")."</option><option value='LOCKED_PRESET_1'>"._QXZ("LOCKED_PRESET_1")."</option><option value='LOCKED_PRESET_2'>"._QXZ("LOCKED_PRESET_2")."</option><option value='LOCKED_PRESET_3'>"._QXZ("LOCKED_PRESET_3")."</option><option value='LOCKED_PRESET_4'>"._QXZ("LOCKED_PRESET_4")."</option><option value='LOCKED_PRESET_5'>"._QXZ("LOCKED_PRESET_5")."</option></select>$NWB#campaigns-quick_transfer_button$NWE</td></tr>\n";

		$eswHTML=''; $cfwHTML='';
		if ($SSenable_second_script > 0)
			{$eswHTML .= "<option value='SCRIPTTWO'>"._QXZ("SCRIPTTWO")."</option>";}
		if ($SSenable_second_webform > 0)
			{$eswHTML .= '<option value="WEBFORMTWO">'._QXZ("WEBFORMTWO").'</option>';}
		if ($SSenable_third_webform > 0)
			{$eswHTML .= "<option value='WEBFORMTHREE'>"._QXZ("WEBFORMTHREE")."</option>";}
		if ($SScustom_fields_enabled > 0)
			{$cfwHTML .= '<option value="FORM">'._QXZ("FORM").'</option>';}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Transfer-Conf Button Launch").": </td><td align=left><select size=1 name=transfer_button_launch><option value='NONE' selected>"._QXZ("NONE")."</option><option value='SCRIPT'>"._QXZ("SCRIPT")."</option><option value='WEBFORM'>"._QXZ("WEBFORM")."</option>$eswHTML$cfwHTML<option value='$transfer_button_launch' selected>"._QXZ("$transfer_button_launch")."</option></select>$NWB#campaigns-transfer_button_launch$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Transfer No Dispo").": </td><td align=left><select size=1 name=transfer_no_dispo><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='EXTERNAL_ONLY'>"._QXZ("EXTERNAL_ONLY")."</option><option value='LOCAL_ONLY'>"._QXZ("LOCAL_ONLY")."</option><option value='LEAVE3WAY_ONLY'>"._QXZ("LEAVE3WAY_ONLY")."</option><option value='LOCAL_AND_EXTERNAL'>"._QXZ("LOCAL_AND_EXTERNAL")."</option><option value='LOCAL_AND_LEAVE3WAY'>"._QXZ("LOCAL_AND_LEAVE3WAY")."</option><option value='LEAVE3WAY_AND_EXTERNAL'>"._QXZ("LEAVE3WAY_AND_EXTERNAL")."</option><option value='LOCAL_AND_EXTERNAL_AND_LEAVE3WAY'>"._QXZ("LOCAL_AND_EXTERNAL_AND_LEAVE3WAY")."</option><option value='$transfer_no_dispo' SELECTED>"._QXZ("$transfer_no_dispo")."</option></select>$NWB#campaigns-transfer_no_dispo$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Custom 3-Way Button Transfer").": </td><td align=left><select size=1 name=custom_3way_button_transfer><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='PRESET_1'>"._QXZ("PRESET_1")."</option><option value='PRESET_2'>"._QXZ("PRESET_2")."</option><option value='PRESET_3'>"._QXZ("PRESET_3")."</option><option value='PRESET_4'>"._QXZ("PRESET_4")."</option><option value='PRESET_5'>"._QXZ("PRESET_5")."</option><option value='FIELD_address3'>"._QXZ("FIELD_address3")."</option><option value='FIELD_province'>"._QXZ("FIELD_province")."</option><option value='FIELD_security_phrase'>"._QXZ("FIELD_security_phrase")."</option><option value='FIELD_vendor_lead_code'>"._QXZ("FIELD_vendor_lead_code")."</option><option value='FIELD_email'>"._QXZ("FIELD_email")."</option><option value='FIELD_owner'>"._QXZ("FIELD_owner")."</option><option value='PARK_PRESET_1'>"._QXZ("PARK_PRESET_1")."</option><option value='PARK_PRESET_2'>"._QXZ("PARK_PRESET_2")."</option><option value='PARK_PRESET_3'>"._QXZ("PARK_PRESET_3")."</option><option value='PARK_PRESET_4'>"._QXZ("PARK_PRESET_4")."</option><option value='PARK_PRESET_5'>"._QXZ("PARK_PRESET_5")."</option><option value='PARK_FIELD_address3'>"._QXZ("PARK_FIELD_address3")."</option><option value='PARK_FIELD_province'>"._QXZ("PARK_FIELD_province")."</option><option value='PARK_FIELD_security_phrase'>"._QXZ("PARK_FIELD_security_phrase")."</option><option value='PARK_FIELD_vendor_lead_code'>"._QXZ("PARK_FIELD_vendor_lead_code")."</option><option value='PARK_FIELD_email'>"._QXZ("PARK_FIELD_email")."</option><option value='PARK_FIELD_owner'>"._QXZ("PARK_FIELD_owner")."</option><option value='VIEW_PRESET'>"._QXZ("VIEW_PRESET")."</option><option value='VIEW_CONTACTS'>"._QXZ("VIEW_CONTACTS")."</option><option value='$custom_3way_button_transfer' SELECTED>"._QXZ("$custom_3way_button_transfer")."</option></select>$NWB#campaigns-custom_3way_button_transfer$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("3-Way Call Outbound CallerID").": </td><td align=left><select size=1 name=three_way_call_cid><option value='CAMPAIGN'>"._QXZ("CAMPAIGN")."</option><option value='CUSTOMER'>"._QXZ("CUSTOMER")."</option><option value='AGENT_PHONE'>"._QXZ("AGENT_PHONE")."</option><option value='AGENT_CHOOSE'>"._QXZ("AGENT_CHOOSE")."</option><option value='CUSTOM_CID'>"._QXZ("CUSTOM_CID")."</option><option value='$three_way_call_cid' SELECTED>"._QXZ("$three_way_call_cid")."</option></select>$NWB#campaigns-three_way_call_cid$NWE</td></tr>\n";

		if ($LOGmodify_dial_prefix > 0)
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("3-Way Call Dial Prefix").": </td><td align=left><input type=text name=three_way_dial_prefix size=15 maxlength=20 value=\"$three_way_dial_prefix\">$NWB#campaigns-three_way_dial_prefix$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right><input type=hidden name=three_way_dial_prefix value=\"$three_way_dial_prefix\"></td></tr>";
			}

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("3-Way Volume Buttons").": </td><td align=left><select size=1 name=three_way_volume_buttons><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$three_way_volume_buttons' SELECTED>"._QXZ("$three_way_volume_buttons")."</option></select>$NWB#campaigns-three_way_volume_buttons$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Customer 3-Way Hangup Logging").": </td><td align=left><select size=1 name=customer_3way_hangup_logging><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='$customer_3way_hangup_logging' SELECTED>"._QXZ("$customer_3way_hangup_logging")."</option></select>$NWB#campaigns-customer_3way_hangup_logging$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Customer 3-Way Hangup Seconds").": </td><td align=left><input type=text name=customer_3way_hangup_seconds size=5 maxlength=5 value=\"$customer_3way_hangup_seconds\">$NWB#campaigns-customer_3way_hangup_seconds$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Customer 3-Way Hangup Action").": </td><td align=left><select size=1 name=customer_3way_hangup_action><option value='NONE'>"._QXZ("NONE")."</option><option value='DISPO'>"._QXZ("DISPO")."</option><option value='$customer_3way_hangup_action' SELECTED>"._QXZ("$customer_3way_hangup_action")."</option></select>$NWB#campaigns-customer_3way_hangup_action$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("3-Way Recording Stop").": </td><td align=left><select size=1 name=three_way_record_stop><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$three_way_record_stop' SELECTED>"._QXZ("$three_way_record_stop")."</option></select>$NWB#campaigns-three_way_record_stop$NWE</td></tr>\n";

		##### get container listings for dynamic phone number list container for three_way_record_stop_exception pulldown menu
		$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='PHONE_NUMBERS' $LOGadmin_viewable_groupsSQL order by container_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$twrse_to_print = mysqli_num_rows($rslt);
		$three_way_record_stop_exception_menu='';
		$twrse_selected=0;
		$o=0;
		while ($twrse_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			if (mb_strlen($rowx[1],'utf-8')>40)
				{$rowx[1] = mb_substr($rowx[1],0,40,'utf-8') . '...';}
			$three_way_record_stop_exception_menu .= "<option ";
			if ($three_way_record_stop_exception == "$rowx[0]") 
				{
				$three_way_record_stop_exception_menu .= "SELECTED ";
				$twrse_selected++;
				}
			$three_way_record_stop_exception_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>";
		if ($twrse_selected > 0)
			{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$three_way_record_stop_exception\">"._QXZ("3-Way Recording Stop Exception")."</a>";}
		else
			{echo _QXZ("3-Way Recording Stop Exception");}
		echo ": </td><td align=left><select size=1 name=three_way_record_stop_exception><option value='DISABLED'>"._QXZ("DISABLED")."</option>$three_way_record_stop_exception_menu</select>$NWB#campaigns-three_way_record_stop_exception$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Leave 3-Way Start Recording").": </td><td align=left><select size=1 name=leave_3way_start_recording><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ALL_CALLS'>"._QXZ("ALL_CALLS")."</option><option value='ALL_BUT_EXCEPTIONS'>"._QXZ("ALL_BUT_EXCEPTIONS")."</option><option value='ONLY_EXCEPTIONS'>"._QXZ("ONLY_EXCEPTIONS")."</option><option value='$leave_3way_start_recording' SELECTED>"._QXZ("$leave_3way_start_recording")."</option></select>$NWB#campaigns-leave_3way_start_recording$NWE</td></tr>\n";

		##### get container listings for dynamic phone number list container for three_way_record_stop_exception pulldown menu
		$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='PHONE_NUMBERS' $LOGadmin_viewable_groupsSQL order by container_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$twrse_to_print = mysqli_num_rows($rslt);
		$leave_3way_start_recording_exception_menu='';
		$twrse_selected=0;
		$o=0;
		while ($twrse_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			if (mb_strlen($rowx[1],'utf-8')>40)
				{$rowx[1] = mb_substr($rowx[1],0,40,'utf-8') . '...';}
			$leave_3way_start_recording_exception_menu .= "<option ";
			if ($leave_3way_start_recording_exception == "$rowx[0]") 
				{
				$leave_3way_start_recording_exception_menu .= "SELECTED ";
				$twrse_selected++;
				}
			$leave_3way_start_recording_exception_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>";
		if ($twrse_selected > 0)
			{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$leave_3way_start_recording_exception\">"._QXZ("Leave 3-Way Start Recording Exception")."</a>";}
		else
			{echo _QXZ("Leave 3-Way Start Recording Exception");}
		echo ": </td><td align=left><select size=1 name=leave_3way_start_recording_exception><option value='DISABLED'>"._QXZ("DISABLED")."</option>$leave_3way_start_recording_exception_menu</select>$NWB#campaigns-leave_3way_start_recording_exception$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Leave 3-Way Stop Recording").": </td><td align=left><select size=1 name=leave_3way_stop_recording><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ALL_CALLS'>"._QXZ("ALL_CALLS")."</option><option value='$leave_3way_stop_recording' SELECTED>"._QXZ("$leave_3way_stop_recording")."</option></select>$NWB#campaigns-leave_3way_stop_recording$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Hangup Xfer Recording Start").": </td><td align=left><select size=1 name=hangup_xfer_record_start><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$hangup_xfer_record_start' SELECTED>"._QXZ("$hangup_xfer_record_start")."</option></select>$NWB#campaigns-hangup_xfer_record_start$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Park Call IVR").": </td><td align=left><select size=1 name=ivr_park_call><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='ENABLED_PARK_ONLY'>"._QXZ("ENABLED_PARK_ONLY")."</option><option value='ENABLED_BUTTON_HIDDEN'>"._QXZ("ENABLED_BUTTON_HIDDEN")."</option><option value='$ivr_park_call' SELECTED>"._QXZ("$ivr_park_call")."</option></select>$NWB#campaigns-ivr_park_call$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Park Call IVR AGI").": </td><td align=left><input type=text name=ivr_park_call_agi size=70 maxlength=1000 value=\"$ivr_park_call_agi\">$NWB#campaigns-ivr_park_call_agi$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Timer Action").": </td><td align=left><select size=1 name=timer_action><option value='NONE' selected>"._QXZ("NONE")."</option><option value='D1_DIAL'>"._QXZ("D1_DIAL")."</option><option value='D2_DIAL'>"._QXZ("D2_DIAL")."</option><option value='D3_DIAL'>"._QXZ("D3_DIAL")."</option><option value='D4_DIAL'>"._QXZ("D4_DIAL")."</option><option value='D5_DIAL'>"._QXZ("D5_DIAL")."</option><option value='D1_DIAL_QUIET'>"._QXZ("D1_DIAL_QUIET")."</option><option value='D2_DIAL_QUIET'>"._QXZ("D2_DIAL_QUIET")."</option><option value='D3_DIAL_QUIET'>"._QXZ("D3_DIAL_QUIET")."</option><option value='D4_DIAL_QUIET'>"._QXZ("D4_DIAL_QUIET")."</option><option value='D5_DIAL_QUIET'>"._QXZ("D5_DIAL_QUIET")."</option><option value='MESSAGE_ONLY'>"._QXZ("MESSAGE_ONLY")."</option><option value='WEBFORM'>"._QXZ("WEBFORM")."</option>$eswHTML<option value='HANGUP'>"._QXZ("HANGUP")."</option><option value='CALLMENU'>"._QXZ("CALLMENU")."</option><option value='EXTENSION'>"._QXZ("EXTENSION")."</option><option value='IN_GROUP'>"._QXZ("IN_GROUP")."</option><option value='$timer_action' selected>"._QXZ("$timer_action")."</option></select>$NWB#campaigns-timer_action$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Timer Action Message").": </td><td align=left><input type=text name=timer_action_message size=50 maxlength=255 value=\"$timer_action_message\">$NWB#campaigns-timer_action_message$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Timer Action Seconds").": </td><td align=left><input type=text name=timer_action_seconds size=10 maxlength=10 value=\"$timer_action_seconds\">$NWB#campaigns-timer_action_seconds$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Timer Action Destination").": </td><td align=left><input type=text name=timer_action_destination size=25 maxlength=30 value=\"$timer_action_destination\">$NWB#campaigns-timer_action_destination$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Scheduled Callbacks").": </td><td align=left><select size=1 name=scheduled_callbacks><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$scheduled_callbacks' SELECTED>"._QXZ("$scheduled_callbacks")."</option></select>$NWB#campaigns-scheduled_callbacks$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Scheduled Callbacks Alert").": </td><td align=left><select size=1 name=scheduled_callbacks_alert><option value='NONE'>"._QXZ("NONE")."</option><option value='BLINK'>"._QXZ("BLINK")."</option><option value='RED'>"._QXZ("RED")."</option><option value='BLINK_RED'>"._QXZ("BLINK_RED")."</option><option value='BLINK_DEFER'>"._QXZ("BLINK_DEFER")."</option><option value='RED_DEFER'>"._QXZ("RED_DEFER")."</option><option value='BLINK_RED_DEFER'>"._QXZ("BLINK_RED_DEFER")."</option><option value='$scheduled_callbacks_alert' SELECTED>"._QXZ("$scheduled_callbacks_alert")."</option></select>$NWB#campaigns-scheduled_callbacks_alert$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Send Callbacks Email").": </td><td align=left><select size=1 name=scheduled_callbacks_email_alert><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$scheduled_callbacks_email_alert' SELECTED>"._QXZ("$scheduled_callbacks_email_alert")."</option></select>$NWB#campaigns-scheduled_callbacks_email_alert$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Scheduled Callbacks Count").": </td><td align=left><select size=1 name=scheduled_callbacks_count><option value='LIVE'>"._QXZ("LIVE")."</option><option value='ALL_ACTIVE'>"._QXZ("ALL_ACTIVE")."</option><option value='$scheduled_callbacks_count' SELECTED>"._QXZ("$scheduled_callbacks_count")."</option></select>$NWB#campaigns-scheduled_callbacks_count$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Scheduled Callbacks Days Limit").": </td><td align=left><input type=text name=callback_days_limit size=4 maxlength=3 value=\"$callback_days_limit\">$NWB#campaigns-callback_days_limit$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Scheduled Callbacks Hours Block").": </td><td align=left><input type=text name=callback_hours_block size=3 maxlength=2 value=\"$callback_hours_block\">$NWB#campaigns-callback_hours_block$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Scheduled Callbacks Calltime Block").": </td><td align=left><select size=1 name=callback_list_calltime><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$callback_list_calltime' SELECTED>"._QXZ("$callback_list_calltime")."</option></select>$NWB#campaigns-callback_list_calltime$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Scheduled Callbacks Active Limit").": </td><td align=left><input type=text name=callback_active_limit size=5 maxlength=5 value=\"$callback_active_limit\">$NWB#campaigns-callback_active_limit$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Scheduled Callbacks Active Limit Override").": </td><td align=left><select size=1 name=callback_active_limit_override><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value=\"$callback_active_limit_override\" SELECTED>"._QXZ("$callback_active_limit_override")."</option></select>$NWB#campaigns-callback_active_limit_override$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Scheduled Callbacks Display Days").": </td><td align=left><input type=text name=callback_display_days size=4 maxlength=3 value=\"$callback_display_days\">$NWB#campaigns-callback_display_days$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Anyone Callbacks DNC Filter").": </td><td align=left><select size=1 name=callback_dnc><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$callback_dnc' SELECTED>"._QXZ("$callback_dnc")."</option></select>$NWB#campaigns-callback_dnc$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("My Callbacks Checkbox Default").": </td><td align=left><select size=1 name=my_callback_option><option value='CHECKED'>"._QXZ("CHECKED")."</option><option value='UNCHECKED'>"._QXZ("UNCHECKED")."</option><option value='$my_callback_option' SELECTED>"._QXZ("$my_callback_option")."</option></select>$NWB#campaigns-my_callback_option$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Show Previous Callback").": </td><td align=left><select size=1 name=show_previous_callback><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='$show_previous_callback' SELECTED>"._QXZ("$show_previous_callback")."</option></select>$NWB#campaigns-show_previous_callback$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Scheduled Callbacks Useronly Move Minutes").": </td><td align=left><input type=text name=callback_useronly_move_minutes size=6 maxlength=5 value=\"$callback_useronly_move_minutes\">$NWB#campaigns-callback_useronly_move_minutes$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Next-Dial My Callbacks").": </td><td align=left><select size=1 name=next_dial_my_callbacks><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='$next_dial_my_callbacks' SELECTED>"._QXZ("$next_dial_my_callbacks")."</option></select>$NWB#campaigns-next_dial_my_callbacks$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Scheduled Callbacks Force Dial").": </td><td align=left><select size=1 name=scheduled_callbacks_force_dial><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$scheduled_callbacks_force_dial' SELECTED>"._QXZ("$scheduled_callbacks_force_dial")."</option></select>$NWB#campaigns-scheduled_callbacks_force_dial$NWE</td></tr>\n";

		$php_timezones=0;
		$stmt="SELECT count(*) from vicidial_phone_codes where php_tz!='';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$phptz_ct_to_print = mysqli_num_rows($rslt);
		if ($phptz_ct_to_print > 0) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$php_timezones = $rowx[0];
			}

		if ($php_timezones > 0)
			{
			##### get timezone_list listings for dynamic pulldown list menu
			$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='TIMEZONE_LIST' $LOGadmin_viewable_groupsSQL order by container_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$tzlc_to_print = mysqli_num_rows($rslt);
			$scheduled_callbacks_timezones_container_menu='';
			$tzlc_selected=0;
			$o=0;
			while ($tzlc_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				if (mb_strlen($rowx[1],'utf-8')>40)
					{$rowx[1] = mb_substr($rowx[1],0,40,'utf-8') . '...';}
				$scheduled_callbacks_timezones_container_menu .= "<option ";
				if ($scheduled_callbacks_timezones_container == "$rowx[0]") 
					{
					$scheduled_callbacks_timezones_container_menu .= "SELECTED ";
					$tzlc_selected++;
					}
				$scheduled_callbacks_timezones_container_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$o++;
				}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>";
			if ($tzlc_selected > 0)
				{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$scheduled_callbacks_timezones_container\">"._QXZ("Scheduled Callbacks Local Timezones")."</a>";}
			else
				{echo _QXZ("Scheduled Callbacks Local Timezones");}
			echo ": </td><td align=left><select size=1 name=scheduled_callbacks_timezones_container>";
			echo "<option value=\"DISABLED\">---"._QXZ("DISABLED")."---</option>";
			echo "$scheduled_callbacks_timezones_container_menu";
			echo "</select>";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Scheduled Callbacks Local Timezones").": </td><td align=left><font size=1>"._QXZ("Feature Disabled,<br> Administrator must update phone codes for this feature to work").".</font>";
			}
		echo "$NWB#campaigns-scheduled_callbacks_timezones_container$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Scheduled Callbacks Auto Reschedule").": </td><td align=left><select size=1 name=scheduled_callbacks_auto_reschedule><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='DAY_1'>"._QXZ("DAY_1")."</option><option value='DAY_2'>"._QXZ("DAY_2")."</option><option value='DAY_3'>"._QXZ("DAY_3")."</option><option value='DAY_4'>"._QXZ("DAY_4")."</option><option value='DAY_5'>"._QXZ("DAY_5")."</option><option value='DAY_6'>"._QXZ("DAY_6")."</option><option value='WEEK_1'>"._QXZ("WEEK_1")."</option><option value='WEEK_2'>"._QXZ("WEEK_2")."</option><option value='WEEK_3'>"._QXZ("WEEK_3")."</option><option value='MONTH_1'>"._QXZ("MONTH_1")."</option><option value='MONTH_2'>"._QXZ("MONTH_2")."</option><option value='MONTH_3'>"._QXZ("MONTH_3")."</option><option value='MONTH_4'>"._QXZ("MONTH_4")."</option><option value='MONTH_5'>"._QXZ("MONTH_5")."</option><option value='MONTH_6'>"._QXZ("MONTH_6")."</option><option value='$scheduled_callbacks_auto_reschedule' SELECTED>"._QXZ("$scheduled_callbacks_auto_reschedule")."</option></select>$NWB#campaigns-scheduled_callbacks_auto_reschedule$NWE</td></tr>\n";

		if ($SSoutbound_autodial_active > 0)
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Drop Call Seconds").": </td><td align=left><input type=text name=drop_call_seconds size=5 maxlength=2 value=\"$drop_call_seconds\">$NWB#campaigns-drop_call_seconds$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Drop Action").": </td><td align=left><select size=1 name=drop_action><option value='AUDIO'>"._QXZ("AUDIO")."</option><option value='HANGUP'>"._QXZ("HANGUP")."</option><option value='MESSAGE'>"._QXZ("MESSAGE")."</option><option value='VOICEMAIL'>"._QXZ("VOICEMAIL")."</option><option value='VMAIL_NO_INST'>"._QXZ("VMAIL_NO_INST")."</option><option value='IN_GROUP'>"._QXZ("IN_GROUP")."</option><option value='CALLMENU'>"._QXZ("CALLMENU")."</option><option value='$drop_action' SELECTED>"._QXZ("$drop_action")."</option></select>$NWB#campaigns-drop_action$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Safe Harbor Exten").": </td><td align=left><input type=text name=safe_harbor_exten size=10 maxlength=20 value=\"$safe_harbor_exten\">$NWB#campaigns-safe_harbor_exten$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Safe Harbor Audio").": </td><td align=left><input type=text name=safe_harbor_audio id=safe_harbor_audio size=40 maxlength=100 value=\"$safe_harbor_audio\"> <a href=\"javascript:launch_chooser('safe_harbor_audio','date');\">"._QXZ("audio chooser")."</a> $NWB#campaigns-safe_harbor_audio$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Safe Harbor Audio Field").": </td><td align=left><select size=1 name=safe_harbor_audio_field><option value='DISABLED'>"._QXZ("DISABLED")."</option><option>vendor_lead_code</option><option>source_id</option><option>list_id</option><option>phone_code</option><option>phone_number</option><option>title</option><option>first_name</option><option>middle_initial</option><option>last_name</option><option>address1</option><option>address2</option><option>address3</option><option>city</option><option>state</option><option>province</option><option>postal_code</option><option>country_code</option><option>gender</option><option>alt_phone</option><option>email</option><option>security_phrase</option><option>comments</option><option>rank</option><option>owner</option><option>entry_list_id</option><option value=\"$safe_harbor_audio_field\" SELECTED>"._QXZ("$safe_harbor_audio_field")."</option></select>$NWB#campaigns-safe_harbor_audio_field$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right><a href=\"$PHP_SELF?ADD=3511&menu_id=$safe_harbor_menu_id\">"._QXZ("Safe Harbor Call Menu")."</a>: </td><td align=left><select size=1 name=safe_harbor_menu_id id=safe_harbor_menu_id>$call_menu_list<option SELECTED>$safe_harbor_menu_id</option></select>$NWB#campaigns-safe_harbor_menu_id$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Voicemail").": </td><td align=left><input type=text name=voicemail_ext id=voicemail_ext size=12 maxlength=10 value=\"$voicemail_ext\"> <a href=\"javascript:launch_vm_chooser('voicemail_ext','vm');\">"._QXZ("voicemail chooser")."</a>$NWB#campaigns-voicemail_ext$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Drop Transfer Group").": </td><td align=left><select size=1 name=drop_inbound_group>";
			echo "$Dgroups_menu";
			echo "</select>$NWB#campaigns-drop_inbound_group$NWE\n";
			$stmt="SELECT count(*) from vicidial_lists where campaign_id='$campaign_id' and drop_inbound_group_override != '' and active='Y' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$rowx=mysqli_fetch_row($rslt);
			if ($rowx[0] > 0) 
				{echo " <font color=red>"._QXZ("LIST OVERRIDE ACTIVE")."</font>";}
			echo "</td></tr>\n";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Call Hangup Route").": </td><td align=left><select size=1 name=agent_hangup_route id=agent_hangup_route onChange=\"AgentCallHangupRouteChange('agent_hangup_value');\"><option value='HANGUP'>"._QXZ("HANGUP")."</option><option value='MESSAGE'>"._QXZ("MESSAGE")."</option><option value='EXTENSION'>"._QXZ("EXTENSION")."</option><option value='IN_GROUP'>"._QXZ("IN_GROUP")."</option><option value='CALLMENU'>"._QXZ("CALLMENU")."</option><option value='$agent_hangup_route' SELECTED>"._QXZ("$agent_hangup_route")."</option></select>$NWB#campaigns-agent_hangup_route$NWE</td></tr>\n";

		$ACHR_title = "-"._QXZ("no value required")."-";
		$ACHR_chooser = '';
		if ($agent_hangup_route=='MESSAGE')
			{
			$ACHR_title = _QXZ("Agent Hangup Message");
			$ACHR_chooser = " <a href=\"javascript:launch_chooser('agent_hangup_value','date');\"> "._QXZ("audio chooser")." </a> ";
			}
		if ($agent_hangup_route=='EXTENSION')
			{
			$ACHR_title = _QXZ("Agent Hangup Dialplan Extension");
			$ACHR_chooser = '';
			}
		if ($agent_hangup_route=='IN_GROUP')
			{
			$ACHR_title = _QXZ("Agent Hangup In-Group");
			$ACHR_chooser = " <a href=\"javascript:launch_ingroup_chooser('agent_hangup_value','group_id');\"> "._QXZ("in-group chooser")." </a> ";
			if (strlen($agent_hangup_value) > 0)
				{
				$ACHR_title = "<a href=\"$PHP_SELF?ADD=3111&group_id=$agent_hangup_value\">"._QXZ("Agent Hangup In-Group")."</a>";
				}
			}
		if ($agent_hangup_route=='CALLMENU')
			{
			$ACHR_title = _QXZ("Agent Hangup Call Menu");
			$ACHR_chooser = " <a href=\"javascript:launch_callmenu_chooser('agent_hangup_value','menu_id');\"> "._QXZ("call menu chooser")." </a> ";
			if (strlen($agent_hangup_value) > 0)
				{
				$ACHR_title = "<a href=\"$PHP_SELF?ADD=3511&menu_id=$agent_hangup_value\">"._QXZ("Agent Hangup Call Menu")."</a>";
				}
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><span id=agent_hangup_value_title>$ACHR_title</span>: </td><td align=left><input type=text name=agent_hangup_value id=agent_hangup_value size=50 maxlength=1000 value=\"$agent_hangup_value\"><span id=agent_hangup_value_chooser>$ACHR_chooser</span>$NWB#campaigns-agent_hangup_value$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Hangup In-Group Override").": </td><td align=left><select size=1 name=agent_hangup_ig_override><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$agent_hangup_ig_override' SELECTED>"._QXZ("$agent_hangup_ig_override")."</option></select>$NWB#campaigns-agent_hangup_ig_override$NWE</td></tr>\n";

		if ($SSagent_hide_hangup > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Hide Customer Hangup Button").": </td><td align=left><select size=1 name=agent_hide_hangup><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$agent_hide_hangup' SELECTED>"._QXZ("$agent_hide_hangup")."</option></select>$NWB#campaigns-agent_hide_hangup$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td colspan=2><input type=hidden name=agent_hide_hangup value='$agent_hide_hangup'></td></tr>\n";
			}

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Disable Dispo Screen").": </td><td align=left><select size=1 name=disable_dispo_screen><option value='DISPO_ENABLED'>"._QXZ("DISPO_ENABLED")."</option><option value='DISPO_DISABLED'>"._QXZ("DISPO_DISABLED")."</option><option value='DISPO_SELECT_DISABLED'>"._QXZ("DISPO_SELECT_DISABLED")."</option><option value='$disable_dispo_screen' SELECTED>"._QXZ("$disable_dispo_screen")."</option></select>$NWB#campaigns-disable_dispo_screen$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Disable Dispo Status").": </td><td align=left><input type=text name=disable_dispo_status size=7 maxlength=6 value=\"$disable_dispo_status\">$NWB#campaigns-disable_dispo_status$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Script on top of Dispo").": </td><td align=left><select size=1 name=script_top_dispo><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$script_top_dispo' SELECTED>"._QXZ("$script_top_dispo")."</option></select>$NWB#campaigns-script_top_dispo$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Wrap Up Seconds").": </td><td align=left><input type=text name=wrapup_seconds size=5 maxlength=3 value=\"$wrapup_seconds\">$NWB#campaigns-wrapup_seconds$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Wrap Up Message").": </td><td align=left><input type=text name=wrapup_message size=40 maxlength=255 value=\"$wrapup_message\">$NWB#campaigns-wrapup_message$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Wrap Up Bypass").": </td><td align=left><select size=1 name=wrapup_bypass><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$wrapup_bypass' SELECTED>"._QXZ("$wrapup_bypass")."</option></select>$NWB#campaigns-wrapup_bypass$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Wrap Up After Hotkey").": </td><td align=left><select size=1 name=wrapup_after_hotkey><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value=\"$wrapup_after_hotkey\" SELECTED>"._QXZ("$wrapup_after_hotkey")."</option></select>$NWB#campaigns-wrapup_after_hotkey$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Dead Call Trigger Action").": </td><td align=left><select size=1 name=dead_trigger_action><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='AUDIO'>"._QXZ("AUDIO")."</option><option value='URL'>"._QXZ("URL")."</option><option value='AUDIO_AND_URL'>"._QXZ("AUDIO_AND_URL")."</option><option value=\"$dead_trigger_action\" SELECTED>"._QXZ("$dead_trigger_action")."</option></select>$NWB#campaigns-dead_trigger_action$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Dead Call Trigger Seconds").": </td><td align=left><input type=text name=dead_trigger_seconds size=5 maxlength=4 value=\"$dead_trigger_seconds\">$NWB#campaigns-dead_trigger_seconds$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Dead Call Trigger Repeat").": </td><td align=left><select size=1 name=dead_trigger_repeat><option value='NO'>"._QXZ("NO")."</option><option value='REPEAT_ALL'>"._QXZ("REPEAT_ALL")."</option><option value='REPEAT_AUDIO'>"._QXZ("REPEAT_AUDIO")."</option><option value='REPEAT_URL'>"._QXZ("REPEAT_URL")."</option><option value=\"$dead_trigger_repeat\" SELECTED>"._QXZ("$dead_trigger_repeat")."</option></select>$NWB#campaigns-dead_trigger_repeat$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Dead Call Trigger Audio").": </td><td align=left><input type=text name=dead_trigger_filename id=dead_trigger_filename size=40 maxlength=100 value=\"$dead_trigger_filename\"> <a href=\"javascript:launch_chooser('dead_trigger_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#campaigns-dead_trigger_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Dead Call Trigger URL").": </td><td align=left><input type=text name=dead_trigger_url size=70 maxlength=5000 value=\"$dead_trigger_url\">$NWB#campaigns-dead_trigger_url$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Dead Call Max Seconds").": </td><td align=left><input type=text name=dead_max size=5 maxlength=4 value=\"$dead_max\">$NWB#campaigns-dead_max$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Dead Call Max Status").": </td><td align=left><input type=text name=dead_max_dispo size=7 maxlength=6 value=\"$dead_max_dispo\">$NWB#campaigns-dead_max_dispo$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Dead Call to Dispo Only").": </td><td align=left><select size=1 name=dead_to_dispo><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value=\"$dead_to_dispo\" SELECTED>"._QXZ("$dead_to_dispo")."</option></select>$NWB#campaigns-dead_to_dispo$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Dead Call Stop Recording").": </td><td align=left><select size=1 name=dead_stop_recording>
		<option value='DISABLED'>"._QXZ("DISABLED")."</option>
		<option value='ALL_CALLS'>"._QXZ("ALL_CALLS")."</option>
		<option value='OUTBOUND_ONLY'>"._QXZ("OUTBOUND_ONLY")."</option>
		<option value='INBOUND_ONLY'>"._QXZ("INBOUND_ONLY")."</option>
		<option value='AUTODIAL_ONLY'>"._QXZ("AUTODIAL_ONLY")."</option>
		<option value='MANUAL_ONLY'>"._QXZ("MANUAL_ONLY")."</option>
		<option value=\"$dead_stop_recording\" SELECTED>"._QXZ("$dead_stop_recording")."</option>
		</select>$NWB#campaigns-dead_stop_recording$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Dispo Call Max Seconds").": </td><td align=left><input type=text name=dispo_max size=5 maxlength=4 value=\"$dispo_max\">$NWB#campaigns-dispo_max$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Dispo Call Max Status").": </td><td align=left><input type=text name=dispo_max_dispo size=7 maxlength=6 value=\"$dispo_max_dispo\">$NWB#campaigns-dispo_max_dispo$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Agent Pause Max Seconds").": </td><td align=left><input type=text name=pause_max size=5 maxlength=4 value=\"$pause_max\">$NWB#campaigns-pause_max$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Agent Pause Max Status").": </td><td align=left><input type=text name=pause_max_dispo size=7 maxlength=6 value=\"$pause_max_dispo\">$NWB#campaigns-pause_max_dispo$NWE</td></tr>\n";

		##### get container listings for dynamic pause max codes exceptions pulldown menu
		$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='PAUSE_CODES_LIST' $LOGadmin_viewable_groupsSQL order by container_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$csea_to_print = mysqli_num_rows($rslt);
		$pause_max_exceptions_container_menu='';
		$csea_selected=0;
		$o=0;
		while ($csea_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			if (mb_strlen($rowx[1],'utf-8')>40)
				{$rowx[1] = mb_substr($rowx[1],0,40,'utf-8') . '...';}
			$pause_max_exceptions_container_menu .= "<option ";
			if ($pause_max_exceptions == "$rowx[0]") 
				{
				$pause_max_exceptions_container_menu .= "SELECTED ";
				$csea_selected++;
				}
			$pause_max_exceptions_container_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		if ($o < 1)
			{$pause_max_exceptions_container_menu .= "<option SELECTED value=\"\">"._QXZ("No Pause Codes Lists Found")."</option>\n";}

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>";
		if ($csea_selected > 0)
			{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$pause_max_exceptions\">"._QXZ("Agent Pause Max Exceptions")."</a>";}
		else
			{echo _QXZ("Agent Pause Max Exceptions");}
		echo ": </td><td align=left><select size=1 name=pause_max_exceptions><option value=''>"._QXZ("DISABLED")."</option>$pause_max_exceptions_container_menu</select>$NWB#campaigns-pause_max_exceptions$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Pause Max URL").": </td><td align=left><input type=text name=pause_max_url size=70 maxlength=5000 value=\"$pause_max_url\">$NWB#campaigns-pause_max_url$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Ready Max Seconds Logout").": </td><td align=left><input type=text name=ready_max_logout size=7 maxlength=6 value=\"$ready_max_logout\">$NWB#campaigns-ready_max_logout$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Inbound Manual Dial Agent Forced Ready Seconds").": </td><td align=left><input type=text name=in_man_dial_next_ready_seconds size=7 maxlength=6 value=\"$in_man_dial_next_ready_seconds\">$NWB#campaigns-in_man_dial_next_ready_seconds$NWE</td></tr>\n";

		##### get container listings for dynamic WEEKDAY_TIMERANGE_SECONDS container pulldown menu
		$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='WEEKDAY_TIMERANGE_SECONDS' $LOGadmin_viewable_groupsSQL order by container_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$dtlc_to_print = mysqli_num_rows($rslt);
		$in_man_dial_next_ready_seconds_override_menu='';
		$dtlc_selected=0;
		$o=0;
		while ($dtlc_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			if (mb_strlen($rowx[1],'utf-8')>40)
				{$rowx[1] = mb_substr($rowx[1],0,40,'utf-8') . '...';}
			$in_man_dial_next_ready_seconds_override_menu .= "<option ";
			if ($in_man_dial_next_ready_seconds_override == "$rowx[0]") 
				{
				$in_man_dial_next_ready_seconds_override_menu .= "SELECTED ";
				$dtlc_selected++;
				}
			$in_man_dial_next_ready_seconds_override_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>";
		if ($dtlc_selected > 0)
			{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$in_man_dial_next_ready_seconds_override\">"._QXZ("InMan Agent Forced Ready Override Container")."</a>";}
		else
			{echo _QXZ("InMan Agent Forced Ready Override Container");}
		echo ": </td><td align=left nowrap><select size=1 name=in_man_dial_next_ready_seconds_override><option value='DISABLED'>"._QXZ("DISABLED")."</option>$in_man_dial_next_ready_seconds_override_menu</select>$NWB#campaigns-in_man_dial_next_ready_seconds_override$NWE</td></tr>\n";

		if ($SSmax_logged_in_agents > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Max Logged-In Agents").": </td><td align=left><input type=text name=max_logged_in_agents size=5 maxlength=4 value=\"$max_logged_in_agents\">$NWB#campaigns-max_logged_in_agents$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td colspan=2><input type=hidden name=max_logged_in_agents value='$max_logged_in_agents'></td></tr>\n";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Customer Gone Warning Seconds").": </td><td align=left><input type=text name=customer_gone_seconds size=5 maxlength=4 value=\"$customer_gone_seconds\">$NWB#campaigns-customer_gone_seconds$NWE</td></tr>\n";

		if ($SSsip_event_logging > 0)
			{
			##### get container listings for dynamic sip event logging actions pulldown menu
			$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='SIP_EVENT_ACTIONS' $LOGadmin_viewable_groupsSQL order by container_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$csea_to_print = mysqli_num_rows($rslt);
			$sip_event_actions_container_menu='';
			$csea_selected=0;
			$o=0;
			while ($csea_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				if (mb_strlen($rowx[1],'utf-8')>40)
					{$rowx[1] = mb_substr($rowx[1],0,40,'utf-8') . '...';}
				$sip_event_actions_container_menu .= "<option ";
				if ($sip_event_logging == "$rowx[0]") 
					{
					$sip_event_actions_container_menu .= "SELECTED ";
					$csea_selected++;
					}
				$sip_event_actions_container_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$o++;
				}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>";
			if ($csea_selected > 0)
				{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$sip_event_logging\">"._QXZ("SIP Event Actions")."</a>";}
			else
				{echo _QXZ("SIP Event Actions");}
			echo ": </td><td align=left><select size=1 name=sip_event_logging><option value='DISABLED'>"._QXZ("DISABLED")."</option>$sip_event_actions_container_menu</select>$NWB#campaigns-sip_event_logging$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td colspan=2><input type=hidden name=sip_event_logging value='$sip_event_logging'></td></tr>\n";
			}

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Use Internal DNC List").": </td><td align=left><select size=1 name=use_internal_dnc><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='AREACODE'>"._QXZ("AREACODE")."</option><option value='$use_internal_dnc' SELECTED>"._QXZ("$use_internal_dnc")."</option></select>$NWB#campaigns-use_internal_dnc$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Use Campaign DNC List").": </td><td align=left><select size=1 name=use_campaign_dnc><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='AREACODE'>"._QXZ("AREACODE")."</option><option value='$use_campaign_dnc' SELECTED>"._QXZ("$use_campaign_dnc")."</option></select>$NWB#campaigns-use_campaign_dnc$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Other Campaign DNC").": </td><td align=left><input type=text name=use_other_campaign_dnc size=9 maxlength=8 value=\"$use_other_campaign_dnc\">$NWB#campaigns-use_other_campaign_dnc$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Pause Codes Active").": </td><td align=left><select size=1 name=agent_pause_codes_active><option value='FORCE'>"._QXZ("FORCE")."</option><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value=\"$agent_pause_codes_active\" SELECTED>"._QXZ("$agent_pause_codes_active")."</option></select>$NWB#campaigns-agent_pause_codes_active$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Auto Pause Pre-Call Work").": </td><td align=left><select size=1 name=auto_pause_precall><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$auto_pause_precall' SELECTED>"._QXZ("$auto_pause_precall")."</option></select>$NWB#campaigns-auto_pause_precall$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Auto Resume Pre-Call Work").": </td><td align=left><select size=1 name=auto_resume_precall><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$auto_resume_precall' SELECTED>"._QXZ("$auto_resume_precall")."</option></select>$NWB#campaigns-auto_resume_precall$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Auto Pause Pre-Call Code").": </td><td align=left><input type=text name=auto_pause_precall_code size=7 maxlength=6 value=\"$auto_pause_precall_code\">$NWB#campaigns-auto_pause_precall_code$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign Stats Refresh").": </td><td align=left><select size=1 name=campaign_stats_refresh><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$campaign_stats_refresh' SELECTED>"._QXZ("$campaign_stats_refresh")."</option></select>$NWB#campaigns-campaign_stats_refresh$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Real-Time Agent Time Stats").": </td><td align=left><select size=1 name=realtime_agent_time_stats><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='WAIT_CUST_ACW'>"._QXZ("WAIT_CUST_ACW")."</option><option value='WAIT_CUST_ACW_PAUSE'>"._QXZ("WAIT_CUST_ACW_PAUSE")."</option><option value='CALLS_WAIT_CUST_ACW_PAUSE'>"._QXZ("CALLS_WAIT_CUST_ACW_PAUSE")."</option><option value='$realtime_agent_time_stats' SELECTED>"._QXZ("$realtime_agent_time_stats")."</option></select>$NWB#campaigns-realtime_agent_time_stats$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Disable Alter Customer Data").": </td><td align=left><select size=1 name=disable_alter_custdata><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$disable_alter_custdata' SELECTED>"._QXZ("$disable_alter_custdata")."</option></select>$NWB#campaigns-disable_alter_custdata$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Disable Alter Customer Phone").": </td><td align=left><select size=1 name=disable_alter_custphone><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='HIDE'>"._QXZ("HIDE")."</option><option value='$disable_alter_custphone' SELECTED>"._QXZ("$disable_alter_custphone")."</option></select>$NWB#campaigns-disable_alter_custphone$NWE</td></tr>\n";

		if ($SSoutbound_autodial_active > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Allow No-Hopper-Leads Logins").": </td><td align=left><select size=1 name=no_hopper_leads_logins><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$no_hopper_leads_logins' SELECTED>"._QXZ("$no_hopper_leads_logins")."</option></select>$NWB#campaigns-no_hopper_leads_logins$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("No Hopper Dialing").": </td><td align=left><select size=1 name=no_hopper_dialing><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$no_hopper_dialing' SELECTED>"._QXZ("$no_hopper_dialing")."</option></select>$NWB#campaigns-no_hopper_dialing$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Owner Only Dialing").": </td><td align=left><select size=1 name=agent_dial_owner_only><option value='NONE'>"._QXZ("NONE")."</option><option value='USER'>"._QXZ("USER")."</option><option value='TERRITORY'>"._QXZ("TERRITORY")."</option><option value='USER_GROUP'>"._QXZ("USER_GROUP")."</option><option value='USER_BLANK'>"._QXZ("USER_BLANK")."</option><option value='TERRITORY_BLANK'>"._QXZ("TERRITORY_BLANK")."</option><option value='USER_GROUP_BLANK'>"._QXZ("USER_GROUP_BLANK")."</option><option value='$agent_dial_owner_only' SELECTED>"._QXZ("$agent_dial_owner_only")."</option></select>$NWB#campaigns-agent_dial_owner_only$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Owner Populate").": </td><td align=left><select size=1 name=owner_populate><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$owner_populate' SELECTED>"._QXZ("$owner_populate")."</option></select>$NWB#campaigns-owner_populate$NWE</td></tr>\n";

			if ($SSuser_territories_active > 0)
				{
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Select Territories").": </td><td align=left><select size=1 name=agent_select_territories><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$agent_select_territories' SELECTED>"._QXZ("$agent_select_territories")."</option></select>$NWB#campaigns-agent_select_territories$NWE</td></tr>\n";
				}
			else
				{
				echo "<tr bgcolor=#$SSstd_row4_background><td colspan=2><input type=hidden name=agent_select_territories value='$agent_select_territories'></td></tr>\n";
				}
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Agent Display Dialable Leads").": </td><td align=left><select size=1 name=agent_display_dialable_leads><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$agent_display_dialable_leads' SELECTED>"._QXZ("$agent_display_dialable_leads")."</option></select>$NWB#campaigns-agent_display_dialable_leads$NWE</td></tr>\n";
			}
		if ( ($screen_labels=='--SYSTEM-SETTINGS--') or (strlen($screen_labels)<2) ) {$ASLlink = "$PHP_SELF?ADD=311111111111111";}
		else {$ASLlink = "$PHP_SELF?ADD=381111111111&label_id=$screen_labels";}
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right><a href=\"$ASLlink\">"._QXZ("Agent Screen Labels")."</a>: </td><td align=left><select size=1 name=screen_labels>$labels_menu<option value=\"--SYSTEM-SETTINGS--\">--"._QXZ("SYSTEM-SETTINGS")."-- - "._QXZ("Default")."</option><option value='$screen_labels' SELECTED>"._QXZ("$screen_labels")."</option></select>$NWB#campaigns-screen_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Allow Required Fields").": </td><td align=left><select size=1 name=allow_required_fields><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$allow_required_fields' SELECTED>"._QXZ("$allow_required_fields")."</option></select>$NWB#campaigns-allow_required_fields$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Status Display Fields").": </td><td align=left><select size=1 name=status_display_fields><option value='NAME'>"._QXZ("NAME")."</option><option value='CALLID'>"._QXZ("CALLID")."</option><option value='LEADID'>"._QXZ("LEADID")."</option><option value='LISTID'>"._QXZ("LISTID")."</option><option value='CALLID_LEADID'>"._QXZ("CALLID_LEADID")."</option><option value='CALLID_LISTID'>"._QXZ("CALLID_LISTID")."</option><option value='CALLID_LEADID_LISTID'>"._QXZ("CALLID_LEADID_LISTID")."</option><option value='NAME_CALLID'>"._QXZ("NAME_CALLID")."</option><option value='NAME_CALLID_LEADID'>"._QXZ("NAME_CALLID_LEADID")."</option><option value='NAME_CALLID_LISTID'>"._QXZ("NAME_CALLID_LISTID")."</option><option value='NAME_CALLID_LEADID_LISTID'>"._QXZ("NAME_CALLID_LEADID_LISTID")."</option><option value='---NONE---'>---"._QXZ("NONE")."---</option><option value='$status_display_fields' SELECTED>"._QXZ("$status_display_fields")."</option></select>$NWB#campaigns-status_display_fields$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Status Display In-Group").": </td><td align=left><select size=1 name=status_display_ingroup><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$status_display_ingroup' SELECTED>"._QXZ("$status_display_ingroup")."</option></select>$NWB#campaigns-status_display_ingroup$NWE</td></tr>\n";

		##### get container listings for dynamic STATE_DESCRIPTIONS container pulldown menu
		$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='STATE_DESCRIPTIONS' $LOGadmin_viewable_groupsSQL order by container_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$sdb_to_print = mysqli_num_rows($rslt);
		$state_descriptions_menu='';
		$sdb_selected=0;
		$o=0;
		while ($sdb_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			if (mb_strlen($rowx[1],'utf-8')>40)
				{$rowx[1] = mb_substr($rowx[1],0,40,'utf-8') . '...';}
			$state_descriptions_menu .= "<option ";
			if ($state_descriptions == "$rowx[0]") 
				{
				$state_descriptions_menu .= "SELECTED ";
				$sdb_selected++;
				}
			$state_descriptions_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>";
		if ($sdb_selected > 0)
			{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$state_descriptions\">"._QXZ("State Descriptions Banner")."</a>";}
		else
			{echo _QXZ("State Descriptions Banner");}
		echo ": </td><td align=left nowrap><select size=1 name=state_descriptions><option value='---DISABLED---'>"._QXZ("---DISABLED---")."</option>$state_descriptions_menu</select>$NWB#campaigns-state_descriptions$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Display Fields").": </td><td align=left><input type=text name=agent_display_fields size=60 maxlength=100 value=\"$agent_display_fields\">$NWB#campaigns-agent_display_fields$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Screen Time Display").": </td><td align=left><select size=1 name=agent_screen_time_display><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED_BASIC'>"._QXZ("ENABLED_BASIC")."</option><option value='ENABLED_FULL'>"._QXZ("ENABLED_FULL")."</option><option value='ENABLED_BILL_BREAK_LUNCH_COACH'>"._QXZ("ENABLED_BILL_BREAK_LUNCH_COACH")."</option><option value='ENABLED_BASIC_RANGE'>"._QXZ("ENABLED_BASIC_RANGE")."</option><option value='ENABLED_FULL_RANGE'>"._QXZ("ENABLED_FULL_RANGE")."</option><option value='ENABLED_EXTENDED_RANGE'>"._QXZ("ENABLED_EXTENDED_RANGE")."</option><option value='ENABLED_BILL_BREAK_LUNCH_COACH_RANGE'>"._QXZ("ENABLED_BILL_BREAK_LUNCH_COACH_RANGE")."</option><option value='$agent_screen_time_display' SELECTED>"._QXZ("$agent_screen_time_display")."</option></select>$NWB#campaigns-agent_screen_time_display$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Display Queue Count").": </td><td align=left><select size=1 name=display_queue_count><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$display_queue_count' SELECTED>"._QXZ("$display_queue_count")."</option></select>$NWB#campaigns-display_queue_count$NWE</td></tr>\n";

		##### get container listings for Calls In Queue Count Display pulldown menus
		$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='CALLS_IN_QUEUE_COUNT' $LOGadmin_viewable_groupsSQL order by container_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$csea_to_print = mysqli_num_rows($rslt);
		$calls_inqueue_count_one_container_menu='';
		$calls_inqueue_count_two_container_menu='';
		$csea_selected_one=0;
		$csea_selected_two=0;
		$o=0;
		while ($csea_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			if (mb_strlen($rowx[1],'utf-8')>40)
				{$rowx[1] = mb_substr($rowx[1],0,40,'utf-8') . '...';}
			$calls_inqueue_count_one_container_menu .= "<option ";
			$calls_inqueue_count_two_container_menu .= "<option ";
			if ($calls_inqueue_count_one == "$rowx[0]") 
				{
				$calls_inqueue_count_one_container_menu .= "SELECTED ";
				$csea_selected_one++;
				}
			if ($calls_inqueue_count_two == "$rowx[0]") 
				{
				$calls_inqueue_count_two_container_menu .= "SELECTED ";
				$csea_selected_two++;
				}
			$calls_inqueue_count_one_container_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$calls_inqueue_count_two_container_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}

		$calls_inqueue_count_one_container_menu .= "<option ";
		$calls_inqueue_count_two_container_menu .= "<option ";
		if ($calls_inqueue_count_one == "DISABLED") 
			{
			$calls_inqueue_count_one_container_menu .= "SELECTED ";
			}
		if ($calls_inqueue_count_two == "DISABLED") 
			{
			$calls_inqueue_count_two_container_menu .= "SELECTED ";
			}
		$calls_inqueue_count_one_container_menu .= "value=\"DISABLED\">---"._QXZ("DISABLED")."---</option>\n";
		$calls_inqueue_count_two_container_menu .= "value=\"DISABLED\">---"._QXZ("DISABLED")."---</option>\n";
		$o++;

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>";
		if ($csea_selected_one > 0)
			{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$calls_inqueue_count_one\">"._QXZ("Calls In Queue Count Display")." 1</a>";}
		else
			{echo _QXZ("Calls In Queue Count Display")." 1";}
		echo ": </td><td align=left><select size=1 name=calls_inqueue_count_one><option value=''>"._QXZ("DISABLED")."</option>$calls_inqueue_count_one_container_menu</select>$NWB#campaigns-calls_inqueue_count$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>";
		if ($csea_selected_two > 0)
			{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$calls_inqueue_count_two\">"._QXZ("Calls In Queue Count Display")." 2</a>";}
		else
			{echo _QXZ("Calls In Queue Count Display")." 2";}
		echo ": </td><td align=left><select size=1 name=calls_inqueue_count_two><option value=''>"._QXZ("DISABLED")."</option>$calls_inqueue_count_two_container_menu</select>$NWB#campaigns-calls_inqueue_count$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Agent View Calls in Queue").": </td><td align=left><select size=1 name=view_calls_in_queue><option value='NONE'>"._QXZ("NONE")."</option><option value='ALL'>"._QXZ("ALL")."</option><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option value='$view_calls_in_queue' SELECTED>"._QXZ("$view_calls_in_queue")."</option></select>$NWB#campaigns-view_calls_in_queue$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("View Calls in Queue Launch").": </td><td align=left><select size=1 name=view_calls_in_queue_launch><option value='AUTO'>"._QXZ("AUTO")."</option><option value='MANUAL'>"._QXZ("MANUAL")."</option><option value='$view_calls_in_queue_launch' SELECTED>"._QXZ("$view_calls_in_queue_launch")."</option></select>$NWB#campaigns-view_calls_in_queue_launch$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Calls in Queue Extra Column 1").": </td><td align=left><select size=1 name=calls_waiting_vl_one><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='lead_id'>"._QXZ("lead_id")."</option><option value='entry_date'>"._QXZ("entry_date")."</option><option value='status'>"._QXZ("status")."</option><option value='user'>"._QXZ("user")."</option><option value='vendor_lead_code'>"._QXZ("vendor_lead_code")."</option><option value='source_id'>"._QXZ("source_id")."</option><option value='list_id'>"._QXZ("list_id")."</option><option value='gmt_offset_now'>"._QXZ("gmt_offset_now")."</option><option value='called_since_last_reset'>"._QXZ("called_since_last_reset")."</option><option value='phone_code'>"._QXZ("phone_code")."</option><option value='phone_number'>"._QXZ("phone_number")."</option><option value='title'>"._QXZ("title")."</option><option value='first_name'>"._QXZ("first_name")."</option><option value='middle_initial'>"._QXZ("middle_initial")."</option><option value='last_name'>"._QXZ("last_name")."</option><option value='address1'>"._QXZ("address1")."</option><option value='address2'>"._QXZ("address2")."</option><option value='address3'>"._QXZ("address3")."</option><option value='city'>"._QXZ("city")."</option><option value='state'>"._QXZ("state")."</option><option value='province'>"._QXZ("province")."</option><option value='postal_code'>"._QXZ("postal_code")."</option><option value='country_code'>"._QXZ("country_code")."</option><option value='gender'>"._QXZ("gender")."</option><option value='date_of_birth'>"._QXZ("date_of_birth")."</option><option value='alt_phone'>"._QXZ("alt_phone")."</option><option value='email'>"._QXZ("email")."</option><option value='security_phrase'>"._QXZ("security_phrase")."</option><option value='comments'>"._QXZ("comments")."</option><option value='called_count'>"._QXZ("called_count")."</option><option value='last_local_call_time'>"._QXZ("last_local_call_time")."</option><option value='rank'>"._QXZ("rank")."</option><option value='owner'>"._QXZ("owner")."</option><option value='entry_list_id'>"._QXZ("entry_list_id")."</option><option value='$calls_waiting_vl_one' SELECTED>"._QXZ("$calls_waiting_vl_one")."</option></select>$NWB#campaigns-calls_waiting_vl_one$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Calls in Queue Extra Column 2").": </td><td align=left><select size=1 name=calls_waiting_vl_two><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='lead_id'>"._QXZ("lead_id")."</option><option value='entry_date'>"._QXZ("entry_date")."</option><option value='status'>"._QXZ("status")."</option><option value='user'>"._QXZ("user")."</option><option value='vendor_lead_code'>"._QXZ("vendor_lead_code")."</option><option value='source_id'>"._QXZ("source_id")."</option><option value='list_id'>"._QXZ("list_id")."</option><option value='gmt_offset_now'>"._QXZ("gmt_offset_now")."</option><option value='called_since_last_reset'>"._QXZ("called_since_last_reset")."</option><option value='phone_code'>"._QXZ("phone_code")."</option><option value='phone_number'>"._QXZ("phone_number")."</option><option value='title'>"._QXZ("title")."</option><option value='first_name'>"._QXZ("first_name")."</option><option value='middle_initial'>"._QXZ("middle_initial")."</option><option value='last_name'>"._QXZ("last_name")."</option><option value='address1'>"._QXZ("address1")."</option><option value='address2'>"._QXZ("address2")."</option><option value='address3'>"._QXZ("address3")."</option><option value='city'>"._QXZ("city")."</option><option value='state'>"._QXZ("state")."</option><option value='province'>"._QXZ("province")."</option><option value='postal_code'>"._QXZ("postal_code")."</option><option value='country_code'>"._QXZ("country_code")."</option><option value='gender'>"._QXZ("gender")."</option><option value='date_of_birth'>"._QXZ("date_of_birth")."</option><option value='alt_phone'>"._QXZ("alt_phone")."</option><option value='email'>"._QXZ("email")."</option><option value='security_phrase'>"._QXZ("security_phrase")."</option><option value='comments'>"._QXZ("comments")."</option><option value='called_count'>"._QXZ("called_count")."</option><option value='last_local_call_time'>"._QXZ("last_local_call_time")."</option><option value='rank'>"._QXZ("rank")."</option><option value='owner'>"._QXZ("owner")."</option><option value='entry_list_id'>"._QXZ("entry_list_id")."</option><option value='$calls_waiting_vl_two' SELECTED>"._QXZ("$calls_waiting_vl_two")."</option></select>$NWB#campaigns-calls_waiting_vl_one$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Agent Grab Calls in Queue").": </td><td align=left><select size=1 name=grab_calls_in_queue><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$grab_calls_in_queue' SELECTED>"._QXZ("$grab_calls_in_queue")."</option></select>$NWB#campaigns-grab_calls_in_queue$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Call Re-Queue Button").": </td><td align=left><select size=1 name=call_requeue_button><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$call_requeue_button' SELECTED>"._QXZ("$call_requeue_button")."</option></select>$NWB#campaigns-call_requeue_button$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Pause After Each Call").": </td><td align=left><select size=1 name=pause_after_each_call><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$pause_after_each_call' SELECTED>"._QXZ("$pause_after_each_call")."</option></select>$NWB#campaigns-pause_after_each_call$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Pause After Next Call Link").": </td><td align=left><select size=1 name=pause_after_next_call><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$pause_after_next_call' SELECTED>"._QXZ("$pause_after_next_call")."</option></select>$NWB#campaigns-pause_after_next_call$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Manual Dial Override").": </td><td align=left><select size=1 name=manual_dial_override><option value='NONE'>"._QXZ("NONE")."</option><option value='ALLOW_ALL'>"._QXZ("ALLOW_ALL")."</option><option value='DISABLE_ALL'>"._QXZ("DISABLE_ALL")."</option><option value='$manual_dial_override' SELECTED>"._QXZ("$manual_dial_override")."</option></select>$NWB#campaigns-manual_dial_override$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Manual Dial Override Field").": </td><td align=left><select size=1 name=manual_dial_override_field><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$manual_dial_override_field' SELECTED>"._QXZ("$manual_dial_override_field")."</option></select>$NWB#campaigns-manual_dial_override_field$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Manual Dial List ID").": </td><td align=left><input type=text name=manual_dial_list_id size=19 maxlength=19 value=\"$manual_dial_list_id\">$NWB#campaigns-manual_dial_list_id$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Manual Dial Filter").": </td><td align=left><select size=1 name=manual_dial_filter>
		<option value='NONE'>"._QXZ("NONE")."</option>
		<option value='DNC_ONLY'>"._QXZ("DNC_ONLY")."</option>
		<option value='CAMPDNC_ONLY'>"._QXZ("CAMPDNC_ONLY")."</option>
		<option value='INTERNALDNC_ONLY'>"._QXZ("INTERNALDNC_ONLY")."</option>
		<option value='DNC_AND_CAMPDNC'>"._QXZ("DNC_AND_CAMPDNC")."</option>
		<option value='CAMPLISTS_ONLY'>"._QXZ("CAMPLISTS_ONLY")."</option>
		<option value='CAMPLISTS_ALL'>"._QXZ("CAMPLISTS_ALL")."</option>
		<option value='SYSTEM'>"._QXZ("SYSTEM")."</option>
		<option value='DNC_AND_CAMPLISTS'>"._QXZ("DNC_AND_CAMPLISTS")."</option>
		<option value='CAMPDNC_ONLY_AND_CAMPLISTS'>"._QXZ("CAMPDNC_ONLY_AND_CAMPLISTS")."</option>
		<option value='INTERNALDNC_ONLY_AND_CAMPLISTS'>"._QXZ("INTERNALDNC_ONLY_AND_CAMPLISTS")."</option>
		<option value='DNC_AND_CAMPDNC_AND_CAMPLISTS'>"._QXZ("DNC_AND_CAMPDNC_AND_CAMPLISTS")."</option>
		<option value='DNC_AND_CAMPLISTS_ALL'>"._QXZ("DNC_AND_CAMPLISTS_ALL")."</option>
		<option value='CAMPDNC_ONLY_AND_CAMPLISTS_ALL'>"._QXZ("CAMPDNC_ONLY_AND_CAMPLISTS_ALL")."</option>
		<option value='INTERNALDNC_ONLY_AND_CAMPLISTS_ALL'>"._QXZ("INTERNALDNC_ONLY_AND_CAMPLISTS_ALL")."</option>
		<option value='DNC_AND_CAMPDNC_AND_CAMPLISTS_ALL'>"._QXZ("DNC_AND_CAMPDNC_AND_CAMPLISTS_ALL")."</option>
		<option value='DNC_AND_SYSTEM'>"._QXZ("DNC_AND_SYSTEM")."</option>
		<option value='CAMPDNC_ONLY_AND_SYSTEM'>"._QXZ("CAMPDNC_ONLY_AND_SYSTEM")."</option>
		<option value='INTERNALDNC_ONLY_AND_SYSTEM'>"._QXZ("INTERNALDNC_ONLY_AND_SYSTEM")."</option>
		<option value='DNC_AND_CAMPDNC_AND_SYSTEM'>"._QXZ("DNC_AND_CAMPDNC_AND_SYSTEM")."</option>
		<option value='NONE_WITH_ALT'>"._QXZ("NONE_WITH_ALT")."</option>
		<option value='DNC_ONLY_WITH_ALT'>"._QXZ("DNC_ONLY_WITH_ALT")."</option>
		<option value='CAMPDNC_ONLY_WITH_ALT'>"._QXZ("CAMPDNC_ONLY_WITH_ALT")."</option>
		<option value='INTERNALDNC_ONLY_WITH_ALT'>"._QXZ("INTERNALDNC_ONLY_WITH_ALT")."</option>
		<option value='DNC_AND_CAMPDNC_WITH_ALT'>"._QXZ("DNC_AND_CAMPDNC_WITH_ALT")."</option>
		<option value='CAMPLISTS_ONLY_WITH_ALT'>"._QXZ("CAMPLISTS_ONLY_WITH_ALT")."</option>
		<option value='CAMPLISTS_ALL_WITH_ALT'>"._QXZ("CAMPLISTS_ALL_WITH_ALT")."</option>
		<option value='SYSTEM_WITH_ALT'>"._QXZ("SYSTEM_WITH_ALT")."</option>
		<option value='DNC_AND_CAMPLISTS_WITH_ALT'>"._QXZ("DNC_AND_CAMPLISTS_WITH_ALT")."</option>
		<option value='CAMPDNC_ONLY_AND_CAMPLISTS_WITH_ALT'>"._QXZ("CAMPDNC_ONLY_AND_CAMPLISTS_WITH_ALT")."</option>
		<option value='INTERNALDNC_ONLY_AND_CAMPLISTS_WITH_ALT'>"._QXZ("INTERNALDNC_ONLY_AND_CAMPLISTS_WITH_ALT")."</option>
		<option value='DNC_AND_CAMPDNC_AND_CAMPLISTS_WITH_ALT'>"._QXZ("DNC_AND_CAMPDNC_AND_CAMPLISTS_WITH_ALT")."</option>
		<option value='DNC_AND_CAMPLISTS_ALL_WITH_ALT'>"._QXZ("DNC_AND_CAMPLISTS_ALL_WITH_ALT")."</option>
		<option value='CAMPDNC_ONLY_AND_CAMPLISTS_ALL_WITH_ALT'>"._QXZ("CAMPDNC_ONLY_AND_CAMPLISTS_ALL_WITH_ALT")."</option>
		<option value='INTERNALDNC_ONLY_AND_CAMPLISTS_ALL_WITH_ALT'>"._QXZ("INTERNALDNC_ONLY_AND_CAMPLISTS_ALL_WITH_ALT")."</option>
		<option value='DNC_AND_CAMPDNC_AND_CAMPLISTS_ALL_WITH_ALT'>"._QXZ("DNC_AND_CAMPDNC_AND_CAMPLISTS_ALL_WITH_ALT")."</option>
		<option value='DNC_AND_SYSTEM_WITH_ALT'>"._QXZ("DNC_AND_SYSTEM_WITH_ALT")."</option>
		<option value='CAMPDNC_ONLY_AND_SYSTEM_WITH_ALT'>"._QXZ("CAMPDNC_ONLY_AND_SYSTEM_WITH_ALT")."</option>
		<option value='INTERNALDNC_ONLY_AND_SYSTEM_WITH_ALT'>"._QXZ("INTERNALDNC_ONLY_AND_SYSTEM_WITH_ALT")."</option>
		<option value='DNC_AND_CAMPDNC_AND_SYSTEM_WITH_ALT'>"._QXZ("DNC_AND_CAMPDNC_AND_SYSTEM_WITH_ALT")."</option>
		<option value='NONE_WITH_ALT_ADDR3'>"._QXZ("NONE_WITH_ALT_ADDR3")."</option>
		<option value='DNC_ONLY_WITH_ALT_ADDR3'>"._QXZ("DNC_ONLY_WITH_ALT_ADDR3")."</option>
		<option value='CAMPDNC_ONLY_WITH_ALT_ADDR3'>"._QXZ("CAMPDNC_ONLY_WITH_ALT_ADDR3")."</option>
		<option value='INTERNALDNC_ONLY_WITH_ALT_ADDR3'>"._QXZ("INTERNALDNC_ONLY_WITH_ALT_ADDR3")."</option>
		<option value='DNC_AND_CAMPDNC_WITH_ALT_ADDR3'>"._QXZ("DNC_AND_CAMPDNC_WITH_ALT_ADDR3")."</option>
		<option value='CAMPLISTS_ONLY_WITH_ALT_ADDR3'>"._QXZ("CAMPLISTS_ONLY_WITH_ALT_ADDR3")."</option>
		<option value='CAMPLISTS_ALL_WITH_ALT_ADDR3'>"._QXZ("CAMPLISTS_ALL_WITH_ALT_ADDR3")."</option>
		<option value='SYSTEM_WITH_ALT_ADDR3'>"._QXZ("SYSTEM_WITH_ALT_ADDR3")."</option>
		<option value='DNC_AND_CAMPLISTS_WITH_ALT_ADDR3'>"._QXZ("DNC_AND_CAMPLISTS_WITH_ALT_ADDR3")."</option>
		<option value='CAMPDNC_ONLY_AND_CAMPLISTS_WITH_ALT_ADDR3'>"._QXZ("CAMPDNC_ONLY_AND_CAMPLISTS_WITH_ALT_ADDR3")."</option>
		<option value='INTERNALDNC_ONLY_AND_CAMPLISTS_WITH_ALT_ADDR3'>"._QXZ("INTERNALDNC_ONLY_AND_CAMPLISTS_WITH_ALT_ADDR3")."</option>
		<option value='DNC_AND_CAMPDNC_AND_CAMPLISTS_WITH_ALT_ADDR3'>"._QXZ("DNC_AND_CAMPDNC_AND_CAMPLISTS_WITH_ALT_ADDR3")."</option>
		<option value='DNC_AND_CAMPLISTS_ALL_WITH_ALT_ADDR3'>"._QXZ("DNC_AND_CAMPLISTS_ALL_WITH_ALT_ADDR3")."</option>
		<option value='CAMPDNC_ONLY_AND_CAMPLISTS_ALL_WITH_ALT_ADDR3'>"._QXZ("CAMPDNC_ONLY_AND_CAMPLISTS_ALL_WITH_ALT_ADDR3")."</option>
		<option value='INTERNALDNC_ONLY_AND_CAMPLISTS_ALL_WITH_ALT_ADDR3'>"._QXZ("INTERNALDNC_ONLY_AND_CAMPLISTS_ALL_WITH_ALT_ADDR3")."</option>
		<option value='DNC_AND_CAMPDNC_AND_CAMPLISTS_ALL_WITH_ALT_ADDR3'>"._QXZ("DNC_AND_CAMPDNC_AND_CAMPLISTS_ALL_WITH_ALT_ADDR3")."</option>
		<option value='DNC_AND_SYSTEM_WITH_ALT_ADDR3'>"._QXZ("DNC_AND_SYSTEM_WITH_ALT_ADDR3")."</option>
		<option value='CAMPDNC_ONLY_AND_SYSTEM_WITH_ALT_ADDR3'>"._QXZ("CAMPDNC_ONLY_AND_SYSTEM_WITH_ALT_ADDR3")."</option>
		<option value='INTERNALDNC_ONLY_AND_SYSTEM_WITH_ALT_ADDR3'>"._QXZ("INTERNALDNC_ONLY_AND_SYSTEM_WITH_ALT_ADDR3")."</option>
		<option value='DNC_AND_CAMPDNC_AND_SYSTEM_WITH_ALT_ADDR3'>"._QXZ("DNC_AND_CAMPDNC_AND_SYSTEM_WITH_ALT_ADDR3")."</option>
		<option value='CALLBACK'>"._QXZ("CALLBACK")."</option>
		<option value='DNC_AND_CALLBACK'>"._QXZ("DNC_AND_CALLBACK")."</option>
		<option value='CAMPDNC_ONLY_AND_CALLBACK'>"._QXZ("CAMPDNC_ONLY_AND_CALLBACK")."</option>
		<option value='INTERNALDNC_ONLY_AND_CALLBACK'>"._QXZ("INTERNALDNC_ONLY_AND_CALLBACK")."</option>
		<option value='DNC_AND_CAMPDNC_AND_CALLBACK'>"._QXZ("DNC_AND_CAMPDNC_AND_CALLBACK")."</option>
		<option value='NONE_WITH_ALT_AND_CALLBACK'>"._QXZ("NONE_WITH_ALT_AND_CALLBACK")."</option>
		<option value='DNC_ONLY_WITH_ALT_AND_CALLBACK'>"._QXZ("DNC_ONLY_WITH_ALT_AND_CALLBACK")."</option>
		<option value='CAMPDNC_ONLY_WITH_ALT_AND_CALLBACK'>"._QXZ("CAMPDNC_ONLY_WITH_ALT_AND_CALLBACK")."</option>
		<option value='INTERNALDNC_ONLY_WITH_ALT_AND_CALLBACK'>"._QXZ("INTERNALDNC_ONLY_WITH_ALT_AND_CALLBACK")."</option>
		<option value='DNC_AND_CAMPDNC_WITH_ALT_AND_CALLBACK'>"._QXZ("DNC_AND_CAMPDNC_WITH_ALT_AND_CALLBACK")."</option>
		<option value='NONE_WITH_ALT_ADDR3_AND_CALLBACK'>"._QXZ("NONE_WITH_ALT_ADDR3_AND_CALLBACK")."</option>
		<option value='DNC_ONLY_WITH_ALT_ADDR3_AND_CALLBACK'>"._QXZ("DNC_ONLY_WITH_ALT_ADDR3_AND_CALLBACK")."</option>
		<option value='CAMPDNC_ONLY_WITH_ALT_ADDR3_AND_CALLBACK'>"._QXZ("CAMPDNC_ONLY_WITH_ALT_ADDR3_AND_CALLBACK")."</option>
		<option value='INTERNALDNC_ONLY_WITH_ALT_ADDR3_AND_CALLBACK'>"._QXZ("INTERNALDNC_ONLY_WITH_ALT_ADDR3_AND_CALLBACK")."</option>
		<option value='DNC_AND_CAMPDNC_WITH_ALT_ADDR3_AND_CALLBACK'>"._QXZ("DNC_AND_CAMPDNC_WITH_ALT_ADDR3_AND_CALLBACK")."</option>
		<option value='$manual_dial_filter' SELECTED>"._QXZ("$manual_dial_filter")."</option>
		</select>$NWB#campaigns-manual_dial_filter$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Manual Preview Dial").": </td><td align=left><select size=1 name=manual_preview_dial><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='PREVIEW_AND_SKIP'>"._QXZ("PREVIEW_AND_SKIP")."</option><option value='PREVIEW_ONLY'>"._QXZ("PREVIEW_ONLY")."</option><option value='$manual_preview_dial' SELECTED>"._QXZ("$manual_preview_dial")."</option></select>$NWB#campaigns-manual_preview_dial$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Manual Dial Search Checkbox").": </td><td align=left><select size=1 name=manual_dial_search_checkbox><option value='SELECTED'>"._QXZ("SELECTED")."</option><option value='SELECTED_RESET'>"._QXZ("SELECTED_RESET")."</option><option value='SELECTED_LOCK'>"._QXZ("SELECTED_LOCK")."</option><option value='UNSELECTED'>"._QXZ("UNSELECTED")."</option><option value='UNSELECTED_RESET'>"._QXZ("UNSELECTED_RESET")."</option><option value='UNSELECTED_LOCK'>"._QXZ("UNSELECTED_LOCK")."</option><option value='$manual_dial_search_checkbox' SELECTED>"._QXZ("$manual_dial_search_checkbox")."</option></select>$NWB#campaigns-manual_dial_search_checkbox$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Manual Dial Search Filter").": </td><td align=left><select size=1 name=manual_dial_search_filter><option value='NONE'>"._QXZ("NONE")."</option>
		<option value='CAMPLISTS_ONLY'>"._QXZ("CAMPLISTS_ONLY")."</option>
		<option value='CAMPLISTS_ALL'>"._QXZ("CAMPLISTS_ALL")."</option>
		<option value='NONE_WITH_ALT'>"._QXZ("NONE_WITH_ALT")."</option>
		<option value='CAMPLISTS_ONLY_WITH_ALT'>"._QXZ("CAMPLISTS_ONLY_WITH_ALT")."</option>
		<option value='CAMPLISTS_ALL_WITH_ALT'>"._QXZ("CAMPLISTS_ALL_WITH_ALT")."</option>
		<option value='NONE_WITH_ALT_ADDR3'>"._QXZ("NONE_WITH_ALT_ADDR3")."</option>
		<option value='CAMPLISTS_ONLY_WITH_ALT_ADDR3'>"._QXZ("CAMPLISTS_ONLY_WITH_ALT_ADDR3")."</option>
		<option value='CAMPLISTS_ALL_WITH_ALT_ADDR3'>"._QXZ("CAMPLISTS_ALL_WITH_ALT_ADDR3")."</option>
		<option value='$manual_dial_search_filter' SELECTED>"._QXZ("$manual_dial_search_filter")."</option>
		</select>$NWB#campaigns-manual_dial_search_filter$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Manual Dial by Lead ID").": </td><td align=left><select size=1 name=manual_dial_lead_id><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='ONLY'>"._QXZ("ONLY")."</option><option value='$manual_dial_lead_id' SELECTED>"._QXZ("$manual_dial_lead_id")."</option></select>$NWB#campaigns-manual_dial_lead_id$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Manual Call Time Check").": </td><td align=left><select size=1 name=manual_dial_call_time_check><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='$manual_dial_call_time_check' SELECTED>"._QXZ("$manual_dial_call_time_check")."</option></select>$NWB#campaigns-manual_dial_call_time_check$NWE</td></tr>\n";

		if ($SSmanual_dial_validation =='1')
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Manual Dial Validation").": </td><td align=left><select size=1 name=manual_dial_validation><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$manual_dial_validation' SELECTED>"._QXZ("$manual_dial_validation")."</option></select>$NWB#campaigns-manual_dial_validation$NWE</td></tr>\n";
			}
		else
			{
			if ($SSmanual_dial_validation =='2')
				{
				echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Manual Dial Validation").": </td><td align=left><input type=hidden name=manual_dial_validation value='$manual_dial_validation'><b>"._QXZ("Y")."</b> $NWB#campaigns-manual_dial_validation$NWE</td></tr>\n";
				}
			else
				{
				echo "<tr bgcolor=#$SSstd_row3_background><td align=right></td><td align=left><input type=hidden name=manual_dial_validation value='$manual_dial_validation'></td></tr>\n";
				}
			}

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Manual Dial API").": </td><td align=left><select size=1 name=api_manual_dial><option value='STANDARD'>"._QXZ("STANDARD")."</option><option value='QUEUE'>"._QXZ("QUEUE")."</option><option value='QUEUE_AND_AUTOCALL'>"._QXZ("QUEUE_AND_AUTOCALL")."</option><option value='$api_manual_dial' SELECTED>"._QXZ("$api_manual_dial")."</option></select>$NWB#campaigns-api_manual_dial$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Manual Dial CID").": </td><td align=left><select size=1 name=manual_dial_cid><option value='CAMPAIGN'>"._QXZ("CAMPAIGN")."</option><option value='AGENT_PHONE'>"._QXZ("AGENT_PHONE")."</option><option value='AGENT_PHONE_OVERRIDE'>"._QXZ("AGENT_PHONE_OVERRIDE")."</option><option value='$manual_dial_cid' SELECTED>"._QXZ("$manual_dial_cid")."</option></select>$NWB#campaigns-manual_dial_cid$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Manual Dial Timeout").": </td><td align=left><input type=text name=manual_dial_timeout size=4 maxlength=3 value=\"$manual_dial_timeout\"> <i>"._QXZ("in seconds")."</i> $NWB#campaigns-manual_dial_timeout$NWE</td></tr>\n";

		if ($SSsip_event_logging > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Manual Minimum Ring Seconds").": </td><td align=left><input type=text name=manual_minimum_ring_seconds size=4 maxlength=3 value=\"$manual_minimum_ring_seconds\"> <i>"._QXZ("in seconds")."</i> $NWB#campaigns-manual_minimum_ring_seconds$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right colspan=2><input type=hidden name=manual_minimum_ring_seconds value=\"$manual_minimum_ring_seconds\"></td></tr>\n";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Manual Minimum Attempt Seconds").": </td><td align=left><input type=text name=manual_minimum_attempt_seconds size=4 maxlength=3 value=\"$manual_minimum_attempt_seconds\"> <i>"._QXZ("in seconds")."</i> $NWB#campaigns-manual_minimum_attempt_seconds$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Manual Minimum Answer Seconds").": </td><td align=left><input type=text name=manual_minimum_answer_seconds size=4 maxlength=3 value=\"$manual_minimum_answer_seconds\"> <i>"._QXZ("in seconds")."</i> $NWB#campaigns-manual_minimum_answer_seconds$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Phone Post Time Difference Alert").": </td><td align=left><select size=1 name=post_phone_time_diff_alert><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='OUTSIDE_CALLTIME_ONLY'>"._QXZ("OUTSIDE_CALLTIME_ONLY")."</option><option value='OUTSIDE_CALLTIME_PHONE'>"._QXZ("OUTSIDE_CALLTIME_PHONE")."</option><option value='OUTSIDE_CALLTIME_POSTAL'>"._QXZ("OUTSIDE_CALLTIME_POSTAL")."</option><option value='OUTSIDE_CALLTIME_BOTH'>"._QXZ("OUTSIDE_CALLTIME_BOTH")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$post_phone_time_diff_alert' SELECTED>"._QXZ("$post_phone_time_diff_alert")."</option></select>$NWB#campaigns-post_phone_time_diff_alert$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("In-Group Manual Dial").": </td><td align=left><select size=1 name=in_group_dial><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='MANUAL_DIAL'>"._QXZ("MANUAL_DIAL")."</option><option value='NO_DIAL'>"._QXZ("NO_DIAL")."</option><option value='BOTH'>"._QXZ("BOTH")."</option><option value='$in_group_dial' SELECTED>"._QXZ("$in_group_dial")."</option></select>$NWB#campaigns-in_group_dial$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("In-Group Manual Dial Select").": </td><td align=left><select size=1 name=in_group_dial_select><option value='CAMPAIGN_SELECTED'>"._QXZ("CAMPAIGN_SELECTED")."</option><option value='ALL_USER_GROUP'>"._QXZ("ALL_USER_GROUP")."</option><option value='$in_group_dial_select' SELECTED>"._QXZ("$in_group_dial_select")."</option></select>$NWB#campaigns-in_group_dial_select$NWE</td></tr>\n";

		if ($SSmanual_auto_next > 0)
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Manual Auto Next Seconds").": </td><td align=left><input type=text name=manual_auto_next size=5 maxlength=4 value=\"$manual_auto_next\">$NWB#campaigns-manual_auto_next$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Manual Auto Next Options").": </td><td align=left><select size=1 name=manual_auto_next_options><option value='DEFAULT'>"._QXZ("DEFAULT")."</option><option value='PAUSE_NO_COUNT'>"._QXZ("PAUSE_NO_COUNT")."</option><option value='$manual_auto_next_options' SELECTED>"._QXZ("$manual_auto_next_options")."</option></select>$NWB#campaigns-manual_auto_next_options$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Manual Auto Next Show Timer").": </td><td align=left><select size=1 name=manual_auto_show><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$manual_auto_show' SELECTED>"._QXZ("$manual_auto_show")."</option></select>$NWB#campaigns-manual_auto_show$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td colspan=2><input type=hidden name=manual_auto_next value='$manual_auto_next'><input type=hidden name=manual_auto_next_options value='$manual_auto_next_options'><input type=hidden name=manual_auto_show value='$manual_auto_show'></td></tr>\n";
			}

		if ($SSoutbound_autodial_active > 0)
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Manual Alt Num Dialing").": </td><td align=left><select size=1 name=alt_number_dialing><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='SELECTED'>"._QXZ("SELECTED")."</option><option value='SELECTED_TIMER_ALT'>"._QXZ("SELECTED_TIMER_ALT")."</option><option value='SELECTED_TIMER_ADDR3'>"._QXZ("SELECTED_TIMER_ADDR3")."</option><option value='UNSELECTED'>"._QXZ("UNSELECTED")."</option><option value='UNSELECTED_TIMER_ALT'>"._QXZ("UNSELECTED_TIMER_ALT")."</option><option value='UNSELECTED_TIMER_ADDR3'>"._QXZ("UNSELECTED_TIMER_ADDR3")."</option><option value='$alt_number_dialing' SELECTED>"._QXZ("$alt_number_dialing")."</option></select>$NWB#campaigns-alt_number_dialing$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Timer Alt Seconds").": </td><td align=left><input type=text name=timer_alt_seconds size=5 maxlength=4 value=\"$timer_alt_seconds\">$NWB#campaigns-timer_alt_seconds$NWE</td></tr>\n";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Screen Clipboard Copy").": </td><td align=left><select size=1 name=agent_clipboard_copy><option value='NONE'>"._QXZ("NONE")."</option><option>lead_id</option><option>list_id</option><option>title</option><option>first_name</option><option>middle_initial</option><option>last_name</option><option>phone_code</option><option>phone_number</option><option>address1</option><option>address2</option><option>address3</option><option>city</option><option>state</option><option>province</option><option>postal_code</option><option>country_code</option><option>alt_phone</option><option>comments</option><option>date_of_birth</option><option>email</option><option>gender</option><option>gmt_offset_now</option><option>security_phrase</option><option>vendor_lead_code</option><option value='$agent_clipboard_copy' SELECTED>"._QXZ("$agent_clipboard_copy")."</option></select>$NWB#campaigns-agent_clipboard_copy$NWE</td></tr>\n";

	#	if ($SSoutbound_autodial_active > 0)
	#		{
	#		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Screen Extended Alt Dial").": </td><td align=left><select size=1 name=agent_extended_alt_dial><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$agent_extended_alt_dial' SELECTED>"._QXZ("$agent_extended_alt_dial")."</option></select>$NWB#campaigns-agent_extended_alt_dial$NWE</td></tr>\n";
	#		}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group Alias Allowed").": </td><td align=left><select size=1 name=agent_allow_group_alias><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$agent_allow_group_alias' SELECTED>"._QXZ("$agent_allow_group_alias")."</option></select>$NWB#campaigns-agent_allow_group_alias$NWE</td></tr>\n";

		if ($agent_allow_group_alias == 'Y')
			{
			##### get groups_alias listings for dynamic default group alias pulldown list menu
			$stmt="SELECT group_alias_id,group_alias_name from groups_alias where active='Y' $LOGadmin_viewable_groupsSQL order by group_alias_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$group_alias_to_print = mysqli_num_rows($rslt);
			$group_alias_menu='';
			$group_alias_selected=0;
			$o=0;
			while ($group_alias_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$group_alias_menu .= "<option ";
				if ($default_group_alias == "$rowx[0]") 
					{
					$group_alias_menu .= "SELECTED ";
					$group_alias_selected++;
					}
				$group_alias_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$o++;
				}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Default Group Alias").": </td><td align=left><select size=1 name=default_group_alias>";
			echo "<option value=\"\">"._QXZ("NONE")."</option>";
			echo "$group_alias_menu";
			echo "</select>$NWB#campaigns-default_group_alias$NWE</td></tr>\n";
			}

		if ($SSenable_vtiger_integration > 0)
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Vtiger Search Category").": </td><td align=left><select size=1 name=vtiger_search_category><option value='LEAD'>"._QXZ("LEAD")."</option><option value='ACCOUNT'>"._QXZ("ACCOUNT")."</option><option value='VENDOR'>"._QXZ("VENDOR")."</option><option value='LEAD_ACCOUNT'>"._QXZ("LEAD_ACCOUNT")."</option><option value='LEAD_ACCOUNT_VENDOR'>"._QXZ("LEAD_ACCOUNT_VENDOR")."</option><option value='ACCTID'>"._QXZ("ACCTID")."</option><option value='ACCTID_ACCOUNT'>"._QXZ("ACCTID_ACCOUNT")."</option><option value='ACCTID_ACCOUNT_LEAD_VENDOR'>"._QXZ("ACCTID_ACCOUNT_LEAD_VENDOR")."</option><option value='UNIFIED_CONTACT'>"._QXZ("UNIFIED_CONTACT")."</option><option value='$vtiger_search_category' SELECTED>"._QXZ("$vtiger_search_category")."</option></select>$NWB#campaigns-vtiger_search_category$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Vtiger Search Dead Accounts").": </td><td align=left><select size=1 name=vtiger_search_dead><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ASK'>"._QXZ("ASK")."</option><option value='RESURRECT'>"._QXZ("RESURRECT")."</option><option value='$vtiger_search_dead' SELECTED>"._QXZ("$vtiger_search_dead")."</option></select>$NWB#campaigns-vtiger_search_dead$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Vtiger Create Call Record").": </td><td align=left><select size=1 name=vtiger_create_call_record><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='DISPO'>"._QXZ("DISPO")."</option><option value='$vtiger_create_call_record' SELECTED>"._QXZ("$vtiger_create_call_record")."</option></select>$NWB#campaigns-vtiger_create_call_record$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Vtiger Create Lead Record").": </td><td align=left><select size=1 name=vtiger_create_lead_record><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$vtiger_create_lead_record' SELECTED>"._QXZ("$vtiger_create_lead_record")."</option></select>$NWB#campaigns-vtiger_create_lead_record$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Vtiger Status Call").": </td><td align=left><select size=1 name=vtiger_status_call><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$vtiger_status_call' SELECTED>"._QXZ("$vtiger_status_call")."</option></select>$NWB#campaigns-vtiger_status_call$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Vtiger Screen Login").": </td><td align=left><select size=1 name=vtiger_screen_login><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='NEW_WINDOW'>"._QXZ("NEW_WINDOW")."</option><option value='$vtiger_screen_login' SELECTED>"._QXZ("$vtiger_screen_login")."</option></select>$NWB#campaigns-vtiger_screen_login$NWE</td></tr>\n";
			}
		else
			{
			echo "<input type=hidden name=vtiger_search_category value=\"$vtiger_search_category\">\n";
			echo "<input type=hidden name=vtiger_create_call_record value=\"$vtiger_create_call_record\">\n";
			echo "<input type=hidden name=vtiger_create_lead_record value=\"$vtiger_create_lead_record\">\n";
			echo "<input type=hidden name=vtiger_screen_login value=\"$vtiger_screen_login\">\n";
			echo "<input type=hidden name=vtiger_search_dead value=\"$vtiger_search_dead\">\n";
			echo "<input type=hidden name=vtiger_status_call value=\"$vtiger_status_call\">\n";
			}

		if ($SSenable_queuemetrics_logging > 0)
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("QM CallStatus Override").": </td><td align=left><select size=1 name=queuemetrics_callstatus><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='NO'>"._QXZ("NO")."</option><option value='YES'>"._QXZ("YES")."</option><option value='$queuemetrics_callstatus' SELECTED>"._QXZ("$queuemetrics_callstatus")."</option></select>$NWB#campaigns-queuemetrics_callstatus$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("QM Phone Environment").": </td><td align=left><input type=text name=queuemetrics_phone_environment size=20 maxlength=20 value=\"$queuemetrics_phone_environment\">$NWB#campaigns-queuemetrics_phone_environment$NWE</td></tr>\n";
			}
		else
			{
			echo "<input type=hidden name=queuemetrics_callstatus value=\"$queuemetrics_callstatus\">\n";
			echo "<input type=hidden name=queuemetrics_phone_environment value=\"$queuemetrics_phone_environment\">\n";
			}

		if ( ($agent_servers_count > 1) and ($phones_alias_count > 0) )
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("PLLB Grouping").": </td><td align=left><select size=1 name=pllb_grouping><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ONE_SERVER_ONLY'>"._QXZ("ONE_SERVER_ONLY")."</option><option value='CASCADING'>"._QXZ("CASCADING")."</option><option value='$pllb_grouping' SELECTED>"._QXZ("$pllb_grouping")."</option></select>$NWB#campaigns-pllb_grouping$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("PLLB Grouping Limit").": </td><td align=left><input type=text name=pllb_grouping_limit size=4 maxlength=3 value=\"$pllb_grouping_limit\">$NWB#campaigns-pllb_grouping_limit$NWE</td></tr>\n";
			}
		else
			{
			echo "<input type=hidden name=pllb_grouping value=\"$pllb_grouping\">\n";
			echo "<input type=hidden name=pllb_grouping_limit value=\"$pllb_grouping_limit\">\n";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("CRM Popup Login").": </td><td align=left><select size=1 name=crm_popup_login><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$crm_popup_login' SELECTED>"._QXZ("$crm_popup_login")."</option></select>$NWB#campaigns-crm_popup_login$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("CRM Popup Address").": </td><td align=left><input type=text name=crm_login_address size=70 maxlength=5000 value=\"$crm_login_address\">$NWB#campaigns-crm_login_address$NWE</td></tr>\n";

		if ($start_call_url == 'ALT')
			{
			$stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$campaign_id' and entry_type='campaign' and url_type='start';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$vum_to_print = mysqli_num_rows($rslt);
			if ($vum_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$vum_count = $rowx[0]; 
				}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"admin_url_multi.php?DB=$DB&campaign_id=$campaign_id&entry_type=campaign&url_type=start\">"._QXZ("Start Call URL")."</a>: </td><td align=left><input type=text name=start_call_url size=10 maxlength=5000 value=\"$start_call_url\">$NWB#campaigns-start_call_url$NWE <a href=\"admin_url_multi.php?DB=$DB&campaign_id=$campaign_id&entry_type=campaign&url_type=start\"> "._QXZ("Alternate Start URLs Defined").": $vum_count</a></td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Start Call URL").": </td><td align=left><input type=text name=start_call_url size=70 maxlength=5000 value=\"$start_call_url\">$NWB#campaigns-start_call_url$NWE</td></tr>\n";
			}

		if ($dispo_call_url == 'ALT')
			{
			$stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$campaign_id' and entry_type='campaign' and url_type='dispo';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$vum_to_print = mysqli_num_rows($rslt);
			if ($vum_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$vum_count = $rowx[0]; 
				}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"admin_url_multi.php?DB=$DB&campaign_id=$campaign_id&entry_type=campaign&url_type=dispo\">"._QXZ("Dispo Call URL")."</a>: </td><td align=left><input type=text name=dispo_call_url size=10 maxlength=5000 value=\"$dispo_call_url\">$NWB#campaigns-dispo_call_url$NWE <a href=\"admin_url_multi.php?DB=$DB&campaign_id=$campaign_id&entry_type=campaign&url_type=dispo\"> "._QXZ("Alternate Dispo URLs Defined").": $vum_count</a></td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Dispo Call URL").": </td><td align=left><input type=text name=dispo_call_url size=70 maxlength=5000 value=\"$dispo_call_url\">$NWB#campaigns-dispo_call_url$NWE</td></tr>\n";
			}

		if ($na_call_url == 'ALT')
			{
			$stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$campaign_id' and entry_type='campaign' and url_type='noagent';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$vum_to_print = mysqli_num_rows($rslt);
			if ($vum_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$vum_count = $rowx[0]; 
				}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"admin_url_multi.php?DB=$DB&campaign_id=$campaign_id&entry_type=campaign&url_type=noagent\">"._QXZ("No Agent Call URL")."</a>: </td><td align=left><input type=text name=na_call_url size=10 maxlength=5000 value=\"$na_call_url\">$NWB#campaigns-na_call_url$NWE <a href=\"admin_url_multi.php?DB=$DB&campaign_id=$campaign_id&entry_type=campaign&url_type=noagent\"> "._QXZ("Alternate No Agent URLs Defined").": $vum_count</a></td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("No Agent Call URL").": </td><td align=left><input type=text name=na_call_url size=70 maxlength=5000 value=\"$na_call_url\">$NWB#campaigns-na_call_url$NWE</td></tr>\n";
			}

		$stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$campaign_id' and entry_type='campaign' and url_type='talk';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$vum_to_print = mysqli_num_rows($rslt);
		if ($vum_to_print > 0) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$vum_count = $rowx[0]; 
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"admin_url_multi.php?DB=$DB&campaign_id=$campaign_id&entry_type=campaign&url_type=talk\">"._QXZ("Talk Seconds URLs")."</a>: </td><td align=left>$NWB#campaigns-talk_sec_url$NWE <a href=\"admin_url_multi.php?DB=$DB&campaign_id=$campaign_id&entry_type=campaign&url_type=talk\"> "._QXZ("Talk Seconds URLs Defined").": $vum_count</a></td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Extension Append CID").": </td><td align=left><select size=1 name=extension_appended_cidname><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='Y_USER'>"._QXZ("Y_USER")."</option><option value='Y_WITH_CAMPAIGN'>"._QXZ("Y_WITH_CAMPAIGN")."</option><option value='Y_USER_WITH_CAMPAIGN'>"._QXZ("Y_USER_WITH_CAMPAIGN")."</option><option value='$extension_appended_cidname' SELECTED>"._QXZ("$extension_appended_cidname")."</option></select>$NWB#campaigns-extension_appended_cidname$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Blind Monitor Warning").": </td><td align=left><select size=1 name=blind_monitor_warning><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ALERT'>"._QXZ("ALERT")."</option><option value='NOTICE'>"._QXZ("NOTICE")."</option><option value='AUDIO'>"._QXZ("AUDIO")."</option><option value='ALERT_NOTICE'>"._QXZ("ALERT_NOTICE")."</option><option value='ALERT_AUDIO'>"._QXZ("ALERT_AUDIO")."</option><option value='NOTICE_AUDIO'>"._QXZ("NOTICE_AUDIO")."</option><option value='ALL'>"._QXZ("ALL")."</option><option value='$blind_monitor_warning' SELECTED>"._QXZ("$blind_monitor_warning")."</option></select>$NWB#campaigns-blind_monitor_warning$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Blind Monitor Notice").": </td><td align=left><input type=text name=blind_monitor_message size=70 maxlength=255 value=\"$blind_monitor_message\">$NWB#campaigns-blind_monitor_message$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Blind Monitor Filename").": </td><td align=left><input type=text name=blind_monitor_filename id=blind_monitor_filename size=40 maxlength=100 value=\"$blind_monitor_filename\"> <a href=\"javascript:launch_chooser('blind_monitor_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#campaigns-blind_monitor_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom 1").": </td><td align=left><input type=text name=custom_one id=custom_one size=40 maxlength=2000 value=\"$custom_one\"> $NWB#campaigns-custom_fields$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom 2").": </td><td align=left><input type=text name=custom_two id=custom_two size=40 maxlength=2000 value=\"$custom_two\"> $NWB#campaigns-custom_fields$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom 3").": </td><td align=left><input type=text name=custom_three id=custom_three size=40 maxlength=2000 value=\"$custom_three\"> $NWB#campaigns-custom_fields$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom 4").": </td><td align=left><input type=text name=custom_four id=custom_four size=40 maxlength=2000 value=\"$custom_four\"> $NWB#campaigns-custom_fields$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom 5").": </td><td align=left><input type=text name=custom_five id=custom_five size=40 maxlength=2000 value=\"$custom_five\"> $NWB#campaigns-custom_fields$NWE</td></tr>\n";

		if ($campaign_allow_inbound == 'Y')
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Max Inbound Calls").": </td><td align=left><input type=text name=max_inbound_calls id=max_inbound_calls size=5 maxlength=4 value=\"$max_inbound_calls\"> $NWB#campaigns-max_inbound_calls$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Max Inbound Calls Outcome").": </td><td align=left><select size=1 name=max_inbound_calls_outcome><option value='DEFAULT'>"._QXZ("DEFAULT")."</option><option value='ALLOW_AGENTDIRECT'>"._QXZ("ALLOW_AGENTDIRECT")."</option><option value='ALLOW_MI_PAUSE'>"._QXZ("ALLOW_MI_PAUSE")."</option><option value='ALLOW_AGENTDIRECT_AND_MI_PAUSE'>"._QXZ("ALLOW_AGENTDIRECT_AND_MI_PAUSE")."</option><option value='$max_inbound_calls_outcome' SELECTED>"._QXZ("$max_inbound_calls_outcome")."</option></select>$NWB#campaigns-max_inbound_calls_outcome$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right valign=top>"._QXZ("Allowed Inbound Groups").": <BR>";
			echo " $NWB#campaigns-closer_campaigns$NWE</td><td align=left>\n";
			echo "$groups_list";
			echo "</td></tr>\n";
			}
		else
			{
			echo "<input type=hidden name=max_inbound_calls value=\"$max_inbound_calls\">\n";
			echo "<input type=hidden name=max_inbound_calls_outcome value=\"$max_inbound_calls_outcome\">\n";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Default Transfer Group").": </td><td align=left><select size=1 name=default_xfer_group>";
		echo "$Xgroups_menu";
		echo "</select>$NWB#campaigns-default_xfer_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Transfer In-Group Validation").": </td><td align=left><select size=1 name=agent_xfer_validation><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$agent_xfer_validation' SELECTED>"._QXZ("$agent_xfer_validation")."</option></select>$NWB#campaigns-agent_xfer_validation$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Transfer In-Group Sort Order").": </td><td align=left><select size=1 name=ig_xfer_list_sort><option value='GROUP_ID_UP'>"._QXZ("GROUP_ID_UP")."</option><option value='GROUP_ID_DOWN'>"._QXZ("GROUP_ID_DOWN")."</option><option value='GROUP_NAME_UP'>"._QXZ("GROUP_NAME_UP")."</option><option value='GROUP_NAME_DOWN'>"._QXZ("GROUP_NAME_DOWN")."</option><option value='PRIORITY_UP'>"._QXZ("PRIORITY_UP")."</option><option value='PRIORITY_DOWN'>"._QXZ("PRIORITY_DOWN")."</option><option value='$ig_xfer_list_sort' SELECTED>"._QXZ("$ig_xfer_list_sort")."</option></select>$NWB#campaigns-ig_xfer_list_sort$NWE</td></tr>\n";

		if ($allow_closers == 'Y')
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top>"._QXZ("Allowed Transfer Groups").": <BR>";
			echo " $NWB#campaigns-xfer_groups$NWE</td><td align=left>\n";
			echo "$XFERgroups_list";
			echo "</td></tr>\n";
			}

		echo "<input type=hidden name=form_end value=\"END\">\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center></FORM>\n";

		if ($SSbrowser_call_alerts > 0)
			{
			$bas=0;   $bas_embed_output='';
			while ($browser_alert_sounds_listARY_ct > $bas)
				{
				$bas_embed_output .= "<audio id='BAS_$browser_alert_sounds_listARY[$bas]'><source src=\"../agc/sounds/".$browser_alert_sounds_listARY[$bas].".mp3\" type=\"audio/mpeg\"></audio>\n";
				$bas++;
				}
			echo "$bas_embed_output";
			echo "\n";
			}

		echo "<center>\n";

		echo "<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=41>\n";
		echo "<input type=hidden name=DB value=$DB>\n";
		echo "<input type=hidden name=stage value=list_activation>\n";
		echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";

		if ($SSoutbound_autodial_active > 0)
			{
			echo "<br><b>"._QXZ("LISTS WITHIN THIS CAMPAIGN").": &nbsp; $NWB#campaign_lists$NWE</b>\n";

			echo "<TABLE><TR><TD>\n";
				echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

			$LISTlink='stage=LISTIDDOWN';
			$NAMElink='stage=LISTNAMEDOWN';
			$CALLTIMElink='stage=CALLTIMEDOWN';
			$TALLYlink='stage=TALLYDOWN';
			$ACTIVElink='stage=ACTIVEDOWN';
			$CAMPAIGNlink='stage=CAMPAIGNDOWN';
			$CALLDATElink='stage=CALLDATEDOWN';
			$SQLorder='order by list_id';
			if (preg_match('/LISTIDUP/i', $stage))			{$SQLorder='order by list_id asc';				$LISTlink='stage=LISTIDDOWN';}
			if (preg_match('/LISTIDDOWN/i', $stage))		{$SQLorder='order by list_id desc';				$LISTlink='stage=LISTIDUP';}
			if (preg_match('/LISTNAMEUP/i', $stage))		{$SQLorder='order by list_name asc';			$NAMElink='stage=LISTNAMEDOWN';}
			if (preg_match('/LISTNAMEDOWN/i', $stage))		{$SQLorder='order by list_name desc';			$NAMElink='stage=LISTNAMEUP';}
			if (preg_match('/CALLTIMEUP/i', $stage))		{$SQLorder='order by local_call_time asc';		$CALLTIMElink='stage=CALLTIMEDOWN';}
			if (preg_match('/CALLTIMEDOWN/i', $stage))		{$SQLorder='order by local_call_time desc';		$CALLTIMElink='stage=CALLTIMEUP';}	
			if (preg_match('/TALLYUP/i', $stage))			{$SQLorder='order by tally asc';				$TALLYlink='stage=TALLYDOWN';}
			if (preg_match('/TALLYDOWN/i', $stage))			{$SQLorder='order by tally desc';				$TALLYlink='stage=TALLYUP';}
			if (preg_match('/ACTIVEUP/i', $stage))			{$SQLorder='order by active asc';				$ACTIVElink='stage=ACTIVEDOWN';}
			if (preg_match('/ACTIVEDOWN/i', $stage))		{$SQLorder='order by active desc';				$ACTIVElink='stage=ACTIVEUP';}
			if (preg_match('/CAMPAIGNUP/i',$stage))			{$SQLorder='order by campaign_id asc';			$CAMPAIGNlink='stage=CAMPAIGNDOWN';}
			if (preg_match('/CAMPAIGNUP/i', $stage))		{$SQLorder='order by campaign_id desc';			$CAMPAIGNlink='stage=CAMPAIGNUP';}
			if (preg_match('/CALLDATEUP/i', $stage))		{$SQLorder='order by list_lastcalldate asc';	$CALLDATElink='stage=CALLDATEDOWN';}
			if (preg_match('/CALLDATEDOWN/i', $stage))		{$SQLorder='order by list_lastcalldate desc';	$CALLDATElink='stage=CALLDATEUP';}
			$stmt="SELECT vls.list_id,list_name,list_description,count(*) as tally,active,list_lastcalldate,campaign_id,DATE_FORMAT(expiration_date,'%Y%m%d'),local_call_time from vicidial_lists vls,vicidial_list vl where vls.list_id=vl.list_id and campaign_id='$campaign_id' $LOGallowed_campaignsSQL group by list_id $SQLorder";
			if ($SSadmin_list_counts < 1)
				{$stmt="SELECT list_id,list_name,list_description,'X' as tally,active,list_lastcalldate,campaign_id,DATE_FORMAT(expiration_date,'%Y%m%d'),local_call_time from vicidial_lists where campaign_id='$campaign_id' $LOGallowed_campaignsSQL $SQLorder";}
			$rslt=mysql_to_mysqli($stmt, $link);
			$lists_to_print = mysqli_num_rows($rslt);

			echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
			echo "<TR BGCOLOR=BLACK>";
			echo "<TD><a href=\"$PHP_SELF?ADD=31&campaign_id=$campaign_id&$LISTlink\"><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("LIST ID")."</B></a></TD>";
			echo "<TD><a href=\"$PHP_SELF?ADD=31&campaign_id=$campaign_id&$NAMElink\"><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("LIST NAME")."</B></a></TD>";
			echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("DESCRIPTION")."</B></TD>\n";
			echo "<TD><a href=\"$PHP_SELF?ADD=31&campaign_id=$campaign_id&$TALLYlink\"><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("LEADS COUNT")."</B></a></TD>\n";
			echo "<TD><a href=\"$PHP_SELF?ADD=31&campaign_id=$campaign_id&$CALLTIMElink\"><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("Call Time")."</B></a></TD>";
			echo "<TD COLSPAN=3><a href=\"$PHP_SELF?ADD=31&campaign_id=$campaign_id&$ACTIVElink\"><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("ACTIVE")."</B></a></TD>";
			echo "<TD><a href=\"$PHP_SELF?ADD=31&campaign_id=$campaign_id&$CALLDATElink\"><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("LAST CALL DATE")."</B></a></TD>";
			echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>MODIFY</TD>\n";
			echo "</TR>\n";

			$o=0;
			$last_list_statuses="";
			while ($lists_to_print > $o)
				{
				$row=mysqli_fetch_row($rslt);
				$last_list_statuses.="$row[0]|$row[4]|";
				if (preg_match('/1$|3$|5$|7$|9$/i', $o))
					{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
				else
					{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}
				echo "<tr $bgcolor><td><font size=1><a href=\"$PHP_SELF?ADD=311&list_id=$row[0]\">$row[0]</a></td>";
				echo "<td><font size=1> $row[1]</td>";
				echo "<td><font size=1> $row[2]</td>";
				echo "<td><font size=1> $row[3]</td>";
				if ($row[8] == 'campaign')
					{echo "<td><font size=1> $row[8]</td>";}
				else
					{echo "<td><font size=1><a href=\"$PHP_SELF?ADD=311111111&call_time_id=$row[8]\"> $row[8]</a></td>";}
				echo "<td><font size=1> "._QXZ("$row[4]")."</td>";
				echo "<td>";

				if (preg_match('/Y/',$row[4]))
					{
					$active_lists++;
					$camp_lists .= "'$row[0]',";
					echo "<input type=\"checkbox\" name=\"list_active_change[]\" value=\"$row[0]\" CHECKED>";
					}
				else
					{
					$inactive_lists++;
					echo "<input type=\"checkbox\" name=\"list_active_change[]\" value=\"$row[0]\"";
					}
					
				echo "</td><td><font size=1>";
				if ($row[7] < $EXPtestdate)
					{echo "<font color=red><B>"._QXZ("EXP")."</B></font>";}
				else
					{echo "&nbsp;";}
				echo "</td>";

				echo "<td><font size=1> $row[5]</td>";
				echo "<td><font size=1><a href=\"$PHP_SELF?ADD=311&list_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";

				$o++;
				}

			echo "<TR><TD COLSPAN=9 ALIGN=CENTER><input style='background-color:#$SSbutton_color' type=button onClick='return ConfirmListStatusChange($SSlist_status_modification_confirmation, this.form)' value=\""._QXZ("SUBMIT ACTIVE LIST CHANGES")."\"></TD></TR>\n";
			echo "</TABLE>";
			echo "<input type='hidden' name='last_list_statuses' id='last_list_statuses' value='$last_list_statuses'>";
			echo "</center><BR></FORM>\n";

			$filterSQL = $filtersql_list[$lead_filter_id];
			$filterSQL = preg_replace("/\\\\/","",$filterSQL);
			$filterSQL = preg_replace('/^and|and$|^or|or$/i', '',$filterSQL);
			if (strlen($filterSQL)>4)
				{$fSQL = "and ($filterSQL)";}
			else
				{$fSQL = '';}

			$camp_lists = preg_replace('/.$/i','',$camp_lists);
			echo "<center><B>"._QXZ("This campaign has")." $active_lists "._QXZ("active lists and")." $inactive_lists "._QXZ("inactive lists")."</B><br><br>\n";

			$dial_statuses_original = $dial_statuses;

			if ( ($display_leads_count == 'Y') and (strlen($camp_lists) > 3) )
				{
				# grab names of global statuses and statuses in the selected campaign
				$stmt="SELECT status,status_name,completed from vicidial_statuses order by status;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$statuses_to_print = mysqli_num_rows($rslt);

				$o=0;
				while ($statuses_to_print > $o) 
					{
					$rowx=mysqli_fetch_row($rslt);
					$statuses_name_list["$rowx[0]"] = "$rowx[1]";
					$statuses_complete_list["$rowx[0]"] = "$rowx[2]";
					$o++;
					}

				$stmt="SELECT status,status_name,completed from vicidial_campaign_statuses where campaign_id IN($camp_status_groups'$campaign_id') $LOGallowed_campaignsSQL order by status;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$Cstatuses_to_print = mysqli_num_rows($rslt);

				$o=0;
				while ($Cstatuses_to_print > $o) 
					{
					$rowx=mysqli_fetch_row($rslt);
					$statuses_name_list["$rowx[0]"] = "$rowx[1]";
					$statuses_complete_list["$rowx[0]"] = "$rowx[2]";
					$o++;
					}
				# end grab status names

				echo "<br><b>"._QXZ("STATUSES WITHIN THE ACTIVE LISTS FOR THIS CAMPAIGN").":</b>\n";
				echo " - <font size=1><a href=\"$PHP_SELF?ADD=31&campaign_id=$campaign_id&stage=hide_leadscount\">"._QXZ("HIDE")."</a></font><BR>";

				if ($SSexpanded_list_stats > 0)
					{
					echo "<TABLE width=700 cellspacing=3>\n";
					$dialable_total=0;
					$complete_total=0;
					$fSQL = '';

					$stmt="SELECT lead_filter_sql from vicidial_lead_filters where lead_filter_id='$lead_filter_id' $LOGadmin_viewable_groupsSQL;";
					$rslt=mysql_to_mysqli($stmt, $link);
					$filters_to_print = mysqli_num_rows($rslt);
					if ($filters_to_print > 0) 
						{
						$rowx=mysqli_fetch_row($rslt);
						$filterSQL = $rowx[0];
						$filterSQL = preg_replace("/\\\\/","",$filterSQL);
						$filterSQL = preg_replace('/^and|and$|^or|or$/i', '',$filterSQL);
						if (strlen($filterSQL)>4)
							{$fSQL = "and ($filterSQL)";}
						else
							{$fSQL = '';}
						}
					echo "<tr><td>"._QXZ("STATUS")."</td><td>"._QXZ("STATUS NAME")."</td><td>"._QXZ("CALLED")."</td><td>"._QXZ("NOT CALLED")."</td><td>"._QXZ("DIALABLE")."</td><td>"._QXZ("PENETRATION")."</td></tr>\n";
					}
				else
					{
					echo "<TABLE width=500 cellspacing=3>\n";
					echo "<tr><td>"._QXZ("STATUS")."</td><td>"._QXZ("STATUS NAME")."</td><td>"._QXZ("CALLED")."</td><td>"._QXZ("NOT CALLED")."</td></tr>\n";
					}

				$leads_in_list = 0;
				$leads_in_list_N = 0;
				$leads_in_list_Y = 0;
				$stmt="SELECT status,called_since_last_reset,count(*) from vicidial_list where list_id IN($camp_lists) group by status,called_since_last_reset order by status,called_since_last_reset;";
				if ($DB) {echo "$stmt\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				$statuses_to_print = mysqli_num_rows($rslt);

				$o=0;
				$lead_list['count'] = 0;
				$lead_list['Y_count'] = 0;
				$lead_list['N_count'] = 0;
				while ($statuses_to_print > $o) 
					{
					$rowx=mysqli_fetch_row($rslt);
					
					$lead_list['count'] = ($lead_list['count'] + $rowx[2]);
					if ($rowx[1] == 'N') 
						{
						$since_reset = 'N';
						$since_resetX = 'Y';
						}
					else 
						{
						$since_reset = 'Y';
						$since_resetX = 'N';
						} 
					$lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]);
					$lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]);
					#If opposite side is not set, it may not in the future so give it a value of zero
					if (!isset($lead_list[$since_resetX][$rowx[0]])) 
						{
						$lead_list[$since_resetX][$rowx[0]]=0;
						}
					$o++;
					}
			 
				$o=0;
				if ($lead_list['count'] > 0)
					{
#					while (list($dispo,) = each($lead_list[$since_reset]))
					foreach($lead_list[$since_reset] as $dispo => $blank)
						{
						if (preg_match('/1$|3$|5$|7$|9$/i', $o))
							{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
						else
							{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

						if ($dispo == 'CBHOLD')
							{
							$CLB="<a href=\"$PHP_SELF?ADD=811&list_id=$list_id\">";
							$CLE="</a>";
							}
						else
							{
							$CLB='';
							$CLE='';
							}
						if ($SSexpanded_list_stats > 0)
							{
							### call function to calculate dialable leads
							$single_status=1;
							$only_return=0;
							$dial_statuses=" $dispo -";
							if ($statuses_complete_list[$dispo] == 'Y')
								{$Xdialable_count=0;}
							else
								{$Xdialable_count = dialable_leads($DB,$link,$local_call_time,$dial_statuses,$camp_lists,$drop_lockout_time,$call_count_limit,$single_status,$fSQL,$only_return);}
							$dialable_total = ($dialable_total + $Xdialable_count);

							### get number of complete calls of this status for penetration calculations
							$Xcomplete_count = complete_leads($DB,$link,$dial_statuses,$camp_lists,$call_count_limit,$single_status,$campaign_id);
							$complete_total = ($complete_total + $Xcomplete_count);
							$dispo_total = ($lead_list['Y'][$dispo] + $lead_list['N'][$dispo]);
							if ( ($Xcomplete_count < 1) or ($dispo_total < 1) )
								{$complete_pct = "0";}
							else
								{
								$complete_pct = intval(($Xcomplete_count / $dispo_total) * 100);
								}

							echo "<tr $bgcolor><td><font size=1>$CLB$dispo$CLE</td><td><font size=1>$statuses_name_list[$dispo]</td><td><font size=1>".$lead_list['Y'][$dispo]."</td><td><font size=1>".$lead_list['N'][$dispo]." </td><td><font size=1>$Xdialable_count </td><td align=right><font size=1>$complete_pct% &nbsp; </td></tr>\n";
							}
						else
							{
							echo "<tr $bgcolor><td><font size=1>$CLB$dispo$CLE</td><td><font size=1>$statuses_name_list[$dispo]</td><td><font size=1>".$lead_list['Y'][$dispo]."</td><td><font size=1>".$lead_list['N'][$dispo]." </td></tr>\n";
							}
						$o++;
						}
					}

				if ($SSexpanded_list_stats > 0)
					{
					if ( ($complete_total < 1) or ($lead_list['count'] < 1) )
						{$total_complete_pct = "0";}
					else
						{$total_complete_pct = intval(($complete_total / $lead_list['count']) * 100);}
					echo "<tr><td colspan=2><font size=1>"._QXZ("SUBTOTALS")."</td><td><font size=1>$lead_list[Y_count]</td><td><font size=1>$lead_list[N_count]</td><td><font size=1> &nbsp; </td><td><font size=1> &nbsp; </td></tr>\n";
					echo "<tr bgcolor=\"#$SSstd_row1_background\"><td><font size=1>"._QXZ("TOTAL")."</td><td colspan=3 align=center><font size=1>$lead_list[count]</td><td><font size=1>$dialable_total</td><td align=right><font size=1> $total_complete_pct% &nbsp; </td></tr>\n";
					}
				else
					{
					echo "<tr><td colspan=2><font size=1>"._QXZ("SUBTOTALS")."</td><td><font size=1>$lead_list[Y_count]</td><td><font size=1>$lead_list[N_count]</td></tr>\n";
					echo "<tr bgcolor=\"#$SSstd_row1_background\"><td><font size=1>"._QXZ("TOTAL")."</td><td colspan=3 align=center><font size=1>$lead_list[count]</td></tr>\n";
					}

				echo "</table></center><br>\n";
				unset($lead_list);
				}
			else
				{
				echo "<font size=1><a href=\"$PHP_SELF?ADD=31&campaign_id=$campaign_id&stage=show_leadscount\">"._QXZ("SHOW LEAD STATUSES IN THIS CAMPAIGN")."</a></font><BR><BR>";
				}



			echo "<center><b>\n";

			if ($display_dialable_count == 'Y')
				{
				### call function to calculate and print dialable leads
				$single_status=0;
				$only_return=0;
				$dial_statuses = $dial_statuses_original;
				dialable_leads($DB,$link,$local_call_time,$dial_statuses,$camp_lists,$drop_lockout_time,$call_count_limit,$single_status,$fSQL,$only_return);
				echo " - <font size=1><a href=\"$PHP_SELF?ADD=31&campaign_id=$campaign_id&stage=hide_dialable\">"._QXZ("HIDE")."</a></font><BR><BR>";
				}
			else
				{
				echo "<a href=\"$PHP_SELF?ADD=73&campaign_id=$campaign_id\" target=\"_blank\">"._QXZ("Popup Dialable Leads Count")."</a>";
				echo " - <font size=1><a href=\"$PHP_SELF?ADD=31&campaign_id=$campaign_id&stage=show_dialable\">"._QXZ("SHOW")."</a></font><BR><BR>";
				}

			$stmt="SELECT count(*) FROM vicidial_hopper where campaign_id='$campaign_id' $LOGallowed_campaignsSQL and status IN('READY','RHOLD','RQUEUE');";
			if ($DB) {echo "$stmt\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			$rowx=mysqli_fetch_row($rslt);
			$hopper_leads = "$rowx[0]";

			echo _QXZ("This campaign has")." $hopper_leads "._QXZ("leads in the dial hopper")."<br><br>\n";
			echo "<a href=\"./AST_VICIDIAL_hopperlist.php?group=$campaign_id\">"._QXZ("Click here to see what leads are in the hopper right now")."</a><br><br>\n";
			echo "<a href=\"./AST_VDADstats.php?group=$campaign_id\">"._QXZ("Click here to see a VDAD report for this campaign")."</a><BR><BR>\n";
			}
		echo "<a href=\"$PHP_SELF?ADD=81&campaign_id=$campaign_id\">"._QXZ("Click here to see all CallBack Holds in this campaign")."</a><BR><BR>\n";

		if ($SSoutbound_autodial_active > 0)
			{
			if ( ($SStest_campaign_calls > 0) and ($campaign_active == 'Y') )
				{
				##### get list of active asterisk server for dynamic pulldown list menu
				$stmt="SELECT server_id,server_ip from servers where active='Y' and active_asterisk_server='Y' $LOGadmin_viewable_groupsSQL order by server_id;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$servers_to_print = mysqli_num_rows($rslt);
				$servers_menu="<option SELECTED value=\"$SSactive_voicemail_server\">"._QXZ("DEFAULT")." - $SSactive_voicemail_server</option>\n";
				$os=0;
				while ($servers_to_print > $os) 
					{
					$rowx=mysqli_fetch_row($rslt);
					$servers_menu .= "<option value=\"$rowx[1]\">$rowx[0] - $rowx[1]</option>\n";
					$os++;
					}
				echo "<form action=$PHP_SELF method=POST>\n";
				echo "<input type=hidden name=ADD value=41>\n";
				echo "<input type=hidden name=DB value=$DB>\n";
				echo "<input type=hidden name=stage value=test_call>\n";
				echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
				echo "<input type=hidden name=manual_dial_list_id value=\"$manual_dial_list_id\">\n";
				echo "<input type=hidden name=dial_timeout value=\"$dial_timeout\">\n";
				echo "<input type=hidden name=dial_prefix value=\"$dial_prefix\">\n";
				echo "<input type=hidden name=campaign_cid value=\"$campaign_cid\">\n";
				echo "<input type=hidden name=campaign_vdad_exten value=\"$campaign_vdad_exten\">\n";
				echo "<input type=hidden name=omit_phone_code value=\"$omit_phone_code\">\n";
				echo _QXZ("Test Outbound Call").": ";
				echo _QXZ("code").": <input type=text name=phone_code id=phone_code size=2 maxlength=10 value=\"\"> &nbsp; ";
				echo _QXZ("number").": <input type=text name=phone_number id=phone_number size=14 maxlength=20 value=\"\"> &nbsp; ";
				echo _QXZ("server").": <select size=1 name=old_server_ip>$servers_menu</select> &nbsp; ";
				echo "<input style='background-color:#$SSbutton_color' type=submit value=\""._QXZ("PLACE TEST CALL")."\"> &nbsp; $NWB#settings-test_campaign_calls$NWE</form><br><br>\n";
				}
			else
				{
				echo _QXZ("Test calling disabled")."<br><br>\n";
				}
			}

		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=CAMPAIGNS&stage=$campaign_id\">"._QXZ("Click here to see Admin changes to this campaign")."</a>\n";

			echo "<br><br><a href=\"campaign_debug.php?group=$campaign_id\">"._QXZ("Click here to see the debug report for this campaign")."</a></FONT>\n";
			}
		echo "</b></center>\n";
		}


	##### CAMPAIGN CUSTOM STATUSES #####
	if ($SUB==22)
		{
		##### get status category listings for dynamic pulldown
		$stmt="SELECT vsc_id,vsc_name from vicidial_status_categories order by vsc_id desc;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$cats_to_print = mysqli_num_rows($rslt);
		$cats_list="";

		$o=0;
		while ($cats_to_print > $o)
			{
			$rowx=mysqli_fetch_row($rslt);
			$cats_list .= "<option value=\"$rowx[0]\">$rowx[0] - " . substr($rowx[1],0,20) . "</option>\n";
			$catsname_list["$rowx[0]"] = substr($rowx[1],0,20);
			$o++;
			}

		$status_group_overrides_OUTPUT='';
		$status_group_overrides_OUTPUT .= "<B>"._QXZ("ALLOWED IN-GROUPS USING A STATUS GROUP OVERRIDE").":</B><BR>\n";
		$status_group_overrides_OUTPUT .= "<TABLE>\n";

		$stmt="SELECT closer_campaigns from vicidial_campaigns where campaign_id='$campaign_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$cg_to_print = mysqli_num_rows($rslt);
		if ($cg_to_print > 0) 
			{
			$row=mysqli_fetch_row($rslt);
			$closer_campaigns =	$row[0];
			$closer_campaigns = preg_replace("/ -$/","",$closer_campaigns);
			$closer_campaigns = preg_replace("/ /","','",$closer_campaigns);
			}

		$stmt="SELECT group_id,group_name from vicidial_inbound_groups where status_group_id NOT IN('','NONE') and group_id IN('$closer_campaigns') $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$ig_to_print = mysqli_num_rows($rslt);
		$sgo_ig=0;
		while ($ig_to_print > $sgo_ig) 
			{
			$row=mysqli_fetch_row($rslt);
			$status_group_overrides_OUTPUT .= "<TR><TD><a href=\"$PHP_SELF?ADD=3111&group_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$sgo_ig++;
			}
		$status_group_overrides_OUTPUT .= "</TABLE><BR>\n";

		$status_group_overrides_OUTPUT .= "<B>"._QXZ("CAMPAIGN LISTS USING A STATUS GROUP OVERRIDE").":</B><BR>\n";
		$status_group_overrides_OUTPUT .= "<TABLE>\n";

		$stmt="SELECT list_id,list_name from vicidial_lists where status_group_id NOT IN('','NONE') and campaign_id='$campaign_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$list_to_print = mysqli_num_rows($rslt);
		$sgo_li=0;
		while ($list_to_print > $sgo_li) 
			{
			$row=mysqli_fetch_row($rslt);
			$status_group_overrides_OUTPUT .= "<TR><TD><a href=\"$PHP_SELF?ADD=311&list_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$sgo_li++;
			}
		$status_group_overrides_OUTPUT .= "</TABLE><BR>\n";
		$sgo_total = ($sgo_ig + $sgo_li);
		$sgo_message='';
		if ($sgo_total > 0)
			{$sgo_message = "<font color=red><b>$sgo_total "._QXZ("STATUS GROUP OVERRIDES USED, see list at bottom")."</b></font>";}

		echo "<center>\n";
		echo "<br><b>"._QXZ("CUSTOM STATUSES WITHIN THIS CAMPAIGN").": &nbsp; $NWB#campaign_statuses$NWE</b> &nbsp; $sgo_message<br>\n";

		echo "<TABLE width=700 cellspacing=3>\n";
		echo "<tr height='250'><td align=center valign=bottom><font size=2><b>"._QXZ("STATUS")."</b></font></td>\n";
		echo "<td align=center valign=bottom><font size=2><b>"._QXZ("DESCRIPTION")."</td>\n";
		echo "<td align=center valign=bottom><font size=2><b>"._QXZ("CATEGORY")."</td>\n";
		echo "<td align=center valign=top bgcolor=\"#ccffff\"><font size=2 class='vertical-text'><b>"._QXZ("AGENT SELECTABLE")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#99ffcc\"><font size=2 class='vertical-text'><b>"._QXZ("HUMAN ANSWER")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#ccffff\"><font size=2 class='vertical-text'><b>"._QXZ("SALE")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#99ffcc\"><font size=2 class='vertical-text'><b>"._QXZ("DNC")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#ccffff\"><font size=2 class='vertical-text'><b>"._QXZ("CUSTOMER CONTACT")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#99ffcc\"><font size=2 class='vertical-text'><b>"._QXZ("NOT INTERESTED")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#ccffff\"><font size=2 class='vertical-text'><b>"._QXZ("UNWORKABLE")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#99ffcc\"><font size=2 class='vertical-text'><b>"._QXZ("SCHEDULED CALLBACK")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#ccffff\"><font size=2 class='vertical-text'><b>"._QXZ("COMPLETED")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#99ffcc\"><font size=2 class='vertical-text'><b>"._QXZ("ANSWERING MACHINE")."</B></font></td>\n";
		echo "<td align=center valign=bottom><font size=1><b>"._QXZ("MIN SEC")."</td>\n";
		echo "<td align=center valign=bottom><font size=1><b>"._QXZ("MAX SEC")."</td>\n";
		echo "<td align=center valign=bottom><font size=2><b>"._QXZ("MODIFY/DELETE")."</td>\n";
		echo "</tr>\n";

		##### get status category listings for dynamic pulldown
		$stmt="SELECT vsc_id,vsc_name from vicidial_status_categories order by vsc_id desc;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$cats_to_print = mysqli_num_rows($rslt);
		$cats_list="";

		$o=0;
		while ($cats_to_print > $o)
			{
			$rowx=mysqli_fetch_row($rslt);
			$cats_list .= "<option value=\"$rowx[0]\">$rowx[0] - " . substr($rowx[1],0,20) . "</option>\n";
			$catsname_list["$rowx[0]"] = substr($rowx[1],0,20);
			$o++;
			}

		$stmt="SELECT status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable,scheduled_callback,completed,min_sec,max_sec,answering_machine from vicidial_campaign_statuses where campaign_id='$campaign_id' $LOGallowed_campaignsSQL order by status;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$statuses_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($statuses_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$AScategory = $rowx[4];
			$o++;

			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

			echo "<tr $bgcolor><td><form action=$PHP_SELF method=POST>\n";
			echo "<input type=hidden name=ADD value=42>\n";
			echo "<input type=hidden name=stage value=modify>\n";
			echo "<input type=hidden name=status value=\"$rowx[0]\">\n";
			echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
			echo "<font size=2><B>$rowx[0]</B></td>\n";
			echo "<td><input type=text name=status_name size=20 maxlength=30 value=\"$rowx[1]\"></td>\n";
			echo "<td>\n";
			echo "<select size=1 name=category class=\"cust_form\">\n";
			echo "$cats_list";
			echo "<option selected value=\"$AScategory\">$AScategory - $catsname_list[$AScategory]</option>\n";
			echo "</select>\n";
			echo "\n";
			echo "</td><td bgcolor=\"#ccffff\"><select size=1 name=selectable class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='"._QXZ("$rowx[2]")."' selected>"._QXZ("$rowx[2]")."</option></select>\n";
			echo "</td><td bgcolor=\"#99ffcc\"><select size=1 name=human_answered class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='"._QXZ("$rowx[3]")."' selected>"._QXZ("$rowx[3]")."</option></select>\n";
			echo "</td><td bgcolor=\"#ccffff\"><select size=1 name=sale class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='"._QXZ("$rowx[5]")."' selected>"._QXZ("$rowx[5]")."</option></select>\n";
			echo "</td><td bgcolor=\"#99ffcc\"><select size=1 name=dnc class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='"._QXZ("$rowx[6]")."' selected>"._QXZ("$rowx[6]")."</option></select>\n";
			echo "</td><td bgcolor=\"#ccffff\"><select size=1 name=customer_contact class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='"._QXZ("$rowx[7]")."' selected>"._QXZ("$rowx[7]")."</option></select>\n";
			echo "</td><td bgcolor=\"#99ffcc\"><select size=1 name=not_interested class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='"._QXZ("$rowx[8]")."' selected>"._QXZ("$rowx[8]")."</option></select>\n";
			echo "</td><td bgcolor=\"#ccffff\"><select size=1 name=unworkable class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='"._QXZ("$rowx[9]")."' selected>"._QXZ("$rowx[9]")."</option></select>\n";
			echo "</td><td bgcolor=\"#99ffcc\"><select size=1 name=scheduled_callbacks class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='"._QXZ("$rowx[10]")."' selected>"._QXZ("$rowx[10]")."</option></select>\n";
			echo "</td><td bgcolor=\"#ccffff\"><select size=1 name=completed class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='"._QXZ("$rowx[11]")."' selected>"._QXZ("$rowx[11]")."</option></select>\n";
			echo "</td><td bgcolor=\"#99ffcc\"><select size=1 name=answering_machine class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='"._QXZ("$rowx[14]")."' selected>"._QXZ("$rowx[14]")."</option></select>\n";
			echo "</td>\n";
			echo "<td><input type=text name=min_sec size=3 maxlength=5 value=\"$rowx[12]\" class=\"cust_form\"></td>\n";
			echo "<td><input type=text name=max_sec size=3 maxlength=5 value=\"$rowx[13]\" class=\"cust_form\"></td>\n";
			echo "</td><td align=center nowrap><font size=1><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("MODIFY")."'> &nbsp; &nbsp; &nbsp; &nbsp; \n";
			echo " &nbsp; \n";
			
			if (preg_match("/^B$|^NA$|^DNC$|^NA$|^DROP$|^INCALL$|^QUEUE$|^NEW$/i",$rowx[0]))
				{
				echo "<DEL>"._QXZ("DELETE")."</DEL>\n";
				}
			else
				{
				echo "<a href=\"$PHP_SELF?ADD=42&campaign_id=$campaign_id&status=$rowx[0]&stage=delete\">"._QXZ("DELETE")."</a>\n";
				}
			echo "</form></td></tr>\n";
			}

		echo "</table>\n";


		echo "<br>"._QXZ("ADD NEW CUSTOM CAMPAIGN STATUS")."<BR><form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=22>\n";
		echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
		echo _QXZ("Status").": <input type=text name=status_id size=8 maxlength=6> &nbsp; \n";
		echo _QXZ("Description").": <input type=text name=status_name size=20 maxlength=30> &nbsp; \n";
		echo _QXZ("Selectable").": <select size=1 name=selectable><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Human Answer").": <select size=1 name=human_answered><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; <BR>\n";
		echo _QXZ("Sale").": <select size=1 name=sale><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("DNC").": <select size=1 name=dnc><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Customer Contact").": <select size=1 name=customer_contact><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Not Interested").": <select size=1 name=not_interested><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp;  <BR>\n";
		echo _QXZ("Unworkable").": <select size=1 name=unworkable><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Callback").": <select size=1 name=scheduled_callbacks><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Completed").": <select size=1 name=completed><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Answering Machine").": <select size=1 name=answering_machine><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Category").": \n";
		echo "<select size=1 name=category>\n";
		echo "$cats_list";
		echo "<option selected value=\"$AScategory\">$AScategory - $catsname_list[$AScategory]</option>\n";
		echo "</select> &nbsp; <BR>\n";
		echo "<input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("ADD")."'><BR>\n";

		echo "</FORM><br><br></center></center>\n";

		echo "$status_group_overrides_OUTPUT";
		}

	##### CAMPAIGN HOTKEYS #####
	if ($SUB==23)
		{
		echo "<br><b>"._QXZ("CUSTOM HOT KEYS WITHIN THIS CAMPAIGN").": &nbsp; $NWB#campaign_hotkeys$NWE</b><br>\n";
		echo "<TABLE width=400 cellspacing=3>\n";
		echo "<tr><td>"._QXZ("HOT KEY")."</td><td>"._QXZ("STATUS")."</td><td>"._QXZ("DESCRIPTION")."</td><td>"._QXZ("DELETE")."</td></tr>\n";

		$stmt="SELECT status,hotkey,status_name,selectable,campaign_id from vicidial_campaign_hotkeys where campaign_id='$campaign_id' $LOGallowed_campaignsSQL order by hotkey;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$statuses_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($statuses_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$o++;

			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

			echo "<tr $bgcolor><td><font size=1>$rowx[1]</td><td><font size=1>$rowx[0]</td><td><font size=1>$rowx[2]</td><td><font size=1><a href=\"$PHP_SELF?ADD=43&campaign_id=$campaign_id&status=$rowx[0]&hotkey=$rowx[1]&action=DELETE\">"._QXZ("DELETE")."</a></td></tr>\n";

			}

		echo "</table>\n";

		echo "<br>"._QXZ("ADD NEW CUSTOM CAMPAIGN HOT KEY")."<BR><form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=23>\n";
		echo "<input type=hidden name=selectable value=Y>\n";
		echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
		echo _QXZ("Hotkey").": <select size=1 name=hotkey>\n";
		echo "<option>1</option>\n";
		echo "<option>2</option>\n";
		echo "<option>3</option>\n";
		echo "<option>4</option>\n";
		echo "<option>5</option>\n";
		echo "<option>6</option>\n";
		echo "<option>7</option>\n";
		echo "<option>8</option>\n";
		echo "<option>9</option>\n";
		echo "</select> &nbsp; \n";
		echo _QXZ("Status").": <select size=1 name=HKstatus>\n";
		echo "$HKstatuses_list\n";
		echo "<option value=\"ALTPH2-----"._QXZ("Alternate Phone Hot Dial")."\">ALTPH2 - "._QXZ("Alternate Phone Hot Dial")."</option>\n";
		echo "<option value=\"ADDR3-----"._QXZ("Address3 Hot Dial")."\">ADDR3 - "._QXZ("Address3 Hot Dial")."</option>\n";
		echo "<option value=\"LTMG-----"._QXZ("Send to Answering Machine Msg")."\">LTMG - "._QXZ("Send to Answering Machine Msg")."</option>\n";
		echo "<option value=\"XFTAMM-----"._QXZ("Send to Answering Machine Msg")."\">XFTAMM - "._QXZ("Send to Answering Machine Msg")."</option>\n";
		echo "<option value=\"LTMGAD-----"._QXZ("Send to AM Message and Dispo")."\">LTMGAD - "._QXZ("Send to AM Message and Dispo")."</option>\n";
		echo "<option value=\"XAMMAD-----"._QXZ("Send to AM Message and Dispo")."\">XAMMAD - "._QXZ("Send to AM Message and Dispo")."</option>\n";
		echo "</select> &nbsp; \n";
		echo "<input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("ADD")."'><BR>\n";
		echo "</form><BR>\n";
		}

	##### CAMPAIGN LEAD RECYCLING #####
	if ($SUB==25)
		{
		### display counts on leads that have hit the limit in this campaign
		$stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$lists_to_print = mysqli_num_rows($rslt);
		$camp_lists='';
		$o=0;
		while ($lists_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			if (preg_match('/Y/', $rowx[1])) {$camp_lists .= "'$rowx[0]',";}
			$o++;
			}
		$camp_lists = preg_replace('/.$/i','',$camp_lists);

		$stmt="SELECT recycle_id,campaign_id,status,attempt_delay,attempt_maximum,active from vicidial_lead_recycle where campaign_id='$campaign_id' $LOGallowed_campaignsSQL order by status;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$recycle_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($recycle_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$RECYCLE_status[$o] =	$rowx[2];
			$RECYCLE_delay[$o] =	$rowx[3];
			$RECYCLE_attempt[$o] =	$rowx[4];
			$RECYCLE_active[$o] =	$rowx[5];
			$RECYCLE_count[$o] = "'Y','Y1','Y2','Y3','Y4','Y5','Y6','Y7','Y8','Y9','Y10'";
			if ($RECYCLE_attempt[$o]==1) {$RECYCLE_count[$o] = "'Y1','Y2','Y3','Y4','Y5','Y6','Y7','Y8','Y9','Y10'";}
			if ($RECYCLE_attempt[$o]==2) {$RECYCLE_count[$o] = "'Y2','Y3','Y4','Y5','Y6','Y7','Y8','Y9','Y10'";}
			if ($RECYCLE_attempt[$o]==3) {$RECYCLE_count[$o] = "'Y3','Y4','Y5','Y6','Y7','Y8','Y9','Y10'";}
			if ($RECYCLE_attempt[$o]==4) {$RECYCLE_count[$o] = "'Y4','Y5','Y6','Y7','Y8','Y9','Y10'";}
			if ($RECYCLE_attempt[$o]==5) {$RECYCLE_count[$o] = "'Y5','Y6','Y7','Y8','Y9','Y10'";}
			if ($RECYCLE_attempt[$o]==6) {$RECYCLE_count[$o] = "'Y6','Y7','Y8','Y9','Y10'";}
			if ($RECYCLE_attempt[$o]==7) {$RECYCLE_count[$o] = "'Y7','Y8','Y9','Y10'";}
			if ($RECYCLE_attempt[$o]==8) {$RECYCLE_count[$o] = "'Y8','Y9','Y10'";}
			if ($RECYCLE_attempt[$o]==9) {$RECYCLE_count[$o] = "'Y9','Y10'";}
			if ($RECYCLE_attempt[$o]>9) {$RECYCLE_count[$o] = "'Y10'";}
			$o++;
			}
		$o=0;

		echo "<br><br><b>"._QXZ("LEAD RECYCLING WITHIN THIS CAMPAIGN").": &nbsp; $NWB#lead_recycle$NWE</b><br>\n";
		echo "<TABLE width=700 cellspacing=3>\n";
		echo "<tr><td>"._QXZ("STATUS")."</td><td>"._QXZ("ATTEMPT DELAY")."</td><td>"._QXZ("ATTEMPT MAXIMUM")."</td><td>"._QXZ("LEADS AT LIMIT")."</td><td>"._QXZ("ACTIVE")."</td><td> </td><td>"._QXZ("DELETE")."</td></tr>\n";

		while ($recycle_to_print > $o) 
			{
			$recycle_limit=0;
			if (strlen($camp_lists) > 2)
				{
				$stmt="SELECT count(*) from vicidial_list where status='$RECYCLE_status[$o]' and list_id IN($camp_lists) and called_since_last_reset IN($RECYCLE_count[$o]);";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				$counts_to_print = mysqli_num_rows($rslt);
				if ($counts_to_print > 0) 
					{
					$rowx=mysqli_fetch_row($rslt);
					$recycle_limit = $rowx[0];
					}
				}

			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

			echo "<tr $bgcolor><td><font size=2> &nbsp; $RECYCLE_status[$o]<form action=$PHP_SELF method=POST>\n";
			echo "<input type=hidden name=status value=\"$RECYCLE_status[$o]\">\n";
			echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
			echo "<input type=hidden name=ADD value=45></td>\n";
			echo "<td><font size=1><input type=text size=7 maxlength=5 name=attempt_delay value=\"$RECYCLE_delay[$o]\"></td>\n";
			echo "<td><font size=1><input type=text size=5 maxlength=3 name=attempt_maximum value=\"$RECYCLE_attempt[$o]\"></td>\n";
			echo "<td align=right><font size=2>$recycle_limit &nbsp; </td>\n";
			echo "<td><select size=1 name=active><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$RECYCLE_active[$o]' SELECTED>"._QXZ("$RECYCLE_active[$o]")."</option></select></td>\n";
			echo "<td><font size=1><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("MODIFY")."'></form></td>\n";
			echo "<td><font size=1><a href=\"$PHP_SELF?ADD=65&campaign_id=$campaign_id&status=$RECYCLE_status[$o]\">"._QXZ("DELETE")."</a></td></tr>\n";
			$o++;
			}

		echo "</table>\n";

		echo "<br>"._QXZ("ADD NEW CAMPAIGN LEAD RECYCLE")."<BR><form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=25>\n";
		echo "<input type=hidden name=active value=\"N\">\n";
		echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
		echo _QXZ("Status").": <select size=1 name=status>\n";
		echo "$LRstatuses_list\n";
		echo "</select> &nbsp; \n";
		echo _QXZ("Attempt Delay").": <input type=text size=7 maxlength=5 name=attempt_delay>\n";
		echo _QXZ("Attempt Maximum").": <input type=text size=5 maxlength=3 name=attempt_maximum>\n";
		echo "<input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("ADD")."'><BR>\n";

		echo "</FORM><br>\n";
		echo "<br>\n";
		echo "* "._QXZ("Lead counts taken from active lists in the campaign only").".\n";
		}

	##### CAMPAIGN AUTO-ALT-NUMBER DIALING #####
	if ($SUB==26)
		{
		echo "<br><br><b>"._QXZ("AUTO ALT NUMBER DIALING FOR THIS CAMPAIGN").": &nbsp; $NWB#auto_alt_dial_statuses$NWE</b><br>\n";
		echo "<TABLE width=500 cellspacing=3>\n";
		echo "<tr><td>"._QXZ("STATUSES")."</td><td>"._QXZ("DELETE")."</td></tr>\n";

		$auto_alt_dial_statuses = preg_replace("/ -$/","",$auto_alt_dial_statuses);
		$AADstatuses = explode(" ", $auto_alt_dial_statuses);
		$AADs_to_print = (count($AADstatuses) -1);

		$o=0;
		while ($AADs_to_print > $o) 
			{
			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}
			$o++;

			echo "<tr $bgcolor><td><font size=1>$AADstatuses[$o]</td>\n";
			echo "<td><font size=1><a href=\"$PHP_SELF?ADD=66&campaign_id=$campaign_id&status=$AADstatuses[$o]\">"._QXZ("DELETE")."</a></td></tr>\n";
			}

		echo "</table>\n";

		echo "<br>"._QXZ("ADD NEW AUTO ALT NUMBER DIALING STATUS")."<BR><form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=26>\n";
		echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
		echo _QXZ("Status").": <select size=1 name=status>\n";
		echo "$LRstatuses_list\n";
		echo "</select> &nbsp; \n";
		echo "<input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("ADD")."'><BR>\n";

		echo "</FORM><br>\n";
		}

	##### CAMPAIGN PAUSE CODES #####
	if ($SUB==27)
		{
		echo "<br><br><b>"._QXZ("AGENT PAUSE CODES FOR THIS CAMPAIGN").": &nbsp; $NWB#pause_codes$NWE</b><br>\n";
		echo "<TABLE width=700 cellspacing=3>\n";
		echo "<tr><td>"._QXZ("PAUSE CODES")."</td><td>"._QXZ("BILLABLE")."</td>";
		if ($SSenable_pause_code_limits > 0)
			{
			echo "<td>"._QXZ("TIME LIMIT")."</td>";
			}
		echo "<td>"._QXZ("MGR APPROVAL")."</td><td>"._QXZ("MODIFY")."</td><td>"._QXZ("DELETE")."</td></tr>\n";

		$stmt="SELECT pause_code,pause_code_name,billable,campaign_id,time_limit,require_mgr_approval from vicidial_pause_codes where campaign_id='$campaign_id' $LOGallowed_campaignsSQL order by pause_code;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$pause_codes_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($pause_codes_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$o++;

			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';}
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

			echo "<tr $bgcolor><td><form action=$PHP_SELF method=POST><font size=1>$rowx[0]\n";
			echo "<input type=hidden name=ADD value=47>\n";
			echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
			echo "<input type=hidden name=pause_code value=\"$rowx[0]\"> &nbsp;\n";
			if ($SSenable_pause_code_limits < 1)
				{echo "<input type=hidden name=time_limit value=\"$rowx[4]\">\n";}
			echo "<input type=text size=20 maxlength=30 name=pause_code_name value=\"$rowx[1]\"></td>\n";
			echo "<td><select size=1 name=billable><option value='YES'>"._QXZ("YES")."</option><option value='NO'>"._QXZ("NO")."</option><option value='HALF'>"._QXZ("HALF")."</option><option value='$rowx[2]' SELECTED>"._QXZ("$rowx[2]")."</option></select></td>\n";
			if ($SSenable_pause_code_limits > 0)
				{
				echo "<td><input type=text size=5 maxlength=5 name=time_limit value=\"$rowx[4]\"></td>\n";
				}
			echo "<td><select size=1 name=require_mgr_approval><option value='YES'>"._QXZ("YES")."</option><option value='NO'>"._QXZ("NO")."</option><option value='$rowx[5]' SELECTED>"._QXZ("$rowx[5]")."</option></select></td>\n";
			echo "<td><font size=1><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("MODIFY")."'></form></td>\n";
			echo "<td><font size=1><a href=\"$PHP_SELF?ADD=67&campaign_id=$campaign_id&pause_code=$rowx[0]\">"._QXZ("DELETE")."</a></td>\n";
			echo "</tr>\n";
			}

		echo "</table>\n";

		echo "<br>"._QXZ("ADD NEW AGENT PAUSE CODE")."<BR><form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=27>\n";
		echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
		echo _QXZ("Pause Code").": <input type=text size=8 maxlength=6 name=pause_code>\n";
		echo " &nbsp; "._QXZ("Name").": <input type=text size=20 maxlength=30 name=pause_code_name>\n";
		echo " &nbsp; "._QXZ("Billable").": <select size=1 name=billable><option value='YES'>"._QXZ("YES")."</option><option value='NO'>"._QXZ("NO")."</option><option value='HALF'>"._QXZ("HALF")."</option></select><BR>\n";
		echo " &nbsp; "._QXZ("Mgr Approve").": <select size=1 name=require_mgr_approval><option value='YES'>"._QXZ("YES")."</option><option SELECTED value='NO'>"._QXZ("NO")."</option></select>\n";
		if ($SSenable_pause_code_limits > 0)
			{
			echo " &nbsp; "._QXZ("Time Limit").": <input type=text size=5 maxlength=5 name=time_limit>\n";
			}
		echo "<BR><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("ADD")."'><BR>\n";

		echo "</center></FORM><br>\n";
		}

	##### CAMPAIGN QC SETTINGS #####
	if ( ($SUB==28) and ($SSqc_features_active > 0) )
		{
		$stmt="SELECT list_id,list_name,active from vicidial_lists where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$lists_to_print = mysqli_num_rows($rslt);
		$qc_lists_list='';

		$p=0;
		while ($lists_to_print > $p) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$qc_lists_list .= "<input type=\"checkbox\" name=\"qc_lists[]\" value=\"$rowx[0]\"";
			$r=0;
			while ($r < $QCL_to_print)
				{
				if ($rowx[0] == $QClists[$r]) 
					{
					$qc_lists_list .= " CHECKED";
					}
				$r++;
				}
			$qc_lists_list .= "> $rowx[0] - $rowx[1] - $rowx[2]<BR>\n";

			$p++;
			}

		##### get QC status container listings for pulldown
		$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='QC_TEMPLATE' order by container_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$containers_to_print = mysqli_num_rows($rslt);
		$QCcontainers_list="<option value=\"\">NONE</option>";
		$o=0;
		while ($containers_to_print > $o)
			{
			$rowx=mysqli_fetch_row($rslt);
			$QCcontainers_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$qc_containers_list["$rowx[0]"] = "$rowx[1]";
			$o++;
			}
		##### get scorecards listings for pulldown
		$stmt="SELECT qc_scorecard_id,scorecard_name from quality_control_scorecards where active='Y' order by qc_scorecard_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$scorecards_to_print = mysqli_num_rows($rslt);
		$QCscorecards_list="<option value=\"\">NONE</option>";
		$o=0;
		while ($scorecards_to_print > $o)
			{
			$rowx=mysqli_fetch_row($rslt);
			$QCscorecards_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$scorecardname_list["$rowx[0]"] = "$rowx[1]";
			$o++;
			}
		##### get scripts listings for pulldown
		$stmt="SELECT script_id,script_name from vicidial_scripts $whereLOGadmin_viewable_groupsSQL order by script_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$scripts_to_print = mysqli_num_rows($rslt);
		$QCscripts_list="";
		$o=0;
		while ($scripts_to_print > $o)
			{
			$rowx=mysqli_fetch_row($rslt);
			$QCscripts_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$scriptname_list["$rowx[0]"] = "$rowx[1]";
			$o++;
			}
		##### get shifts listings for pulldown
		$stmt="SELECT shift_id,shift_name from vicidial_shifts $whereLOGadmin_viewable_groupsSQL order by shift_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$shifts_to_print = mysqli_num_rows($rslt);
		$QCshifts_list="";
		$o=0;
		while ($shifts_to_print > $o)
			{
			$rowx=mysqli_fetch_row($rslt);
			$QCshifts_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$shiftname_list["$rowx[0]"] = "$rowx[1]";
			$o++;
			}

		echo "<br><br><b>"._QXZ("QC SETTINGS FOR THIS CAMPAIGN").":</b><br>\n";
		echo "<form action=$PHP_SELF method=POST><center><TABLE width=800 cellspacing=3>\n";
#		echo "<tr bgcolor=#$SSstd_row2_background>\n";
#		echo "<td align=right>"._QXZ("QC Enabled").": </td><td><select size=1 name=qc_enabled><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$qc_enabled' SELECTED>"._QXZ("$qc_enabled")."</option></select> $NWB#campaigns-qc_enabled$NWE</td></tr>\n";
#		echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("QC Statuses").": <BR> $NWB#campaigns-qc_statuses$NWE</td><td>$qc_statuses_list</td></tr>\n";
#		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>QC Lists: <BR> $NWB#campaigns-qc_lists$NWE</td><td>$qc_lists_list</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right><input type=hidden name=ADD value=48>\n";
		echo "<input type=hidden name=campaign_id value=\"$campaign_id\">"._QXZ("QC Statuses").": </td><td align=left><select size=1 name=qc_statuses_id>";
		echo "<option selected value=\"$qc_statuses_id\">".(!$qc_statuses_id ? "NONE" : "$qc_statuses_id - $qc_containers_list[$qc_statuses_id]")."</option>\n";
		echo "$QCcontainers_list";
		echo "</select>$NWB#campaigns-qc_statuses_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("QC Scorecard").": </td><td align=left><select size=1 name=qc_scorecard_id>";
		echo "<option selected value=\"$qc_scorecard_id\">".(!$qc_scorecard_id ? "NONE" : "$qc_scorecard_id - $scorecardname_list[$qc_scorecard_id]")."</option>\n";
		echo "$QCscorecards_list";
		echo "</select>$NWB#campaigns-qc_scorecard$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("QC WebForm").": </td><td align=left><input type=text name=qc_web_form_address size=70 maxlength=255 value=\"$qc_web_form_address\">$NWB#campaigns-qc_web_form_address$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row2_background><td align=right><a href=\"$PHP_SELF?ADD=3111111&script_id=$script_id\">"._QXZ("QC Script")."</a>: </td><td align=left><select size=1 name=qc_script>\n";
		echo "$QCscripts_list";
		echo "<option selected value=\"$qc_script\">$qc_script - $scriptname_list[$qc_script]</option>\n";
		echo "</select>$NWB#campaigns-qc_script$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row2_background><td align=right><a href=\"$PHP_SELF?ADD=331111111&shift_id=$qc_shift_id\">"._QXZ("QC Shift")."</a>: </td><td align=left><select size=1 name=qc_shift_id>\n";
		echo "$QCshifts_list";
		echo "<option selected value=\"$qc_shift_id\">$qc_shift_id - $shiftname_list[$qc_shift_id]</option>\n";
		echo "</select>$NWB#campaigns-qc_shift_id$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("QC Get Record Launch").": </td><td><select size=1 name=qc_get_record_launch><option value='NONE'>"._QXZ("NONE")."</option><option value='SCRIPT'>"._QXZ("SCRIPT")."</option><option value='WEBFORM'>"._QXZ("WEBFORM")."</option><option value='QCSCRIPT'>"._QXZ("QCSCRIPT")."</option><option value='QCWEBFORM'>"._QXZ("QCWEBFORM")."</option><option value='$qc_get_record_launch' SELECTED>"._QXZ("$qc_get_record_launch")."</option></select> $NWB#campaigns-qc_get_record_launch$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("QC Show Recording").": </td><td><select size=1 name=qc_show_recording><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$qc_show_recording' SELECTED>"._QXZ("$qc_show_recording")."</option></select> $NWB#campaigns-qc_show_recording$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row2_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</table>\n";
		echo "<BR></center></FORM><br>\n";
		}

	##### CAMPAIGN SURVEY SETTINGS #####
	if ($SUB=='20A')
		{

		echo "<center><br><b>"._QXZ("SURVEY SETTINGS FOR THIS CAMPAIGN").":</b><br>\n";
		echo "<form action=$PHP_SELF method=POST name=admin_form id=admin_form><center><TABLE width=850 cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right><input type=hidden name=ADD value=40A>\n";
		echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";

		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Survey First Audio File").": </td><td nowrap><input type=text size=70 maxlength=1000 name=survey_first_audio_file id=survey_first_audio_file value=\"$survey_first_audio_file\"> <a href=\"javascript:launch_chooser('survey_first_audio_file','date');\">"._QXZ("audio chooser")."</a>  $NWB#campaigns-survey_first_audio_file$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Survey DTMF Digits").": </td><td><input type=text size=16 maxlength=16 name=survey_dtmf_digits value=\"$survey_dtmf_digits\"> $NWB#campaigns-survey_dtmf_digits$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Survey Not Interested Digit").": </td><td><input type=text size=5 maxlength=1 name=survey_ni_digit value=\"$survey_ni_digit\"> $NWB#campaigns-survey_ni_digit$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Survey Wait Seconds").": </td><td><input type=text size=5 maxlength=2 name=survey_wait_sec value=\"$survey_wait_sec\"> $NWB#campaigns-survey_wait_sec$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Survey Opt-in Audio File").": </td><td nowrap><input type=text size=70 maxlength=1000 name=survey_opt_in_audio_file id=survey_opt_in_audio_file value=\"$survey_opt_in_audio_file\"> <a href=\"javascript:launch_chooser('survey_opt_in_audio_file','date');\">"._QXZ("audio chooser")."</a> $NWB#campaigns-survey_opt_in_audio_file$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Survey Not Interested Audio File").": </td><td nowrap><input type=text size=70 maxlength=1000 name=survey_ni_audio_file id=survey_ni_audio_file value=\"$survey_ni_audio_file\"> <a href=\"javascript:launch_chooser('survey_ni_audio_file','date');\">"._QXZ("audio chooser")."</a> $NWB#campaigns-survey_ni_audio_file$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Survey Method").": </td><td><select size=1 name=survey_method><option value='AGENT_XFER'>"._QXZ("AGENT_XFER")."</option><option value='VOICEMAIL'>"._QXZ("VOICEMAIL")."</option><option value='VMAIL_NO_INST'>"._QXZ("VMAIL_NO_INST")."</option><option value='EXTENSION'>"._QXZ("EXTENSION")."</option><option value='HANGUP'>"._QXZ("HANGUP")."</option><option value='CAMPREC_60_WAV'>"._QXZ("CAMPREC_60_WAV")."</option><option value='CALLMENU'>"._QXZ("CALLMENU")."</option><option value='$survey_method' SELECTED>"._QXZ("$survey_method")."</option></select> $NWB#campaigns-survey_method$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Survey No-Response Action").": </td><td><select size=1 name=survey_no_response_action><option value='OPTIN'>"._QXZ("OPTIN")."</option><option value='OPTOUT'>"._QXZ("OPTOUT")."</option><option value='DROP'>"._QXZ("DROP")."</option><option value='$survey_no_response_action' SELECTED>"._QXZ("$survey_no_response_action")."</option></select> $NWB#campaigns-survey_no_response_action$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Survey Not Interested Status").": </td><td><select name=survey_ni_status>$survey_ni_status_list</select> $NWB#campaigns-survey_ni_status$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Survey Third Digit").": </td><td><input type=text size=5 maxlength=1 name=survey_third_digit id=survey_third_digit value=\"$survey_third_digit\"> $NWB#campaigns-survey_third_digit$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Survey Third Audio File").": </td><td nowrap><input type=text size=70 maxlength=1000 name=survey_third_audio_file id=survey_third_audio_file value=\"$survey_third_audio_file\"> <a href=\"javascript:launch_chooser('survey_third_audio_file','date');\">"._QXZ("audio chooser")."</a> $NWB#campaigns-survey_third_audio_file$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Survey Third Status").": </td><td><input type=text size=10 maxlength=6 name=survey_third_status value=\"$survey_third_status\"> $NWB#campaigns-survey_third_status$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Survey Third Extension").": </td><td><input type=text size=20 maxlength=20 name=survey_third_exten value=\"$survey_third_exten\"> $NWB#campaigns-survey_third_exten$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Survey Fourth Digit").": </td><td><input type=text size=5 maxlength=1 name=survey_fourth_digit value=\"$survey_fourth_digit\"> $NWB#campaigns-survey_fourth_digit$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Survey Fourth Audio File").": </td><td nowrap><input type=text size=70 maxlength=1000 name=survey_fourth_audio_file id=survey_fourth_audio_file value=\"$survey_fourth_audio_file\"> <a href=\"javascript:launch_chooser('survey_fourth_audio_file','date');\">"._QXZ("audio chooser")."</a> $NWB#campaigns-survey_fourth_audio_file$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Survey Fourth Status").": </td><td><input type=text size=10 maxlength=6 name=survey_fourth_status value=\"$survey_fourth_status\"> $NWB#campaigns-survey_fourth_status$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Survey Fourth Extension").": </td><td><input type=text size=20 maxlength=20 name=survey_fourth_exten value=\"$survey_fourth_exten\"> $NWB#campaigns-survey_fourth_exten$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Survey Response Digit Map").": </td><td><input type=text size=70 maxlength=100 name=survey_response_digit_map value=\"$survey_response_digit_map\"> $NWB#campaigns-survey_response_digit_map$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Survey Survey Xfer Extension").": </td><td><input type=text size=12 maxlength=20 name=survey_xfer_exten value=\"$survey_xfer_exten\"> $NWB#campaigns-survey_xfer_exten$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Survey Campaign Recording Directory").": </td><td><input type=text size=70 maxlength=255 name=survey_camp_record_dir value=\"$survey_camp_record_dir\"> $NWB#campaigns-survey_camp_record_dir$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Voicemail").": </td><td><input type=text size=12 maxlength=10 name=voicemail_ext id=voicemail_ext value=\"$voicemail_ext\"> <a href=\"javascript:launch_vm_chooser('voicemail_ext','vm');\">"._QXZ("voicemail chooser")."</a> $NWB#campaigns-voicemail_ext$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row2_background><td align=right><a href=\"$PHP_SELF?ADD=3511&menu_id=$survey_menu_id\">"._QXZ("Survey Call Menu")."</a>: </td><td align=left><select size=1 name=survey_menu_id id=survey_menu_id>$call_menu_list<option SELECTED>$survey_menu_id</option></select>$NWB#campaigns-survey_menu_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Survey Recording").": </td><td align=left><select size=1 name=survey_recording id=survey_recording><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='Y_WITH_AMD'>"._QXZ("Y_WITH_AMD")."</option><option value='$survey_recording' SELECTED>"._QXZ("$survey_recording")."</option></select>$NWB#campaigns-survey_recording$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row2_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</table>\n";
		echo "<BR></center></FORM><br>\n";
		}


	##### CAMPAIGN PRESETS #####
	if ($SUB==201)
		{
		$preset_status=_QXZ("set to ").'<font color=purple><b>INACTIVE</b></font>';
		$stmt="SELECT enable_xfer_presets,campaign_name from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL limit 1;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campaigns_to_print = mysqli_num_rows($rslt);
		if ($DB > 0) {echo "DEBUG: |$campaigns_to_print|$stmt|\n";}
		if ($campaigns_to_print > 0) 
			{
			$row=mysqli_fetch_row($rslt);
			$enable_xfer_presets =		$row[0];
			$campaign_name =			$row[1];
			if ($enable_xfer_presets == 'ENABLED') {$preset_status=_QXZ("set to ").'<font color=darkgreen><b>ENABLED</b></font>';}
			if ($enable_xfer_presets == 'STAGING') {$preset_status=_QXZ("set to ").'<font color=red><b>STAGING</b></font>';}
			if ($enable_xfer_presets == 'CONTACTS') {$preset_status=_QXZ("set to ").'<font color=red><b>CONTACTS</b></font>';}
			}
		else
			{
			echo "<br>"._QXZ("CAMPAIGN DOES NOT EXIST")." - $campaign_id<BR>\n";
			exit;
			}

		$stmt="SELECT preset_name,preset_number,preset_dtmf,preset_hide_number from vicidial_xfer_presets where campaign_id='$campaign_id' $LOGallowed_campaignsSQL order by preset_name;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$presets_to_print = mysqli_num_rows($rslt);

		echo "<br><br><b>$presets_to_print "._QXZ("PRESETS FOR THIS CAMPAIGN")." ($campaign_id - $campaign_name): $preset_status &nbsp; $NWB#xfer_presets$NWE</b><br>\n";

		echo "<br>"._QXZ("ADD NEW PRESET")." -<BR><form action=$PHP_SELF method=POST><font size=2>\n";
		echo "<input type=hidden name=ADD value=201>\n";
		echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
		echo _QXZ("Preset Name").": <input type=text size=20 maxlength=40 name=preset_name style=\"font-family: sans-serif; font-size: 10px;\">\n";
		echo " "._QXZ("Number").": <input type=text size=18 maxlength=50 name=preset_number style=\"font-family: sans-serif; font-size: 10px;\">\n";
		echo " "._QXZ("DTMF").": <input type=text size=5 maxlength=50 name=preset_dtmf style=\"font-family: sans-serif; font-size: 10px;\">\n";
		echo " &nbsp; "._QXZ("Hide Number").": <select size=1 name=preset_hide_number style=\"font-family: sans-serif; font-size: 10px;\"><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp;\n";
		echo "<input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("ADD")."' style=\"font-family: sans-serif; font-size: 10px;\"><BR>\n";
		echo "</font></center></FORM><br>\n";

		echo "<center><table width=700 cellspacing=3>\n";
		echo "<tr><td># </td><td>"._QXZ("PRESET NAME")."</td><td>"._QXZ("NUMBER")."</td><td>"._QXZ("DTMF")."</td><td>"._QXZ("HIDE")."</td><td>"._QXZ("MODIFY")."</td><td>"._QXZ("DELETE")."</td></tr>\n";

		$o=0;
		while ($presets_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$o++;

			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

			echo "<form action=$PHP_SELF method=POST><tr $bgcolor>\n";
			echo "<td><font size=2>$o </td>\n";
			echo "<td><font size=2>$rowx[0]\n";
			echo "<input type=hidden name=ADD value=401>\n";
			echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
			echo "<input type=hidden name=preset_name value=\"$rowx[0]\"> &nbsp;</td>\n";
			echo "<td><input type=text size=20 maxlength=50 name=preset_number value=\"$rowx[1]\" style=\"font-family: sans-serif; font-size: 10px;\"></td>\n";
			echo "<td><input type=text size=20 maxlength=50 name=preset_dtmf value=\"$rowx[2]\" style=\"font-family: sans-serif; font-size: 10px;\"></td>\n";
			echo "<td><select size=1 name=preset_hide_number style=\"font-family: sans-serif; font-size: 10px;\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$rowx[3]' SELECTED>"._QXZ("$rowx[3]")."</option></select></td>\n";
			echo "<td><font size=1><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("MODIFY")."' style=\"font-family: sans-serif; font-size: 10px;\"></td>\n";
			echo "<td><font size=1><a href=\"$PHP_SELF?ADD=601&campaign_id=$campaign_id&preset_name=$rowx[0]\">"._QXZ("DELETE")."</a></td></tr></form>\n";
			}

		echo "</table>\n";
		}


	##### CAMPAIGN AREACODE CID #####
	if ($SUB==202)
		{
		$checkbox_list='';
		$checkbox_count=0;
		echo "<br><br><b>"._QXZ("AREACODE CIDS FOR THIS CAMPAIGN").": &nbsp; $NWB#campaign_cid_areacodes$NWE</b><br>\n";
		if ($use_custom_cid != 'AREACODE')
			{echo "<br><B><font color=red>"._QXZ("The campaign setting Custom CallerID is not set to AREACODE")."! </font></B><BR>";}
		echo "<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=202>\n";
		echo "<input type=hidden name=stage value=MODIFY>\n";
		echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
		echo "<center><TABLE width=700 cellspacing=2>\n";

		$stmt="SELECT areacode,outbound_cid,active,cid_description,call_count_today from vicidial_campaign_cid_areacodes where campaign_id='$campaign_id' $LOGallowed_campaignsSQL order by areacode,outbound_cid;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$accids_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($accids_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$Xareacode[$o] =			$rowx[0];
			$Xoutbound_cid[$o] =		$rowx[1];
			$Xactive[$o] =				$rowx[2];
			$Xcid_description[$o] =		$rowx[3];
			$Xcall_count_today[$o] =	$rowx[4];
			$checkbox_list .= "|active_$Xareacode[$o]_$Xoutbound_cid[$o]";
			$o++;
			$checkbox_count++;
			}

		echo "<tr><td>#</td><td>"._QXZ("AREACODE")."</td><td>"._QXZ("CID NUMBER")."</td><td>"._QXZ("DESCRIPTION")."</td><td>"._QXZ("ACTIVE")."<br><span id=ACCID_link><a href=\"#\" onclick=\"FORM_selectall('$checkbox_count','$checkbox_list','on','ACCID_link');return false;\"><font size=1>"._QXZ("select all")."</font></a></span></td><td>"._QXZ("CALLS")."</td><td>"._QXZ("DELETE")."</td></tr>\n";

		$o=0;
		while ($accids_to_print > $o) 
			{
			$ct = ($o + 1);
			if ($ct == '1')
				{
				$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';
				$bgac = $Xareacode[$o];
				} 
			else
				{
				if ($Xareacode[$o] != $bgac)
					{
					if (preg_match("/1$|3$|5$|7$|9$/i", $bgct))
						{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';} 
					else
						{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';}
					$bgct++;
					$bgac = $Xareacode[$o];
					}
				}

			$DID_edit_link_BEGIN='';
			$DID_edit_link_END='';
			if (strlen($Xoutbound_cid[$o]) > 0)
				{
				$stmt="SELECT did_id from vicidial_inbound_dids where did_pattern='$Xoutbound_cid[$o]' $LOGadmin_viewable_groupsSQL limit 1;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$dids_to_print = mysqli_num_rows($rslt);
				if ($dids_to_print > 0) 
					{
					$rowx=mysqli_fetch_row($rslt);
					$DID_edit_link_BEGIN = "<a href=\"$PHP_SELF?ADD=3311&did_id=$rowx[0]\">";
					$DID_edit_link_END='</a>';
					}
				}
			echo "<tr $bgcolor><td><font size=2> &nbsp; $ct</font></td>\n";
			echo "<td><font size=2> &nbsp; $Xareacode[$o]</font></td>\n";
			echo "<td><font size=2> &nbsp; $DID_edit_link_BEGIN$Xoutbound_cid[$o]$DID_edit_link_END</font></td>\n";
			echo "<td><input type=text size=30 maxlength=100 name=cid_description_$Xareacode[$o]_$Xoutbound_cid[$o] value=\"$Xcid_description[$o]\" style=\"font-family: sans-serif; font-size: 10px;\"></td>\n";
			echo "<td>\n";
			if ($Xactive[$o] == 'Y')
				{
				echo "<input type=\"checkbox\" name=\"active_$Xareacode[$o]_$Xoutbound_cid[$o]\" id=\"active_$Xareacode[$o]_$Xoutbound_cid[$o]\" value=\"Y\" CHECKED>";
				}
			else
				{
				echo "<input type=\"checkbox\" name=\"active_$Xareacode[$o]_$Xoutbound_cid[$o]\" id=\"active_$Xareacode[$o]_$Xoutbound_cid[$o]\" value=\"Y\">";
				}
			echo "</td>\n";
			echo "<td><font size=2> &nbsp; $Xcall_count_today[$o]</font></td>\n";
			echo "<td><font size=1> &nbsp; <a href=\"$PHP_SELF?ADD=202&stage=DELETE&campaign_id=$campaign_id&areacode=$Xareacode[$o]&outbound_cid=$Xoutbound_cid[$o]\">"._QXZ("DELETE")."</a></td></tr>\n";
			$o++;
			}

		echo "</table>\n";
		echo "<input style='background-color:#$SSbutton_color' type=submit name=submit value=\""._QXZ("SUBMIT CHANGES")."\"></form><br><br>\n";

		echo "<br>"._QXZ("ADD NEW AREACODE CID")."<BR><form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=202>\n";
		echo "<input type=hidden name=stage value=ADD>\n";
		echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
		echo _QXZ("Areacode").": <input type=text size=7 maxlength=5 name=areacode>\n";
		echo _QXZ("Outbound CID").": <input type=text size=20 maxlength=20 name=outbound_cid><BR>\n";
		echo _QXZ("Description").": <input type=text size=50 maxlength=100 name=cid_description>\n";
		echo "<input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("ADD")."'><BR>\n";

		echo "</center></FORM><br>\n";
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=CAMPAIGN_AC-CID&stage=$campaign_id\">"._QXZ("Click here to see Admin changes to this campaign")." AC-CID</a></FONT>\n";
			}
		echo "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD>\n";
		}


	if ($SUB < 1)
		{
		echo "<BR><BR>\n";
		echo "<a href=\"$PHP_SELF?ADD=52&campaign_id=$campaign_id&DB=$DB\">"._QXZ("LOG ALL AGENTS OUT OF THIS CAMPAIGN")."</a><BR><BR>\n";
	#	echo "<a href=\"$PHP_SELF?ADD=53&campaign_id=$campaign_id&DB=$DB\">EMERGENCY VDAC CLEAR FOR THIS CAMPAIGN</a><BR><BR>\n";

		if ($LOGdelete_campaigns > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=51&campaign_id=$campaign_id\">"._QXZ("DELETE THIS CAMPAIGN")."</a>\n";
			}
		}
	}
	else
	{
	echo _QXZ("You do not have permission to view this page")."\n";
	exit;
	}
}


######################
# ADD=34 modify campaign info in the system - Basic View
######################

if ( ($ADD==34) and ( (!preg_match("/$campaign_id/i", $LOGallowed_campaigns)) and (!preg_match("/ALL-CAMPAIGNS/i",$LOGallowed_campaigns)) ) ) 
	{$ADD=30;}	# send to not allowed screen if not in vicidial_user_groups allowed_campaigns list

if ($ADD==34)
	{
	if ($LOGmodify_campaigns==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=31&campaign_id=$campaign_id&SUB=$SUB";
			$modify_footer_refresh=1;
			}
		if ($stage=='show_dialable')
			{
			$stmt="UPDATE vicidial_campaigns set display_dialable_count='Y' where campaign_id='$campaign_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		if ($stage=='hide_dialable')
			{
			$stmt="UPDATE vicidial_campaigns set display_dialable_count='N' where campaign_id='$campaign_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		if ($stage=='show_leadscount')
			{
			$stmt="UPDATE vicidial_campaigns set display_leads_count='Y' where campaign_id='$campaign_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		if ($stage=='hide_leadscount')
			{
			$stmt="UPDATE vicidial_campaigns set display_leads_count='N' where campaign_id='$campaign_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}

		$stmt="SELECT campaign_id,campaign_name,active,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,list_order_mix,campaign_allow_inbound,manual_dial_list_id,default_xfer_group,xfer_groups,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_third_audio_file,survey_third_status,survey_third_exten,survey_fourth_digit,survey_fourth_audio_file,survey_fourth_status,survey_fourth_exten,drop_lockout_time,quick_transfer_button,prepopulate_transfer_preset,drop_rate_group,view_calls_in_queue,view_calls_in_queue_launch,grab_calls_in_queue,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,waitforsilence_options,display_leads_count,user_group,allow_emails,call_count_limit,allow_chats,web_form_address_three,manual_vm_status_updates from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$dial_status_a = $row[3];
		$dial_status_b = $row[4];
		$dial_status_c = $row[5];
		$dial_status_d = $row[6];
		$dial_status_e = $row[7];
		$lead_order = $row[8];
		$hopper_level = $row[13];
		$auto_dial_level = $row[14];
		$next_agent_call = $row[15];
		$local_call_time = $row[16];
		$voicemail_ext = $row[17];
		$dial_timeout = $row[18];
		$dial_prefix = $row[19];
		$campaign_cid = $row[20];
		$campaign_vdad_exten = $row[21];
		$script_id = $row[25];
		$get_call_launch = $row[26];
		$lead_filter_id = $row[35];
			if ($lead_filter_id=='') {$lead_filter_id='NONE';}
		$display_dialable_count = $row[39];
		$closer_campaigns = $row[42];
		$dial_method = $row[46];
		$adaptive_intensity = $row[51];
		$auto_alt_dial = $row[54];
		$campaign_description = $row[57];
		$campaign_changedate = $row[58];
		$campaign_stats_refresh = $row[59];
		$campaign_logindate = $row[60];
		$dial_statuses = $row[61];
		$list_order_mix = $row[64];
		$default_xfer_group = $row[67];
		$campaign_allow_inbound = $row[65];
		$default_xfer_group = $row[67];
		$drop_lockout_time = $row[116];
		$display_leads_count = $row[130];
		$user_group = $row[131];
		$allow_emails = $row[132];
		$call_count_limit = $row[133];
		$allow_chats = $row[134];
		$web_form_address_three=$row[135];

	if (preg_match('/DISABLED/', $list_order_mix))
		{$DEFlistDISABLE = '';	$DEFstatusDISABLED=0;}
	else
		{$DEFlistDISABLE = 'disabled';	$DEFstatusDISABLED=1;}

	if ($auto_alt_dial == 'MULTI_LEAD')
		{$ALTmultiDISABLE=1;	$ALTmultiLINK="<a href=\"./admin_campaign_multi_alt.php?campaign_id=$campaign_id\">"._QXZ("Multi-Alt-Settings")."</a>";}
	else
		{$ALTmultiDISABLE=0;	$ALTmultiLINK='';}

	##### get status groups for the lists and in-groups within this campaign
	$stmt="SELECT status_group_id from vicidial_lists where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$lists_to_print = mysqli_num_rows($rslt);
	$camp_status_groups='';
	if ($DB) {echo "$lists_to_print|$stmt|\n";}
	$o=0;
	while ($lists_to_print > $o) 
		{
		$rowx=mysqli_fetch_row($rslt);
		if (strlen($rowx[0]) > 0) {$camp_status_groups .= "'$rowx[0]',";}
		$o++;
		}
	$closer_campaigns = preg_replace("/ -$/","",$closer_campaigns);
	$closer_campaigns = preg_replace("/ /","','",$closer_campaigns);
	$stmt="SELECT status_group_id from vicidial_inbound_groups where status_group_id NOT IN('','NONE') and group_id IN('$closer_campaigns') $LOGadmin_viewable_groupsSQL ;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$lists_to_print = mysqli_num_rows($rslt);
	if ($DB) {echo "$lists_to_print|$stmt|\n";}
	$o=0;
	while ($lists_to_print > $o) 
		{
		$rowx=mysqli_fetch_row($rslt);
		if (strlen($rowx[0]) > 0) {$camp_status_groups .= "'$rowx[0]',";}
		$o++;
		}
#	$camp_status_groups = preg_replace('/.$/i','',$camp_status_groups);

	$stmt="SELECT status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable,scheduled_callback,completed,min_sec,max_sec,answering_machine from vicidial_statuses order by status;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$statuses_to_print = mysqli_num_rows($rslt);
	$statuses_list='';
	$dial_statuses_list='';
	$o=0;
	while ($statuses_to_print > $o) 
		{
		$rowx=mysqli_fetch_row($rslt);
		$statuses_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
		if ($rowx[0] != 'CBHOLD') {$dial_statuses_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";}
		$statname_list["$rowx[0]"] = "$rowx[1]";
		$LRstatuses_list .= "<option value=\"$rowx[0]-----$rowx[1]\">$rowx[0] - $rowx[1]</option>\n";
		if (preg_match('/Y/i', $rowx[2]))
			{$HKstatuses_list .= "<option value=\"$rowx[0]-----$rowx[1]\">$rowx[0] - $rowx[1]</option>\n";}
		$o++;
		}

	$stmt="SELECT status,status_name,selectable,campaign_id,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable,scheduled_callback,completed,min_sec,max_sec,answering_machine from vicidial_campaign_statuses where campaign_id IN($camp_status_groups'$campaign_id') $LOGallowed_campaignsSQL order by status;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$Cstatuses_to_print = mysqli_num_rows($rslt);

	$o=0;
	while ($Cstatuses_to_print > $o) 
		{
		$rowx=mysqli_fetch_row($rslt);
		$statuses_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
		if ($rowx[0] != 'CBHOLD') {$dial_statuses_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";}
		$statname_list["$rowx[0]"] = "$rowx[1]";
		$LRstatuses_list .= "<option value=\"$rowx[0]-----$rowx[1]\">$rowx[0] - $rowx[1]</option>\n";
		if (preg_match('/Y/i', $rowx[2]))
			{$HKstatuses_list .= "<option value=\"$rowx[0]-----$rowx[1]\">$rowx[0] - $rowx[1]</option>\n";}
		$o++;
		}

	$dial_statuses = preg_replace("/ -$/","",$dial_statuses);
	$Dstatuses = explode(" ", $dial_statuses);
	$Ds_to_print = (count($Dstatuses) -1);

	$stmt="SELECT count(*) from vicidial_campaigns_list_mix where campaign_id='$campaign_id' and status='ACTIVE' $LOGallowed_campaignsSQL;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$rowx=mysqli_fetch_row($rslt);
	if ($rowx[0] < 1)
		{
		$mixes_list="<option SELECTED value=\"DISABLED\">"._QXZ("DISABLED")."</option>\n";
		$mixname_list["DISABLED"] = "DISABLED";
		}
	else
		{
		##### get list_mix listings for dynamic pulldown
		$stmt="SELECT vcl_id,vcl_name from vicidial_campaigns_list_mix where campaign_id='$campaign_id' and status='ACTIVE' $LOGallowed_campaignsSQL limit 1;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$mixes_to_print = mysqli_num_rows($rslt);
		$mixes_list="<option value=\"DISABLED\">"._QXZ("DISABLED")."</option>\n";

		$o=0;
		while ($mixes_to_print > $o)
			{
			$rowx=mysqli_fetch_row($rslt);
			$mixes_list .= "<option value=\"ACTIVE\">"._QXZ("ACTIVE")." ($rowx[0] - $rowx[1])</option>\n";
			$mixname_list["ACTIVE"] = "$rowx[0] - $rowx[1]";
			$o++;
			}
		}

	if ($SUB<1)		{$camp_detail_color=$subcamp_color;}
		else		{$camp_detail_color=$campaigns_color;}
	if ($SUB==22)	{$camp_statuses_color=$subcamp_color;}
		else		{$camp_statuses_color=$campaigns_color;}
	if ($SUB==23)	{$camp_hotkeys_color=$subcamp_color;}
		else		{$camp_hotkeys_color=$campaigns_color;}
	if ($SUB==25)	{$camp_recycle_color=$subcamp_color;}
		else		{$camp_recycle_color=$campaigns_color;}
	if ($SUB==26)	{$camp_autoalt_color=$subcamp_color;}
		else		{$camp_autoalt_color=$campaigns_color;}
	if ($SUB==27)	{$camp_pause_color=$subcamp_color;}
		else		{$camp_pause_color=$campaigns_color;}
	if ($SUB==29)	{$camp_listmix_color=$subcamp_color;}
		else		{$camp_listmix_color=$campaigns_color;}
	echo "<TABLE WIDTH=$page_width CELLPADDING=2 CELLSPACING=0><TR BGCOLOR=\"$campaigns_color\">\n";
	echo "<TD><font size=2 color=$subcamp_font face=\"ARIAL,HELVETICA\"> <B>$campaign_id</B>: </font></TD>";


	echo "<TD ALIGN=CENTER BGCOLOR=\"$camp_detail_color\"> &nbsp; <a href=\"$PHP_SELF?ADD=34&campaign_id=$campaign_id\" STYLE=\"text-decoration:none;\"><font class=\"sub_sub_head_links\">"._QXZ("Basic View")."</font></a></TD>";
	echo "<TD ALIGN=CENTER> <a href=\"$PHP_SELF?ADD=31&campaign_id=$campaign_id\" STYLE=\"text-decoration:none;\"><font class=\"sub_sub_head_links\">"._QXZ("Detail View")." </font></a> </TD>";

	if ($SSoutbound_autodial_active > 0)
		{
		echo "<TD ALIGN=CENTER BGCOLOR=\"$camp_listmix_color\"> <a href=\"$PHP_SELF?ADD=34&SUB=29&campaign_id=$campaign_id\" STYLE=\"text-decoration:none;\"><font class=\"sub_sub_head_links\">"._QXZ("List Mix")."</font></a> </TD>";
		}
	echo "<TD ALIGN=CENTER> <a href=\"./realtime_report.php?RR=4&DB=0&group=$campaign_id\" STYLE=\"text-decoration:none;\"><font class=\"sub_sub_head_links\">"._QXZ("Real-Time Screen")."</font></a></TD>\n";
	echo "<TD WIDTH=300><font class=\"sub_sub_head_links\"> &nbsp; </font></TD>\n";
	if ($SSoutbound_autodial_active < 1)
		{
		echo "<TD></TD>";
		}
	echo "</TR></TABLE>\n";

	if ($SUB < 1)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		echo "<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=44>\n";
		echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
		echo "<input type=hidden name=old_campaign_allow_inbound value=\"$campaign_allow_inbound\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign ID").": </td><td align=left><b>$campaign_id</b>$NWB#campaigns-campaign_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign Name").": </td><td align=left><input type=text name=campaign_name size=40 maxlength=40 value=\"$row[1]\">$NWB#campaigns-campaign_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign Description").": </td><td align=left>$row[57]$NWB#campaigns-campaign_description$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign Change Date").": </td><td align=left>$campaign_changedate &nbsp; $NWB#campaigns-campaign_changedate$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaign Login Date").": </td><td align=left>$campaign_logindate &nbsp; $NWB#campaigns-campaign_logindate$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$row[2]' SELECTED>"._QXZ("$row[2]")."</option></select>$NWB#campaigns-active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left>"._QXZ("$user_group")." $NWB#campaigns-user_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Park Music-on-Hold").": </td><td align=left>$row[10] $NWB#campaigns-park_ext$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Web Form").": </td><td align=left>$row[11]$NWB#campaigns-web_form_address$NWE"; if ($SSenable_first_webform < 1) {echo " <font color=red><b>"._QXZ("DISABLED")."</b></font>";} echo "</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Allow Closers").": </td><td align=left>"._QXZ("$row[12]")." $NWB#campaigns-allow_closers$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Default Transfer Group").": </td><td align=left>"._QXZ("$default_xfer_group")." $NWB#campaigns-default_xfer_group$NWE</td></tr>\n";
		if ($SSallow_emails > 0) 
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Allow Emails").": </td><td align=left>"._QXZ("$allow_emails")." $NWB#campaigns-allow_emails$NWE</td></tr>\n";
			}
		if ($SSallow_chats > 0) 
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Allow Chats").": </td><td align=left>"._QXZ("$allow_chats")." $NWB#campaigns-allow_chats$NWE</td></tr>\n";
			}

		if ($SSoutbound_autodial_active > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Allow Inbound and Blended").": </td><td align=left>"._QXZ("$campaign_allow_inbound")." $NWB#campaigns-campaign_allow_inbound$NWE</td></tr>\n";

			$o=0;
			while ($Ds_to_print > $o) 
				{
				$o++;
				$Dstatus = $Dstatuses[$o];

				echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Dial Status")." $o: </td><td align=left> \n";
				if ($DEFstatusDISABLED > 0)
					{
					echo "<font color=grey><DEL><b>$Dstatus</b> - $statname_list[$Dstatus] &nbsp; &nbsp; &nbsp; &nbsp; <font size=2>\n";
					echo _QXZ("REMOVE")."</DEL></td></tr>\n";
					}
				else
					{
					echo "<b>$Dstatus</b> - $statname_list[$Dstatus] &nbsp; &nbsp; &nbsp; &nbsp; <font size=2>\n";
					echo "<a href=\"$PHP_SELF?ADD=68&campaign_id=$campaign_id&status=$Dstatuses[$o]\">"._QXZ("REMOVE")."</a></td></tr>\n";
					}
				}

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Add A Dial Status to Call").": </td><td align=left><select size=1 name=dial_status $DEFlistDISABLE>\n";
			echo "<option value=\"\"> - "._QXZ("NONE")." - </option>\n";

			echo "$dial_statuses_list";
			echo "</select> &nbsp; \n";
			echo "<input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("ADD")."'> &nbsp; &nbsp; $NWB#campaigns-dial_status$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("List Order").": </td><td align=left>";
			if ($ALTmultiDISABLE > 0)
				{
				echo "<input type=hidden name=lead_order value=\"$lead_order\"> $ALTmultiLINK";
				}
			else
				{
				if (file_exists('options.php'))
					{require('options.php');}
				if ($camp_lead_order_random > 0)
					{
					echo "<select size=1 name=lead_order>
					<option value='$lead_order' SELECTED>"._QXZ("$lead_order")."</option>
					<option value='DOWN'>"._QXZ("DOWN")."</option>
					<option value='UP'>"._QXZ("UP")."</option>
					<option value='DOWN PHONE'>"._QXZ("DOWN PHONE")."</option>
					<option value='UP PHONE'>"._QXZ("UP PHONE")."</option>
					<option value='DOWN LAST NAME'>"._QXZ("DOWN LAST NAME")."</option>
					<option value='UP LAST NAME'>"._QXZ("UP LAST NAME")."</option>
					<option value='DOWN COUNT'>"._QXZ("DOWN COUNT")."</option>
					<option value='UP COUNT'>"._QXZ("UP COUNT")."</option>
					<option value='RANDOM'>"._QXZ("RANDOM")."</option>
					<option value='DOWN LAST CALL TIME'>"._QXZ("DOWN LAST CALL TIME")."</option>
					<option value='UP LAST CALL TIME'>"._QXZ("UP LAST CALL TIME")."</option>
					<option value='DOWN RANK'>"._QXZ("DOWN RANK")."</option>
					<option value='UP RANK'>"._QXZ("UP RANK")."</option>
					<option value='DOWN OWNER'>"._QXZ("DOWN OWNER")."</option>
					<option value='UP OWNER'>"._QXZ("UP OWNER")."</option>
					<option value='DOWN TIMEZONE'>"._QXZ("DOWN TIMEZONE")."</option>
					<option value='UP TIMEZONE'>"._QXZ("UP TIMEZONE")."</option>
					<option value='DOWN 2nd NEW'>"._QXZ("DOWN 2nd NEW")."</option>
					<option value='DOWN 3rd NEW'>"._QXZ("DOWN 3rd NEW")."</option>
					<option value='DOWN 4th NEW'>"._QXZ("DOWN 4th NEW")."</option>
					<option value='DOWN 5th NEW'>"._QXZ("DOWN 5th NEW")."</option>
					<option value='DOWN 6th NEW'>"._QXZ("DOWN 6th NEW")."</option>
					<option value='UP 2nd NEW'>"._QXZ("UP 2nd NEW")."</option>
					<option value='UP 3rd NEW'>"._QXZ("UP 3rd NEW")."</option>
					<option value='UP 4th NEW'>"._QXZ("UP 4th NEW")."</option>
					<option value='UP 5th NEW'>"._QXZ("UP 5th NEW")."</option>
					<option value='UP 6th NEW'>"._QXZ("UP 6th NEW")."</option>
					<option value='DOWN PHONE 2nd NEW'>"._QXZ("DOWN PHONE 2nd NEW")."</option>
					<option value='DOWN PHONE 3rd NEW'>"._QXZ("DOWN PHONE 3rd NEW")."</option>
					<option value='DOWN PHONE 4th NEW'>"._QXZ("DOWN PHONE 4th NEW")."</option>
					<option value='DOWN PHONE 5th NEW'>"._QXZ("DOWN PHONE 5th NEW")."</option>
					<option value='DOWN PHONE 6th NEW'>"._QXZ("DOWN PHONE 6th NEW")."</option>
					<option value='UP PHONE 2nd NEW'>"._QXZ("UP PHONE 2nd NEW")."</option>
					<option value='UP PHONE 3rd NEW'>"._QXZ("UP PHONE 3rd NEW")."</option>
					<option value='UP PHONE 4th NEW'>"._QXZ("UP PHONE 4th NEW")."</option>
					<option value='UP PHONE 5th NEW'>"._QXZ("UP PHONE 5th NEW")."</option>
					<option value='UP PHONE 6th NEW'>"._QXZ("UP PHONE 6th NEW")."</option>
					<option value='DOWN LAST NAME 2nd NEW'>"._QXZ("DOWN LAST NAME 2nd NEW")."</option>
					<option value='DOWN LAST NAME 3rd NEW'>"._QXZ("DOWN LAST NAME 3rd NEW")."</option>
					<option value='DOWN LAST NAME 4th NEW'>"._QXZ("DOWN LAST NAME 4th NEW")."</option>
					<option value='DOWN LAST NAME 5th NEW'>"._QXZ("DOWN LAST NAME 5th NEW")."</option>
					<option value='DOWN LAST NAME 6th NEW'>"._QXZ("DOWN LAST NAME 6th NEW")."</option>
					<option value='UP LAST NAME 2nd NEW'>"._QXZ("UP LAST NAME 2nd NEW")."</option>
					<option value='UP LAST NAME 3rd NEW'>"._QXZ("UP LAST NAME 3rd NEW")."</option>
					<option value='UP LAST NAME 4th NEW'>"._QXZ("UP LAST NAME 4th NEW")."</option>
					<option value='UP LAST NAME 5th NEW'>"._QXZ("UP LAST NAME 5th NEW")."</option>
					<option value='UP LAST NAME 6th NEW'>"._QXZ("UP LAST NAME 6th NEW")."</option>
					<option value='DOWN COUNT 2nd NEW'>"._QXZ("DOWN COUNT 2nd NEW")."</option>
					<option value='DOWN COUNT 3rd NEW'>"._QXZ("DOWN COUNT 3rd NEW")."</option>
					<option value='DOWN COUNT 4th NEW'>"._QXZ("DOWN COUNT 4th NEW")."</option>
					<option value='DOWN COUNT 5th NEW'>"._QXZ("DOWN COUNT 5th NEW")."</option>
					<option value='DOWN COUNT 6th NEW'>"._QXZ("DOWN COUNT 6th NEW")."</option>
					<option value='UP COUNT 2nd NEW'>"._QXZ("UP COUNT 2nd NEW")."</option>
					<option value='UP COUNT 3rd NEW'>"._QXZ("UP COUNT 3rd NEW")."</option>
					<option value='UP COUNT 4th NEW'>"._QXZ("UP COUNT 4th NEW")."</option>
					<option value='UP COUNT 5th NEW'>"._QXZ("UP COUNT 5th NEW")."</option>
					<option value='UP COUNT 6th NEW'>"._QXZ("UP COUNT 6th NEW")."</option>
					<option value='RANDOM 2nd NEW'>"._QXZ("RANDOM 2nd NEW")."</option>
					<option value='RANDOM 3rd NEW'>"._QXZ("RANDOM 3rd NEW")."</option>
					<option value='RANDOM 4th NEW'>"._QXZ("RANDOM 4th NEW")."</option>
					<option value='RANDOM 5th NEW'>"._QXZ("RANDOM 5th NEW")."</option>
					<option value='RANDOM 6th NEW'>"._QXZ("RANDOM 6th NEW")."</option>
					<option value='DOWN LAST CALL TIME 2nd NEW'>"._QXZ("DOWN LAST CALL TIME 2nd NEW")."</option>
					<option value='DOWN LAST CALL TIME 3rd NEW'>"._QXZ("DOWN LAST CALL TIME 3rd NEW")."</option>
					<option value='DOWN LAST CALL TIME 4th NEW'>"._QXZ("DOWN LAST CALL TIME 4th NEW")."</option>
					<option value='DOWN LAST CALL TIME 5th NEW'>"._QXZ("DOWN LAST CALL TIME 5th NEW")."</option>
					<option value='DOWN LAST CALL TIME 6th NEW'>"._QXZ("DOWN LAST CALL TIME 6th NEW")."</option>
					<option value='UP LAST CALL TIME 2nd NEW'>"._QXZ("UP LAST CALL TIME 2nd NEW")."</option>
					<option value='UP LAST CALL TIME 3rd NEW'>"._QXZ("UP LAST CALL TIME 3rd NEW")."</option>
					<option value='UP LAST CALL TIME 4th NEW'>"._QXZ("UP LAST CALL TIME 4th NEW")."</option>
					<option value='UP LAST CALL TIME 5th NEW'>"._QXZ("UP LAST CALL TIME 5th NEW")."</option>
					<option value='UP LAST CALL TIME 6th NEW'>"._QXZ("UP LAST CALL TIME 6th NEW")."</option>
					<option value='DOWN RANK 2nd NEW'>"._QXZ("DOWN RANK 2nd NEW")."</option>
					<option value='DOWN RANK 3rd NEW'>"._QXZ("DOWN RANK 3rd NEW")."</option>
					<option value='DOWN RANK 4th NEW'>"._QXZ("DOWN RANK 4th NEW")."</option>
					<option value='DOWN RANK 5th NEW'>"._QXZ("DOWN RANK 5th NEW")."</option>
					<option value='DOWN RANK 6th NEW'>"._QXZ("DOWN RANK 6th NEW")."</option>
					<option value='UP RANK 2nd NEW'>"._QXZ("UP RANK 2nd NEW")."</option>
					<option value='UP RANK 3rd NEW'>"._QXZ("UP RANK 3rd NEW")."</option>
					<option value='UP RANK 4th NEW'>"._QXZ("UP RANK 4th NEW")."</option>
					<option value='UP RANK 5th NEW'>"._QXZ("UP RANK 5th NEW")."</option>
					<option value='UP RANK 6th NEW'>"._QXZ("UP RANK 6th NEW")."</option>
					<option value='DOWN OWNER 2nd NEW'>"._QXZ("DOWN OWNER 2nd NEW")."</option>
					<option value='DOWN OWNER 3rd NEW'>"._QXZ("DOWN OWNER 3rd NEW")."</option>
					<option value='DOWN OWNER 4th NEW'>"._QXZ("DOWN OWNER 4th NEW")."</option>
					<option value='DOWN OWNER 5th NEW'>"._QXZ("DOWN OWNER 5th NEW")."</option>
					<option value='DOWN OWNER 6th NEW'>"._QXZ("DOWN OWNER 6th NEW")."</option>
					<option value='UP OWNER 2nd NEW'>"._QXZ("UP OWNER 2nd NEW")."</option>
					<option value='UP OWNER 3rd NEW'>"._QXZ("UP OWNER 3rd NEW")."</option>
					<option value='UP OWNER 4th NEW'>"._QXZ("UP OWNER 4th NEW")."</option>
					<option value='UP OWNER 5th NEW'>"._QXZ("UP OWNER 5th NEW")."</option>
					<option value='UP OWNER 6th NEW'>"._QXZ("UP OWNER 6th NEW")."</option>
					<option value='DOWN TIMEZONE 2nd NEW'>"._QXZ("DOWN TIMEZONE 2nd NEW")."</option>
					<option value='DOWN TIMEZONE 3rd NEW'>"._QXZ("DOWN TIMEZONE 3rd NEW")."</option>
					<option value='DOWN TIMEZONE 4th NEW'>"._QXZ("DOWN TIMEZONE 4th NEW")."</option>
					<option value='DOWN TIMEZONE 5th NEW'>"._QXZ("DOWN TIMEZONE 5th NEW")."</option>
					<option value='DOWN TIMEZONE 6th NEW'>"._QXZ("DOWN TIMEZONE 6th NEW")."</option>
					<option value='UP TIMEZONE 2nd NEW'>"._QXZ("UP TIMEZONE 2nd NEW")."</option>
					<option value='UP TIMEZONE 3rd NEW'>"._QXZ("UP TIMEZONE 3rd NEW")."</option>
					<option value='UP TIMEZONE 4th NEW'>"._QXZ("UP TIMEZONE 4th NEW")."</option>
					<option value='UP TIMEZONE 5th NEW'>"._QXZ("UP TIMEZONE 5th NEW")."</option>
					<option value='UP TIMEZONE 6th NEW'>"._QXZ("UP TIMEZONE 6th NEW")."</option>
					</select>$NWB#campaigns-lead_order$NWE";
					}
				else
					{
					echo "<select size=1 name=lead_order>
					<option value='$lead_order' SELECTED>"._QXZ("$lead_order")."</option>
					<option value='DOWN'>"._QXZ("DOWN")."</option>
					<option value='UP'>"._QXZ("UP")."</option>
					<option value='DOWN PHONE'>"._QXZ("DOWN PHONE")."</option>
					<option value='UP PHONE'>"._QXZ("UP PHONE")."</option>
					<option value='DOWN LAST NAME'>"._QXZ("DOWN LAST NAME")."</option>
					<option value='UP LAST NAME'>"._QXZ("UP LAST NAME")."</option>
					<option value='DOWN COUNT'>"._QXZ("DOWN COUNT")."</option>
					<option value='UP COUNT'>"._QXZ("UP COUNT")."</option>
					<option value='DOWN LAST CALL TIME'>"._QXZ("DOWN LAST CALL TIME")."</option>
					<option value='UP LAST CALL TIME'>"._QXZ("UP LAST CALL TIME")."</option>
					<option value='DOWN RANK'>"._QXZ("DOWN RANK")."</option>
					<option value='UP RANK'>"._QXZ("UP RANK")."</option>
					<option value='DOWN OWNER'>"._QXZ("DOWN OWNER")."</option>
					<option value='UP OWNER'>"._QXZ("UP OWNER")."</option>
					<option value='DOWN TIMEZONE'>"._QXZ("DOWN TIMEZONE")."</option>
					<option value='UP TIMEZONE'>"._QXZ("UP TIMEZONE")."</option>
					<option value='DOWN 2nd NEW'>"._QXZ("DOWN 2nd NEW")."</option>
					<option value='DOWN 3rd NEW'>"._QXZ("DOWN 3rd NEW")."</option>
					<option value='DOWN 4th NEW'>"._QXZ("DOWN 4th NEW")."</option>
					<option value='DOWN 5th NEW'>"._QXZ("DOWN 5th NEW")."</option>
					<option value='DOWN 6th NEW'>"._QXZ("DOWN 6th NEW")."</option>
					<option value='UP 2nd NEW'>"._QXZ("UP 2nd NEW")."</option>
					<option value='UP 3rd NEW'>"._QXZ("UP 3rd NEW")."</option>
					<option value='UP 4th NEW'>"._QXZ("UP 4th NEW")."</option>
					<option value='UP 5th NEW'>"._QXZ("UP 5th NEW")."</option>
					<option value='UP 6th NEW'>"._QXZ("UP 6th NEW")."</option>
					<option value='DOWN PHONE 2nd NEW'>"._QXZ("DOWN PHONE 2nd NEW")."</option>
					<option value='DOWN PHONE 3rd NEW'>"._QXZ("DOWN PHONE 3rd NEW")."</option>
					<option value='DOWN PHONE 4th NEW'>"._QXZ("DOWN PHONE 4th NEW")."</option>
					<option value='DOWN PHONE 5th NEW'>"._QXZ("DOWN PHONE 5th NEW")."</option>
					<option value='DOWN PHONE 6th NEW'>"._QXZ("DOWN PHONE 6th NEW")."</option>
					<option value='UP PHONE 2nd NEW'>"._QXZ("UP PHONE 2nd NEW")."</option>
					<option value='UP PHONE 3rd NEW'>"._QXZ("UP PHONE 3rd NEW")."</option>
					<option value='UP PHONE 4th NEW'>"._QXZ("UP PHONE 4th NEW")."</option>
					<option value='UP PHONE 5th NEW'>"._QXZ("UP PHONE 5th NEW")."</option>
					<option value='UP PHONE 6th NEW'>"._QXZ("UP PHONE 6th NEW")."</option>
					<option value='DOWN LAST NAME 2nd NEW'>"._QXZ("DOWN LAST NAME 2nd NEW")."</option>
					<option value='DOWN LAST NAME 3rd NEW'>"._QXZ("DOWN LAST NAME 3rd NEW")."</option>
					<option value='DOWN LAST NAME 4th NEW'>"._QXZ("DOWN LAST NAME 4th NEW")."</option>
					<option value='DOWN LAST NAME 5th NEW'>"._QXZ("DOWN LAST NAME 5th NEW")."</option>
					<option value='DOWN LAST NAME 6th NEW'>"._QXZ("DOWN LAST NAME 6th NEW")."</option>
					<option value='UP LAST NAME 2nd NEW'>"._QXZ("UP LAST NAME 2nd NEW")."</option>
					<option value='UP LAST NAME 3rd NEW'>"._QXZ("UP LAST NAME 3rd NEW")."</option>
					<option value='UP LAST NAME 4th NEW'>"._QXZ("UP LAST NAME 4th NEW")."</option>
					<option value='UP LAST NAME 5th NEW'>"._QXZ("UP LAST NAME 5th NEW")."</option>
					<option value='UP LAST NAME 6th NEW'>"._QXZ("UP LAST NAME 6th NEW")."</option>
					<option value='DOWN COUNT 2nd NEW'>"._QXZ("DOWN COUNT 2nd NEW")."</option>
					<option value='DOWN COUNT 3rd NEW'>"._QXZ("DOWN COUNT 3rd NEW")."</option>
					<option value='DOWN COUNT 4th NEW'>"._QXZ("DOWN COUNT 4th NEW")."</option>
					<option value='DOWN COUNT 5th NEW'>"._QXZ("DOWN COUNT 5th NEW")."</option>
					<option value='DOWN COUNT 6th NEW'>"._QXZ("DOWN COUNT 6th NEW")."</option>
					<option value='UP COUNT 2nd NEW'>"._QXZ("UP COUNT 2nd NEW")."</option>
					<option value='UP COUNT 3rd NEW'>"._QXZ("UP COUNT 3rd NEW")."</option>
					<option value='UP COUNT 4th NEW'>"._QXZ("UP COUNT 4th NEW")."</option>
					<option value='UP COUNT 5th NEW'>"._QXZ("UP COUNT 5th NEW")."</option>
					<option value='UP COUNT 6th NEW'>"._QXZ("UP COUNT 6th NEW")."</option>
					<option value='DOWN LAST CALL TIME 2nd NEW'>"._QXZ("DOWN LAST CALL TIME 2nd NEW")."</option>
					<option value='DOWN LAST CALL TIME 3rd NEW'>"._QXZ("DOWN LAST CALL TIME 3rd NEW")."</option>
					<option value='DOWN LAST CALL TIME 4th NEW'>"._QXZ("DOWN LAST CALL TIME 4th NEW")."</option>
					<option value='DOWN LAST CALL TIME 5th NEW'>"._QXZ("DOWN LAST CALL TIME 5th NEW")."</option>
					<option value='DOWN LAST CALL TIME 6th NEW'>"._QXZ("DOWN LAST CALL TIME 6th NEW")."</option>
					<option value='UP LAST CALL TIME 2nd NEW'>"._QXZ("UP LAST CALL TIME 2nd NEW")."</option>
					<option value='UP LAST CALL TIME 3rd NEW'>"._QXZ("UP LAST CALL TIME 3rd NEW")."</option>
					<option value='UP LAST CALL TIME 4th NEW'>"._QXZ("UP LAST CALL TIME 4th NEW")."</option>
					<option value='UP LAST CALL TIME 5th NEW'>"._QXZ("UP LAST CALL TIME 5th NEW")."</option>
					<option value='UP LAST CALL TIME 6th NEW'>"._QXZ("UP LAST CALL TIME 6th NEW")."</option>
					<option value='DOWN RANK 2nd NEW'>"._QXZ("DOWN RANK 2nd NEW")."</option>
					<option value='DOWN RANK 3rd NEW'>"._QXZ("DOWN RANK 3rd NEW")."</option>
					<option value='DOWN RANK 4th NEW'>"._QXZ("DOWN RANK 4th NEW")."</option>
					<option value='DOWN RANK 5th NEW'>"._QXZ("DOWN RANK 5th NEW")."</option>
					<option value='DOWN RANK 6th NEW'>"._QXZ("DOWN RANK 6th NEW")."</option>
					<option value='UP RANK 2nd NEW'>"._QXZ("UP RANK 2nd NEW")."</option>
					<option value='UP RANK 3rd NEW'>"._QXZ("UP RANK 3rd NEW")."</option>
					<option value='UP RANK 4th NEW'>"._QXZ("UP RANK 4th NEW")."</option>
					<option value='UP RANK 5th NEW'>"._QXZ("UP RANK 5th NEW")."</option>
					<option value='UP RANK 6th NEW'>"._QXZ("UP RANK 6th NEW")."</option>
					<option value='DOWN OWNER 2nd NEW'>"._QXZ("DOWN OWNER 2nd NEW")."</option>
					<option value='DOWN OWNER 3rd NEW'>"._QXZ("DOWN OWNER 3rd NEW")."</option>
					<option value='DOWN OWNER 4th NEW'>"._QXZ("DOWN OWNER 4th NEW")."</option>
					<option value='DOWN OWNER 5th NEW'>"._QXZ("DOWN OWNER 5th NEW")."</option>
					<option value='DOWN OWNER 6th NEW'>"._QXZ("DOWN OWNER 6th NEW")."</option>
					<option value='UP OWNER 2nd NEW'>"._QXZ("UP OWNER 2nd NEW")."</option>
					<option value='UP OWNER 3rd NEW'>"._QXZ("UP OWNER 3rd NEW")."</option>
					<option value='UP OWNER 4th NEW'>"._QXZ("UP OWNER 4th NEW")."</option>
					<option value='UP OWNER 5th NEW'>"._QXZ("UP OWNER 5th NEW")."</option>
					<option value='UP OWNER 6th NEW'>"._QXZ("UP OWNER 6th NEW")."</option>
					<option value='DOWN TIMEZONE 2nd NEW'>"._QXZ("DOWN TIMEZONE 2nd NEW")."</option>
					<option value='DOWN TIMEZONE 3rd NEW'>"._QXZ("DOWN TIMEZONE 3rd NEW")."</option>
					<option value='DOWN TIMEZONE 4th NEW'>"._QXZ("DOWN TIMEZONE 4th NEW")."</option>
					<option value='DOWN TIMEZONE 5th NEW'>"._QXZ("DOWN TIMEZONE 5th NEW")."</option>
					<option value='DOWN TIMEZONE 6th NEW'>"._QXZ("DOWN TIMEZONE 6th NEW")."</option>
					<option value='UP TIMEZONE 2nd NEW'>"._QXZ("UP TIMEZONE 2nd NEW")."</option>
					<option value='UP TIMEZONE 3rd NEW'>"._QXZ("UP TIMEZONE 3rd NEW")."</option>
					<option value='UP TIMEZONE 4th NEW'>"._QXZ("UP TIMEZONE 4th NEW")."</option>
					<option value='UP TIMEZONE 5th NEW'>"._QXZ("UP TIMEZONE 5th NEW")."</option>
					<option value='UP TIMEZONE 6th NEW'>"._QXZ("UP TIMEZONE 6th NEW")."</option>
					</select>$NWB#campaigns-lead_order$NWE";
					}
				}
			echo "</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=31&SUB=29&campaign_id=$campaign_id&vcl_id=$list_order_mix\">"._QXZ("List Mix")."</a>: </td><td align=left>";
			if ($ALTmultiDISABLE > 0)
				{
				echo "<input type=hidden name=list_order_mix value=\"$list_order_mix\"> $ALTmultiLINK";
				}
			else
				{
				echo "<select size=1 name=list_order_mix>\n";
				echo "$mixes_list";
				if (preg_match('/DISABLED/', $list_order_mix))
					{echo "<option selected value=\"$list_order_mix\">"._QXZ("$list_order_mix")." - "._QXZ("$mixname_list[$list_order_mix]")."</option>\n";}
				else
					{echo "<option selected value=\"ACTIVE\">"._QXZ("ACTIVE")." ($mixname_list[ACTIVE])</option>\n";}
				echo "</select>$NWB#campaigns-list_order_mix$NWE";
				}
			echo "</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=31111111&lead_filter_id=$lead_filter_id\">"._QXZ("Lead Filter")."</a>: </td><td align=left>";
			if ($ALTmultiDISABLE > 0)
				{
				echo "<input type=hidden name=lead_filter_id value=\"$lead_filter_id\"> $ALTmultiLINK";
				}
			else
				{
				echo "<select size=1 name=lead_filter_id>\n";
				echo "$filters_list";
				echo "<option selected value=\"$lead_filter_id\">"._QXZ("$lead_filter_id")." - $filtername_list[$lead_filter_id]</option>\n";
				echo "</select>$NWB#campaigns-lead_filter_id$NWE";
				}
			echo "</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Minimum Hopper Level").": </td><td align=left><select size=1 name=hopper_level><option>1</option><option>5</option><option>10</option><option>20</option><option>50</option><option>100</option><option>200</option><option>500</option><option>700</option><option>1000</option><option>2000</option><option>3000</option><option>4000</option><option>5000</option><option SELECTED>$hopper_level</option></select>$NWB#campaigns-hopper_level$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Force Reset of Hopper").": </td><td align=left><select size=1 name=reset_hopper><option value='Y'>"._QXZ("Y")."</option><option value=\"N\" SELECTED>"._QXZ("N")."</option></select>$NWB#campaigns-force_reset_hopper$NWE</td></tr>\n";

			if ( (preg_match("/RATIO|ADAPT/",$dial_method)) and ($SSdisable_auto_dial > 0) )
				{
				echo "<tr bgcolor=#$SSalt_row1_background><td align=center colspan=2><b>"._QXZ("Auto-dialing has been disabled on this system")."</b></td></tr>\n";
				}
			echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Dial Method").": </td><td align=left><select size=1 name=dial_method><option value='MANUAL'>"._QXZ("MANUAL")."</option><option value='RATIO'>"._QXZ("RATIO")."</option><option value='ADAPT_HARD_LIMIT'>"._QXZ("ADAPT_HARD_LIMIT")."</option><option value='ADAPT_TAPERED'>"._QXZ("ADAPT_TAPERED")."</option><option value='ADAPT_AVERAGE'>"._QXZ("ADAPT_AVERAGE")."</option><option value='INBOUND_MAN'>"._QXZ("INBOUND_MAN")."</option><option value='$dial_method' SELECTED>"._QXZ("$dial_method")."</option></select>$NWB#campaigns-dial_method$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Auto Dial Level").": </td><td align=left><select size=1 name=auto_dial_level><option selected>$auto_dial_level</option><option>0</option>\n";
			$adl=0;
			while($adl <= $SSauto_dial_limit)
				{
				if ($adl < 1)
					{$adl = ($adl + 1);}
				else
					{
					if ($adl < 3)
						{$adl = ($adl + 0.1);}
					else
						{
						if ($adl < 4)
							{$adl = ($adl + 0.25);}
						else
							{
							if ($adl < 5)
								{$adl = ($adl + 0.5);}
							else
								{
								if ($adl < 20)
									{$adl = ($adl + 1);}
								else
									{
									if ($adl < 40)
										{$adl = ($adl + 2);}
									else
										{
										if ($adl < 100)
											{$adl = ($adl + 5);}
										else
											{
											if ($adl < 200)
												{$adl = ($adl + 10);}
											else
												{
												if ($adl < 400)
													{$adl = ($adl + 50);}
												else
													{
													if ($adl < 1000)
														{$adl = ($adl + 100);}
													else
													{$adl = ($adl + 1);}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				if ($adl > $SSauto_dial_limit) {$hmm=1;}
				else {echo "<option>$adl</option>\n";}
				}
			echo "</select>(0 = "._QXZ("off").")$NWB#campaigns-auto_dial_level$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Adapt Intensity Modifier").": </td><td align=left><select size=1 name=adaptive_intensity>\n";
			$n=40;
			while ($n>=-40)
				{
				$dtl = _QXZ("Balanced");
				if ($n<0) {$dtl = _QXZ("Less Intense");}
				if ($n>0) {$dtl = _QXZ("More Intense");}
				if ($n == $adaptive_intensity) 
					{echo "<option SELECTED value=\"$n\">$n - $dtl</option>\n";}
				else
					{echo "<option value=\"$n\">$n - $dtl</option>\n";}
				$n--;
				}
			echo "</select> $NWB#campaigns-adaptive_intensity$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=3111111&script_id=$script_id\">"._QXZ("Script")."</a>: </td><td align=left>"._QXZ("$script_id")."</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Get Call Launch").": </td><td align=left>"._QXZ("$get_call_launch")."</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center></FORM>\n";

		echo "<center>\n";

	if ($SSoutbound_autodial_active > 0)
		{
		echo "<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=44>\n";
		echo "<input type=hidden name=DB value=$DB>\n";
		echo "<input type=hidden name=stage value=list_activation>\n";
		echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
		echo "<br><b>"._QXZ("LISTS WITHIN THIS CAMPAIGN").": &nbsp; $NWB#campaign_lists$NWE</b>\n";

		echo "<TABLE><TR><TD>\n";
			echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$LISTlink='stage=LISTIDDOWN';
		$NAMElink='stage=LISTNAMEDOWN';
		$CALLTIMElink='stage=CALLTIMEDOWN';
		$TALLYlink='stage=TALLYDOWN';
		$ACTIVElink='stage=ACTIVEDOWN';
		$CAMPAIGNlink='stage=CAMPAIGNDOWN';
		$CALLDATElink='stage=CALLDATEDOWN';
		$SQLorder='order by list_id';
		if (preg_match('/LISTIDUP/i', $stage))		{$SQLorder='order by list_id asc';				$LISTlink='stage=LISTIDDOWN';}
		if (preg_match('/LISTIDDOWN/i', $stage))	{$SQLorder='order by list_id desc';				$LISTlink='stage=LISTIDUP';}
		if (preg_match('/LISTNAMEUP/i', $stage))	{$SQLorder='order by list_name asc';			$NAMElink='stage=LISTNAMEDOWN';}
		if (preg_match('/LISTNAMEDOWN/i', $stage))	{$SQLorder='order by list_name desc';			$NAMElink='stage=LISTNAMEUP';}
		if (preg_match('/CALLTIMEUP/i', $stage))	{$SQLorder='order by local_call_time asc';		$CALLTIMElink='stage=CALLTIMEDOWN';}
		if (preg_match('/CALLTIMEDOWN/i', $stage))	{$SQLorder='order by local_call_time desc';		$CALLTIMElink='stage=CALLTIMEUP';}	
		if (preg_match('/TALLYUP/i', $stage))		{$SQLorder='order by tally asc';				$TALLYlink='stage=TALLYDOWN';}
		if (preg_match('/TALLYDOWN/i', $stage))		{$SQLorder='order by tally desc';				$TALLYlink='stage=TALLYUP';}
		if (preg_match('/ACTIVEUP/i', $stage))		{$SQLorder='order by active asc';				$ACTIVElink='stage=ACTIVEDOWN';}
		if (preg_match('/ACTIVEDOWN/i', $stage))	{$SQLorder='order by active desc';				$ACTIVElink='stage=ACTIVEUP';}
		if (preg_match('/CAMPAIGNUP/i',$stage))		{$SQLorder='order by campaign_id asc';			$CAMPAIGNlink='stage=CAMPAIGNDOWN';}
		if (preg_match('/CAMPAIGNUP/i', $stage))	{$SQLorder='order by campaign_id desc';			$CAMPAIGNlink='stage=CAMPAIGNUP';}
		if (preg_match('/CALLDATEUP/i', $stage))	{$SQLorder='order by list_lastcalldate asc';	$CALLDATElink='stage=CALLDATEDOWN';}
		if (preg_match('/CALLDATEDOWN/i', $stage))	{$SQLorder='order by list_lastcalldate desc';	$CALLDATElink='stage=CALLDATEUP';}
		$stmt="SELECT vls.list_id,list_name,list_description,count(*) as tally,active,list_lastcalldate,campaign_id,DATE_FORMAT(expiration_date,'%Y%m%d'),local_call_time from vicidial_lists vls,vicidial_list vl where vls.list_id=vl.list_id and campaign_id='$campaign_id' $LOGallowed_campaignsSQL group by list_id $SQLorder";
		if ($SSadmin_list_counts < 1)
			{$stmt="SELECT list_id,list_name,list_description,'X' as tally,active,list_lastcalldate,campaign_id,DATE_FORMAT(expiration_date,'%Y%m%d'),local_call_time from vicidial_lists where campaign_id='$campaign_id' $LOGallowed_campaignsSQL $SQLorder";}
		$rslt=mysql_to_mysqli($stmt, $link);
		$lists_to_print = mysqli_num_rows($rslt);

		echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
		echo "<TR BGCOLOR=BLACK>";
		echo "<TD><a href=\"$PHP_SELF?ADD=34&campaign_id=$campaign_id&$LISTlink\"><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("LIST ID")."</B></a></TD>";
		echo "<TD><a href=\"$PHP_SELF?ADD=34&campaign_id=$campaign_id&$NAMElink\"><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("LIST NAME")."</B></a></TD>";
		echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("DESCRIPTION")."</B></TD>\n";
		echo "<TD><a href=\"$PHP_SELF?ADD=34&campaign_id=$campaign_id&$TALLYlink\"><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("LEADS COUNT")."</B></a></TD>\n";
		echo "<TD><a href=\"$PHP_SELF?ADD=34&campaign_id=$campaign_id&$CALLTIMElink\"><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("Call Time")."</B></a></TD>";
		echo "<TD COLSPAN=3><a href=\"$PHP_SELF?ADD=31&campaign_id=$campaign_id&$ACTIVElink\"><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("ACTIVE")."</B></a></TD>";
		echo "<TD><a href=\"$PHP_SELF?ADD=34&campaign_id=$campaign_id&$CALLDATElink\"><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("LAST CALL DATE")."</B></a></TD>";
		echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("MODIFY")."</TD>\n";
		echo "</TR>\n";

		$o=0;
		$last_list_statuses="";
		while ($lists_to_print > $o)
			{
			$row=mysqli_fetch_row($rslt);
			$last_list_statuses.="$row[0]|$row[4]|";
			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}
			echo "<tr $bgcolor><td><font size=1><a href=\"$PHP_SELF?ADD=311&list_id=$row[0]\">$row[0]</a></td>";
			echo "<td><font size=1> $row[1]</td>";
			echo "<td><font size=1> $row[2]</td>";
			echo "<td><font size=1> $row[3]</td>";
			if ($row[8] == 'campaign')
				{echo "<td><font size=1> $row[8]</td>";}
			else
				{echo "<td><font size=1><a href=\"$PHP_SELF?ADD=311111111&call_time_id=$row[8]\"> $row[8]</a></td>";}
			echo "<td><font size=1> "._QXZ("$row[4]")."</td>";
			echo "<td>";

			if (preg_match('/Y/',$row[4]))
				{
				$active_lists++;
				$camp_lists .= "'$row[0]',";
				echo "<input type=\"checkbox\" name=\"list_active_change[]\" value=\"$row[0]\" CHECKED>";
				}
			else
				{
				$inactive_lists++;
				echo "<input type=\"checkbox\" name=\"list_active_change[]\" value=\"$row[0]\"";
				}

			echo "</td><td><font size=1>";
			if ($row[7] < $EXPtestdate)
				{echo "<font color=red><B>"._QXZ("EXP")."</B></font>";}
			else
				{echo "&nbsp;";}
			echo "</td>";
			echo "<td><font size=1> $row[5]</td>";
			echo "<td><font size=1><a href=\"$PHP_SELF?ADD=311&list_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";

			$o++;
			}

		echo "<TR><TD COLSPAN=9 ALIGN=CENTER><input style='background-color:#$SSbutton_color' type=button onClick='return ConfirmListStatusChange($SSlist_status_modification_confirmation, this.form)' value=\""._QXZ("SUBMIT ACTIVE LIST CHANGES")."\"></TD></TR>\n";
		echo "</TABLE>";
		echo "<input type='hidden' name='last_list_statuses' id='last_list_statuses' value='$last_list_statuses'>";
		echo "</center><BR></FORM>\n";
		echo "<center><b>\n";

		$filterSQL = $filtersql_list[$lead_filter_id];
		$filterSQL = preg_replace("/\\\\/","",$filterSQL);
		$filterSQL = preg_replace('/^and|and$|^or|or$/i', '',$filterSQL);
		if (strlen($filterSQL)>4)
			{$fSQL = "and ($filterSQL)";}
		else
			{$fSQL = '';}

			$camp_lists = preg_replace('/.$/i','',$camp_lists);
		echo _QXZ("This campaign has")." $active_lists "._QXZ("active lists and")." $inactive_lists "._QXZ("inactive lists")."<br><br>\n";


		if ( ($display_leads_count == 'Y') and (strlen($camp_lists) > 3) )
			{
			# grab names of global statuses and statuses in the selected campaign
			$stmt="SELECT status,status_name from vicidial_statuses order by status;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$statuses_to_print = mysqli_num_rows($rslt);

			$o=0;
			while ($statuses_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$statuses_name_list["$rowx[0]"] = "$rowx[1]";
				$o++;
				}

			$stmt="SELECT status,status_name from vicidial_campaign_statuses where campaign_id IN($camp_status_groups'$campaign_id') $LOGallowed_campaignsSQL order by status;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$Cstatuses_to_print = mysqli_num_rows($rslt);

			$o=0;
			while ($Cstatuses_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$statuses_name_list["$rowx[0]"] = "$rowx[1]";
				$o++;
				}
			# end grab status names

			echo "<br><b>"._QXZ("STATUSES WITHIN THE ACTIVE LISTS FOR THIS CAMPAIGN").":</b>\n";
			echo " - <font size=1><a href=\"$PHP_SELF?ADD=34&campaign_id=$campaign_id&stage=hide_leadscount\">"._QXZ("HIDE")."</a></font><BR>";
			echo "<TABLE width=500 cellspacing=3>\n";
			echo "<tr><td>"._QXZ("STATUS")."</td><td>"._QXZ("STATUS NAME")."</td><td>"._QXZ("CALLED")."</td><td>"._QXZ("NOT CALLED")."</td></tr>\n";

			$leads_in_list = 0;
			$leads_in_list_N = 0;
			$leads_in_list_Y = 0;
			$stmt="SELECT status,called_since_last_reset,count(*) from vicidial_list where list_id IN($camp_lists) group by status,called_since_last_reset order by status,called_since_last_reset;";
			if ($DB) {echo "$stmt\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			$statuses_to_print = mysqli_num_rows($rslt);

			$o=0;
			$lead_list['count'] = 0;
			$lead_list['Y_count'] = 0;
			$lead_list['N_count'] = 0;
			while ($statuses_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				
				$lead_list['count'] = ($lead_list['count'] + $rowx[2]);
				if ($rowx[1] == 'N') 
					{
					$since_reset = 'N';
					$since_resetX = 'Y';
					}
				else 
					{
					$since_reset = 'Y';
					$since_resetX = 'N';
					} 
				$lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]);
				$lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]);
				#If opposite side is not set, it may not in the future so give it a value of zero
				if (!isset($lead_list[$since_resetX][$rowx[0]])) 
					{
					$lead_list[$since_resetX][$rowx[0]]=0;
					}
				$o++;
				}
		 
			$o=0;
			if ($lead_list['count'] > 0)
				{
#				while (list($dispo,) = each($lead_list[$since_reset]))
				foreach($lead_list[$since_reset] as $dispo => $blank)
					{
					if (preg_match('/1$|3$|5$|7$|9$/i', $o))
						{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
					else
						{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

					if ($dispo == 'CBHOLD')
						{
						$CLB="<a href=\"$PHP_SELF?ADD=811&list_id=$list_id\">";
						$CLE="</a>";
						}
					else
						{
						$CLB='';
						$CLE='';
						}

					echo "<tr $bgcolor><td><font size=1>$CLB$dispo$CLE</td><td><font size=1>$statuses_name_list[$dispo]</td><td><font size=1>".$lead_list['Y'][$dispo]."</td><td><font size=1>".$lead_list['N'][$dispo]." </td></tr>\n";
					$o++;
					}
				}

			echo "<tr><td colspan=2><font size=1>"._QXZ("SUBTOTALS")."</td><td><font size=1>$lead_list[Y_count]</td><td><font size=1>$lead_list[N_count]</td></tr>\n";
			echo "<tr bgcolor=\"#$SSstd_row1_background\"><td><font size=1>"._QXZ("TOTAL")."</td><td colspan=3 align=center><font size=1>$lead_list[count]</td></tr>\n";

			echo "</table></center><br>\n";
			unset($lead_list);				
			}
		else
			{
			echo "<font size=1><a href=\"$PHP_SELF?ADD=34&campaign_id=$campaign_id&stage=show_leadscount\">"._QXZ("SHOW LEAD STATUSES IN THIS CAMPAIGN")."</a></font><BR><BR>";
			}


		if ($display_dialable_count == 'Y')
			{
			### call function to calculate and print dialable leads
			$single_status=0;
			$only_return=0;
			dialable_leads($DB,$link,$local_call_time,$dial_statuses,$camp_lists,$drop_lockout_time,$call_count_limit,$single_status,$fSQL,$only_return);
			echo " - <font size=1><a href=\"$PHP_SELF?ADD=34&campaign_id=$campaign_id&stage=hide_dialable\">"._QXZ("HIDE")."</a></font><BR><BR>";
			}
		else
			{
			echo "<a href=\"$PHP_SELF?ADD=73&campaign_id=$campaign_id\" target=\"_blank\">Popup Dialable Leads Count</a>";
			echo " - <font size=1><a href=\"$PHP_SELF?ADD=31&campaign_id=$campaign_id&stage=show_dialable\">"._QXZ("SHOW")."</a></font><BR><BR>";
			}

		$stmt="SELECT count(*) FROM vicidial_hopper where campaign_id='$campaign_id' and status IN('READY','RHOLD','RQUEUE') $LOGallowed_campaignsSQL;";
		if ($DB) {echo "$stmt\n";}
		$rslt=mysql_to_mysqli($stmt, $link);
		$rowx=mysqli_fetch_row($rslt);
		$hopper_leads = "$rowx[0]";

		echo _QXZ("This campaign has")." $hopper_leads "._QXZ("leads in the dial hopper")."<br><br>\n";
		echo "<a href=\"./AST_VICIDIAL_hopperlist.php?group=$campaign_id\">"._QXZ("Click here to see what leads are in the hopper right now")."</a><br><br>\n";
		echo "<a href=\"./AST_VDADstats.php?group=$campaign_id\">"._QXZ("Click here to see a VDAD report for this campaign")."</a><BR><BR>\n";
		}
		echo "<a href=\"$PHP_SELF?ADD=81&campaign_id=$campaign_id\">"._QXZ("Click here to see all CallBack Holds in this campaign")."</a><BR><BR>\n";
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=CAMPAIGNS&stage=$campaign_id\">"._QXZ("Click here to see Admin changes to this campaign")."</a></FONT>\n";
			}

		echo "</b></center>\n";

		echo "<br>\n";

		### list of agent rank or skill-level for this campaign
		echo "<center>\n";
		echo "<br><b>"._QXZ("AGENT RANKS FOR THIS CAMPAIGN").":</b><br>\n";
		echo "<TABLE width=600 cellspacing=3>\n";
		echo "<tr><td>"._QXZ("USER")."</td><td> &nbsp; &nbsp; "._QXZ("RANK")."</td><td> &nbsp; &nbsp; "._QXZ("GRADE")."</td><td> &nbsp; &nbsp; "._QXZ("CALLS TODAY")."</td></tr>\n";

		$stmt="SELECT vu.user,vca.campaign_rank,vca.calls_today,full_name,vca.campaign_grade from vicidial_campaign_agents vca, vicidial_users vu where campaign_id='$campaign_id' and active='Y' and vu.user=vca.user $LOGadmin_viewable_groupsSQL order by vu.user;";
		$rsltx=mysql_to_mysqli($stmt, $link);
		$users_to_print = mysqli_num_rows($rsltx);

		$o=0;
		while ($users_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rsltx);
			$o++;

			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

			echo "<tr $bgcolor><td><font size=1><a href=\"$PHP_SELF?ADD=3&user=$rowx[0]\">$rowx[0]</a> - $rowx[3]</td><td><font size=1>$rowx[1]</td><td><font size=1>$rowx[4]</td><td><font size=1>$rowx[2]</td></tr>\n";
			}

		echo "</table></center><br>\n";


		echo "<a href=\"$PHP_SELF?ADD=52&campaign_id=$campaign_id&DB=$DB\">"._QXZ("LOG ALL AGENTS OUT OF THIS CAMPAIGN")."</a><BR><BR>\n";


		if ($LOGdelete_campaigns > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=51&campaign_id=$campaign_id\">"._QXZ("DELETE THIS CAMPAIGN")."</a>\n";
			}
		}
	}
	else
	{
	echo _QXZ("You do not have permission to view this page")."\n";
	exit;
	}
}


######################
# ADD=31 or 34 and SUB=29 for list mixes
######################
if ( ( ($ADD==34) or ($ADD==31) ) and ( (!preg_match("/$campaign_id/i", $LOGallowed_campaigns)) and (!preg_match("/ALL-CAMPAIGNS/i",$LOGallowed_campaigns)) ) ) 
	{$ADD=30;}	# send to not allowed screen if not in vicidial_user_groups allowed_campaigns list

if ( ($ADD==34) or ($ADD==31) )
{
	if ($LOGmodify_campaigns==1)
	{
	##### CAMPAIGN LIST MIX SETTINGS #####
	if ($SUB==29)
		{
		##### get list_id listings for dynamic pulldown
		$stmt="SELECT list_id,list_name from vicidial_lists where campaign_id='$campaign_id' $LOGallowed_campaignsSQL order by list_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$mixlists_to_print = mysqli_num_rows($rslt);
		$mixlists_list="";

		$o=0;
		while ($mixlists_to_print > $o)
			{
			$rowx=mysqli_fetch_row($rslt);
			$mixlists_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$mixlistsname_list["$rowx[0]"] = "$rowx[1]";
			$o++;
			}


		echo "<br><br><b>"._QXZ("LIST MIXES FOR THIS CAMPAIGN").": &nbsp; $NWB#campaigns-list_order_mix$NWE</b><br>\n";

		echo "<br><b>"._QXZ("WARNING, we only recommend List Mix for advanced users, Please read the Manager Manual")."</b><br>\n";

		$stmt="SELECT dial_statuses from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$statuses = mysqli_num_rows($rslt);
		if ($statuses > 0) 
			{
			$rowy=mysqli_fetch_row($rslt);
			$LMdial_statuses=$rowy[0];
			}

		$stmt="SELECT vcl_id,vcl_name,campaign_id,list_mix_container,mix_method,status from vicidial_campaigns_list_mix where campaign_id='$campaign_id' $LOGallowed_campaignsSQL order by status, vcl_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$listmixes = mysqli_num_rows($rslt);
		$o=0;
		while ($listmixes > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$vcl_id=$rowx[0];
			$o++;

			if ($o < 2)
				{$tablecolor='bgcolor="#'. $SSalt_row2_background .'"';   $bgcolor='bgcolor="#'. $SSalt_row2_background .'"';}
			else
				{
				if (preg_match('/1$|3$|5$|7$|9$/i', $o))
					{$tablecolor='bgcolor="#'. $SSstd_row2_background .'"';   $bgcolor='bgcolor="#'. $SSstd_row1_background .'"';} 
				else
					{$tablecolor='bgcolor="#'. $SSstd_row1_background .'"';   $bgcolor='bgcolor="#'. $SSstd_row2_background .'"';}
				}
			echo "<a name=\"LINK_$vcl_id\"><BR>\n";
			echo "<span id=\"LISTMIX$US$vcl_id$US$o\">";
			echo "<TABLE width=740 cellspacing=3 $tablecolor>\n";
			echo "<tr><td colspan=6>\n";
			echo "<form action=\"$PHP_SELF#LINK_$vcl_id\" method=POST name=$vcl_id id=$vcl_id>\n";
			echo "<input type=hidden name=ADD value=49>\n";
			echo "<input type=hidden name=SUB value=29>\n";
			echo "<input type=hidden name=stage value=\"MODIFY\">\n";
			echo "<input type=hidden name=vcl_id value=\"$vcl_id\">\n";
			echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
			echo "<input type=hidden name=list_mix_container$US$vcl_id id=list_mix_container$US$vcl_id value=\"\">\n";
			echo "<B>$vcl_id:</B>\n";
			echo "<input type=text size=40 maxlength=50 name=vcl_name$US$vcl_id id=vcl_name$US$vcl_id value=\"$rowx[1]\">\n";
			echo " &nbsp; &nbsp; <a href=\"$PHP_SELF?ADD=49&SUB=29&stage=DELMIX&campaign_id=$campaign_id&vcl_id=$vcl_id\">"._QXZ("DELETE LIST MIX")."</a></td></tr>\n";
			echo "<tr><td colspan=3>"._QXZ("Status").": \n";
			if ($rowx[5]=='INACTIVE')
				{
				echo "<B>"._QXZ("$rowx[5]")."</B>\n";
				echo "<a href=\"$PHP_SELF?ADD=49&SUB=29&stage=SETACTIVE&campaign_id=$campaign_id&vcl_id=$vcl_id\"><font size=1>"._QXZ("SET TO ACTIVE")."</font></a></td>\n";
				}
			else
				{echo "<B>"._QXZ("$rowx[5]")."</B></td>\n";}
			echo "<td colspan=3>"._QXZ("Method").":\n";
			echo "<select size=1 name=mix_method$US$vcl_id id=method$US$vcl_id><option value=\"EVEN_MIX\">"._QXZ("EVEN_MIX")."</option><option value=\"IN_ORDER\">"._QXZ("IN_ORDER")."</option><option value=\"RANDOM\">"._QXZ("RANDOM")."</option><option value='$rowx[4]' SELECTED value=\"$rowx[4]\">"._QXZ("$rowx[4]")."</option></select></td></tr>\n";
			echo "<tr><td>"._QXZ("LIST ID")."</td><td>"._QXZ("PRIORITY")."</td><td>"._QXZ("% MIX")."</td><td>"._QXZ("STATUSES")."</td><td>"._QXZ("")."</td></tr>\n";

# list_id|order|percent|statuses|:list_id|order|percent|statuses|:...
# 101|1|40| A B NA -|:102|2|25| NEW -|:103|3|30| DROP CALLBK -|:101|4|5| DROP -|
# INSERT INTO vicidial_campaigns_list_mix values('TESTMIX','TESTCAMP List Mix','TESTCAMP','101|1|40| A B NA -|:102|2|25| NEW -|:103|3|30| DROP CALLBK -|:101|4|5| DROP -|','IN_ORDER','ACTIVE');
# INSERT INTO vicidial_campaigns_list_mix values('TESTMIX2','TESTCAMP List Mix2','TESTCAMP','101|1|20| A B -|:102|2|45| NEW -|:103|3|30| DROP CALLBK -|:101|4|5| DROP -|','IN_ORDER','ACTIVE');
# INSERT INTO vicidial_campaigns_list_mix values('TESTMIX3','TESTCAMP List Mix3','TESTCAMP','101|1|30| A NA -|:102|2|35| NEW -|:103|3|30| DROP CALLBK -|:101|4|5| DROP -|','IN_ORDER','ACTIVE');

			$MIXentries = $MT;
			$MIXentries = explode(":", $rowx[3]);
			$Ms_to_print = (count($MIXentries) - 0);
			$q=0;
			while ($Ms_to_print > $q) 
				{
				$MIXdetails = explode('|', $MIXentries[$q]);
				$MIXdetailsLIST = $MIXdetails[0];

				$dial_statuses = preg_replace("/ -$/","",$dial_statuses);
				$Dstatuses = explode(" ", $dial_statuses);
				$Ds_to_print = (count($Dstatuses) - 0);
				$Dsql = '';
				$r=0;
				while ($Ds_to_print > $r) 
					{
					$r++;
					$Dsql .= "'$Dstatuses[$r]',";
					}
				$Dsql = preg_replace("/,$/","",$Dsql);

				echo "<tr $bgcolor><td NOWRAP><font size=3>\n";
				echo "<input type=hidden name=list_id$US$q$US$vcl_id id=list_id$US$q$US$vcl_id value=$MIXdetailsLIST>\n";
				echo "<a href=\"$PHP_SELF?ADD=311&list_id=$MIXdetailsLIST\">"._QXZ("List")."</a>: $MIXdetailsLIST &nbsp; <font size=1><a href=\"$PHP_SELF?ADD=49&SUB=29&stage=REMOVE&campaign_id=$campaign_id&vcl_id=$vcl_id&mix_container_item=$q&list_id=$MIXdetailsLIST#LINK_$vcl_id\">"._QXZ("REMOVE")."</a></font></td>\n";

				echo "<td><select size=1 name=priority$US$q$US$vcl_id id=priority$US$q$US$vcl_id>\n";
				$n=40;
				while ($n>=1)
					{
					echo "<option value=\"$n\">$n</option>\n";
					$n = ($n-1);
					}
				echo "<option SELECTED value=\"$MIXdetails[1]\">$MIXdetails[1]</option></select></td>\n";

				echo "<td><select size=1 name=\"percentage$US$q$US$vcl_id\" id=\"percentage$US$q$US$vcl_id\" onChange=\"mod_mix_percent('$vcl_id','$Ms_to_print')\">\n";
				$n=100;
				while ($n>=0)
					{
					echo "<option value=\"$n\">$n</option>\n";
					$n = ($n-1);
					}
				echo "<option SELECTED value=\"$MIXdetails[2]\">$MIXdetails[2]</option></select></td>\n";

				
				echo "<td><input type=hidden name=status$US$q$US$vcl_id id=status$US$q$US$vcl_id value=\"$MIXdetails[3]\"><input type=text size=20 maxlength=255 name=ROstatus$US$q$US$vcl_id id=ROstatus$US$q$US$vcl_id value=\"$MIXdetails[3]\" READONLY></td>\n";
				echo "<td NOWRAP>\n";



				echo "<select size=1 name=dial_status$US$q$US$vcl_id id=dial_status$US$q$US$vcl_id>\n";
				echo "<option value=\"\"> - "._QXZ("Select A Status")." - </option>\n";

				echo "$dial_statuses_list";
				echo "</select> <font size=2><B>\n";
				echo "<a href=\"#\" onclick=\"mod_mix_status('ADD','$vcl_id','$q');return false;\">"._QXZ("ADD")."</a> &nbsp; \n";
				echo "<a href=\"#\" onclick=\"mod_mix_status('REMOVE','$vcl_id','$q');return false;\">"._QXZ("REMOVE")."</a>\n";
				echo "</font></B></td></tr>\n";


				echo "</td></tr>\n";


				$q++;

				}



			
			echo "<tr $bgcolor><td colspan=3 align=right><font size=2>\n";
			echo _QXZ("Difference")." %: <input type=text size=4 name=PCT_DIFF_$vcl_id id=PCT_DIFF_$vcl_id value=0 readonly>\n";
			echo "</td>\n";

			echo "<td colspan=2><input style='background-color:#$SSbutton_color' type=button name=submit_$vcl_id id=submit_$vcl_id value=\""._QXZ("SUBMIT")."\" onClick=\"submit_mix('$vcl_id','$Ms_to_print')\"> &nbsp; \n";
			echo "<span id=ERROR_$vcl_id></span>\n";
			echo "</form></td></tr>\n";


			echo "<tr $bgcolor><td colspan=3 align=center VALIGN=BOTTOM><font size=2>\n";
			echo "<form action=\"$PHP_SELF#LINK_$vcl_id\" method=POST name=ADD_$vcl_id id=ADD_$vcl_id>\n";
			echo "<input type=hidden name=ADD value=49>\n";
			echo "<input type=hidden name=SUB value=29>\n";
			echo "<input type=hidden name=stage value=\"ADD\">\n";
			echo "<input type=hidden name=vcl_id value=\"$vcl_id\">\n";
			echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
			echo _QXZ("List").": <select size=1 name=list_id>\n";
			echo "$mixlists_list";
			echo "<option selected value=\"\">"._QXZ("ADD ANOTHER ENTRY")."</option>\n";
			echo "</select>\n";
			
			if ($q > 39) {$AE_disabled = 'DISABLED';}
			else {$AE_disabled = '';}
			echo "<input style='background-color:#$SSbutton_color' type=submit name=submit value=\""._QXZ("ADD ENTRY")."\" $AE_disabled>\n";
			echo "</form></td>\n";

			$X='X';
			echo "<td NOWRAP VALIGN=BOTTOM>\n";
			echo "<form action=\"$PHP_SELF#LINK_$vcl_id\" method=POST name=DEFAULT_$vcl_id id=DEFAULT_$vcl_id>\n";
			echo "<input type=hidden name=status$US$X$US$vcl_id id=status$US$X$US$vcl_id value=\"\"><input type=text size=20 maxlength=255 name=ROstatus$US$X$US$vcl_id id=ROstatus$US$X$US$vcl_id value=\"$LMdial_statuses\" READONLY>\n";
			echo "<BR><font size=2><B>"._QXZ("CHANGE").": \n";
			echo "<a href=\"#\" onclick=\"mod_mix_status('ALL','$vcl_id','$q');return false;\">"._QXZ("ALL")."</a> &nbsp; \n";
			echo "<a href=\"#\" onclick=\"mod_mix_status('EMPTY','$vcl_id','$q');return false;\">"._QXZ("EMPTY")."</a>\n";
			echo "</td><td NOWRAP VALIGN=MIDDLE>\n";
			echo "<select size=1 name=dial_status$US$X$US$vcl_id id=dial_status$US$X$US$vcl_id>\n";
			echo "<option value=\"\"> - "._QXZ("Select A Status")." - </option>\n";
			echo "$dial_statuses_list";
			echo "</select> <font size=2><B>\n";
			echo "<a href=\"#\" onclick=\"mod_mix_status('ADD','$vcl_id','X');return false;\">"._QXZ("ADD")."</a> &nbsp; \n";
			echo "<a href=\"#\" onclick=\"mod_mix_status('REMOVE','$vcl_id','X');return false;\">"._QXZ("REMOVE")."</a>\n";
			echo "</form></td></tr>\n";
			echo "</table></span>\n";
			}


		echo "<br><br><B>"._QXZ("ADD NEW LIST MIX")."</B><BR><form action=$PHP_SELF method=POST>\n";
		echo "<table border=0>\n";
		echo "<tr $bgcolor><td><form action=\"$PHP_SELF#LINK_$vcl_id\" method=POST>\n";
		echo "<input type=hidden name=ADD value=49>\n";
		echo "<input type=hidden name=SUB value=29>\n";
		echo "<input type=hidden name=stage value=\"NEWMIX\">\n";
		echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
		echo _QXZ("Mix ID").": <input type=text size=20 maxlength=20 name=vcl_id value=\"\"></td>\n";
		echo "<td>"._QXZ("Mix Name").": <input type=text size=30 maxlength=50 name=vcl_name value=\"\"></td>\n";
		echo "<td>"._QXZ("Mix Method").": ";
		echo "<select size=1 name=mix_method><option value=\"EVEN_MIX\">"._QXZ("EVEN_MIX")."</option><option value=\"IN_ORDER\">"._QXZ("IN_ORDER")."</option><option value=\"RANDOM\">"._QXZ("RANDOM")."</option></select></td></tr>\n";
		echo "<tr $bgcolor><td>"._QXZ("List").": <select size=1 name=list_id>\n";
		echo "$mixlists_list";
		echo "</select></td>\n";
		echo "<td>"._QXZ("Dial Status").": <select size=1 name=status>\n";
		echo "$dial_statuses_list";
		echo "</select></td>\n";
		echo "<td> &nbsp; <input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'></form></td>\n";
		echo "</tr>\n";
		echo "</table>\n";

		echo "<br>\n";

		}
	}
	echo "</TD></TR></TABLE></center>\n";
}


######################
# ADD=30 campaign not allowed
######################
if ($ADD==30)
	{
	echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
	echo _QXZ("You do not have permission to view campaign")." $campaign_id\n";
	}


######################
# ADD=32 display all campaign statuses
######################
if ($ADD==32)
	{
	echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	echo "<br>"._QXZ("CUSTOM CAMPAIGN STATUSES LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr>\n";
	echo "<td><B>"._QXZ("CAMPAIGN")."</B></td>\n";
	echo "<td><B>"._QXZ("NAME")."</B></td>\n";
	echo "<td><B>"._QXZ("STATUSES")."</B></td>\n";
	echo "<td><B>"._QXZ("MODIFY")."</B></td>\n";
	echo "</tr>\n";

		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campaigns_to_print = mysqli_num_rows($rslt);

		$o=0;
		while ($campaigns_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			$campaigns_id_list[$o] = $row[0];
			$campaigns_name_list[$o] = $row[1];
			$o++;
			}

		$o=0;
		while ($campaigns_to_print > $o) 
			{
			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='class="records_list_x"';} 
			else
				{$bgcolor='class="records_list_y"';}
			echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=31&SUB=22&campaign_id=$campaigns_id_list[$o]'\"";} echo "><td><font size=1><a href=\"$PHP_SELF?ADD=31&SUB=22&campaign_id=$campaigns_id_list[$o]\">$campaigns_id_list[$o]</a></td>";
			echo "<td><font size=1> $campaigns_name_list[$o] </td>";
			echo "<td><font size=1> ";

			$stmt="SELECT status from vicidial_campaign_statuses where campaign_id='$campaigns_id_list[$o]' $LOGallowed_campaignsSQL order by status;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$campstatus_to_print = mysqli_num_rows($rslt);
			$p=0;
			while ( ($campstatus_to_print > $p) and ($p < 10) )
				{
				$row=mysqli_fetch_row($rslt);
				echo "$row[0] ";
				$p++;
				}
			if ($p<1) 
				{echo "<font color=grey><DEL>"._QXZ("NONE")."</DEL></font>";}
			echo "</td>";
			echo "<td><font size=1><a href=\"$PHP_SELF?ADD=31&SUB=22&campaign_id=$campaigns_id_list[$o]\">"._QXZ("MODIFY STATUSES")."</a></td></tr>\n";
			$o++;
			}

	echo "</TABLE></center>\n";
	}


######################
# ADD=33 display all campaign hotkeys
######################
if ($ADD==33)
	{
	echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	echo "<br>"._QXZ("CAMPAIGN HOTKEYS LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr>\n";
	echo "<td><B>"._QXZ("CAMPAIGN")."</B></td>\n";
	echo "<td><B>"._QXZ("NAME")."</B></td>\n";
	echo "<td><B>"._QXZ("HOTKEYS")."</B></td>\n";
	echo "<td><B>"._QXZ("MODIFY")."</B></td>\n";
	echo "</tr>\n";

		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campaigns_to_print = mysqli_num_rows($rslt);

		$o=0;
		while ($campaigns_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			$campaigns_id_list[$o] = $row[0];
			$campaigns_name_list[$o] = $row[1];
			$o++;
			}

		$o=0;
		while ($campaigns_to_print > $o) 
			{
			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='class="records_list_x"';} 
			else
				{$bgcolor='class="records_list_y"';}
			echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=31&SUB=23&campaign_id=$campaigns_id_list[$o]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=31&SUB=23&campaign_id=$campaigns_id_list[$o]\"><font size=1 color=black>$campaigns_id_list[$o]</a></td>";
			echo "<td><font size=1> $campaigns_name_list[$o] </td>";
			echo "<td><font size=1> ";

			$stmt="SELECT status from vicidial_campaign_hotkeys where campaign_id='$campaigns_id_list[$o]' $LOGallowed_campaignsSQL order by hotkey;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$campstatus_to_print = mysqli_num_rows($rslt);
			$p=0;
			while ( ($campstatus_to_print > $p) and ($p < 10) )
				{
				$row=mysqli_fetch_row($rslt);
				echo "$row[0] ";
				$p++;
				}
			if ($p<1) 
				{echo "<font color=grey><DEL>"._QXZ("NONE")."</DEL></font>";}
			echo "</td>";
			echo "<td><font size=1><a href=\"$PHP_SELF?ADD=31&SUB=23&campaign_id=$campaigns_id_list[$o]\">"._QXZ("MODIFY HOTKEYS")."</a></td></tr>\n";
			$o++;
			}

	echo "</TABLE></center>\n";
	}


######################
# ADD=35 display all campaign lead recycle entries
######################
if ($ADD==35)
	{
	echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	echo "<br>"._QXZ("CAMPAIGN LEAD RECYCLE LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr>\n";
	echo "<td><B>"._QXZ("CAMPAIGN")."</B></td>\n";
	echo "<td><B>"._QXZ("NAME")."</B></td>\n";
	echo "<td><B>"._QXZ("LEAD RECYCLES")."</B></td>\n";
	echo "<td><B>"._QXZ("MODIFY")."</B></td>\n";
	echo "</tr>\n";

		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campaigns_to_print = mysqli_num_rows($rslt);

		$o=0;
		while ($campaigns_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			$campaigns_id_list[$o] = $row[0];
			$campaigns_name_list[$o] = $row[1];
			$o++;
			}

		$o=0;
		while ($campaigns_to_print > $o) 
			{
			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='class="records_list_x"';} 
			else
				{$bgcolor='class="records_list_y"';}
			echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=31&SUB=25&campaign_id=$campaigns_id_list[$o]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=31&SUB=25&campaign_id=$campaigns_id_list[$o]\"><font size=1 color=black>$campaigns_id_list[$o]</a></td>";
			echo "<td><font size=1> $campaigns_name_list[$o] </td>";
			echo "<td><font size=1> ";

			$stmt="SELECT status from vicidial_lead_recycle where campaign_id='$campaigns_id_list[$o]' $LOGallowed_campaignsSQL order by status;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$campstatus_to_print = mysqli_num_rows($rslt);
			$p=0;
			while ( ($campstatus_to_print > $p) and ($p < 10) )
				{
				$row=mysqli_fetch_row($rslt);
				echo "$row[0] ";
				$p++;
				}
			if ($p<1) 
				{echo "<font color=grey><DEL>"._QXZ("NONE")."</DEL></font>";}
			echo "</td>";
			echo "<td><font size=1><a href=\"$PHP_SELF?ADD=31&SUB=25&campaign_id=$campaigns_id_list[$o]\">"._QXZ("MODIFY LEAD RECYCLES")."</a></td></tr>\n";
			$o++;
			}

	echo "</TABLE></center>\n";
	}


######################
# ADD=36 display all campaign auto-alt dial entries
######################
if ($ADD==36)
	{
	echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	echo "<br>"._QXZ("CAMPAIGN LEAD AUTO-ALT DIAL LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr>\n";
	echo "<td><B>"._QXZ("CAMPAIGN")."</B></td>\n";
	echo "<td><B>"._QXZ("NAME")."</B></td>\n";
	echo "<td><B>"._QXZ("AUTO-ALT DIAL")."</B></td>\n";
	echo "<td><B>"._QXZ("MODIFY")."</B></td>\n";
	echo "</tr>\n";

		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campaigns_to_print = mysqli_num_rows($rslt);

		$o=0;
		while ($campaigns_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			$campaigns_id_list[$o] = $row[0];
			$campaigns_name_list[$o] = $row[1];
			$o++;
			}

		$o=0;
		while ($campaigns_to_print > $o) 
			{
			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='class="records_list_x"';} 
			else
				{$bgcolor='class="records_list_y"';}
			echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=31&SUB=26&campaign_id=$campaigns_id_list[$o]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=31&SUB=26&campaign_id=$campaigns_id_list[$o]\"><font size=1 color=black>$campaigns_id_list[$o]</a></td>";
			echo "<td><font size=1> $campaigns_name_list[$o] </td>";
			echo "<td><font size=1> ";

			$stmt="SELECT auto_alt_dial_statuses from vicidial_campaigns where campaign_id='$campaigns_id_list[$o]' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$campstatus_to_print = mysqli_num_rows($rslt);
			$p=0;
			while ( ($campstatus_to_print > $p) and ($p < 10) )
				{
				$row=mysqli_fetch_row($rslt);
				echo "$row[0] ";
				$p++;
				}
			if (strlen($row[0])<3) 
				{echo "<font color=grey><DEL>"._QXZ("NONE")."</DEL></font>";}
			echo "</td>";
			echo "<td><font size=1><a href=\"$PHP_SELF?ADD=31&SUB=26&campaign_id=$campaigns_id_list[$o]\">"._QXZ("MODIFY AUTO-ALT DIAL")."</a></td></tr>\n";
			$o++;
			}

	echo "</TABLE></center>\n";
	}


######################
# ADD=37 display all campaign agent pause codes
######################
if ($ADD==37)
	{
	echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	echo "<br>"._QXZ("CAMPAIGN AGENT PAUSE CODE LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr>\n";
	echo "<td><B>"._QXZ("CAMPAIGN")."</B></td>\n";
	echo "<td><B>"._QXZ("NAME")."</B></td>\n";
	echo "<td><B>"._QXZ("PAUSE CODES")."</B></td>\n";
	echo "<td><B>"._QXZ("MODIFY")."</B></td>\n";
	echo "</tr>\n";

		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campaigns_to_print = mysqli_num_rows($rslt);

		$o=0;
		while ($campaigns_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			$campaigns_id_list[$o] = $row[0];
			$campaigns_name_list[$o] = $row[1];
			$o++;
			}

		$o=0;
		while ($campaigns_to_print > $o) 
			{
			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='class="records_list_x"';} 
			else
				{$bgcolor='class="records_list_y"';}
			echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=31&SUB=27&campaign_id=$campaigns_id_list[$o]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=31&SUB=27&campaign_id=$campaigns_id_list[$o]\"><font size=1 color=black>$campaigns_id_list[$o]</a></td>";
			echo "<td><font size=1> $campaigns_name_list[$o] </td>";
			echo "<td><font size=1> ";

			$stmt="SELECT pause_code from vicidial_pause_codes where campaign_id='$campaigns_id_list[$o]' $LOGallowed_campaignsSQL order by pause_code;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$campstatus_to_print = mysqli_num_rows($rslt);
			$p=0;
			while ( ($campstatus_to_print > $p) and ($p < 10) )
				{
				$row=mysqli_fetch_row($rslt);
				echo "$row[0] ";
				$p++;
				}
			if ($p<1) 
				{echo "<font color=grey><DEL>"._QXZ("NONE")."</DEL></font>";}
			echo "</td>";
			echo "<td><font size=1><a href=\"$PHP_SELF?ADD=31&SUB=27&campaign_id=$campaigns_id_list[$o]\">"._QXZ("MODIFY PAUSE CODES")."</a></td></tr>\n";
			$o++;
			}

	echo "</TABLE></center>\n";
	}


######################
# ADD=39 display all campaign list mixes
######################
if ($ADD==39)
	{
	echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	echo "<br>"._QXZ("CAMPAIGN LIST MIX LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr>\n";
	echo "<td><B>"._QXZ("CAMPAIGN")."</B></td>\n";
	echo "<td><B>"._QXZ("NAME")."</B></td>\n";
	echo "<td><B>"._QXZ("LIST MIX")."</B></td>\n";
	echo "<td><B>"._QXZ("MODIFY")."</B></td>\n";
	echo "</tr>\n";

		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campaigns_to_print = mysqli_num_rows($rslt);

		$o=0;
		while ($campaigns_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			$campaigns_id_list[$o] = $row[0];
			$campaigns_name_list[$o] = $row[1];
			$o++;
			}

		$o=0;
		while ($campaigns_to_print > $o) 
			{
			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='class="records_list_x"';} 
			else
				{$bgcolor='class="records_list_y"';}
			echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=31&SUB=29&campaign_id=$campaigns_id_list[$o]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=31&SUB=29&campaign_id=$campaigns_id_list[$o]\"><font size=1 color=black>$campaigns_id_list[$o]</a></td>";
			echo "<td><font size=1> $campaigns_name_list[$o] </td>";
			echo "<td><font size=1> ";

			$stmt="SELECT vcl_id from vicidial_campaigns_list_mix where campaign_id='$campaigns_id_list[$o]' $LOGallowed_campaignsSQL order by status,vcl_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$campstatus_to_print = mysqli_num_rows($rslt);
			$p=0;
			while ( ($campstatus_to_print > $p) and ($p < 10) )
				{
				$row=mysqli_fetch_row($rslt);
				echo "$row[0] ";
				$p++;
				}
			if ($p<1) 
				{echo "<font color=grey><DEL>"._QXZ("NONE")."</DEL></font>";}
			echo "</td>";
			echo "<td><font size=1><a href=\"$PHP_SELF?ADD=31&SUB=29&campaign_id=$campaigns_id_list[$o]\">"._QXZ("MODIFY LIST MIX")."</a></td></tr>\n";
			$o++;
			}

	echo "</TABLE></center>\n";
	}


######################
# ADD=301 display all campaign presets
######################
if ($ADD==301)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	echo "<br>"._QXZ("CAMPAIGN PRESET LISTINGS").":\n";
	echo "<center><TABLE width=900 cellspacing=0 cellpadding=1>\n";
	echo "<tr>\n";
	echo "<td><B>"._QXZ("CAMPAIGN")."</B></td>\n";
	echo "<td><B>"._QXZ("NAME")."</B></td>\n";
	echo "<td><B>"._QXZ("PRESETS")."</B></td>\n";
	echo "<td><B>"._QXZ("MODIFY")."</B></td>\n";
	echo "</tr>\n";

	$stmt="SELECT campaign_id,campaign_name,enable_xfer_presets from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$campaigns_to_print = mysqli_num_rows($rslt);
	if ($DB > 0) {echo "DEBUG: |$campaigns_to_print|$stmt|\n";}
	$o=0;
	while ($campaigns_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		$campaigns_id_list[$o] =		$row[0];
		$campaigns_name_list[$o] =		$row[1];
		$enable_xfer_presets_list[$o] = $row[2];
		$o++;
		}

	$o=0;
	$k=0;
	while ($campaigns_to_print > $o) 
		{
		if ( ($enable_xfer_presets_list[$o] == 'ENABLED') or ($enable_xfer_presets_list[$o] == 'STAGING') )
			{
			if (preg_match('/1$|3$|5$|7$|9$/i', $k))
				{$bgcolor='class="records_list_x"';} 
			else
				{$bgcolor='class="records_list_y"';}
			echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=31&SUB=201&campaign_id=$campaigns_id_list[$o]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=31&SUB=201&campaign_id=$campaigns_id_list[$o]\"><font size=1 color=black>$campaigns_id_list[$o]</a></td>";
			echo "<td><font size=1> $campaigns_name_list[$o] </td>";
			echo "<td><font size=1> ";

			$stmt="SELECT preset_name from vicidial_xfer_presets where campaign_id='$campaigns_id_list[$o]' $LOGallowed_campaignsSQL order by preset_name;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$campstatus_to_print = mysqli_num_rows($rslt);
			$p=0;
			while ( ($campstatus_to_print > $p) and ($p < 10) )
				{
				$row=mysqli_fetch_row($rslt);
				echo "$row[0] ";
				$p++;
				}
			if ($p<1) 
				{echo "<font color=grey><DEL>"._QXZ("NONE")."</DEL></font>";}
			echo "</td>";
			echo "<td><font size=1><a href=\"$PHP_SELF?ADD=31&SUB=201&campaign_id=$campaigns_id_list[$o]\">"._QXZ("MODIFY PRESETS")."</a></td></tr>\n";

			$k++;
			}
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=302 display campaign areacode cid counts
######################
if ($ADD==302)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	echo "<br>"._QXZ("CAMPAIGN AREACODE CID LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr>\n";
	echo "<td><B>"._QXZ("CAMPAIGN")."</B></td>\n";
	echo "<td><B>"._QXZ("NAME")."</B></td>\n";
	echo "<td><B>"._QXZ("CUSTOM CID")."</B></td>\n";
	echo "<td><B>"._QXZ("AC-CIDS")."</B></td>\n";
	echo "<td><B>"._QXZ("MODIFY")."</B></td>\n";
	echo "</tr>\n";

	$stmt="SELECT campaign_id,campaign_name,use_custom_cid from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$campaigns_to_print = mysqli_num_rows($rslt);

	$o=0;
	while ($campaigns_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		$campaigns_id_list[$o] =	$row[0];
		$campaigns_name_list[$o] =	$row[1];
		$use_custom_cid_list[$o] =	$row[2];
		$o++;
		}

	$o=0;
	$k=0;
	while ($campaigns_to_print > $o) 
		{
		if (preg_match('/1$|3$|5$|7$|9$/i', $k))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=31&SUB=202&campaign_id=$campaigns_id_list[$o]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=31&SUB=202&campaign_id=$campaigns_id_list[$o]\"><font size=1 color=black>$campaigns_id_list[$o]</a></td>";
		echo "<td><font size=1> $campaigns_name_list[$o] </td>";
		echo "<td><font size=1> "._QXZ("$use_custom_cid_list[$o]")." </td>";
		echo "<td><font size=1> ";

		$stmt="SELECT count(*) from vicidial_campaign_cid_areacodes where campaign_id='$campaigns_id_list[$o]' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campstatus_to_print = mysqli_num_rows($rslt);
		$p=0;
		while ( ($campstatus_to_print > $p) and ($p < 10) )
			{
			$row=mysqli_fetch_row($rslt);
			echo "$row[0] ";
			$p++;
			}
		echo "</td>";
		echo "<td><font size=1><a href=\"$PHP_SELF?ADD=31&SUB=202&campaign_id=$campaigns_id_list[$o]\">"._QXZ("MODIFY AC-CIDS")."</a></td></tr>\n";

		$k++;
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=311 modify list info in the system
######################
if ($ADD==311)
	{
	if ($LOGmodify_lists==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=311&list_id=$list_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ($SSexpired_lists_inactive > 0)
			{
			$expired_check=0;
			$stmt="SELECT count(*) from vicidial_lists where list_id='$list_id' and expiration_date < \"$REPORTdate\";";
			$rslt=mysql_to_mysqli($stmt, $link);
			$Cexp_to_print = mysqli_num_rows($rslt);
			if ($Cexp_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$expired_check = "$rowx[0]";
				}
			if ($DB) {echo "$expired_check|$stmt|\n";}
			if ($expired_check > 0)
				{
				$stmt = "UPDATE vicidial_lists SET active='N' where list_id='$list_id';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$ELaffected_rows = mysqli_affected_rows($link);
				if ($DB) {echo "|$stmt|\n";}

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='LISTS', event_type='MODIFY', record_id='$list_id', event_code='ADMIN AUTO EXPIRE LIST', event_sql=\"$SQL_log\", event_notes='LIST: $list_id CHANGED: $ELaffected_rows';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);

				echo "<br><b>"._QXZ("NOTICE: expired list set to inactive")."\n";
				}
			}

		$stmt="SELECT vicidial_lists.list_id,list_name,campaign_id,active,list_description,list_changedate,list_lastcalldate,reset_time,agent_script_override,campaign_cid_override,am_message_exten_override,drop_inbound_group_override,xferconf_a_number,xferconf_b_number,xferconf_c_number,xferconf_d_number,xferconf_e_number,web_form_address,web_form_address_two,time_zone_setting,inventory_report,IFNULL(audit_comments,0),expiration_date,DATE_FORMAT(expiration_date,'%Y%m%d'),na_call_url,local_call_time,web_form_address_three,status_group_id,user_new_lead_limit,inbound_list_script_override,default_xfer_group,daily_reset_limit,resets_today,auto_active_list_rank,inbound_drop_voicemail,inbound_after_hours_voicemail,qc_scorecard_id,qc_statuses_id,qc_web_form_address,auto_alt_threshold,cid_group_id,dial_prefix,weekday_resets_container from vicidial_lists left outer join vicidial_lists_custom on vicidial_lists.list_id=vicidial_lists_custom.list_id where vicidial_lists.list_id='$list_id' $LOGallowed_campaignsSQL;";

		$rslt=mysql_to_mysqli($stmt, $link);
                if ($DB) {echo "$stmt\n";}
		$row=mysqli_fetch_row($rslt);
		$list_name =				$row[1];
		$campaign_id =				$row[2];
		$active =					$row[3];
		$list_description =			$row[4];
		$list_changedate =			$row[5];
		$list_lastcalldate =		$row[6];
		$reset_time =				$row[7];
		$agent_script_override =	$row[8];
		$campaign_cid_override =	$row[9];
		$am_message_exten_override =	$row[10];
		$drop_inbound_group_override =	$row[11];
		$xferconf_a_number =		$row[12];
		$xferconf_b_number =		$row[13];
		$xferconf_c_number =		$row[14];
		$xferconf_d_number =		$row[15];
		$xferconf_e_number =		$row[16];
		$web_form_address =			$row[17];
		$web_form_address_two =		$row[18];
		$time_zone_setting =		$row[19];
		$inventory_report =			$row[20];
		$audit_comments = 			$row[21];
		$expiration_date =			$row[22];
		$expiration_dateINT =		$row[23];
		$na_call_url =				$row[24];
		$list_local_call_time =		$row[25];
		$web_form_address_three =	$row[26];
		$status_group_id =			$row[27];
		$user_new_lead_limit =		$row[28];
		$inbound_list_script_override =		$row[29];
		$default_xfer_group =		$row[30];
		$daily_reset_limit =		$row[31];
		$resets_today =				$row[32];
		$auto_active_list_rank =	$row[33];
		$inbound_drop_voicemail =	$row[34];
		$inbound_after_hours_voicemail =	$row[35];
		$qc_scorecard_id =			$row[36];
		$qc_statuses_id =			$row[37];
		$qc_web_form_address =		$row[38];
		$auto_alt_threshold =		$row[39];
		$cid_group_id =				$row[40];
		$dial_prefix =				$row[41];
		$weekday_resets_container = $row[42];

		# grab names of global statuses and statuses in the selected campaign
		$stmt="SELECT status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable,scheduled_callback,completed,min_sec,max_sec,answering_machine from vicidial_statuses order by status;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$statuses_to_print = mysqli_num_rows($rslt);

		$o=0;
		while ($statuses_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$statuses_list["$rowx[0]"] = "$rowx[1]";
			$statuses_complete_list["$rowx[0]"] = "$rowx[11]";
			$o++;
			}

		$stmt="SELECT status,status_name,selectable,campaign_id,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable,scheduled_callback,completed,min_sec,max_sec,answering_machine from vicidial_campaign_statuses where campaign_id='$campaign_id' $LOGallowed_campaignsSQL order by status;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$Cstatuses_to_print = mysqli_num_rows($rslt);

		$o=0;
		while ($Cstatuses_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$statuses_list["$rowx[0]"] = "$rowx[1]";
			$statuses_complete_list["$rowx[0]"] = "$rowx[12]";
			$o++;
			}
		# end grab status names

		##### get scripts listings for pulldown
		$Lscripts_list = "<option value=\"\">"._QXZ("NONE - INACTIVE")."</option>\n";
		$stmt="SELECT script_id,script_name from vicidial_scripts $whereLOGadmin_viewable_groupsSQL order by script_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$scripts_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($scripts_to_print > $o)
			{
			$rowx=mysqli_fetch_row($rslt);
			$Lscripts_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$scriptname_list["$rowx[0]"] = "$rowx[1]";
			$o++;
			}

		##### get in-groups listings for dynamic drop in-group pulldown
		$stmt="SELECT group_id,group_name from vicidial_inbound_groups $whereLOGadmin_viewable_groupsSQL order by group_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$Dgroups_to_print = mysqli_num_rows($rslt);
		$Dgroups_menu='';
		$Dgroups_selected=0;
		$o=0;
		while ($Dgroups_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$Dgroups_menu .= "<option ";
			if ($drop_inbound_group_override == "$rowx[0]") 
				{
				$Dgroups_menu .= "SELECTED ";
				$Dgroups_selected++;
				}
			$Dgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		if ($Dgroups_selected < 1) 
			{$Dgroups_menu .= "<option SELECTED value=\"\">---"._QXZ("NONE")."---</option>\n";}
		else 
			{$Dgroups_menu .= "<option value=\"\">---"._QXZ("NONE")."---</option>\n";}


		echo "<br>"._QXZ("MODIFY A LISTS RECORD").": $list_id<form action=$PHP_SELF method=POST name=vicidial_report id=vicidial_report>\n";
		echo "<input type=hidden name=ADD value=411>\n";
		echo "<input type=hidden name=list_id value=\"$list_id\">\n";
		echo "<input type=hidden name=old_campaign_id value=\"$campaign_id\">\n";
		echo "<center><TABLE width=900 cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("List ID").": </td><td align=left><b>$list_id</b>$NWB#lists-list_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("List Name").": </td><td align=left><input type=text name=list_name size=30 maxlength=30 value=\"$list_name\">$NWB#lists-list_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("List Description").": </td><td align=left><input type=text name=list_description size=30 maxlength=255 value=\"$list_description\">$NWB#lists-list_description$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=34&campaign_id=$campaign_id\">"._QXZ("Campaign")."</a>: </td><td align=left><select size=1 name=campaign_id>\n";

		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campaigns_to_print = mysqli_num_rows($rslt);
		$campaigns_list='';
		$camp_list='|';
		$o=0;
		while ($campaigns_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$campaigns_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$camp_list .= "$rowx[0]|";
			$o++;
			}
		echo "$campaigns_list";
		echo "<option SELECTED>$campaign_id</option>\n";
		echo "</select>$NWB#lists-campaign_id$NWE";
		if (!preg_match("/\|$campaign_id\|/",$camp_list))
			{echo "<br> &nbsp; &nbsp; <font color=red><B>"._QXZ("CAMPAIGN DOES NOT EXIST")."</B></font>";}
		echo "</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$active' SELECTED>"._QXZ("$active")."</option></select>$NWB#lists-active$NWE \n";
		if ( ($expiration_dateINT < $EXPtestdate) and ($active == 'Y') )
			{echo " &nbsp; &nbsp; <font color=red><B>"._QXZ("LIST EXPIRED AND SET TO ACTIVE")."</B></font>";}
		echo "</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Reset Lead-Called-Status for this list").": </td><td align=left><select size=1 name=reset_list><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select>$NWB#lists-reset_list$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Reset Times").": </td><td align=left><input type=text name=reset_time size=30 maxlength=100 value=\"$reset_time\">$NWB#lists-reset_time$NWE</td></tr>\n";

		if ($SSweekday_resets > 0)
			{
			##### get container listings for dynamic WEEKDAY_TIMERANGE_SECONDS container pulldown menu
			$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='LIST_WEEKDAY_RESETS' $LOGadmin_viewable_groupsSQL order by container_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$dtlc_to_print = mysqli_num_rows($rslt);
			$weekday_resets_container_menu='';
			$dtlc_selected=0;
			$o=0;
			while ($dtlc_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				if (mb_strlen($rowx[1],'utf-8')>40)
					{$rowx[1] = mb_substr($rowx[1],0,40,'utf-8') . '...';}
				$weekday_resets_container_menu .= "<option ";
				if ($weekday_resets_container == "$rowx[0]") 
					{
					$weekday_resets_container_menu .= "SELECTED ";
					$dtlc_selected++;
					}
				$weekday_resets_container_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$o++;
				}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>";
			if ($dtlc_selected > 0)
				{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$weekday_resets_container\">"._QXZ("Weekday Resets Container")."</a>";}
			else
				{echo _QXZ("Weekday Resets Container");}
			echo ": </td><td align=left nowrap><select size=1 name=weekday_resets_container><option value='DISABLED'>"._QXZ("DISABLED")."</option>$weekday_resets_container_menu</select>$NWB#lists-weekday_resets_container$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td colspan=2><input type=hidden name=weekday_resets_container value=\"$weekday_resets_container\"</td></tr>\n";
			}

		if ($LOGuser_level >= 9)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Daily Reset Limit").": </td><td align=left><input type=text name=daily_reset_limit size=4 maxlength=3 value=\"$daily_reset_limit\"> &nbsp; <i>"._QXZ("Resets Today").":</i> $resets_today &nbsp; $NWB#lists-daily_reset_limit$NWE</td></tr>\n";
			}
		else
			{
			$daily_reset_limitTEXT = $daily_reset_limit;
			if ($daily_reset_limit < 0) {$daily_reset_limitTEXT=_QXZ("none");}
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Daily Reset Limit").": </td><td align=left><input type=hidden name=daily_reset_limit value=\"$daily_reset_limit\">$daily_reset_limitTEXT &nbsp; <i>"._QXZ("Resets Today").":</i> $resets_today &nbsp; $NWB#lists-daily_reset_limit$NWE</td></tr>\n";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Expiration Date").": </td><td align=left><input type=text name=expiration_date size=12 maxlength=10 value=\"$expiration_date\"> \n";
		echo "<script language=\"JavaScript\">\n";
		echo "var o_cal = new tcal ({\n";
		echo "	// form name\n";
		echo "	'formname': 'vicidial_report',\n";
		echo "	// input name\n";
		echo "	'controlname': 'expiration_date'\n";
		echo "});\n";
		echo "o_cal.a_tpl.yearscroll = false;\n";
		echo "// o_cal.a_tpl.weekstart = 1; // Monday week start\n";
		echo "</script> $NWB#lists-expiration_date$NWE \n";
		if ($expiration_dateINT < $EXPtestdate)
			{
			if ($active == 'Y')
				{echo " &nbsp; &nbsp; <font color=red><B>"._QXZ("LIST EXPIRED AND SET TO ACTIVE")."</B></font>";}
			else
				{echo " &nbsp; &nbsp; <font color=red><B>"._QXZ("LIST EXPIRED")."</B></font>";}
			}
		echo "</td></tr>\n";
		
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>";
		if ($list_local_call_time == 'campaign')
			{echo _QXZ("Local Call Time").": ";}
		else
			{echo "<a href=\"$PHP_SELF?ADD=311111111&call_time_id=$list_local_call_time\">"._QXZ("Local Call Time").": </a>";}
		echo "</td><td align=left><select size=1 name=local_call_time>\n";
		
		echo "<option value=\"campaign\">"._QXZ("Campaign - Use Campaign Settings")."</option>\n";
		echo "$call_times_list";
		if($list_local_call_time == "campaign")
			{
			echo "<option selected value=\"campaign\">"._QXZ("Campaign - Use Campaign Settings")."</option>\n";
			} 
		else 
			{
			echo "<option selected value=\"$list_local_call_time\">$list_local_call_time - $call_timename_list[$list_local_call_time]</option>\n";
			}
		echo "</select>$NWB#lists-local_call_time$NWE</td></tr>\n";
		
		if($audit_comments=='1') 
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Audit Comments").": </td><td align=left><select size=1 name=audit_comments><option value='1' selected>"._QXZ("Y")."</option><option value='0'>"._QXZ("N")."</option></select>$NWB#lists-audit_comments$NWE</td></tr>\n";
			} 
		else 
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Audit Comments").": </td><td align=left><select size=1 name=audit_comments><option value='1'>"._QXZ("Y")."</option><option value='0' selected>"._QXZ("N")."</option></select>$NWB#lists-audit_comments$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("List Change Date").": </td><td align=left>$list_changedate &nbsp; $NWB#lists-list_changedate$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("List Last Call Date").": </td><td align=left>$list_lastcalldate &nbsp; $NWB#lists-list_lastcalldate$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right><a href=\"$PHP_SELF?ADD=3111111&script_id=$agent_script_override\">"._QXZ("Agent Script Override")."</a>: </td><td align=left><select size=1 name=agent_script_override>\n";
		echo "$Lscripts_list";
		echo "<option selected value=\"$agent_script_override\">$agent_script_override - $scriptname_list[$agent_script_override]</option>\n";
		echo "</select>$NWB#lists-agent_script_override$NWE</td></tr>\n";
 		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=3111111&script_id=$inbound_list_script_override\">"._QXZ("Inbound Script Override")."</a>: </td><td align=left><select size=1 name=inbound_list_script_override>\n";
 		echo "$Lscripts_list";
 		echo "<option selected value=\"$inbound_list_script_override\">$inbound_list_script_override - $scriptname_list[$inbound_list_script_override]</option>\n";
 		echo "</select>$NWB#lists-inbound_list_script_override$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Inbound Drop Voicemail Override").": </td><td align=left><input type=text name=inbound_drop_voicemail id=inbound_drop_voicemail size=12 maxlength=20 value=\"$inbound_drop_voicemail\"> <a href=\"javascript:launch_vm_chooser('inbound_drop_voicemail','vm');\">"._QXZ("voicemail chooser")."</a>$NWB#lists-inbound_drop_voicemail$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Inbound After Hours Voicemail Override").": </td><td align=left><input type=text name=inbound_after_hours_voicemail id=inbound_after_hours_voicemail size=12 maxlength=20 value=\"$inbound_after_hours_voicemail\"> <a href=\"javascript:launch_vm_chooser('inbound_after_hours_voicemail','vm');\">"._QXZ("voicemail chooser")."</a>$NWB#lists-inbound_after_hours_voicemail$NWE</td></tr>\n";

		$DID_edit_link_BEGIN='';
		$DID_edit_link_END='';
		if (strlen($campaign_cid_override) > 0)
			{
			$stmt="SELECT did_id from vicidial_inbound_dids where did_pattern='$campaign_cid_override' $LOGadmin_viewable_groupsSQL limit 1;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$dids_to_print = mysqli_num_rows($rslt);
			if ($dids_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$DID_edit_link_BEGIN = "<a href=\"$PHP_SELF?ADD=3311&did_id=$rowx[0]\">";
				$DID_edit_link_END='</a>';
				}
			}

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>$DID_edit_link_BEGIN"._QXZ("Campaign CID Override")."$DID_edit_link_END: </td><td align=left><input type=text name=campaign_cid_override size=20 maxlength=20 value=\"$campaign_cid_override\">$NWB#lists-campaign_cid_override$NWE</td></tr>\n";

		if ($SScampaign_cid_areacodes_enabled == '1')
			{
			##### get vicidial_cid_groups listings for dynamic pulldown list
			$stmt="SELECT cid_group_id,cid_group_type,cid_group_notes from vicidial_cid_groups $whereLOGadmin_viewable_groupsSQL order by cid_group_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$cid_groups_to_print = mysqli_num_rows($rslt);
			$cid_groups_menu='';
			$cid_groups_selected=0;
			$o=0;
			while ($cid_groups_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$cid_groups_menu .= "<option ";
				if ($cid_group_id == "$rowx[0]") 
					{
					$cid_groups_menu .= "SELECTED ";
					$cid_groups_selected++;
					}
				$cid_groups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1] - $rowx[2]</option>\n";
				$o++;
				}

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>";
			if ($cid_groups_selected > 0)
				{echo "<a href=\"$PHP_SELF?ADD=396111111111&cid_group_id=$cid_group_id\">"._QXZ("Campaign CID Group Override")."</a>";}
			else
				{echo _QXZ("Campaign CID Group Override");}
			echo ": </td><td align=left><select size=1 name=cid_group_id>";
			echo "<option value=\"---DISABLED---\">---"._QXZ("DISABLED")."---</option>";
			echo "$cid_groups_menu";
			echo "</select>$NWB#lists-cid_group_id$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right><input type=hidden name=cid_group_id value=\"$cid_group_id\"></td></tr>";
			}

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Answering Machine Message Override").": </td><td align=left><input type=text name=am_message_exten_override id=am_message_exten_override size=50 maxlength=100 value=\"$am_message_exten_override\"> <a href=\"javascript:launch_chooser('am_message_exten_override','date');\">"._QXZ("audio chooser")."</a> $NWB#lists-am_message_exten_override$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Drop Inbound Group Override").": </td><td align=left><select size=1 name=drop_inbound_group_override>";
		echo "$Dgroups_menu";
		echo "</select>$NWB#lists-drop_inbound_group_override$NWE</td></tr>\n";

		##### get status group listings for dynamic pulldown menu
		$stmt="SELECT status_group_id,status_group_notes from vicidial_status_groups $whereLOGadmin_viewable_groupsSQL order by status_group_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$status_groups_to_print = mysqli_num_rows($rslt);
		$status_groups_menu='';
		$status_groups_selected=0;
		$o=0;
		while ($status_groups_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$status_groups_menu .= "<option ";
			if ($status_group_id == "$rowx[0]") 
				{
				$status_groups_menu .= "SELECTED ";
				$status_groups_selected++;
				}
			$status_groups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		$sglinkB='';   $sglinkE='';
		if (strlen($status_group_id)>1)
			{
			$sglinkB="<a href=\"$PHP_SELF?ADD=393111111111&status_group_id=$status_group_id\">";
			$sglinkE='</a>';
			}

		##### get in-groups listings for dynamic transfer group pulldown list menu
		$xfer_groupsSQL='';
		$stmt="SELECT closer_campaigns,xfer_groups from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$closer_campaigns =	$row[0];
			$closer_campaigns = preg_replace("/ -$/","",$closer_campaigns);
			$groups = explode(" ", $closer_campaigns);
		$xfer_groups =	$row[1];
			$xfer_groups = preg_replace("/ -$/","",$xfer_groups);
			$XFERgroups = explode(" ", $xfer_groups);
		$xfer_groupsSQL = preg_replace("/^ | -$/","",$xfer_groups);
		$xfer_groupsSQL = preg_replace("/ /","','",$xfer_groupsSQL);
		$xfer_groupsSQL = "WHERE group_id IN('$xfer_groupsSQL')";

		$nxLOGadmin_viewable_groupsSQL = $LOGadmin_viewable_groupsSQL;
		if (strlen($xfer_groupsSQL) < 6)
				{$nxLOGadmin_viewable_groupsSQL = $whereLOGadmin_viewable_groupsSQL;}

		$stmt="SELECT group_id,group_name from vicidial_inbound_groups $xfer_groupsSQL $nxLOGadmin_viewable_groupsSQL order by group_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$Xgroups_to_print = mysqli_num_rows($rslt);
		$Xgroups_menu='';
		$Xgroups_selected=0;
		$o=0;
		while ($Xgroups_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$Xgroups_menu .= "<option ";
			if ($default_xfer_group == "$rowx[0]") 
				{
				$Xgroups_menu .= "SELECTED ";
				$Xgroups_selected++;
				}
			$Xgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		if ($Xgroups_selected < 1) 
			{$Xgroups_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		else 
			{$Xgroups_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}


		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>$sglinkB"._QXZ("Status Group Override")."$sglinkE: </td><td align=left><select size=1 name=status_group_id>";
		echo "<option value=\"\">"._QXZ("NONE")."</option>";
		echo "$status_groups_menu";
		echo "</select>$NWB#lists-status_group_id$NWE</td></tr>\n";

		if ($SSqc_features_active>0)
			{
			##### get QC status container listings for pulldown
			$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='QC_TEMPLATE' order by container_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$containers_to_print = mysqli_num_rows($rslt);
			$QCcontainers_list="<option value=\"\">NONE</option>";
			$o=0;
			while ($containers_to_print > $o)
				{
				$rowx=mysqli_fetch_row($rslt);
				$QCcontainers_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$qc_containers_list["$rowx[0]"] = "$rowx[1]";
				$o++;
				}
			##### get scorecards listings for pulldown
			$stmt="SELECT qc_scorecard_id,scorecard_name from quality_control_scorecards where active='Y' order by qc_scorecard_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$scorecards_to_print = mysqli_num_rows($rslt);
			$QCscorecards_list="<option value=\"\">NONE</option>";
			$o=0;
			while ($scorecards_to_print > $o)
				{
				$rowx=mysqli_fetch_row($rslt);
				$QCscorecards_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$scorecardname_list["$rowx[0]"] = "$rowx[1]";
				$o++;
				}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("QC Statuses").": </td><td align=left><select size=1 name=qc_statuses_id>";
			echo "<option selected value=\"$qc_statuses_id\">".(!$qc_statuses_id ? "NONE" : "$qc_statuses_id - $qc_containers_list[$qc_statuses_id]")."</option>\n";
			echo "$QCcontainers_list";
			echo "</select>$NWB#lists-qc_statuses_id$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("QC Scorecard Override").": </td><td align=left><select size=1 name=qc_scorecard_id>";
			echo "<option selected value=\"$qc_scorecard_id\">".(!$qc_scorecard_id ? "NONE" : "$qc_scorecard_id - $scorecardname_list[$qc_scorecard_id]")."</option>\n";
			echo "$QCscorecards_list";
			echo "</select>$NWB#lists-qc_scorecard_override$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("QC WebForm").": </td><td align=left><input type=text name=qc_web_form_address size=70 maxlength=255 value=\"$qc_web_form_address\">$NWB#lists-qc_web_form_address$NWE</td></tr>\n";

			}

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Web Form").": </td><td align=left><input type=text name=web_form_address size=70 maxlength=9999 value=\"$web_form_address\">$NWB#lists-web_form_address$NWE"; if ($SSenable_first_webform < 1) {echo " <font color=red><b>"._QXZ("DISABLED")."</b></font>";} echo "</td></tr>\n";
		if ($SSenable_second_webform > 0)
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Web Form Two").": </td><td align=left><input type=text name=web_form_address_two size=70 maxlength=9999 value=\"$web_form_address_two\">$NWB#lists-web_form_address$NWE</td></tr>\n";
			}
		if ($SSenable_third_webform > 0)
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Web Form Three").": </td><td align=left><input type=text name=web_form_address_three size=70 maxlength=9999 value=\"$web_form_address_three\">$NWB#lists-web_form_address$NWE</td></tr>\n";
			}

		if ($na_call_url == 'ALT')
			{
			$stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$list_id' and entry_type='list' and url_type='noagent';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$vum_to_print = mysqli_num_rows($rslt);
			if ($vum_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$vum_count = $rowx[0]; 
				}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"admin_url_multi.php?DB=$DB&campaign_id=$list_id&entry_type=list&url_type=noagent\">"._QXZ("No Agent Call URL")."</a>: </td><td align=left><input type=text name=na_call_url size=10 maxlength=5000 value=\"$na_call_url\">$NWB#lists-na_call_url$NWE <a href=\"admin_url_multi.php?DB=$DB&campaign_id=$list_id&entry_type=list&url_type=noagent\"> "._QXZ("Alternate No Agent URLs Defined").": $vum_count</a></td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("No Agent Call URL").": </td><td align=left><input type=text name=na_call_url size=70 maxlength=5000 value=\"$na_call_url\">$NWB#lists-na_call_url$NWE</td></tr>\n";
			}

		$apinewlead_url='';
		$stmt="SELECT url_address from vicidial_url_multi where campaign_id='$list_id' and entry_type='list' and url_type='apinewlead';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$urls_to_print = mysqli_num_rows($rslt);
		if ($urls_to_print > 0) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$apinewlead_url = $rowx[0];
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("API New Lead URL").": </td><td align=left NOWRAP><input type=text size=70 maxlength=5000 name=apinewlead_url value=\"$apinewlead_url\">$NWB#lists-apinewlead_url$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Auto Alt Threshold Override").": </td><td align=left><input type=text name=auto_alt_threshold size=3 maxlength=3 value=\"$auto_alt_threshold\"><i>"._QXZ("number only")."</i> $NWB#lists-auto_alt_threshold$NWE</td></tr>\n";

		if ($LOGmodify_dial_prefix > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Dial Prefix Override").": </td><td align=left><input type=text name=dial_prefix size=4 maxlength=20 value=\"$dial_prefix\"> $NWB#lists-dial_prefix$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><input type=hidden name=dial_prefix value=\"$dial_prefix\"></td></tr>";
			}

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Transfer-Conf Number 1 Override").": </td><td align=left><input type=text name=xferconf_a_number size=20 maxlength=50 value=\"$xferconf_a_number\">$NWB#lists-xferconf_a_dtmf$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Transfer-Conf Number 2 Override").": </td><td align=left><input type=text name=xferconf_b_number size=20 maxlength=50 value=\"$xferconf_b_number\">$NWB#lists-xferconf_a_dtmf$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Transfer-Conf Number 3 Override").": </td><td align=left><input type=text name=xferconf_c_number size=20 maxlength=50 value=\"$xferconf_c_number\">$NWB#lists-xferconf_a_dtmf$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Transfer-Conf Number 4 Override").": </td><td align=left><input type=text name=xferconf_d_number size=20 maxlength=50 value=\"$xferconf_d_number\">$NWB#lists-xferconf_a_dtmf$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Transfer-Conf Number 5 Override").": </td><td align=left><input type=text name=xferconf_e_number size=20 maxlength=50 value=\"$xferconf_e_number\">$NWB#lists-xferconf_a_dtmf$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Default Transfer Group").": </td><td align=left><select size=1 name=default_xfer_group>";
		echo "$Xgroups_menu";
		echo "</select>$NWB#lists-default_xfer_group$NWE</td></tr>\n";

		if ($SSuser_new_lead_limit > 0)
			{
			$stmt="SELECT no_hopper_dialing from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			$no_hopper_dialing =		$row[0];

			$no_hopper_dialing_warning='';
			if ($no_hopper_dialing == 'N') {$no_hopper_dialing_warning=" <font color=red>"._QXZ("CAMPAIGN NO HOPPER DIALING DISABLED")."</font>";}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User New Lead Limit").": </td><td align=left><input type=text name=user_new_lead_limit size=4 maxlength=4 value=\"$user_new_lead_limit\">$NWB#lists-user_new_lead_limit$NWE $no_hopper_dialing_warning &nbsp <a href=\"admin_user_list_new.php?user=---ALL---&list_id=$list_id\">"._QXZ("User Overrides for this list")."</a></td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right colspan=2><input type=hidden name=user_new_lead_limit value=\"$user_new_lead_limit\"></td></tr>\n";
			}

		if ($SScall_quota_lead_ranking > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Auto Active List Rank").": </td><td align=left><input type=text name=auto_active_list_rank size=4 maxlength=4 value=\"$auto_active_list_rank\">$NWB#lists-auto_active_list_rank$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right colspan=2><input type=hidden name=auto_active_list_rank value=\"$auto_active_list_rank\"></td></tr>\n";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Inventory Report").": </td><td align=left><select size=1 name=inventory_report><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$inventory_report' SELECTED>"._QXZ("$inventory_report")."</option></select>$NWB#lists-inventory_report$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Time Zone Setting").": </td><td align=left><select size=1 name=time_zone_setting><option value='COUNTRY_AND_AREA_CODE'>"._QXZ("COUNTRY_AND_AREA_CODE")."</option><option value='POSTAL_CODE'>"._QXZ("POSTAL_CODE")."</option><option value='NANPA_PREFIX'>"._QXZ("NANPA_PREFIX")."</option><option value='OWNER_TIME_ZONE_CODE'>"._QXZ("OWNER_TIME_ZONE_CODE")."</option><option value='$time_zone_setting' SELECTED>"._QXZ("$time_zone_setting")."</option></select>$NWB#lists-time_zone_setting$NWE</td></tr>\n";


		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";

		echo "<center>\n";
		echo "<br><b>"._QXZ("STATUSES WITHIN THIS LIST").":</b><br>\n";

		if ($SSexpanded_list_stats > 0)
			{
			echo "<TABLE width=700 cellspacing=3>\n";
			$dialable_total=0;
			$complete_total=0;
			$fSQL = '';
			$stmt="SELECT dial_statuses,local_call_time,lead_filter_id,drop_lockout_time,call_count_limit from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			$dial_statuses =		$row[0];
			$local_call_time =		$row[1];
			$lead_filter_id =		$row[2];
			$drop_lockout_time =	$row[3];
			$call_count_limit =		$row[4];

			$stmt="SELECT lead_filter_sql from vicidial_lead_filters where lead_filter_id='$lead_filter_id' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$filters_to_print = mysqli_num_rows($rslt);
			if ($filters_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$filterSQL = $rowx[0];
				$filterSQL = preg_replace("/\\\\/","",$filterSQL);
				$filterSQL = preg_replace('/^and|and$|^or|or$/i', '',$filterSQL);
				if (strlen($filterSQL)>4)
					{$fSQL = "and ($filterSQL)";}
				else
					{$fSQL = '';}
				}
			echo "<tr><td>"._QXZ("STATUS")."</td><td>"._QXZ("STATUS NAME")."</td><td>"._QXZ("CALLED")."</td><td>"._QXZ("NOT CALLED")."</td><td>"._QXZ("DIALABLE")."</td><td>"._QXZ("PENETRATION")."</td></tr>\n";
			}
		else
			{
			echo "<TABLE width=500 cellspacing=3>\n";
			echo "<tr><td>"._QXZ("STATUS")."</td><td>"._QXZ("STATUS NAME")."</td><td>"._QXZ("CALLED")."</td><td>"._QXZ("NOT CALLED")."</td></tr>\n";
			}

		$leads_in_list = 0;
		$leads_in_list_N = 0;
		$leads_in_list_Y = 0;
		$stmt="SELECT status,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by status,called_since_last_reset order by status,called_since_last_reset;";
		if ($DB) {echo "$stmt\n";}
		$rslt=mysql_to_mysqli($stmt, $link);
		$statuses_to_print = mysqli_num_rows($rslt);

		$o=0;
		$lead_list['count'] = 0;
		$lead_list['Y_count'] = 0;
		$lead_list['N_count'] = 0;
		while ($statuses_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			
			$lead_list['count'] = ($lead_list['count'] + $rowx[2]);
			if ($rowx[1] == 'N') 
				{
				$since_reset = 'N';
				$since_resetX = 'Y';
				}
			else 
				{
				$since_reset = 'Y';
				$since_resetX = 'N';
				} 
			$lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]);
			$lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]);
			#If opposite side is not set, it may not in the future so give it a value of zero
			if (!isset($lead_list[$since_resetX][$rowx[0]])) 
				{
				$lead_list[$since_resetX][$rowx[0]]=0;
				}
			$o++;
			}
	 
		$o=0;
		if ($lead_list['count'] > 0)
			{
			#while (list($dispo,) = each($lead_list[$since_reset]))
			foreach($lead_list[$since_reset] as $dispo => $blank)
				{
				if (preg_match('/1$|3$|5$|7$|9$/i', $o))
					{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
				else
					{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

				if ($dispo == 'CBHOLD')
					{
					$CLB="<a href=\"$PHP_SELF?ADD=811&list_id=$list_id\">";
					$CLE="</a>";
					}
				else
					{
					$CLB='';
					$CLE='';
					}
				if ($SSexpanded_list_stats > 0)
					{
					### call function to calculate dialable leads
					$single_status=1;
					$only_return=0;
					$dial_statuses=" $dispo -";
					$camp_lists=$list_id;
					if ($statuses_complete_list[$dispo] == 'Y')
						{$Xdialable_count=0;}
					else
						{$Xdialable_count = dialable_leads($DB,$link,$local_call_time,$dial_statuses,$camp_lists,$drop_lockout_time,$call_count_limit,$single_status,$fSQL,$only_return);}
					$dialable_total = ($dialable_total + $Xdialable_count);

					### get number of complete calls of this status for penetration calculations
					$Xcomplete_count = complete_leads($DB,$link,$dial_statuses,$camp_lists,$call_count_limit,$single_status,$campaign_id);
					$complete_total = ($complete_total + $Xcomplete_count);
					$dispo_total = ($lead_list['Y'][$dispo] + $lead_list['N'][$dispo]);
					if ( ($Xcomplete_count < 1) or ($dispo_total < 1) )
						{$complete_pct = "0";}
					else
						{
						$complete_pct = intval(($Xcomplete_count / $dispo_total) * 100);
						}

					echo "<tr $bgcolor><td><font size=1>$CLB$dispo$CLE</td><td><font size=1>$statuses_list[$dispo]</td><td><font size=1>".$lead_list['Y'][$dispo]."</td><td><font size=1>".$lead_list['N'][$dispo]." </td><td><font size=1>$Xdialable_count </td><td align=right><font size=1>$complete_pct% &nbsp; </td></tr>\n";
					}
				else
					{
					echo "<tr $bgcolor><td><font size=1>$CLB$dispo$CLE</td><td><font size=1>$statuses_list[$dispo]</td><td><font size=1>".$lead_list['Y'][$dispo]."</td><td><font size=1>".$lead_list['N'][$dispo]." </td></tr>\n";
					}
				$o++;
				}
			}

		if ($SSexpanded_list_stats > 0)
			{
			if ( ($complete_total < 1) or ($lead_list['count'] < 1) )
				{$total_complete_pct = "0";}
			else
				{$total_complete_pct = intval(($complete_total / $lead_list['count']) * 100);}
			echo "<tr><td colspan=2><font size=1>"._QXZ("SUBTOTALS")."</td><td><font size=1>$lead_list[Y_count]</td><td><font size=1>$lead_list[N_count]</td><td><font size=1> &nbsp; </td><td><font size=1> &nbsp; </td></tr>\n";
			echo "<tr bgcolor=\"#$SSstd_row1_background\"><td><font size=1>"._QXZ("TOTAL")."</td><td colspan=3 align=center><font size=1>$lead_list[count]</td><td><font size=1>$dialable_total</td><td align=right><font size=1> $total_complete_pct% &nbsp; </td></tr>\n";
			}
		else
			{
			echo "<tr><td colspan=2><font size=1>SUBTOTALS</td><td><font size=1>$lead_list[Y_count]</td><td><font size=1>$lead_list[N_count]</td></tr>\n";
			echo "<tr bgcolor=\"#$SSstd_row1_background\"><td><font size=1>TOTAL</td><td colspan=3 align=center><font size=1>$lead_list[count]</td></tr>\n";
			}
		echo "</table></center><br>\n";
		unset($lead_list);


		echo "<center>\n";
		echo "<br><b>"._QXZ("TIME ZONES WITHIN THIS LIST").":</b><br>\n";
		echo "<TABLE width=500 cellspacing=3>\n";
		echo "<tr><td>"._QXZ("GMT OFFSET NOW (local time)")."</td><td>"._QXZ("CALLED")."</td><td>"._QXZ("NOT CALLED")."</td></tr>\n";

		$stmt="SELECT gmt_offset_now,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by gmt_offset_now,called_since_last_reset order by gmt_offset_now,called_since_last_reset;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$statuses_to_print = mysqli_num_rows($rslt);

		$o=0;
		$plus='+';
		$lead_list['count'] = 0;
		$lead_list['Y_count'] = 0;
		$lead_list['N_count'] = 0;
		while ($statuses_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			
			$lead_list['count'] = ($lead_list['count'] + $rowx[2]);
			if ($rowx[1] == 'N') 
				{
				$since_reset = 'N';
				$since_resetX = 'Y';
				}
			else 
				{
				$since_reset = 'Y';
				$since_resetX = 'N';
				} 
			$lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]);
			$lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]);
			#If opposite side is not set, it may not in the future so give it a value of zero
			if (!isset($lead_list[$since_resetX][$rowx[0]])) 
				{
				$lead_list[$since_resetX][$rowx[0]]=0;
				}
			$o++;
			}

		if ($lead_list['count'] > 0)
			{
#			while (list($tzone,) = each($lead_list[$since_reset]))
			foreach($lead_list[$since_reset] as $tzone => $blank)
				{
				$LOCALzone=3600 * $tzone;
				$LOCALdate=gmdate("D j M Y H:i", time() + $LOCALzone);

				if ($tzone >= 0) {$DISPtzone = "$plus$tzone";}
				else {$DISPtzone = "$tzone";}
				if (preg_match('/1$|3$|5$|7$|9$/i', $o))
					{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
				else
					{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

					echo "<tr $bgcolor><td><font size=1>".$DISPtzone." &nbsp; &nbsp; ($LOCALdate)</td><td><font size=1>".$lead_list['Y'][$tzone]."</td><td><font size=1>".$lead_list['N'][$tzone]."</td></tr>\n";
				}
			}

		echo "<tr><td><font size=1>"._QXZ("SUBTOTALS")."</td><td><font size=1>$lead_list[Y_count]</td><td><font size=1>$lead_list[N_count]</td></tr>\n";
		echo "<tr bgcolor=\"#$SSstd_row1_background\"><td><font size=1>"._QXZ("TOTAL")."</td><td colspan=2 align=center><font size=1>$lead_list[count]</td></tr>\n";

		echo "</table></center><br>\n";
		unset($lead_list);


		echo "<center>\n";
		echo "<br><b>"._QXZ("OWNERS WITHIN THIS LIST").":</b><br>\n";
		if ($SSuser_territories_active > 0)
			{
			### if territories are active in the system then allow for selected-territory called-since-last-reset resetting
			echo "</form>\n";
			echo "<form action=$PHP_SELF method=POST>\n";
			echo "<input type=hidden name=ADD value=411>\n";
			echo "<input type=hidden name=DB value=$DB>\n";
			echo "<input type=hidden name=stage value=territory_reset>\n";
			echo "<input type=hidden name=list_id value=\"$list_id\">\n";
			echo "<TABLE width=600 cellspacing=3>\n";
			echo "<tr><td>"._QXZ("OWNER")."</td><td>"._QXZ("CALLED")."</td><td>"._QXZ("NOT CALLED")."</td><td align=center>"._QXZ("RESET")."</td></tr>\n";

			$leads_in_list = 0;
			$leads_in_list_N = 0;
			$leads_in_list_Y = 0;
			$stmt="SELECT owner,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by owner,called_since_last_reset order by owner,called_since_last_reset;";
			if ($DB) {echo "$stmt\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			$owners_to_print = mysqli_num_rows($rslt);

			$o=0;
			$lead_list['count'] = 0;
			$lead_list['Y_count'] = 0;
			$lead_list['N_count'] = 0;
			while ($owners_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				
				$lead_list['count'] = ($lead_list['count'] + $rowx[2]);
				if ($rowx[1] == 'N') 
					{
					$since_reset = 'N';
					$since_resetX = 'Y';
					}
				else 
					{
					$since_reset = 'Y';
					$since_resetX = 'N';
					} 
				$lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]);
				$lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]);
				#If opposite side is not set, it may not in the future so give it a value of zero
				if (!isset($lead_list[$since_resetX][$rowx[0]])) 
					{
					$lead_list[$since_resetX][$rowx[0]]=0;
					}
				$o++;
				}
		 
			$o=0;
			if ($lead_list['count'] > 0)
				{
#				while (list($owner,) = each($lead_list[$since_reset]))
				foreach($lead_list[$since_reset] as $owner => $blank)
					{
					if (preg_match('/1$|3$|5$|7$|9$/i', $o))
						{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
					else
						{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

					$CLB='';
					$CLE='';

					echo "<tr $bgcolor><td><font size=1><a href=\"./user_territories.php?action=MODIFY_TERRITORY&territory=$owner\">$CLB$owner$CLE</a></td><td><font size=1>".$lead_list['Y'][$owner]."</td><td><font size=1>".$lead_list['N'][$owner]." </td><td align=center><input type=\"checkbox\" name=\"territory_reset[]\" value=\"$owner\"></td></tr>\n";
					$o++;
					}
				}

			echo "<tr><td><font size=1>"._QXZ("SUBTOTALS")."</td><td><font size=1>$lead_list[Y_count]</td><td><font size=1>$lead_list[N_count]</td>\n";
			echo "<td rowspan=2 align=center bgcolor=\"#$SSframe_background\"><input style='background-color:#$SSbutton_color' type=submit value=\""._QXZ("SUBMIT")."\"></td></tr>\n";
			echo "<tr bgcolor=\"#$SSstd_row1_background\"><td><font size=1>"._QXZ("TOTAL")."</td><td colspan=3 align=center><font size=1>$lead_list[count]</td></tr>\n";
			echo "</form>\n";

			}
		else
			{
			echo "<TABLE width=500 cellspacing=3>\n";
			echo "<tr><td>"._QXZ("OWNER")."</td><td>"._QXZ("CALLED")."</td><td>"._QXZ("NOT CALLED")."</td></tr>\n";

			$leads_in_list = 0;
			$leads_in_list_N = 0;
			$leads_in_list_Y = 0;
			$stmt="SELECT owner,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by owner,called_since_last_reset order by owner,called_since_last_reset;";
			if ($DB) {echo "$stmt\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			$owners_to_print = mysqli_num_rows($rslt);

			$o=0;
			$lead_list['count'] = 0;
			$lead_list['Y_count'] = 0;
			$lead_list['N_count'] = 0;
			while ($owners_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				
				$lead_list['count'] = ($lead_list['count'] + $rowx[2]);
				if ($rowx[1] == 'N') 
					{
					$since_reset = 'N';
					$since_resetX = 'Y';
					}
				else 
					{
					$since_reset = 'Y';
					$since_resetX = 'N';
					} 
				$lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]);
				$lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]);
				#If opposite side is not set, it may not in the future so give it a value of zero
				if (!isset($lead_list[$since_resetX][$rowx[0]])) 
					{
					$lead_list[$since_resetX][$rowx[0]]=0;
					}
				$o++;
				}
		 
			$o=0;
			if ($lead_list['count'] > 0)
				{
#				while (list($owner,) = each($lead_list[$since_reset]))
				foreach($lead_list[$since_reset] as $owner => $blank)
					{
					if (preg_match('/1$|3$|5$|7$|9$/i', $o))
						{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
					else
						{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

					$CLB='';
					$CLE='';

					echo "<tr $bgcolor><td><font size=1>$CLB$owner$CLE</td><td><font size=1>".$lead_list['Y'][$owner]."</td><td><font size=1>".$lead_list['N'][$owner]." </td></tr>\n";
					$o++;
					}
				}

			echo "<tr><td><font size=1>"._QXZ("SUBTOTALS")."</td><td><font size=1>$lead_list[Y_count]</td><td><font size=1>$lead_list[N_count]</td></tr>\n";
			echo "<tr bgcolor=\"#$SSstd_row1_background\"><td><font size=1>"._QXZ("TOTAL")."</td><td colspan=3 align=center><font size=1>$lead_list[count]</td></tr>\n";
			}
		echo "</table></center><br>\n";
		unset($lead_list);


		echo "<center>\n";
		echo "<br><b>"._QXZ("RANKS WITHIN THIS LIST").":</b><br>\n";
		echo "<TABLE width=500 cellspacing=3>\n";
		echo "<tr><td>"._QXZ("RANK")."</td><td>"._QXZ("CALLED")."</td><td>"._QXZ("NOT CALLED")."</td></tr>\n";

		$leads_in_list = 0;
		$leads_in_list_N = 0;
		$leads_in_list_Y = 0;
		$stmt="SELECT rank,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by rank,called_since_last_reset order by rank,called_since_last_reset;";
		if ($DB) {echo "$stmt\n";}
		$rslt=mysql_to_mysqli($stmt, $link);
		$ranks_to_print = mysqli_num_rows($rslt);

		$o=0;
		$lead_list['count'] = 0;
		$lead_list['Y_count'] = 0;
		$lead_list['N_count'] = 0;
		while ($ranks_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			
			$lead_list['count'] = ($lead_list['count'] + $rowx[2]);
			if ($rowx[1] == 'N') 
				{
				$since_reset = 'N';
				$since_resetX = 'Y';
				}
			else 
				{
				$since_reset = 'Y';
				$since_resetX = 'N';
				} 
			$lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]);
			$lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]);
			#If opposite side is not set, it may not in the future so give it a value of zero
			if (!isset($lead_list[$since_resetX][$rowx[0]])) 
				{
				$lead_list[$since_resetX][$rowx[0]]=0;
				}
			$o++;
			}
	 
		$o=0;
		if ($lead_list['count'] > 0)
			{
#			while (list($rank,) = each($lead_list[$since_reset]))
			foreach($lead_list[$since_reset] as $rank => $blank)
				{
				if (preg_match('/1$|3$|5$|7$|9$/i', $o))
					{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
				else
					{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

				$CLB='';
				$CLE='';

				echo "<tr $bgcolor><td><font size=1>$CLB$rank$CLE</td><td><font size=1>".$lead_list['Y'][$rank]."</td><td><font size=1>".$lead_list['N'][$rank]." </td></tr>\n";
				$o++;
				}
			}

		echo "<tr><td><font size=1>"._QXZ("SUBTOTALS")."</td><td><font size=1>$lead_list[Y_count]</td><td><font size=1>$lead_list[N_count]</td></tr>\n";
		echo "<tr bgcolor=\"#$SSstd_row1_background\"><td><font size=1>"._QXZ("TOTAL")."</td><td colspan=3 align=center><font size=1>$lead_list[count]</td></tr>\n";

		echo "</table></center><br>\n";
		unset($lead_list);

		if ($SScountry_code_list_stats > 0)
			{
			echo "<center>\n";
			echo "<br><b>"._QXZ("COUNTRY CODES WITHIN THIS LIST").":</b><br>\n";
			echo "<TABLE width=500 cellspacing=3>\n";
			echo "<tr><td>"._QXZ("CODE")."</td><td>"._QXZ("CALLED")."</td><td>"._QXZ("NOT CALLED")."</td></tr>\n";

			$leads_in_list = 0;
			$leads_in_list_N = 0;
			$leads_in_list_Y = 0;
			$stmt="SELECT country_code,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by country_code,called_since_last_reset order by country_code,called_since_last_reset;";
			if ($DB) {echo "$stmt\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			$ranks_to_print = mysqli_num_rows($rslt);

			$o=0;
			$lead_list['count'] = 0;
			$lead_list['Y_count'] = 0;
			$lead_list['N_count'] = 0;
			while ($ranks_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				
				$lead_list['count'] = ($lead_list['count'] + $rowx[2]);
				if ($rowx[1] == 'N') 
					{
					$since_reset = 'N';
					$since_resetX = 'Y';
					}
				else 
					{
					$since_reset = 'Y';
					$since_resetX = 'N';
					} 
				$lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]);
				$lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]);
				#If opposite side is not set, it may not in the future so give it a value of zero
				if (!isset($lead_list[$since_resetX][$rowx[0]])) 
					{
					$lead_list[$since_resetX][$rowx[0]]=0;
					}
				$o++;
				}
		 
			$o=0;
			if ($lead_list['count'] > 0)
				{
#				while (list($rank,) = each($lead_list[$since_reset]))
				foreach($lead_list[$since_reset] as $rank => $blank)
					{
					if (preg_match('/1$|3$|5$|7$|9$/i', $o))
						{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
					else
						{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

					$CLB='';
					$CLE='';

					echo "<tr $bgcolor><td><font size=1>$CLB$rank$CLE</td><td><font size=1>".$lead_list['Y'][$rank]."</td><td><font size=1>".$lead_list['N'][$rank]." </td></tr>\n";
					$o++;
					}
				}

			echo "<tr><td><font size=1>"._QXZ("SUBTOTALS")."</td><td><font size=1>$lead_list[Y_count]</td><td><font size=1>$lead_list[N_count]</td></tr>\n";
			echo "<tr bgcolor=\"#$SSstd_row1_background\"><td><font size=1>"._QXZ("TOTAL")."</td><td colspan=3 align=center><font size=1>$lead_list[count]</td></tr>\n";

			echo "</table></center><br>\n";
			unset($lead_list);			
			}

		$leads_in_list = 0;
		$leads_in_list_N = 0;
		$leads_in_list_Y = 0;
		$stmt="SELECT status, if(called_count >= 100, 100, called_count), count(*) from vicidial_list where list_id='$list_id' group by status, if(called_count >= 100, 100, called_count) order by status,called_count;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$status_called_to_print = mysqli_num_rows($rslt);

		$status = $MT;
		$o=0;
		$sts=0;
		$first_row=1;
		$all_called_first=1000;
		$all_called_last=0;
		while ($status_called_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$leads_in_list = ($leads_in_list + $rowx[2]);
			$count_statuses[$o]			= $rowx[0];
			$count_called[$o]			= $rowx[1];
			$count_count[$o]			= $rowx[2];
			$all_called_count[$rowx[1]] = ($all_called_count[$rowx[1]] + $rowx[2]);

			if ( (strlen($status[$sts]) < 1) or ($status[$sts] != "$rowx[0]") )
				{
				if ($first_row) {$first_row=0;}
				else {$sts++;}
				$status[$sts] = "$rowx[0]";
				$status_called_first[$sts] = "$rowx[1]";
				if ($status_called_first[$sts] < $all_called_first) {$all_called_first = $status_called_first[$sts];}
				}
			$leads_in_sts[$sts] = ($leads_in_sts[$sts] + $rowx[2]);
			$status_called_last[$sts] = "$rowx[1]";
			if ($status_called_last[$sts] > $all_called_last) {$all_called_last = $status_called_last[$sts];}

			$o++;
			}


		echo "<center>\n";
		echo "<br><b>"._QXZ("CALLED COUNTS WITHIN THIS LIST").":</b><br>\n";
		echo "<TABLE width=500 cellspacing=1>\n";
		echo "<tr><td align=left><font size=1>"._QXZ("STATUS")."</td><td align=center><font size=1>"._QXZ("STATUS NAME")."</td>";
		$first = $all_called_first;
		while ($first <= $all_called_last)
			{
			if (preg_match('/1$|3$|5$|7$|9$/i', $first)) {$AB='bgcolor="#AFEEEE"';} 
			else{$AB='bgcolor="#E0FFFF"';}
			if ($first >= 100) {$Fplus='+';}
			else {$Fplus='';}
			echo "<td align=center $AB><font size=1>$first$Fplus</td>";
			$first++;
			}
		echo "<td align=center><font size=1>"._QXZ("SUBTOTAL")."</td></tr>\n";

		$sts=0;
		$statuses_called_to_print = count($status);
		while ($statuses_called_to_print > $sts) 
			{
			$Pstatus = $status[$sts];
			if (preg_match("/1$|3$|5$|7$|9$/i", $sts))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';   $AB='bgcolor="#'. $SSstd_row1_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';   $AB='bgcolor="#'. $SSstd_row2_background .'"';}
		#	echo "$status[$sts]|$status_called_first[$sts]|$status_called_last[$sts]|$leads_in_sts[$sts]|\n";
		#	echo "$status[$sts]|";
			echo "<tr $bgcolor><td><font size=1>$Pstatus</td><td><font size=1>$statuses_list[$Pstatus]</td>";

			$first = $all_called_first;
			while ($first <= $all_called_last)
				{
				if (preg_match("/1$|3$|5$|7$|9$/i", $sts))
					{
					if (preg_match('/1$|3$|5$|7$|9$/i', $first)) {$AB='bgcolor="#'. $SSstd_row1_background .'"';} 
					else{$AB='bgcolor="#'. $SSstd_row2_background .'"';}
					}
				else
					{
					if (preg_match("/0$|2$|4$|6$|8$/i", $first)) {$AB='bgcolor="#'. $SSstd_row1_background .'"';} 
					else{$AB='bgcolor="#'. $SSstd_row2_background .'"';}
					}

				$called_printed=0;
				$o=0;
				while ($status_called_to_print > $o)
					{
					if ( ($count_statuses[$o] == "$Pstatus") and ($count_called[$o] == "$first") )
						{
						$called_printed++;
						echo "<td $AB><font size=1> <a href=\"admin_search_lead.php?list_id=$list_id&status=$Pstatus&called_count=$first\">$count_count[$o]</a></td>";
						}

					$o++;
					}
				if (!$called_printed) 
					{echo "<td $AB><font size=1> &nbsp;</td>";}
				$first++;
				}
			echo "<td><font size=1><a href=\"admin_search_lead.php?list_id=$list_id&status=$Pstatus\">$leads_in_sts[$sts]</a></td></tr>\n\n";

			$sts++;
			}

		echo "<tr><td align=center colspan=2><b><font size=1>"._QXZ("TOTAL")."</td>";
		$first = $all_called_first;
		while ($first <= $all_called_last)
			{
			if (preg_match('/1$|3$|5$|7$|9$/i', $first)) {$AB='bgcolor="#AFEEEE"';} 
			else{$AB='bgcolor="#E0FFFF"';}
			echo "<td align=center $AB><b><font size=1><a href=\"admin_search_lead.php?list_id=$list_id&called_count=$first\">$all_called_count[$first]</a></td>";
			$first++;
			}
		echo "<td align=center><b><font size=1>$leads_in_list</td></tr>\n";

		echo "</table></center><br>\n";

		if ($SSdaily_call_count_limit > 0)
			{
			echo "<center>\n";
			echo "<br><b>"._QXZ("TODAY CALLED COUNTS FOR LEADS CALLED TODAY WITHIN THIS LIST").":</b><br>\n";
			echo "<TABLE width=300 cellspacing=1>\n";
			echo "<tr><td align=center><font size=1>"._QXZ("TODAY CALLED COUNT")."</td><td align=left><font size=1>"._QXZ("CALLED")."</td><td align=center><font size=1>"._QXZ("SUBTOTAL")."</td></tr>\n";

			$stmt="SELECT LEFT(called_since_last_reset,1) as cslr,called_count_total,count(*) from vicidial_list LEFT OUTER JOIN vicidial_lead_call_daily_counts on vicidial_list.lead_id=vicidial_lead_call_daily_counts.lead_id where vicidial_list.list_id='$list_id' group by cslr,called_count_total order by called_count_total;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$counts_to_print = mysqli_num_rows($rslt);
			$o=0;
			while ($counts_to_print > $o) 
				{
				if (preg_match('/1$|3$|5$|7$|9$/i', $o))
					{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
				else
					{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

				$rowx=mysqli_fetch_row($rslt);
				$cslr[$o] =			$rowx[0];
				$counts[$o] =		$rowx[1];
				$tallies[$o] =		$rowx[2];
				if ( ($counts[$o]=='') or ($counts[$o]=='NULL') or (strlen($counts[$o]) < 1) ) {$counts[$o]=0;}
				echo "<tr $bgcolor><td align=center><font size=1>$counts[$o] </td><td align=left><font size=1> $cslr[$o]</td><td align=center><font size=1>$tallies[$o]</td></tr>\n";

				$o++;
				}
			echo "<tr><td align=center><b><font size=1> &nbsp; </td><td align=center><b><font size=1> "._QXZ("TOTAL")." </td><td align=center><b><font size=1>$leads_in_list</td></tr>\n";

			echo "</table></center><br>\n";
			}

		if ($SScall_limit_24hour > 0)
			{
			$temp_zero_called = $leads_in_list;
			$temp_24hour_output='';
			echo "<center>\n";
			echo "<br><b>"._QXZ("24-HOUR CALLED COUNTS FOR LEADS WITHIN THIS LIST").":</b><br>\n";
			echo "<TABLE width=300 cellspacing=1>\n";
			echo "<tr><td align=center><font size=1>"._QXZ("24-HOUR CALLED COUNT")."</td><td align=left><font size=1>"._QXZ("LEADS")."</td></tr>\n";

			$stmt="SELECT count(tally) as lead_tally,tally FROM(select count(*) as tally,t.lead_id from vicidial_lead_24hour_calls t where list_id='$list_id' and (call_date >= NOW() - INTERVAL 1 DAY) group by t.lead_id) t group by tally order by tally;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$counts_to_print = mysqli_num_rows($rslt);
			$o=0;
			while ($counts_to_print > $o) 
				{
				if (preg_match('/1$|3$|5$|7$|9$/i', $o))
					{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';} 
				else
					{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';}

				$rowx=mysqli_fetch_row($rslt);
				$counts[$o] =		$rowx[1];
				$tallies[$o] =		$rowx[0];
				$temp_zero_called = ($temp_zero_called - $rowx[0]);
				$temp_24hour_output .= "<tr $bgcolor><td align=center><font size=1>$counts[$o] </td><td align=center><font size=1>$tallies[$o]</td></tr>\n";

				$o++;
				}
			echo "<tr bgcolor=#$SSstd_row1_background><td align=center><font size=1>0 </td><td align=center><font size=1>$temp_zero_called</td></tr>\n";
			echo $temp_24hour_output;
			echo "<tr><td align=center><b><font size=1> "._QXZ("TOTAL")." </td><td align=center><b><font size=1>$leads_in_list</td></tr>\n";

			echo "</table></center><br>\n";
			}

		echo "<center><b>\n";

		if ($SScustom_fields_enabled > 0)
			{
			$stmt="SELECT count(*) from vicidial_lists_fields where list_id='$list_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$rowx=mysqli_fetch_row($rslt);

			echo "<br><br><a href=\"./$admin_lists_custom?action=MODIFY_CUSTOM_FIELDS&list_id=$list_id\">"._QXZ("Custom fields defined for this list").": $rowx[0]</a><BR>\n";
			}

		echo "<br><br><a href=\"$PHP_SELF?ADD=811&list_id=$list_id\">"._QXZ("Click here to see all CallBack Holds in this list")."</a><BR>\n";
		echo "<br><br><a href=\"./list_download.php?list_id=$list_id\">"._QXZ("Click here to download this list")."</a><BR><BR>\n";

		if ($LOGdelete_lists > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=511&list_id=$list_id\">"._QXZ("DELETE THIS LIST")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ($LOGdelete_lists > 0) and ($LOGmodify_lists > 0) and ($LOGmodify_leads > 0) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=512&list_id=$list_id\">"._QXZ("CLEAR THIS LIST")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=LISTS&stage=$list_id\">"._QXZ("Click here to see Admin changes to this list")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}



######################
# ADD=431 modify drop list, add new drop status to the drop list drop statuses
######################
if ($ADD==431)
	{
	if ($LOGmodify_lists!=1)
		{
		echo "<br>"._QXZ("You do not have permission to view this page")."\n";
		}
	else
		{
		$stmt="SELECT count(*) from vicidial_drop_lists where dl_id='$dl_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ( ($row[0] < 1) or (strlen($dl_id) < 2) )
			{
			echo "<br>"._QXZ("DROP LIST DROP NOT MODIFIED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("drop list id must be between 2 and 30 characters in length")."\n";
			}
		else
			{
			### BEGIN drop list add status ###
			if (strlen($drop_status) > 0)
				{
				$drop_status = preg_replace('/\-\-\-\-\-.*/i', '',$drop_status);
				echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
				$stmt="SELECT count(*) from vicidial_drop_lists where dl_id='$dl_id' and drop_statuses LIKE \"% $drop_status %\"  $LOGadmin_viewable_groupsSQL;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				if ($row[0] > 0)
					{echo "<br>"._QXZ("DROP LIST DROP STATUS NOT ADDED - there is already an entry for this drop list with this status")."\n";}
				else
					{
					echo "<br><B>"._QXZ("DROP LIST STATUS ADDED").": $dl_id - $drop_status</B>\n";

					$stmt="SELECT drop_statuses from vicidial_drop_lists where dl_id='$dl_id';";
					$rslt=mysql_to_mysqli($stmt, $link);
					$row=mysqli_fetch_row($rslt);

					if (strlen($row[0])<2) {$row[0] = ' -';}
					$drop_statuses = " $drop_status$row[0]";
					$stmt="UPDATE vicidial_drop_lists set drop_statuses='$drop_statuses' where dl_id='$dl_id';";
					$rslt=mysql_to_mysqli($stmt, $link);

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$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='DROPLISTS', event_type='ADD', record_id='$dl_id', event_code='ADMIN ADD DROP LIST STATUS', event_sql=\"$SQL_log\", event_notes='Status: $statuses';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				### END drop list add status ###
				}
			else
				{
				### BEGIN modify drop list ###
				echo "<br><B>"._QXZ("DROP LIST MODIFIED").": $dl_id - $dl_name</B>\n";

				$p=0;
				$DL_weekdays='';
				if (!is_array($dl_weekdays)) {$dl_weekdays=array();}
				$dl_weekdays_ct = count($dl_weekdays);
				while ($p <= $dl_weekdays_ct)
					{
					$DL_weekdays .= "$dl_weekdays[$p]";
					$p++;
					}

				$groups_value='';
				if (is_array($groups)) {$group_ct = count($groups);} else {$group_ct=0;}
				$p=0;
				while ($p < $group_ct)
					{
					$groups_value .= " $groups[$p]";
					$p++;
					}
				if (strlen($groups_value)>2) {$groups_value .= " -";}

				$stmt="UPDATE vicidial_drop_lists set dl_name='$dl_name',dl_server='$dl_server',dl_times='$dl_times',dl_weekdays='$DL_weekdays',dl_monthdays='$dl_monthdays',list_id='$list_id',duplicate_check='$duplicate_check',run_now_trigger='$run_now_trigger',active='$active',user_group='$user_group',closer_campaigns='$groups_value',dl_minutes='$dl_minutes' where dl_id='$dl_id';";
				$rslt=mysql_to_mysqli($stmt, $link);

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$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='DROPLISTS', event_type='MODIFY', record_id='$dl_id', event_code='ADMIN MODIFY DROP LIST', event_sql=\"$SQL_log\", event_notes='';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				### END modify drop list ###
				}
			}
		}
	$ADD=331;
	}


######################
# ADD=333 remove drop list drop status
######################
if ($ADD==333)
	{
	if ($LOGmodify_lists==1)
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		$stmt="SELECT count(*) from vicidial_drop_lists where dl_id='$dl_id' and drop_statuses LIKE \"% $status %\" $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ($row[0] < 1)
			{echo "<br>"._QXZ("DROP LIST DROP STATUS NOT REMOVED - this drop status is not selected for this drop list")."\n";}
		else
			{
			if ( (strlen($dl_id) < 2) or (strlen($status) < 1) )
				{
				echo "<br>"._QXZ("DROP LIST DROP STATUS NOT REMOVED - Please go back and look at the data you entered")."\n";
				echo "<br>"._QXZ("status must be between 1 and 6 characters in length")."\n";
				}
			else
				{
				$stmt="SELECT count(*) from vicidial_drop_lists where dl_id='$dl_id' $LOGadmin_viewable_groupsSQL;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				if ($row[0] < 1)
					{echo "<br>"._QXZ("DROP LIST NOT FOUND").": $dl_id";}
				else
					{
					echo "<br><B>"._QXZ("DROP LIST DROP STATUS REMOVED").": $dl_id - $status</B>\n";

					$stmt="SELECT drop_statuses from vicidial_drop_lists where dl_id='$dl_id' $LOGadmin_viewable_groupsSQL;";
					$rslt=mysql_to_mysqli($stmt, $link);
					$row=mysqli_fetch_row($rslt);

					$drop_statuses = preg_replace("/\s$status\s/i", " ",$row[0]);
					$stmt="UPDATE vicidial_drop_lists set drop_statuses='$drop_statuses' where dl_id='$dl_id' $LOGadmin_viewable_groupsSQL;";
					$rslt=mysql_to_mysqli($stmt, $link);

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$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='DROPLISTS', event_type='DELETE', record_id='$dl_id', event_code='ADMIN DELETE DROP LIST STATUS', event_sql=\"$SQL_log\", event_notes='Status: $status';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	$ADD=331;	# go to drop list modification form below
	}


######################
# ADD=331 modify drop list info in the system
######################
if ($ADD==331)
	{
	if ($LOGmodify_lists==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=331&dl_id=$dl_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT count(*) from vicidial_drop_lists where dl_id='$dl_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if ( ($row[0] < 1) or (strlen($dl_id) < 2) )
			{
			echo "<br>"._QXZ("DROP LIST DROP NOT MODIFIED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("drop list id must be between 2 and 30 characters in length")."\n";
			}
		else
			{
			##### get server listing for dynamic pulldown 
			$stmt="SELECT server_ip,server_description,external_server_ip from servers order by server_ip";
			$rsltx=mysql_to_mysqli($stmt, $link);
			$servers_to_print = mysqli_num_rows($rsltx);
			$servers_list='';
			$o=0;
			while ($servers_to_print > $o)
				{
				$rowx=mysqli_fetch_row($rsltx);
				$servers_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$o++;
				}

			$stmt="SELECT dl_id,dl_name,last_run,dl_server,dl_times,dl_weekdays,dl_monthdays,drop_statuses,list_id,duplicate_check,run_now_trigger,active,user_group,closer_campaigns,dl_minutes from vicidial_drop_lists where dl_id='$dl_id' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			$dl_id =			$row[0];
			$dl_name =			$row[1];
			$last_run =			$row[2];
			$dl_server =		$row[3];
			$dl_times =			$row[4];
			$dl_weekdays =		$row[5];
			$dl_monthdays =		$row[6];
			$drop_statuses =	$row[7];
			$list_id =			$row[8];
			$duplicate_check =	$row[9];
			$run_now_trigger =	$row[10];
			$active =			$row[11];
			$user_group =		$row[12];
			$closer_campaigns =	$row[13];
			$dl_minutes =		$row[14];

			echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

			echo "<br>"._QXZ("MODIFY A DROP LIST")."<form action=$PHP_SELF method=POST>\n";
			echo "<input type=hidden name=ADD value=431>\n";
			echo "<input type=hidden name=DB value=\"$DB\">\n";
			echo "<input type=hidden name=dl_id value=\"$dl_id\">\n";
			echo "<center><TABLE width=980 cellspacing=3>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Drop List ID").": </td><td align=left><B>$dl_id</B></td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Drop List Name").": </td><td align=left><input type=text name=dl_name size=40 maxlength=100 value=\"$dl_name\"> $NWB#drop_lists-dl_name$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Last Run Time").": </td><td align=left><B>$last_run</B></td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
			echo "$UUgroups_list";
			echo "<option SELECTED value=\"$user_group\">$user_group</option>\n";
			echo "</select>$NWB#drop_lists-user_group$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Run Server").": </td><td align=left><select size=1 name=dl_server>\n";
			echo "<option>active_voicemail_server</option>\n";
			echo "$servers_list";
			echo "<option SELECTED>$dl_server</option>\n";
			echo "</select>$NWB#drop_lists-dl_server$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Run Times").": </td><td align=left><input type=text name=dl_times size=80 maxlength=120 id=dl_times value=\"$dl_times\">$NWB#drop_lists-dl_times$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right NOWRAP>"._QXZ("Run Weekdays").":</td><td align=left NOWRAP>\n";
			echo "<input type=\"checkbox\" name=\"dl_weekdays[]\" value=\"0\"";
				if (preg_match('/0/',$dl_weekdays)) {echo " CHECKED";}
			echo ">"._QXZ("Sunday")." &nbsp; \n";
			echo "<input type=\"checkbox\" name=\"dl_weekdays[]\" value=\"1\"";
				if (preg_match('/1/',$dl_weekdays)) {echo " CHECKED";}
			echo ">"._QXZ("Monday")." &nbsp; \n";
			echo "<input type=\"checkbox\" name=\"dl_weekdays[]\" value=\"2\"";
				if (preg_match('/2/',$dl_weekdays)) {echo " CHECKED";}
			echo ">"._QXZ("Tuesday")." &nbsp; \n";
			echo "<input type=\"checkbox\" name=\"dl_weekdays[]\" value=\"3\"";
				if (preg_match('/3/',$dl_weekdays)) {echo " CHECKED";}
			echo ">"._QXZ("Wednesday")." &nbsp; \n";
			echo "<input type=\"checkbox\" name=\"dl_weekdays[]\" value=\"4\"";
				if (preg_match('/4/',$dl_weekdays)) {echo " CHECKED";}
			echo ">"._QXZ("Thursday")." &nbsp; \n";
			echo "<input type=\"checkbox\" name=\"dl_weekdays[]\" value=\"5\"";
				if (preg_match('/5/',$dl_weekdays)) {echo " CHECKED";}
			echo ">"._QXZ("Friday")." &nbsp; \n";
			echo "<input type=\"checkbox\" name=\"dl_weekdays[]\" value=\"6\"";
				if (preg_match('/6/',$dl_weekdays)) {echo " CHECKED";}
			echo ">"._QXZ("Saturday")." &nbsp; \n";
			echo "$NWB#drop_lists-dl_weekdays$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Run Month Days").": </td><td align=left><input type=text name=dl_monthdays size=80 maxlength=100 id=dl_monthdays value=\"$dl_monthdays\">$NWB#drop_lists-dl_monthdays$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Duplicate Check").": </td><td align=left><select size=1 name=duplicate_check>\n";
			echo "<option value=\"NONE\">"._QXZ("NONE")."</option>\n";
			echo "<option value=\"LIST\">"._QXZ("LIST")."</option>\n";
			echo "<option value=\"LIST_CAMPAIGN_LISTS\">"._QXZ("LIST_CAMPAIGN_LISTS")."</option>\n";
			echo "<option value=\"$duplicate_check\" SELECTED>"._QXZ("$duplicate_check")."</option>\n";
			echo "</select>$NWB#drop_lists-duplicate_check$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("List ID").": </td><td align=left><input type=text name=list_id size=19 maxlength=19 value=\"$list_id\"> &nbsp; ("._QXZ("digits only").") $NWB#drop_lists-list_id$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active>\n";
			echo "<option value=\"Y\">"._QXZ("YES")."</option>\n";
			echo "<option value=\"N\">"._QXZ("NO")."</option>\n";
			echo "<option value=\"$active\" SELECTED>"._QXZ("$active")."</option>\n";
			echo "</select>$NWB#drop_lists-active$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Gather Minutes").": </td><td align=left><input type=text name=dl_minutes size=7 maxlength=6 value=\"$dl_minutes\"> &nbsp; ("._QXZ("digits only").") $NWB#drop_lists-dl_minutes$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Run Now Trigger").": </td><td align=left><select size=1 name=run_now_trigger>\n";
			echo "<option value=\"Y\">"._QXZ("YES")."</option>\n";
			echo "<option value=\"N\">"._QXZ("NO")."</option>\n";
			echo "<option value=\"$run_now_trigger\" SELECTED>"._QXZ("$run_now_trigger")."</option>\n";
			echo "</select>$NWB#drop_lists-run_now_trigger$NWE</td></tr>\n";

			$drop_statuses = preg_replace("/ -$/","",$drop_statuses);
			$Dstatuses = explode(" ", $drop_statuses);
			$Ds_to_print = (count($Dstatuses) - 0);
			$o=0; $p=0;
			while ($Ds_to_print > $o)
				{
				$o++;
				$Dstatus = $Dstatuses[$o];

				if (strlen($Dstatus)>0)
					{
					$p++;
					echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Drop Status")." $p: </td><td align=left> \n";
					echo "<b>$Dstatus</b> - $statname_list[$Dstatus] &nbsp; &nbsp; &nbsp; &nbsp; <font size=2>\n";
					echo "<a href=\"$PHP_SELF?ADD=333&dl_id=$dl_id&status=$Dstatuses[$o]\">"._QXZ("REMOVE")."</a></td></tr>\n";
					}
				}

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Add A Drop Status").": </td><td align=left><select size=1 name=drop_status>\n";
			echo "<option value=\"\" selected> - "._QXZ("NONE")." - </option>\n";
			echo "<option>DROP</option>\n";
			echo "<option>AFTHRS</option>\n";
			echo "<option>NANQUE</option>\n";
			echo "<option>MAXCAL</option>\n";
			echo "<option>HXFER</option>\n";
			echo "<option>QVMAIL</option>\n";
			echo "<option>HOLDTO</option>\n";
			echo "<option>WAITTO</option>\n";
			echo "<option>ACFLTR</option>\n";
			echo "<option>HXFER</option>\n";
			echo "<option>TIMEOT</option>\n";
			echo "<option>PDROP</option>\n";
			echo "</select> &nbsp; \n";
			echo "<input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("ADD")."'> &nbsp; &nbsp; $NWB#drop_lists-drop_statuses$NWE</td></tr>\n";

			$closer_campaignsSQL = 'closer_campaigns';
			$groups_list='';

			$stmt="SELECT closer_campaigns from vicidial_drop_lists where dl_id='$dl_id' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			$Mcloser_campaigns =	$row[0];
			$Mcloser_campaigns = preg_replace("/ -$/","",$Mcloser_campaigns);
			$groups = explode(" ", $Mcloser_campaigns);

			$stmt="SELECT group_id,group_name from vicidial_inbound_groups where group_handling='PHONE' $LOGadmin_viewable_groupsSQL order by group_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$Dgroups_to_print = mysqli_num_rows($rslt);
			$o=0;
			while ($Dgroups_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$group_id_values[$o] =		$rowx[0];
				$group_name_values[$o] =	$rowx[1];
				if (strlen($group_id_values[$o])>0)
					{
					$groups_list .= "<input type=\"checkbox\" name=\"groups[]\" value=\"$group_id_values[$o]\"";
					$p=0;
					$group_ct = count($groups);
					while ($p < $group_ct)
						{
						if ($group_id_values[$o] === $groups[$p]) 
							{
							$groups_list .= " CHECKED";
							$groups_value .= " $group_id_values[$o]";
							}
						$p++;
						}
					$groups_list .= "> <a href=\"$PHP_SELF?ADD=3111&group_id=$group_id_values[$o]\">$group_id_values[$o]</a> - $group_name_values[$o]<BR>\n";
					}
				$o++;
				}
			if (strlen($groups_value)>2) {$groups_value .= " -";}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top><BR>"._QXZ("Inbound Groups").": <BR>$NWB#drop_lists-closer_campaigns$NWE</td><td align=left>\n";
			echo "$groups_list";
			echo "</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
			echo "</TABLE></center>\n";

			echo "</center><BR><BR>\n";

			if ($LOGmodify_lists > 0)
				{
				echo "<br><br><a href=\"$PHP_SELF?ADD=531&dl_id=$dl_id\">"._QXZ("DELETE THIS DROP LIST")."</a>\n";
				}
			if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
				{
				echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=DROPLISTS&stage=$dl_id\">"._QXZ("Click here to see Admin changes to this drop list")."</FONT>\n";
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=3111 modify in-group info in the system
######################
if ($ADD==3111)
	{
	if ($LOGmodify_ingroups==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=3111&group_id=$group_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,drop_call_seconds,drop_action,drop_exten,call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,default_xfer_group,queue_priority,drop_inbound_group,ingroup_recording_override,ingroup_rec_filename,afterhours_xfer_group,qc_enabled,qc_statuses,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two,default_group_alias,no_agent_no_queue,no_agent_action,no_agent_action_value,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,ignore_list_script_override,extension_appended_cidname,uniqueid_status_display,uniqueid_status_prefix,hold_time_option_minimum,hold_time_option_press_filename,hold_time_option_callmenu,onhold_prompt_no_block,onhold_prompt_seconds,hold_time_option_no_block,hold_time_option_prompt_seconds,hold_time_second_option,hold_time_third_option,wait_hold_option_priority,wait_time_option,wait_time_second_option,wait_time_third_option,wait_time_option_seconds,wait_time_option_exten,wait_time_option_voicemail,wait_time_option_xfer_group,wait_time_option_callmenu,wait_time_option_callback_filename,wait_time_option_callback_list_id,wait_time_option_press_filename,wait_time_option_no_block,wait_time_option_prompt_seconds,timer_action_destination,calculate_estimated_hold_seconds,add_lead_url,eht_minimum_prompt_filename,eht_minimum_prompt_no_block,eht_minimum_prompt_seconds,on_hook_ring_time,na_call_url,on_hook_cid,group_calldate,action_xfer_cid,drop_callmenu,after_hours_callmenu,user_group,max_calls_method,max_calls_count,max_calls_action,dial_ingroup_cid,group_handling,web_form_address_three,populate_lead_ingroup,drop_lead_reset,after_hours_lead_reset,nanq_lead_reset,wait_time_lead_reset,hold_time_lead_reset,status_group_id,routing_initiated_recordings,on_hook_cid_number,customer_chat_screen_colors,customer_chat_survey_link,customer_chat_survey_text,populate_lead_province,areacode_filter,areacode_filter_seconds,areacode_filter_action,areacode_filter_action_value,populate_state_areacode,inbound_survey,inbound_survey_filename,inbound_survey_accept_digit,inbound_survey_question_filename,inbound_survey_callmenu,icbq_expiration_hours,closing_time_action,closing_time_now_trigger,closing_time_filename,closing_time_end_filename,closing_time_lead_reset,closing_time_option_exten,closing_time_option_callmenu,closing_time_option_voicemail,closing_time_option_xfer_group,closing_time_option_callback_list_id,icbq_call_time_id,add_lead_timezone,icbq_dial_filter,populate_lead_source,populate_lead_vendor,park_file_name,waiting_call_url_on,waiting_call_url_off,enter_ingroup_url,cid_cb_confirm_number,cid_cb_invalid_filter_phone_group,cid_cb_valid_length,cid_cb_valid_filename,cid_cb_confirmed_filename,cid_cb_enter_filename,cid_cb_you_entered_filename,cid_cb_press_to_confirm_filename,cid_cb_invalid_filename,cid_cb_reenter_filename,cid_cb_error_filename,place_in_line_caller_number_filename,place_in_line_you_next_filename,ingroup_script_two,browser_alert_sound,browser_alert_volume,answer_signal,no_agent_delay,agent_search_method,qc_scorecard_id,qc_statuses_id,populate_lead_comments,drop_call_seconds_override,populate_lead_owner,in_queue_nanque,in_queue_nanque_exceptions,custom_one,custom_two,custom_three,custom_four,custom_five,second_alert_trigger,second_alert_trigger_seconds,second_alert_filename,second_alert_delay,second_alert_container,second_alert_only,third_alert_trigger,third_alert_trigger_seconds,third_alert_filename,third_alert_delay,third_alert_container,third_alert_only,agent_search_list,state_descriptions,stereo_recording,stereo_rec_filename,stereo_parallel_recording,recording_dtmf_muting,stereo_recording_agent,parallel_rec_co_filename,parallel_rec_cm_filename,parallel_rec_fr_filename from vicidial_inbound_groups where group_id='$group_id' $LOGadmin_viewable_groupsSQL;";

		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$query_group_id =			$row[0];
		$group_name =				$row[1];
		$group_color =				$row[2];
		$active =					$row[3];
		$web_form_address =			stripslashes($row[4]);
		$voicemail_ext =			$row[5];
		$next_agent_call =			$row[6];
		$fronter_display =			$row[7];
		$script_id =				$row[8];
		$get_call_launch =			$row[9];
		$xferconf_a_dtmf =			$row[10];
		$xferconf_a_number =		$row[11];
		$xferconf_b_dtmf =			$row[12];
		$xferconf_b_number =		$row[13];
		$drop_call_seconds =		$row[14];
		$drop_action =				$row[15];
		$drop_exten =				$row[16];
		$call_time_id =				$row[17];
		$after_hours_action =		$row[18];
		$after_hours_message_filename =	$row[19];
		$after_hours_exten =		$row[20];
		$after_hours_voicemail =	$row[21];
		$welcome_message_filename =	$row[22];
		$moh_context =				$row[23];
		$onhold_prompt_filename =	$row[24];
		$prompt_interval =			$row[25];
		$agent_alert_exten =		$row[26];
		$agent_alert_delay =		$row[27];
		$default_xfer_group =		$row[28];
		$queue_priority =			$row[29];
		$drop_inbound_group =		$row[30];
		$ingroup_recording_override = $row[31];
		$ingroup_rec_filename =		$row[32];
		$afterhours_xfer_group =	$row[33];
		$qc_enabled =				$row[34];
		$qc_statuses =				$row[35];
		$qc_shift_id =				$row[36];
		$qc_get_record_launch =		$row[37];
		$qc_show_recording =		$row[38];
		$qc_web_form_address =		stripslashes($row[39]);
		$qc_script =				$row[40];
		$play_place_in_line = 		$row[41];
		$play_estimate_hold_time = 	$row[42];
		$hold_time_option = 		$row[43];
		$hold_time_option_seconds = $row[44];
		$hold_time_option_exten = 	$row[45];
		$hold_time_option_voicemail = 	$row[46];
		$hold_time_option_xfer_group = 	$row[47];
		$hold_time_option_callback_filename =	$row[48];
		$hold_time_option_callback_list_id = 	$row[49];
		$hold_recall_xfer_group = 	$row[50];
		$no_delay_call_route = 		$row[51];
		$play_welcome_message = 	$row[52];
		$answer_sec_pct_rt_stat_one =	$row[53];
		$answer_sec_pct_rt_stat_two =	$row[54];
		$default_group_alias =		$row[55];
		$no_agent_no_queue =		$row[56];
		$no_agent_action =			$row[57];
		$no_agent_action_value =	$row[58];
		$web_form_address_two =		stripslashes($row[59]);
		$timer_action =				$row[60];
		$timer_action_message =		$row[61];
		$timer_action_seconds =		$row[62];
		$start_call_url =			$row[63];
		$dispo_call_url =			$row[64];
		$xferconf_c_number =		$row[65];
		$xferconf_d_number =		$row[66];
		$xferconf_e_number =		$row[67];
		$ignore_list_script_override = $row[68];
		$extension_appended_cidname = $row[69];
		$uniqueid_status_display =	$row[70];
		$uniqueid_status_prefix =	$row[71];
		$hold_time_option_minimum = $row[72];
		$hold_time_option_press_filename = $row[73];
		$hold_time_option_callmenu = $row[74];
		$onhold_prompt_no_block =	$row[75];
		$onhold_prompt_seconds =	$row[76];
		$hold_time_option_no_block = $row[77];
		$hold_time_option_prompt_seconds =	$row[78];
		$hold_time_second_option =			$row[79];
		$hold_time_third_option =			$row[80];
		$wait_hold_option_priority =		$row[81];
		$wait_time_option =					$row[82];
		$wait_time_second_option =			$row[83];
		$wait_time_third_option =			$row[84];
		$wait_time_option_seconds =			$row[85];
		$wait_time_option_exten =			$row[86];
		$wait_time_option_voicemail =		$row[87];
		$wait_time_option_xfer_group =		$row[88];
		$wait_time_option_callmenu =		$row[89];
		$wait_time_option_callback_filename =	$row[90];
		$wait_time_option_callback_list_id =	$row[91];
		$wait_time_option_press_filename =	$row[92];
		$wait_time_option_no_block =		$row[93];
		$wait_time_option_prompt_seconds =	$row[94];
		$timer_action_destination =			$row[95];
		$calculate_estimated_hold_seconds = $row[96];
		$add_lead_url =						$row[97];
		$eht_minimum_prompt_filename =		$row[98];
		$eht_minimum_prompt_no_block =		$row[99];
		$eht_minimum_prompt_seconds =		$row[100];
		$on_hook_ring_time =				$row[101];
		$na_call_url =						$row[102];
		$on_hook_cid =						$row[103];
		$group_calldate =					$row[104];
		$action_xfer_cid =					$row[105];
		$drop_callmenu =					$row[106];
		$after_hours_callmenu =				$row[107];
		$user_group =						$row[108];
		$max_calls_method =					$row[109];
		$max_calls_count =					$row[110];
		$max_calls_action =					$row[111];
		$dial_ingroup_cid =					$row[112];
		$group_handling =					$row[113];
		$web_form_address_three =			$row[114];
		$populate_lead_ingroup =			$row[115];
		$drop_lead_reset =					$row[116];
		$after_hours_lead_reset =			$row[117];
		$nanq_lead_reset =					$row[118];
		$wait_time_lead_reset =				$row[119];
		$hold_time_lead_reset =				$row[120];
		$status_group_id =					$row[121];
		$routing_initiated_recordings =		$row[122];
		$on_hook_cid_number =				$row[123];
		$customer_chat_screen_colors =		$row[124];
		$customer_chat_survey_link =		$row[125];
		$customer_chat_survey_text =		$row[126];
		$populate_lead_province =			$row[127];
		$areacode_filter =					$row[128];
		$areacode_filter_seconds =			$row[129];
		$areacode_filter_action =			$row[130];
		$areacode_filter_action_value =		$row[131];
		$populate_state_areacode =			$row[132];
		$inbound_survey =					$row[133];
		$inbound_survey_filename =			$row[134];
		$inbound_survey_accept_digit =		$row[135];
		$inbound_survey_question_filename =	$row[136];
		$inbound_survey_callmenu =			$row[137];
		$icbq_expiration_hours =			$row[138];
		$closing_time_action =				$row[139];
		$closing_time_now_trigger =			$row[140];
		$closing_time_filename =			$row[141];
		$closing_time_end_filename =		$row[142];
		$closing_time_lead_reset =			$row[143];
		$closing_time_option_exten =		$row[144];
		$closing_time_option_callmenu =		$row[145];
		$closing_time_option_voicemail =	$row[146];
		$closing_time_option_xfer_group =	$row[147];
		$closing_time_option_callback_list_id =	$row[148];
		$icbq_call_time_id =				$row[149];
		$add_lead_timezone =				$row[150];
		$icbq_dial_filter =					$row[151];
		$populate_lead_source =				$row[152];
		$populate_lead_vendor =				$row[153];
		$park_file_name =					$row[154];
		$waiting_call_url_on =				$row[155];
		$waiting_call_url_off =				$row[156];
		$enter_ingroup_url =				$row[157];
		$cid_cb_confirm_number =			$row[158];
		$cid_cb_invalid_filter_phone_group = $row[159];
		$cid_cb_valid_length =				$row[160];
		$cid_cb_valid_filename =			$row[161];
		$cid_cb_confirmed_filename =		$row[162];
		$cid_cb_enter_filename =			$row[163];
		$cid_cb_you_entered_filename =		$row[164];
		$cid_cb_press_to_confirm_filename =	$row[165];
		$cid_cb_invalid_filename =			$row[166];
		$cid_cb_reenter_filename =			$row[167];
		$cid_cb_error_filename =			$row[168];
		$place_in_line_caller_number_filename =	$row[169];
		$place_in_line_you_next_filename =	$row[170];
		$ingroup_script_two =				$row[171];
		$browser_alert_sound =				$row[172];
		$browser_alert_volume =				$row[173];
		$answer_signal =					$row[174];
		$no_agent_delay =					$row[175];
		$agent_search_method =				$row[176];
		$qc_scorecard_id =					$row[177];
		$qc_statuses_id =					$row[178];
		$populate_lead_comments =			$row[179];
		$drop_call_seconds_override =		$row[180];
		$populate_lead_owner =				$row[181];
		$in_queue_nanque =					$row[182];
		$in_queue_nanque_exceptions =		$row[183];
		$custom_one =						$row[184];
		$custom_two =						$row[185];
		$custom_three =						$row[186];
		$custom_four =						$row[187];
		$custom_five =						$row[188];
		$second_alert_trigger =				$row[189];
		$second_alert_trigger_seconds =		$row[190];
		$second_alert_filename =			$row[191];
		$second_alert_delay =				$row[192];
		$second_alert_container =			$row[193];
		$second_alert_only =				$row[194];
		$third_alert_trigger =				$row[195];
		$third_alert_trigger_seconds =		$row[196];
		$third_alert_filename =				$row[197];
		$third_alert_delay =				$row[198];
		$third_alert_container =			$row[199];
		$third_alert_only =					$row[200];
		$agent_search_list =				$row[201];
		$state_descriptions =				$row[202];
		$stereo_recording =					$row[203];
		$stereo_rec_filename =				$row[204];
		$stereo_parallel_recording =		$row[205];
		$recording_dtmf_muting =			$row[206];
		$stereo_recording_agent =			$row[207];
		$parallel_rec_co_filename =			$row[208];
		$parallel_rec_cm_filename =			$row[209];
		$parallel_rec_fr_filename =			$row[210];

		##### get callmenu listings for dynamic pulldown
		$stmt="SELECT menu_id,menu_name from vicidial_call_menu $whereLOGadmin_viewable_groupsSQL order by menu_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$Xmenus_to_print = mysqli_num_rows($rslt);
		$o=0;
		$Xmenuslist='';
		$Wmenuslist='';
		$Cmenuslist='';
		while ($Xmenus_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$Xmenuslist .= "<option ";
			$Wmenuslist .= "<option ";
			$Cmenuslist .= "<option ";
			if ($hold_time_option_callmenu == "$rowx[0]") 
				{
				$Xmenuslist .= "SELECTED ";
				$Xmenus_selected++;
				}
			if ($wait_time_option_callmenu == "$rowx[0]") 
				{
				$Wmenuslist .= "SELECTED ";
				$Wmenus_selected++;
				}
			if ($closing_time_option_callmenu == "$rowx[0]") 
				{
				$Cmenuslist .= "SELECTED ";
				$Cmenus_selected++;
				}
			$Xmenuslist .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$Wmenuslist .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$Cmenuslist .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		if ($Xmenus_selected < 1) 
			{$Xmenuslist .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		if ($Wmenus_selected < 1) 
			{$Wmenuslist .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		if ($Cmenus_selected < 1) 
			{$Cmenuslist .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}


		##### get in-groups listings for dynamic pulldown
		$stmt="SELECT group_id,group_name from vicidial_inbound_groups where group_id NOT IN('AGENTDIRECT') $LOGadmin_viewable_groupsSQL order by group_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$Xgroups_to_print = mysqli_num_rows($rslt);
		$Xgroups_menu='';
		$Xgroups_selected=0;
		$Dgroups_menu='';
		$Dgroups_selected=0;
		$Agroups_menu='';
		$Agroups_selected=0;
		$Hgroups_menu='';
		$Hgroups_selected=0;
		$Wgroups_menu='';
		$Wgroups_selected=0;
		$Tgroups_menu='';
		$Tgroups_selected=0;
		$Cgroups_menu='';
		$Cgroups_selected=0;
		$o=0;
		while ($Xgroups_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$Xgroups_menu .= "<option ";
			$Dgroups_menu .= "<option ";
			$Agroups_menu .= "<option ";
			$Tgroups_menu .= "<option ";
			$Cgroups_menu .= "<option ";
			$Wgroups_menu .= "<option ";
			$Hgroups_menu .= "<option ";
			if ($default_xfer_group == "$rowx[0]") 
				{
				$Xgroups_menu .= "SELECTED ";
				$Xgroups_selected++;
				}
			if ($drop_inbound_group == "$rowx[0]") 
				{
				$Dgroups_menu .= "SELECTED ";
				$Dgroups_selected++;
				}
			if ($afterhours_xfer_group == "$rowx[0]") 
				{
				$Agroups_menu .= "SELECTED ";
				$Agroups_selected++;
				}
			if ($hold_time_option_xfer_group == "$rowx[0]") 
				{
				$Tgroups_menu .= "SELECTED ";
				$Tgroups_selected++;
				}
			if ($closing_time_option_xfer_group == "$rowx[0]") 
				{
				$Cgroups_menu .= "SELECTED ";
				$Cgroups_selected++;
				}
			if ($wait_time_option_xfer_group == "$rowx[0]") 
				{
				$Wgroups_menu .= "SELECTED ";
				$Wgroups_selected++;
				}
			if ($hold_recall_xfer_group == "$rowx[0]") 
				{
				$Hgroups_menu .= "SELECTED ";
				$Hgroups_selected++;
				}
			$Xgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$Dgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			if ($group_id!=$rowx[0])
				{
				$Agroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$Tgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$Cgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$Wgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$Hgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				}
			$o++;
			}
		if ($Xgroups_selected < 1) 
			{$Xgroups_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		else 
			{$Xgroups_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		if ($Dgroups_selected < 1) 
			{$Dgroups_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		else 
			{$Dgroups_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		if ($Agroups_selected < 1) 
			{$Agroups_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		else 
			{$Agroups_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		if ($Tgroups_selected < 1) 
			{$Tgroups_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		else 
			{$Tgroups_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		if ($Cgroups_selected < 1) 
			{$Cgroups_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		else 
			{$Cgroups_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		if ($Wgroups_selected < 1) 
			{$Wgroups_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		else 
			{$Wgroups_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		if ($Hgroups_selected < 1) 
			{$Hgroups_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		else 
			{$Hgroups_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}

		$allowed_campaigns_count=0;
		$allowed_campaigns_warning='';
		$SQL_query_group_id = preg_replace("/_/",'\\_',$query_group_id);
		$stmt="SELECT count(*) from vicidial_campaigns where closer_campaigns LIKE \"% $SQL_query_group_id %\" $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campin_to_print = mysqli_num_rows($rslt);
		$vc_allowed_ct=0;
		if ($campin_to_print > $vc_allowed_ct) 
			{
			$rowc=mysqli_fetch_row($rslt);
			$allowed_campaigns_count = $rowc[0];
			$vc_allowed_ct++;
			}
		if ($allowed_campaigns_count < 1)
			{$allowed_campaigns_warning='<font color=red><b><br> &nbsp; '._QXZ("Not set as allowed in any campaigns").'!</b></font>';}

		echo "<br>"._QXZ("MODIFY A GROUPS RECORD").": $query_group_id<form action=$PHP_SELF method=POST name=admin_form id=admin_form>\n";
		echo "<input type=hidden name=ADD value=4111>\n";
		echo "<input type=hidden name=group_id value=\"$query_group_id\">\n";
		echo "<input type=hidden name=DB value=\"$DB\">\n";
		echo "<input type=hidden name=stage value=\"SUBMIT\">\n";
		echo "<center><TABLE width=900 cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group ID").": </td><td align=left><b>$query_group_id</b>$NWB#inbound_groups-group_id$NWE $allowed_campaigns_warning</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group Name").": </td><td align=left><input type=text name=group_name size=30 maxlength=30 value=\"$group_name\">$NWB#inbound_groups-group_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group Color")." <font size=2>(<a href=\"javascript:launch_color_chooser('group_color','color','1');\">"._QXZ("color chooser")."</a>)</font>: </td><td align=left bgcolor=\"$group_color\" id=\"group_color_td\"><input type=text name=group_color id=group_color size=7 maxlength=20 value=\"$group_color\"> $NWB#inbound_groups-group_color$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$active' SELECTED>"._QXZ("$active")."</option></select>$NWB#inbound_groups-active$NWE</td></tr>\n";

		$stmt="SELECT count(*) from vicidial_inbound_callback_queue where group_id='$group_id' and icbq_status='LIVE';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$icbq_to_print = mysqli_num_rows($rslt);
		if ($icbq_to_print > 0) 
			{
			$row=mysqli_fetch_row($rslt);
			if ($row[0] > 0)
				{
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Callback Queue Calls").": </td><td align=left><font color=red><b> &nbsp; $row[0]</b></font> $NWB#inbound_groups-callback_queue_calls$NWE</td></tr>\n";
				}
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("In-Group Calldate").": </td><td align=left>$group_calldate$NWB#inbound_groups-group_calldate$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>\n";
			$temp_chart_title = _QXZ("8 Day inbound call count for this in-group");
			horizontal_bar_chart($group_id,'8','in-group',$link,'total_calls','call count',1,'','',$temp_chart_title);
		echo "</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">$user_group</option>\n";
		echo "</select>$NWB#inbound_groups-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Park Music-on-Hold").": </td><td align=left><input type=text name=park_file_name id=park_file_name size=20 maxlength=100 value=\"$park_file_name\"> <a href=\"javascript:launch_moh_chooser('park_file_name','moh');\">"._QXZ("moh chooser")."</a> $NWB#inbound_groups-park_ext$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Web Form").": </td><td align=left><input type=text name=web_form_address size=70 maxlength=9999 value=\"$web_form_address\">$NWB#inbound_groups-web_form_address$NWE"; if ($SSenable_first_webform < 1) {echo " <font color=red><b>"._QXZ("DISABLED")."</b></font>";} echo "</td></tr>\n";
		if ($SSenable_second_webform > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Web Form Two").": </td><td align=left><input type=text name=web_form_address_two size=70 maxlength=9999 value=\"$web_form_address_two\">$NWB#inbound_groups-web_form_address$NWE</td></tr>\n";
			}
		if ($SSenable_third_webform > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Web Form Three").": </td><td align=left><input type=text name=web_form_address_three size=70 maxlength=9999 value=\"$web_form_address_three\">$NWB#inbound_groups-web_form_address$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Next Agent Call").": </td><td align=left><select size=1 name=next_agent_call><option value='random'>"._QXZ("random")."</option><option value='oldest_call_start'>"._QXZ("oldest_call_start")."</option><option value='oldest_call_finish'>"._QXZ("oldest_call_finish")."</option><option value='oldest_inbound_call_start'>"._QXZ("oldest_inbound_call_start")."</option><option value='oldest_inbound_call_finish'>"._QXZ("oldest_inbound_call_finish")."</option><option value='oldest_inbound_filtered_call_start'>"._QXZ("oldest_inbound_filtered_call_start")."</option><option value='oldest_inbound_filtered_call_finish'>"._QXZ("oldest_inbound_filtered_call_finish")."</option><option value='overall_user_level'>"._QXZ("overall_user_level")."</option><option value='inbound_group_rank'>"._QXZ("inbound_group_rank")."</option><option value='campaign_rank'>"._QXZ("campaign_rank")."</option><option value='ingroup_grade_random'>"._QXZ("ingroup_grade_random")."</option><option value='campaign_grade_random'>"._QXZ("campaign_grade_random")."</option><option value='fewest_calls'>"._QXZ("fewest_calls")."</option><option value='fewest_calls_campaign'>"._QXZ("fewest_calls_campaign")."</option><option value='longest_wait_time'>"._QXZ("longest_wait_time")."</option><option value='ring_all'>"._QXZ("ring_all")."</option><option value='overall_user_level_wait_time'>"._QXZ("overall_user_level_wait_time")."</option><option value='campaign_rank_wait_time'>"._QXZ("campaign_rank_wait_time")."</option><option value='fewest_calls_campaign_wait_time'>"._QXZ("fewest_calls_campaign_wait_time")."</option><option value='inbound_group_rank_wait_time'>"._QXZ("inbound_group_rank_wait_time")."</option><option value='fewest_calls_wait_time'>"._QXZ("fewest_calls_wait_time")."</option><option value='$next_agent_call' SELECTED>"._QXZ("$next_agent_call")."</option></select>$NWB#inbound_groups-next_agent_call$NWE</td></tr>\n";

		if ( ($SSagent_search_method == 1) or ($SSagent_search_method == 2) )
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Search Method Override").": </td><td align=left><select size=1 name=agent_search_method>\n";
			echo "<option value=\"LB\""; if ($agent_search_method == 'LB') {echo " SELECTED";}
			echo ">LB - "._QXZ("Load Balanced")."</option>\n";
			#echo "<option value=\"LO\""; if ($agent_search_method == 'LO') {echo " SELECTED";}
			#echo ">LO - "._QXZ("Load Balanced Overflow")."</option>\n";
			echo "<option value=\"SO\""; if ($agent_search_method == 'SO') {echo " SELECTED";}
			echo ">SO - "._QXZ("Server Only")."</option>\n";
			echo "<option value=\"\""; if ($agent_search_method == '') {echo " SELECTED";}
			echo ">"._QXZ("DISABLED")."</option>\n";
			echo "</select>$NWB#inbound_groups-agent_search_method$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><input type=hidden name=agent_search_method value=\"$agent_search_method\"></td></tr>";
			}

		echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Queue Priority").": </td><td align=left><select size=1 name=queue_priority>\n";
		$n=99;
		while ($n>=-99)
			{
			$dtl = _QXZ("Even");
			if ($n<0) {$dtl = _QXZ("Lower");}
			if ($n>0) {$dtl = _QXZ("Higher");}
			if ($n == $queue_priority) 
				{echo "<option SELECTED value=\"$n\">$n - $dtl</option>\n";}
			else
				{echo "<option value=\"$n\">$n - $dtl</option>\n";}
			$n--;
			}
		echo "</select> $NWB#inbound_groups-queue_priority$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("On-Hook Ring Time").": </td><td align=left><input type=text name=on_hook_ring_time size=5 maxlength=4 value=\"$on_hook_ring_time\">$NWB#inbound_groups-on_hook_ring_time$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("On-Hook CID").": </td><td align=left><select size=1 name=on_hook_cid><option value='GENERIC' SELECTED>"._QXZ("GENERIC")."</option><option value='INGROUP'>"._QXZ("INGROUP")."</option><option value='CUSTOMER_PHONE'>"._QXZ("CUSTOMER_PHONE")."</option><option value='CUSTOMER_PHONE_RINGAGENT'>"._QXZ("CUSTOMER_PHONE_RINGAGENT")."</option><option value='CUSTOMER_PHONE_INGROUP'>"._QXZ("CUSTOMER_PHONE_INGROUP")."</option><option value='RA_AGENT_PHONE'>"._QXZ("RA_AGENT_PHONE")."</option><option value='$on_hook_cid' SELECTED>"._QXZ("$on_hook_cid")."</option></select>$NWB#inbound_groups-on_hook_cid$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("On-Hook CID Number").": </td><td align=left><input type=text name=on_hook_cid_number size=12 maxlength=18 value=\"$on_hook_cid_number\">$NWB#inbound_groups-on_hook_cid_number$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Fronter Display").": </td><td align=left><select size=1 name=fronter_display><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$fronter_display' SELECTED>"._QXZ("$fronter_display")."</option></select>$NWB#inbound_groups-fronter_display$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=3111111&script_id=$script_id\">"._QXZ("Script")."</a>: </td><td align=left><select size=1 name=script_id>\n";
		echo "$scripts_list";
		echo "<option selected value=\"$script_id\">$script_id - $scriptname_list[$script_id]</option>\n";
		echo "</select>$NWB#inbound_groups-ingroup_script$NWE</td></tr>\n";

		if ($SSenable_second_script > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=3111111&script_id=$ingroup_script_two\">"._QXZ("Script Two").": </td><td align=left><select size=1 name=ingroup_script_two>\n";
			echo "$scripts_list";
			echo "<option selected value=\"$ingroup_script_two\">"._QXZ("$ingroup_script_two")." - $scriptname_list[$ingroup_script_two]</option>\n";
			echo "</select>$NWB#inbound_groups-ingroup_script$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right></td><td align=left><input type=hidden name=ingroup_script_two value='$ingroup_script_two'></td></tr>\n";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Ignore List Script Override").": </td><td align=left><select size=1 name=ignore_list_script_override><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$ignore_list_script_override' SELECTED>"._QXZ("$ignore_list_script_override")."</option></select>$NWB#inbound_groups-ignore_list_script_override$NWE</td></tr>\n";

		##### get status group listings for dynamic pulldown menu
		$stmt="SELECT status_group_id,status_group_notes from vicidial_status_groups $whereLOGadmin_viewable_groupsSQL order by status_group_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$status_groups_to_print = mysqli_num_rows($rslt);
		$status_groups_menu='';
		$status_groups_selected=0;
		$o=0;
		while ($status_groups_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$status_groups_menu .= "<option ";
			if ($status_group_id == "$rowx[0]") 
				{
				$status_groups_menu .= "SELECTED ";
				$status_groups_selected++;
				}
			$status_groups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		$sglinkB='';   $sglinkE='';
		if (strlen($status_group_id)>1)
			{
			$sglinkB="<a href=\"$PHP_SELF?ADD=393111111111&status_group_id=$status_group_id\">";
			$sglinkE='</a>';
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>$sglinkB"._QXZ("Status Group Override")."$sglinkE: </td><td align=left><select size=1 name=status_group_id>";
		echo "<option value=\"\">"._QXZ("NONE")."</option>";
		echo "$status_groups_menu";
		echo "</select>$NWB#inbound_groups-status_group_id$NWE</td></tr>\n";

		$eswHTML=''; $cfwHTML='';
		if ($SSenable_second_script > 0)
			{$eswHTML .= "<option value='SCRIPTTWO'>"._QXZ("SCRIPTTWO")."</option>";}
		if ($SSenable_second_webform > 0)
			{$eswHTML .= "<option value='WEBFORMTWO'>"._QXZ("WEBFORMTWO")."</option>";}
		if ($SSenable_third_webform > 0)
			{$eswHTML .= "<option value='WEBFORMTHREE'>"._QXZ("WEBFORMTHREE")."</option>";}
		if ($SScustom_fields_enabled > 0)
			{$cfwHTML .= "<option value='FORM'>"._QXZ("FORM")."</option>";}
		if ($SSallow_emails > 0)
			{$aemHTML .= "<option value='EMAIL'>"._QXZ("EMAIL")."</option>";}
		if ($SSallow_chats > 0)
			{$achHTML .= "<option value='CHAT'>"._QXZ("CHAT")."</option>";}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Get Call Launch").": </td><td align=left><select size=1 name=get_call_launch><option value='NONE' selected>"._QXZ("NONE")."</option><option value='SCRIPT'>"._QXZ("SCRIPT")."</option><option value='WEBFORM'>"._QXZ("WEBFORM")."</option>$eswHTML$cfwHTML$aemHTML$achHTML<option value='$get_call_launch' selected>"._QXZ("$get_call_launch")."</option></select>$NWB#inbound_groups-get_call_launch$NWE</td></tr>\n";

		if ($SSbrowser_call_alerts > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Browser Call Alert Sound").": </td><td align=left><select size=1 name='browser_alert_sound' id='browser_alert_sound'>\n";
			$browser_alert_sounds_listARY = explode(',',$browser_alert_sounds_list);
			$browser_alert_sounds_listARY_ct = count($browser_alert_sounds_listARY);
			$bas=0;   $bas_output='';
			while ($browser_alert_sounds_listARY_ct > $bas)
				{
				$bas_output .= "<option value='$browser_alert_sounds_listARY[$bas]'>"._QXZ("$browser_alert_sounds_listARY[$bas]")."</option>";
				$bas++;
				}
			echo "$bas_output";
			echo "<option value='---NONE---'>---"._QXZ("NONE")."---</option>";
			echo "<option value='---DISABLED---'>---"._QXZ("DISABLED")."---</option>";
			echo "<option value='$browser_alert_sound' selected>"._QXZ("$browser_alert_sound")."</option>";
			echo "</select> &nbsp; \n";
			echo " "._QXZ("volume").": <select size=1 name='browser_alert_volume' id='browser_alert_volume'>";
			$bav=100;
			while ($bav >= 0)
				{
				echo "<option>$bav</option>";
				$bav = ($bav - 5);
				}
			echo "<option selected>$browser_alert_volume</option></select> &nbsp; ";
			echo "<a href=\"#\" onclick=\"play_browser_sound('browser_alert_sound','browser_alert_volume');return false;\"><font size=2 color=black>"._QXZ("play selected sound")."</font></a> $NWB#inbound_groups-browser_alert_sound$NWE &nbsp; </td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right></td><td align=left><input type=hidden name=browser_alert_sound value=\"$browser_alert_sound\"><input type=hidden name=browser_alert_volume value=\"$browser_alert_volume\"></td></tr>\n";
			}

		if ($SSallow_emails>0 || $SSallow_chats > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group Handling").": </td><td align=left><select size=1 name=group_handling><option selected value='PHONE'>"._QXZ("PHONE")."</option>";
			if ($SSallow_emails>0) {echo "<option value='EMAIL'>"._QXZ("EMAIL")."</option>";}
			if ($SSallow_chats>0) {echo "<option value='CHAT'>"._QXZ("CHAT")."</option>";}			
			echo "</select>$NWB#inbound_groups-group_handling$NWE</td></tr>\n";
			}
		else
			{echo "<tr bgcolor=#$SSstd_row4_background><td align=right></td><td align=left><input type=hidden name=group_handling value=PHONE></td></tr>\n";}

		if ($SSinbound_answer_config > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Answer Signal").": </td><td align=left><select size=1 name=answer_signal><option value='START'>"._QXZ("START")."</option><option value='ROUTE'>"._QXZ("ROUTE")."</option><option value='NONE'>"._QXZ("NONE")."</option><option value='$answer_signal' SELECTED>"._QXZ("$answer_signal")."</option></select>$NWB#inbound_groups-answer_signal$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right></td><td align=left><input type=hidden name=answer_signal value='START'></td></tr>";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Transfer-Conf DTMF")." 1: </td><td align=left><input type=text name=xferconf_a_dtmf size=20 maxlength=50 value=\"$xferconf_a_dtmf\">$NWB#inbound_groups-xferconf_a_dtmf$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Transfer-Conf Number")." 1: </td><td align=left><input type=text name=xferconf_a_number size=20 maxlength=50 value=\"$xferconf_a_number\">$NWB#inbound_groups-xferconf_a_dtmf$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Transfer-Conf DTMF")." 2: </td><td align=left><input type=text name=xferconf_b_dtmf size=20 maxlength=50 value=\"$xferconf_b_dtmf\">$NWB#inbound_groups-xferconf_a_dtmf$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Transfer-Conf Number")." 2: </td><td align=left><input type=text name=xferconf_b_number size=20 maxlength=50 value=\"$xferconf_b_number\">$NWB#inbound_groups-xferconf_a_dtmf$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Transfer-Conf Number")." 3: </td><td align=left><input type=text name=xferconf_c_number size=20 maxlength=50 value=\"$xferconf_c_number\">$NWB#inbound_groups-xferconf_a_dtmf$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Transfer-Conf Number")." 4: </td><td align=left><input type=text name=xferconf_d_number size=20 maxlength=50 value=\"$xferconf_d_number\">$NWB#inbound_groups-xferconf_a_dtmf$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Transfer-Conf Number")." 5: </td><td align=left><input type=text name=xferconf_e_number size=20 maxlength=50 value=\"$xferconf_e_number\">$NWB#inbound_groups-xferconf_a_dtmf$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Timer Action").": </td><td align=left><select size=1 name=timer_action><option value='NONE' SELECTED>"._QXZ("NONE")."</option><option value='D1_DIAL'>"._QXZ("D1_DIAL")."</option><option value='D2_DIAL'>"._QXZ("D2_DIAL")."</option><option value='D3_DIAL'>"._QXZ("D3_DIAL")."</option><option value='D4_DIAL'>"._QXZ("D4_DIAL")."</option><option value='D5_DIAL'>"._QXZ("D5_DIAL")."</option><option value='D1_DIAL_QUIET'>"._QXZ("D1_DIAL_QUIET")."</option><option value='D2_DIAL_QUIET'>"._QXZ("D2_DIAL_QUIET")."</option><option value='D3_DIAL_QUIET'>"._QXZ("D3_DIAL_QUIET")."</option><option value='D4_DIAL_QUIET'>"._QXZ("D4_DIAL_QUIET")."</option><option value='D5_DIAL_QUIET'>"._QXZ("D5_DIAL_QUIET")."</option><option value='MESSAGE_ONLY'>"._QXZ("MESSAGE_ONLY")."</option><option value='WEBFORM'>"._QXZ("WEBFORM")."</option>$eswHTML<option value='HANGUP'>"._QXZ("HANGUP")."</option><option value='CALLMENU'>"._QXZ("CALLMENU")."</option><option value='EXTENSION'>"._QXZ("EXTENSION")."</option><option value='IN_GROUP'>"._QXZ("IN_GROUP")."</option><option value='$timer_action' SELECTED>"._QXZ("$timer_action")."</option></select>$NWB#inbound_groups-timer_action$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Timer Action Message").": </td><td align=left><input type=text name=timer_action_message size=50 maxlength=255 value=\"$timer_action_message\">$NWB#inbound_groups-timer_action_message$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Timer Action Seconds").": </td><td align=left><input type=text name=timer_action_seconds size=10 maxlength=10 value=\"$timer_action_seconds\">$NWB#inbound_groups-timer_action_seconds$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Timer Action Destination").": </td><td align=left><input type=text name=timer_action_destination size=25 maxlength=30 value=\"$timer_action_destination\">$NWB#inbound_groups-timer_action_destination$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Drop Call Seconds").": </td><td align=left><input type=text name=drop_call_seconds size=5 maxlength=4 value=\"$drop_call_seconds\">$NWB#inbound_groups-drop_call_seconds$NWE</td></tr>\n";

		##### get container listings for dynamic WEEKDAY_TIMERANGE_SECONDS container pulldown menu
		$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='WEEKDAY_TIMERANGE_SECONDS' $LOGadmin_viewable_groupsSQL order by container_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$dtlc_to_print = mysqli_num_rows($rslt);
		$drop_call_seconds_override_menu='';
		$dtlc_selected=0;
		$o=0;
		while ($dtlc_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			if (mb_strlen($rowx[1],'utf-8')>40)
				{$rowx[1] = mb_substr($rowx[1],0,40,'utf-8') . '...';}
			$drop_call_seconds_override_menu .= "<option ";
			if ($drop_call_seconds_override == "$rowx[0]") 
				{
				$drop_call_seconds_override_menu .= "SELECTED ";
				$dtlc_selected++;
				}
			$drop_call_seconds_override_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}

		echo "<tr bgcolor=#99FFCC><td align=right>";
		if ($dtlc_selected > 0)
			{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$drop_call_seconds_override\">"._QXZ("Drop Seconds Override Container")."</a>";}
		else
			{echo _QXZ("Drop Seconds Override Container");}
		echo ": </td><td align=left nowrap><select size=1 name=drop_call_seconds_override><option value='DISABLED'>"._QXZ("DISABLED")."</option>$drop_call_seconds_override_menu</select>$NWB#inbound_groups-drop_call_seconds_override$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Drop Action").": </td><td align=left><select size=1 name=drop_action><option value='HANGUP'>"._QXZ("HANGUP")."</option><option value='MESSAGE'>"._QXZ("MESSAGE")."</option><option value='VOICEMAIL'>"._QXZ("VOICEMAIL")."</option><option value='VMAIL_NO_INST'>"._QXZ("VMAIL_NO_INST")."</option><option value='IN_GROUP'>"._QXZ("IN_GROUP")."</option><option value='CALLMENU'>"._QXZ("CALLMENU")."</option><option value='$drop_action' SELECTED>"._QXZ("$drop_action")."</option></select>$NWB#inbound_groups-drop_action$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Drop Lead Reset").": </td><td align=left><select size=1 name=drop_lead_reset><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$drop_lead_reset' SELECTED>"._QXZ("$drop_lead_reset")."</option></select>$NWB#inbound_groups-drop_lead_reset$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Drop Exten").": </td><td align=left><input type=text name=drop_exten size=10 maxlength=20 value=\"$drop_exten\">$NWB#inbound_groups-drop_exten$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Voicemail").": </td><td align=left><input type=text name=voicemail_ext id=voicemail_ext size=12 maxlength=10 value=\"$voicemail_ext\"> <a href=\"javascript:launch_vm_chooser('voicemail_ext','vm');\">"._QXZ("voicemail chooser")."</a>$NWB#inbound_groups-voicemail_ext$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right><a href=\"$PHP_SELF?ADD=3111&group_id=$drop_inbound_group\">"._QXZ("Drop Transfer Group").":</a> </td><td align=left><select size=1 name=drop_inbound_group>";
		echo "$Dgroups_menu";
		echo "</select>$NWB#inbound_groups-drop_inbound_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right><a href=\"$PHP_SELF?ADD=3511&menu_id=$drop_callmenu\">"._QXZ("Drop Call Menu").":</a></td><td align=left><select size=1 name=drop_callmenu id=drop_callmenu>$call_menu_list<option SELECTED>$drop_callmenu</option></select>$NWB#inbound_groups-drop_callmenu$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=311111111&call_time_id=$call_time_id\">"._QXZ("Call Time").": </a></td><td align=left><select size=1 name=call_time_id>\n";
		echo "$call_times_list";
		echo "<option selected value=\"$call_time_id\">$call_time_id - $call_timename_list[$call_time_id]</option>\n";
		echo "</select>$NWB#inbound_groups-call_time_id$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>\n";
		$stmt="SELECT ct_holidays from vicidial_call_times where call_time_id='$call_time_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$call_times_to_print = mysqli_num_rows($rslt);
		if ($call_times_to_print > 0) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$ct_holidays =	$rowx[0];
			$holiday_rules = explode('|',$ct_holidays);
			$ct_hrs = ((count($holiday_rules)) - 2);
			if ($ct_hrs < 0) {$ct_hrs=0;}
			echo _QXZ("Holidays defined for this call time").": $ct_hrs\n";
			}
		else
			{echo "<BLINK><B><font color=red>"._QXZ("Call time not found")."!: $call_time_id</font></B></BLINK>\n";}
		echo "</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Action Transfer CID").": </td><td align=left><input type=text name=action_xfer_cid size=12 maxlength=18 value=\"$action_xfer_cid\">$NWB#inbound_groups-action_xfer_cid$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("After Hours Action").": </td><td align=left><select size=1 name=after_hours_action><option value='HANGUP'>"._QXZ("HANGUP")."</option><option value='MESSAGE'>"._QXZ("MESSAGE")."</option><option value='EXTENSION'>"._QXZ("EXTENSION")."</option><option value='VOICEMAIL'>"._QXZ("VOICEMAIL")."</option><option value='VMAIL_NO_INST'>"._QXZ("VMAIL_NO_INST")."</option><option value='IN_GROUP'>"._QXZ("IN_GROUP")."</option><option value='CALLMENU'>"._QXZ("CALLMENU")."</option><option value='$after_hours_action' SELECTED>"._QXZ("$after_hours_action")."</option></select>$NWB#inbound_groups-after_hours_action$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("After Hours Lead Reset").": </td><td align=left><select size=1 name=after_hours_lead_reset><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$after_hours_lead_reset' SELECTED>"._QXZ("$after_hours_lead_reset")."</option></select>$NWB#inbound_groups-after_hours_lead_reset$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("After Hours Message Filename").": </td><td align=left><input type=text name=after_hours_message_filename id=after_hours_message_filename size=50 maxlength=255 value=\"$after_hours_message_filename\"> <a href=\"javascript:launch_chooser('after_hours_message_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-after_hours_message_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("After Hours Extension").": </td><td align=left><input type=text name=after_hours_exten size=10 maxlength=20 value=\"$after_hours_exten\">$NWB#inbound_groups-after_hours_exten$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("After Hours Voicemail").": </td><td align=left><input type=text name=after_hours_voicemail id=after_hours_voicemail size=12 maxlength=10 value=\"$after_hours_voicemail\"> <a href=\"javascript:launch_vm_chooser('after_hours_voicemail','vm');\">"._QXZ("voicemail chooser")."</a>$NWB#inbound_groups-after_hours_voicemail$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right><a href=\"$PHP_SELF?ADD=3111&group_id=$afterhours_xfer_group\">"._QXZ("After Hours Transfer Group").":</a> </td><td align=left><select size=1 name=afterhours_xfer_group>";
		echo "$Agroups_menu";
		echo "</select>$NWB#inbound_groups-afterhours_xfer_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right><a href=\"$PHP_SELF?ADD=3511&menu_id=$after_hours_callmenu\">"._QXZ("After Hours Call Menu").":</a></td><td align=left><select size=1 name=after_hours_callmenu id=after_hours_callmenu>$call_menu_list<option SELECTED>$after_hours_callmenu</option></select>$NWB#inbound_groups-after_hours_callmenu$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("No Agents No Queueing").": </td><td align=left><select size=1 name=no_agent_no_queue><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='NO_PAUSED'>"._QXZ("NO_PAUSED")."</option><option value='NO_READY'>"._QXZ("NO_READY")."</option><option value='$no_agent_no_queue' SELECTED>"._QXZ("$no_agent_no_queue")."</option></select>$NWB#inbound_groups-no_agent_no_queue$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("No Agent No Queue Action").": </td><td align=left><select size=1 name=no_agent_action id=no_agent_action onChange=\"dynamic_call_action('no_agent_action','$no_agent_action','$no_agent_action_value','600');\"><option value='CALLMENU'>"._QXZ("CALLMENU")."</option><option value='INGROUP'>"._QXZ("INGROUP")."</option><option value='DID'>"._QXZ("DID")."</option><option value='MESSAGE'>"._QXZ("MESSAGE")."</option><option value='EXTENSION'>"._QXZ("EXTENSION")."</option><option value='VOICEMAIL'>"._QXZ("VOICEMAIL")."</option><option value='VMAIL_NO_INST'>"._QXZ("VMAIL_NO_INST")."</option><option value='$no_agent_action' SELECTED>"._QXZ("$no_agent_action")."</option></select>$NWB#inbound_groups-no_agent_no_queue$NWE\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("No Agent No Queue Delay").": </td><td align=left><input type=text name=no_agent_delay id=no_agent_delay size=6 maxlength=5 value=\"$no_agent_delay\"> $NWB#inbound_groups-no_agent_delay$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("No Agent No Queue Lead Reset").": </td><td align=left><select size=1 name=nanq_lead_reset><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$nanq_lead_reset' SELECTED>"._QXZ("$nanq_lead_reset")."</option></select>$NWB#inbound_groups-nanq_lead_reset$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>";
		echo "<span id=\"no_agent_action_value_span\" name=\"no_agent_action_value_span\">\n";

		if ($no_agent_action=='CALLMENU')
			{
			echo "<span name=no_agent_action_value_link id=no_agent_action_value_link>";
			echo "<a href=\"$PHP_SELF?ADD=3511&menu_id=$no_agent_action_value\">"._QXZ("Call Menu").":</a>";
			echo "</span>";
			echo " <select size=1 name=no_agent_action_value id=no_agent_action_value onChange=\"dynamic_call_action_link('no_agent_action','CALLMENU');\">$call_menu_list<option SELECTED>$no_agent_action_value</option></select>\n";
			}
		if ($no_agent_action=='INGROUP')
			{
			if (strlen($no_agent_action_value) < 10)
				{$no_agent_action_value = 'SALESLINE,CID,LB,998,TESTCAMP,1';}
			$IGno_agent_action_value = explode(",",$no_agent_action_value);
			$IGgroup_id =		$IGno_agent_action_value[0];
			$IGhandle_method =	$IGno_agent_action_value[1];
			$IGsearch_method =	$IGno_agent_action_value[2];
			$IGlist_id =		$IGno_agent_action_value[3];
			$IGcampaign_id =	$IGno_agent_action_value[4];
			$IGphone_code =		$IGno_agent_action_value[5];
			echo "<span name=no_agent_action_value_link id=no_agent_action_value_link>";
			echo "<a href=\"$PHP_SELF?ADD=3111&group_id=$IGgroup_id\">"._QXZ("In-Group").":</a>";
			echo "</span>";
			echo " <select size=1 name=IGgroup_id_no_agent_action id=IGgroup_id_no_agent_action onChange=\"dynamic_call_action_link('IGgroup_id_no_agent_action','INGROUP');\">";
			echo "$ingroup_list<option SELECTED>$IGgroup_id</option></select>";
			echo " &nbsp; "._QXZ("Handle Method").": <select size=1 name=IGhandle_method_$j id=IGhandle_method_$j>";
			echo "<option SELECTED>$IGhandle_method</option>$IGhandle_method_list</select>\n";
			echo "<BR>"._QXZ("Search Method").": <select size=1 name=IGsearch_method_$j id=IGsearch_method_$j>";
			echo "$IGsearch_method_list<option SELECTED>$IGsearch_method</option></select>\n";
			echo " &nbsp; "._QXZ("List ID").": <input type=text size=5 maxlength=19 name=IGlist_id_$j id=IGlist_id_$j value=\"$IGlist_id\">";
			echo "<BR>"._QXZ("Campaign ID").": <select size=1 name=IGcampaign_id_$j id=IGcampaign_id_$j>";
			echo "$IGcampaign_id_list<option SELECTED>$IGcampaign_id</option></select>\n";
			echo " &nbsp; "._QXZ("Phone Code").": <input type=text size=5 maxlength=14 name=IGphone_code_$j id=IGphone_code_$j value=\"$IGphone_code\">";
			}
		if ($no_agent_action=='DID')
			{
			$stmt="SELECT did_id from vicidial_inbound_dids where did_pattern='$no_agent_action_value';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			$did_id =			$row[0];

			echo "<span name=no_agent_action_value_link id=no_agent_action_value_link>";
			echo "<a href=\"$PHP_SELF?ADD=3311&did_id=$did_id\">"._QXZ("DID").":</a>";
			echo "</span>";
			echo " <select size=1 name=no_agent_action_value id=no_agent_action_value onChange=\"dynamic_call_action_link('no_agent_action','DID');\">$did_list<option SELECTED>$no_agent_action_value</option></select>\n";
			}
		if ($no_agent_action=='MESSAGE')
			{
			if (strlen($no_agent_action_value) < 3)
				{$no_agent_action_value = 'nbdy-avail-to-take-call|vm-goodbye';}
			echo _QXZ("Audio File").": <input type=text name=no_agent_action_value id=no_agent_action_value size=50 maxlength=255 value=\"$no_agent_action_value\"> <a href=\"javascript:launch_chooser('no_agent_action_value','date');\">"._QXZ("audio chooser")."</a>\n";
			}
		if ($no_agent_action=='EXTENSION')
			{
			if (strlen($no_agent_action_value) < 3)
				{$no_agent_action_value = '8304,default';}
			$EXno_agent_action_value = explode(",",$no_agent_action_value);
			$EXextension =	$EXno_agent_action_value[0];
			$EXcontext =	$EXno_agent_action_value[1];
			echo _QXZ("Extension").": <input type=text name=EXextension_no_agent_action id=EXextension_no_agent_action size=20 maxlength=255 value=\"$EXextension\"> &nbsp; "._QXZ("Context").": <input type=text name=EXcontext_no_agent_action id=EXcontext_no_agent_action size=20 maxlength=255 value=\"$EXcontext\">\n";
			}
		if ( ($no_agent_action=='VOICEMAIL') or  ($no_agent_action=='VMAIL_NO_INST') )
			{
			echo _QXZ("Voicemail Box").": <input type=text name=no_agent_action_value id=no_agent_action_value size=12 maxlength=10 value=\"$no_agent_action_value\"> <a href=\"javascript:launch_vm_chooser('no_agent_action_value','vm');\">"._QXZ("voicemail chooser")."</a>\n";
			}

		echo "</span>
		<BR> &nbsp; </td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("In-Queue No Agents Check").": </td><td align=left><select size=1 name=in_queue_nanque><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='NO_PAUSED'>"._QXZ("NO_PAUSED")."</option><option value='NO_PAUSED_EXCEPTIONS'>"._QXZ("NO_PAUSED_EXCEPTIONS")."</option><option value='NO_READY'>"._QXZ("NO_READY")."</option><option value='$in_queue_nanque' SELECTED>"._QXZ("$in_queue_nanque")."</option></select>$NWB#inbound_groups-in_queue_nanque$NWE</td></tr>\n";

		##### get container listings for dynamic PAUSE_CODES_LIST container pulldown menu
		$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='PAUSE_CODES_LIST' $LOGadmin_viewable_groupsSQL order by container_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$dtlc_to_print = mysqli_num_rows($rslt);
		$in_queue_nanque_exceptions_menu='';
		$dtlc_selected=0;
		$o=0;
		while ($dtlc_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			if (mb_strlen($rowx[1],'utf-8')>40)
				{$rowx[1] = mb_substr($rowx[1],0,40,'utf-8') . '...';}
			$in_queue_nanque_exceptions_menu .= "<option ";
			if ($in_queue_nanque_exceptions == "$rowx[0]") 
				{
				$in_queue_nanque_exceptions_menu .= "SELECTED ";
				$dtlc_selected++;
				}
			$in_queue_nanque_exceptions_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>";
		if ($dtlc_selected > 0)
			{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$in_queue_nanque_exceptions\">"._QXZ("In-Queue No Agents Pause Exceptions")."</a>";}
		else
			{echo _QXZ("In-Queue No Agents Pause Exceptions");}
		echo ": </td><td align=left nowrap><select size=1 name=in_queue_nanque_exceptions><option value=''>"._QXZ("DISABLED")."</option>$in_queue_nanque_exceptions_menu</select>$NWB#inbound_groups-in_queue_nanque_exceptions$NWE</td></tr>\n";


		$stmt="SELECT count(*) from vicidial_areacode_filters where group_id='$group_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$vaf_count =	$row[0];

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Areacode Filter").": </td><td align=left><select size=1 name=areacode_filter><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ALLOW_ONLY'>"._QXZ("ALLOW_ONLY")."</option><option value='DROP_ONLY'>"._QXZ("DROP_ONLY")."</option><option value='$areacode_filter' SELECTED>"._QXZ("$areacode_filter")."</option></select>$NWB#inbound_groups-areacode_filter$NWE &nbsp; <a href=\"$PHP_SELF?ADD=3211&group_id=$group_id\">"._QXZ("areacode filter list").": $vaf_count</a></td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Areacode Filter Seconds").": </td><td align=left><input type=text name=areacode_filter_seconds id=areacode_filter_seconds size=6 maxlength=5 value=\"$areacode_filter_seconds\"> $NWB#inbound_groups-areacode_filter_seconds$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Areacode Filter Action").": </td><td align=left><select size=1 name=areacode_filter_action id=areacode_filter_action onChange=\"dynamic_call_action('areacode_filter_action','$areacode_filter_action','$areacode_filter_action_value','700');\"><option value='CALLMENU'>"._QXZ("CALLMENU")."</option><option value='INGROUP'>"._QXZ("INGROUP")."</option><option value='DID'>"._QXZ("DID")."</option><option value='MESSAGE'>"._QXZ("MESSAGE")."</option><option value='EXTENSION'>"._QXZ("EXTENSION")."</option><option value='VOICEMAIL'>"._QXZ("VOICEMAIL")."</option><option value='VMAIL_NO_INST'>"._QXZ("VMAIL_NO_INST")."</option><option value='$areacode_filter_action' SELECTED>"._QXZ("$areacode_filter_action")."</option></select>$NWB#inbound_groups-areacode_filter_action$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=center colspan=2>";
		echo "<span id=\"areacode_filter_action_value_span\" name=\"areacode_filter_action_value_span\">\n";

		if ($areacode_filter_action=='CALLMENU')
			{
			echo "<span name=areacode_filter_action_value_link id=areacode_filter_action_value_link>";
			echo "<a href=\"$PHP_SELF?ADD=3511&menu_id=$areacode_filter_action_value\">"._QXZ("Call Menu").":</a>";
			echo "</span>";
			echo " <select size=1 name=areacode_filter_action_value id=areacode_filter_action_value onChange=\"dynamic_call_action_link('areacode_filter_action','CALLMENU');\">$call_menu_list<option SELECTED>$areacode_filter_action_value</option></select>\n";
			}
		if ($areacode_filter_action=='INGROUP')
			{
			if (strlen($areacode_filter_action_value) < 10)
				{$areacode_filter_action_value = 'SALESLINE,CID,LB,998,TESTCAMP,1';}
			$IGareacode_filter_action_value = explode(",",$areacode_filter_action_value);
			$IGgroup_id =		$IGareacode_filter_action_value[0];
			$IGhandle_method =	$IGareacode_filter_action_value[1];
			$IGsearch_method =	$IGareacode_filter_action_value[2];
			$IGlist_id =		$IGareacode_filter_action_value[3];
			$IGcampaign_id =	$IGareacode_filter_action_value[4];
			$IGphone_code =		$IGareacode_filter_action_value[5];
			echo "<span name=areacode_filter_action_value_link id=areacode_filter_action_value_link>";
			echo "<a href=\"$PHP_SELF?ADD=3111&group_id=$IGgroup_id\">"._QXZ("In-Group").":</a>";
			echo "</span>";
			echo " <select size=1 name=IGgroup_id_areacode_filter_action id=IGgroup_id_areacode_filter_action onChange=\"dynamic_call_action_link('IGgroup_id_areacode_filter_action','INGROUP');\">";
			echo "$ingroup_list<option SELECTED>$IGgroup_id</option></select>";
			echo " &nbsp; "._QXZ("Handle Method").": <select size=1 name=IGhandle_method_$j id=IGhandle_method_$j>";
			echo "<option SELECTED>$IGhandle_method</option>$IGhandle_method_list</select>\n";
			echo "<BR>"._QXZ("Search Method").": <select size=1 name=IGsearch_method_$j id=IGsearch_method_$j>";
			echo "$IGsearch_method_list<option SELECTED>$IGsearch_method</option></select>\n";
			echo " &nbsp; "._QXZ("List ID").": <input type=text size=5 maxlength=19 name=IGlist_id_$j id=IGlist_id_$j value=\"$IGlist_id\">";
			echo "<BR>"._QXZ("Campaign ID").": <select size=1 name=IGcampaign_id_$j id=IGcampaign_id_$j>";
			echo "$IGcampaign_id_list<option SELECTED>$IGcampaign_id</option></select>\n";
			echo " &nbsp; "._QXZ("Phone Code").": <input type=text size=5 maxlength=14 name=IGphone_code_$j id=IGphone_code_$j value=\"$IGphone_code\">";
			}
		if ($areacode_filter_action=='DID')
			{
			$stmt="SELECT did_id from vicidial_inbound_dids where did_pattern='$areacode_filter_action_value';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			$did_id =			$row[0];

			echo "<span name=areacode_filter_action_value_link id=areacode_filter_action_value_link>";
			echo "<a href=\"$PHP_SELF?ADD=3311&did_id=$did_id\">"._QXZ("DID").":</a>";
			echo "</span>";
			echo " <select size=1 name=areacode_filter_action_value id=areacode_filter_action_value onChange=\"dynamic_call_action_link('areacode_filter_action','DID');\">$did_list<option SELECTED>$areacode_filter_action_value</option></select>\n";
			}
		if ($areacode_filter_action=='MESSAGE')
			{
			if (strlen($areacode_filter_action_value) < 3)
				{$areacode_filter_action_value = 'nbdy-avail-to-take-call|vm-goodbye';}
			echo _QXZ("Audio File").": <input type=text name=areacode_filter_action_value id=areacode_filter_action_value size=50 maxlength=255 value=\"$areacode_filter_action_value\"> <a href=\"javascript:launch_chooser('areacode_filter_action_value','date');\">"._QXZ("audio chooser")."</a>\n";
			}
		if ($areacode_filter_action=='EXTENSION')
			{
			if (strlen($areacode_filter_action_value) < 3)
				{$areacode_filter_action_value = '8304,default';}
			$EXareacode_filter_action_value = explode(",",$areacode_filter_action_value);
			$EXextension =	$EXareacode_filter_action_value[0];
			$EXcontext =	$EXareacode_filter_action_value[1];
			echo _QXZ("Extension").": <input type=text name=EXextension_areacode_filter_action id=EXextension_areacode_filter_action size=20 maxlength=255 value=\"$EXextension\"> &nbsp; "._QXZ("Context").": <input type=text name=EXcontext_areacode_filter_action id=EXcontext_areacode_filter_action size=20 maxlength=255 value=\"$EXcontext\">\n";
			}
		if ( ($areacode_filter_action=='VOICEMAIL') or  ($areacode_filter_action=='VMAIL_NO_INST') )
			{
			echo _QXZ("Voicemail Box").": <input type=text name=areacode_filter_action_value id=areacode_filter_action_value size=12 maxlength=10 value=\"$areacode_filter_action_value\"> <a href=\"javascript:launch_vm_chooser('areacode_filter_action_value','vm');\">"._QXZ("voicemail chooser")."</a>\n";
			}

		echo "</span>
		<BR> &nbsp; </td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Max Calls Method").": </td><td align=left><select size=1 name=max_calls_method><option value='TOTAL'>"._QXZ("TOTAL")."</option><option value='IN_QUEUE'>"._QXZ("IN_QUEUE")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$max_calls_method' SELECTED>"._QXZ("$max_calls_method")."</option></select>$NWB#inbound_groups-max_calls_method$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Max Calls Count").": </td><td align=left><input type=text name=max_calls_count id=max_calls_count size=6 maxlength=5 value=\"$max_calls_count\"> $NWB#inbound_groups-max_calls_count$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Max Calls Action").": </td><td align=left><select size=1 name=max_calls_action><option value='DROP'>"._QXZ("DROP")."</option><option value='AFTERHOURS'>"._QXZ("AFTERHOURS")."</option><option value='NO_AGENT_NO_QUEUE'>"._QXZ("NO_AGENT_NO_QUEUE")."</option><option value='AREACODE_FILTER'>"._QXZ("AREACODE_FILTER")."</option><option value='$max_calls_action' SELECTED>"._QXZ("$max_calls_action")."</option></select>$NWB#inbound_groups-max_calls_action$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Welcome Message Filename").": </td><td align=left><input type=text name=welcome_message_filename id=welcome_message_filename size=50 maxlength=255 value=\"$welcome_message_filename\"> <a href=\"javascript:launch_chooser('welcome_message_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-welcome_message_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Play Welcome Message").": </td><td align=left><select size=1 name=play_welcome_message><option value='ALWAYS'>"._QXZ("ALWAYS")."</option><option value='NEVER'>"._QXZ("NEVER")."</option><option value='IF_WAIT_ONLY'>"._QXZ("IF_WAIT_ONLY")."</option><option value='YES_UNLESS_NODELAY'>"._QXZ("YES_UNLESS_NODELAY")."</option><option value='$play_welcome_message' SELECTED>"._QXZ("$play_welcome_message")."</option></select>$NWB#inbound_groups-play_welcome_message$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Music On Hold Context").": </td><td align=left><input type=text name=moh_context id=moh_context size=50 maxlength=50 value=\"$moh_context\"> <a href=\"javascript:launch_moh_chooser('moh_context','moh');\">"._QXZ("moh chooser")."</a> $NWB#inbound_groups-moh_context$NWE</td></tr>\n";

		$wav='.wav';
		$gsm='.gsm';
		$ohpf_message='';
		$stmt="SELECT audio_length from audio_store_details where audio_filename IN('$onhold_prompt_filename$wav','$onhold_prompt_filename$gsm') order by audio_length desc limit 1;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$audio_to_print = mysqli_num_rows($rslt);
		if ($audio_to_print > 0) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$audio_length =	$rowx[0];
			if ($audio_length > 9) {$ohpf_message="<tr bgcolor=#$SSstd_row4_background><td colspan=2 align=center><B><font color=red>"._QXZ("The On Hold Prompt Filename you have selected above is too long, please select one that is 9 seconds or less.")." &nbsp; </font></B><font size=0>($audio_length "._QXZ("seconds").")</font></td></tr>\n";}
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("On Hold Prompt Filename").": </td><td align=left><input type=text name=onhold_prompt_filename id=onhold_prompt_filename size=50 maxlength=255 value=\"$onhold_prompt_filename\"> <a href=\"javascript:launch_chooser('onhold_prompt_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-onhold_prompt_filename$NWE</td></tr>\n$ohpf_message";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("On Hold Prompt Interval").": </td><td align=left><input type=text name=prompt_interval size=5 maxlength=5 value=\"$prompt_interval\">$NWB#inbound_groups-prompt_interval$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("On Hold Prompt No Block").": </td><td align=left><select size=1 name=onhold_prompt_no_block><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$onhold_prompt_no_block' SELECTED>"._QXZ("$onhold_prompt_no_block")."</option></select>$NWB#inbound_groups-onhold_prompt_no_block$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("On Hold Prompt Seconds").": </td><td align=left><input type=text name=onhold_prompt_seconds size=5 maxlength=5 value=\"$onhold_prompt_seconds\">$NWB#inbound_groups-onhold_prompt_seconds$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Play Place in Line").": </td><td align=left><select size=1 name=play_place_in_line><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$play_place_in_line' SELECTED>"._QXZ("$play_place_in_line")."</option></select>$NWB#inbound_groups-play_place_in_line$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Place in Line Caller Number").": </td><td align=left><input type=text name=place_in_line_caller_number_filename id=place_in_line_caller_number_filename size=50 maxlength=255 value=\"$place_in_line_caller_number_filename\"> <a href=\"javascript:launch_chooser('place_in_line_caller_number_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-place_in_line_caller_number_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Place in Line You Are Next Filename").": </td><td align=left><input type=text name=place_in_line_you_next_filename id=place_in_line_you_next_filename size=50 maxlength=255 value=\"$place_in_line_you_next_filename\"> <a href=\"javascript:launch_chooser('place_in_line_you_next_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-place_in_line_you_next_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Play Estimated Hold Time").": </td><td align=left><select size=1 name=play_estimate_hold_time><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$play_estimate_hold_time' SELECTED>"._QXZ("$play_estimate_hold_time")."</option></select>$NWB#inbound_groups-play_estimate_hold_time$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Calculate Estimated Hold Seconds").": </td><td align=left><input type=text name=calculate_estimated_hold_seconds size=5 maxlength=5 value=\"$calculate_estimated_hold_seconds\">$NWB#inbound_groups-calculate_estimated_hold_seconds$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Estimated Hold Time Minimum Filename").": </td><td align=left><input type=text name=eht_minimum_prompt_filename id=eht_minimum_prompt_filename size=50 maxlength=255 value=\"$eht_minimum_prompt_filename\"> <a href=\"javascript:launch_chooser('eht_minimum_prompt_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-eht_minimum_prompt_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Estimated Hold Time Minimum Prompt No Block").": </td><td align=left><select size=1 name=eht_minimum_prompt_no_block><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$eht_minimum_prompt_no_block' SELECTED>"._QXZ("$eht_minimum_prompt_no_block")."</option></select>$NWB#inbound_groups-eht_minimum_prompt_no_block$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Estimated Hold Time Minimum Prompt Seconds").": </td><td align=left><input type=text name=eht_minimum_prompt_seconds size=5 maxlength=5 value=\"$eht_minimum_prompt_seconds\">$NWB#inbound_groups-eht_minimum_prompt_seconds$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Wait Time Option").": </td><td align=left><select size=1 name=wait_time_option><option value='NONE'>"._QXZ("NONE")."</option><option value='PRESS_STAY'>"._QXZ("PRESS_STAY")."</option><option value='PRESS_VMAIL'>"._QXZ("PRESS_VMAIL")."</option><option value='PRESS_VMAIL_NO_INST'>"._QXZ("PRESS_VMAIL_NO_INST")."</option><option value='PRESS_EXTEN'>"._QXZ("PRESS_EXTEN")."</option><option value='PRESS_CALLMENU'>"._QXZ("PRESS_CALLMENU")."</option><option value='PRESS_CID_CALLBACK'>"._QXZ("PRESS_CID_CALLBACK")."</option><option value='PRESS_INGROUP'>"._QXZ("PRESS_INGROUP")."</option><option value='PRESS_CALLBACK_QUEUE'>"._QXZ("PRESS_CALLBACK_QUEUE")."</option><option value='$wait_time_option' SELECTED>"._QXZ("$wait_time_option")."</option></select>$NWB#inbound_groups-wait_time_option$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Wait Time Second Option").": </td><td align=left><select size=1 name=wait_time_second_option><option value='NONE'>"._QXZ("NONE")."</option><option value='PRESS_STAY'>"._QXZ("PRESS_STAY")."</option><option value='PRESS_VMAIL'>"._QXZ("PRESS_VMAIL")."</option><option value='PRESS_VMAIL_NO_INST'>"._QXZ("PRESS_VMAIL_NO_INST")."</option><option value='PRESS_EXTEN'>"._QXZ("PRESS_EXTEN")."</option><option value='PRESS_CALLMENU'>"._QXZ("PRESS_CALLMENU")."</option><option value='PRESS_CID_CALLBACK'>"._QXZ("PRESS_CID_CALLBACK")."</option><option value='PRESS_INGROUP'>"._QXZ("PRESS_INGROUP")."</option><option value='PRESS_CALLBACK_QUEUE'>"._QXZ("PRESS_CALLBACK_QUEUE")."</option><option value='$wait_time_second_option' SELECTED>"._QXZ("$wait_time_second_option")."</option></select>$NWB#inbound_groups-wait_time_second_option$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Wait Time Third Option").": </td><td align=left><select size=1 name=wait_time_third_option><option value='NONE'>"._QXZ("NONE")."</option><option value='PRESS_STAY'>"._QXZ("PRESS_STAY")."</option><option value='PRESS_VMAIL'>"._QXZ("PRESS_VMAIL")."</option><option value='PRESS_VMAIL_NO_INST'>"._QXZ("PRESS_VMAIL_NO_INST")."</option><option value='PRESS_EXTEN'>"._QXZ("PRESS_EXTEN")."</option><option value='PRESS_CALLMENU'>"._QXZ("PRESS_CALLMENU")."</option><option value='PRESS_CID_CALLBACK'>"._QXZ("PRESS_CID_CALLBACK")."</option><option value='PRESS_INGROUP'>"._QXZ("PRESS_INGROUP")."</option><option value='PRESS_CALLBACK_QUEUE'>"._QXZ("PRESS_CALLBACK_QUEUE")."</option><option value='$wait_time_third_option' SELECTED>"._QXZ("$wait_time_third_option")."</option></select>$NWB#inbound_groups-wait_time_third_option$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Wait Time Option Seconds").": </td><td align=left><input type=text name=wait_time_option_seconds size=5 maxlength=5 value=\"$wait_time_option_seconds\">$NWB#inbound_groups-wait_time_option_seconds$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Wait Time Option Lead Reset").": </td><td align=left><select size=1 name=wait_time_lead_reset><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$wait_time_lead_reset' SELECTED>"._QXZ("$wait_time_lead_reset")."</option></select>$NWB#inbound_groups-wait_time_lead_reset$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Wait Time Option Extension").": </td><td align=left><input type=text name=wait_time_option_exten size=20 maxlength=20 value=\"$wait_time_option_exten\">$NWB#inbound_groups-wait_time_option_exten$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right><a href=\"$PHP_SELF?ADD=3511&menu_id=$wait_time_option_callmenu\">"._QXZ("Wait Time Option Callmenu")."</a>: </td><td align=left><select size=1 name=wait_time_option_callmenu>\n";
		echo "$Wmenuslist";
		echo "</select>$NWB#inbound_groups-wait_time_option_callmenu$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Wait Time Option Voicemail").": </td><td align=left><input type=text name=wait_time_option_voicemail id=wait_time_option_voicemail size=12 maxlength=10 value=\"$wait_time_option_voicemail\"> <a href=\"javascript:launch_vm_chooser('wait_time_option_voicemail','vm');\">"._QXZ("voicemail chooser")."</a> $NWB#inbound_groups-wait_time_option_voicemail$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Wait Time Option Transfer In-Group").": </td><td align=left><select size=1 name=wait_time_option_xfer_group>";
		echo "$Wgroups_menu";
		echo "</select>$NWB#inbound_groups-wait_time_option_xfer_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Wait Time Option Press Filename").": </td><td align=left><input type=text name=wait_time_option_press_filename id=wait_time_option_press_filename size=50 maxlength=255 value=\"$wait_time_option_press_filename\"> <a href=\"javascript:launch_chooser('wait_time_option_press_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-wait_time_option_press_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Wait Time Option Press No Block").": </td><td align=left><select size=1 name=wait_time_option_no_block><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$wait_time_option_no_block' SELECTED>"._QXZ("$wait_time_option_no_block")."</option></select>$NWB#inbound_groups-wait_time_option_no_block$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Wait Time Option Press Filename Seconds").": </td><td align=left><input type=text name=wait_time_option_prompt_seconds size=5 maxlength=5 value=\"$wait_time_option_prompt_seconds\">$NWB#inbound_groups-wait_time_option_prompt_seconds$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Wait Time Option After Press Filename").": </td><td align=left><input type=text name=wait_time_option_callback_filename id=wait_time_option_callback_filename size=50 maxlength=255 value=\"$wait_time_option_callback_filename\"> <a href=\"javascript:launch_chooser('wait_time_option_callback_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-wait_time_option_callback_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Wait Time Option Callback List ID").": </td><td align=left><input type=text name=wait_time_option_callback_list_id size=19 maxlength=19 value=\"$wait_time_option_callback_list_id\">$NWB#inbound_groups-wait_time_option_callback_list_id$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Wait Hold Option Priority").": </td><td align=left><select size=1 name=wait_hold_option_priority><option value='WAIT'>"._QXZ("WAIT")."</option><option value='BOTH'>"._QXZ("BOTH")."</option><option value='$wait_hold_option_priority' SELECTED>"._QXZ("$wait_hold_option_priority")."</option></select>$NWB#inbound_groups-wait_hold_option_priority$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Estimated Hold Time Option").": </td><td align=left><select size=1 name=hold_time_option><option value='NONE'>"._QXZ("NONE")."</option><option value='EXTENSION'>"._QXZ("EXTENSION")."</option><option value='CALL_MENU'>"._QXZ("CALL_MENU")."</option><option value='VOICEMAIL'>"._QXZ("VOICEMAIL")."</option><option value='VMAIL_NO_INST'>"._QXZ("VMAIL_NO_INST")."</option><option value='IN_GROUP'>"._QXZ("IN_GROUP")."</option><option value='CALLERID_CALLBACK'>"._QXZ("CALLERID_CALLBACK")."</option><option value='DROP_ACTION'>"._QXZ("DROP_ACTION")."</option><option value='PRESS_STAY'>"._QXZ("PRESS_STAY")."</option><option value='PRESS_VMAIL'>"._QXZ("PRESS_VMAIL")."</option><option value='PRESS_VMAIL_NO_INST'>"._QXZ("PRESS_VMAIL_NO_INST")."</option><option value='PRESS_EXTEN'>"._QXZ("PRESS_EXTEN")."</option><option value='PRESS_CALLMENU'>"._QXZ("PRESS_CALLMENU")."</option><option value='PRESS_CID_CALLBACK'>"._QXZ("PRESS_CID_CALLBACK")."</option><option value='PRESS_INGROUP'>"._QXZ("PRESS_INGROUP")."</option><option value='PRESS_CALLBACK_QUEUE'>"._QXZ("PRESS_CALLBACK_QUEUE")."</option><option value='$hold_time_option' SELECTED>"._QXZ("$hold_time_option")."</option></select>$NWB#inbound_groups-hold_time_option$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Hold Time Second Option").": </td><td align=left><select size=1 name=hold_time_second_option><option value='NONE'>"._QXZ("NONE")."</option><option value='PRESS_STAY'>"._QXZ("PRESS_STAY")."</option><option value='PRESS_VMAIL'>"._QXZ("PRESS_VMAIL")."</option><option value='PRESS_VMAIL_NO_INST'>"._QXZ("PRESS_VMAIL_NO_INST")."</option><option value='PRESS_EXTEN'>"._QXZ("PRESS_EXTEN")."</option><option value='PRESS_CALLMENU'>"._QXZ("PRESS_CALLMENU")."</option><option value='PRESS_CID_CALLBACK'>"._QXZ("PRESS_CID_CALLBACK")."</option><option value='PRESS_INGROUP'>"._QXZ("PRESS_INGROUP")."</option><option value='PRESS_CALLBACK_QUEUE'>"._QXZ("PRESS_CALLBACK_QUEUE")."</option><option value='$hold_time_second_option' SELECTED>"._QXZ("$hold_time_second_option")."</option></select>$NWB#inbound_groups-hold_time_second_option$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Hold Time Third Option").": </td><td align=left><select size=1 name=hold_time_third_option><option value='NONE'>"._QXZ("NONE")."</option><option value='PRESS_STAY'>"._QXZ("PRESS_STAY")."</option><option value='PRESS_VMAIL'>"._QXZ("PRESS_VMAIL")."</option><option value='PRESS_VMAIL_NO_INST'>"._QXZ("PRESS_VMAIL_NO_INST")."</option><option value='PRESS_EXTEN'>"._QXZ("PRESS_EXTEN")."</option><option value='PRESS_CALLMENU'>"._QXZ("PRESS_CALLMENU")."</option><option value='PRESS_CID_CALLBACK'>"._QXZ("PRESS_CID_CALLBACK")."</option><option value='PRESS_INGROUP'>"._QXZ("PRESS_INGROUP")."</option><option value='PRESS_CALLBACK_QUEUE'>"._QXZ("PRESS_CALLBACK_QUEUE")."</option><option value='$hold_time_third_option' SELECTED>"._QXZ("$hold_time_third_option")."</option></select>$NWB#inbound_groups-hold_time_third_option$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Hold Time Option Seconds").": </td><td align=left><input type=text name=hold_time_option_seconds size=5 maxlength=5 value=\"$hold_time_option_seconds\">$NWB#inbound_groups-hold_time_option_seconds$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Hold Time Option Lead Reset").": </td><td align=left><select size=1 name=hold_time_lead_reset><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$hold_time_lead_reset' SELECTED>"._QXZ("$hold_time_lead_reset")."</option></select>$NWB#inbound_groups-hold_time_lead_reset$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Hold Time Option Minimum").": </td><td align=left><input type=text name=hold_time_option_minimum size=5 maxlength=5 value=\"$hold_time_option_minimum\">$NWB#inbound_groups-hold_time_option_minimum$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Hold Time Option Extension").": </td><td align=left><input type=text name=hold_time_option_exten size=20 maxlength=20 value=\"$hold_time_option_exten\">$NWB#inbound_groups-hold_time_option_exten$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right><a href=\"$PHP_SELF?ADD=3511&menu_id=$hold_time_option_callmenu\">"._QXZ("Hold Time Option Callmenu")."</a>: </td><td align=left><select size=1 name=hold_time_option_callmenu>\n";
		echo "$Xmenuslist";
		echo "</select>$NWB#inbound_groups-hold_time_option_callmenu$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Hold Time Option Voicemail").": </td><td align=left><input type=text name=hold_time_option_voicemail id=hold_time_option_voicemail size=12 maxlength=10 value=\"$hold_time_option_voicemail\"> <a href=\"javascript:launch_vm_chooser('hold_time_option_voicemail','vm');\">"._QXZ("voicemail chooser")."</a> $NWB#inbound_groups-hold_time_option_voicemail$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Hold Time Option Transfer In-Group").": </td><td align=left><select size=1 name=hold_time_option_xfer_group>";
		echo "$Tgroups_menu";
		echo "</select>$NWB#inbound_groups-hold_time_option_xfer_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Hold Time Option Press Filename").": </td><td align=left><input type=text name=hold_time_option_press_filename id=hold_time_option_press_filename size=50 maxlength=255 value=\"$hold_time_option_press_filename\"> <a href=\"javascript:launch_chooser('hold_time_option_press_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-hold_time_option_press_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Hold Time Option Press No Block").": </td><td align=left><select size=1 name=hold_time_option_no_block><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$hold_time_option_no_block' SELECTED>"._QXZ("$hold_time_option_no_block")."</option></select>$NWB#inbound_groups-hold_time_option_no_block$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Hold Time Option Press Filename Seconds").": </td><td align=left><input type=text name=hold_time_option_prompt_seconds size=5 maxlength=5 value=\"$hold_time_option_prompt_seconds\">$NWB#inbound_groups-hold_time_option_prompt_seconds$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Hold Time Option After Press Filename").": </td><td align=left><input type=text name=hold_time_option_callback_filename id=hold_time_option_callback_filename size=50 maxlength=255 value=\"$hold_time_option_callback_filename\"> <a href=\"javascript:launch_chooser('hold_time_option_callback_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-hold_time_option_callback_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Hold Time Option Callback List ID").": </td><td align=left><input type=text name=hold_time_option_callback_list_id size=19 maxlength=19 value=\"$hold_time_option_callback_list_id\">$NWB#inbound_groups-hold_time_option_callback_list_id$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Callback Queue Expire Hours").": </td><td align=left><input type=text name=icbq_expiration_hours id=icbq_expiration_hours size=6 maxlength=6 value=\"$icbq_expiration_hours\"> $NWB#inbound_groups-icbq_expiration_hours$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=311111111&call_time_id=$icbq_call_time_id\">"._QXZ("Callback Queue Call Time").": </a></td><td align=left><select size=1 name=icbq_call_time_id>\n";
		echo "$call_times_list";
		echo "<option selected value=\"$icbq_call_time_id\">$icbq_call_time_id - $call_timename_list[$icbq_call_time_id]</option>\n";
		echo "</select>$NWB#inbound_groups-icbq_call_time_id$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>\n";
		$stmt="SELECT ct_holidays from vicidial_call_times where call_time_id='$icbq_call_time_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$call_times_to_print = mysqli_num_rows($rslt);
		if ($call_times_to_print > 0) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$ct_holidays =	$rowx[0];
			$holiday_rules = explode('|',$ct_holidays);
			$ct_hrs = ((count($holiday_rules)) - 2);
			if ($ct_hrs < 0) {$ct_hrs=0;}
			echo _QXZ("Holidays defined for this callback queue call time").": $ct_hrs\n";
			}
		else
			{echo "<BLINK><B><font color=red>"._QXZ("Call time not found")."!: $icbq_call_time_id</font></B></BLINK>\n";}
		echo "</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Callback Queue Dial Filter").": </td><td align=left><select size=1 name=icbq_dial_filter><option value='NONE'>"._QXZ("NONE")."</option><option value=\"DNC_INTERNAL\">"._QXZ("DNC_INTERNAL")."</option><option value=\"DNC_CAMPAIGN\">"._QXZ("DNC_CAMPAIGN")."</option><option value=\"DNC_INTERNAL_AND_CAMPAIGN\">"._QXZ("DNC_INTERNAL_AND_CAMPAIGN")."</option><option value=\"DNC_INTERNAL_WITH_AREACODE\">"._QXZ("DNC_INTERNAL_WITH_AREACODE")."</option><option value=\"DNC_CAMPAIGN_WITH_AREACODE\">"._QXZ("DNC_CAMPAIGN_WITH_AREACODE")."</option><option value=\"DNC_INTERNAL_AND_CAMPAIGN_WITH_AREACODE\">"._QXZ("DNC_INTERNAL_AND_CAMPAIGN_WITH_AREACODE")."</option><option value='$icbq_dial_filter' SELECTED>"._QXZ("$icbq_dial_filter")."</option></select>$NWB#inbound_groups-icbq_dial_filter$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("CID Callback Number Validation").": </td><td align=left><select size=1 name=cid_cb_confirm_number><option value='NO'>"._QXZ("NO")."</option><option value=\"YES\">"._QXZ("YES")."</option><option value=\"ONLY_IF_INVALID\">"._QXZ("ONLY_IF_INVALID")."</option><option value='$cid_cb_confirm_number' SELECTED>"._QXZ("$cid_cb_confirm_number")."</option></select>$NWB#inbound_groups-cid_cb_confirm_number$NWE</td></tr>\n";

		$stmt="SELECT filter_phone_group_id,filter_phone_group_name from vicidial_filter_phone_groups $whereLOGadmin_viewable_groupsSQL order by filter_phone_group_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$Fgroups_to_print = mysqli_num_rows($rslt);
		$Fgroups_list='';
		$i=0;
		while ($i < $Fgroups_to_print)
			{
			$row=mysqli_fetch_row($rslt);
			$Fgroups_list .= "<option value=\"$row[0]\">$row[0] - $row[1] - $row[2]</option>";
			$i++;
			}

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right><a href=\"$PHP_SELF?ADD=3711&filter_phone_group_id=$cid_cb_invalid_filter_phone_group\">"._QXZ("CID Callback Number Invalid Filter Phone Group").":</a> </td><td align=left><select size=1 name=cid_cb_invalid_filter_phone_group>$Fgroups_list<option value='$cid_cb_invalid_filter_phone_group' SELECTED>"._QXZ("$cid_cb_invalid_filter_phone_group")."</option><option value=\"\">---"._QXZ("NONE")."---</option></select>$NWB#inbound_groups-cid_cb_invalid_filter_phone_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("CID Callback Number Length").": </td><td align=left><input type=text name=cid_cb_valid_length id=cid_cb_valid_length size=20 maxlength=30 value=\"$cid_cb_valid_length\"> $NWB#inbound_groups-cid_cb_valid_length$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("CID Callback Number Valid Filename").": </td><td align=left><input type=text name=cid_cb_valid_filename id=cid_cb_valid_filename size=50 maxlength=255 value=\"$cid_cb_valid_filename\"> <a href=\"javascript:launch_chooser('cid_cb_valid_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-cid_cb_valid_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("CID Callback Number Confirmed Filename").": </td><td align=left><input type=text name=cid_cb_confirmed_filename id=cid_cb_confirmed_filename size=50 maxlength=255 value=\"$cid_cb_confirmed_filename\"> <a href=\"javascript:launch_chooser('cid_cb_confirmed_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-cid_cb_confirmed_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("CID Callback Number Enter Filename").": </td><td align=left><input type=text name=cid_cb_enter_filename id=cid_cb_enter_filename size=50 maxlength=255 value=\"$cid_cb_enter_filename\"> <a href=\"javascript:launch_chooser('cid_cb_enter_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-cid_cb_enter_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("CID Callback Number You Entered Filename").": </td><td align=left><input type=text name=cid_cb_you_entered_filename id=cid_cb_you_entered_filename size=50 maxlength=255 value=\"$cid_cb_you_entered_filename\"> <a href=\"javascript:launch_chooser('cid_cb_you_entered_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-cid_cb_you_entered_filename$NWE</td></tr>\n";
		
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("CID Callback Number Confirm Filename").": </td><td align=left><input type=text name=cid_cb_press_to_confirm_filename id=cid_cb_press_to_confirm_filename size=50 maxlength=255 value=\"$cid_cb_press_to_confirm_filename\"> <a href=\"javascript:launch_chooser('cid_cb_press_to_confirm_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-cid_cb_press_to_confirm_filename$NWE</td></tr>\n";
		
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("CID Callback Number Invalid Filename").": </td><td align=left><input type=text name=cid_cb_invalid_filename id=cid_cb_invalid_filename size=50 maxlength=255 value=\"$cid_cb_invalid_filename\"> <a href=\"javascript:launch_chooser('cid_cb_invalid_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-cid_cb_invalid_filename$NWE</td></tr>\n";
		
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("CID Callback Number Reenter Filename").": </td><td align=left><input type=text name=cid_cb_reenter_filename id=cid_cb_reenter_filename size=50 maxlength=255 value=\"$cid_cb_reenter_filename\"> <a href=\"javascript:launch_chooser('cid_cb_reenter_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-cid_cb_reenter_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("CID Callback Number Error Filename").": </td><td align=left><input type=text name=cid_cb_error_filename id=cid_cb_error_filename size=50 maxlength=255 value=\"$cid_cb_error_filename\"> <a href=\"javascript:launch_chooser('cid_cb_error_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-cid_cb_error_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Closing Time Action").": </td><td align=left><select size=1 name=closing_time_action>
		<option value='DISABLED'>"._QXZ("DISABLED")."</option>
		<option value='PRESS_VMAIL'>"._QXZ("PRESS_VMAIL")."</option>
		<option value='PRESS_VMAIL_NO_INST'>"._QXZ("PRESS_VMAIL_NO_INST")."</option>
		<option value='PRESS_EXTEN'>"._QXZ("PRESS_EXTEN")."</option>
		<option value='PRESS_CALLMENU'>"._QXZ("PRESS_CALLMENU")."</option>
		<option value='PRESS_CID_CALLBACK'>"._QXZ("PRESS_CID_CALLBACK")."</option>
		<option value='PRESS_INGROUP'>"._QXZ("PRESS_INGROUP")."</option>
		<option value='PRESS_CALLBACK_QUEUE'>"._QXZ("PRESS_CALLBACK_QUEUE")."</option>
		<option value='VMAIL'>"._QXZ("VMAIL")."</option>
		<option value='VMAIL_NO_INST'>"._QXZ("VMAIL_NO_INST")."</option>
		<option value='EXTEN'>"._QXZ("EXTEN")."</option>
		<option value='CALLMENU'>"._QXZ("CALLMENU")."</option>
		<option value='CID_CALLBACK'>"._QXZ("CID_CALLBACK")."</option>
		<option value='INGROUP'>"._QXZ("INGROUP")."</option>
		<option value='CALLBACK_QUEUE'>"._QXZ("CALLBACK_QUEUE")."</option>
		<option value='$closing_time_action' SELECTED>"._QXZ("$closing_time_action")."</option></select>$NWB#inbound_groups-closing_time_action$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Closing Time Now Trigger").": </td><td align=left><select size=1 name=closing_time_now_trigger><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$closing_time_now_trigger' SELECTED>"._QXZ("$closing_time_now_trigger")."</option></select>$NWB#inbound_groups-closing_time_now_trigger$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Closing Time Press Filename").": </td><td align=left><input type=text name=closing_time_filename id=closing_time_filename size=50 maxlength=255 value=\"$closing_time_filename\"> <a href=\"javascript:launch_chooser('closing_time_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-closing_time_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Closing Time End Filename").": </td><td align=left><input type=text name=closing_time_end_filename id=closing_time_end_filename size=50 maxlength=255 value=\"$closing_time_end_filename\"> <a href=\"javascript:launch_chooser('closing_time_end_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-closing_time_end_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Closing Time Option Lead Reset").": </td><td align=left><select size=1 name=closing_time_lead_reset><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$closing_time_lead_reset' SELECTED>"._QXZ("$closing_time_lead_reset")."</option></select>$NWB#inbound_groups-closing_time_lead_reset$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Closing Time Option Extension").": </td><td align=left><input type=text name=closing_time_option_exten size=20 maxlength=20 value=\"$closing_time_option_exten\">$NWB#inbound_groups-closing_time_option_exten$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right><a href=\"$PHP_SELF?ADD=3511&menu_id=$closing_time_option_callmenu\">"._QXZ("Closing Time Option Callmenu")."</a>: </td><td align=left><select size=1 name=closing_time_option_callmenu>\n";
		echo "$Cmenuslist";
		echo "</select>$NWB#inbound_groups-closing_time_option_callmenu$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Closing Time Option Voicemail").": </td><td align=left><input type=text name=closing_time_option_voicemail id=closing_time_option_voicemail size=12 maxlength=10 value=\"$closing_time_option_voicemail\"> <a href=\"javascript:launch_vm_chooser('closing_time_option_voicemail','vm');\">"._QXZ("voicemail chooser")."</a> $NWB#inbound_groups-closing_time_option_voicemail$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Closing Time Option Transfer In-Group").": </td><td align=left><select size=1 name=closing_time_option_xfer_group>";
		echo "$Cgroups_menu";
		echo "</select>$NWB#inbound_groups-closing_time_option_xfer_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Closing Time Option Callback List ID").": </td><td align=left><input type=text name=closing_time_option_callback_list_id size=19 maxlength=19 value=\"$closing_time_option_callback_list_id\">$NWB#inbound_groups-closing_time_option_callback_list_id$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Agent Screen Search List Restrict").": </td><td align=left><input type=text name=agent_search_list id=agent_search_list size=20 maxlength=15 value=\"$agent_search_list\"> $NWB#inbound_groups-agent_search_list$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Alert Filename").": </td><td align=left><input type=text name=agent_alert_exten id=agent_alert_exten size=40 maxlength=100 value=\"$agent_alert_exten\"> <a href=\"javascript:launch_chooser('agent_alert_exten','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-agent_alert_exten$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Alert Delay").": </td><td align=left><input type=text name=agent_alert_delay size=6 maxlength=6 value=\"$agent_alert_delay\">$NWB#inbound_groups-agent_alert_delay$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Second Agent Alert Trigger").": </td><td align=left><select size=1 name=second_alert_trigger>
		<option value='DISABLED'>"._QXZ("DISABLED")."</option>
		<option value='PHONE'>"._QXZ("PHONE")."</option>
		<option value='LEAD_ID'>"._QXZ("LEAD_ID")."</option>
		<option value='PHONE_TO'>"._QXZ("PHONE_TO")."</option>
		<option value='LEAD_ID_TO'>"._QXZ("LEAD_ID_TO")."</option>
		<option value='PHONE_NQ'>"._QXZ("PHONE_NQ")."</option>
		<option value='LEAD_ID_NQ'>"._QXZ("LEAD_ID_NQ")."</option>
		<option value='PHONE_TO_NQ'>"._QXZ("PHONE_TO_NQ")."</option>
		<option value='LEAD_ID_TO_NQ'>"._QXZ("LEAD_ID_TO_NQ")."</option>
		<option value='$second_alert_trigger' SELECTED>"._QXZ("$second_alert_trigger")."</option>
		</select>$NWB#inbound_groups-second_alert_trigger$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Second Agent Alert Trigger Seconds").": </td><td align=left><input type=text name=second_alert_trigger_seconds size=6 maxlength=6 value=\"$second_alert_trigger_seconds\">$NWB#inbound_groups-second_alert_trigger_seconds$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Second Agent Alert Filename").": </td><td align=left><input type=text name=second_alert_filename id=second_alert_filename size=40 maxlength=100 value=\"$second_alert_filename\"> <a href=\"javascript:launch_chooser('second_alert_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-second_alert_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Second Agent Alert Delay").": </td><td align=left><input type=text name=second_alert_delay size=6 maxlength=6 value=\"$second_alert_delay\">$NWB#inbound_groups-second_alert_delay$NWE</td></tr>\n";

		##### get container listings for dynamic in-group list pulldown menu
		$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='INGROUP_LIST' $LOGadmin_viewable_groupsSQL order by container_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$inand_to_print = mysqli_num_rows($rslt);
		$second_alert_container_menu='';
		$inand_selected=0;
		$o=0;
		while ($inand_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			if (mb_strlen($rowx[1],'utf-8')>40)
				{$rowx[1] = mb_substr($rowx[1],0,40,'utf-8') . '...';}
			$second_alert_container_menu .= "<option ";
			if ($second_alert_container == "$rowx[0]") 
				{
				$second_alert_container_menu .= "SELECTED ";
				$inand_selected++;
				}
			$second_alert_container_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>";
		if ($inand_selected > 0)
			{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$second_alert_container\">"._QXZ("Second Agent Alert Container")."</a>";}
		else
			{echo _QXZ("Second Agent Alert Container");}
		echo ": </td><td align=left><select size=1 name=second_alert_container>";
		echo "<option value=\"\">---"._QXZ("DISABLED")."---</option>";
		echo "$second_alert_container_menu";
		echo "</select>$NWB#ingroups-second_alert_container$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Second Agent Alert Only").": </td><td align=left><select size=1 name=second_alert_only><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='$second_alert_only' SELECTED>"._QXZ("$second_alert_only")."</option></select>$NWB#inbound_groups-second_alert_only$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Third Agent Alert Trigger").": </td><td align=left><select size=1 name=third_alert_trigger>
		<option value='DISABLED'>"._QXZ("DISABLED")."</option>
		<option value='PHONE'>"._QXZ("PHONE")."</option>
		<option value='LEAD_ID'>"._QXZ("LEAD_ID")."</option>
		<option value='PHONE_TO'>"._QXZ("PHONE_TO")."</option>
		<option value='LEAD_ID_TO'>"._QXZ("LEAD_ID_TO")."</option>
		<option value='PHONE_NQ'>"._QXZ("PHONE_NQ")."</option>
		<option value='LEAD_ID_NQ'>"._QXZ("LEAD_ID_NQ")."</option>
		<option value='PHONE_TO_NQ'>"._QXZ("PHONE_TO_NQ")."</option>
		<option value='LEAD_ID_TO_NQ'>"._QXZ("LEAD_ID_TO_NQ")."</option>
		<option value='$third_alert_trigger' SELECTED>"._QXZ("$third_alert_trigger")."</option>
		</select>$NWB#inbound_groups-third_alert_trigger$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Third Agent Alert Trigger Seconds").": </td><td align=left><input type=text name=third_alert_trigger_seconds size=6 maxlength=6 value=\"$third_alert_trigger_seconds\">$NWB#inbound_groups-third_alert_trigger_seconds$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Third Agent Alert Filename").": </td><td align=left><input type=text name=third_alert_filename id=third_alert_filename size=40 maxlength=100 value=\"$third_alert_filename\"> <a href=\"javascript:launch_chooser('third_alert_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-third_alert_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Third Agent Alert Delay").": </td><td align=left><input type=text name=third_alert_delay size=6 maxlength=6 value=\"$third_alert_delay\">$NWB#inbound_groups-third_alert_delay$NWE</td></tr>\n";

		##### get container listings for dynamic in-group list pulldown menu
		$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='INGROUP_LIST' $LOGadmin_viewable_groupsSQL order by container_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$inand_to_print = mysqli_num_rows($rslt);
		$third_alert_container_menu='';
		$inand_selected=0;
		$o=0;
		while ($inand_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			if (mb_strlen($rowx[1],'utf-8')>40)
				{$rowx[1] = mb_substr($rowx[1],0,40,'utf-8') . '...';}
			$third_alert_container_menu .= "<option ";
			if ($third_alert_container == "$rowx[0]") 
				{
				$third_alert_container_menu .= "SELECTED ";
				$inand_selected++;
				}
			$third_alert_container_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>";
		if ($inand_selected > 0)
			{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$third_alert_container\">"._QXZ("Third Agent Alert Container")."</a>";}
		else
			{echo _QXZ("Third Agent Alert Container");}
		echo ": </td><td align=left><select size=1 name=third_alert_container>";
		echo "<option value=\"\">---"._QXZ("DISABLED")."---</option>";
		echo "$third_alert_container_menu";
		echo "</select>$NWB#ingroups-third_alert_container$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Third Agent Alert Only").": </td><td align=left><select size=1 name=third_alert_only><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='$third_alert_only' SELECTED>"._QXZ("$third_alert_only")."</option></select>$NWB#inbound_groups-third_alert_only$NWE</td></tr>\n";




		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Default Transfer Group").": </td><td align=left><select size=1 name=default_xfer_group>";
		echo "$Xgroups_menu";
		echo "</select>$NWB#inbound_groups-default_xfer_group$NWE</td></tr>\n";

		##### get groups_alias listings for dynamic default group alias pulldown list menu
		$stmt="SELECT group_alias_id,group_alias_name from groups_alias where active='Y' $LOGadmin_viewable_groupsSQL order by group_alias_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$group_alias_to_print = mysqli_num_rows($rslt);
		$group_alias_menu='';
		$group_alias_selected=0;
		$o=0;
		while ($group_alias_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$group_alias_menu .= "<option ";
			if ($default_group_alias == "$rowx[0]") 
				{
				$group_alias_menu .= "SELECTED ";
				$group_alias_selected++;
				}
			$group_alias_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Default Group Alias").": </td><td align=left><select size=1 name=default_group_alias>";
		echo "<option value=\"\">"._QXZ("NONE")."</option>";
		echo "$group_alias_menu";
		echo "</select>$NWB#inbound_groups-default_group_alias$NWE</td></tr>\n";

		$DID_edit_link_BEGIN='';
		$DID_edit_link_END='';
		if (strlen($dial_ingroup_cid) > 0)
			{
			$stmt="SELECT did_id from vicidial_inbound_dids where did_pattern='$dial_ingroup_cid' $LOGadmin_viewable_groupsSQL limit 1;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$dids_to_print = mysqli_num_rows($rslt);
			if ($dids_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$DID_edit_link_BEGIN = "<a href=\"$PHP_SELF?ADD=3311&did_id=$rowx[0]\">";
				$DID_edit_link_END='</a>';
				}
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>$DID_edit_link_BEGIN"._QXZ("Dial In-Group CID")."$DID_edit_link_END: </td><td align=left><input type=text name=dial_ingroup_cid size=20 maxlength=20 value=\"$dial_ingroup_cid\">$NWB#inbound_groups-dial_ingroup_cid$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Hold Recall Transfer In-Group").": </td><td align=left><select size=1 name=hold_recall_xfer_group>";
		echo "$Hgroups_menu";
		echo "</select>$NWB#inbound_groups-hold_recall_xfer_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("No Delay Call Route").": </td><td align=left><select size=1 name=no_delay_call_route><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$no_delay_call_route' SELECTED>"._QXZ("$no_delay_call_route")."</option></select>$NWB#inbound_groups-no_delay_call_route$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("In-Group Recording Override").": </td><td align=left><select size=1 name=ingroup_recording_override><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='NEVER'>"._QXZ("NEVER")."</option><option value='ONDEMAND'>"._QXZ("ONDEMAND")."</option><option value='ALLCALLS'>"._QXZ("ALLCALLS")."</option><option value='ALLFORCE'>"._QXZ("ALLFORCE")."</option><option value='$ingroup_recording_override' SELECTED>"._QXZ("$ingroup_recording_override")."</option></select>$NWB#inbound_groups-ingroup_recording_override$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("In-Group Recording Filename").": </td><td align=left><input type=text name=ingroup_rec_filename size=50 maxlength=50 value=\"$ingroup_rec_filename\">$NWB#inbound_groups-ingroup_rec_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Routing Initiated Recording").": </td><td align=left><select size=1 name=routing_initiated_recordings><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$routing_initiated_recordings' SELECTED>"._QXZ("$routing_initiated_recordings")."</option></select>$NWB#inbound_groups-routing_initiated_recordings$NWE</td></tr>\n";

		if ( ($SSstereo_recording =='1') or ($SSstereo_recording =='2') or ($SSstereo_recording =='3') or ($SSstereo_recording =='4') or ($SSstereo_recording =='5') )
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Stereo Call Recordings").": </td><td align=left><select size=1 name=stereo_recording><option value='BOTH_CHANNELS'>"._QXZ("BOTH_CHANNELS")."</option><option value='CUSTOMER_ONLY'>"._QXZ("CUSTOMER_ONLY")."</option><option value='CUSTOMER_MUTE'>"._QXZ("CUSTOMER_MUTE")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$stereo_recording' SELECTED>"._QXZ("$stereo_recording")."</option></select> $NWB#inbound_groups-stereo_recording$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Stereo Recording Agent Control").": </td><td align=left><select size=1 name=stereo_recording_agent><option value='NEVER'>"._QXZ("NEVER")."</option><option value='ONDEMAND'>"._QXZ("ONDEMAND")."</option><option value='ALLCALLS'>"._QXZ("ALLCALLS")."</option><option value='ALLFORCE'>"._QXZ("ALLFORCE")."</option><option value='$stereo_recording_agent' SELECTED>"._QXZ("$stereo_recording_agent")."</option></select> $NWB#inbound_groups-stereo_recording_agent$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Stereo Rec Filename").": </td><td align=left><input type=text name=stereo_rec_filename size=50 maxlength=50 value=\"$stereo_rec_filename\">$NWB#inbound_groups-stereo_rec_filename$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right></td><td align=left><input type=hidden name=stereo_recording value='$stereo_recording'><input type=hidden name=stereo_rec_filename value='$stereo_rec_filename'><input type=hidden name=stereo_recording_agent value='$stereo_recording_agent'></td></tr>\n";
			}
		if ( ( ($SSstereo_recording =='1') or ($SSstereo_recording =='2') or ($SSstereo_recording =='3') or ($SSstereo_recording =='4') or ($SSstereo_recording =='5') ) and ($SSstereo_parallel_recording == '1') )
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Parallel Stereo Recordings").": </td><td align=left><select size=1 name=stereo_parallel_recording><option value='CUSTOMER-ONLY'>"._QXZ("CUSTOMER-ONLY")."</option><option value='CUSTOMER-MUTED'>"._QXZ("CUSTOMER-MUTED")."</option><option value='CUSTOMER-ONLY_CUSTOMER-MUTED'>"._QXZ("CUSTOMER-ONLY_CUSTOMER-MUTED")."</option><option value='FULL-RECORDING'>"._QXZ("FULL-RECORDING")."</option><option value='CUSTOMER-ONLY_FULL-RECORDING'>"._QXZ("CUSTOMER-ONLY_FULL-RECORDING")."</option><option value='CUSTOMER-MUTED_FULL-RECORDING'>"._QXZ("CUSTOMER-MUTED_FULL-RECORDING")."</option><option value='CUSTOMER-ONLY_CUSTOMER-MUTED_FULL-RECORDING'>"._QXZ("CUSTOMER-ONLY_CUSTOMER-MUTED_FULL-RECORDING")."</option><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='$stereo_parallel_recording' SELECTED>"._QXZ("$stereo_parallel_recording")."</option></select> $NWB#inbound_groups-stereo_parallel_recording$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Parallel Customer-Only Rec Filename").": </td><td align=left><input type=text name=parallel_rec_co_filename size=50 maxlength=50 value=\"$parallel_rec_co_filename\">$NWB#inbound_groups-parallel_rec_xx_filename$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Parallel Customer-Muted Rec Filename").": </td><td align=left><input type=text name=parallel_rec_cm_filename size=50 maxlength=50 value=\"$parallel_rec_cm_filename\">$NWB#inbound_groups-parallel_rec_xx_filename$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Parallel Full-Recording Rec Filename").": </td><td align=left><input type=text name=parallel_rec_fr_filename size=50 maxlength=50 value=\"$parallel_rec_fr_filename\">$NWB#inbound_groups-parallel_rec_xx_filename$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right></td><td align=left><input type=hidden name=stereo_parallel_recording value='$stereo_parallel_recording'><input type=hidden name=parallel_rec_co_filename value='$parallel_rec_co_filename'><input type=hidden name=parallel_rec_cm_filename value='$parallel_rec_cm_filename'><input type=hidden name=parallel_rec_fr_filename value='$parallel_rec_fr_filename'></td></tr>\n";
			}
		if ( ( ($SSrecording_dtmf_muting =='1') or ($SSrecording_dtmf_muting =='2') or ($SSrecording_dtmf_muting =='3') ) and ($SSrecording_dtmf_detection == '1') )
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Recording DTMF Muting").": </td><td align=left><input type=text name=recording_dtmf_muting size=2 maxlength=3 value=\"$recording_dtmf_muting\"> $NWB#inbound_groups-recording_dtmf_muting$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right></td><td align=left><input type=hidden name=recording_dtmf_muting value='$recording_dtmf_muting'></td></tr>\n";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Stats Percent of Calls Answered Within X seconds")." 1: </td><td align=left><input type=text name=answer_sec_pct_rt_stat_one size=5 maxlength=5 value=\"$answer_sec_pct_rt_stat_one\">$NWB#inbound_groups-answer_sec_pct_rt_stat_one$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Stats Percent of Calls Answered Within X seconds")." 2: </td><td align=left><input type=text name=answer_sec_pct_rt_stat_two size=5 maxlength=5 value=\"$answer_sec_pct_rt_stat_two\">$NWB#inbound_groups-answer_sec_pct_rt_stat_one$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Enter In-Group URL").": </td><td align=left><input type=text name=enter_ingroup_url size=70 maxlength=5000 value=\"$enter_ingroup_url\">$NWB#inbound_groups-enter_ingroup_url$NWE</td></tr>\n";

		if ($start_call_url == 'ALT')
			{
			$stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$group_id' and entry_type='ingroup' and url_type='start';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$vum_to_print = mysqli_num_rows($rslt);
			if ($vum_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$vum_count = $rowx[0]; 
				}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"admin_url_multi.php?DB=$DB&campaign_id=$group_id&entry_type=ingroup&url_type=start\">"._QXZ("Start Call URL")."</a>: </td><td align=left><input type=text name=start_call_url size=10 maxlength=2000 value=\"$start_call_url\">$NWB#inbound_groups-start_call_url$NWE <a href=\"admin_url_multi.php?DB=$DB&campaign_id=$group_id&entry_type=ingroup&url_type=start\"> "._QXZ("Alternate Start URLs Defined").": $vum_count</a></td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Start Call URL").": </td><td align=left><input type=text name=start_call_url size=70 maxlength=5000 value=\"$start_call_url\">$NWB#inbound_groups-start_call_url$NWE</td></tr>\n";
			}

		if ($dispo_call_url == 'ALT')
			{
			$stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$group_id' and entry_type='ingroup' and url_type='dispo';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$vum_to_print = mysqli_num_rows($rslt);
			if ($vum_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$vum_count = $rowx[0]; 
				}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"admin_url_multi.php?DB=$DB&campaign_id=$group_id&entry_type=ingroup&url_type=dispo\">"._QXZ("Dispo Call URL")."</a>: </td><td align=left><input type=text name=dispo_call_url size=10 maxlength=2000 value=\"$dispo_call_url\">$NWB#inbound_groups-dispo_call_url$NWE <a href=\"admin_url_multi.php?DB=$DB&campaign_id=$group_id&entry_type=ingroup&url_type=dispo\"> "._QXZ("Alternate Dispo URLs Defined").": $vum_count</a></td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Dispo Call URL").": </td><td align=left><input type=text name=dispo_call_url size=70 maxlength=5000 value=\"$dispo_call_url\">$NWB#inbound_groups-dispo_call_url$NWE</td></tr>\n";
			}

		if ($na_call_url == 'ALT')
			{
			$stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$group_id' and entry_type='ingroup' and url_type='noagent';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$vum_to_print = mysqli_num_rows($rslt);
			if ($vum_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$vum_count = $rowx[0]; 
				}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"admin_url_multi.php?DB=$DB&campaign_id=$group_id&entry_type=ingroup&url_type=noagent\">"._QXZ("No Agent Call URL")."</a>: </td><td align=left><input type=text name=na_call_url size=10 maxlength=5000 value=\"$na_call_url\">$NWB#inbound_groups-na_call_url$NWE <a href=\"admin_url_multi.php?DB=$DB&campaign_id=$group_id&entry_type=ingroup&url_type=noagent\"> "._QXZ("Alternate No Agent URLs Defined").": $vum_count</a></td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("No Agent Call URL").": </td><td align=left><input type=text name=na_call_url size=70 maxlength=5000 value=\"$na_call_url\">$NWB#inbound_groups-na_call_url$NWE</td></tr>\n";
			}

		# get count of talk seconds urls in this In-Group
		$stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$group_id' and entry_type='ingroup' and url_type='talk';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$vum_to_print = mysqli_num_rows($rslt);
		if ($vum_to_print > 0) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$vum_count = $rowx[0]; 
			}
		# check if this In-Group has talk seconds url set to -FORCEDISABLE-
		$force_disableHTML='';
		$stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$group_id' and entry_type='ingroup' and url_type='talk' and active='N' and url_address LIKE \"%FORCEDISABLE%\";";
		$rslt=mysql_to_mysqli($stmt, $link);
		$fdtsu_to_print = mysqli_num_rows($rslt);
		if ($fdtsu_to_print > 0) 
			{
			$rowx=mysqli_fetch_row($rslt);
			if ($rowx[0] > 0)
				{$force_disableHTML="<font color='red'><b>FORCED DISABLE</b></font>";}
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"admin_url_multi.php?DB=$DB&campaign_id=$group_id&entry_type=ingroup&url_type=talk\">"._QXZ("Talk Seconds URLs")."</a>: </td><td align=left>$NWB#inbound_groups-talk_sec_url$NWE <a href=\"admin_url_multi.php?DB=$DB&campaign_id=$group_id&entry_type=ingroup&url_type=talk\"> "._QXZ("Talk Seconds URLs Defined").": $vum_count</a> &nbsp; $force_disableHTML</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right nowrap>"._QXZ("Waiting Call URL On").": </td><td align=left><input type=text name=waiting_call_url_on size=70 maxlength=5000 value=\"$waiting_call_url_on\">$NWB#inbound_groups-waiting_call_url_on$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right nowrap>"._QXZ("Waiting Call URL Off").": </td><td align=left><input type=text name=waiting_call_url_off size=70 maxlength=5000 value=\"$waiting_call_url_off\">$NWB#inbound_groups-waiting_call_url_on$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Add Lead URL").": </td><td align=left><input type=text name=add_lead_url size=70 maxlength=5000 value=\"$add_lead_url\">$NWB#inbound_groups-add_lead_url$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Add Lead Timezone").": </td><td align=left><select size=1 name=add_lead_timezone><option value='SERVER'>"._QXZ("SERVER")."</option><option value='PHONE_CODE_AREACODE'>"._QXZ("PHONE_CODE_AREACODE")."</option><option value='$add_lead_timezone' SELECTED>"._QXZ("$add_lead_timezone")."</option></select>$NWB#inbound_groups-add_lead_timezone$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Extension Append CID").": </td><td align=left><select size=1 name=extension_appended_cidname><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='Y_USER'>"._QXZ("Y_USER")."</option><option value='Y_WITH_CAMPAIGN'>"._QXZ("Y_WITH_CAMPAIGN")."</option><option value='Y_USER_WITH_CAMPAIGN'>"._QXZ("Y_USER_WITH_CAMPAIGN")."</option><option value='$extension_appended_cidname' SELECTED>"._QXZ("$extension_appended_cidname")."</option></select>$NWB#inbound_groups-extension_appended_cidname$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Uniqueid Status Display").": </td><td align=left><select size=1 name=uniqueid_status_display><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='ENABLED_PREFIX'>"._QXZ("ENABLED_PREFIX")."</option><option value='ENABLED_PRESERVE'>"._QXZ("ENABLED_PRESERVE")."</option><option value='$uniqueid_status_display' SELECTED>"._QXZ("$uniqueid_status_display")."</option></select>$NWB#inbound_groups-uniqueid_status_display$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Uniqueid Status Prefix").": </td><td align=left><input type=text name=uniqueid_status_prefix size=10 maxlength=50 value=\"$uniqueid_status_prefix\">$NWB#inbound_groups-uniqueid_status_prefix$NWE</td></tr>\n";

		##### get container listings for dynamic STATE_DESCRIPTIONS container pulldown menu
		$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='STATE_DESCRIPTIONS' $LOGadmin_viewable_groupsSQL order by container_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$sdb_to_print = mysqli_num_rows($rslt);
		$state_descriptions_menu='';
		$sdb_selected=0;
		$o=0;
		while ($sdb_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			if (mb_strlen($rowx[1],'utf-8')>40)
				{$rowx[1] = mb_substr($rowx[1],0,40,'utf-8') . '...';}
			$state_descriptions_menu .= "<option ";
			if ($state_descriptions == "$rowx[0]") 
				{
				$state_descriptions_menu .= "SELECTED ";
				$sdb_selected++;
				}
			$state_descriptions_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>";
		if ($sdb_selected > 0)
			{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$state_descriptions\">"._QXZ("State Descriptions Banner")."</a>";}
		else
			{echo _QXZ("State Descriptions Banner");}
		echo ": </td><td align=left nowrap><select size=1 name=state_descriptions><option value='---DISABLED---'>"._QXZ("---DISABLED---")."</option>$state_descriptions_menu</select>$NWB#inbound_groups-state_descriptions$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Populate Lead In-Group").": </td><td align=left><select size=1 name=populate_lead_ingroup><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='$populate_lead_ingroup' SELECTED>"._QXZ("$populate_lead_ingroup")."</option></select>$NWB#inbound_groups-populate_lead_ingroup$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Populate Lead Province").": </td><td align=left><select size=1 name=populate_lead_province><option value='DISABLED'>"._QXZ("DISABLED")."</option><option>did_pattern</option><option>did_description</option><option>did_carrier</option><option>did_custom_one</option><option>did_custom_two</option><option>did_custom_three</option><option>did_custom_four</option><option>did_custom_five</option><option>OW_did_pattern</option><option>OW_did_description</option><option>OW_did_carrier</option><option>OW_did_custom_one</option><option>OW_did_custom_two</option><option>OW_did_custom_three</option><option>OW_did_custom_four</option><option>OW_did_custom_five</option><option value='$populate_lead_province' SELECTED>"._QXZ("$populate_lead_province")."</option></select>$NWB#inbound_groups-populate_lead_province$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Populate Lead Owner").": </td><td align=left><select size=1 name=populate_lead_owner><option value='DISABLED'>"._QXZ("DISABLED")."</option><option>did_pattern</option><option>did_description</option><option>did_carrier</option><option>did_custom_one</option><option>did_custom_two</option><option>did_custom_three</option><option>did_custom_four</option><option>did_custom_five</option><option>OW_did_pattern</option><option>OW_did_description</option><option>OW_did_carrier</option><option>OW_did_custom_one</option><option>OW_did_custom_two</option><option>OW_did_custom_three</option><option>OW_did_custom_four</option><option>OW_did_custom_five</option><option>OWNERCUSTOM</option><option value='$populate_lead_owner' SELECTED>"._QXZ("$populate_lead_owner")."</option></select>$NWB#inbound_groups-populate_lead_owner$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Populate Lead State Areacode").": </td><td align=left><select size=1 name=populate_state_areacode><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='NEW_LEAD_ONLY'>"._QXZ("NEW_LEAD_ONLY")."</option><option value='OVERWRITE_ALWAYS'>"._QXZ("OVERWRITE_ALWAYS")."</option><option value='$populate_state_areacode' SELECTED>"._QXZ("$populate_state_areacode")."</option></select>$NWB#inbound_groups-populate_state_areacode$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Populate Lead Source").": </td><td align=left><select size=1 name=populate_lead_source><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='INBOUND_NUMBER'>"._QXZ("INBOUND_NUMBER")."</option><option value='INBOUND_DID'>"._QXZ("INBOUND_DID")."</option><option value='BLANK'>"._QXZ("BLANK")."</option><option value='$populate_lead_source' SELECTED>"._QXZ("$populate_lead_source")."</option></select>$NWB#inbound_groups-populate_lead_source$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Populate Lead Vendor").": </td><td align=left><input type=text name=populate_lead_vendor id=populate_lead_vendor size=22 maxlength=20 value=\"$populate_lead_vendor\"> $NWB#inbound_groups-populate_lead_vendor$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Populate Lead Comments").": </td><td align=left><input type=text name=populate_lead_comments id=populate_lead_comments size=22 maxlength=40 value=\"$populate_lead_comments\"> $NWB#inbound_groups-populate_lead_comments$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("After Call Survey").": </td><td align=left><select size=1 name=inbound_survey><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='$inbound_survey' SELECTED>"._QXZ("$inbound_survey")."</option></select>$NWB#inbound_groups-inbound_survey$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("After Call Survey Accept Filename").": </td><td align=left><input type=text name=inbound_survey_filename id=inbound_survey_filename size=50 maxlength=255 value=\"$inbound_survey_filename\"> <a href=\"javascript:launch_chooser('inbound_survey_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-inbound_survey_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("After Call Survey Accept Digit").": </td><td align=left><select size=1 name=inbound_survey_accept_digit><option value='0'>"._QXZ("0")."</option><option value='1'>"._QXZ("1")."</option><option value='2'>"._QXZ("2")."</option><option value='3'>"._QXZ("3")."</option><option value='4'>"._QXZ("4")."</option><option value='5'>"._QXZ("5")."</option><option value='6'>"._QXZ("6")."</option><option value='7'>"._QXZ("7")."</option><option value='8'>"._QXZ("8")."</option><option value='9'>"._QXZ("9")."</option><option value='$inbound_survey_accept_digit' SELECTED>"._QXZ("$inbound_survey_accept_digit")."</option></select>$NWB#inbound_groups-inbound_survey_accept_digit$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("After Call Question Filename").": </td><td align=left><input type=text name=inbound_survey_question_filename id=inbound_survey_question_filename size=50 maxlength=255 value=\"$inbound_survey_question_filename\"> <a href=\"javascript:launch_chooser('inbound_survey_question_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#inbound_groups-inbound_survey_question_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right><a href=\"$PHP_SELF?ADD=3511&menu_id=$inbound_survey_callmenu\">"._QXZ("After Call End Call Menu").":</a></td><td align=left><select size=1 name=inbound_survey_callmenu id=inbound_survey_callmenu>$call_menu_list<option SELECTED>$inbound_survey_callmenu</option></select>$NWB#inbound_groups-inbound_survey_callmenu$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom 1").": </td><td align=left><input type=text name=custom_one id=custom_one size=40 maxlength=2000 value=\"$custom_one\"> $NWB#inbound_groups-custom_fields$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom 2").": </td><td align=left><input type=text name=custom_two id=custom_two size=40 maxlength=2000 value=\"$custom_two\"> $NWB#inbound_groups-custom_fields$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom 3").": </td><td align=left><input type=text name=custom_three id=custom_three size=40 maxlength=2000 value=\"$custom_three\"> $NWB#inbound_groups-custom_fields$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom 4").": </td><td align=left><input type=text name=custom_four id=custom_four size=40 maxlength=2000 value=\"$custom_four\"> $NWB#inbound_groups-custom_fields$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom 5").": </td><td align=left><input type=text name=custom_five id=custom_five size=40 maxlength=2000 value=\"$custom_five\"> $NWB#inbound_groups-custom_fields$NWE</td></tr>\n";

		echo "<input type=hidden name=form_end value=\"END\">\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";

		if ($SSqc_features_active > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2> &nbsp; </td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row3_background><td align=center colspan=2> "._QXZ("Inbound Group QC Settings").": </td></tr>\n";

/* JCJ - deprecated 2021-03-06
			##### get status listings for dynamic pulldown
			$qc_statuses = preg_replace("/^ | -$/","",$qc_statuses);
			$QCstatuses = explode(" ", $qc_statuses);
			$QCs_to_print = (count($QCstatuses) -0);
			$stmt="SELECT status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable,scheduled_callback from vicidial_statuses where status NOT IN('QUEUE','INCALL') order by status";
			$rslt=mysql_to_mysqli($stmt, $link);
			$statuses_to_print = mysqli_num_rows($rslt);
			$qc_statuses_list='';

			$o=0;
			while ($statuses_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$qc_statuses_list .= "<input type=\"checkbox\" name=\"qc_statuses[]\" value=\"$rowx[0]\"";
				$p=0;
				while ($p < $QCs_to_print)
					{
					if ($rowx[0] === $QCstatuses[$p]) 
						{
						$qc_statuses_list .= " CHECKED";
						}
					$p++;
					}
				$qc_statuses_list .= "> $rowx[0] - $rowx[1]<BR>\n";

				$o++;
				}

			$stmt="SELECT distinct(status),status_name from vicidial_campaign_statuses $whereLOGallowed_campaignsSQL order by status;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$Cstatuses_to_print = mysqli_num_rows($rslt);

			$o=0;
			while ($Cstatuses_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				if (!preg_match("/\"$rowx[0]\"/",$qc_statuses_list))
					{
					$qc_statuses_list .= "<input type=\"checkbox\" name=\"qc_statuses[]\" value=\"$rowx[0]\"";
					$p=0;
					while ($p < $QCs_to_print)
						{
						if ($rowx[0] === $QCstatuses[$p]) 
							{
							$qc_statuses_list .= " CHECKED";
							}
						$p++;
						}
					$qc_statuses_list .= "> $rowx[0] - $rowx[1]<BR>\n";
					}
				$o++;
				}
*/
			##### get QC status container listings for pulldown
			$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='QC_TEMPLATE' order by container_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$containers_to_print = mysqli_num_rows($rslt);
			$QCcontainers_list="<option value=\"\">NONE</option>";
			$o=0;
			while ($containers_to_print > $o)
				{
				$rowx=mysqli_fetch_row($rslt);
				$QCcontainers_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$qc_containers_list["$rowx[0]"] = "$rowx[1]";
				$o++;
				}
			##### get scorecards listings for pulldown
			$stmt="SELECT qc_scorecard_id,scorecard_name from quality_control_scorecards where active='Y' order by qc_scorecard_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$scorecards_to_print = mysqli_num_rows($rslt);
			$QCscorecards_list="<option value=\"\">NONE</option>";
			$o=0;
			while ($scorecards_to_print > $o)
				{
				$rowx=mysqli_fetch_row($rslt);
				$QCscorecards_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$scorecardname_list["$rowx[0]"] = "$rowx[1]";
				$o++;
				}
			##### get scripts listings for pulldown
			$stmt="SELECT script_id,script_name from vicidial_scripts $whereLOGadmin_viewable_groupsSQL order by script_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$scripts_to_print = mysqli_num_rows($rslt);
			$QCscripts_list="";
			$o=0;
			while ($scripts_to_print > $o)
				{
				$rowx=mysqli_fetch_row($rslt);
				$QCscripts_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$scriptname_list["$rowx[0]"] = "$rowx[1]";
				$o++;
				}
			##### get shifts listings for pulldown
			$stmt="SELECT shift_id,shift_name from vicidial_shifts $whereLOGadmin_viewable_groupsSQL order by shift_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$shifts_to_print = mysqli_num_rows($rslt);
			$QCshifts_list="";
			$o=0;
			while ($shifts_to_print > $o)
				{
				$rowx=mysqli_fetch_row($rslt);
				$QCshifts_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$shiftname_list["$rowx[0]"] = "$rowx[1]";
				$o++;
				}

			# echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("QC Enabled").": </td><td><select size=1 name=qc_enabled><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value=\"$qc_enabled\" SELECTED>"._QXZ("$qc_enabled")."</option></select> $NWB#inbound_groups-qc_enabled$NWE</td></tr>\n";
			# echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("QC Statuses").": <BR> $NWB#inbound_groups-qc_statuses$NWE</td><td>$qc_statuses_list</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("QC Statuses").": </td><td align=left><select size=1 name=qc_statuses_id>";
			echo "<option selected value=\"$qc_statuses_id\">".(!$qc_statuses_id ? "NONE" : "$qc_statuses_id - $qc_containers_list[$qc_statuses_id]")."</option>\n";
			echo "$QCcontainers_list";
			echo "</select>$NWB#inbound_groups-qc_statuses_id$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("QC Scorecard").": </td><td align=left><select size=1 name=qc_scorecard_id>";
			echo "<option selected value=\"$qc_scorecard_id\">".(!$qc_scorecard_id ? "NONE" : "$qc_scorecard_id - $scorecardname_list[$qc_scorecard_id]")."</option>\n";
			echo "$QCscorecards_list";
			echo "</select>$NWB#inbound_groups-qc_scorecard$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("QC WebForm").": </td><td align=left><input type=text name=qc_web_form_address size=70 maxlength=255 value=\"$qc_web_form_address\">$NWB#inbound_groups-qc_web_form_address$NWE</td></tr>\n";

/* JCJ - deprecated 2021-03-06

			echo "<tr bgcolor=#$SSstd_row2_background><td align=right><a href=\"$PHP_SELF?ADD=3111111&script_id=$script_id\">"._QXZ("QC Script")."</a>: </td><td align=left><select size=1 name=qc_script>\n";
			echo "$QCscripts_list";
			echo "<option selected value=\"$qc_script\">$qc_script - $scriptname_list[$qc_script]</option>\n";
			echo "</select>$NWB#inbound_groups-qc_script$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row2_background><td align=right><a href=\"$PHP_SELF?ADD=331111111&shift_id=$qc_shift_id\">"._QXZ("QC Shift")."</a>: </td><td align=left><select size=1 name=qc_shift_id>\n";
			echo "$QCshifts_list";
			echo "<option selected value=\"$qc_shift_id\">$qc_shift_id - $shiftname_list[$qc_shift_id]</option>\n";
			echo "</select>$NWB#inbound_groups-qc_shift_id$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("QC Get Record Launch").": </td><td><select size=1 name=qc_get_record_launch><option value='NONE'>"._QXZ("NONE")."</option><option value='SCRIPT'>"._QXZ("SCRIPT")."</option><option value='WEBFORM'>"._QXZ("WEBFORM")."</option><option value='QCSCRIPT'>"._QXZ("QCSCRIPT")."</option><option value='QCWEBFORM'>"._QXZ("QCWEBFORM")."</option><option value='$qc_get_record_launch' SELECTED>"._QXZ("$qc_get_record_launch")."</option></select> $NWB#inbound_groups-qc_get_record_launch$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("QC Show Recording").": </td><td><select size=1 name=qc_show_recording><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$qc_show_recording' SELECTED>"._QXZ("$qc_show_recording")."</option></select> $NWB#inbound_groups-qc_show_recording$NWE</td></tr>\n";
	
			echo "<tr bgcolor=#$SSstd_row2_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'></td></tr>\n";
*/
			}

		echo "<input type=hidden name=form_end value=\"END\">\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2> &nbsp; </td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";

		echo "</table>\n";
		echo "<BR></center><BR><BR>\n";

		if ($SSbrowser_call_alerts > 0)
			{
			$bas=0;   $bas_embed_output='';
			while ($browser_alert_sounds_listARY_ct > $bas)
				{
				$bas_embed_output .= "<audio id='BAS_$browser_alert_sounds_listARY[$bas]'><source src=\"../agc/sounds/".$browser_alert_sounds_listARY[$bas].".mp3\" type=\"audio/mpeg\"></audio>\n";
				$bas++;
				}
			echo "$bas_embed_output";
			echo "\n";
			}

		### list of agent rank or skill-level for this inbound group
		echo "<center><a name=\"agent_ranks\">\n";
		echo "<br><b>"._QXZ("AGENT RANKS FOR THIS INBOUND GROUP").":</b><br>\n";
		echo "<TABLE width=800 cellspacing=3>\n";
		echo "<tr><td>"._QXZ("USER")."</td><td>"._QXZ("GROUP")."</td><td>"._QXZ("SELECTED")."</td><td> &nbsp; "._QXZ("RANK")." &nbsp; </td><td> &nbsp; "._QXZ("GRADE")." &nbsp; </td><td> "._QXZ("DAILY LIMIT")." </td><td> "._QXZ("CALLS TODAY")." </td></tr>\n";

		$stmt="SELECT user,full_name,closer_campaigns,user_group from vicidial_users where active='Y' $LOGadmin_viewable_groupsSQL order by user;";
		$rsltx=mysql_to_mysqli($stmt, $link);
		$users_to_print = mysqli_num_rows($rsltx);

		$o=0;
		while ($users_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rsltx);
			$o++;

			$ARIG_user[$o] =	$rowx[0];
			$ARIG_name[$o] =	$rowx[1];
			$ARIG_close[$o] =	$rowx[2];
			$ARIG_group[$o] =	$rowx[3];
			$ARIG_check[$o] =	'';
			if (preg_match("/ $group_id /",$ARIG_close[$o]))
				{$ARIG_check[$o] = ' CHECKED';}
			}

		$o=0;
		$ARIG_changenotes='';
		$stmtDlog='';
		while ($users_to_print > $o) 
			{
			$o++;
			$stmt="SELECT group_rank,calls_today,group_grade,daily_limit from vicidial_inbound_group_agents where group_id='$group_id' and user='$ARIG_user[$o]';";
			$rsltx=mysql_to_mysqli($stmt, $link);
			$viga_to_print = mysqli_num_rows($rsltx);
			if ($viga_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rsltx);
				$ARIG_rank[$o] =	$rowx[0];
				$ARIG_calls[$o] =	$rowx[1];
				$ARIG_grade[$o] =	$rowx[2];
				$ARIG_limit[$o] =	$rowx[3];
				}
			else
				{
				$stmtD="INSERT INTO vicidial_inbound_group_agents set calls_today='0',group_rank='0',group_weight='0',user='$ARIG_user[$o]',group_id='$group_id',group_grade='1',daily_limit='-1';";
				$rslt=mysql_to_mysqli($stmtD, $link);
				$affected_rows_grp = mysqli_affected_rows($link);
				if ($DB > 0) {echo "$affected_rows_grp|$stmtD|";}
				$stmtDlog .= "$stmtD|";
				$ARIG_changenotes .= "added missing user to viga table $ARIG_user[$o]|";
				$ARIG_rank[$o] =	'0';
				$ARIG_calls[$o] =	'0';
				$ARIG_grade[$o] =	'1';
				$ARIG_limit[$o] =	'-1';
				}
			}
		if (strlen($ARIG_changenotes) > 10)
			{
			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmtDlog|";
			$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='INGROUPS', event_type='MODIFY', record_id='$group_id', event_code='USER INGROUP VIGA ADD', event_sql=\"$SQL_log\", event_notes='$ARIG_changenotes';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}


		if ( ($stage=='SUBMIT') or ($stage==_QXZ("SUBMIT")) )
			{
			$o=0;
			while ($users_to_print > $o) 
				{
				$o++;

				$ARIG_checked='';
				$ARIG_ranked='';
				$ARIG_graded='';
				$ARIG_limited='';

				$checkbox_field="CHECK_$ARIG_user[$o]$US$group_id";
				$rank_field="RANK_$ARIG_user[$o]$US$group_id";
				$grade_field="GRADE_$ARIG_user[$o]$US$group_id";
				$limit_field="LIMIT_$ARIG_user[$o]$US$group_id";

				if (isset($_GET["$checkbox_field"]))			{$ARIG_checked=$_GET["$checkbox_field"];}
					elseif (isset($_POST["$checkbox_field"]))	{$ARIG_checked=$_POST["$checkbox_field"];}
				if (isset($_GET["$rank_field"]))			{$ARIG_ranked=$_GET["$rank_field"];}
					elseif (isset($_POST["$rank_field"]))	{$ARIG_ranked=$_POST["$rank_field"];}
				if (isset($_GET["$grade_field"]))			{$ARIG_graded=$_GET["$grade_field"];}
					elseif (isset($_POST["$grade_field"]))	{$ARIG_graded=$_POST["$grade_field"];}
				if (isset($_GET["$limit_field"]))			{$ARIG_limited=$_GET["$limit_field"];}
					elseif (isset($_POST["$limit_field"]))	{$ARIG_limited=$_POST["$limit_field"];}
				$ARIG_checked = preg_replace('/[^A-Z]/','',$ARIG_checked);
				$ARIG_ranked = preg_replace('/[^-0-9]/','',$ARIG_ranked);
				$ARIG_graded = preg_replace('/[^-0-9]/','',$ARIG_graded);
				$ARIG_limited = preg_replace('/[^-0-9]/','',$ARIG_limited);

				$stmtA='';
				$stmtB='';
				$stmtC='';
				$stmtD='';
				$stmtE='';
				$ARIG_updated=0;
				$ARIG_changenotes='';
				if ( ($ARIG_check[$o]=='') and ($ARIG_checked=='YES') )
					{
					if (strlen($ARIG_close[$o]) < 4) {$ARIG_close[$o]=' - ';}
					$stmtA="UPDATE vicidial_users set closer_campaigns=' $group_id$ARIG_close[$o]' where user='$ARIG_user[$o]';";
					$rslt=mysql_to_mysqli($stmtA, $link);
					if ($DB > 0) {echo "|$stmtA|";}
					$ARIG_updated++;
					$ARIG_changenotes .= "added $group_id to selected in-groups|";
					}
				if ( ($ARIG_check[$o]==' CHECKED') and ($ARIG_checked=='') )
					{
					$ARIG_close[$o] = preg_replace("/ $group_id /",' ',$ARIG_close[$o]);
					$stmtB="UPDATE vicidial_users set closer_campaigns='$ARIG_close[$o]' where user='$ARIG_user[$o]';";
					$rslt=mysql_to_mysqli($stmtB, $link);
					if ($DB > 0) {echo "|$stmtB|";}
					$ARIG_updated++;
					$ARIG_changenotes .= "removed $group_id from selected in-groups|";
					}
				if ( ($ARIG_ranked < $ARIG_rank[$o]) or ($ARIG_ranked > $ARIG_rank[$o]) )
					{
					$stmtC="UPDATE vicidial_inbound_group_agents set group_rank='$ARIG_ranked',group_weight='$ARIG_ranked' where user='$ARIG_user[$o]' and group_id='$group_id';";
					$rslt=mysql_to_mysqli($stmtC, $link);
					if ($DB > 0) {echo "|$stmtC|";}
					$ARIG_updated++;
					$ARIG_changenotes .= "changed rank from $ARIG_rank[$o] to $ARIG_ranked|";
					}
				if ( ($ARIG_graded < $ARIG_grade[$o]) or ($ARIG_graded > $ARIG_grade[$o]) )
					{
					$stmtD="UPDATE vicidial_inbound_group_agents set group_grade='$ARIG_graded' where user='$ARIG_user[$o]' and group_id='$group_id';";
					$rslt=mysql_to_mysqli($stmtD, $link);
					if ($DB > 0) {echo "|$stmtD|";}
					$ARIG_updated++;
					$ARIG_changenotes .= "changed grade from $ARIG_grade[$o] to $ARIG_graded|";
					}
				if ( ($ARIG_limited < $ARIG_limit[$o]) or ($ARIG_limited > $ARIG_limit[$o]) )
					{
					$stmtE="UPDATE vicidial_inbound_group_agents set daily_limit='$ARIG_limited' where user='$ARIG_user[$o]' and group_id='$group_id';";
					$rslt=mysql_to_mysqli($stmtE, $link);
					if ($DB > 0) {echo "|$stmtE|";}
					$ARIG_updated++;
					$ARIG_changenotes .= "changed limit from $ARIG_limit[$o] to $ARIG_limited|";
					}
				if ($ARIG_updated > 0)
					{
					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$stmtA|$stmtB|$stmtC|$stmtD|$stmtE|";
					$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='$ARIG_user[$o]', event_code='USER INGROUP SETTINGS', event_sql=\"$SQL_log\", event_notes='$ARIG_changenotes';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}

			$stmt="SELECT vu.user,viga.group_rank,calls_today,full_name,closer_campaigns,viga.group_grade,viga.daily_limit from vicidial_inbound_group_agents viga, vicidial_users vu where group_id='$group_id' and active='Y' and vu.user=viga.user $LOGadmin_viewable_groupsSQL order by vu.user;";
			$rsltx=mysql_to_mysqli($stmt, $link);
			$users_to_print = mysqli_num_rows($rsltx);

			$o=0;
			while ($users_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rsltx);
				$o++;

				$ARIG_user[$o] =	$rowx[0];
				$ARIG_rank[$o] =	$rowx[1];
				$ARIG_calls[$o] =	$rowx[2];
				$ARIG_name[$o] =	$rowx[3];
				$ARIG_close[$o] =	$rowx[4];
				$ARIG_grade[$o] =	$rowx[5];
				$ARIG_limit[$o] =	$rowx[6];
				$ARIG_check[$o] =	'';
				if (preg_match("/ $group_id /",$ARIG_close[$o]))
					{$ARIG_check[$o] = ' CHECKED';}
				}
			}

		$checkbox_count=0;
		$o=0;
		while ($users_to_print > $o) 
			{
			$o++;

			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

			$checkbox_field="CHECK_$ARIG_user[$o]$US$group_id";
			$rank_field="RANK_$ARIG_user[$o]$US$group_id";
			$grade_field="GRADE_$ARIG_user[$o]$US$group_id";
			$limit_field="LIMIT_$ARIG_user[$o]$US$group_id";
			$checkbox_list .= "|$checkbox_field";
			$checkbox_count++;

			$users_output .= "<tr $bgcolor><td><font size=1><a href=\"$PHP_SELF?ADD=3&user=$ARIG_user[$o]\">$ARIG_user[$o]</a> - $ARIG_name[$o]</td>\n";
			$users_output .= "<td><font size=1>$ARIG_group[$o]</td>\n";
			$users_output .= "<td><input type=checkbox name=\"$checkbox_field\" id=\"$checkbox_field\" value=\"YES\"$ARIG_check[$o]></td>\n";
			$users_output .= "<td><select size=1 name=$rank_field>\n";
			$h="9";
			while ($h>=-9)
				{
				$users_output .= "<option value=\"$h\"";
				if ($h==$ARIG_rank[$o])
					{$users_output .= " SELECTED";}
				$users_output .= ">$h</option>";
				$h--;
				}
			$users_output .= "</select></td>\n";
			$users_output .= "<td><select size=1 name=$grade_field>\n";
			$h="10";
			while ($h>=1)
				{
				$users_output .= "<option value=\"$h\"";
				if ($h==$ARIG_grade[$o])
					{$users_output .= " SELECTED";}
				$users_output .= ">$h</option>";
				$h--;
				}
			$users_output .= "</select></td>\n";
			$users_output .= "<td><input type=text name=$limit_field size=5 maxlength=4 value=\"$ARIG_limit[$o]\"></td>\n";
			$users_output .= "<td><font size=1>$ARIG_calls[$o]</td></tr>\n";
			}
		echo "<tr><td><font size=1> &nbsp; </font></td><td><font size=1> &nbsp; </font></td><td align=left><span id=IGU_selectlink><a href=\"#\" onclick=\"FORM_selectall('$checkbox_count','$checkbox_list','on','IGU_selectlink');return false;\"><font size=1>"._QXZ("select all")."</font></a></span></td><td colspan=2><font size=1> &nbsp; </font></td></tr>\n";

		echo "$users_output";

		echo "<tr><td align=center colspan=4><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'></td></tr>\n";

		echo "</table></center><br></FORM>\n";

		echo "<a href=\"./AST_CLOSERstats.php?group[]=$group_id\">"._QXZ("Click here to see a report for this inbound group")."</a><BR><BR>\n";

		echo "<a href=\"./AST_VICIDIAL_ingrouplist.php?group=$group_id\">"._QXZ("Click here to see agents logged in to this inbound group")."</a><BR><BR>\n";

		echo "<center><b>\n";

		echo "<B>"._QXZ("DIDS USING THIS IN-GROUP").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT did_id,did_pattern,did_description from vicidial_inbound_dids where group_id='$group_id' and did_route='IN_GROUP' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$dids_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($dids_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=3311&did_id=$row[0]\">$row[1] </a></TD><TD> $row[2]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE><BR>\n";
		echo "<B>"._QXZ("CALL MENUS USING THIS IN-GROUP").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT distinct vm.menu_id,menu_name from vicidial_call_menu vm,vicidial_call_menu_options vmo where vm.menu_id=vmo.menu_id and option_route='INGROUP' and option_route_value='$group_id' $vmLOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$cms_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($cms_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=3511&menu_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE><BR>\n";
		echo "<B>"._QXZ("CAMPAIGNS USING THIS IN-GROUP").":</B><BR>\n";
		echo "<TABLE>\n";

		$SQL_group_id = preg_replace("/_/",'\\_',$group_id);
		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where ( (agent_hangup_route='IN_GROUP' and agent_hangup_value='$group_id') or (drop_inbound_group='$group_id') ) $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campin_to_print = mysqli_num_rows($rslt);
		if ($DB > 0) {echo "|$SQL_group_id|$group_id|$stmt|\n";}
		$o=0;
		while ($campin_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=31&campaign_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE>\n";
		echo "<B>"._QXZ("CAMPAIGNS ALLOWING THIS IN-GROUP").":</B><BR>\n";
		echo "<TABLE>\n";

		$SQL_group_id = preg_replace("/_/",'\\_',$group_id);
		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where closer_campaigns LIKE \"% $SQL_group_id %\" $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campin_to_print = mysqli_num_rows($rslt);
		if ($DB > 0) {echo "|$SQL_group_id|$group_id|$stmt|\n";}
		$o=0;
		while ($campin_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=31&campaign_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE>\n";

		if ($LOGdelete_ingroups > 0)
			{
		#	echo "<br><br><a href=\"$PHP_SELF?ADD=53&campaign_id=$group_id&stage=IN\">EMERGENCY VDAC CLEAR FOR THIS IN-GROUP</a><BR><BR>\n";
			echo "<br><br><a href=\"$PHP_SELF?ADD=5111&group_id=$group_id&group_handling=$group_handling\">"._QXZ("DELETE THIS IN-GROUP")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=INGROUPS&stage=$group_id\">"._QXZ("Click here to see Admin changes to this In-Group")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}

	}


######################
# ADD=3811 modify email in-group info in the system
######################
if ($ADD==3811)
	{
	if ( ($LOGmodify_ingroups==1) and ($SSallow_emails>0) )
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=3811&group_id=$group_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,drop_call_seconds,drop_action,drop_exten,call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,default_xfer_group,queue_priority,drop_inbound_group,ingroup_recording_override,ingroup_rec_filename,afterhours_xfer_group,qc_enabled,qc_statuses,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two,default_group_alias,no_agent_no_queue,no_agent_action,no_agent_action_value,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,ignore_list_script_override,extension_appended_cidname,uniqueid_status_display,uniqueid_status_prefix,hold_time_option_minimum,hold_time_option_press_filename,hold_time_option_callmenu,onhold_prompt_no_block,onhold_prompt_seconds,hold_time_option_no_block,hold_time_option_prompt_seconds,hold_time_second_option,hold_time_third_option,wait_hold_option_priority,wait_time_option,wait_time_second_option,wait_time_third_option,wait_time_option_seconds,wait_time_option_exten,wait_time_option_voicemail,wait_time_option_xfer_group,wait_time_option_callmenu,wait_time_option_callback_filename,wait_time_option_callback_list_id,wait_time_option_press_filename,wait_time_option_no_block,wait_time_option_prompt_seconds,timer_action_destination,calculate_estimated_hold_seconds,add_lead_url,eht_minimum_prompt_filename, eht_minimum_prompt_no_block,eht_minimum_prompt_seconds,on_hook_ring_time,na_call_url,on_hook_cid,group_calldate,action_xfer_cid,drop_callmenu,after_hours_callmenu,user_group,max_calls_method,max_calls_count,max_calls_action,dial_ingroup_cid,group_handling,web_form_address_three,status_group_id,routing_initiated_recordings,ingroup_script_two,browser_alert_sound,browser_alert_volume,custom_one,custom_two,custom_three,custom_four,custom_five from vicidial_inbound_groups where group_id='$group_id' $LOGadmin_viewable_groupsSQL;";

		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$query_group_id =			$row[0];
		$group_name =				$row[1];
		$group_color =				$row[2];
		$active =					$row[3];
		$web_form_address =			stripslashes($row[4]);
		$voicemail_ext =			$row[5];
		$next_agent_call =			$row[6];
		$fronter_display =			$row[7];
		$script_id =				$row[8];
		$get_call_launch =			$row[9];
		$drop_call_seconds =		$row[14];
		$drop_action =				$row[15];
		$drop_exten =				$row[16];
		$call_time_id =				$row[17];
		$after_hours_action =		$row[18];
		$after_hours_message_filename =	$row[19];
		$after_hours_exten =		$row[20];
		$after_hours_voicemail =	$row[21];
		$welcome_message_filename =	$row[22];
		$moh_context =				$row[23];
		$onhold_prompt_filename =	$row[24];
		$prompt_interval =			$row[25];
		$agent_alert_exten =		$row[26];
		$agent_alert_delay =		$row[27];
		$default_xfer_group =		$row[28];
		$queue_priority =			$row[29];
		$drop_inbound_group =		$row[30];
		$ingroup_recording_override = $row[31];
		$ingroup_rec_filename =		$row[32];
		$afterhours_xfer_group =	$row[33];
		$qc_enabled =				$row[34];
		$qc_statuses =				$row[35];
		$qc_shift_id =				$row[36];
		$qc_get_record_launch =		$row[37];
		$qc_show_recording =		$row[38];
		$qc_web_form_address =		stripslashes($row[39]);
		$qc_script =				$row[40];
		$play_place_in_line = 		$row[41];
		$play_estimate_hold_time = 	$row[42];
		$hold_time_option = 		$row[43];
		$hold_time_option_seconds = $row[44];
		$hold_time_option_exten = 	$row[45];
		$hold_time_option_voicemail = 	$row[46];
		$hold_time_option_xfer_group = 	$row[47];
		$hold_time_option_callback_filename =	$row[48];
		$hold_time_option_callback_list_id = 	$row[49];
		$hold_recall_xfer_group = 	$row[50];
		$no_delay_call_route = 		$row[51];
		$play_welcome_message = 	$row[52];
		$answer_sec_pct_rt_stat_one =	$row[53];
		$answer_sec_pct_rt_stat_two =	$row[54];
		$default_group_alias =		$row[55];
		$no_agent_no_queue =		$row[56];
		$no_agent_action =			$row[57];
		$no_agent_action_value =	$row[58];
		$web_form_address_two =		stripslashes($row[59]);
		$timer_action =				$row[60];
		$timer_action_message =		$row[61];
		$timer_action_seconds =		$row[62];
		$start_call_url =			$row[63];
		$dispo_call_url =			$row[64];
		$ignore_list_script_override = $row[68];
		$extension_appended_cidname = $row[69];
		$uniqueid_status_display =	$row[70];
		$uniqueid_status_prefix =	$row[71];
		$hold_time_option_minimum = $row[72];
		$hold_time_option_press_filename = $row[73];
		$hold_time_option_callmenu = $row[74];
		$onhold_prompt_no_block =	$row[75];
		$onhold_prompt_seconds =	$row[76];
		$hold_time_option_no_block = $row[77];
		$hold_time_option_prompt_seconds =	$row[78];
		$hold_time_second_option =			$row[79];
		$hold_time_third_option =			$row[80];
		$wait_hold_option_priority =		$row[81];
		$wait_time_option =					$row[82];
		$wait_time_second_option =			$row[83];
		$wait_time_third_option =			$row[84];
		$wait_time_option_seconds =			$row[85];
		$wait_time_option_exten =			$row[86];
		$wait_time_option_voicemail =		$row[87];
		$wait_time_option_xfer_group =		$row[88];
		$wait_time_option_callmenu =		$row[89];
		$wait_time_option_callback_filename =	$row[90];
		$wait_time_option_callback_list_id =	$row[91];
		$wait_time_option_press_filename =	$row[92];
		$wait_time_option_no_block =		$row[93];
		$wait_time_option_prompt_seconds =	$row[94];
		$timer_action_destination =			$row[95];
		$calculate_estimated_hold_seconds = $row[96];
		$add_lead_url =						$row[97];
		$eht_minimum_prompt_filename =		$row[98];
		$eht_minimum_prompt_no_block =		$row[99];
		$eht_minimum_prompt_seconds =		$row[100];
		$na_call_url =						$row[102];
		$group_calldate =					$row[104];
		$action_xfer_cid =					$row[105];
		$drop_callmenu =					$row[106];
		$after_hours_callmenu =				$row[107];
		$user_group =						$row[108];
		$max_calls_method =					$row[109];
		$max_calls_count =					$row[110];
		$max_calls_action =					$row[111];
		$dial_ingroup_cid =					$row[112];
		$group_handling =					$row[113];
		$web_form_address_three =			$row[114];
		$status_group_id =					$row[115];
		$routing_initiated_recordings =		$row[116];
		$ingroup_script_two =				$row[117];
		$browser_alert_sound =				$row[118];
		$browser_alert_volume =				$row[119];
		$custom_one =						$row[120];
		$custom_two =						$row[121];
		$custom_three =						$row[122];
		$custom_four =						$row[123];
		$custom_five =						$row[124];

		##### get callmenu listings for dynamic pulldown
		$stmt="SELECT menu_id,menu_name from vicidial_call_menu $whereLOGadmin_viewable_groupsSQL order by menu_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$Xmenus_to_print = mysqli_num_rows($rslt);
		$o=0;
		$Xmenuslist='';
		$Wmenuslist='';
		while ($Xmenus_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$Xmenuslist .= "<option ";
			$Wmenuslist .= "<option ";
			if ($hold_time_option_callmenu == "$rowx[0]") 
				{
				$Xmenuslist .= "SELECTED ";
				$Xmenus_selected++;
				}
			if ($wait_time_option_callmenu == "$rowx[0]") 
				{
				$Wmenuslist .= "SELECTED ";
				$Wmenus_selected++;
				}
			$Xmenuslist .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$Wmenuslist .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		if ($Xmenus_selected < 1) 
			{$Xmenuslist .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		if ($Wmenus_selected < 1) 
			{$Wmenuslist .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}


		##### get in-groups listings for dynamic pulldown
		$stmt="SELECT group_id,group_name from vicidial_inbound_groups where group_id NOT IN('AGENTDIRECT') $LOGadmin_viewable_groupsSQL order by group_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$Xgroups_to_print = mysqli_num_rows($rslt);
		$Xgroups_menu='';
		$Xgroups_selected=0;
		$Dgroups_menu='';
		$Dgroups_selected=0;
		$Agroups_menu='';
		$Agroups_selected=0;
		$Hgroups_menu='';
		$Hgroups_selected=0;
		$Wgroups_menu='';
		$Wgroups_selected=0;
		$Tgroups_menu='';
		$Tgroups_selected=0;
		$o=0;
		while ($Xgroups_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$Xgroups_menu .= "<option ";
			$Dgroups_menu .= "<option ";
			$Agroups_menu .= "<option ";
			$Tgroups_menu .= "<option ";
			$Wgroups_menu .= "<option ";
			$Hgroups_menu .= "<option ";
			if ($default_xfer_group == "$rowx[0]") 
				{
				$Xgroups_menu .= "SELECTED ";
				$Xgroups_selected++;
				}
			if ($drop_inbound_group == "$rowx[0]") 
				{
				$Dgroups_menu .= "SELECTED ";
				$Dgroups_selected++;
				}
			if ($afterhours_xfer_group == "$rowx[0]") 
				{
				$Agroups_menu .= "SELECTED ";
				$Agroups_selected++;
				}
			if ($hold_time_option_xfer_group == "$rowx[0]") 
				{
				$Tgroups_menu .= "SELECTED ";
				$Tgroups_selected++;
				}
			if ($wait_time_option_xfer_group == "$rowx[0]") 
				{
				$Wgroups_menu .= "SELECTED ";
				$Wgroups_selected++;
				}
			if ($hold_recall_xfer_group == "$rowx[0]") 
				{
				$Hgroups_menu .= "SELECTED ";
				$Hgroups_selected++;
				}
			$Xgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$Dgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			if ($group_id!=$rowx[0])
				{
				$Agroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$Tgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$Wgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$Hgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				}
			$o++;
			}
		if ($Xgroups_selected < 1) 
			{$Xgroups_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		else 
			{$Xgroups_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		if ($Dgroups_selected < 1) 
			{$Dgroups_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		else 
			{$Dgroups_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		if ($Agroups_selected < 1) 
			{$Agroups_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		else 
			{$Agroups_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		if ($Tgroups_selected < 1) 
			{$Tgroups_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		else 
			{$Tgroups_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		if ($Wgroups_selected < 1) 
			{$Wgroups_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		else 
			{$Wgroups_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		if ($Hgroups_selected < 1) 
			{$Hgroups_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		else 
			{$Hgroups_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}

		$allowed_campaigns_count=0;
		$allowed_campaigns_warning='';
		$SQL_group_id = preg_replace("/_/",'\\_',$query_group_id);
		$stmt="SELECT count(*) from vicidial_campaigns where closer_campaigns LIKE \"% $SQL_group_id %\" $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campin_to_print = mysqli_num_rows($rslt);
		$vc_allowed_ct=0;
		if ($campin_to_print > $vc_allowed_ct) 
			{
			$rowc=mysqli_fetch_row($rslt);
			$allowed_campaigns_count = $rowc[0];
			$vc_allowed_ct++;
			}
		if ($allowed_campaigns_count < 1)
			{$allowed_campaigns_warning='<font color=red><b><br> &nbsp; '._QXZ("Not set as allowed in any campaigns!").'</b></font>';}

		echo "<br>"._QXZ("MODIFY AN EMAIL GROUPS RECORD").": $query_group_id<form action=$PHP_SELF method=POST name=admin_form id=admin_form>\n";
		echo "<input type=hidden name=ADD value=4811>\n";
		echo "<input type=hidden name=group_id value=\"$query_group_id\">\n";
		echo "<input type=hidden name=DB value=\"$DB\">\n";
		echo "<input type=hidden name=stage value=\"SUBMIT\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group ID").": </td><td align=left><b>$query_group_id</b>$NWB#inbound_groups-group_id$NWE $allowed_campaigns_warning</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group Name").": </td><td align=left><input type=text name=group_name size=30 maxlength=30 value=\"$group_name\">$NWB#inbound_groups-group_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group Color")." <font size=2>(<a href=\"javascript:launch_color_chooser('group_color','color','1');\">"._QXZ("color chooser")."</a>)</font>: </td><td align=left bgcolor=\"$group_color\" id=\"group_color_td\"><input type=text name=group_color id=group_color size=7 maxlength=20 value=\"$group_color\"> $NWB#inbound_groups-group_color$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$active' SELECTED>"._QXZ("$active")."</option></select>$NWB#inbound_groups-active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("In-Group Email Date").": </td><td align=left>$group_calldate$NWB#inbound_groups-group_emaildate$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>\n";
			$temp_chart_title = _QXZ("8 Day inbound call count for this in-group");
			horizontal_bar_chart($group_id,'8','in-group',$link,'total_calls','call count',1,'','',$temp_chart_title);
		echo "</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">".(preg_match('/\-\-ALL\-\-/', $user_group) ? _QXZ("$user_group") : $user_group)."</option>\n";
		echo "</select>$NWB#inbound_groups-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Web Form").": </td><td align=left><input type=text name=web_form_address size=70 maxlength=9999 value=\"$web_form_address\">$NWB#inbound_groups-web_form_address$NWE"; if ($SSenable_first_webform < 1) {echo " <font color=red><b>"._QXZ("DISABLED")."</b></font>";} echo "</td></tr>\n";
		if ($SSenable_second_webform > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Web Form Two").": </td><td align=left><input type=text name=web_form_address_two size=70 maxlength=9999 value=\"$web_form_address_two\">$NWB#inbound_groups-web_form_address$NWE</td></tr>\n";
			}
		if ($SSenable_third_webform > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Web Form Three").": </td><td align=left><input type=text name=web_form_address_three size=70 maxlength=9999 value=\"$web_form_address_three\">$NWB#inbound_groups-web_form_address$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Next Agent Email").": </td><td align=left><select size=1 name=next_agent_call><option value='random'>"._QXZ("random")."</option><option value='oldest_call_start'>"._QXZ("oldest_call_start")."</option><option value='oldest_call_finish'>"._QXZ("oldest_call_finish")."</option><option value='oldest_inbound_call_start'>"._QXZ("oldest_inbound_call_start")."</option><option value='oldest_inbound_call_finish'>"._QXZ("oldest_inbound_call_finish")."</option><option value='oldest_inbound_filtered_call_start'>"._QXZ("oldest_inbound_filtered_call_start")."</option><option value='oldest_inbound_filtered_call_finish'>"._QXZ("oldest_inbound_filtered_call_finish")."</option><option value='overall_user_level'>"._QXZ("overall_user_level")."</option><option value='inbound_group_rank'>"._QXZ("inbound_group_rank")."</option><option value='campaign_rank'>"._QXZ("campaign_rank")."</option><option value='ingroup_grade_random'>"._QXZ("ingroup_grade_random")."</option><option value='campaign_grade_random'>"._QXZ("campaign_grade_random")."</option><option value='fewest_calls'>"._QXZ("fewest_calls")."</option><option value='fewest_calls_campaign'>"._QXZ("fewest_calls_campaign")."</option><option value='longest_wait_time'>"._QXZ("longest_wait_time")."</option><option value='overall_user_level_wait_time'>"._QXZ("overall_user_level_wait_time")."</option><option value='campaign_rank_wait_time'>"._QXZ("campaign_rank_wait_time")."</option><option value='fewest_calls_campaign_wait_time'>"._QXZ("fewest_calls_campaign_wait_time")."</option><option value='inbound_group_rank_wait_time'>"._QXZ("inbound_group_rank_wait_time")."</option><option value='fewest_calls_wait_time'>"._QXZ("fewest_calls_wait_time")."</option><option value='$next_agent_call' SELECTED>"._QXZ("$next_agent_call")."</option></select>$NWB#inbound_groups-next_agent_email$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Queue Priority").": </td><td align=left><select size=1 name=queue_priority>\n";
		$n=99;
		while ($n>=-99)
			{
			$dtl = _QXZ("Even");
			if ($n<0) {$dtl = _QXZ("Lower");}
			if ($n>0) {$dtl = _QXZ("Higher");}
			if ($n == $queue_priority) 
				{echo "<option SELECTED value=\"$n\">$n - $dtl</option>\n";}
			else
				{echo "<option value=\"$n\">$n - $dtl</option>\n";}
			$n--;
			}
		echo "</select> $NWB#inbound_groups-queue_priority$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Fronter Display").": </td><td align=left><select size=1 name=fronter_display><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$fronter_display' SELECTED>"._QXZ("$fronter_display")."</option></select>$NWB#inbound_groups-fronter_display$NWE</td></tr>\n";

		$eswHTML=''; $cfwHTML='';
		if ($SSenable_second_script > 0)
			{$eswHTML .= "<option value='SCRIPTTWO'>"._QXZ("SCRIPTTWO")."</option>";}
		if ($SSenable_second_webform > 0)
			{$eswHTML .= "<option value='WEBFORMTWO'>"._QXZ("WEBFORMTWO")."</option>";}
		if ($SSenable_third_webform > 0)
			{$eswHTML .= "<option value='WEBFORMTHREE'>"._QXZ("WEBFORMTHREE")."</option>";}
		if ($SSallow_emails > 0)
			{$aemHTML .= "<option value='EMAIL'>"._QXZ("EMAIL")."</option>";}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Get Call Launch").": </td><td align=left><select size=1 name=get_call_launch><option value='NONE' selected>"._QXZ("NONE")."</option><option value='SCRIPT'>"._QXZ("SCRIPT")."</option><option value='WEBFORM'>"._QXZ("WEBFORM")."</option>$eswHTML$cfwHTML$aemHTML$achHTML<option value='$get_call_launch' selected>"._QXZ("$get_call_launch")."</option></select>$NWB#inbound_groups-get_call_launch$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right></td><td align=left><input type=hidden name=browser_alert_sound value=\"$browser_alert_sound\"><input type=hidden name=browser_alert_volume value=\"$browser_alert_volume\"></td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group Handling").": </td><td align=left><select size=1 name=group_handling><option  value='PHONE'>"._QXZ("PHONE")."</option>";
		echo "<option selected value='EMAIL'>"._QXZ("EMAIL")."</option>";

		if ($SSallow_chats > 0)
			{
			if ($SSallow_chats>0) {echo "<option value='CHAT'>"._QXZ("CHAT")."</option>";}			
			}

		echo "</select>$NWB#inbound_groups-group_handling$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=3111111&script_id=$script_id\">"._QXZ("Script")."</a>: </td><td align=left><select size=1 name=script_id>\n";
		echo "$scripts_list";
		echo "<option selected value=\"$script_id\">$script_id - $scriptname_list[$script_id]</option>\n";
		echo "</select>$NWB#inbound_groups-ingroup_script$NWE</td></tr>\n";

		if ($SSenable_second_script > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=3111111&script_id=$ingroup_script_two\">"._QXZ("Script Two").": </td><td align=left><select size=1 name=ingroup_script_two>\n";
			echo "$scripts_list";
			echo "<option selected value=\"$ingroup_script_two\">"._QXZ("$ingroup_script_two")." - $scriptname_list[$ingroup_script_two]</option>\n";
			echo "</select>$NWB#inbound_groups-ingroup_script$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right></td><td align=left><input type=hidden name=ingroup_script_two value='$ingroup_script_two'></td></tr>\n";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Ignore List Script Override").": </td><td align=left><select size=1 name=ignore_list_script_override><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$ignore_list_script_override' SELECTED>"._QXZ("$ignore_list_script_override")."</option></select>$NWB#inbound_groups-ignore_list_script_override$NWE</td></tr>\n";

		##### get status group listings for dynamic pulldown menu
		$stmt="SELECT status_group_id,status_group_notes from vicidial_status_groups $whereLOGadmin_viewable_groupsSQL order by status_group_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$status_groups_to_print = mysqli_num_rows($rslt);
		$status_groups_menu='';
		$status_groups_selected=0;
		$o=0;
		while ($status_groups_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$status_groups_menu .= "<option ";
			if ($status_group_id == "$rowx[0]") 
				{
				$status_groups_menu .= "SELECTED ";
				$status_groups_selected++;
				}
			$status_groups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		$sglinkB='';   $sglinkE='';
		if (strlen($status_group_id)>1)
			{
			$sglinkB="<a href=\"$PHP_SELF?ADD=393111111111&status_group_id=$status_group_id\">";
			$sglinkE='</a>';
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>$sglinkB"._QXZ("Status Group Override")."$sglinkE: </td><td align=left><select size=1 name=status_group_id>";
		echo "<option value=\"\">"._QXZ("NONE")."</option>";
		echo "$status_groups_menu";
		echo "</select>$NWB#inbound_groups-status_group_id$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("In-Group Recording Override").": </td><td align=left><select size=1 name=ingroup_recording_override><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='NEVER'>"._QXZ("NEVER")."</option><option value='ONDEMAND'>"._QXZ("ONDEMAND")."</option><option value='ALLCALLS'>"._QXZ("ALLCALLS")."</option><option value='ALLFORCE'>"._QXZ("ALLFORCE")."</option><option value='$ingroup_recording_override' SELECTED>"._QXZ("$ingroup_recording_override")."</option></select>$NWB#inbound_groups-ingroup_recording_override$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("In-Group Recording Filename").": </td><td align=left><input type=text name=ingroup_rec_filename size=50 maxlength=50 value=\"$ingroup_rec_filename\">$NWB#inbound_groups-ingroup_rec_filename$NWE</td></tr>\n";

/* Commenting this out because it is handled by the Email Account section and is redundant here
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>In-Group Call Handle Method: </td><td align=left><select size=1 name=call_handle_method><option>CID</option><option>CIDLOOKUP</option><option>CIDLOOKUPRL</option><option>CIDLOOKUPRC</option><option>CIDLOOKUPALT</option><option>CIDLOOKUPRLALT</option><option>CIDLOOKUPRCALT</option><option>CIDLOOKUPADDR3</option><option>CIDLOOKUPRLADDR3</option><option>CIDLOOKUPRCADDR3</option><option>CIDLOOKUPALTADDR3</option><option>CIDLOOKUPRLALTADDR3</option><option>CIDLOOKUPRCALTADDR3</option><option>ANI</option><option>ANILOOKUP</option><option>ANILOOKUPRL</option><option>VIDPROMPT</option><option>VIDPROMPTLOOKUP</option><option>VIDPROMPTLOOKUPRL</option><option>VIDPROMPTLOOKUPRC</option><option>CLOSER</option><option>3DIGITID</option><option>4DIGITID</option><option>5DIGITID</option><option>10DIGITID</option><option SELECTED>$call_handle_method</option></select>$NWB#inbound_dids-call_handle_method$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>In-Group Agent Search Method: </td><td align=left><select size=1 name=agent_search_method><option value=\"LB\">LB - Load Balanced</option><option value=\"LO\">LO - Load Balanced Overflow</option><option value=\"SO\">SO - Server Only</option><option SELECTED>$agent_search_method</option></select>$NWB#inbound_dids-agent_search_method$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>In-Group List ID: </td><td align=left><input type=text name=list_id size=14 maxlength=14 value=\"$list_id\">$NWB#inbound_dids-list_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>In-Group Campaign ID: </td><td align=left><select size=1 name=campaign_id>\n";
		echo "$campaigns_list";
		echo "<option SELECTED>$campaign_id</option>\n";
		echo "</select>$NWB#inbound_dids-campaign_id$NWE</td></tr>\n";
*/


		if ($start_call_url == 'ALT')
			{
			$stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$group_id' and entry_type='ingroup' and url_type='start';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$vum_to_print = mysqli_num_rows($rslt);
			if ($vum_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$vum_count = $rowx[0]; 
				}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"admin_url_multi.php?DB=$DB&campaign_id=$group_id&entry_type=ingroup&url_type=start\">"._QXZ("Start Email URL")."</a>: </td><td align=left><input type=text name=start_call_url size=10 maxlength=2000 value=\"$start_call_url\">$NWB#inbound_groups-start_call_url$NWE <a href=\"admin_url_multi.php?DB=$DB&campaign_id=$group_id&entry_type=ingroup&url_type=start\"> "._QXZ("Alternate Start URLs Defined").": $vum_count</a></td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Start Email URL").": </td><td align=left><input type=text name=start_call_url size=70 maxlength=5000 value=\"$start_call_url\">$NWB#inbound_groups-start_email_url$NWE</td></tr>\n";
			}

		if ($dispo_call_url == 'ALT')
			{
			$stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$group_id' and entry_type='ingroup' and url_type='dispo';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$vum_to_print = mysqli_num_rows($rslt);
			if ($vum_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$vum_count = $rowx[0]; 
				}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"admin_url_multi.php?DB=$DB&campaign_id=$group_id&entry_type=ingroup&url_type=dispo\">"._QXZ("Dispo Email URL")."</a>: </td><td align=left><input type=text name=dispo_call_url size=10 maxlength=2000 value=\"$dispo_call_url\">$NWB#inbound_groups-dispo_call_url$NWE <a href=\"admin_url_multi.php?DB=$DB&campaign_id=$group_id&entry_type=ingroup&url_type=dispo\"> "._QXZ("Alternate Dispo URLs Defined").": $vum_count</a></td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Dispo Email URL").": </td><td align=left><input type=text name=dispo_call_url size=70 maxlength=5000 value=\"$dispo_call_url\">$NWB#inbound_groups-dispo_email_url$NWE</td></tr>\n";
			}

		# get count of talk seconds urls in this In-Group
		$stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$group_id' and entry_type='ingroup' and url_type='talk';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$vum_to_print = mysqli_num_rows($rslt);
		if ($vum_to_print > 0) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$vum_count = $rowx[0]; 
			}
		# check if this In-Group has talk seconds url set to -FORCEDISABLE-
		$force_disableHTML='';
		$stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$group_id' and entry_type='ingroup' and url_type='talk' and active='N' and url_address LIKE \"%FORCEDISABLE%\";";
		$rslt=mysql_to_mysqli($stmt, $link);
		$fdtsu_to_print = mysqli_num_rows($rslt);
		if ($fdtsu_to_print > 0) 
			{
			$rowx=mysqli_fetch_row($rslt);
			if ($rowx[0] > 0)
				{$force_disableHTML="<font color='red'><b>FORCED DISABLE</b></font>";}
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"admin_url_multi.php?DB=$DB&campaign_id=$group_id&entry_type=ingroup&url_type=talk\">"._QXZ("Talk Seconds URLs")."</a>: </td><td align=left>$NWB#inbound_groups-talk_sec_url$NWE <a href=\"admin_url_multi.php?DB=$DB&campaign_id=$group_id&entry_type=ingroup&url_type=talk\"> "._QXZ("Talk Seconds URLs Defined").": $vum_count</a> &nbsp; $force_disableHTML</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Custom 1").": </td><td align=left><input type=text name=custom_one id=custom_one size=40 maxlength=2000 value=\"$custom_one\"> $NWB#inbound_groups-custom_fields$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Custom 2").": </td><td align=left><input type=text name=custom_two id=custom_two size=40 maxlength=2000 value=\"$custom_two\"> $NWB#inbound_groups-custom_fields$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Custom 3").": </td><td align=left><input type=text name=custom_three id=custom_three size=40 maxlength=2000 value=\"$custom_three\"> $NWB#inbound_groups-custom_fields$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Custom 4").": </td><td align=left><input type=text name=custom_four id=custom_four size=40 maxlength=2000 value=\"$custom_four\"> $NWB#inbound_groups-custom_fields$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Custom 5").": </td><td align=left><input type=text name=custom_five id=custom_five size=40 maxlength=2000 value=\"$custom_five\"> $NWB#inbound_groups-custom_fields$NWE</td></tr>\n";

/*
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>Add Lead URL: </td><td align=left><input type=text name=add_lead_url size=70 maxlength=5000 value=\"$add_lead_url\">$NWB#inbound_groups-add_lead_url$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("No Agent Email URL").": </td><td align=left><input type=text name=na_call_url size=70 maxlength=5000 value=\"$na_call_url\">$NWB#inbound_groups-na_email_url$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Extension Append CID").": </td><td align=left><select size=1 name=extension_appended_cidname><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option SELECTED>$extension_appended_cidname</option></select>$NWB#inbound_groups-extension_appended_cidname$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Uniqueid Status Display").": </td><td align=left><select size=1 name=uniqueid_status_display><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='ENABLED_PREFIX'>"._QXZ("ENABLED_PREFIX")."</option><option value='ENABLED_PRESERVE'>"._QXZ("ENABLED_PRESERVE")."</option><option value='$uniqueid_status_display' SELECTED>$uniqueid_status_display</option></select>$NWB#inbound_groups-uniqueid_status_display$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Uniqueid Status Prefix").": </td><td align=left><input type=text name=uniqueid_status_prefix size=10 maxlength=50 value=\"$uniqueid_status_prefix\">$NWB#inbound_groups-uniqueid_status_prefix$NWE</td></tr>\n";
*/

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>\n";
		echo "<input type=hidden name=call_handle_method value=\"$call_handle_method\">\n";
		echo "<input type=hidden name=agent_search_method value=\"$agent_search_method\">\n";
		echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
		echo "<input type=hidden name=add_lead_url value=\"$add_lead_url\">\n";
		echo "<input type=hidden name=na_call_url value=\"$na_call_url\">\n";
		echo "<input type=hidden name=extension_appended_cidname value=\"$extension_appended_cidname\">\n";
		echo "<input type=hidden name=uniqueid_status_display value=\"$uniqueid_status_display\">\n";
		echo "<input type=hidden name=uniqueid_status_prefix value=\"$uniqueid_status_prefix\">\n";
		echo "<input type=hidden name=form_end value=\"END\">\n";
		echo "</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";

		if ($SSqc_features_active > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2> &nbsp; </td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2> "._QXZ("Inbound Group QC Settings").": </td></tr>\n";

			##### get status listings for dynamic pulldown
			$qc_statuses = preg_replace("/^ | -$/","",$qc_statuses);
			$QCstatuses = explode(" ", $qc_statuses);
			$QCs_to_print = (count($QCstatuses) -0);
			$stmt="SELECT status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable,scheduled_callback from vicidial_statuses where status NOT IN('QUEUE','INCALL') order by status";
			$rslt=mysql_to_mysqli($stmt, $link);
			$statuses_to_print = mysqli_num_rows($rslt);
			$qc_statuses_list='';

			$o=0;
			while ($statuses_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$qc_statuses_list .= "<input type=\"checkbox\" name=\"qc_statuses[]\" value=\"$rowx[0]\"";
				$p=0;
				while ($p < $QCs_to_print)
					{
					if ($rowx[0] === $QCstatuses[$p]) 
						{
						$qc_statuses_list .= " CHECKED";
						}
					$p++;
					}
				$qc_statuses_list .= "> $rowx[0] - $rowx[1]<BR>\n";

				$o++;
				}

			$stmt="SELECT distinct(status),status_name from vicidial_campaign_statuses $whereLOGallowed_campaignsSQL order by status;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$Cstatuses_to_print = mysqli_num_rows($rslt);

			$o=0;
			while ($Cstatuses_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				if (!preg_match("/\"$rowx[0]\"/",$qc_statuses_list))
					{
					$qc_statuses_list .= "<input type=\"checkbox\" name=\"qc_statuses[]\" value=\"$rowx[0]\"";
					$p=0;
					while ($p < $QCs_to_print)
						{
						if ($rowx[0] === $QCstatuses[$p]) 
							{
							$qc_statuses_list .= " CHECKED";
							}
						$p++;
						}
					$qc_statuses_list .= "> $rowx[0] - $rowx[1]<BR>\n";
					}
				$o++;
				}

			##### get scripts listings for pulldown
			$stmt="SELECT script_id,script_name from vicidial_scripts $whereLOGadmin_viewable_groupsSQL order by script_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$scripts_to_print = mysqli_num_rows($rslt);
			$QCscripts_list="";
			$o=0;
			while ($scripts_to_print > $o)
				{
				$rowx=mysqli_fetch_row($rslt);
				$QCscripts_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$scriptname_list["$rowx[0]"] = "$rowx[1]";
				$o++;
				}
			##### get shifts listings for pulldown
			$stmt="SELECT shift_id,shift_name from vicidial_shifts $whereLOGadmin_viewable_groupsSQL order by shift_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$shifts_to_print = mysqli_num_rows($rslt);
			$QCshifts_list="";
			$o=0;
			while ($shifts_to_print > $o)
				{
				$rowx=mysqli_fetch_row($rslt);
				$QCshifts_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$shiftname_list["$rowx[0]"] = "$rowx[1]";
				$o++;
				}

			echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("QC Enabled").": </td><td><select size=1 name=qc_enabled><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value=\"$qc_enabled\" SELECTED>"._QXZ("$qc_enabled")."</option></select> $NWB#inbound_groups-qc_enabled$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("QC Statuses").": <BR> $NWB#inbound_groups-qc_statuses$NWE</td><td>$qc_statuses_list</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("QC WebForm").": </td><td align=left><input type=text name=qc_web_form_address size=70 maxlength=255 value=\"$qc_web_form_address\">$NWB#inbound_groups-qc_web_form_address$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row2_background><td align=right><a href=\"$PHP_SELF?ADD=3111111&script_id=$script_id\">"._QXZ("QC Script")."</a>: </td><td align=left><select size=1 name=qc_script>\n";
			echo "$QCscripts_list";
			echo "<option selected value=\"$qc_script\">$qc_script - $scriptname_list[$qc_script]</option>\n";
			echo "</select>$NWB#inbound_groups-qc_script$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row2_background><td align=right><a href=\"$PHP_SELF?ADD=331111111&shift_id=$qc_shift_id\">"._QXZ("QC Shift")."</a>: </td><td align=left><select size=1 name=qc_shift_id>\n";
			echo "$QCshifts_list";
			echo "<option selected value=\"$qc_shift_id\">$qc_shift_id - $shiftname_list[$qc_shift_id]</option>\n";
			echo "</select>$NWB#inbound_groups-qc_shift_id$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("QC Get Record Launch").": </td><td><select size=1 name=qc_get_record_launch><option value='NONE'>"._QXZ("NONE")."</option><option value='SCRIPT'>"._QXZ("SCRIPT")."</option><option value='WEBFORM'>"._QXZ("WEBFORM")."</option><option value='QCSCRIPT'>"._QXZ("QCSCRIPT")."</option><option value='QCWEBFORM'>"._QXZ("QCWEBFORM")."</option><option value='$qc_get_record_launch' SELECTED>"._QXZ("$qc_get_record_launch")."</option></select> $NWB#inbound_groups-qc_get_record_launch$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("QC Show Recording").": </td><td><select size=1 name=qc_show_recording><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$qc_show_recording' SELECTED>"._QXZ("$qc_show_recording")."</option></select> $NWB#inbound_groups-qc_show_recording$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row2_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'></td></tr>\n";
			}

		echo "</table>\n";
		echo "<BR></center><BR><BR>\n";


		### list of agent rank or skill-level for this inbound group
		echo "<center><a name=\"agent_ranks\">\n";
		echo "<br><b>"._QXZ("AGENT RANKS FOR THIS INBOUND GROUP").":</b><br>\n";
		echo "<TABLE width=800 cellspacing=3>\n";
		echo "<tr><td>"._QXZ("USER")."</td><td>"._QXZ("GROUP")."</td><td>"._QXZ("SELECTED")."</td><td> &nbsp; "._QXZ("RANK")." &nbsp; </td><td> &nbsp; "._QXZ("GRADE")." &nbsp; </td><td> "._QXZ("DAILY LIMIT")." </td><td> "._QXZ("CALLS TODAY")." </td></tr>\n";

		$stmt="SELECT user,full_name,closer_campaigns,user_group from vicidial_users where active='Y' $LOGadmin_viewable_groupsSQL order by user;";
		$rsltx=mysql_to_mysqli($stmt, $link);
		$users_to_print = mysqli_num_rows($rsltx);

		$o=0;
		while ($users_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rsltx);
			$o++;

			$ARIG_user[$o] =	$rowx[0];
			$ARIG_name[$o] =	$rowx[1];
			$ARIG_close[$o] =	$rowx[2];
			$ARIG_group[$o] =	(preg_match('/\-\-ALL\-\-/', $rowx[3]) ? _QXZ("$rowx[3]") : $rowx[3]);
			$ARIG_check[$o] =	'';
			if (preg_match("/ $group_id /",$ARIG_close[$o]))
				{$ARIG_check[$o] = ' CHECKED';}
			}

		$o=0;
		$ARIG_changenotes='';
		$stmtDlog='';
		while ($users_to_print > $o) 
			{
			$o++;
			$stmt="SELECT group_rank,calls_today,group_grade,daily_limit from vicidial_inbound_group_agents where group_id='$group_id' and user='$ARIG_user[$o]';";
			$rsltx=mysql_to_mysqli($stmt, $link);
			$viga_to_print = mysqli_num_rows($rsltx);
			if ($viga_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rsltx);
				$ARIG_rank[$o] =	$rowx[0];
				$ARIG_calls[$o] =	$rowx[1];
				$ARIG_grade[$o] =	$rowx[2];
				$ARIG_limit[$o] =	$rowx[3];
				}
			else
				{
				$stmtD="INSERT INTO vicidial_inbound_group_agents set calls_today='0',group_rank='0',group_weight='0',user='$ARIG_user[$o]',group_id='$group_id',group_grade='1',group_type='E';";
				$rslt=mysql_to_mysqli($stmtD, $link);
				$affected_rows_grp = mysqli_affected_rows($link);
				if ($DB > 0) {echo "$affected_rows_grp|$stmtD|";}
				$stmtDlog .= "$stmtD|";
				$ARIG_changenotes .= "added missing user to viga table $ARIG_user[$o]|";
				$ARIG_rank[$o] =	'0';
				$ARIG_calls[$o] =	'0';
				$ARIG_grade[$o] =	'1';
				$ARIG_limit[$o] =	'-1';
				}
			}
		if (strlen($ARIG_changenotes) > 10)
			{
			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmtDlog|";
			$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='INGROUPS', event_type='MODIFY', record_id='$group_id', event_code='USER INGROUP VIGA ADD', event_sql=\"$SQL_log\", event_notes='$ARIG_changenotes';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}


		if ( ($stage=='SUBMIT') or ($stage==_QXZ("SUBMIT")) )
			{
			$o=0;
			while ($users_to_print > $o) 
				{
				$o++;

				$ARIG_checked='';
				$ARIG_ranked='';
				$ARIG_graded='';
				$ARIG_limited='';

				$checkbox_field="CHECK_$ARIG_user[$o]$US$group_id";
				$rank_field="RANK_$ARIG_user[$o]$US$group_id";
				$grade_field="GRADE_$ARIG_user[$o]$US$group_id";
				$limit_field="LIMIT_$ARIG_user[$o]$US$group_id";

				if (isset($_GET["$checkbox_field"]))			{$ARIG_checked=$_GET["$checkbox_field"];}
					elseif (isset($_POST["$checkbox_field"]))	{$ARIG_checked=$_POST["$checkbox_field"];}
				if (isset($_GET["$rank_field"]))			{$ARIG_ranked=$_GET["$rank_field"];}
					elseif (isset($_POST["$rank_field"]))	{$ARIG_ranked=$_POST["$rank_field"];}
				if (isset($_GET["$grade_field"]))			{$ARIG_graded=$_GET["$grade_field"];}
					elseif (isset($_POST["$grade_field"]))	{$ARIG_graded=$_POST["$grade_field"];}
				if (isset($_GET["$limit_field"]))			{$ARIG_limited=$_GET["$limit_field"];}
					elseif (isset($_POST["$limit_field"]))	{$ARIG_limited=$_POST["$limit_field"];}
				$ARIG_checked = preg_replace('/[^A-Z]/','',$ARIG_checked);
				$ARIG_ranked = preg_replace('/[^-0-9]/','',$ARIG_ranked);
				$ARIG_graded = preg_replace('/[^-0-9]/','',$ARIG_graded);
				$ARIG_limited = preg_replace('/[^-0-9]/','',$ARIG_limited);

				$stmtA='';
				$stmtB='';
				$stmtC='';
				$stmtD='';
				$stmtE='';
				$ARIG_updated=0;
				$ARIG_changenotes='';
				if ( ($ARIG_check[$o]=='') and ($ARIG_checked=='YES') )
					{
					if (strlen($ARIG_close[$o]) < 4) {$ARIG_close[$o]=' - ';}
					$stmtA="UPDATE vicidial_users set closer_campaigns=' $group_id$ARIG_close[$o]' where user='$ARIG_user[$o]';";
					$rslt=mysql_to_mysqli($stmtA, $link);
					if ($DB > 0) {echo "|$stmtA|";}
					$ARIG_updated++;
					$ARIG_changenotes .= "added $group_id to selected in-groups|";
					}
				if ( ($ARIG_check[$o]==' CHECKED') and ($ARIG_checked=='') )
					{
					$ARIG_close[$o] = preg_replace("/ $group_id /",' ',$ARIG_close[$o]);
					$stmtB="UPDATE vicidial_users set closer_campaigns='$ARIG_close[$o]' where user='$ARIG_user[$o]';";
					$rslt=mysql_to_mysqli($stmtB, $link);
					if ($DB > 0) {echo "|$stmtB|";}
					$ARIG_updated++;
					$ARIG_changenotes .= "removed $group_id from selected in-groups|";
					}
				if ( ($ARIG_ranked < $ARIG_rank[$o]) or ($ARIG_ranked > $ARIG_rank[$o]) )
					{
					$stmtC="UPDATE vicidial_inbound_group_agents set group_rank='$ARIG_ranked',group_weight='$ARIG_ranked' where user='$ARIG_user[$o]' and group_id='$group_id';";
					$rslt=mysql_to_mysqli($stmtC, $link);
					if ($DB > 0) {echo "|$stmtC|";}
					$ARIG_updated++;
					$ARIG_changenotes .= "changed rank from $ARIG_rank[$o] to $ARIG_ranked|";
					}
				if ( ($ARIG_graded < $ARIG_grade[$o]) or ($ARIG_graded > $ARIG_grade[$o]) )
					{
					$stmtD="UPDATE vicidial_inbound_group_agents set group_grade='$ARIG_graded' where user='$ARIG_user[$o]' and group_id='$group_id';";
					$rslt=mysql_to_mysqli($stmtD, $link);
					if ($DB > 0) {echo "|$stmtD|";}
					$ARIG_updated++;
					$ARIG_changenotes .= "changed grade from $ARIG_grade[$o] to $ARIG_graded|";
					}
				if ( ($ARIG_limited < $ARIG_limit[$o]) or ($ARIG_limited > $ARIG_limit[$o]) )
					{
					$stmtE="UPDATE vicidial_inbound_group_agents set daily_limit='$ARIG_limited' where user='$ARIG_user[$o]' and group_id='$group_id';";
					$rslt=mysql_to_mysqli($stmtE, $link);
					if ($DB > 0) {echo "|$stmtE|";}
					$ARIG_updated++;
					$ARIG_changenotes .= "changed limit from $ARIG_limit[$o] to $ARIG_limited|";
					}
				if ($ARIG_updated > 0)
					{
					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$stmtA|$stmtB|$stmtC|$stmtD|$stmtE|";
					$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='$ARIG_user[$o]', event_code='USER INGROUP SETTINGS', event_sql=\"$SQL_log\", event_notes='$ARIG_changenotes';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}

			$stmt="SELECT vu.user,viga.group_rank,calls_today,full_name,closer_campaigns,viga.group_grade,viga.daily_limit from vicidial_inbound_group_agents viga, vicidial_users vu where group_id='$group_id' and active='Y' and vu.user=viga.user $LOGadmin_viewable_groupsSQL order by vu.user;";
			$rsltx=mysql_to_mysqli($stmt, $link);
			$users_to_print = mysqli_num_rows($rsltx);

			$o=0;
			while ($users_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rsltx);
				$o++;

				$ARIG_user[$o] =	$rowx[0];
				$ARIG_rank[$o] =	$rowx[1];
				$ARIG_calls[$o] =	$rowx[2];
				$ARIG_name[$o] =	$rowx[3];
				$ARIG_close[$o] =	$rowx[4];
				$ARIG_grade[$o] =	$rowx[5];
				$ARIG_limit[$o] =	$rowx[6];
				$ARIG_check[$o] =	'';
				if (preg_match("/ $group_id /",$ARIG_close[$o]))
					{$ARIG_check[$o] = ' CHECKED';}
				}
			}

		$checkbox_count=0;
		$o=0;
		while ($users_to_print > $o) 
			{
			$o++;

			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

			$checkbox_field="CHECK_$ARIG_user[$o]$US$group_id";
			$rank_field="RANK_$ARIG_user[$o]$US$group_id";
			$grade_field="GRADE_$ARIG_user[$o]$US$group_id";
			$limit_field="LIMIT_$ARIG_user[$o]$US$group_id";
			$checkbox_list .= "|$checkbox_field";
			$checkbox_count++;

			$users_output .= "<tr $bgcolor><td><font size=1><a href=\"$PHP_SELF?ADD=3&user=$ARIG_user[$o]\">$ARIG_user[$o]</a> - $ARIG_name[$o]</td>\n";
			$users_output .= "<td><font size=1>$ARIG_group[$o]</td>\n";
			$users_output .= "<td><input type=checkbox name=\"$checkbox_field\" id=\"$checkbox_field\" value=\"YES\"$ARIG_check[$o]></td>\n";
			$users_output .= "<td><select size=1 name=$rank_field>\n";
			$h="9";
			while ($h>=-9)
				{
				$users_output .= "<option value=\"$h\"";
				if ($h==$ARIG_rank[$o])
					{$users_output .= " SELECTED";}
				$users_output .= ">$h</option>";
				$h--;
				}
			$users_output .= "</select></td>\n";
			$users_output .= "<td><select size=1 name=$grade_field>\n";
			$h="10";
			while ($h>=1)
				{
				$users_output .= "<option value=\"$h\"";
				if ($h==$ARIG_grade[$o])
					{$users_output .= " SELECTED";}
				$users_output .= ">$h</option>";
				$h--;
				}
			$users_output .= "</select></td>\n";
			$users_output .= "<td><input type=text name=$limit_field size=5 maxlength=4 value=\"$ARIG_limit[$o]\"></td>\n";
			$users_output .= "<td><font size=1>$ARIG_calls[$o]</td></tr>\n";
			}
		echo "<tr><td><font size=1> &nbsp; </font></td><td><font size=1> &nbsp; </font></td><td align=left><span id=IGU_selectlink><a href=\"#\" onclick=\"FORM_selectall('$checkbox_count','$checkbox_list','on','IGU_selectlink');return false;\"><font size=1>"._QXZ("select all")."</font></a></span></td><td colspan=2><font size=1> &nbsp; </font></td></tr>\n";

		echo "$users_output";

		echo "<tr><td align=center colspan=4><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'></td></tr>\n";

		echo "</table></center><br></FORM>\n";

		echo "<a href=\"./AST_CLOSERstats.php?group[]=$group_id\">"._QXZ("Click here to see a report for this inbound group")."</a><BR><BR>\n";

		echo "<a href=\"./AST_VICIDIAL_ingrouplist.php?group=$group_id\">"._QXZ("Click here to see agents logged in to this inbound group")."</a><BR><BR>\n";

		echo "<center><b>\n";

		echo "<B>"._QXZ("EMAIL ACCOUNTS USING THIS IN-GROUP").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT email_account_id, email_account_name from vicidial_email_accounts where group_id='$group_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$emails_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($emails_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"admin_email_accounts.php?eact=UPDATE&email_account_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE><BR>\n";
		echo "<B>"._QXZ("CAMPAIGNS ALLOWING THIS IN-GROUP").":</B><BR>\n";
		echo "<TABLE>\n";

		$SQL_group_id = preg_replace("/_/",'\\_',$group_id);
		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where closer_campaigns LIKE \"% $SQL_group_id %\" $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campin_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($campin_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=31&campaign_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE>\n";

		if ($LOGdelete_ingroups > 0)
			{
		#	echo "<br><br><a href=\"$PHP_SELF?ADD=53&campaign_id=$group_id&stage=IN\">EMERGENCY VDAC CLEAR FOR THIS IN-GROUP</a><BR><BR>\n";
			echo "<br><br><a href=\"$PHP_SELF?ADD=5111&group_id=$group_id&group_handling=$group_handling\">"._QXZ("DELETE THIS IN-GROUP")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=INGROUPS&stage=$group_id\">"._QXZ("Click here to see Admin changes to this In-Group")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}

	}


######################
# ADD=3911 modify chat in-group info in the system
######################
if ($ADD==3911)
	{
	if ( ($LOGmodify_ingroups==1) and ($SSallow_chats>0) )
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=4911&group_id=$group_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,drop_call_seconds,drop_action,drop_exten,call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,default_xfer_group,queue_priority,drop_inbound_group,ingroup_recording_override,ingroup_rec_filename,afterhours_xfer_group,qc_enabled,qc_statuses,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two,default_group_alias,no_agent_no_queue,no_agent_action,no_agent_action_value,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,ignore_list_script_override,extension_appended_cidname,uniqueid_status_display,uniqueid_status_prefix,hold_time_option_minimum,hold_time_option_press_filename,hold_time_option_callmenu,onhold_prompt_no_block,onhold_prompt_seconds,hold_time_option_no_block,hold_time_option_prompt_seconds,hold_time_second_option,hold_time_third_option,wait_hold_option_priority,wait_time_option,wait_time_second_option,wait_time_third_option,wait_time_option_seconds,wait_time_option_exten,wait_time_option_voicemail,wait_time_option_xfer_group,wait_time_option_callmenu,wait_time_option_callback_filename,wait_time_option_callback_list_id,wait_time_option_press_filename,wait_time_option_no_block,wait_time_option_prompt_seconds,timer_action_destination,calculate_estimated_hold_seconds,add_lead_url,eht_minimum_prompt_filename, eht_minimum_prompt_no_block,eht_minimum_prompt_seconds,on_hook_ring_time,na_call_url,on_hook_cid,group_calldate,action_xfer_cid,drop_callmenu,after_hours_callmenu,user_group,max_calls_method,max_calls_count,max_calls_action,dial_ingroup_cid,group_handling,web_form_address_three,status_group_id,customer_chat_screen_colors,customer_chat_survey_link,customer_chat_survey_text,browser_alert_sound,browser_alert_volume,custom_one,custom_two,custom_three,custom_four,custom_five from vicidial_inbound_groups where group_id='$group_id' $LOGadmin_viewable_groupsSQL;";

		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$query_group_id =			$row[0];
		$group_name =				$row[1];
		$group_color =				$row[2];
		$active =					$row[3];
		$web_form_address =			stripslashes($row[4]);
		$voicemail_ext =			$row[5];
		$next_agent_call =			$row[6];
		$fronter_display =			$row[7];
		$script_id =				$row[8];
		$get_call_launch =			$row[9];
		$drop_call_seconds =		$row[14];
		$drop_action =				$row[15];
		$drop_exten =				$row[16];
		$call_time_id =				$row[17];
		$after_hours_action =		$row[18];
		$after_hours_message_filename =	$row[19];
		$after_hours_exten =		$row[20];
		$after_hours_voicemail =	$row[21];
		$welcome_message_filename =	$row[22];
		$moh_context =				$row[23];
		$onhold_prompt_filename =	$row[24];
		$prompt_interval =			$row[25];
		$agent_alert_exten =		$row[26];
		$agent_alert_delay =		$row[27];
		$default_xfer_group =		$row[28];
		$queue_priority =			$row[29];
		$drop_inbound_group =		$row[30];
		$ingroup_recording_override = $row[31];
		$ingroup_rec_filename =		$row[32];
		$afterhours_xfer_group =	$row[33];
		$qc_enabled =				$row[34];
		$qc_statuses =				$row[35];
		$qc_shift_id =				$row[36];
		$qc_get_record_launch =		$row[37];
		$qc_show_recording =		$row[38];
		$qc_web_form_address =		stripslashes($row[39]);
		$qc_script =				$row[40];
		$play_place_in_line = 		$row[41];
		$play_estimate_hold_time = 	$row[42];
		$hold_time_option = 		$row[43];
		$hold_time_option_seconds = $row[44];
		$hold_time_option_exten = 	$row[45];
		$hold_time_option_voicemail = 	$row[46];
		$hold_time_option_xfer_group = 	$row[47];
		$hold_time_option_callback_filename =	$row[48];
		$hold_time_option_callback_list_id = 	$row[49];
		$hold_recall_xfer_group = 	$row[50];
		$no_delay_call_route = 		$row[51];
		$play_welcome_message = 	$row[52];
		$answer_sec_pct_rt_stat_one =	$row[53];
		$answer_sec_pct_rt_stat_two =	$row[54];
		$default_group_alias =		$row[55];
		$no_agent_no_queue =		$row[56];
		$no_agent_action =			$row[57];
		$no_agent_action_value =	$row[58];
		$web_form_address_two =		stripslashes($row[59]);
		$timer_action =				$row[60];
		$timer_action_message =		$row[61];
		$timer_action_seconds =		$row[62];
		$start_call_url =			$row[63];
		$dispo_call_url =			$row[64];
		$ignore_list_script_override = $row[68];
		$extension_appended_cidname = $row[69];
		$uniqueid_status_display =	$row[70];
		$uniqueid_status_prefix =	$row[71];
		$hold_time_option_minimum = $row[72];
		$hold_time_option_press_filename = $row[73];
		$hold_time_option_callmenu = $row[74];
		$onhold_prompt_no_block =	$row[75];
		$onhold_prompt_seconds =	$row[76];
		$hold_time_option_no_block = $row[77];
		$hold_time_option_prompt_seconds =	$row[78];
		$hold_time_second_option =			$row[79];
		$hold_time_third_option =			$row[80];
		$wait_hold_option_priority =		$row[81];
		$wait_time_option =					$row[82];
		$wait_time_second_option =			$row[83];
		$wait_time_third_option =			$row[84];
		$wait_time_option_seconds =			$row[85];
		$wait_time_option_exten =			$row[86];
		$wait_time_option_voicemail =		$row[87];
		$wait_time_option_xfer_group =		$row[88];
		$wait_time_option_callmenu =		$row[89];
		$wait_time_option_callback_filename =	$row[90];
		$wait_time_option_callback_list_id =	$row[91];
		$wait_time_option_press_filename =	$row[92];
		$wait_time_option_no_block =		$row[93];
		$wait_time_option_prompt_seconds =	$row[94];
		$timer_action_destination =			$row[95];
		$calculate_estimated_hold_seconds = $row[96];
		$add_lead_url =						$row[97];
		$eht_minimum_prompt_filename =		$row[98];
		$eht_minimum_prompt_no_block =		$row[99];
		$eht_minimum_prompt_seconds =		$row[100];
		$na_call_url =						$row[102];
		$group_calldate =					$row[104];
		$action_xfer_cid =					$row[105];
		$drop_callmenu =					$row[106];
		$after_hours_callmenu =				$row[107];
		$user_group =						$row[108];
		$max_calls_method =					$row[109];
		$max_calls_count =					$row[110];
		$max_calls_action =					$row[111];
		$dial_ingroup_cid =					$row[112];
		$group_handling =					$row[113];
		$web_form_address_three =			$row[114];
		$status_group_id =					$row[115];
		$customer_chat_screen_colors =		$row[116];
		$customer_chat_survey_link =		$row[117];
		$customer_chat_survey_text =		$row[118];
		$browser_alert_sound =				$row[119];
		$browser_alert_volume =				$row[120];
		$custom_one =						$row[121];
		$custom_two =						$row[122];
		$custom_three =						$row[123];
		$custom_four =						$row[124];
		$custom_five =						$row[125];

/*
		##### get callmenu listings for dynamic pulldown
		$stmt="SELECT menu_id,menu_name from vicidial_call_menu $whereLOGadmin_viewable_groupsSQL order by menu_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$Xmenus_to_print = mysqli_num_rows($rslt);
		$o=0;
		$Xmenuslist='';
		$Wmenuslist='';
		while ($Xmenus_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$Xmenuslist .= "<option ";
			$Wmenuslist .= "<option ";
			if ($hold_time_option_callmenu == "$rowx[0]") 
				{
				$Xmenuslist .= "SELECTED ";
				$Xmenus_selected++;
				}
			if ($wait_time_option_callmenu == "$rowx[0]") 
				{
				$Wmenuslist .= "SELECTED ";
				$Wmenus_selected++;
				}
			$Xmenuslist .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$Wmenuslist .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		if ($Xmenus_selected < 1) 
			{$Xmenuslist .= "<option SELECTED value=\"---NONE---\">---NONE---</option>\n";}
		if ($Wmenus_selected < 1) 
			{$Wmenuslist .= "<option SELECTED value=\"---NONE---\">---NONE---</option>\n";}
*/

/*
		##### get in-groups listings for dynamic pulldown
		$stmt="SELECT group_id,group_name from vicidial_inbound_groups where group_id NOT IN('AGENTDIRECT') $LOGadmin_viewable_groupsSQL order by group_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$Xgroups_to_print = mysqli_num_rows($rslt);
		$Xgroups_menu='';
		$Xgroups_selected=0;
		$Dgroups_menu='';
		$Dgroups_selected=0;
		$Agroups_menu='';
		$Agroups_selected=0;
		$Hgroups_menu='';
		$Hgroups_selected=0;
		$Wgroups_menu='';
		$Wgroups_selected=0;
		$Tgroups_menu='';
		$Tgroups_selected=0;
		$o=0;
		while ($Xgroups_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$Xgroups_menu .= "<option ";
			$Dgroups_menu .= "<option ";
			$Agroups_menu .= "<option ";
			$Tgroups_menu .= "<option ";
			$Wgroups_menu .= "<option ";
			$Hgroups_menu .= "<option ";
			if ($default_xfer_group == "$rowx[0]") 
				{
				$Xgroups_menu .= "SELECTED ";
				$Xgroups_selected++;
				}
			if ($drop_inbound_group == "$rowx[0]") 
				{
				$Dgroups_menu .= "SELECTED ";
				$Dgroups_selected++;
				}
			if ($afterhours_xfer_group == "$rowx[0]") 
				{
				$Agroups_menu .= "SELECTED ";
				$Agroups_selected++;
				}
			if ($hold_time_option_xfer_group == "$rowx[0]") 
				{
				$Tgroups_menu .= "SELECTED ";
				$Tgroups_selected++;
				}
			if ($wait_time_option_xfer_group == "$rowx[0]") 
				{
				$Wgroups_menu .= "SELECTED ";
				$Wgroups_selected++;
				}
			if ($hold_recall_xfer_group == "$rowx[0]") 
				{
				$Hgroups_menu .= "SELECTED ";
				$Hgroups_selected++;
				}
			$Xgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$Dgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			if ($group_id!=$rowx[0])
				{
				$Agroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$Tgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$Wgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$Hgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				}
			$o++;
			}
		if ($Xgroups_selected < 1) 
			{$Xgroups_menu .= "<option SELECTED value=\"---NONE---\">---NONE---</option>\n";}
		else 
			{$Xgroups_menu .= "<option value=\"---NONE---\">---NONE---</option>\n";}
		if ($Dgroups_selected < 1) 
			{$Dgroups_menu .= "<option SELECTED value=\"---NONE---\">---NONE---</option>\n";}
		else 
			{$Dgroups_menu .= "<option value=\"---NONE---\">---NONE---</option>\n";}
		if ($Agroups_selected < 1) 
			{$Agroups_menu .= "<option SELECTED value=\"---NONE---\">---NONE---</option>\n";}
		else 
			{$Agroups_menu .= "<option value=\"---NONE---\">---NONE---</option>\n";}
		if ($Tgroups_selected < 1) 
			{$Tgroups_menu .= "<option SELECTED value=\"---NONE---\">---NONE---</option>\n";}
		else 
			{$Tgroups_menu .= "<option value=\"---NONE---\">---NONE---</option>\n";}
		if ($Wgroups_selected < 1) 
			{$Wgroups_menu .= "<option SELECTED value=\"---NONE---\">---NONE---</option>\n";}
		else 
			{$Wgroups_menu .= "<option value=\"---NONE---\">---NONE---</option>\n";}
		if ($Hgroups_selected < 1) 
			{$Hgroups_menu .= "<option SELECTED value=\"---NONE---\">---NONE---</option>\n";}
		else 
			{$Hgroups_menu .= "<option value=\"---NONE---\">---NONE---</option>\n";}
*/

		$allowed_campaigns_count=0;
		$allowed_campaigns_warning='';
		$SQL_group_id = preg_replace("/_/",'\\_',$query_group_id);
		$stmt="SELECT count(*) from vicidial_campaigns where closer_campaigns LIKE \"% $SQL_group_id %\" $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campin_to_print = mysqli_num_rows($rslt);
		$vc_allowed_ct=0;
		if ($campin_to_print > $vc_allowed_ct) 
			{
			$rowc=mysqli_fetch_row($rslt);
			$allowed_campaigns_count = $rowc[0];
			$vc_allowed_ct++;
			}
		if ($allowed_campaigns_count < 1)
			{$allowed_campaigns_warning="<font color=red><b><br> &nbsp; "._QXZ("Not set as allowed in any campaigns")."!</b></font>";}

		echo "<br>"._QXZ("MODIFY AN CHAT GROUPS RECORD").": $query_group_id<form action=$PHP_SELF method=POST name=admin_form id=admin_form>\n";
		echo "<input type=hidden name=ADD value=4911>\n";
		echo "<input type=hidden name=group_id value=\"$query_group_id\">\n";
		echo "<input type=hidden name=DB value=\"$DB\">\n";
		echo "<input type=hidden name=stage value=\"SUBMIT\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group ID").": </td><td align=left><b>$query_group_id</b>$NWB#inbound_groups-group_id$NWE $allowed_campaigns_warning</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group Name").": </td><td align=left><input type=text name=group_name size=30 maxlength=30 value=\"$group_name\">$NWB#inbound_groups-group_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group Color")." <font size=2>(<a href=\"javascript:launch_color_chooser('group_color','color','1');\">"._QXZ("color chooser")."</a>)</font>: </td><td align=left bgcolor=\"$group_color\" id=\"group_color_td\"><input type=text name=group_color id=group_color size=7 maxlength=20 value=\"$group_color\"> $NWB#inbound_groups-group_color$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option SELECTED value='$active'>"._QXZ("$active")."</option></select>$NWB#inbound_groups-active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("In-Group Chat Date").": </td><td align=left>$group_calldate$NWB#inbound_groups-group_chatdate$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Default List ID").": </td><td align=left><input type=text name=hold_time_option_callback_list_id size=19 maxlength=19 value='$hold_time_option_callback_list_id'>$NWB#inbound_groups-default_list_id$NWE</td></tr>";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>\n";
			$temp_chart_title = _QXZ("8 Day inbound call count for this in-group");
			horizontal_bar_chart($group_id,'8','in-group',$link,'total_calls','call count',1,'','',$temp_chart_title);
		echo "</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">".(preg_match('/\-\-ALL\-\-/', $user_group) ? _QXZ("$user_group") : $user_group)."</option>\n";
		echo "</select>$NWB#inbound_groups-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Web Form").": </td><td align=left><input type=text name=web_form_address size=70 maxlength=9999 value=\"$web_form_address\">$NWB#inbound_groups-web_form_address$NWE"; if ($SSenable_first_webform < 1) {echo " <font color=red><b>"._QXZ("DISABLED")."</b></font>";} echo "</td></tr>\n";
		if ($SSenable_second_webform > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Web Form Two").": </td><td align=left><input type=text name=web_form_address_two size=70 maxlength=9999 value=\"$web_form_address_two\">$NWB#inbound_groups-web_form_address$NWE</td></tr>\n";
			}
		if ($SSenable_third_webform > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Web Form Three").": </td><td align=left><input type=text name=web_form_address_three size=70 maxlength=9999 value=\"$web_form_address_three\">$NWB#inbound_groups-web_form_address$NWE</td></tr>\n";
			}
		# echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Next Agent Chat").": </td><td align=left><select size=1 name=next_agent_call><option value='random'>"._QXZ("random")."</option><option value='oldest_call_start'>"._QXZ("oldest_call_start")."</option><option value='oldest_call_finish'>"._QXZ("oldest_call_finish")."</option><option value='oldest_inbound_call_start'>"._QXZ("oldest_inbound_call_start")."</option><option value='oldest_inbound_call_finish'>"._QXZ("oldest_inbound_call_finish")."</option><option value='overall_user_level'>"._QXZ("overall_user_level")."</option><option value='inbound_group_rank'>"._QXZ("inbound_group_rank")."</option><option value='campaign_rank'>"._QXZ("campaign_rank")."</option><option value='ingroup_grade_random'>"._QXZ("ingroup_grade_random")."</option><option value='campaign_grade_random'>"._QXZ("campaign_grade_random")."</option><option value='fewest_calls'>"._QXZ("fewest_calls")."</option><option value='fewest_calls_campaign'>"._QXZ("fewest_calls_campaign")."</option><option value='longest_wait_time'>"._QXZ("longest_wait_time")."</option><option SELECTED value='$next_agent_call'>"._QXZ("$next_agent_call")."</option></select>$NWB#inbound_groups-next_agent_chat$NWE "._QXZ("THIS OPTION IS NOT ACTIVE")."</td></tr>\n";
		echo "<input type='hidden' name='next_agent_call' value='random'>";

		echo "<tr bgcolor=#$SSalt_row1_background><td align=right>"._QXZ("Queue Priority").": </td><td align=left><select size=1 name=queue_priority>\n";
		$n=99;
		while ($n>=-99)
			{
			$dtl = 'Even';
			if ($n<0) {$dtl = 'Lower';}
			if ($n>0) {$dtl = 'Higher';}
			if ($n == $queue_priority) 
				{echo "<option SELECTED value=\"$n\">$n - "._QXZ("$dtl")."</option>\n";}
			else
				{echo "<option value=\"$n\">$n - "._QXZ("$dtl")."</option>\n";}
			$n--;
			}
		echo "</select> $NWB#inbound_groups-queue_priority$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Fronter Display").": </td><td align=left><select size=1 name=fronter_display><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option SELECTED value='$fronter_display'>"._QXZ("$fronter_display")."</option></select>$NWB#inbound_groups-fronter_display$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right></td><td align=left><input type=hidden name=browser_alert_sound value=\"$browser_alert_sound\"><input type=hidden name=browser_alert_volume value=\"$browser_alert_volume\"></td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group Handling").": </td><td align=left><select size=1 name=group_handling><option  value='PHONE'>"._QXZ("PHONE")."</option>";
		echo "<option selected value='CHAT'>"._QXZ("CHAT")."</option>";
		if ($SSallow_emails > 0)
			{
			if ($SSallow_emails>0) {echo "<option value='EMAIL'>"._QXZ("EMAIL")."</option>";}			
			}
		echo "</select>$NWB#inbound_groups-group_handling$NWE</td></tr>\n";

		##### get status group listings for dynamic pulldown menu
		$stmt="SELECT status_group_id,status_group_notes from vicidial_status_groups $whereLOGadmin_viewable_groupsSQL order by status_group_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$status_groups_to_print = mysqli_num_rows($rslt);
		$status_groups_menu='';
		$status_groups_selected=0;
		$o=0;
		while ($status_groups_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$status_groups_menu .= "<option ";
			if ($status_group_id == "$rowx[0]") 
				{
				$status_groups_menu .= "SELECTED ";
				$status_groups_selected++;
				}
			$status_groups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		$sglinkB='';   $sglinkE='';
		if (strlen($status_group_id)>1)
			{
			$sglinkB="<a href=\"$PHP_SELF?ADD=393111111111&status_group_id=$status_group_id\">";
			$sglinkE='</a>';
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>$sglinkB"._QXZ("Status Group Override")."$sglinkE: </td><td align=left><select size=1 name=status_group_id>";
		echo "<option value=\"\">"._QXZ("NONE")."</option>";
		echo "$status_groups_menu";
		echo "</select>$NWB#inbound_groups-status_group_id$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("In-Group Recording Override").": </td><td align=left><select size=1 name=ingroup_recording_override><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='NEVER'>"._QXZ("NEVER")."</option><option value='ONDEMAND'>"._QXZ("ONDEMAND")."</option><option value='ALLCALLS'>"._QXZ("ALLCALLS")."</option><option value='ALLFORCE'>"._QXZ("ALLFORCE")."</option><option value='$ingroup_recording_override' SELECTED>"._QXZ("$ingroup_recording_override")."</option></select>$NWB#inbound_groups-ingroup_recording_override$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("In-Group Recording Filename").": </td><td align=left><input type=text name=ingroup_rec_filename size=50 maxlength=50 value=\"$ingroup_rec_filename\">$NWB#inbound_groups-ingroup_rec_filename$NWE</td></tr>\n";

/* Commenting this out because it is handled by the Email Account section and is redundant here
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>In-Group Call Handle Method: </td><td align=left><select size=1 name=call_handle_method><option>CID</option><option>CIDLOOKUP</option><option>CIDLOOKUPRL</option><option>CIDLOOKUPRC</option><option>CIDLOOKUPALT</option><option>CIDLOOKUPRLALT</option><option>CIDLOOKUPRCALT</option><option>CIDLOOKUPADDR3</option><option>CIDLOOKUPRLADDR3</option><option>CIDLOOKUPRCADDR3</option><option>CIDLOOKUPALTADDR3</option><option>CIDLOOKUPRLALTADDR3</option><option>CIDLOOKUPRCALTADDR3</option><option>ANI</option><option>ANILOOKUP</option><option>ANILOOKUPRL</option><option>VIDPROMPT</option><option>VIDPROMPTLOOKUP</option><option>VIDPROMPTLOOKUPRL</option><option>VIDPROMPTLOOKUPRC</option><option>CLOSER</option><option>3DIGITID</option><option>4DIGITID</option><option>5DIGITID</option><option>10DIGITID</option><option SELECTED>$call_handle_method</option></select>$NWB#inbound_dids-call_handle_method$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>In-Group Agent Search Method: </td><td align=left><select size=1 name=agent_search_method><option value=\"LB\">LB - Load Balanced</option><option value=\"LO\">LO - Load Balanced Overflow</option><option value=\"SO\">SO - Server Only</option><option SELECTED>$agent_search_method</option></select>$NWB#inbound_dids-agent_search_method$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>In-Group List ID: </td><td align=left><input type=text name=list_id size=14 maxlength=14 value=\"$list_id\">$NWB#inbound_dids-list_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>In-Group Campaign ID: </td><td align=left><select size=1 name=campaign_id>\n";
		echo "$campaigns_list";
		echo "<option SELECTED>$campaign_id</option>\n";
		echo "</select>$NWB#inbound_dids-campaign_id$NWE</td></tr>\n";
*/


		if ($start_call_url == 'ALT')
			{
			$stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$group_id' and entry_type='ingroup' and url_type='start';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$vum_to_print = mysqli_num_rows($rslt);
			if ($vum_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$vum_count = $rowx[0]; 
				}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"admin_url_multi.php?DB=$DB&campaign_id=$group_id&entry_type=ingroup&url_type=start\">"._QXZ("Start Chat URL")."</a>: </td><td align=left><input type=text name=start_call_url size=10 maxlength=2000 value=\"$start_call_url\">$NWB#inbound_groups-start_call_url$NWE <a href=\"admin_url_multi.php?DB=$DB&campaign_id=$group_id&entry_type=ingroup&url_type=start\"> "._QXZ("Alternate Start URLs Defined").": $vum_count</a></td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Start Chat URL").": </td><td align=left><input type=text name=start_call_url size=70 maxlength=5000 value=\"$start_call_url\">$NWB#inbound_groups-start_chat_url$NWE</td></tr>\n";
			}

		if ($dispo_call_url == 'ALT')
			{
			$stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$group_id' and entry_type='ingroup' and url_type='dispo';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$vum_to_print = mysqli_num_rows($rslt);
			if ($vum_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$vum_count = $rowx[0]; 
				}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"admin_url_multi.php?DB=$DB&campaign_id=$group_id&entry_type=ingroup&url_type=dispo\">"._QXZ("Dispo Chat URL")."</a>: </td><td align=left><input type=text name=dispo_call_url size=10 maxlength=2000 value=\"$dispo_call_url\">$NWB#inbound_groups-dispo_call_url$NWE <a href=\"admin_url_multi.php?DB=$DB&campaign_id=$group_id&entry_type=ingroup&url_type=dispo\"> "._QXZ("Alternate Dispo URLs Defined").": $vum_count</a></td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Dispo Chat URL").": </td><td align=left><input type=text name=dispo_call_url size=70 maxlength=5000 value=\"$dispo_call_url\">$NWB#inbound_groups-dispo_chat_url$NWE</td></tr>\n";
			}

		if ($na_call_url == 'ALT')
			{
			$stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$group_id' and entry_type='ingroup' and url_type='noagent';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$vum_to_print = mysqli_num_rows($rslt);
			if ($vum_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$vum_count = $rowx[0]; 
				}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"admin_url_multi.php?DB=$DB&campaign_id=$group_id&entry_type=ingroup&url_type=noagent\">"._QXZ("No Agent Chat URL")."</a>: </td><td align=left><input type=text name=na_call_url size=10 maxlength=5000 value=\"$na_call_url\">$NWB#inbound_groups-na_chat_url$NWE <a href=\"admin_url_multi.php?DB=$DB&campaign_id=$group_id&entry_type=ingroup&url_type=noagent\"> "._QXZ("Alternate No Agent URLs Defined").": $vum_count</a></td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("No Agent Chat URL").": </td><td align=left><input type=text name=na_call_url size=70 maxlength=5000 value=\"$na_call_url\">$NWB#inbound_groups-na_chat_url$NWE</td></tr>\n";
			}

		# get count of talk seconds urls in this In-Group
		$stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$group_id' and entry_type='ingroup' and url_type='talk';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$vum_to_print = mysqli_num_rows($rslt);
		if ($vum_to_print > 0) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$vum_count = $rowx[0]; 
			}
		# check if this In-Group has talk seconds url set to -FORCEDISABLE-
		$force_disableHTML='';
		$stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$group_id' and entry_type='ingroup' and url_type='talk' and active='N' and url_address LIKE \"%FORCEDISABLE%\";";
		$rslt=mysql_to_mysqli($stmt, $link);
		$fdtsu_to_print = mysqli_num_rows($rslt);
		if ($fdtsu_to_print > 0) 
			{
			$rowx=mysqli_fetch_row($rslt);
			if ($rowx[0] > 0)
				{$force_disableHTML="<font color='red'><b>FORCED DISABLE</b></font>";}
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"admin_url_multi.php?DB=$DB&campaign_id=$group_id&entry_type=ingroup&url_type=talk\">"._QXZ("Talk Seconds URLs")."</a>: </td><td align=left>$NWB#inbound_groups-talk_sec_url$NWE <a href=\"admin_url_multi.php?DB=$DB&campaign_id=$group_id&entry_type=ingroup&url_type=talk\"> "._QXZ("Talk Seconds URLs Defined").": $vum_count</a> &nbsp; $force_disableHTML</td></tr>\n";

/*
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>Extension Append CID: </td><td align=left><select size=1 name=extension_appended_cidname><option>"._QXZ("Y")."</option><option>N</option><option SELECTED>$extension_appended_cidname</option></select>$NWB#inbound_groups-extension_appended_cidname$NWE</td></tr>\n";
*/
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Uniqueid Status Display").": </td><td align=left><select size=1 name=uniqueid_status_display><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='ENABLED'>"._QXZ("ENABLED")."</option><option value='ENABLED_PREFIX'>"._QXZ("ENABLED_PREFIX")."</option><option value='ENABLED_PRESERVE'>"._QXZ("ENABLED_PRESERVE")."</option><option SELECTED value='$uniqueid_status_display'>"._QXZ("$uniqueid_status_display")."</option></select>$NWB#inbound_groups-uniqueid_status_display$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Uniqueid Status Prefix").": </td><td align=left><input type=text name=uniqueid_status_prefix size=10 maxlength=50 value=\"$uniqueid_status_prefix\">$NWB#inbound_groups-uniqueid_status_prefix$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=382111111111&colors_id=$customer_chat_screen_colors\"><font color=black>"._QXZ("Customer Chat Screen Colors")."</font></a>: </td><td align=left><select size=1 name=customer_chat_screen_colors><option value=\"default\">"._QXZ("default")."</option>\n";
		$stmt="SELECT colors_id,colors_name from vicidial_screen_colors where active='Y' $LOGadmin_viewable_groupsSQL order by colors_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$colors_to_print = mysqli_num_rows($rslt);
		$colors_list='';
		$o=0;
		while ($colors_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$colors_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		echo "$colors_list";
		echo "<option SELECTED>$customer_chat_screen_colors</option></select>$NWB#inbound_groups-customer_chat_screen_colors$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Customer Chat Survey Link").": </td><td align=left><input type=text name=customer_chat_survey_link size=70 maxlength=5000 value=\"$customer_chat_survey_link\">$NWB#inbound_groups-customer_chat_survey_link$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Customer Chat Survey Text").": </td><td align=left><input type=text name=customer_chat_survey_text size=65 maxlength=5000 value=\"$customer_chat_survey_text\">$NWB#inbound_groups-customer_chat_survey_text$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Customer Chat Link").": </td><td align=left><a href='../chat_customer/customer_chat_code.php?group_id=$group_id'>"._QXZ("First Link")."</a> &nbsp; <a href='../chat_customer/vicidial_chat_customer_side.php?group_id=$group_id'>"._QXZ("Second Link")."</a> $NWB#inbound_groups-customer_chat_link$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Custom 1").": </td><td align=left><input type=text name=custom_one id=custom_one size=40 maxlength=2000 value=\"$custom_one\"> $NWB#inbound_groups-custom_fields$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Custom 2").": </td><td align=left><input type=text name=custom_two id=custom_two size=40 maxlength=2000 value=\"$custom_two\"> $NWB#inbound_groups-custom_fields$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Custom 3").": </td><td align=left><input type=text name=custom_three id=custom_three size=40 maxlength=2000 value=\"$custom_three\"> $NWB#inbound_groups-custom_fields$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Custom 4").": </td><td align=left><input type=text name=custom_four id=custom_four size=40 maxlength=2000 value=\"$custom_four\"> $NWB#inbound_groups-custom_fields$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Custom 5").": </td><td align=left><input type=text name=custom_five id=custom_five size=40 maxlength=2000 value=\"$custom_five\"> $NWB#inbound_groups-custom_fields$NWE</td></tr>\n";

		echo "<input type=hidden name=form_end value=\"END\">\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";

		if ($SSqc_features_active > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2> &nbsp; </td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2> "._QXZ("Inbound Group QC Settings").": </td></tr>\n";

			##### get status listings for dynamic pulldown
			$qc_statuses = preg_replace("/^ | -$/","",$qc_statuses);
			$QCstatuses = explode(" ", $qc_statuses);
			$QCs_to_print = (count($QCstatuses) -0);
			$stmt="SELECT status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable,scheduled_callback from vicidial_statuses where status NOT IN('QUEUE','INCALL') order by status";
			$rslt=mysql_to_mysqli($stmt, $link);
			$statuses_to_print = mysqli_num_rows($rslt);
			$qc_statuses_list='';

			$o=0;
			while ($statuses_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$qc_statuses_list .= "<input type=\"checkbox\" name=\"qc_statuses[]\" value=\"$rowx[0]\"";
				$p=0;
				while ($p < $QCs_to_print)
					{
					if ($rowx[0] === $QCstatuses[$p]) 
						{
						$qc_statuses_list .= " CHECKED";
						}
					$p++;
					}
				$qc_statuses_list .= "> $rowx[0] - $rowx[1]<BR>\n";

				$o++;
				}

			$stmt="SELECT distinct(status),status_name from vicidial_campaign_statuses $whereLOGallowed_campaignsSQL order by status;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$Cstatuses_to_print = mysqli_num_rows($rslt);

			$o=0;
			while ($Cstatuses_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				if (!preg_match("/\"$rowx[0]\"/",$qc_statuses_list))
					{
					$qc_statuses_list .= "<input type=\"checkbox\" name=\"qc_statuses[]\" value=\"$rowx[0]\"";
					$p=0;
					while ($p < $QCs_to_print)
						{
						if ($rowx[0] === $QCstatuses[$p]) 
							{
							$qc_statuses_list .= " CHECKED";
							}
						$p++;
						}
					$qc_statuses_list .= "> $rowx[0] - $rowx[1]<BR>\n";
					}
				$o++;
				}

			##### get scripts listings for pulldown
			$stmt="SELECT script_id,script_name from vicidial_scripts $whereLOGadmin_viewable_groupsSQL order by script_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$scripts_to_print = mysqli_num_rows($rslt);
			$QCscripts_list="";
			$o=0;
			while ($scripts_to_print > $o)
				{
				$rowx=mysqli_fetch_row($rslt);
				$QCscripts_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$scriptname_list["$rowx[0]"] = "$rowx[1]";
				$o++;
				}
			##### get shifts listings for pulldown
			$stmt="SELECT shift_id,shift_name from vicidial_shifts $whereLOGadmin_viewable_groupsSQL order by shift_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$shifts_to_print = mysqli_num_rows($rslt);
			$QCshifts_list="";
			$o=0;
			while ($shifts_to_print > $o)
				{
				$rowx=mysqli_fetch_row($rslt);
				$QCshifts_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$shiftname_list["$rowx[0]"] = "$rowx[1]";
				$o++;
				}

			echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("QC Enabled").": </td><td><select size=1 name=qc_enabled><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value=\"$qc_enabled\" SELECTED>"._QXZ("$qc_enabled")."</option></select> $NWB#inbound_groups-qc_enabled$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("QC Statuses").": <BR> $NWB#inbound_groups-qc_statuses$NWE</td><td>$qc_statuses_list</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("QC WebForm").": </td><td align=left><input type=text name=qc_web_form_address size=70 maxlength=255 value=\"$qc_web_form_address\">$NWB#inbound_groups-qc_web_form_address$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row2_background><td align=right><a href=\"$PHP_SELF?ADD=3111111&script_id=$script_id\">"._QXZ("QC Script")."</a>: </td><td align=left><select size=1 name=qc_script>\n";
			echo "$QCscripts_list";
			echo "<option selected value=\"$qc_script\">$qc_script - $scriptname_list[$qc_script]</option>\n";
			echo "</select>$NWB#inbound_groups-qc_script$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row2_background><td align=right><a href=\"$PHP_SELF?ADD=331111111&shift_id=$qc_shift_id\">"._QXZ("QC Shift")."</a>: </td><td align=left><select size=1 name=qc_shift_id>\n";
			echo "$QCshifts_list";
			echo "<option selected value=\"$qc_shift_id\">$qc_shift_id - $shiftname_list[$qc_shift_id]</option>\n";
			echo "</select>$NWB#inbound_groups-qc_shift_id$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("QC Get Record Launch").": </td><td><select size=1 name=qc_get_record_launch><option value='NONE'>"._QXZ("NONE")."</option><option value='SCRIPT'>"._QXZ("SCRIPT")."</option><option value='WEBFORM'>"._QXZ("WEBFORM")."</option><option value='QCSCRIPT'>"._QXZ("QCSCRIPT")."</option><option value='QCWEBFORM'>"._QXZ("QCWEBFORM")."</option><option value='$qc_get_record_launch' SELECTED>"._QXZ("$qc_get_record_launch")."</option></select> $NWB#inbound_groups-qc_get_record_launch$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("QC Show Recording").": </td><td><select size=1 name=qc_show_recording><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$qc_show_recording' SELECTED>"._QXZ("$qc_show_recording")."</option></select> $NWB#inbound_groups-qc_show_recording$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row2_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'></td></tr>\n";
			}

		echo "</table>\n";
		echo "<BR></center><BR><BR>\n";


		### list of agent rank or skill-level for this inbound group
		echo "<center><a name=\"agent_ranks\">\n";
		echo "<br><b>"._QXZ("AGENT RANKS FOR THIS INBOUND GROUP").":</b><br>\n";
		echo "<TABLE width=800 cellspacing=3>\n";
		echo "<tr><td>"._QXZ("USER")."</td><td>"._QXZ("GROUP")."</td><td>"._QXZ("SELECTED")."</td><td> &nbsp; "._QXZ("RANK")." &nbsp; </td><td> &nbsp; "._QXZ("GRADE")." &nbsp; </td><td> "._QXZ("DAILY LIMIT")." </td><td> "._QXZ("CALLS TODAY")." </td></tr>\n";

		$stmt="SELECT user,full_name,closer_campaigns,user_group from vicidial_users where active='Y' $LOGadmin_viewable_groupsSQL order by user;";
		$rsltx=mysql_to_mysqli($stmt, $link);
		$users_to_print = mysqli_num_rows($rsltx);

		$o=0;
		while ($users_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rsltx);
			$o++;

			$ARIG_user[$o] =	$rowx[0];
			$ARIG_name[$o] =	$rowx[1];
			$ARIG_close[$o] =	$rowx[2];
			$ARIG_group[$o] =	(preg_match('/\-\-ALL\-\-/', $rowx[3]) ? _QXZ("$rowx[3]") : $rowx[3]);
			$ARIG_check[$o] =	'';
			if (preg_match("/ $group_id /",$ARIG_close[$o]))
				{$ARIG_check[$o] = ' CHECKED';}
			}

		$o=0;
		$ARIG_changenotes='';
		$stmtDlog='';
		while ($users_to_print > $o) 
			{
			$o++;
			$stmt="SELECT group_rank,calls_today,group_grade,daily_limit from vicidial_inbound_group_agents where group_id='$group_id' and user='$ARIG_user[$o]';";
			$rsltx=mysql_to_mysqli($stmt, $link);
			$viga_to_print = mysqli_num_rows($rsltx);
			if ($viga_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rsltx);
				$ARIG_rank[$o] =	$rowx[0];
				$ARIG_calls[$o] =	$rowx[1];
				$ARIG_grade[$o] =	$rowx[2];
				$ARIG_limit[$o] =	$rowx[3];
				}
			else
				{
				$stmtD="INSERT INTO vicidial_inbound_group_agents set calls_today='0',group_rank='0',group_weight='0',user='$ARIG_user[$o]',group_id='$group_id',group_grade='1',group_type='E';";
				$rslt=mysql_to_mysqli($stmtD, $link);
				$affected_rows_grp = mysqli_affected_rows($link);
				if ($DB > 0) {echo "$affected_rows_grp|$stmtD|";}
				$stmtDlog .= "$stmtD|";
				$ARIG_changenotes .= "added missing user to viga table $ARIG_user[$o]|";
				$ARIG_rank[$o] =	'0';
				$ARIG_calls[$o] =	'0';
				$ARIG_grade[$o] =	'1';
				$ARIG_limit[$o] =	'-1';
				}
			}
		if (strlen($ARIG_changenotes) > 10)
			{
			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$stmtDlog|";
			$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='INGROUPS', event_type='MODIFY', record_id='$group_id', event_code='USER INGROUP VIGA ADD', event_sql=\"$SQL_log\", event_notes='$ARIG_changenotes';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}


		if ( ($stage=='SUBMIT') or ($stage==_QXZ("SUBMIT")) )
			{
			$o=0;
			while ($users_to_print > $o) 
				{
				$o++;

				$ARIG_checked='';
				$ARIG_ranked='';
				$ARIG_graded='';
				$ARIG_limited='';

				$checkbox_field="CHECK_$ARIG_user[$o]$US$group_id";
				$rank_field="RANK_$ARIG_user[$o]$US$group_id";
				$grade_field="GRADE_$ARIG_user[$o]$US$group_id";
				$limit_field="LIMIT_$ARIG_user[$o]$US$group_id";

				if (isset($_GET["$checkbox_field"]))			{$ARIG_checked=$_GET["$checkbox_field"];}
					elseif (isset($_POST["$checkbox_field"]))	{$ARIG_checked=$_POST["$checkbox_field"];}
				if (isset($_GET["$rank_field"]))			{$ARIG_ranked=$_GET["$rank_field"];}
					elseif (isset($_POST["$rank_field"]))	{$ARIG_ranked=$_POST["$rank_field"];}
				if (isset($_GET["$grade_field"]))			{$ARIG_graded=$_GET["$grade_field"];}
					elseif (isset($_POST["$grade_field"]))	{$ARIG_graded=$_POST["$grade_field"];}
				if (isset($_GET["$limit_field"]))			{$ARIG_limited=$_GET["$limit_field"];}
					elseif (isset($_POST["$limit_field"]))	{$ARIG_limited=$_POST["$limit_field"];}
				$ARIG_checked = preg_replace('/[^A-Z]/','',$ARIG_checked);
				$ARIG_ranked = preg_replace('/[^-0-9]/','',$ARIG_ranked);
				$ARIG_graded = preg_replace('/[^-0-9]/','',$ARIG_graded);
				$ARIG_limited = preg_replace('/[^-0-9]/','',$ARIG_limited);

				$stmtA='';
				$stmtB='';
				$stmtC='';
				$stmtD='';
				$stmtE='';
				$ARIG_updated=0;
				$ARIG_changenotes='';
				if ( ($ARIG_check[$o]=='') and ($ARIG_checked=='YES') )
					{
					if (strlen($ARIG_close[$o]) < 4) {$ARIG_close[$o]=' - ';}
					$stmtA="UPDATE vicidial_users set closer_campaigns=' $group_id$ARIG_close[$o]' where user='$ARIG_user[$o]';";
					$rslt=mysql_to_mysqli($stmtA, $link);
					if ($DB > 0) {echo "|$stmtA|";}
					$ARIG_updated++;
					$ARIG_changenotes .= "added $group_id to selected in-groups|";
					}
				if ( ($ARIG_check[$o]==' CHECKED') and ($ARIG_checked=='') )
					{
					$ARIG_close[$o] = preg_replace("/ $group_id /",' ',$ARIG_close[$o]);
					$stmtB="UPDATE vicidial_users set closer_campaigns='$ARIG_close[$o]' where user='$ARIG_user[$o]';";
					$rslt=mysql_to_mysqli($stmtB, $link);
					if ($DB > 0) {echo "|$stmtB|";}
					$ARIG_updated++;
					$ARIG_changenotes .= "removed $group_id from selected in-groups|";
					}
				if ( ($ARIG_ranked < $ARIG_rank[$o]) or ($ARIG_ranked > $ARIG_rank[$o]) )
					{
					$stmtC="UPDATE vicidial_inbound_group_agents set group_rank='$ARIG_ranked',group_weight='$ARIG_ranked' where user='$ARIG_user[$o]' and group_id='$group_id';";
					$rslt=mysql_to_mysqli($stmtC, $link);
					if ($DB > 0) {echo "|$stmtC|";}
					$ARIG_updated++;
					$ARIG_changenotes .= "changed rank from $ARIG_rank[$o] to $ARIG_ranked|";
					}
				if ( ($ARIG_graded < $ARIG_grade[$o]) or ($ARIG_graded > $ARIG_grade[$o]) )
					{
					$stmtD="UPDATE vicidial_inbound_group_agents set group_grade='$ARIG_graded' where user='$ARIG_user[$o]' and group_id='$group_id';";
					$rslt=mysql_to_mysqli($stmtD, $link);
					if ($DB > 0) {echo "|$stmtD|";}
					$ARIG_updated++;
					$ARIG_changenotes .= "changed grade from $ARIG_grade[$o] to $ARIG_graded|";
					}
				if ( ($ARIG_limited < $ARIG_limit[$o]) or ($ARIG_limited > $ARIG_limit[$o]) )
					{
					$stmtE="UPDATE vicidial_inbound_group_agents set daily_limit='$ARIG_limited' where user='$ARIG_user[$o]' and group_id='$group_id';";
					$rslt=mysql_to_mysqli($stmtE, $link);
					if ($DB > 0) {echo "|$stmtE|";}
					$ARIG_updated++;
					$ARIG_changenotes .= "changed limit from $ARIG_limit[$o] to $ARIG_limited|";
					}
				if ($ARIG_updated > 0)
					{
					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$stmtA|$stmtB|$stmtC|$stmtD|$stmtE|";
					$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='$ARIG_user[$o]', event_code='USER INGROUP SETTINGS', event_sql=\"$SQL_log\", event_notes='$ARIG_changenotes';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}

			$stmt="SELECT vu.user,viga.group_rank,calls_today,full_name,closer_campaigns,viga.group_grade,viga.daily_limit from vicidial_inbound_group_agents viga, vicidial_users vu where group_id='$group_id' and active='Y' and vu.user=viga.user $LOGadmin_viewable_groupsSQL order by vu.user;";
			$rsltx=mysql_to_mysqli($stmt, $link);
			$users_to_print = mysqli_num_rows($rsltx);

			$o=0;
			while ($users_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rsltx);
				$o++;

				$ARIG_user[$o] =	$rowx[0];
				$ARIG_rank[$o] =	$rowx[1];
				$ARIG_calls[$o] =	$rowx[2];
				$ARIG_name[$o] =	$rowx[3];
				$ARIG_close[$o] =	$rowx[4];
				$ARIG_grade[$o] =	$rowx[5];
				$ARIG_limit[$o] =	$rowx[6];
				$ARIG_check[$o] =	'';
				if (preg_match("/ $group_id /",$ARIG_close[$o]))
					{$ARIG_check[$o] = ' CHECKED';}
				}
			}

		$checkbox_count=0;
		$o=0;
		while ($users_to_print > $o) 
			{
			$o++;

			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

			$checkbox_field="CHECK_$ARIG_user[$o]$US$group_id";
			$rank_field="RANK_$ARIG_user[$o]$US$group_id";
			$grade_field="GRADE_$ARIG_user[$o]$US$group_id";
			$limit_field="LIMIT_$ARIG_user[$o]$US$group_id";
			$checkbox_list .= "|$checkbox_field";
			$checkbox_count++;

			$users_output .= "<tr $bgcolor><td><font size=1><a href=\"$PHP_SELF?ADD=3&user=$ARIG_user[$o]\">$ARIG_user[$o]</a> - $ARIG_name[$o]</td>\n";
			$users_output .= "<td><font size=1>$ARIG_group[$o]</td>\n";
			$users_output .= "<td><input type=checkbox name=\"$checkbox_field\" id=\"$checkbox_field\" value=\"YES\"$ARIG_check[$o]></td>\n";
			$users_output .= "<td><select size=1 name=$rank_field>\n";
			$h="9";
			while ($h>=-9)
				{
				$users_output .= "<option value=\"$h\"";
				if ($h==$ARIG_rank[$o])
					{$users_output .= " SELECTED";}
				$users_output .= ">$h</option>";
				$h--;
				}
			$users_output .= "</select></td>\n";
			$users_output .= "<td><select size=1 name=$grade_field>\n";
			$h="10";
			while ($h>=1)
				{
				$users_output .= "<option value=\"$h\"";
				if ($h==$ARIG_grade[$o])
					{$users_output .= " SELECTED";}
				$users_output .= ">$h</option>";
				$h--;
				}
			$users_output .= "</select></td>\n";
			$users_output .= "<td><input type=text name=$limit_field size=5 maxlength=4 value=\"$ARIG_limit[$o]\"></td>\n";
			$users_output .= "<td><font size=1>$ARIG_calls[$o]</td></tr>\n";
			}
		echo "<tr><td><font size=1> &nbsp; </font></td><td><font size=1> &nbsp; </font></td><td align=left><span id=IGU_selectlink><a href=\"#\" onclick=\"FORM_selectall('$checkbox_count','$checkbox_list','on','IGU_selectlink');return false;\"><font size=1>"._QXZ("select all")."</font></a></span></td><td colspan=2><font size=1> &nbsp; </font></td></tr>\n";

		echo "$users_output";

		echo "<tr><td align=center colspan=4><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'></td></tr>\n";

		echo "</table></center><br></FORM>\n";

		echo "<a href=\"./AST_CLOSERstats.php?group[]=$group_id\">"._QXZ("Click here to see a report for this inbound group")."</a><BR><BR>\n";

		echo "<a href=\"./AST_VICIDIAL_ingrouplist.php?group=$group_id\">"._QXZ("Click here to see agents logged in to this inbound group")."</a><BR><BR>\n";

		echo "<center><b>\n";

		echo "<B>"._QXZ("CAMPAIGNS ALLOWING THIS CHAT GROUP").":</B><BR>\n";
		echo "<TABLE>\n";

		$SQL_group_id = preg_replace("/_/",'\\_',$group_id);
		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where closer_campaigns LIKE \"% $SQL_group_id %\" $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campin_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($campin_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=31&campaign_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE>\n";

		if ($LOGdelete_ingroups > 0)
			{
		#	echo "<br><br><a href=\"$PHP_SELF?ADD=53&campaign_id=$group_id&stage=IN\">EMERGENCY VDAC CLEAR FOR THIS IN-GROUP</a><BR><BR>\n";
			echo "<br><br><a href=\"$PHP_SELF?ADD=5111&group_id=$group_id&group_handling=$group_handling\">"._QXZ("DELETE THIS IN-GROUP")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=INGROUPS&stage=$group_id\">"._QXZ("Click here to see Admin changes to this In-Group")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}

	}


######################
# ADD=3311 modify did info in the system
######################
if ($ADD==3311)
	{
	if ($LOGmodify_dids==1)
		{
		### check for system DID filter, create if does not exist
		if ($did_id == 'did_system_filter')
			{
			$did_pattern = 'did_system_filter';
			$stmt="SELECT did_id from vicidial_inbound_dids where did_pattern='did_system_filter';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$rows_to_print = mysqli_num_rows($rslt);
			if ($rows_to_print > 0)
				{
				$row=mysqli_fetch_row($rslt);
				$did_id = $row[0];
				}
			else
				{
				$stmtA="INSERT INTO vicidial_inbound_dids (did_pattern,did_description,user_group,filter_phone_group_id,pre_filter_phone_group_id) values('did_system_filter','DID System Filter','---ALL---','','');";
				$rslt=mysql_to_mysqli($stmtA, $link);

				$stmt="SELECT did_id from vicidial_inbound_dids where did_pattern='did_system_filter';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				$did_id = $row[0];
				}
			}

		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=3311&did_id=$did_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$didSQL = "did_id='$did_id'";
		if ( (strlen($did_id)<1) and (strlen($did_pattern)>0) )
			{$didSQL = "did_pattern='$did_pattern'";}
		$stmt="SELECT did_id,did_pattern,did_description,did_active,did_route,extension,exten_context,voicemail_ext,phone,server_ip,user,user_unavailable_action,user_route_settings_ingroup,group_id,call_handle_method,agent_search_method,list_id,campaign_id,phone_code,menu_id,record_call,filter_inbound_number,filter_phone_group_id,filter_url,filter_action,filter_extension,filter_exten_context,filter_voicemail_ext,filter_phone,filter_server_ip,filter_user,filter_user_unavailable_action,filter_user_route_settings_ingroup,filter_group_id,filter_call_handle_method,filter_agent_search_method,filter_list_id,filter_campaign_id,filter_phone_code,filter_menu_id,filter_clean_cid_number,custom_one,custom_two,custom_three,custom_four,custom_five,user_group,filter_dnc_campaign,filter_url_did_redirect,no_agent_ingroup_redirect,no_agent_ingroup_id,no_agent_ingroup_extension,pre_filter_phone_group_id,pre_filter_extension,entry_list_id,filter_entry_list_id,max_queue_ingroup_calls,max_queue_ingroup_id,max_queue_ingroup_extension,did_carrier_description,inbound_route_answer,pre_filter_recent_call,pre_filter_recent_extension from vicidial_inbound_dids where $didSQL $LOGadmin_viewable_groupsSQL;";
		if ($DB) {echo "$stmt\n";}
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if (strlen($row[0])>0)
			{$did_id = 			$row[0];}
		if (strlen($row[1])>0)
			{$did_pattern = 	$row[1];}
		$did_description = 		$row[2];
		$did_active = 			$row[3];
		$did_route = 			$row[4];
		$extension = 			$row[5];
		$exten_context = 		$row[6];
		$voicemail_ext = 		$row[7];
		$phone = 				$row[8];
		$server_ip = 			$row[9];
		$user = 				$row[10];
		$user_unavailable_action = 	$row[11];
		$user_route_settings_ingroup = 	$row[12];
		$group_id = 			$row[13];
		$call_handle_method = 	$row[14];
		$agent_search_method =	$row[15];
		$list_id = 				$row[16];
		$campaign_id = 			$row[17];
		$phone_code = 			$row[18];
		$menu_id =				$row[19];
		$record_call =			$row[20];
		$filter_inbound_number = $row[21];
		$filter_phone_group_id = $row[22];
		$filter_url =			$row[23];
		$filter_action =		$row[24];
		$filter_extension =		$row[25];
		$filter_exten_context = $row[26];
		$filter_voicemail_ext = $row[27];
		$filter_phone =			$row[28];
		$filter_server_ip =		$row[29];
		$filter_user =			$row[30];
		$filter_user_unavailable_action = $row[31];
		$filter_user_route_settings_ingroup = $row[32];
		$filter_group_id =		$row[33];
		$filter_call_handle_method = $row[34];
		$filter_agent_search_method = $row[35];
		$filter_list_id =		$row[36];
		$filter_campaign_id =	$row[37];
		$filter_phone_code =	$row[38];
		$filter_menu_id =		$row[39];
		$filter_clean_cid_number = $row[40];
		$custom_one =			$row[41];
		$custom_two =			$row[42];
		$custom_three =			$row[43];
		$custom_four =			$row[44];
		$custom_five =			$row[45];
		$user_group =			$row[46];
		$filter_dnc_campaign =	$row[47];
		$filter_url_did_redirect = $row[48];
		$no_agent_ingroup_redirect = $row[49];
		$no_agent_ingroup_id =	$row[50];
		$no_agent_ingroup_extension = $row[51];
		$pre_filter_phone_group_id = $row[52];
		$pre_filter_extension = $row[53];
		$entry_list_id = $row[54];
		$filter_entry_list_id = $row[55];
		$max_queue_ingroup_calls = $row[56];
		$max_queue_ingroup_id = $row[57];
		$max_queue_ingroup_extension = $row[58];
		$did_carrier_description = $row[59];
		$inbound_route_answer =	$row[60];
		$pre_filter_recent_call =	$row[61];
		$pre_filter_recent_extension =	$row[62];

		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campaigns_to_print = mysqli_num_rows($rslt);
		$campaigns_list='';
		$o=0;
		while ($campaigns_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$campaigns_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}

		##### get in-groups listings for dynamic pulldown
		$stmt="SELECT group_id,group_name from vicidial_inbound_groups $whereLOGadmin_viewable_groupsSQL order by group_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$Xgroups_to_print = mysqli_num_rows($rslt);
		$Xgroups_menu='';
		$Xgroups_selected=0;
		$FXgroups_menu='';
		$FXgroups_selected=0;
		$o=0;
		while ($Xgroups_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$Xgroups_menu .= "<option ";
			$FXgroups_menu .= "<option ";
			if ($user_route_settings_ingroup == "$rowx[0]") 
				{
				$Xgroups_menu .= "SELECTED ";
				$Xgroups_selected++;
				}
			if ($filter_user_route_settings_ingroup == "$rowx[0]") 
				{
				$FXgroups_menu .= "SELECTED ";
				$FXgroups_selected++;
				}
			$Xgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$FXgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		if ($Xgroups_selected < 1) 
			{$Xgroups_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		else 
			{$Xgroups_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		if ($FXgroups_selected < 1) 
			{$FXgroups_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		else 
			{$FXgroups_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}


		##### get in-groups listings for dynamic pulldown
		$stmt="SELECT group_id,group_name from vicidial_inbound_groups where group_id NOT IN('AGENTDIRECT') $LOGadmin_viewable_groupsSQL order by group_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$Dgroups_to_print = mysqli_num_rows($rslt);
		$Dgroups_menu='';
		$Dgroups_selected=0;
		$FDgroups_menu='';
		$FDgroups_selected=0;
		$PFDgroups_menu='';
		$PFDgroups_selected=0;
		$MQIgroups_menu='';
		$MQIgroups_selected=0;
		$o=0;
		while ($Dgroups_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$Dgroups_menu .= "<option ";
			$FDgroups_menu .= "<option ";
			$PFDgroups_menu .= "<option ";
			$MQIgroups_menu .= "<option ";
			if ($group_id == "$rowx[0]") 
				{
				$Dgroups_menu .= "SELECTED ";
				$Dgroups_selected++;
				}
			if ($filter_group_id == "$rowx[0]") 
				{
				$FDgroups_menu .= "SELECTED ";
				$FDgroups_selected++;
				}
			if ($no_agent_ingroup_id == "$rowx[0]") 
				{
				$PFDgroups_menu .= "SELECTED ";
				$PFDgroups_selected++;
				}
			if ($max_queue_ingroup_id == "$rowx[0]") 
				{
				$MQIgroups_menu .= "SELECTED ";
				$MQIgroups_selected++;
				}
			$Dgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$FDgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$PFDgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$MQIgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		if ($Dgroups_selected < 1) 
			{$Dgroups_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		else 
			{$Dgroups_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		if ($FDgroups_selected < 1) 
			{$FDgroups_menu .= "<option SELECTED value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		else 
			{$FDgroups_menu .= "<option value=\"---NONE---\">---"._QXZ("NONE")."---</option>\n";}
		if ($PFDgroups_selected < 1) 
			{$PFDgroups_menu .= "<option SELECTED value=\"\">---"._QXZ("NONE")."---</option>\n";}
		else 
			{$PFDgroups_menu .= "<option value=\"\">---"._QXZ("NONE")."---</option>\n";}
		if ($MQIgroups_selected < 1) 
			{$MQIgroups_menu .= "<option SELECTED value=\"\">---"._QXZ("NONE")."---</option>\n";}
		else 
			{$MQIgroups_menu .= "<option value=\"\">---"._QXZ("NONE")."---</option>\n";}

		$stmt="SELECT filter_phone_group_id,filter_phone_group_name from vicidial_filter_phone_groups $whereLOGadmin_viewable_groupsSQL order by filter_phone_group_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$Fgroups_to_print = mysqli_num_rows($rslt);
		$Fgroups_list=array();
		$Fgroups_names=array();
		$i=0;
		while ($i < $Fgroups_to_print)
			{
			$row=mysqli_fetch_row($rslt);
			$Fgroups_list[$i] =			$row[0];
			$Fgroups_names[$i] =		$row[1];
			$i++;
			}
		$Fgroups_list[$i] =			'';
		$Fgroups_names[$i] =		'---NONE---';

		$stmt="SELECT menu_id,menu_name,menu_prompt from vicidial_call_menu $whereLOGadmin_viewable_groupsSQL order by menu_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$menus_to_print = mysqli_num_rows($rslt);
		$menu_list='';
		$i=0;
		while ($i < $menus_to_print)
			{
			$row=mysqli_fetch_row($rslt);
			$menu_list .= "<option value=\"$row[0]\">$row[0] - $row[1] - $row[2]</option>";
			$i++;
			}


		echo "<br>"._QXZ("MODIFY A DID RECORD").": $did_pattern<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=4311>\n";
		echo "<input type=hidden name=did_id value=\"$did_id\">\n";
		echo "<input type=hidden name=did_pattern value=\"$did_pattern\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
	#	echo "<tr bgcolor=#$SSstd_row4_background><td align=right>DID Extension: </td><td align=left><input type=text name=did_pattern size=30 maxlength=50 value=\"$did_pattern\">$NWB#inbound_dids-did_pattern$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("DID Extension").": </td><td align=left>$did_pattern $NWB#inbound_dids-did_pattern$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("DID Description").": </td><td align=left><input type=text name=did_description size=40 maxlength=50 value=\"$did_description\">$NWB#inbound_dids-did_description$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("DID Carrier Description").": </td><td align=left><input type=text name=did_carrier_description size=50 maxlength=255 value=\"$did_carrier_description\">$NWB#inbound_dids-did_carrier_description$NWE</td></tr>\n";
		if ($did_pattern == 'did_system_filter')
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
			echo "$UUgroups_list";
			echo "<option SELECTED value=\"$user_group\">".(preg_match('/\-\-ALL\-\-/', $user_group) ? _QXZ("$user_group") : $user_group)."</option>\n";
			echo "</select>$NWB#inbound_dids-user_group$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><input type=hidden name=did_active value='Y'>Y</td></tr>\n";
			echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Clean CID Number").": </td><td align=left><input type=text name=filter_clean_cid_number size=20 maxlength=20 value=\"$filter_clean_cid_number\">$NWB#inbound_dids-filter_clean_cid_number$NWE</td></tr>\n";

			echo "<tr bgcolor=#99FFCC><td align=right></td><td align=left>";
			echo "<input type=hidden name=did_route value='$did_route'>\n";
			echo "<input type=hidden name=record_call value='$record_call'>\n";
			echo "<input type=hidden name=extension value='$extension'>\n";
			echo "<input type=hidden name=exten_context value='$exten_context'>\n";
			echo "<input type=hidden name=voicemail_ext value='$voicemail_ext'>\n";
			echo "<input type=hidden name=phone value='$phone'>\n";
			echo "<input type=hidden name=server_ip value='$server_ip'>\n";
			echo "<input type=hidden name=menu_id value='$menu_id'>\n";
			echo "<input type=hidden name=user value='$user'>\n";
			echo "<input type=hidden name=user_unavailable_action value='$user_unavailable_action'>\n";
			echo "<input type=hidden name=user_route_settings_ingroup value='$user_route_settings_ingroup'>\n";
			echo "<input type=hidden name=group_id value='$group_id'>\n";
			echo "<input type=hidden name=call_handle_method value='$call_handle_method'>\n";
			echo "<input type=hidden name=agent_search_method value='$agent_search_method'>\n";
			echo "<input type=hidden name=list_id value='$list_id'>\n";
			echo "<input type=hidden name=entry_list_id value='$entry_list_id'>\n";
			echo "<input type=hidden name=campaign_id value='$campaign_id'>\n";
			echo "<input type=hidden name=phone_code value='$phone_code'>\n";
			echo "<input type=hidden name=no_agent_ingroup_redirect value='$no_agent_ingroup_redirect'>\n";
			echo "<input type=hidden name=no_agent_ingroup_id value='$no_agent_ingroup_id'>\n";
			echo "<input type=hidden name=no_agent_ingroup_extension value='$no_agent_ingroup_extension'>\n";
			echo "<input type=hidden name=max_queue_ingroup_calls value='$max_queue_ingroup_calls'>\n";
			echo "<input type=hidden name=max_queue_ingroup_id value='$max_queue_ingroup_id'>\n";
			echo "<input type=hidden name=max_queue_ingroup_extension value='$max_queue_ingroup_extension'>\n";
			echo "<input type=hidden name=pre_filter_phone_group_id value='$pre_filter_phone_group_id'>\n";
			echo "<input type=hidden name=pre_filter_extension value='$pre_filter_extension'>\n";
			echo "</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=did_active><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$did_active' SELECTED>"._QXZ("$did_active")."</option></select>$NWB#inbound_dids-did_active$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
			echo "$UUgroups_list";
			echo "<option SELECTED value=\"$user_group\">".(preg_match('/\-\-ALL\-\-/', $user_group) ? _QXZ("$user_group") : $user_group)."</option>\n";
			echo "</select>$NWB#inbound_dids-user_group$NWE</td></tr>\n";
			echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("DID Route").": </td><td align=left><select size=1 name=did_route><option value='AGENT'>"._QXZ("AGENT")."</option><option value='EXTEN'>"._QXZ("EXTEN")."</option><option value='VOICEMAIL'>"._QXZ("VOICEMAIL")."</option><option value='VMAIL_NO_INST'>"._QXZ("VMAIL_NO_INST")."</option><option value='PHONE'>"._QXZ("PHONE")."</option><option value='IN_GROUP'>"._QXZ("IN_GROUP")."</option><option value='CALLMENU'>"._QXZ("CALLMENU")."</option><option value='$did_route' SELECTED>"._QXZ("$did_route")."</option></select>$NWB#inbound_dids-did_route$NWE</td></tr>\n";
			echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Record Call").": </td><td align=left><select size=1 name=record_call><option value='N'>"._QXZ("N")."</option><option value='Y_QUEUESTOP'>"._QXZ("Y_QUEUESTOP")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$record_call' SELECTED>"._QXZ("$record_call")."</option></select>$NWB#inbound_dids-record_call$NWE</td></tr>\n";

			if ($SSinbound_answer_config > 0)
				{
				echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Route Answer").": </td><td align=left><select size=1 name=inbound_route_answer><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$inbound_route_answer' SELECTED>"._QXZ("$inbound_route_answer")."</option></select>$NWB#inbound_dids-inbound_route_answer$NWE</td></tr>\n";
				}
			else
				{
				echo "<tr bgcolor=#99FFCC><td align=right></td><td align=left><input type=hidden name=inbound_route_answer value='Y'></td></tr>";
				}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Extension").": </td><td align=left><input type=text name=extension size=40 maxlength=50 value=\"$extension\">$NWB#inbound_dids-extension$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Extension Context").": </td><td align=left><input type=text name=exten_context size=40 maxlength=50 value=\"$exten_context\">$NWB#inbound_dids-exten_context$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Voicemail Box").": </td><td align=left><input type=text name=voicemail_ext id=voicemail_ext size=12 maxlength=10 value=\"$voicemail_ext\"> <a href=\"javascript:launch_vm_chooser('voicemail_ext','vm');\">"._QXZ("voicemail chooser")."</a>$NWB#inbound_dids-voicemail_ext$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Phone Extension").": </td><td align=left><input type=text name=phone size=20 maxlength=100 value=\"$phone\">$NWB#inbound_dids-phone$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Server IP").": </td><td align=left><select size=1 name=server_ip>\n";
			echo "$servers_list";
			echo "<option SELECTED>$server_ip</option>\n";
			echo "<option value=''>---"._QXZ("NONE")."---</option>\n";
			echo "</select>$NWB#inbound_dids-server_ip$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=3511&menu_id=$menu_id\">"._QXZ("Call Menu").":</a> </td><td align=left><select size=1 name=menu_id>$menu_list<option SELECTED>$menu_id</option></select>$NWB#inbound_dids-menu_id$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User Agent").": </td><td align=left><input type=text name=user size=20 maxlength=20 value=\"$user\">$NWB#inbound_dids-user$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User Unavailable Action").": </td><td align=left><select size=1 name=user_unavailable_action><option value='EXTEN'>"._QXZ("EXTEN")."</option><option value='VOICEMAIL'>"._QXZ("VOICEMAIL")."</option><option value='VMAIL_NO_INST'>"._QXZ("VMAIL_NO_INST")."</option><option value='PHONE'>"._QXZ("PHONE")."</option><option value='IN_GROUP'>"._QXZ("IN_GROUP")."</option><option value=\"$user_unavailable_action\" SELECTED>"._QXZ("$user_unavailable_action")."</option></select>$NWB#inbound_dids-user_unavailable_action$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User Route Settings In-Group").": </td><td align=left><select size=1 name=user_route_settings_ingroup>";
			echo "$Xgroups_menu";
			echo "</select>$NWB#inbound_dids-user_route_settings_ingroup$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=3111&group_id=$group_id\">"._QXZ("In-Group ID")."</a>: </td><td align=left><select size=1 name=group_id>";
			echo "$Dgroups_menu";
			echo "</select>$NWB#inbound_dids-group_id$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("In-Group Call Handle Method").": </td><td align=left><select size=1 name=call_handle_method>
			<option value='$call_handle_method' SELECTED>"._QXZ("$call_handle_method")."</option>
			<option value='CID'>"._QXZ("CID")."</option>
			<option value='CIDLOOKUP'>"._QXZ("CIDLOOKUP")."</option>
			<option value='CIDLOOKUPRL'>"._QXZ("CIDLOOKUPRL")."</option>
			<option value='CIDLOOKUPRC'>"._QXZ("CIDLOOKUPRC")."</option>
			<option value='CIDLOOKUPALT'>"._QXZ("CIDLOOKUPALT")."</option>
			<option value='CIDLOOKUPRLALT'>"._QXZ("CIDLOOKUPRLALT")."</option>
			<option value='CIDLOOKUPRCALT'>"._QXZ("CIDLOOKUPRCALT")."</option>
			<option value='CIDLOOKUPADDR3'>"._QXZ("CIDLOOKUPADDR3")."</option>
			<option value='CIDLOOKUPRLADDR3'>"._QXZ("CIDLOOKUPRLADDR3")."</option>
			<option value='CIDLOOKUPRCADDR3'>"._QXZ("CIDLOOKUPRCADDR3")."</option>
			<option value='CIDLOOKUPALTADDR3'>"._QXZ("CIDLOOKUPALTADDR3")."</option>
			<option value='CIDLOOKUPRLALTADDR3'>"._QXZ("CIDLOOKUPRLALTADDR3")."</option>
			<option value='CIDLOOKUPRCALTADDR3'>"._QXZ("CIDLOOKUPRCALTADDR3")."</option>
			<option value='ANI'>"._QXZ("ANI")."</option>
			<option value='ANILOOKUP'>"._QXZ("ANILOOKUP")."</option>
			<option value='ANILOOKUPRL'>"._QXZ("ANILOOKUPRL")."</option>
			<option value='VIDPROMPT'>"._QXZ("VIDPROMPT")."</option>
			<option value='VIDPROMPTLOOKUP'>"._QXZ("VIDPROMPTLOOKUP")."</option>
			<option value='VIDPROMPTLOOKUPRL'>"._QXZ("VIDPROMPTLOOKUPRL")."</option>
			<option value='VIDPROMPTLOOKUPRC'>"._QXZ("VIDPROMPTLOOKUPRC")."</option>
			<option value='VIDPROMPTSPECIALLOOKUP'>"._QXZ("VIDPROMPTSPECIALLOOKUP")."</option>
			<option value='VIDPROMPTSPECIALLOOKUPRL'>"._QXZ("VIDPROMPTSPECIALLOOKUPRL")."</option>
			<option value='VIDPROMPTSPECIALLOOKUPRC'>"._QXZ("VIDPROMPTSPECIALLOOKUPRC")."</option>
			<option value='CLOSER'>"._QXZ("CLOSER")."</option>
			<option value='3DIGITID'>"._QXZ("3DIGITID")."</option>
			<option value='4DIGITID'>"._QXZ("4DIGITID")."</option>
			<option value='5DIGITID'>"._QXZ("5DIGITID")."</option>
			<option value='10DIGITID'>"._QXZ("10DIGITID")."</option>
			<option value='CIDLOOKUPOWNERCUSTOM1'>"._QXZ("CIDLOOKUPOWNERCUSTOM1")."</option>
			<option value='CIDLOOKUPRLOWNERCUSTOM1'>"._QXZ("CIDLOOKUPRLOWNERCUSTOM1")."</option>
			<option value='CIDLOOKUPRCOWNERCUSTOM1'>"._QXZ("CIDLOOKUPRCOWNERCUSTOM1")."</option>
			<option value='CIDLOOKUPALTOWNERCUSTOM1'>"._QXZ("CIDLOOKUPALTOWNERCUSTOM1")."</option>
			<option value='CIDLOOKUPRLALTOWNERCUSTOM1'>"._QXZ("CIDLOOKUPRLALTOWNERCUSTOM1")."</option>
			<option value='CIDLOOKUPRCALTOWNERCUSTOM1'>"._QXZ("CIDLOOKUPRCALTOWNERCUSTOM1")."</option>
			<option value='CIDLOOKUPADDR3OWNERCUSTOM1'>"._QXZ("CIDLOOKUPADDR3OWNERCUSTOM1")."</option>
			<option value='CIDLOOKUPRLADDR3OWNERCUSTOM1'>"._QXZ("CIDLOOKUPRLADDR3OWNERCUSTOM1")."</option>
			<option value='CIDLOOKUPRCADDR3OWNERCUSTOM1'>"._QXZ("CIDLOOKUPRCADDR3OWNERCUSTOM1")."</option>
			<option value='CIDLOOKUPALTADDR3OWNERCUSTOM1'>"._QXZ("CIDLOOKUPALTADDR3OWNERCUSTOM1")."</option>
			<option value='CIDLOOKUPRLALTADDR3OWNERCUSTOM1'>"._QXZ("CIDLOOKUPRLALTADDR3OWNERCUSTOM1")."</option>
			<option value='CIDLOOKUPRCALTADDR3OWNERCUSTOM1'>"._QXZ("CIDLOOKUPRCALTADDR3OWNERCUSTOM1")."</option>
			<option value='CIDLOOKUPOWNERCUSTOM2'>"._QXZ("CIDLOOKUPOWNERCUSTOM2")."</option>
			<option value='CIDLOOKUPRLOWNERCUSTOM2'>"._QXZ("CIDLOOKUPRLOWNERCUSTOM2")."</option>
			<option value='CIDLOOKUPRCOWNERCUSTOM2'>"._QXZ("CIDLOOKUPRCOWNERCUSTOM2")."</option>
			<option value='CIDLOOKUPALTOWNERCUSTOM2'>"._QXZ("CIDLOOKUPALTOWNERCUSTOM2")."</option>
			<option value='CIDLOOKUPRLALTOWNERCUSTOM2'>"._QXZ("CIDLOOKUPRLALTOWNERCUSTOM2")."</option>
			<option value='CIDLOOKUPRCALTOWNERCUSTOM2'>"._QXZ("CIDLOOKUPRCALTOWNERCUSTOM2")."</option>
			<option value='CIDLOOKUPADDR3OWNERCUSTOM2'>"._QXZ("CIDLOOKUPADDR3OWNERCUSTOM2")."</option>
			<option value='CIDLOOKUPRLADDR3OWNERCUSTOM2'>"._QXZ("CIDLOOKUPRLADDR3OWNERCUSTOM2")."</option>
			<option value='CIDLOOKUPRCADDR3OWNERCUSTOM2'>"._QXZ("CIDLOOKUPRCADDR3OWNERCUSTOM2")."</option>
			<option value='CIDLOOKUPALTADDR3OWNERCUSTOM2'>"._QXZ("CIDLOOKUPALTADDR3OWNERCUSTOM2")."</option>
			<option value='CIDLOOKUPRLALTADDR3OWNERCUSTOM2'>"._QXZ("CIDLOOKUPRLALTADDR3OWNERCUSTOM2")."</option>
			<option value='CIDLOOKUPRCALTADDR3OWNERCUSTOM2'>"._QXZ("CIDLOOKUPRCALTADDR3OWNERCUSTOM2")."</option>
			<option value='CIDLOOKUPOWNERCUSTOM3'>"._QXZ("CIDLOOKUPOWNERCUSTOM3")."</option>
			<option value='CIDLOOKUPRLOWNERCUSTOM3'>"._QXZ("CIDLOOKUPRLOWNERCUSTOM3")."</option>
			<option value='CIDLOOKUPRCOWNERCUSTOM3'>"._QXZ("CIDLOOKUPRCOWNERCUSTOM3")."</option>
			<option value='CIDLOOKUPALTOWNERCUSTOM3'>"._QXZ("CIDLOOKUPALTOWNERCUSTOM3")."</option>
			<option value='CIDLOOKUPRLALTOWNERCUSTOM3'>"._QXZ("CIDLOOKUPRLALTOWNERCUSTOM3")."</option>
			<option value='CIDLOOKUPRCALTOWNERCUSTOM3'>"._QXZ("CIDLOOKUPRCALTOWNERCUSTOM3")."</option>
			<option value='CIDLOOKUPADDR3OWNERCUSTOM3'>"._QXZ("CIDLOOKUPADDR3OWNERCUSTOM3")."</option>
			<option value='CIDLOOKUPRLADDR3OWNERCUSTOM3'>"._QXZ("CIDLOOKUPRLADDR3OWNERCUSTOM3")."</option>
			<option value='CIDLOOKUPRCADDR3OWNERCUSTOM3'>"._QXZ("CIDLOOKUPRCADDR3OWNERCUSTOM3")."</option>
			<option value='CIDLOOKUPALTADDR3OWNERCUSTOM3'>"._QXZ("CIDLOOKUPALTADDR3OWNERCUSTOM3")."</option>
			<option value='CIDLOOKUPRLALTADDR3OWNERCUSTOM3'>"._QXZ("CIDLOOKUPRLALTADDR3OWNERCUSTOM3")."</option>
			<option value='CIDLOOKUPRCALTADDR3OWNERCUSTOM3'>"._QXZ("CIDLOOKUPRCALTADDR3OWNERCUSTOM3")."</option>
			<option value='CIDLOOKUPOWNERCUSTOM4'>"._QXZ("CIDLOOKUPOWNERCUSTOM4")."</option>
			<option value='CIDLOOKUPRLOWNERCUSTOM4'>"._QXZ("CIDLOOKUPRLOWNERCUSTOM4")."</option>
			<option value='CIDLOOKUPRCOWNERCUSTOM4'>"._QXZ("CIDLOOKUPRCOWNERCUSTOM4")."</option>
			<option value='CIDLOOKUPALTOWNERCUSTOM4'>"._QXZ("CIDLOOKUPALTOWNERCUSTOM4")."</option>
			<option value='CIDLOOKUPRLALTOWNERCUSTOM4'>"._QXZ("CIDLOOKUPRLALTOWNERCUSTOM4")."</option>
			<option value='CIDLOOKUPRCALTOWNERCUSTOM4'>"._QXZ("CIDLOOKUPRCALTOWNERCUSTOM4")."</option>
			<option value='CIDLOOKUPADDR3OWNERCUSTOM4'>"._QXZ("CIDLOOKUPADDR3OWNERCUSTOM4")."</option>
			<option value='CIDLOOKUPRLADDR3OWNERCUSTOM4'>"._QXZ("CIDLOOKUPRLADDR3OWNERCUSTOM4")."</option>
			<option value='CIDLOOKUPRCADDR3OWNERCUSTOM4'>"._QXZ("CIDLOOKUPRCADDR3OWNERCUSTOM4")."</option>
			<option value='CIDLOOKUPALTADDR3OWNERCUSTOM4'>"._QXZ("CIDLOOKUPALTADDR3OWNERCUSTOM4")."</option>
			<option value='CIDLOOKUPRLALTADDR3OWNERCUSTOM4'>"._QXZ("CIDLOOKUPRLALTADDR3OWNERCUSTOM4")."</option>
			<option value='CIDLOOKUPRCALTADDR3OWNERCUSTOM4'>"._QXZ("CIDLOOKUPRCALTADDR3OWNERCUSTOM4")."</option>
			<option value='CIDLOOKUPOWNERCUSTOM5'>"._QXZ("CIDLOOKUPOWNERCUSTOM5")."</option>
			<option value='CIDLOOKUPRLOWNERCUSTOM5'>"._QXZ("CIDLOOKUPRLOWNERCUSTOM5")."</option>
			<option value='CIDLOOKUPRCOWNERCUSTOM5'>"._QXZ("CIDLOOKUPRCOWNERCUSTOM5")."</option>
			<option value='CIDLOOKUPALTOWNERCUSTOM5'>"._QXZ("CIDLOOKUPALTOWNERCUSTOM5")."</option>
			<option value='CIDLOOKUPRLALTOWNERCUSTOM5'>"._QXZ("CIDLOOKUPRLALTOWNERCUSTOM5")."</option>
			<option value='CIDLOOKUPRCALTOWNERCUSTOM5'>"._QXZ("CIDLOOKUPRCALTOWNERCUSTOM5")."</option>
			<option value='CIDLOOKUPADDR3OWNERCUSTOM5'>"._QXZ("CIDLOOKUPADDR3OWNERCUSTOM5")."</option>
			<option value='CIDLOOKUPRLADDR3OWNERCUSTOM5'>"._QXZ("CIDLOOKUPRLADDR3OWNERCUSTOM5")."</option>
			<option value='CIDLOOKUPRCADDR3OWNERCUSTOM5'>"._QXZ("CIDLOOKUPRCADDR3OWNERCUSTOM5")."</option>
			<option value='CIDLOOKUPALTADDR3OWNERCUSTOM5'>"._QXZ("CIDLOOKUPALTADDR3OWNERCUSTOM5")."</option>
			<option value='CIDLOOKUPRLALTADDR3OWNERCUSTOM5'>"._QXZ("CIDLOOKUPRLALTADDR3OWNERCUSTOM5")."</option>
			<option value='CIDLOOKUPRCALTADDR3OWNERCUSTOM5'>"._QXZ("CIDLOOKUPRCALTADDR3OWNERCUSTOM5")."</option>
			</select>$NWB#inbound_dids-call_handle_method$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("In-Group Agent Search Method").": </td><td align=left><select size=1 name=agent_search_method><option value=\"LB\">LB - "._QXZ("Load Balanced")."</option><option value=\"LO\">LO - "._QXZ("Load Balanced Overflow")."</option><option value=\"SO\">SO - "._QXZ("Server Only")."</option><option SELECTED>$agent_search_method</option></select>$NWB#inbound_dids-agent_search_method$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("In-Group List ID").": </td><td align=left><input type=text name=list_id size=19 maxlength=19 value=\"$list_id\">$NWB#inbound_dids-list_id$NWE</td></tr>\n";

			if ($SSenable_did_entry_list_id > 0)
				{
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("In-Group Entry List ID").": </td><td align=left><input type=text name=entry_list_id size=19 maxlength=19 value=\"$entry_list_id\">$NWB#inbound_dids-entry_list_id$NWE</td></tr>\n";
				}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("In-Group Campaign ID").": </td><td align=left><select size=1 name=campaign_id>\n";
			echo "$campaigns_list";
			echo "<option value=\"\">---"._QXZ("NONE")."---</option>\n";
			echo "<option SELECTED>$campaign_id</option>\n";
			echo "</select>$NWB#inbound_dids-campaign_id$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("In-Group Phone Code").": </td><td align=left><input type=text name=phone_code size=14 maxlength=14 value=\"$phone_code\">$NWB#inbound_dids-phone_code$NWE</td></tr>\n";

			echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Clean CID Number").": </td><td align=left><input type=text name=filter_clean_cid_number size=20 maxlength=20 value=\"$filter_clean_cid_number\">$NWB#inbound_dids-filter_clean_cid_number$NWE</td></tr>\n";

			echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("No-Agent In-Group Redirect").": </td><td align=left><select size=1 name=no_agent_ingroup_redirect><option value=\"DISABLED\">"._QXZ("DISABLED")."</option><option value=\"Y\">"._QXZ("Y")."</option><option value=\"NO_PAUSED\">"._QXZ("NO_PAUSED")."</option><option value=\"READY_ONLY\">"._QXZ("READY_ONLY")."</option><option value=\"$no_agent_ingroup_redirect\" SELECTED>"._QXZ("$no_agent_ingroup_redirect")."</option></select>$NWB#inbound_dids-no_agent_ingroup_redirect$NWE</td></tr>\n";

			echo "<tr bgcolor=#CCFFFF><td align=right><a href=\"$PHP_SELF?ADD=3111&group_id=$no_agent_ingroup_id\">"._QXZ("No-Agent In-Group ID")."</a>: </td><td align=left><select size=1 name=no_agent_ingroup_id>";
			echo "$PFDgroups_menu";
			echo "</select>$NWB#inbound_dids-no_agent_ingroup_id$NWE</td></tr>\n";

			echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("No-Agent In-Group Extension").": </td><td align=left><input type=text name=no_agent_ingroup_extension size=40 maxlength=50 value=\"$no_agent_ingroup_extension\">$NWB#inbound_dids-no_agent_ingroup_extension$NWE</td></tr>\n";

			echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Max Queue In-Group Calls").": </td><td align=left><input type=text size=5 maxlength=4 name=max_queue_ingroup_calls value=\"$max_queue_ingroup_calls\"> $NWB#inbound_dids-max_queue_ingroup_calls$NWE</td></tr>\n";

			echo "<tr bgcolor=#CCFFFF><td align=right><a href=\"$PHP_SELF?ADD=3111&group_id=$max_queue_ingroup_id\">"._QXZ("Max Queue In-Group ID")."</a>: </td><td align=left><select size=1 name=max_queue_ingroup_id>";
			echo "$MQIgroups_menu";
			echo "</select>$NWB#inbound_dids-max_queue_ingroup_id$NWE</td></tr>\n";

			echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Max Queue In-Group Extension").": </td><td align=left><input type=text name=max_queue_ingroup_extension size=40 maxlength=50 value=\"$max_queue_ingroup_extension\">$NWB#inbound_dids-max_queue_ingroup_extension$NWE</td></tr>\n";

		#	echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=3711&filter_phone_group_id=$pre_filter_phone_group_id\">"._QXZ("Pre-Filter Phone Group ID").":</a> </td><td align=left><select size=1 name=pre_filter_phone_group_id>$Fgroups_list<option value='$pre_filter_phone_group_id' SELECTED>"._QXZ("$pre_filter_phone_group_id")."</option><option value=\"\">---"._QXZ("NONE")."---</option></select>$NWB#inbound_dids-pre_filter_phone_group_id$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Pre-Filter Phone Group ID").": </td><td align=left><select MULTIPLE size=4 name=pre_filter_phone_group_id[]>\n";

			$Fgroups_ct = count($Fgroups_list);
			$b=0;
			while ($b < $Fgroups_ct)
				{
				$field_selected='';
				if (preg_match("/^$Fgroups_list[$b]$|^$Fgroups_list[$b],|,$Fgroups_list[$b]$|,$Fgroups_list[$b],/",$pre_filter_phone_group_id))
					{$field_selected = 'SELECTED';}
				echo "<option value=\"$Fgroups_list[$b]\" $field_selected>$Fgroups_list[$b] - $Fgroups_names[$b]</option>\n";
				$b++;
				}
			echo "</select>$NWB#inbound_dids-pre_filter_phone_group_id$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Pre-Filter Phone Group DID").": </td><td align=left><input type=text name=pre_filter_extension size=40 maxlength=50 value=\"$pre_filter_extension\">$NWB#inbound_dids-pre_filter_extension$NWE</td></tr>\n";


			##### get container listings for dynamic DID_RECENT_CALL container pulldown menu
			$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='DID_RECENT_CALL' $LOGadmin_viewable_groupsSQL order by container_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$dtlc_to_print = mysqli_num_rows($rslt);
			$pre_filter_recent_call_menu='';
			$dtlc_selected=0;
			$o=0;
			while ($dtlc_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				if (mb_strlen($rowx[1],'utf-8')>40)
					{$rowx[1] = mb_substr($rowx[1],0,40,'utf-8') . '...';}
				$pre_filter_recent_call_menu .= "<option ";
				if ($pre_filter_recent_call == "$rowx[0]") 
					{
					$pre_filter_recent_call_menu .= "SELECTED ";
					$dtlc_selected++;
					}
				$pre_filter_recent_call_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$o++;
				}

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>";
			if ($dtlc_selected > 0)
				{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$pre_filter_recent_call\">"._QXZ("Pre-Filter Recent Call")."</a>";}
			else
				{echo _QXZ("Pre-Filter Recent Call");}
			echo ": </td><td align=left nowrap><select size=1 name=pre_filter_recent_call><option value=''>"._QXZ("DISABLED")."</option>$pre_filter_recent_call_menu</select>$NWB#inbound_dids-pre_filter_recent_call$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Pre-Filter Recent Call DID").": </td><td align=left><input type=text name=pre_filter_recent_extension size=40 maxlength=50 value=\"$pre_filter_recent_extension\">$NWB#inbound_dids-pre_filter_recent_extension$NWE</td></tr>\n";

			}

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Filter Inbound Number").": </td><td align=left><select size=1 name=filter_inbound_number><option value=\"DISABLED\">"._QXZ("DISABLED")."</option><option value=\"GROUP\">"._QXZ("GROUP")."</option><option value=\"URL\">"._QXZ("URL")."</option><option value=\"DNC_INTERNAL\">"._QXZ("DNC_INTERNAL")."</option><option value=\"DNC_CAMPAIGN\">"._QXZ("DNC_CAMPAIGN")."</option><option value=\"GROUP_AREACODE\">"._QXZ("GROUP_AREACODE")."</option><option value=\"$filter_inbound_number\" SELECTED>"._QXZ("$filter_inbound_number")."</option></select>$NWB#inbound_dids-filter_inbound_number$NWE</td></tr>\n";

	#	echo "<tr bgcolor=#CCFFFF><td align=right><a href=\"$PHP_SELF?ADD=3711&filter_phone_group_id=$filter_phone_group_id\">"._QXZ("Filter Phone Group ID").":</a> </td><td align=left><select size=1 name=filter_phone_group_id>$Fgroups_list<option value='$filter_phone_group_id' SELECTED>"._QXZ("$filter_phone_group_id")."</option></select>$NWB#inbound_dids-filter_phone_group_id$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Filter Phone Group ID").": </td><td align=left><select MULTIPLE size=4 name=filter_phone_group_id[]>\n";

		$Fgroups_ct = count($Fgroups_list);
		$b=0;
		while ($b < $Fgroups_ct)
			{
			$field_selected='';
			if (preg_match("/^$Fgroups_list[$b]$|^$Fgroups_list[$b],|,$Fgroups_list[$b]$|,$Fgroups_list[$b],/",$filter_phone_group_id))
				{$field_selected = 'SELECTED';}
			echo "<option value=\"$Fgroups_list[$b]\" $field_selected>$Fgroups_list[$b] - $Fgroups_names[$b]</option>\n";
			$b++;
			}
		echo "</select>$NWB#inbound_dids-filter_phone_group_id$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Filter URL").": </td><td align=left><input type=text name=filter_url size=80 maxlength=1000 value=\"$filter_url\">$NWB#inbound_dids-filter_url$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Filter URL DID Redirect").": </td><td align=left><select size=1 name=filter_url_did_redirect><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$filter_url_did_redirect' SELECTED>"._QXZ("$filter_url_did_redirect")."</option></select>$NWB#inbound_dids-filter_url_did_redirect$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Filter DNC Campaign").": </td><td align=left><input type=text name=filter_dnc_campaign size=10 maxlength=8 value=\"$filter_dnc_campaign\">$NWB#inbound_dids-filter_dnc_campaign$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Filter Action").": </td><td align=left><select size=1 name=filter_action><option value='AGENT'>"._QXZ("AGENT")."</option><option value='EXTEN'>"._QXZ("EXTEN")."</option><option value='VOICEMAIL'>"._QXZ("VOICEMAIL")."</option><option value='VMAIL_NO_INST'>"._QXZ("VMAIL_NO_INST")."</option><option value='PHONE'>"._QXZ("PHONE")."</option><option value='IN_GROUP'>"._QXZ("IN_GROUP")."</option><option value='CALLMENU'>"._QXZ("CALLMENU")."</option><option value=\"$filter_action\" SELECTED>"._QXZ("$filter_action")."</option></select>$NWB#inbound_dids-filter_action$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Filter Extension").": </td><td align=left><input type=text name=filter_extension size=40 maxlength=50 value=\"$filter_extension\">$NWB#inbound_dids-extension$NWE</td></tr>\n";
		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Filter Extension Context").": </td><td align=left><input type=text name=filter_exten_context size=40 maxlength=50 value=\"$filter_exten_context\">$NWB#inbound_dids-exten_context$NWE</td></tr>\n";
		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Filter Voicemail Box").": </td><td align=left><input type=text name=filter_voicemail_ext id=filter_voicemail_ext size=12 maxlength=10 value=\"$filter_voicemail_ext\"> <a href=\"javascript:launch_vm_chooser('filter_voicemail_ext','vm');\">"._QXZ("voicemail chooser")."</a>$NWB#inbound_dids-voicemail_ext$NWE</td></tr>\n";
		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Filter Phone Extension").": </td><td align=left><input type=text name=filter_phone size=20 maxlength=100 value=\"$filter_phone\">$NWB#inbound_dids-phone$NWE</td></tr>\n";
		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Filter Server IP").": </td><td align=left><select size=1 name=filter_server_ip>\n";
		echo "$servers_list";
		echo "<option SELECTED>$filter_server_ip</option>\n";
		echo "<option value=''>---"._QXZ("NONE")."---</option>\n";
		echo "</select>$NWB#inbound_dids-server_ip$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right><a href=\"$PHP_SELF?ADD=3511&menu_id=$filter_menu_id\">"._QXZ("Filter Call Menu").":</a> </td><td align=left><select size=1 name=filter_menu_id>$menu_list<option SELECTED>$filter_menu_id</option></select>$NWB#inbound_dids-menu_id$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Filter User Agent").": </td><td align=left><input type=text name=filter_user size=20 maxlength=20 value=\"$filter_user\">$NWB#inbound_dids-user$NWE</td></tr>\n";
		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Filter User Unavailable Action").": </td><td align=left><select size=1 name=filter_user_unavailable_action><option value='EXTEN'>"._QXZ("EXTEN")."</option><option value='VOICEMAIL'>"._QXZ("VOICEMAIL")."</option><option value='VMAIL_NO_INST'>"._QXZ("VMAIL_NO_INST")."</option><option value='PHONE'>"._QXZ("PHONE")."</option><option value='IN_GROUP'>"._QXZ("IN_GROUP")."</option><option value=\"$filter_user_unavailable_action\" SELECTED>"._QXZ("$filter_user_unavailable_action")."</option></select>$NWB#inbound_dids-user_unavailable_action$NWE</td></tr>\n";
		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Filter User Route Settings In-Group").": </td><td align=left><select size=1 name=filter_user_route_settings_ingroup>";
		echo "$FXgroups_menu";
		echo "</select>$NWB#inbound_dids-user_route_settings_ingroup$NWE</td></tr>\n";
		echo "<tr bgcolor=#CCFFFF><td align=right><a href=\"$PHP_SELF?ADD=3111&group_id=$filter_group_id\">"._QXZ("Filter In-Group ID")."</a>: </td><td align=left><select size=1 name=filter_group_id>";
		echo "$FDgroups_menu";
		echo "</select>$NWB#inbound_dids-group_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Filter In-Group Call Handle Method").": </td><td align=left><select size=1 name=filter_call_handle_method>
		<option value='$filter_call_handle_method' SELECTED>"._QXZ("$filter_call_handle_method")."</option>
		<option value='CID'>"._QXZ("CID")."</option>
		<option value='CIDLOOKUP'>"._QXZ("CIDLOOKUP")."</option>
		<option value='CIDLOOKUPRL'>"._QXZ("CIDLOOKUPRL")."</option>
		<option value='CIDLOOKUPRC'>"._QXZ("CIDLOOKUPRC")."</option>
		<option value='CIDLOOKUPALT'>"._QXZ("CIDLOOKUPALT")."</option>
		<option value='CIDLOOKUPRLALT'>"._QXZ("CIDLOOKUPRLALT")."</option>
		<option value='CIDLOOKUPRCALT'>"._QXZ("CIDLOOKUPRCALT")."</option>
		<option value='CIDLOOKUPADDR3'>"._QXZ("CIDLOOKUPADDR3")."</option>
		<option value='CIDLOOKUPRLADDR3'>"._QXZ("CIDLOOKUPRLADDR3")."</option>
		<option value='CIDLOOKUPRCADDR3'>"._QXZ("CIDLOOKUPRCADDR3")."</option>
		<option value='CIDLOOKUPALTADDR3'>"._QXZ("CIDLOOKUPALTADDR3")."</option>
		<option value='CIDLOOKUPRLALTADDR3'>"._QXZ("CIDLOOKUPRLALTADDR3")."</option>
		<option value='CIDLOOKUPRCALTADDR3'>"._QXZ("CIDLOOKUPRCALTADDR3")."</option>
		<option value='ANI'>"._QXZ("ANI")."</option>
		<option value='ANILOOKUP'>"._QXZ("ANILOOKUP")."</option>
		<option value='ANILOOKUPRL'>"._QXZ("ANILOOKUPRL")."</option>
		<option value='VIDPROMPT'>"._QXZ("VIDPROMPT")."</option>
		<option value='VIDPROMPTLOOKUP'>"._QXZ("VIDPROMPTLOOKUP")."</option>
		<option value='VIDPROMPTLOOKUPRL'>"._QXZ("VIDPROMPTLOOKUPRL")."</option>
		<option value='VIDPROMPTLOOKUPRC'>"._QXZ("VIDPROMPTLOOKUPRC")."</option>
		<option value='VIDPROMPTSPECIALLOOKUP'>"._QXZ("VIDPROMPTSPECIALLOOKUP")."</option>
		<option value='VIDPROMPTSPECIALLOOKUPRL'>"._QXZ("VIDPROMPTSPECIALLOOKUPRL")."</option>
		<option value='VIDPROMPTSPECIALLOOKUPRC'>"._QXZ("VIDPROMPTSPECIALLOOKUPRC")."</option>
		<option value='CLOSER'>"._QXZ("CLOSER")."</option>
		<option value='3DIGITID'>"._QXZ("3DIGITID")."</option>
		<option value='4DIGITID'>"._QXZ("4DIGITID")."</option>
		<option value='5DIGITID'>"._QXZ("5DIGITID")."</option>
		<option value='10DIGITID'>"._QXZ("10DIGITID")."</option>
		<option value='CIDLOOKUPOWNERCUSTOM1'>"._QXZ("CIDLOOKUPOWNERCUSTOM1")."</option>
		<option value='CIDLOOKUPRLOWNERCUSTOM1'>"._QXZ("CIDLOOKUPRLOWNERCUSTOM1")."</option>
		<option value='CIDLOOKUPRCOWNERCUSTOM1'>"._QXZ("CIDLOOKUPRCOWNERCUSTOM1")."</option>
		<option value='CIDLOOKUPALTOWNERCUSTOM1'>"._QXZ("CIDLOOKUPALTOWNERCUSTOM1")."</option>
		<option value='CIDLOOKUPRLALTOWNERCUSTOM1'>"._QXZ("CIDLOOKUPRLALTOWNERCUSTOM1")."</option>
		<option value='CIDLOOKUPRCALTOWNERCUSTOM1'>"._QXZ("CIDLOOKUPRCALTOWNERCUSTOM1")."</option>
		<option value='CIDLOOKUPADDR3OWNERCUSTOM1'>"._QXZ("CIDLOOKUPADDR3OWNERCUSTOM1")."</option>
		<option value='CIDLOOKUPRLADDR3OWNERCUSTOM1'>"._QXZ("CIDLOOKUPRLADDR3OWNERCUSTOM1")."</option>
		<option value='CIDLOOKUPRCADDR3OWNERCUSTOM1'>"._QXZ("CIDLOOKUPRCADDR3OWNERCUSTOM1")."</option>
		<option value='CIDLOOKUPALTADDR3OWNERCUSTOM1'>"._QXZ("CIDLOOKUPALTADDR3OWNERCUSTOM1")."</option>
		<option value='CIDLOOKUPRLALTADDR3OWNERCUSTOM1'>"._QXZ("CIDLOOKUPRLALTADDR3OWNERCUSTOM1")."</option>
		<option value='CIDLOOKUPRCALTADDR3OWNERCUSTOM1'>"._QXZ("CIDLOOKUPRCALTADDR3OWNERCUSTOM1")."</option>
		<option value='CIDLOOKUPOWNERCUSTOM2'>"._QXZ("CIDLOOKUPOWNERCUSTOM2")."</option>
		<option value='CIDLOOKUPRLOWNERCUSTOM2'>"._QXZ("CIDLOOKUPRLOWNERCUSTOM2")."</option>
		<option value='CIDLOOKUPRCOWNERCUSTOM2'>"._QXZ("CIDLOOKUPRCOWNERCUSTOM2")."</option>
		<option value='CIDLOOKUPALTOWNERCUSTOM2'>"._QXZ("CIDLOOKUPALTOWNERCUSTOM2")."</option>
		<option value='CIDLOOKUPRLALTOWNERCUSTOM2'>"._QXZ("CIDLOOKUPRLALTOWNERCUSTOM2")."</option>
		<option value='CIDLOOKUPRCALTOWNERCUSTOM2'>"._QXZ("CIDLOOKUPRCALTOWNERCUSTOM2")."</option>
		<option value='CIDLOOKUPADDR3OWNERCUSTOM2'>"._QXZ("CIDLOOKUPADDR3OWNERCUSTOM2")."</option>
		<option value='CIDLOOKUPRLADDR3OWNERCUSTOM2'>"._QXZ("CIDLOOKUPRLADDR3OWNERCUSTOM2")."</option>
		<option value='CIDLOOKUPRCADDR3OWNERCUSTOM2'>"._QXZ("CIDLOOKUPRCADDR3OWNERCUSTOM2")."</option>
		<option value='CIDLOOKUPALTADDR3OWNERCUSTOM2'>"._QXZ("CIDLOOKUPALTADDR3OWNERCUSTOM2")."</option>
		<option value='CIDLOOKUPRLALTADDR3OWNERCUSTOM2'>"._QXZ("CIDLOOKUPRLALTADDR3OWNERCUSTOM2")."</option>
		<option value='CIDLOOKUPRCALTADDR3OWNERCUSTOM2'>"._QXZ("CIDLOOKUPRCALTADDR3OWNERCUSTOM2")."</option>
		<option value='CIDLOOKUPOWNERCUSTOM3'>"._QXZ("CIDLOOKUPOWNERCUSTOM3")."</option>
		<option value='CIDLOOKUPRLOWNERCUSTOM3'>"._QXZ("CIDLOOKUPRLOWNERCUSTOM3")."</option>
		<option value='CIDLOOKUPRCOWNERCUSTOM3'>"._QXZ("CIDLOOKUPRCOWNERCUSTOM3")."</option>
		<option value='CIDLOOKUPALTOWNERCUSTOM3'>"._QXZ("CIDLOOKUPALTOWNERCUSTOM3")."</option>
		<option value='CIDLOOKUPRLALTOWNERCUSTOM3'>"._QXZ("CIDLOOKUPRLALTOWNERCUSTOM3")."</option>
		<option value='CIDLOOKUPRCALTOWNERCUSTOM3'>"._QXZ("CIDLOOKUPRCALTOWNERCUSTOM3")."</option>
		<option value='CIDLOOKUPADDR3OWNERCUSTOM3'>"._QXZ("CIDLOOKUPADDR3OWNERCUSTOM3")."</option>
		<option value='CIDLOOKUPRLADDR3OWNERCUSTOM3'>"._QXZ("CIDLOOKUPRLADDR3OWNERCUSTOM3")."</option>
		<option value='CIDLOOKUPRCADDR3OWNERCUSTOM3'>"._QXZ("CIDLOOKUPRCADDR3OWNERCUSTOM3")."</option>
		<option value='CIDLOOKUPALTADDR3OWNERCUSTOM3'>"._QXZ("CIDLOOKUPALTADDR3OWNERCUSTOM3")."</option>
		<option value='CIDLOOKUPRLALTADDR3OWNERCUSTOM3'>"._QXZ("CIDLOOKUPRLALTADDR3OWNERCUSTOM3")."</option>
		<option value='CIDLOOKUPRCALTADDR3OWNERCUSTOM3'>"._QXZ("CIDLOOKUPRCALTADDR3OWNERCUSTOM3")."</option>
		<option value='CIDLOOKUPOWNERCUSTOM4'>"._QXZ("CIDLOOKUPOWNERCUSTOM4")."</option>
		<option value='CIDLOOKUPRLOWNERCUSTOM4'>"._QXZ("CIDLOOKUPRLOWNERCUSTOM4")."</option>
		<option value='CIDLOOKUPRCOWNERCUSTOM4'>"._QXZ("CIDLOOKUPRCOWNERCUSTOM4")."</option>
		<option value='CIDLOOKUPALTOWNERCUSTOM4'>"._QXZ("CIDLOOKUPALTOWNERCUSTOM4")."</option>
		<option value='CIDLOOKUPRLALTOWNERCUSTOM4'>"._QXZ("CIDLOOKUPRLALTOWNERCUSTOM4")."</option>
		<option value='CIDLOOKUPRCALTOWNERCUSTOM4'>"._QXZ("CIDLOOKUPRCALTOWNERCUSTOM4")."</option>
		<option value='CIDLOOKUPADDR3OWNERCUSTOM4'>"._QXZ("CIDLOOKUPADDR3OWNERCUSTOM4")."</option>
		<option value='CIDLOOKUPRLADDR3OWNERCUSTOM4'>"._QXZ("CIDLOOKUPRLADDR3OWNERCUSTOM4")."</option>
		<option value='CIDLOOKUPRCADDR3OWNERCUSTOM4'>"._QXZ("CIDLOOKUPRCADDR3OWNERCUSTOM4")."</option>
		<option value='CIDLOOKUPALTADDR3OWNERCUSTOM4'>"._QXZ("CIDLOOKUPALTADDR3OWNERCUSTOM4")."</option>
		<option value='CIDLOOKUPRLALTADDR3OWNERCUSTOM4'>"._QXZ("CIDLOOKUPRLALTADDR3OWNERCUSTOM4")."</option>
		<option value='CIDLOOKUPRCALTADDR3OWNERCUSTOM4'>"._QXZ("CIDLOOKUPRCALTADDR3OWNERCUSTOM4")."</option>
		<option value='CIDLOOKUPOWNERCUSTOM5'>"._QXZ("CIDLOOKUPOWNERCUSTOM5")."</option>
		<option value='CIDLOOKUPRLOWNERCUSTOM5'>"._QXZ("CIDLOOKUPRLOWNERCUSTOM5")."</option>
		<option value='CIDLOOKUPRCOWNERCUSTOM5'>"._QXZ("CIDLOOKUPRCOWNERCUSTOM5")."</option>
		<option value='CIDLOOKUPALTOWNERCUSTOM5'>"._QXZ("CIDLOOKUPALTOWNERCUSTOM5")."</option>
		<option value='CIDLOOKUPRLALTOWNERCUSTOM5'>"._QXZ("CIDLOOKUPRLALTOWNERCUSTOM5")."</option>
		<option value='CIDLOOKUPRCALTOWNERCUSTOM5'>"._QXZ("CIDLOOKUPRCALTOWNERCUSTOM5")."</option>
		<option value='CIDLOOKUPADDR3OWNERCUSTOM5'>"._QXZ("CIDLOOKUPADDR3OWNERCUSTOM5")."</option>
		<option value='CIDLOOKUPRLADDR3OWNERCUSTOM5'>"._QXZ("CIDLOOKUPRLADDR3OWNERCUSTOM5")."</option>
		<option value='CIDLOOKUPRCADDR3OWNERCUSTOM5'>"._QXZ("CIDLOOKUPRCADDR3OWNERCUSTOM5")."</option>
		<option value='CIDLOOKUPALTADDR3OWNERCUSTOM5'>"._QXZ("CIDLOOKUPALTADDR3OWNERCUSTOM5")."</option>
		<option value='CIDLOOKUPRLALTADDR3OWNERCUSTOM5'>"._QXZ("CIDLOOKUPRLALTADDR3OWNERCUSTOM5")."</option>
		<option value='CIDLOOKUPRCALTADDR3OWNERCUSTOM5'>"._QXZ("CIDLOOKUPRCALTADDR3OWNERCUSTOM5")."</option>		</select>$NWB#inbound_dids-call_handle_method$NWE</td></tr>\n";
		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Filter In-Group Agent Search Method").": </td><td align=left><select size=1 name=filter_agent_search_method><option value=\"LB\">LB - "._QXZ("Load Balanced")."</option><option value=\"LO\">LO - "._QXZ("Load Balanced Overflow")."</option><option value=\"SO\">SO - "._QXZ("Server Only")."</option><option SELECTED>$filter_agent_search_method</option></select>$NWB#inbound_dids-agent_search_method$NWE</td></tr>\n";
		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Filter In-Group List ID").": </td><td align=left><input type=text name=filter_list_id size=19 maxlength=19 value=\"$filter_list_id\">$NWB#inbound_dids-list_id$NWE</td></tr>\n";

		if ($SSenable_did_entry_list_id > 0)
			{
			echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Filter In-Group Entry List ID").": </td><td align=left><input type=text name=filter_entry_list_id size=19 maxlength=19 value=\"$filter_entry_list_id\">$NWB#inbound_dids-entry_list_id$NWE</td></tr>\n";
			}

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Filter In-Group Campaign ID").": </td><td align=left><select size=1 name=filter_campaign_id>\n";
		echo "$campaigns_list";
		echo "<option value=\"\">---"._QXZ("NONE")."---</option>\n";
		echo "<option SELECTED>$filter_campaign_id</option>\n";
		echo "</select>$NWB#inbound_dids-campaign_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Filter In-Group Phone Code").": </td><td align=left><input type=text name=filter_phone_code size=14 maxlength=14 value=\"$filter_phone_code\">$NWB#inbound_dids-phone_code$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom")." 1: </td><td align=left><input type=text name=custom_one size=50 maxlength=100 value=\"$custom_one\">$NWB#inbound_dids-custom_one$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom")." 2: </td><td align=left><input type=text name=custom_two size=50 maxlength=100 value=\"$custom_two\">$NWB#inbound_dids-custom_one$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom")." 3: </td><td align=left><input type=text name=custom_three size=50 maxlength=100 value=\"$custom_three\">$NWB#inbound_dids-custom_one$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom")." 4: </td><td align=left><input type=text name=custom_four size=50 maxlength=100 value=\"$custom_four\">$NWB#inbound_dids-custom_one$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom")." 5: </td><td align=left><input type=text name=custom_five size=50 maxlength=100 value=\"$custom_five\">$NWB#inbound_dids-custom_one$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</table>\n";
		echo "<BR></center></FORM><br>\n";


		echo "<B>"._QXZ("CALL MENUS USING THIS DID").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT distinct vm.menu_id,menu_name from vicidial_call_menu vm,vicidial_call_menu_options vmo where vm.menu_id=vmo.menu_id and option_route='DID' and option_route_value='$did_pattern';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$cms_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($cms_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=3511&menu_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}
		echo "</TABLE><BR>\n";


		echo "<B>"._QXZ("CAMPAIGNS USING THIS DID").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where campaign_cid='$did_pattern' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$camps_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($camps_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=31&campaign_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}
		echo "</TABLE><BR>\n";


		echo "<B>"._QXZ("CAMPAIGN AC-CIDs USING THIS DID").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT camp.campaign_id,campaign_name from vicidial_campaign_cid_areacodes campac,vicidial_campaigns camp where outbound_cid='$did_pattern' and camp.campaign_id=campac.campaign_id $campLOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campacs_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($campacs_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=31&SUB=202&campaign_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}
		echo "</TABLE><BR>\n";


		echo "<B>"._QXZ("CID GROUPS USING THIS DID").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT camp.cid_group_id,cid_group_notes from vicidial_campaign_cid_areacodes campac,vicidial_cid_groups camp where outbound_cid='$did_pattern' and camp.cid_group_id=campac.campaign_id $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$cidgps_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($cidgps_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=396111111111&cid_group_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}
		echo "</TABLE><BR>\n";


		echo "<B>"._QXZ("IN-GROUPS USING THIS DID").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT group_id,group_name from vicidial_inbound_groups where dial_ingroup_cid='$did_pattern' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$ingrps_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($ingrps_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=3111&group_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}
		echo "</TABLE><BR>\n";


		echo "<B>"._QXZ("LISTS USING THIS DID").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT list_id,list_name from vicidial_lists where campaign_cid_override='$did_pattern' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$lists_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($lists_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=311&list_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}
		echo "</TABLE><BR>\n";


		echo "<br><a href=\"./AST_DIDstats.php?group[0]=$did_id\">"._QXZ("Click here to see a traffic report for this DID")."</FONT><br>\n";

		$temp_did_pattern = $did_pattern;
		$temp_did_pattern = preg_replace("/\+/",'%2B',$temp_did_pattern);
		echo "<br><a href=\"./user_stats.php?user=$temp_did_pattern&did=1&did_id=$did_id\">"._QXZ("Click here to see a list of recordings and calls for this DID")."</FONT><br>\n";

		if ($SSdid_ra_extensions_enabled > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=3321&did_id=$did_id\">"._QXZ("SEE DID REMOTE AGENT EXTENSION OVERRIDES FOR THIS DID")."</a>\n";
			}
		if ($LOGdelete_dids > 0)
			{
			if ($did_pattern == 'default')
				{echo "<br><br><DEL>"._QXZ("DELETE THIS DID")."</DEL>\n";}
			else
				{echo "<br><br><a href=\"$PHP_SELF?ADD=5311&did_id=$did_id\">"._QXZ("DELETE THIS DID")."</a>\n";}
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=DIDS&stage=$did_id\">"._QXZ("Click here to see Admin changes to this DID")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=1320 display did remote agent extension override summary
######################
if ($ADD==1320)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	echo "<br>"._QXZ("REMOTE AGENT EXTENSION OVERRIDE LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr>\n";
	echo "<td><B>"._QXZ("DID")."</B></td>\n";
	echo "<td><B>"._QXZ("NAME")."</B></td>\n";
	echo "<td><B>"._QXZ("RA-EXTENS")."</B></td>\n";
	echo "<td><B>"._QXZ("MODIFY")."</B></td>\n";
	echo "</tr>\n";

	$stmt="SELECT did_id,did_pattern,did_description from vicidial_inbound_dids $whereLOGadmin_viewable_groupsSQL order by did_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$dids_to_print = mysqli_num_rows($rslt);

	$o=0;
	while ($dids_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		$dids_id_list[$o] =			$row[0];
		$did_pattern_list[$o] =		$row[1];
		$did_description_list[$o] =	$row[2];
		$o++;
		}

	$o=0;
	$k=0;
	while ($dids_to_print > $o) 
		{
		if (preg_match('/1$|3$|5$|7$|9$/i', $k))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=3321&did_id=$dids_id_list[$o]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=3321&did_id=$dids_id_list[$o]\"><font size=1 color=black>$did_pattern_list[$o]</a></td>";
		echo "<td><font size=1> $did_description_list[$o] </td>";
		echo "<td><font size=1> ";

		$stmt="SELECT count(*) from vicidial_did_ra_extensions where did_id='$dids_id_list[$o]';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$didstatus_to_print = mysqli_num_rows($rslt);
		$p=0;
		while ( ($didstatus_to_print > $p) and ($p < 10) )
			{
			$row=mysqli_fetch_row($rslt);
			echo "$row[0] ";
			$p++;
			}
		echo "</td>";
		echo "<td><font size=1><a href=\"$PHP_SELF?ADD=3321&did_id=$dids_id_list[$o]\">"._QXZ("MODIFY RA-EXTENS")."</a></td></tr>\n";

		$k++;
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=3321 modify did remote agent extension override entries in the system
######################
if ($ADD==3321)
	{
	if ( ($LOGmodify_dids==1) and ($SSdid_ra_extensions_enabled > 0) )
		{
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		##### BEGIN Add/Delete/Modify DID Remote Agent Extensions section #####
		if ($stage == 'ADD')
			{
			if ($add_copy_disabled > 0)
				{
				echo "<br>"._QXZ("You do not have permission to add records on this system")." -system_settings-\n";
				}
			else
				{
				$stmt="SELECT count(*) from vicidial_did_ra_extensions where did_id='$did_id' and user_start='$user_start' and extension='$extension';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				if ($row[0] > 0)
					{echo "<br>"._QXZ("DID REMOTE AGENT EXTENSION OVERRIDE NOT ADDED - there is already an entry for this DID with this RA EXTENSION")."<br>\n";}
				else
					{
					if ( (strlen($did_id) < 1) or (strlen($user_start) < 2) or (strlen($extension) < 4) )
						{
						echo "<br>"._QXZ("DID REMOTE AGENT EXTENSION OVERRIDE NOT ADDED - Please go back and look at the data you entered")."<br>\n";
						}
					else
						{
						echo "<br><b>"._QXZ("DID REMOTE AGENT EXTENSION OVERRIDE ADDED").": $did_id - $user_start - $extension</B><br>\n";

						$stmt="INSERT INTO vicidial_did_ra_extensions(did_id,user_start,extension,description,active) values('$did_id','$user_start','$extension','$description','Y');";
						$rslt=mysql_to_mysqli($stmt, $link);

						### LOG INSERTION Admin Log Table ###
						$SQL_log = "$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='DID_RA-EXTEN', event_type='ADD', record_id='$did_id', event_code='ADMIN ADD DID RA EXTEN', event_sql=\"$SQL_log\", event_notes='DID: $user_start - $extension';";
						if ($DB) {echo "|$stmt|\n";}
						$rslt=mysql_to_mysqli($stmt, $link);
						}
					}
				}
			}
		if ($stage == 'DELETE')
			{
			$stmt="SELECT count(*) from vicidial_did_ra_extensions where did_id='$did_id' and user_start='$user_start' and extension='$extension';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			if ($row[0] < 1)
				{echo "<br>"._QXZ("DID REMOTE AGENT EXTENSION OVERRIDE NOT DELETED - this entry does not exist")."<br>\n";}
			else
				{
				if ( (strlen($did_id) < 1) or (strlen($user_start) < 2) or (strlen($extension) < 4) )
					{
					echo "<br>"._QXZ("DID REMOTE AGENT EXTENSION OVERRIDE NOT DELETED - Please go back and look at the data you entered")."<br>\n";
					}
				else
					{
					echo "<br><b>"._QXZ("DID REMOTE AGENT EXTENSION OVERRIDE DELETED").": $did_id - $user_start - $extension</B><br>\n";

					$stmt="DELETE FROM vicidial_did_ra_extensions where did_id='$did_id' and user_start='$user_start' and extension='$extension';";
					$rslt=mysql_to_mysqli($stmt, $link);

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$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='DID_RA-EXTEN', event_type='DELETE', record_id='$did_id', event_code='ADMIN DELETE DID RA EXTEN', event_sql=\"$SQL_log\", event_notes='DID: $user_start - $extension';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				}
			}
		if ($stage == 'MODIFY')
			{
			$stmt="SELECT user_start,extension,active,description,call_count_today from vicidial_did_ra_extensions where did_id='$did_id' order by user_start,extension;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$raextens_to_print = mysqli_num_rows($rslt);
			$o=0;
			while ($raextens_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$Xuser_start[$o] =			$rowx[0];
				$Xextension[$o] =			$rowx[1];
				$Xactive[$o] =				$rowx[2];
				$Xdescription[$o] =			$rowx[3];
				$Xcall_count_today[$o] =	$rowx[4];
				$o++;
				}

			$o=0;
			while ($raextens_to_print > $o) 
				{
				$Factive_value='';
				$Fdescription_value='';
				$Factive = "active_$Xuser_start[$o]_$Xextension[$o]";
				$Fdescription = "description_$Xuser_start[$o]_$Xextension[$o]";

				if (isset($_GET[$Factive]))						{$Factive_value=$_GET[$Factive];}
					elseif (isset($_POST[$Factive]))			{$Factive_value=$_POST[$Factive];}
				if (isset($_GET[$Fdescription]))				{$Fdescription_value=$_GET[$Fdescription];}
					elseif (isset($_POST[$Fdescription]))		{$Fdescription_value=$_POST[$Fdescription];}
				if ($non_latin < 1)
					{
					$Fdescription_value = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$Fdescription_value);
					}
				else
					{
					$Fdescription_value = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$Fdescription_value);
					}
				$Factive_value = preg_replace('/[^A-Z]/','',$Factive_value);

			#	echo "$did_id - $Xuser_start[$o] - $Xextension[$o] - $Factive($Factive_value|$Xactive[$o]) - $Fdescription($Fdescription_value|$Xdescription[$o])<BR>";

				if ( ($Factive_value == $Xactive[$o]) and ($Fdescription_value == $Xdescription[$o]) )
					{
			#		echo "<br>DID REMOTE AGENT EXTENSION OVERRIDE NOT MODIFIED - Please go back and look at the data you entered<br>\n";
					}
				else
					{
					echo "<B>"._QXZ("DID REMOTE AGENT EXTENSION OVERRIDE MODIFIED").": $Xuser_start[$o] - $Xextension[$o]</B><br>\n";

					$stmt="UPDATE vicidial_did_ra_extensions SET active='$Factive_value',description='$Fdescription_value' WHERE did_id='$did_id' and user_start='$Xuser_start[$o]' and extension='$Xextension[$o]';";
					$rslt=mysql_to_mysqli($stmt, $link);

					### LOG INSERTION Admin Log Table ###
					$SQL_log = "$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='DID_RA-EXTEN', event_type='MODIFY', record_id='$did_id', event_code='ADMIN MODIFY DID RA EXTEN', event_sql=\"$SQL_log\", event_notes='DID: $user_start - $extension';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);
					}
				$o++;
				}
			}
		##### END Add/Delete/Modify DID Remote Agent Extensions section #####


		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=3321&did_id=$did_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		echo "<br><br><b>"._QXZ("REMOTE AGENT EXTENSION OVERRIDES FOR THIS DID").": &nbsp; $NWB#did_ra_extensions$NWE</b><br>\n";
		echo "<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=3321>\n";
		echo "<input type=hidden name=stage value=MODIFY>\n";
		echo "<input type=hidden name=did_id value=\"$did_id\">\n";
		echo "<center><TABLE width=700 cellspacing=2>\n";
		echo "<tr><td>#</td><td>"._QXZ("USER START")."</td><td>"._QXZ("EXTENSION")."</td><td>"._QXZ("DESCRIPTION")."</td><td>"._QXZ("ACTIVE")."</td><td>"._QXZ("CALLS")."</td><td>"._QXZ("DELETE")."</td></tr>\n";

		$stmt="SELECT user_start,extension,active,description,call_count_today from vicidial_did_ra_extensions where did_id='$did_id' order by user_start,extension;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$raextens_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($raextens_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$Xuser_start[$o] =			$rowx[0];
			$Xextension[$o] =			$rowx[1];
			$Xactive[$o] =				$rowx[2];
			$Xdescription[$o] =			$rowx[3];
			$Xcall_count_today[$o] =	$rowx[4];
			$o++;
			}

		$o=0;
		while ($raextens_to_print > $o) 
			{
			$ct = ($o + 1);
			if ($ct == '1')
				{
				$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';
				$bgac = $Xuser_start[$o];
				} 
			else
				{
				if ($Xuser_start[$o] != $bgac)
					{
					if (preg_match("/1$|3$|5$|7$|9$/i", $bgct))
						{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';} 
					else
						{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';}
					$bgct++;
					$bgac = $Xuser_start[$o];
					}
				}

			echo "<tr $bgcolor><td><font size=2> &nbsp; $ct</font></td>\n";
			echo "<td><font size=2> &nbsp; $Xuser_start[$o]</font></td>\n";
			echo "<td><font size=2> &nbsp; $Xextension[$o]</font></td>\n";
			echo "<td><input type=text size=30 maxlength=100 name=description_$Xuser_start[$o]_$Xextension[$o] value=\"$Xdescription[$o]\" style=\"font-family: sans-serif; font-size: 10px;\"></td>\n";
			echo "<td>\n";
			if ($Xactive[$o] == 'Y')
				{
				echo "<input type=\"checkbox\" name=\"active_$Xuser_start[$o]_$Xextension[$o]\" value=\"Y\" CHECKED>";
				}
			else
				{
				echo "<input type=\"checkbox\" name=\"active_$Xuser_start[$o]_$Xextension[$o]\" value=\"Y\">";
				}
			echo "</td>\n";
			echo "<td><font size=2> &nbsp; $Xcall_count_today[$o]</font></td>\n";
			echo "<td><font size=1> &nbsp; <a href=\"$PHP_SELF?ADD=3321&stage=DELETE&did_id=$did_id&user_start=$Xuser_start[$o]&extension=$Xextension[$o]\">"._QXZ("DELETE")."</a></td></tr>\n";
			$o++;
			}

		echo "</table>\n";
		echo "<input style='background-color:#$SSbutton_color' type=submit name=submit value=\""._QXZ("SUBMIT CHANGES")."\"></form><br><br>\n";

		echo "<br>"._QXZ("ADD NEW REMOTE AGENT EXTENSION OVERRIDE")."<BR><form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=3321>\n";
		echo "<input type=hidden name=stage value=ADD>\n";
		echo "<input type=hidden name=did_id value=\"$did_id\">\n";
		echo _QXZ("User Start").": <input type=text size=10 maxlength=20 name=user_start>\n";
		echo _QXZ("Extension").": <input type=text size=20 maxlength=20 name=extension><BR>\n";
		echo _QXZ("Description").": <input type=text size=50 maxlength=100 name=description>\n";
		echo "<input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("ADD")."'><BR>\n";

		echo "</center></FORM><br>\n";

		echo "<br><br><a href=\"$PHP_SELF?ADD=3311&did_id=$did_id\">"._QXZ("MODIFY THIS DID")."</a>\n";

		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=DIDS&stage=$did_id\">"._QXZ("Click here to see Admin changes to this DID")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=3511 modify call menu info in the system
######################
if ($ADD==3511)
	{
	if ($LOGmodify_dids==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=3511&menu_id=$menu_id";
			$modify_footer_refresh=1;
			}
		$temp_section_width = $section_width;
		if ($temp_section_width < 850) {$temp_section_width = 850;}
		$temp_main_section_width = ($temp_section_width + 50);
		echo "<TABLE WIDTH=$temp_main_section_width><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT menu_name,menu_prompt,menu_timeout,menu_timeout_prompt,menu_invalid_prompt,menu_repeat,menu_time_check,call_time_id,track_in_vdac,custom_dialplan_entry,tracking_group,dtmf_log,dtmf_field,user_group,qualify_sql,alt_dtmf_log,question,answer_signal from vicidial_call_menu where menu_id='$menu_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$menu_name =			$row[0];
		$menu_prompt =			$row[1];
		$menu_timeout =			$row[2];
		$menu_timeout_prompt =	$row[3];
		$menu_invalid_prompt =	$row[4];
		$menu_repeat =			$row[5];
		$menu_time_check =		$row[6];
		$call_time_id =			$row[7];
		$track_in_vdac =		$row[8];
		$custom_dialplan_entry= $row[9];
		$tracking_group =		$row[10];
		$dtmf_log =				$row[11];
		$dtmf_field =			$row[12];
		$user_group =			$row[13];
		$qualify_sql =			$row[14];
		$alt_dtmf_log =			$row[15];
		$question =				$row[16];
		$answer_signal =		$row[17];

		echo "<br>"._QXZ("MODIFY A CALL MENU RECORD").": $menu_id<form action=$PHP_SELF method=POST name=admin_form id=admin_form>\n";
		echo "<input type=hidden name=ADD value=4511>\n";
		echo "<input type=hidden name=menu_id value=\"$menu_id\">\n";
		echo "<center><TABLE width=1000 cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Menu ID").": </td><td align=left>$menu_id $NWB#call_menu-menu_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Menu Name").": </td><td align=left><input type=text name=menu_name size=40 maxlength=50 value=\"$menu_name\">$NWB#call_menu-menu_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">$user_group</option>\n";
		echo "</select>$NWB#call_menu-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Menu Prompt").": </td><td align=left><input type=text name=menu_prompt id=menu_prompt size=60 maxlength=255 value=\"$menu_prompt\"> <a href=\"javascript:launch_chooser('menu_prompt','date');\">"._QXZ("audio chooser")."</a> $NWB#call_menu-menu_prompt$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Menu Timeout").": </td><td align=left><input type=text name=menu_timeout size=10 maxlength=5 value=\"$menu_timeout\">$NWB#call_menu-menu_timeout$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Menu Timeout Prompt").": </td><td align=left><input type=text name=menu_timeout_prompt id=menu_timeout_prompt size=60 maxlength=255 value=\"$menu_timeout_prompt\"> <a href=\"javascript:launch_chooser('menu_timeout_prompt','date');\">"._QXZ("audio chooser")."</a> $NWB#call_menu-menu_timeout_prompt$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Menu Invalid Prompt").": </td><td align=left><input type=text name=menu_invalid_prompt id=menu_invalid_prompt size=60 maxlength=255 value=\"$menu_invalid_prompt\"> <a href=\"javascript:launch_chooser('menu_invalid_prompt','date');\">"._QXZ("audio chooser")."</a> $NWB#call_menu-menu_invalid_prompt$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Menu Repeat").": </td><td align=left><input type=text name=menu_repeat size=4 maxlength=3 value=\"$menu_repeat\">$NWB#call_menu-menu_repeat$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Menu Time Check").": </td><td align=left><select size=1 name=menu_time_check>\n";
		if ($menu_time_check > 0)
			{
			echo "<option value=\"0\">0 - "._QXZ("No Time Check")."</option><option selected value=\"1\">1 - "._QXZ("Time Check")."</option>\n";
			}
		else
			{
			echo "<option selected value=\"0\">0 - "._QXZ("No Time Check")."</option><option value=\"1\">1 - "._QXZ("Time Check")."</option>\n";
			}
		echo "	</select>$NWB#call_menu-menu_time_check$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=311111111&call_time_id=$call_time_id\">"._QXZ("Call Time").": </a></td><td align=left><select size=1 name=call_time_id>\n";
		echo "$call_times_list";
		echo "<option selected value=\"$call_time_id\">$call_time_id - $call_timename_list[$call_time_id]</option>\n";
		echo "</select>$NWB#call_menu-call_time_id$NWE ";
		$stmt="SELECT ct_holidays from vicidial_call_times where call_time_id='$call_time_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$call_times_to_print = mysqli_num_rows($rslt);
		if ($call_times_to_print > 0) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$ct_holidays =	$rowx[0];
			$holiday_rules = explode('|',$ct_holidays);
			$ct_hrs = ((count($holiday_rules)) - 2);
			if ($ct_hrs < 0) {$ct_hrs=0;}
			echo " &nbsp; "._QXZ("Holidays defined for this call time").": $ct_hrs\n";
			}
		else
			{echo "<BLINK><B><font color=red>"._QXZ("Call time not found")."!</font></B></BLINK>\n";}
		echo "</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Track Calls in Real-Time Report").": </td><td align=left><select size=1 name=track_in_vdac>";
		if ($track_in_vdac > 0)
			{
			echo "<option value=\"0\">0 - "._QXZ("No Realtime Tracking")."</option><option selected value=\"1\">1 - "._QXZ("Realtime Tracking")."</option>\n";
			}
		else
			{
			echo "<option selected value=\"0\">0 - "._QXZ("No Realtime Tracking")."</option><option value=\"1\">1 - "._QXZ("Realtime Tracking")."</option>\n";
			}
		echo "</select>$NWB#call_menu-track_in_vdac$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Tracking Group").": </td><td align=left><select size=1 name=tracking_group>\n";
		echo "<option value=\"CALLMENU\">CALLMENU - "._QXZ("Default")."</option>\n";
		echo "$ingroup_list";
		echo "<option selected value=\"$tracking_group\">$tracking_group</option>\n";
		echo "</select>$NWB#call_menu-tracking_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Log Key Press").": </td><td align=left><select size=1 name=dtmf_log>";
		if ($dtmf_log > 0)
			{
			echo "<option value=\"0\">0 - "._QXZ("No DTMF Logging")."</option><option selected value=\"1\">1 - "._QXZ("DTMF Logging Enabled")."</option>\n";
			}
		else
			{
			echo "<option selected value=\"0\">0 - "._QXZ("No DTMF Logging")."</option><option value=\"1\">1 - "._QXZ("DTMF Logging Enabled")."</option>\n";
			}

		if (file_exists('options.php'))
			{require('options.php');}
		$extended_vl_fields_OPTIONS='';
		if ($extended_vl_fields > 0)
			{
			$extended_vl_fields_OPTIONS = '<option>q01</option><option>q02</option><option>q03</option><option>q04</option><option>q05</option><option>q06</option><option>q07</option><option>q08</option><option>q09</option><option>q10</option><option>q11</option><option>q12</option><option>q13</option><option>q14</option><option>q15</option><option>q16</option><option>q17</option><option>q18</option><option>q19</option><option>q20</option><option>q21</option><option>q22</option><option>q23</option><option>q24</option><option>q25</option><option>q26</option><option>q27</option><option>q28</option><option>q29</option><option>q30</option><option>q31</option><option>q32</option><option>q33</option><option>q34</option><option>q35</option><option>q36</option><option>q37</option><option>q38</option><option>q39</option><option>q40</option><option>q41</option><option>q42</option><option>q43</option><option>q44</option><option>q45</option><option>q46</option><option>q47</option><option>q48</option><option>q49</option><option>q50</option><option>q51</option><option>q52</option><option>q53</option><option>q54</option><option>q55</option><option>q56</option><option>q57</option><option>q58</option><option>q59</option><option>q60</option><option>q61</option><option>q62</option><option>q63</option><option>q64</option><option>q65</option><option>q66</option><option>q67</option><option>q68</option><option>q69</option><option>q70</option><option>q71</option><option>q72</option><option>q73</option><option>q74</option><option>q75</option><option>q76</option><option>q77</option><option>q78</option><option>q79</option><option>q80</option><option>q81</option><option>q82</option><option>q83</option><option>q84</option><option>q85</option><option>q86</option><option>q87</option><option>q88</option><option>q89</option><option>q90</option><option>q91</option><option>q92</option><option>q93</option><option>q94</option><option>q95</option><option>q96</option><option>q97</option><option>q98</option><option>q99</option>';
			}

		echo "</select>$NWB#call_menu-dtmf_log$NWE &nbsp; &nbsp; "._QXZ("Log Field").": \n";
		echo "<select size=1 name=dtmf_field><option value='NONE'>"._QXZ("NONE")."</option><option>vendor_lead_code</option><option>source_id</option><option>phone_code</option><option>title</option><option>first_name</option><option>middle_initial</option><option>last_name</option><option>address1</option><option>address2</option><option>address3</option><option>city</option><option>state</option><option>province</option><option>postal_code</option><option>country_code</option><option>alt_phone</option><option>email</option><option>security_phrase</option><option>comments</option><option>rank</option><option>owner</option><option>status</option><option>user</option><option value=\"$dtmf_field\" SELECTED>"._QXZ("$dtmf_field")."</option>$extended_vl_fields_OPTIONS</select>$NWB#call_menu-dtmf_field$NWE</td></tr>\n";

		if ($SSalt_ivr_logging > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Alt DTMF Log").": </td><td align=left><select size=1 name=alt_dtmf_log>";
			if ($alt_dtmf_log > 0)
				{
				echo "<option value=\"0\">0 - "._QXZ("Alt DTMF Logging Disabled")."</option><option selected value=\"1\">1 - "._QXZ("Alt DTMF Logging Enabled")."</option>\n";
				}
			else
				{
				echo "<option selected value=\"0\">0 - "._QXZ("Alt DTMF Logging Disabled")."</option><option value=\"1\">1 - "._QXZ("Alt DTMF Logging Enabled")."</option>\n";
				}
			echo "</select>$NWB#call_menu-alt_dtmf_log$NWE &nbsp; &nbsp; "._QXZ("Question").": \n";
			echo "<input type=text name=question size=10 value=\"$question\">$NWB#call_menu-question$NWE</td></tr>\n";
			}
		else
			{echo "<tr bgcolor=#$SSstd_row4_background><td align=right></td><td align=left><input type=hidden name=alt_dtmf_log value=\"$alt_dtmf_log\"><input type=hidden name=question value=\"$question\"></td></tr>";}

		if ($SSinbound_answer_config > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Beginning Answer Signal").": </td><td align=left><select size=1 name=answer_signal><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$answer_signal' SELECTED>"._QXZ("$answer_signal")."</option></select>$NWB#call_menu-answer_signal$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right></td><td align=left><input type=hidden name=answer_signal value='Y'></td></tr>";
			}

		echo "<tr><td align=center colspan=2> <input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'> </td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=CENTER colspan=2> "._QXZ("Call Menu Options").": </td></tr>\n";

		$j=0;
		$stmtA="SELECT option_value,option_description,option_route,option_route_value,option_route_value_context from vicidial_call_menu_options where menu_id='$menu_id' order by option_value;";
		$rslt=mysql_to_mysqli($stmtA, $link);
		$menus_to_print = mysqli_num_rows($rslt);

		while ($menus_to_print > $j)
			{
			$row=mysqli_fetch_row($rslt);
			$Aoption_value[$j] =				$row[0];
			$Aoption_description[$j] =			$row[1];
			$Aoption_route[$j] =				$row[2];
			$Aoption_route_value[$j] =			$row[3];
			$Aoption_route_value_context[$j] =	$row[4];
			$j++;
			}

		$j=0;
		while ($menus_to_print > $j)
			{
			$choose_height = (($j * 100) + 550);
			$option_value =					$Aoption_value[$j];
			$option_description =			$Aoption_description[$j];
			$option_route =					$Aoption_route[$j];
			$option_route_value =			$Aoption_route_value[$j];
			$option_route_value_context =	$Aoption_route_value_context[$j];

			$dtmf_list = "<select size=1 name=option_value_$j id=option_value_$j>";
			$h=0;
			while ($h <= 20)
				{
				$dtmf_list .= "<option";
				if ( (preg_match("/$dtmf[$h]/",$option_value) and (strlen($option_value) == strlen($dtmf[$h])) ) )
					{$dtmf_list .= " selected";}
				$dtmf_list .= " value=\"$dtmf[$h]\"> $dtmf_key[$h]</option>";
				$h++;
				}
			$dtmf_list .= "</select>";

			if (preg_match("/1$|3$|5$|7$|9$/i", $j))
				{$bgcolor='bgcolor="#CCFFFF"';} 
			else
				{$bgcolor='bgcolor="#99FFCC"';}

			echo "<tr $bgcolor><td align=CENTER colspan=2> 
			"._QXZ("Option").": $dtmf_list &nbsp; 
			"._QXZ("Description").": <input type=text name=option_description_$j id=option_description_$j size=40 maxlength=255 value=\"$option_description\"> 
			"._QXZ("Route").": <select size=1 name=option_route_$j id=option_route_$j onChange=\"call_menu_option('$j','$option_route','$option_route_value','$option_route_value_context','$choose_height');\">
				<option value='CALLMENU'>"._QXZ("CALLMENU")."</option>
				<option value='INGROUP'>"._QXZ("INGROUP")."</option>
				<option value='DID'>"._QXZ("DID")."</option>
				<option value='HANGUP'>"._QXZ("HANGUP")."</option>
				<option value='EXTENSION'>"._QXZ("EXTENSION")."</option>
				<option value='PHONE'>"._QXZ("PHONE")."</option>
				<option value='VOICEMAIL'>"._QXZ("VOICEMAIL")."</option>
				<option value='VMAIL_NO_INST'>"._QXZ("VMAIL_NO_INST")."</option>
				<option value='AGI'>"._QXZ("AGI")."</option>
				<option value=\"\">* "._QXZ("REMOVE")." *</option>
				<option selected value=\"$option_route\">$option_route</option>
			</select>		$NWB#call_menu-option_value$NWE ";
			
			if ($j > 0) {echo "<span id='cm_copy_$j' name='cm_copy_$j' onclick=\"copy_prev_cm_option('$j','$choose_height');\"><font size=1><u>copy ^</u></font></span> ";}
			else {echo "<span id='cm_copy_$j' name='cm_copy_$j'><font size=1> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </font></span> ";}

			echo "<BR>
			<span id=\"option_value_value_context_$j\" name=\"option_value_value_context_$j\">\n";

			if ($option_route=='CALLMENU')
				{
				echo "<span name=option_route_link_$j id=option_route_link_$j>";
				echo "<a href=\"$PHP_SELF?ADD=3511&menu_id=$option_route_value\">"._QXZ("Call Menu").":</a>";
				echo "</span>";
				echo " <select size=1 name=option_route_value_$j id=option_route_value_$j onChange=\"call_menu_link('$j','CALLMENU');\">$call_menu_list<option SELECTED>$option_route_value</option></select>\n";
				}
			if ($option_route=='INGROUP')
				{
				if (strlen($option_route_value_context) < 10)
					{$option_route_value_context = 'CID,LB,998,TESTCAMP,1,,,,,';}
				$IGoption_route_value_context = explode(",",$option_route_value_context);
				$IGhandle_method =			$IGoption_route_value_context[0];
				$IGsearch_method =			$IGoption_route_value_context[1];
				$IGlist_id =				$IGoption_route_value_context[2];
				$IGcampaign_id =			$IGoption_route_value_context[3];
				$IGphone_code =				$IGoption_route_value_context[4];
				$IGvid_enter_filename =		$IGoption_route_value_context[5];
				$IGvid_id_number_filename =	$IGoption_route_value_context[6];
				$IGvid_confirm_filename =	$IGoption_route_value_context[7];
				$IGvid_validate_digits =	$IGoption_route_value_context[8];
				$IGvid_container =			$IGoption_route_value_context[9];

				echo "<span name=option_route_link_$j id=option_route_link_$j>";
				echo "<a href=\"$PHP_SELF?ADD=3111&group_id=$option_route_value\">"._QXZ("In-Group").":</a>";
				echo "</span>";
				echo " <input type=hidden name=option_route_value_context_$j id=option_route_value_context_$j value=\"$option_route_value_context\">";
				echo " <select size=1 name=option_route_value_$j id=option_route_value_$j onChange=\"call_menu_link('$j','INGROUP');\">";
				echo "$ingroup_list<option SELECTED>$option_route_value</option><option>DYNAMIC_INGROUP_VAR</option></select>";
				echo " &nbsp; "._QXZ("Handle Method").": <select size=1 name=IGhandle_method_$j id=IGhandle_method_$j>";
				echo "<option SELECTED>$IGhandle_method</option>$IGhandle_method_list</select> $NWB#call_menu-ingroup_settings$NWE\n";
				echo "<BR>"._QXZ("Search Method").": <select size=1 name=IGsearch_method_$j id=IGsearch_method_$j>";
				echo "$IGsearch_method_list<option SELECTED>$IGsearch_method</option></select>\n";
				echo " &nbsp; "._QXZ("List ID").": <input type=text size=5 maxlength=19 name=IGlist_id_$j id=IGlist_id_$j value=\"$IGlist_id\">";
				echo "<BR>"._QXZ("Campaign ID").": <select size=1 name=IGcampaign_id_$j id=IGcampaign_id_$j>";
				echo "$IGcampaign_id_list<option SELECTED>$IGcampaign_id</option></select>\n";
				echo " &nbsp; "._QXZ("Phone Code").": <input type=text size=5 maxlength=14 name=IGphone_code_$j id=IGphone_code_$j value=\"$IGphone_code\">";
				echo "<BR> &nbsp; "._QXZ("VID Enter Filename").": <input type=text name=IGvid_enter_filename_$j id=IGvid_enter_filename_$j size=40 maxlength=255 value=\"$IGvid_enter_filename\"> <a href=\"javascript:launch_chooser('IGvid_enter_filename_$j','date');\">"._QXZ("audio chooser")."</a>";
				echo "<BR> &nbsp; "._QXZ("VID ID Number Filename").": <input type=text name=IGvid_id_number_filename_$j id=IGvid_id_number_filename_$j size=40 maxlength=255 value=\"$IGvid_id_number_filename\"> <a href=\"javascript:launch_chooser('IGvid_id_number_filename_$j','date');\">"._QXZ("audio chooser")."</a>";
				echo "<BR> &nbsp; "._QXZ("VID Confirm Filename").": <input type=text name=IGvid_confirm_filename_$j id=IGvid_confirm_filename_$j size=40 maxlength=255 value=\"$IGvid_confirm_filename\"> <a href=\"javascript:launch_chooser('IGvid_confirm_filename_$j','date');\">"._QXZ("audio chooser")."</a>";
				echo " &nbsp; "._QXZ("VID Digits").": <input type=text size=3 maxlength=3 name=IGvid_validate_digits_$j id=IGvid_validate_digits_$j value=\"$IGvid_validate_digits\">";
				echo "<BR> &nbsp; "._QXZ("VID Container").": <input type=text size=40 maxlength=40 name=IGvid_container_$j id=IGvid_container_$j value=\"$IGvid_container\"> $NWB#call_menu-ingroup_vid_container$NWE <a href=\"javascript:launch_container_chooser('IGvid_container_$j','date','CM_VIDPROMPT_SPECIAL');\">"._QXZ("container chooser")."</a>";
				}
			if ($option_route=='DID')
				{
				$stmt="SELECT did_id from vicidial_inbound_dids where did_pattern='$option_route_value' $LOGadmin_viewable_groupsSQL;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				$did_id =			$row[0];

				echo "<span name=option_route_link_$j id=option_route_link_$j>";
				echo "<a href=\"$PHP_SELF?ADD=3311&did_id=$did_id\">"._QXZ("DID").":</a>";
				echo "</span>";
				echo " <select size=1 name=option_route_value_$j id=option_route_value_$j onChange=\"call_menu_link('$j','DID');\">$did_list<option SELECTED>$option_route_value</option></select>\n";
				}
			if ($option_route=='HANGUP')
				{
				echo _QXZ("Audio File").": <input type=text name=option_route_value_$j id=option_route_value_$j size=50 maxlength=255 value=\"$option_route_value\"> <a href=\"javascript:launch_chooser('option_route_value_$j','date');\">"._QXZ("audio chooser")."</a>\n";
				}
			if ($option_route=='EXTENSION')
				{
				echo _QXZ("Extension").": <input type=text name=option_route_value_$j id=option_route_value_$j size=20 maxlength=255 value=\"$option_route_value\"> &nbsp; "._QXZ("Context").": <input type=text name=option_route_value_context_$j id=option_route_value_context_$j size=20 maxlength=255 value=\"$option_route_value_context\">\n";
				}
			if ($option_route=='PHONE')
				{
				echo _QXZ("Phone").": <select size=1 name=option_route_value_$j id=option_route_value_$j>$phone_list<option SELECTED>$option_route_value</option></select>\n";
				}
			if ( ($option_route=='VOICEMAIL') or ($option_route=='VMAIL_NO_INST') )
				{
				echo _QXZ("Voicemail Box").": <input type=text name=option_route_value_$j id=option_route_value_$j size=12 maxlength=10 value=\"$option_route_value\"> <a href=\"javascript:launch_vm_chooser('option_route_value_$j','vm');\">"._QXZ("voicemail chooser")."</a>\n";
				}
			if ($option_route=='AGI')
				{
				echo _QXZ("AGI").": <input type=text name=option_route_value_$j id=option_route_value_$j size=80 maxlength=255 value=\"$option_route_value\">\n";
				}

			echo "</span>
			<BR> &nbsp; </td></tr>\n";
			$j++;
			}

		while ($j <= 20)
			{
			$choose_height = (($j * 100) + 550);
			$dtmf_list = "<select size=1 name=option_value_$j id=option_value_$j><option value=\"\"></option>";
			$h=0;
			while ($h <= 20)
				{
				$dtmf_list .= "<option value=\"$dtmf[$h]\"> $dtmf_key[$h]</option>";
				$h++;
				}
			$dtmf_list .= "</select>";

			if (preg_match("/1$|3$|5$|7$|9$/i", $j))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

			echo "<tr $bgcolor><td align=CENTER colspan=2> 
			"._QXZ("Option").": $dtmf_list &nbsp; 
			"._QXZ("Description").": <input type=text name=option_description_$j id=option_description_$j size=40 maxlength=255 value=\"\">  
			"._QXZ("Route").": <select size=1 name=option_route_$j id=option_route_$j onChange=\"call_menu_option('$j','','','','$choose_height');\">
				<option value='CALLMENU'>"._QXZ("CALLMENU")."</option>
				<option value='INGROUP'>"._QXZ("INGROUP")."</option>
				<option value='DID'>"._QXZ("DID")."</option>
				<option value='HANGUP'>"._QXZ("HANGUP")."</option>
				<option value='EXTENSION'>"._QXZ("EXTENSION")."</option>
				<option value='PHONE'>"._QXZ("PHONE")."</option>
				<option value='VOICEMAIL'>"._QXZ("VOICEMAIL")."</option>
				<option value='VMAIL_NO_INST'>"._QXZ("VMAIL_NO_INST")."</option>
				<option value='AGI'>"._QXZ("AGI")."</option>
				<option SELECTED value=\"\"> </option>
			</select> 
			$NWB#call_menu-option_value$NWE ";
			
			if ($j > 0) {echo "<span id='cm_copy_$j' name='cm_copy_$j' onclick=\"copy_prev_cm_option('$j','$choose_height');\"><font size=1><u>copy ^</u></font></span> ";}
			else {echo "<span id='cm_copy_$j' name='cm_copy_$j'><font size=1> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </font></span> ";}

			echo "<BR>
			<span id=\"option_value_value_context_$j\" name=\"option_value_value_context_$j\">\n";
			echo "</span>
			<BR> &nbsp; </td></tr>\n";
			$j++;
			}

		if ( ($SSallow_custom_dialplan > 0) and ($LOGmodify_custom_dialplans > 0) )
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom Dialplan Entry").": <BR> $NWB#call_menu-custom_dialplan_entry$NWE</td><td align=left><TEXTAREA NAME=custom_dialplan_entry ROWS=5 COLS=70>$custom_dialplan_entry</TEXTAREA></td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom Dialplan Entry").": </td><td align=left>"._QXZ("Disabled")." <input type=hidden name=custom_dialplan_entry value=\"\">$NWB#call_menu-custom_dialplan_entry$NWE</td></tr>\n";
			}

		if ($SScall_menu_qualify_enabled > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Qualify SQL").": <BR> $NWB#call_menu-qualify_sql$NWE</td><td align=left><TEXTAREA NAME=qualify_sql ROWS=5 COLS=70>$qualify_sql</TEXTAREA></td></tr>\n";
			}
		else
			{echo "<tr bgcolor=#$SSstd_row4_background><td align=right> </td><td align=left> <input type=hidden name=qualify_sql value=\"\"></td></tr>\n";}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</table>\n";
		echo "<BR></center></FORM><br>\n";

		echo "<B>"._QXZ("DIDS USING THIS CALL MENU").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT did_id,did_pattern,did_description from vicidial_inbound_dids where menu_id='$menu_id' and did_route='CALLMENU' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$dids_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($dids_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=3311&did_id=$row[0]\">$row[1] </a></TD><TD> $row[2]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE><BR>\n";

		echo "<B>"._QXZ("CALL MENUS USING THIS CALL MENU").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT distinct vm.menu_id,menu_name from vicidial_call_menu vm,vicidial_call_menu_options vmo where vm.menu_id=vmo.menu_id and option_route='CALLMENU' and option_route_value='$menu_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$cms_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($cms_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=3511&menu_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE><BR>\n";


		echo "<B>"._QXZ("CAMPAIGNS USING THIS CALL MENU").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where (safe_harbor_menu_id='$menu_id' or survey_menu_id='$menu_id' or amd_callmenu='$menu_id' or ((agent_hangup_route='CALLMENU' and agent_hangup_value='$menu_id') ) ) $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$camps_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($camps_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=31&campaign_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE><BR>\n";


		echo "<B>"._QXZ("IN-GROUPS USING THIS CALL MENU").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT group_id,group_name from vicidial_inbound_groups where (hold_time_option_callmenu='$menu_id' or wait_time_option_callmenu='$menu_id' or drop_callmenu='$menu_id' or after_hours_callmenu='$menu_id') $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$ingrps_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($ingrps_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=3111&group_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE><BR>\n";


		if ($LOGdelete_dids > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=5511&menu_id=$menu_id\">"._QXZ("DELETE THIS CALL MENU")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=CALLMENUS&stage=$menu_id\">"._QXZ("Click here to see Admin changes to this CALL MENU")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=31111 modify remote agents info in the system
######################
if ($ADD==31111)
	{
	if ( ($LOGmodify_remoteagents==1) and ($x_ra_carrier < 1) )
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=31111&remote_agent_id=$remote_agent_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT remote_agent_id,user_start,number_of_lines,server_ip,conf_exten,status,campaign_id,closer_campaigns,extension_group,on_hook_agent,on_hook_ring_time from vicidial_remote_agents where remote_agent_id='$remote_agent_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$remote_agent_id =	$row[0];
		$user_start =		$row[1];
		$number_of_lines =	$row[2];
		$server_ip =		$row[3];
		$conf_exten =		$row[4];
		$status =			$row[5];
		$campaign_id =		$row[6];
		$extension_group =	$row[8];
		$on_hook_agent =	$row[9];
		$on_hook_ring_time =$row[10];

		##### get user_group of start_user
		$stmt="SELECT user_group from vicidial_users where user='$user_start' $LOGadmin_viewable_groupsSQL;";
		$rsltx=mysql_to_mysqli($stmt, $link);
		$vu_to_print = mysqli_num_rows($rsltx);
		if ($vu_to_print > 0)
			{
			$rowx=mysqli_fetch_row($rsltx);
			$user_group = $rowx[0];

			##### get extension group listing for dynamic pulldown
			$stmt="SELECT extension_group_id,count(*) from vicidial_extension_groups group by extension_group_id order by extension_group_id;";
			$rsltx=mysql_to_mysqli($stmt, $link);
			$extengrp_to_print = mysqli_num_rows($rsltx);
			$extengrp_list='';
			$o=0;
			while ($extengrp_to_print > $o)
				{
				$rowx=mysqli_fetch_row($rsltx);
				$extengrp_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$o++;
				}

			echo "<br>"._QXZ("MODIFY A REMOTE AGENTS ENTRY").": $row[0]<form action=$PHP_SELF method=POST>\n";
			echo "<input type=hidden name=ADD value=41111>\n";
			echo "<input type=hidden name=DB value=\"$DB\">\n";
			echo "<input type=hidden name=remote_agent_id value=\"$row[0]\">\n";
			echo "<center><TABLE width=$section_width cellspacing=3>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=3&user=$user_start\">"._QXZ("User ID Start")."</a>: </td><td align=left><input type=text name=user_start size=9 maxlength=9 value=\"$user_start\"> ("._QXZ("numbers only, incremented, must be an existing vicidial user").")$NWB#remote_agents-user_start$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Number of Lines").": </td><td align=left><input type=text name=number_of_lines size=3 maxlength=3 value=\"$number_of_lines\"> ("._QXZ("numbers only").")$NWB#remote_agents-number_of_lines$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Server IP").": </td><td align=left><select size=1 name=server_ip>\n";
			echo "$servers_list";
			echo "<option SELECTED>$row[3]</option>\n";
			echo "</select>$NWB#remote_agents-server_ip$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("External Extension").": </td><td align=left><input type=text name=conf_exten size=20 maxlength=20 value=\"$conf_exten\"> ("._QXZ("dial plan number dialed to reach agents").")$NWB#remote_agents-conf_exten$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Extension Group").": </td><td align=left><select size=1 name=extension_group>\n";
			echo "$extengrp_list";
			echo "<option value='NONE'>"._QXZ("NONE")."</option>\n";
			echo "<option value='$extension_group' SELECTED>"._QXZ("$extension_group")."</option>\n";
			echo "</select>$NWB#remote_agents-extension_group$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Status").": </td><td align=left><select size=1 name=status><option value='ACTIVE'>"._QXZ("ACTIVE")."</option><option value='INACTIVE'>"._QXZ("INACTIVE")."</option><option value='$status' SELECTED>"._QXZ("$status")."</option></select>$NWB#remote_agents-status$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=31&campaign_id=$campaign_id\">"._QXZ("Campaign")."</a>: </td><td align=left><select size=1 name=campaign_id>\n";
			echo "$campaigns_list";
			echo "<option SELECTED>$campaign_id</option>\n";
			echo "</select>$NWB#remote_agents-campaign_id$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("On-Hook Agent").": </td><td align=left><select size=1 name=on_hook_agent><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$on_hook_agent' SELECTED>"._QXZ("$on_hook_agent")."</option></select>$NWB#remote_agents-on_hook_agent$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("On-Hook Ring Time").": </td><td align=left><input type=text name=on_hook_ring_time size=5 maxlength=4 value=\"$on_hook_ring_time\"> $NWB#remote_agents-on_hook_ring_time$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>\n";
				$temp_chart_title = _QXZ("8 Day call count for this remote-agent");
				horizontal_bar_chart($user_start,'8','remote-agent',$link,'ra_total_calls','call count',1,'','',$temp_chart_title);
			echo "</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top>"._QXZ("Inbound Groups").": <BR>$NWB#remote_agents-closer_campaigns$NWE</td><td align=left>\n";
			echo "$groups_list";
			echo "</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
			echo "</TABLE></center>\n";
			echo _QXZ("NOTE: It can take up to 30 seconds for changes submitted on this screen to go live")."\n";

			##### get count of did ra extens
			$stmt="SELECT count(*) from vicidial_did_ra_extensions where user_start='$user_start';";
			$rsltx=mysql_to_mysqli($stmt, $link);
			$didraext_to_print = mysqli_num_rows($rsltx);
			$didraext_count='0';
			if ($didraext_to_print > 0)
				{
				$rowx=mysqli_fetch_row($rsltx);
				$didraext_count = $rowx[0];
				}

			if ($SSdid_ra_extensions_enabled > 0)
				{
				echo "<br><br><a href=\"$PHP_SELF?ADD=1320\">"._QXZ("THERE ARE")." $didraext_count "._QXZ("DID REMOTE AGENT EXTENSION OVERRIDES FOR THIS REMOTE AGENT")."</a>\n";
				}
			if ($LOGdelete_remote_agents > 0)
				{
				echo "<br><br><a href=\"$PHP_SELF?ADD=51111&remote_agent_id=$remote_agent_id\">"._QXZ("DELETE THIS REMOTE AGENT")."</a>\n";
				}
			if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
				{
				echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=REMOTEAGENTS&stage=$remote_agent_id\">"._QXZ("Click here to see Admin changes to this remote agent")."</FONT>\n";
				}
			}
		else
			{
			echo "<b>"._QXZ("User Start for this remote agent does not exist as a User").": $user_start</b><BR>\n";

			echo "<br><b>"._QXZ("MODIFY AN ORPHAN REMOTE AGENTS ENTRY").": $row[0]</b><form action=$PHP_SELF method=POST>\n";
			echo "<input type=hidden name=ADD value=41111>\n";
			echo "<input type=hidden name=DB value=\"$DB\">\n";
			echo "<input type=hidden name=stage value=\"ORPHAN\">\n";
			echo "<input type=hidden name=remote_agent_id value=\"$row[0]\">\n";
			echo "<center><TABLE width=$section_width cellspacing=3>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=3&user=$user_start\">"._QXZ("User ID Start")."</a>: </td><td align=left><input type=text name=user_start size=9 maxlength=9 value=\"$user_start\"> ("._QXZ("numbers only, incremented, must be an existing vicidial user").")$NWB#remote_agents-user_start$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Number of Lines").": </td><td align=left><input type=text name=number_of_lines size=3 maxlength=3 value=\"$number_of_lines\"> ("._QXZ("numbers only").")$NWB#remote_agents-number_of_lines$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Server IP").": </td><td align=left><select size=1 name=server_ip>\n";
			echo "$servers_list";
			echo "<option SELECTED>$row[3]</option>\n";
			echo "</select>$NWB#remote_agents-server_ip$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("External Extension").": </td><td align=left><input type=text name=conf_exten size=20 maxlength=20 value=\"$conf_exten\"> ("._QXZ("dial plan number dialed to reach agents").")$NWB#remote_agents-conf_exten$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Extension Group").": </td><td align=left><select size=1 name=extension_group>\n";
			echo "<option value='NONE'>"._QXZ("NONE")."</option>\n";
			echo "<option value='$extension_group' SELECTED>"._QXZ("$extension_group")."</option>\n";
			echo "</select>$NWB#remote_agents-extension_group$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Status").": </td><td align=left><select size=1 name=status><option value='ACTIVE'>"._QXZ("ACTIVE")."</option><option value='INACTIVE'>"._QXZ("INACTIVE")."</option><option value='$status' SELECTED>"._QXZ("$status")."</option></select>$NWB#remote_agents-status$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=31&campaign_id=$campaign_id\">"._QXZ("Campaign")."</a>: </td><td align=left><select size=1 name=campaign_id>\n";
			echo "<option SELECTED>$campaign_id</option>\n";
			echo "</select>$NWB#remote_agents-campaign_id$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("On-Hook Agent").": </td><td align=left><select size=1 name=on_hook_agent><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$on_hook_agent' SELECTED>"._QXZ("$on_hook_agent")."</option></select>$NWB#remote_agents-on_hook_agent$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("On-Hook Ring Time").": </td><td align=left><input type=text name=on_hook_ring_time size=5 maxlength=4 value=\"$on_hook_ring_time\"> $NWB#remote_agents-on_hook_ring_time$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>\n";
				$temp_chart_title = _QXZ("8 Day call count for this remote-agent");
				horizontal_bar_chart($user_start,'8','remote-agent',$link,'ra_total_calls','call count',1,'','',$temp_chart_title);
			echo "</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Inbound Groups").": </td><td align=left>\n";
			echo "$NWB#remote_agents-closer_campaigns$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
			echo "</TABLE></center>\n";
			echo _QXZ("NOTE: It can take up to 30 seconds for changes submitted on this screen to go live")."\n";
			exit;
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=3711 modify filter phone group info in the system
######################
if ($ADD==3711)
	{
	if ($LOGmodify_dids==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=3711&filter_phone_group_id=$filter_phone_group_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT filter_phone_group_id,filter_phone_group_name,filter_phone_group_description,user_group from vicidial_filter_phone_groups where filter_phone_group_id='$filter_phone_group_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$filter_phone_group_id =			$row[0];
		$filter_phone_group_name =			$row[1];
		$filter_phone_group_description =	$row[2];
		$user_group =						$row[3];

		echo "<br>"._QXZ("Modify Filter Phone Group").": $filter_phone_group_id<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=4711>\n";
		echo "<input type=hidden name=filter_phone_group_id value=\"$filter_phone_group_id\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Filter Phone Group ID").": </td><td align=left> <B>$filter_phone_group_id</B> $NWB#filter_phone_groups-filter_phone_group_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Filter Phone Group Name").": </td><td align=left><input type=text name=filter_phone_group_name size=40 maxlength=40 value=\"$filter_phone_group_name\"> $NWB#filter_phone_groups-filter_phone_group_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Filter Phone Group Description").": </td><td align=left><input type=text name=filter_phone_group_description size=60 maxlength=100 value=\"$filter_phone_group_description\"> $NWB#filter_phone_groups-filter_phone_group_description$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">".(preg_match('/\-\-ALL\-\-/', $user_group) ? _QXZ("$user_group") : $user_group)."</option>\n";
		echo "</select>$NWB#filter_phone_groups-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";

		$stmt="SELECT count(*) from vicidial_filter_phone_numbers where filter_phone_group_id='$filter_phone_group_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		echo "<br><br>"._QXZ("Numbers in this Filter Phone Group").": $row[0]";

		if ($LOGdelete_dids > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=5711&filter_phone_group_id=$filter_phone_group_id\">"._QXZ("DELETE THIS FILTER PHONE GROUP")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Download List/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"./list_download.php?group_id=$filter_phone_group_id&download_type=fpgn\">"._QXZ("Click here to download the numbers in this filter phone group")."</FONT>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=FILTERPHONEGROUPS&stage=$filter_phone_group_id\">"._QXZ("Click here to see Admin changes to this filter phone group")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=32111 modify extension group entry in the system
######################
if ($ADD==32111)
	{
	if ($LOGmodify_remoteagents==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=32111&extension_id=$extension_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT extension_id,extension_group_id,extension,rank,campaign_groups,call_count_today,last_call_time,last_callerid from vicidial_extension_groups where extension_id='$extension_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$extension_id =			$row[0];
		$extension_group_id =	$row[1];
		$extension =			$row[2];
		$rank =					$row[3];
		$campaign_groups =		$row[4];
		$call_count_today =		$row[5];
		$last_call_time =		$row[6];
		$last_callerid =		$row[7];

		echo "<br>"._QXZ("MODIFY AN EXTENSION GROUP ENTRY").": $row[0]<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=42111>\n";
		echo "<input type=hidden name=extension_id value=\"$extension_id\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Extension Group").": </td><td align=left><input type=text name=extension_group_id size=20 maxlength=20 value=\"$extension_group_id\"> ("._QXZ("no spaces").")$NWB#extension_groups-extension_group_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Extension").": </td><td align=left><input type=text name=extension size=18 maxlength=18 value=\"$extension\"> ("._QXZ("numbers only").")$NWB#extension_groups-extension$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Rank").": </td><td align=left><select size=1 name=rank>\n";
		$n=99;
		$rankfound=0;
		while ($n>=-99)
			{
			if ($n == $rank) 
				{echo "<option SELECTED value=\"$n\">$n</option>\n";   $rankfound++;}
			else
				{echo "<option value=\"$n\">$n</option>\n";}
			$n--;
			}
		if ($rankfound < 1)
			{echo "<option SELECTED value=\"$rank\">$rank</option>\n";}

		echo "</select> $NWB#extension_groups-rank$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Campaigns Groups").": </td><td align=left><input type=text name=campaign_groups size=50 maxlength=255 value=\"$campaign_groups\"> ("._QXZ("pipe-delimited list").")$NWB#extension_groups-campaign_groups$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Call Count Today").": </td><td align=left>$call_count_today</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Last Call Time").": </td><td align=left>$last_call_time</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Last Call ID").": </td><td align=left>$last_callerid</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";

		if ($LOGdelete_remote_agents > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=52111&extension_id=$extension_id\">"._QXZ("DELETE THIS EXTENSION GROUP ENTRY")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=EXTENGROUP&stage=$extension_id\">"._QXZ("Click here to see Admin changes to this extension group entry")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=311111 modify user group info in the system
######################
if ($ADD==311111)
	{
	if ($LOGmodify_usergroups==1)
		{
		if ( ($LOGmodify_same_user_level < 1) and ($user_group=="$LOGuser_group") )
			{
			echo _QXZ("You are not allowed to edit your own user group")."\n";
			exit;
			}
		else
			{
			if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
				{
				$modify_url = "$PHP_SELF?ADD=311111&user_group=$user_group";
				$modify_footer_refresh=1;
				}
			echo "<TABLE><TR><TD>\n";
			echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

			$stmt="SELECT user_group,group_name,allowed_campaigns,qc_allowed_campaigns,qc_allowed_inbound_groups,group_shifts,forced_timeclock_login,shift_enforcement,agent_status_viewable_groups,agent_status_view_time,agent_call_log_view,agent_xfer_consultative,agent_xfer_dial_override,agent_xfer_vm_transfer,agent_xfer_blind_transfer,agent_xfer_dial_with_customer,agent_xfer_park_customer_dial,agent_fullscreen,allowed_reports,webphone_url_override,webphone_systemkey_override,webphone_dialpad_override,admin_viewable_groups,admin_viewable_call_times,agent_allowed_chat_groups,agent_xfer_park_3way,admin_ip_list,agent_ip_list,api_ip_list,webphone_layout,reports_header_override,admin_home_url,script_id from vicidial_user_groups where user_group='$user_group' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			$user_group =						$row[0];
			$group_name =						$row[1];
			$GROUP_shifts =						$row[5];
			$forced_timeclock_login =			$row[6];
			$shift_enforcement =				$row[7];
			$VGROUP_vgroups =					$row[8];
			$agent_status_view_time =			$row[9];
			$agent_call_log_view =				$row[10];
			$agent_xfer_consultative =			$row[11];
			$agent_xfer_dial_override =			$row[12];
			$agent_xfer_vm_transfer =			$row[13];
			$agent_xfer_blind_transfer =		$row[14];
			$agent_xfer_dial_with_customer =	$row[15];
			$agent_xfer_park_customer_dial =	$row[16];
			$agent_fullscreen =					$row[17];
			$allowed_reports =					$row[18];
			$webphone_url_override =			$row[19];
			$webphone_systemkey_override =		$row[20];
			$webphone_dialpad_override =		$row[21];
			$admin_viewable_groups =			$row[22];
			$admin_viewable_call_times =		$row[23];
			$VGROUP_chatgroups =				$row[24];
			$agent_xfer_park_3way =				$row[25];
			$admin_ip_list =					$row[26];
			$agent_ip_list =					$row[27];
			$api_ip_list =						$row[28];
			$webphone_layout =					$row[29];
			$reports_header_override =			$row[30];
			$admin_home_url =					$row[31];
			$script_id =						$row[32];

			echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

			echo "<br>"._QXZ("MODIFY A USERS GROUP ENTRY")."<form action=$PHP_SELF method=POST>\n";
			echo "<input type=hidden name=ADD value=411111>\n";
			echo "<input type=hidden name=OLDuser_group value=\"$user_group\">\n";
			echo "<input type=hidden name=user_group value=\"$user_group\">\n";
			echo "<center><TABLE width=$section_width cellspacing=3>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group").": </td><td align=left>$user_group $NWB#user_groups-user_group$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Description").": </td><td align=left><input type=text name=group_name size=40 maxlength=40 value=\"$group_name\"> ("._QXZ("description of group").")$NWB#user_groups-group_name$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Force Timeclock Login").": </td><td align=left><select size=1 name=forced_timeclock_login><option value='N' SELECTED>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='ADMIN_EXEMPT'>"._QXZ("ADMIN_EXEMPT")."</option><option value='$forced_timeclock_login' SELECTED>"._QXZ("$forced_timeclock_login")."</option></select>$NWB#user_groups-forced_timeclock_login$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Shift Enforcement").": </td><td align=left><select size=1 name=shift_enforcement><option value='OFF' SELECTED>"._QXZ("OFF")."</option><option value='START'>"._QXZ("START")."</option><option value='ALL'>"._QXZ("ALL")."</option><option value='ADMIN_EXEMPT'>"._QXZ("ADMIN_EXEMPT")."</option><option VALUE='$shift_enforcement' SELECTED>"._QXZ("$shift_enforcement")."</option></select>$NWB#user_groups-shift_enforcement$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top>"._QXZ("Allowed Campaigns").": <BR>$NWB#user_groups-allowed_campaigns$NWE</td><td align=left>\n";
			echo "$campaigns_list <BR>&nbsp;";
			echo "</td></tr>\n";


			echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top>"._QXZ("Group Shifts").": <BR>$NWB#user_groups-group_shifts$NWE</td><td align=left>\n";
			$stmt="SELECT shift_id,shift_name from vicidial_shifts $whereLOGadmin_viewable_groupsSQL order by shift_id;";
			if ($DB > 0) {echo "$stmt\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			$shifts_to_print = mysqli_num_rows($rslt);
			$o=0;
			while ($shifts_to_print > $o)
				{
				$rowx=mysqli_fetch_row($rslt);
				$shift_id_value = $rowx[0];
				$shift_name_value = $rowx[1];
				echo "<input type=\"checkbox\" name=\"group_shifts[]\" value=\"$shift_id_value\"";
				$p=0;
				while ($p<1000)
					{
					if (preg_match("/\s$shift_id_value\s/", $GROUP_shifts))
						{
						echo " CHECKED";
						}
					$p++;
					}
				echo "> <a href=\"$PHP_SELF?ADD=331111111&shift_id=$shift_id_value\">$shift_id_value</a> - $shift_name_value<BR>\n";
				$o++;
				}
			echo " <BR>&nbsp;</td></tr>\n";


			echo "<tr bgcolor=#$SSstd_row1_background><td align=right valign=top>"._QXZ("Agent Status Viewable Groups").": <BR>$NWB#user_groups-agent_status_viewable_groups$NWE</td><td align=left>\n";
			if ($admin_viewable_groupsALL > 0)
				{
				echo "<input type=\"checkbox\" name=\"agent_status_viewable_groups[]\" value=\"--ALL-GROUPS--\"";
				if (preg_match('/\s\-\-ALL\-GROUPS\-\-\s/', $VGROUP_vgroups))
					{echo " CHECKED";}
				echo "><B>"._QXZ("ALL-GROUPS")."</B> - "._QXZ("All user groups in the system")."<BR>\n";
				}
			echo "<input type=\"checkbox\" name=\"agent_status_viewable_groups[]\" value=\"--CAMPAIGN-AGENTS--\"";
			if (preg_match('/\s\-\-CAMPAIGN\-AGENTS\-\-\s/', $VGROUP_vgroups))
				{echo " CHECKED";}
			echo "><B>"._QXZ("CAMPAIGN-AGENTS")."</B> - "._QXZ("All users logged into the same campaign as the agent")."<BR>\n";
			if ($admin_viewable_groupsALL > 0)
				{
				echo "<input type=\"checkbox\" name=\"agent_status_viewable_groups[]\" value=\"--NOT-LOGGED-IN-AGENTS--\"";
				if (preg_match('/\s\-\-NOT\-LOGGED\-IN\-AGENTS\-\-\s/', $VGROUP_vgroups))
					{echo " CHECKED";}
				echo "><B>"._QXZ("NOT-LOGGED-IN-AGENTS")."</B> - "._QXZ("All users in the system, even not logged-in users")."<BR>\n";
				}

			$stmt="SELECT user_group,group_name from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$view_groups_to_print = mysqli_num_rows($rslt);
			$o=0;
			while ($view_groups_to_print > $o)
				{
				$rowx=mysqli_fetch_row($rslt);
				$vgroups_id_value = $rowx[0];
				$vgroups_name_value = $rowx[1];
				echo "<input type=\"checkbox\" name=\"agent_status_viewable_groups[]\" value=\"$vgroups_id_value\"";
				$p=0;
				while ($p<1000)
					{
					if (preg_match("/\s$vgroups_id_value\s/", $VGROUP_vgroups))
						{
						echo " CHECKED";
						}
					$p++;
					}
				echo "> <a href=\"$PHP_SELF?ADD=311111&user_group=$vgroups_id_value\">$vgroups_id_value</a> - $vgroups_name_value<BR>\n";
				$o++;
				}
			echo " <BR>&nbsp;</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Status View Time").": </td><td align=left><select size=1 name=agent_status_view_time><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$agent_status_view_time' SELECTED>"._QXZ("$agent_status_view_time")."</option></select>$NWB#user_groups-agent_status_view_time$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Call Log View").": </td><td align=left><select size=1 name=agent_call_log_view><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$agent_call_log_view' SELECTED>"._QXZ("$agent_call_log_view")."</option></select>$NWB#user_groups-agent_call_log_view$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Fullscreen").": </td><td align=left><select size=1 name=agent_fullscreen><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$agent_fullscreen' SELECTED>"._QXZ("$agent_fullscreen")."</option></select>$NWB#user_groups-agent_fullscreen$NWE</td></tr>\n";

			##### get scripts listing for dynamic pulldown
			$stmt="SELECT script_id,script_name from vicidial_scripts $whereLOGadmin_viewable_groupsSQL order by script_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$scripts_to_print = mysqli_num_rows($rslt);
			if ($DB) {echo "$scripts_to_print|$stmt|\n";}
			$UGscripts_list="<option value=\"\"";
			if ($script_id == '') {$UGscripts_list.=" SELECTED";}
			$UGscripts_list.=">"._QXZ("NONE")."</option>\n";

			$o=0;
			while ($scripts_to_print > $o)
				{
				$rowx=mysqli_fetch_row($rslt);
				$UGscripts_list .= "<option value=\"$rowx[0]\"";
				if ($script_id == "$rowx[0]") {$UGscripts_list .= " SELECTED";}
				$UGscripts_list .= ">$rowx[0] - $rowx[1]</option>\n";
				$o++;
				}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=3111111&script_id=$script_id\">"._QXZ("Script Override")."</a>: </td><td align=left><select size=1 name=script_id>$UGscripts_list</select>$NWB#user_groups-script_id$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Agent Allow Consultative Xfer").": </td><td align=left><select size=1 name=agent_xfer_consultative><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$agent_xfer_consultative' SELECTED>"._QXZ("$agent_xfer_consultative")."</option></select>$NWB#user_groups-agent_xfer_options$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Agent Allow Dial Override Xfer").": </td><td align=left><select size=1 name=agent_xfer_dial_override><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$agent_xfer_dial_override' SELECTED>"._QXZ("$agent_xfer_dial_override")."</option></select>$NWB#user_groups-agent_xfer_options$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Agent Allow Voicemail Message Xfer").": </td><td align=left><select size=1 name=agent_xfer_vm_transfer><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$agent_xfer_vm_transfer' SELECTED>"._QXZ("$agent_xfer_vm_transfer")."</option></select>$NWB#user_groups-agent_xfer_options$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Agent Allow Blind Xfer").": </td><td align=left><select size=1 name=agent_xfer_blind_transfer><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$agent_xfer_blind_transfer' SELECTED>"._QXZ("$agent_xfer_blind_transfer")."</option></select>$NWB#user_groups-agent_xfer_options$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Agent Allow Dial With Customer Xfer").": </td><td align=left><select size=1 name=agent_xfer_dial_with_customer><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$agent_xfer_dial_with_customer' SELECTED>"._QXZ("$agent_xfer_dial_with_customer")."</option></select>$NWB#user_groups-agent_xfer_options$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Agent Allow Park Customer Dial Xfer").": </td><td align=left><select size=1 name=agent_xfer_park_customer_dial><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$agent_xfer_park_customer_dial' SELECTED>"._QXZ("$agent_xfer_park_customer_dial")."</option></select>$NWB#user_groups-agent_xfer_options$NWE</td></tr>\n";
			
			if ($SSagent_xfer_park_3way > 0)
				{
				echo "<tr bgcolor=#$SSstd_row1_background><td align=right>"._QXZ("Agent Allow Park Xfer").": </td><td align=left><select size=1 name=agent_xfer_park_3way><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$agent_xfer_park_3way' SELECTED>"._QXZ("$agent_xfer_park_3way")."</option></select>$NWB#user_groups-agent_xfer_options$NWE</td></tr>\n";
				}
			else
				{
				echo "<tr bgcolor=#$SSstd_row1_background><td colspan=2><input type=hidden name=agent_xfer_park_3way value=\"$agent_xfer_park_3way\"></td></tr>\n";
				}

			echo "<tr bgcolor=#$SSstd_row1_background><td align=right valign=top>"._QXZ("Agent Allowed Chat Groups").": <BR>$NWB#user_groups-agent_allowed_chat_groups$NWE</td><td align=left>\n";
			if ($admin_viewable_groupsALL > 0)
				{
				echo "<input type=\"checkbox\" name=\"agent_allowed_chat_groups[]\" value=\"--ALL-GROUPS--\"";
				if (preg_match('/\s\-\-ALL\-GROUPS\-\-\s/', $VGROUP_chatgroups))
					{echo " CHECKED";}
				echo "><B>"._QXZ("ALL-GROUPS")."</B> - "._QXZ("All user groups in the system")."<BR>\n";
				}
			echo "<input type=\"checkbox\" name=\"agent_allowed_chat_groups[]\" value=\"--CAMPAIGN-AGENTS--\"";
			if (preg_match('/\s\-\-CAMPAIGN\-AGENTS\-\-\s/', $VGROUP_chatgroups))
				{echo " CHECKED";}
			echo "><B>"._QXZ("CAMPAIGN-AGENTS")."</B> - "._QXZ("All users logged into the same campaign as the agent")."<BR>\n";

			$stmt="SELECT user_group,group_name from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$view_chatgroups_to_print = mysqli_num_rows($rslt);
			$o=0;
			while ($view_chatgroups_to_print > $o)
				{
				$rowx=mysqli_fetch_row($rslt);
				$chatgroups_id_value =		$rowx[0];
				$chatgroups_name_value =	$rowx[1];
				echo "<input type=\"checkbox\" name=\"agent_allowed_chat_groups[]\" value=\"$chatgroups_id_value\"";
				$p=0;
				while ($p<1000)
					{
					if (preg_match("/\s$chatgroups_id_value\s/", $VGROUP_chatgroups))
						{
						echo " CHECKED";
						}
					$p++;
					}
				echo "> <a href=\"$PHP_SELF?ADD=311111&user_group=$chatgroups_id_value\">$chatgroups_id_value</a> - $chatgroups_name_value<BR>\n";
				$o++;
				}
			echo " <BR>&nbsp;</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Allowed Reports").": </td><td align=left><select MULTIPLE size=8 name=allowed_reports[]>\n";
			$Vreports_ARY = explode(',',$UGreports);
			$Vreports_ct = count($Vreports_ARY);
			$b=0;
			while ($b < $Vreports_ct)
				{
				$field_selected='';
				trim($Vreports_ARY[$b]);
				if (preg_match("/$Vreports_ARY[$b]/",$allowed_reports))
					{$field_selected = 'SELECTED';}
				echo "<option value=\"$Vreports_ARY[$b]\" $field_selected>"._QXZ("$Vreports_ARY[$b]")."</option>\n";
				$b++;
				}
			echo "</select>$NWB#user_groups-allowed_reports$NWE</td></tr>\n";

			$custom_stmt="show tables like 'vicidial_custom_reports'";
			$custom_rslt=mysql_to_mysqli($custom_stmt, $link);
			if (mysqli_num_rows($custom_rslt)>0) 
				{

				$custom_rpt_stmt="SELECT custom_report_id, report_name from vicidial_custom_reports order by report_name asc";
				$custom_rpt_rslt=mysql_to_mysqli($custom_rpt_stmt, $link);

				$allowed_rpt_stmt="SELECT allowed_custom_reports from vicidial_user_groups where user_group='$user_group'";
				$allowed_rpt_rslt=mysql_to_mysqli($allowed_rpt_stmt, $link);

				if (mysqli_num_rows($custom_rpt_rslt)>0) 
					{
					$allowed_rpt_row=mysqli_fetch_row($allowed_rpt_rslt);
					$allowed_custom_reports=$allowed_rpt_row[0];
					$allowed_reports_array=explode("|", $allowed_custom_reports);

					echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Allowed Custom Reports").": </td><td align=left><select MULTIPLE size=8 name=allowed_custom_reports[]>\n";

					echo "<option value=\"--ALL--\">"._QXZ("ALL REPORTS")."</option>\n";
					echo "<option value=\"--NONE--\">"._QXZ("NONE")."</option>\n";

					while ($custom_rpt_row=mysqli_fetch_array($custom_rpt_rslt)) 
						{
						$report_id=$custom_rpt_row["custom_report_id"];
						$report_name=$custom_rpt_row["report_name"];
						if (in_array("$report_name", $allowed_reports_array)) {$x="selected";} else {$x="";}
						echo "<option value=\"$report_name\" $x>$report_name</option>\n";
						}
					}
					echo "</select>$NWB#user_groups-allowed_custom_reports$NWE</td></tr>\n";
				}


			echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top>"._QXZ("Allowed Queue Groups").": <BR>$NWB#user_groups-allowed_queue_groups$NWE</td><td align=left>\n";
			echo "$queue_groups_list";
			echo " <BR>&nbsp;</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Reports Header Override").": </td><td align=left><select size=1 name=reports_header_override><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='LOGO_ONLY_SMALL'>"._QXZ("LOGO_ONLY_SMALL")."</option><option value='LOGO_ONLY_LARGE'>"._QXZ("LOGO_ONLY_LARGE")."</option><option value='ALT_1'>"._QXZ("ALT_1")."</option><option value='ALT_2'>"._QXZ("ALT_2")."</option><option value='ALT_3'>"._QXZ("ALT_3")."</option><option value='ALT_4'>"._QXZ("ALT_4")."</option><option value=\"$reports_header_override\" SELECTED>"._QXZ("$reports_header_override")."</option></select>$NWB#user_groups-reports_header_override$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Home URL Override").": </td><td align=left><input type=text name=admin_home_url size=60 maxlength=255 value=\"$admin_home_url\"> $NWB#user_groups-admin_home_url$NWE</td></tr>\n";


			if (strlen($SSwebphone_url) > 5)
				{
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Webphone URL Override").": </td><td align=left><input type=text name=webphone_url_override size=60 maxlength=255 value=\"$webphone_url_override\"> $NWB#user_groups-webphone_url_override$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Webphone System Key Override").": </td><td align=left><input type=text name=webphone_systemkey_override size=60 maxlength=100 value=\"$webphone_systemkey_override\"> $NWB#user_groups-webphone_systemkey_override$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Webphone Dialpad Override").": </td><td align=left><select size=1 name=webphone_dialpad_override><option value='DISABLED'>"._QXZ("DISABLED")."</option><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='TOGGLE'>"._QXZ("TOGGLE")."</option><option value='TOGGLE_OFF'>"._QXZ("TOGGLE_OFF")."</option><option value=\"$webphone_dialpad_override\" SELECTED>"._QXZ("$webphone_dialpad_override")."</option></select>$NWB#user_groups-webphone_dialpad_override$NWE</td></tr>\n";

				echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Webphone Layout Override").": </td><td align=left><input type=text name=webphone_layout size=60 maxlength=255 value=\"$webphone_layout\"> $NWB#user_groups-webphone_layout$NWE</td></tr>\n";
				}
			else
				{
				echo "<input type=hidden name=webphone_url_override value=\"$webphone_url_override\"> ";
				echo "<input type=hidden name=webphone_systemkey_override value=\"$webphone_systemkey_override\"> ";
				echo "<input type=hidden name=webphone_dialpad_override value=\"$webphone_dialpad_override\"> ";
				echo "<input type=hidden name=webphone_layout value=\"$webphone_layout\"> ";
				}

			if ($SSqc_features_active > 0)
				{
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top>"._QXZ("QC Allowed Campaigns").": <BR>$NWB#user_groups-qc_allowed_campaigns$NWE</td><td align=left>\n";
				echo "$qc_campaigns_list";
				echo " <BR>&nbsp;</td></tr>\n";
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top>"._QXZ("QC Allowed Inbound Groups").": <BR>$NWB#user_groups-qc_allowed_inbound_groups$NWE</td><td align=left>\n";
				echo "$qc_groups_list";
				echo " <BR>&nbsp;</td></tr>\n";
				}

			if ($SSallow_ip_lists > 0)
				{
				##### get ip lists listing for dynamic pulldowns 
				$stmt="SELECT ip_list_id,ip_list_name from vicidial_ip_lists where active='Y' order by ip_list_id;";
				$rsltx=mysql_to_mysqli($stmt, $link);
				$iplists_to_print = mysqli_num_rows($rsltx);
				$ip_list='';
				$o=0;
				while ($iplists_to_print > $o)
					{
					$rowx=mysqli_fetch_row($rsltx);
					$ip_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
					$o++;
					}

				if (strlen($admin_ip_list) < 1)
					{
					$ip_list_link_BEGIN = "";   $ip_list_link_END = "";
					$ip_list_menu = "<option value=\"\" SELECTED>--- "._QXZ("DISABLED")." ---</option>\n";
					}
				else
					{
					$ip_list_link_BEGIN = "<a href='$PHP_SELF?ADD=395111111111&ip_list_id=$admin_ip_list'>";   $ip_list_link_END = "</a>";
					$ip_list_menu = "<option value=\"\">--- "._QXZ("DISABLED")." ---</option>\n";
					$ip_list_menu .= "<option SELECTED>$admin_ip_list</option>\n";
					}

				echo "<tr bgcolor=#$SSstd_row3_background><td align=right>$ip_list_link_BEGIN"._QXZ("Admin IP Whitelist")."$ip_list_link_END: </td><td align=left><select size=1 name=admin_ip_list>\n";
				echo "$ip_list$ip_list_menu";
				echo "</select>$NWB#user_groups-admin_ip_list$NWE</td></tr>\n";

				if (strlen($agent_ip_list) < 1)
					{
					$ip_list_link_BEGIN = "";   $ip_list_link_END = "";
					$ip_list_menu = "<option value=\"\" SELECTED>--- "._QXZ("DISABLED")." ---</option>\n";
					}
				else
					{
					$ip_list_link_BEGIN = "<a href='$PHP_SELF?ADD=395111111111&ip_list_id=$agent_ip_list'>";   $ip_list_link_END = "</a>";
					$ip_list_menu = "<option value=\"\">--- "._QXZ("DISABLED")." ---</option>\n";
					$ip_list_menu .= "<option SELECTED>$agent_ip_list</option>\n";
					}

				echo "<tr bgcolor=#$SSstd_row3_background><td align=right>$ip_list_link_BEGIN"._QXZ("Agent IP Whitelist")."$ip_list_link_END: </td><td align=left><select size=1 name=agent_ip_list>\n";
				echo "$ip_list$ip_list_menu";
				echo "</select>$NWB#user_groups-agent_ip_list$NWE</td></tr>\n";

				if (strlen($api_ip_list) < 1)
					{
					$ip_list_link_BEGIN = "";   $ip_list_link_END = "";
					$ip_list_menu = "<option value=\"\" SELECTED>--- "._QXZ("DISABLED")." ---</option>\n";
					}
				else
					{
					$ip_list_link_BEGIN = "<a href='$PHP_SELF?ADD=395111111111&ip_list_id=$api_ip_list'>";   $ip_list_link_END = "</a>";
					$ip_list_menu = "<option value=\"\">--- "._QXZ("DISABLED")." ---</option>\n";
					$ip_list_menu .= "<option SELECTED>$api_ip_list</option>\n";
					}

				echo "<tr bgcolor=#$SSstd_row3_background><td align=right>$ip_list_link_BEGIN"._QXZ("API IP Whitelist")."$ip_list_link_END: </td><td align=left><select size=1 name=api_ip_list>\n";
				echo "$ip_list$ip_list_menu";
				echo "</select>$NWB#user_groups-api_ip_list$NWE</td></tr>\n";
				}
			else
				{
				echo "<tr bgcolor=#$SSstd_row2_background><td align=right></td><td align=left><input type=hidden name=admin_ip_list value=$admin_ip_list><input type=hidden name=agent_ip_list value=$agent_ip_list><input type=hidden name=api_ip_list value=$api_ip_list></td></tr>\n";
				}

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top>"._QXZ("Allowed User Groups").": <BR>$NWB#user_groups-admin_viewable_groups$NWE</td><td align=left>\n";
			if ($admin_viewable_groupsALL > 0)
				{
				echo "<input type=\"checkbox\" name=\"admin_viewable_groups[]\" value=\"---ALL---\"";
				if (preg_match("/\s\-\-\-ALL\-\-\-\s/",$admin_viewable_groups))
					{echo " CHECKED";}
				echo "><B>"._QXZ("ALL-GROUPS")."</B> - "._QXZ("All user groups in the system")."<BR>\n";
				}

			$stmt="SELECT user_group,group_name from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$view_groups_to_print = mysqli_num_rows($rslt);
			$o=0;
			while ($view_groups_to_print > $o)
				{
				$rowx=mysqli_fetch_row($rslt);
				$vgroups_id_value =		$rowx[0];
				$vgroups_name_value =	$rowx[1];
				echo "<input type=\"checkbox\" name=\"admin_viewable_groups[]\" value=\"$vgroups_id_value\"";
				$p=0;
				while ($p<1000)
					{
					if (preg_match("/\s$vgroups_id_value\s/", $admin_viewable_groups))
						{
						echo " CHECKED";
						}
					$p++;
					}
				echo "> <a href=\"$PHP_SELF?ADD=311111&user_group=$vgroups_id_value\">$vgroups_id_value</a> - $vgroups_name_value<BR>\n";
				$o++;
				}
			echo " <BR>&nbsp;</td></tr>\n";


			echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top>"._QXZ("Allowed Call Times").": <BR>$NWB#user_groups-admin_viewable_call_times$NWE</td><td align=left>\n";
			echo "<input type=\"checkbox\" name=\"admin_viewable_call_times[]\" value=\"---ALL---\"";
			if (preg_match("/\s\-\-\-ALL\-\-\-\s/",$admin_viewable_call_times))
				{echo " CHECKED";}
			echo "><B>"._QXZ("ALL-CALLTIMES")."</B> - "._QXZ("All call times in the system")."<BR>\n";

			$stmt="SELECT call_time_id,call_time_name from vicidial_call_times $whereLOGadmin_viewable_call_timesSQL order by call_time_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$view_calltimes_to_print = mysqli_num_rows($rslt);
			$o=0;
			while ($view_calltimes_to_print > $o)
				{
				$rowx=mysqli_fetch_row($rslt);
				$vcalltimes_id_value =		$rowx[0];
				$vcalltimes_name_value =	$rowx[1];
				echo "<input type=\"checkbox\" name=\"admin_viewable_call_times[]\" value=\"$vcalltimes_id_value\"";
				$p=0;
				while ($p<1000)
					{
					if (preg_match("/\s$vcalltimes_id_value\s/", $admin_viewable_call_times))
						{
						echo " CHECKED";
						}
					$p++;
					}
				echo "> <a href=\"$PHP_SELF?ADD=311111111&call_time_id=$vcalltimes_id_value\">$vcalltimes_id_value</a> - $vcalltimes_name_value<BR>\n";
				$o++;
				}
			echo " <BR>&nbsp;</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
			echo "</TABLE></center>\n";


			### list of users in this user group

			$active_confs = 0;
			$stmt="SELECT user,full_name,user_level,active from vicidial_users where user_group='$user_group' $LOGadmin_viewable_groupsSQL;";
			$rsltx=mysql_to_mysqli($stmt, $link);
			$users_to_print = mysqli_num_rows($rsltx);

			echo "<center>\n";
			echo "<br><b>"._QXZ("USERS WITHIN THIS USER GROUP").": $users_to_print</b><br>\n";
			echo "<TABLE width=400 cellspacing=3>\n";
			echo "<tr><td>"._QXZ("USER")."</td><td>"._QXZ("FULL NAME")."</td><td>"._QXZ("LEVEL")."</td><td>"._QXZ("ACTIVE")."</td></tr>\n";

			$o=0;
			while ($users_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rsltx);
				$o++;

				if (preg_match('/1$|3$|5$|7$|9$/i', $o))
					{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}
				else
					{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 

				echo "<tr $bgcolor>\n";
				echo "<td><font size=1><a href=\"$PHP_SELF?ADD=3&user=$rowx[0]\">$rowx[0]</a></td>\n";
				echo "<td><font size=1>$rowx[1]</td>\n";
				echo "<td><font size=1>$rowx[2]</td>\n";
				echo "<td><font size=1>"._QXZ("$rowx[3]")."</td>\n";
				echo "</tr>\n";
				}
			if ($o < 1)
				{echo "<tr bgcolor=\"#". $SSstd_row1_background ."\"><td colspan=5><font size=1>--"._QXZ("NONE")."--</td></tr>\n";}

			echo "</table></center><br></form>\n";


			##### BEGIN add/remove in-group as selected for all active users in this group #####
			echo "<center>\n";
			echo "<br><b>"._QXZ("Add or Remove In-Group Selected For Active Users in This User Group")."</b><form action=$PHP_SELF#agent_ranks method=POST>\n";
			echo "<input type=hidden name=ADD value=4111>\n";
			echo "<input type=hidden name=SUB value=agents_select>\n";
			echo "<input type=hidden name=OLDuser_group value=\"$user_group\">\n";
			### get in-groups listings for dynamic pulldown
			$stmt="SELECT group_id,group_name from vicidial_inbound_groups $whereLOGadmin_viewable_groupsSQL order by group_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$Xgroups_to_print = mysqli_num_rows($rslt);
			$Xgroups_menu='';
			$o=0;
			while ($Xgroups_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$Xgroups_menu .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$o++;
				}
			echo "<select size=1 name=stage><option value=\"add\" SELECTED>"._QXZ("add")."</option><option value=\"remove\">"._QXZ("remove")."</option></select> &nbsp; \n";
			echo _QXZ("In-Group").": <select size=1 name=group_id>$Xgroups_menu</select><br>\n";
			echo "<input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></form>\n";
			##### END add/remove in-group as selected for all active users in this group #####


			### list of users with this user group set as secondary user group

			$active_confs = 0;
			$stmt="SELECT user,full_name,user_level,active,user_group from vicidial_users where user_group_two='$user_group' $LOGadmin_viewable_groupsSQL;";
			$rsltx=mysql_to_mysqli($stmt, $link);
			$users_to_print = mysqli_num_rows($rsltx);

			echo "<br><br><center>\n";
			echo "<br><b>"._QXZ("USERS WITHIN THIS SECONDARY USER GROUP").": $users_to_print</b><br>\n";
			echo "<TABLE width=500 cellspacing=3>\n";
			echo "<tr><td>"._QXZ("USER")."</td><td>"._QXZ("FULL NAME")."</td><td>"._QXZ("LEVEL")."</td><td>"._QXZ("ACTIVE")."</td><td>"._QXZ("USER GROUP")."</td></tr>\n";

			$o=0;
			while ($users_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rsltx);
				$o++;

				if (preg_match('/1$|3$|5$|7$|9$/i', $o))
					{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}
				else
					{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 

				echo "<tr $bgcolor>\n";
				echo "<td><font size=1><a href=\"$PHP_SELF?ADD=3&user=$rowx[0]\">$rowx[0]</a></td>\n";
				echo "<td><font size=1>$rowx[1]</td>\n";
				echo "<td><font size=1>$rowx[2]</td>\n";
				echo "<td><font size=1>"._QXZ("$rowx[3]")."</td>\n";
				echo "<td><font size=1>$rowx[4]</td>\n";
				echo "</tr>\n";
				}
			if ($o < 1)
				{echo "<tr bgcolor=\"#". $SSstd_row1_background ."\"><td colspan=5><font size=1>--"._QXZ("NONE")."--</td></tr>\n";}

			echo "</table></center><br></form>\n";






			echo "<br><br><a href=\"$PHP_SELF?ADD=8111&user_group=$user_group\">"._QXZ("Click here to see all CallBack Holds in this user group")."</a><BR><BR>\n";
			echo "<br><br><a href=\"./timeclock_status.php?user_group=$user_group\">"._QXZ("Click here to see the Timeclock Status for this user group")."</a><BR><BR>\n";

			if ($LOGdelete_user_groups > 0)
				{
				echo "<br><br><a href=\"$PHP_SELF?ADD=511111&user_group=$user_group\">"._QXZ("DELETE THIS USER GROUP")."</a>\n";
				}
			if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
				{
				echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=USERGROUPS&stage=$user_group\">"._QXZ("Click here to see Admin changes to this user group")."</FONT>\n";
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=3111111 modify script info in the system
######################
if ($ADD==3111111)
	{
	if ($LOGmodify_scripts==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=3111111&script_id=$script_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT script_id,script_name,script_comments,script_text,active,user_group,script_color from vicidial_scripts where script_id='$script_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$script_name =		$row[1];
		$script_comments =	$row[2];
		$script_text =		stripslashes($row[3]);
		$active =			$row[4];
		$user_group =		$row[5];
		$script_color =		$row[6];

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("MODIFY A SCRIPT")."<form name=scriptForm action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=4111111>\n";
		echo "<input type=hidden name=DB value=\"$DB\">\n";
		echo "<input type=hidden name=script_id value=\"$script_id\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Script ID").": </td><td align=left><B>$script_id</B>$NWB#scripts-script_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Script Name").": </td><td align=left><input type=text name=script_name size=40 maxlength=50 value=\"$script_name\"> ("._QXZ("title of the script").")$NWB#scripts-script_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Script Comments").": </td><td align=left><input type=text name=script_comments size=50 maxlength=255 value=\"$script_comments\"> $NWB#scripts-script_comments$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">".(preg_match('/\-\-ALL\-\-/', $user_group) ? _QXZ("$user_group") : $user_group)."</option>\n";
		echo "</select>$NWB#scripts-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='Y' SELECTED>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$active' selected>"._QXZ("$active")."</option></select>$NWB#scripts-active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Script Color")." <font size=2>(<a href=\"javascript:launch_color_chooser('script_color','color','1');\">"._QXZ("color chooser")."</a>)</font>: </td><td align=left bgcolor=\"$script_color\" id=\"script_color_td\"><input type=text name=script_color id=script_color size=7 maxlength=20 value=\"$script_color\"> $NWB#scripts-script_color$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Script Text").": <BR><BR><B><a href=\"javascript:openNewWindow('$PHP_SELF?ADD=7111111&script_id=$script_id')\">"._QXZ("Preview Script")."</a></B> </td><td align=left>";
		# BEGIN Insert Field
		echo "<select id=\"selectedField\" name=\"selectedField\">";
		echo "<option value=\"fullname\">"._QXZ("Agent Name")."(fullname)</option>";
		echo "<option>vendor_lead_code</option>";
		echo "<option>source_id</option>";
		echo "<option>list_id</option>";
		echo "<option>list_name</option>";
		echo "<option>list_description</option>";
		echo "<option>gmt_offset_now</option>";
		echo "<option>called_since_last_reset</option>";
		echo "<option>phone_code</option>";
		echo "<option>phone_number</option>";
		echo "<option>title</option>";
		echo "<option>first_name</option>";
		echo "<option>middle_initial</option>";
		echo "<option>last_name</option>";
		echo "<option>address1</option>";
		echo "<option>address2</option>";
		echo "<option>address3</option>";
		echo "<option>city</option>";
		echo "<option>state</option>";
		echo "<option>province</option>";
		echo "<option>postal_code</option>";
		echo "<option>country_code</option>";
		echo "<option>gender</option>";
		echo "<option>date_of_birth</option>";
		echo "<option>alt_phone</option>";
		echo "<option>email</option>";
		echo "<option>security_phrase</option>";
		echo "<option>comments</option>";
		echo "<option>lead_id</option>";
		echo "<option>campaign</option>";
		echo "<option>phone_login</option>";
		echo "<option>group</option>";
		echo "<option>channel_group</option>";
		echo "<option>SQLdate</option>";
		echo "<option>epoch</option>";
		echo "<option>uniqueid</option>";
		echo "<option>customer_zap_channel</option>";
		echo "<option>server_ip</option>";
		echo "<option>SIPexten</option>";
		echo "<option>session_id</option>";
		echo "<option>dialed_number</option>";
		echo "<option>dialed_label</option>";
		echo "<option>rank</option>";
		echo "<option>owner</option>";
		echo "<option>camp_script</option>";
		echo "<option>in_script</option>";
		echo "<option>script_width</option>";
		echo "<option>script_height</option>";
		echo "<option>recording_filename</option>";
		echo "<option>recording_id</option>";
		echo "<option>user_custom_one</option>";
		echo "<option>user_custom_two</option>";
		echo "<option>user_custom_three</option>";
		echo "<option>user_custom_four</option>";
		echo "<option>user_custom_five</option>";
		echo "<option>preset_number_a</option>";
		echo "<option>preset_number_b</option>";
		echo "<option>preset_number_c</option>";
		echo "<option>preset_number_d</option>";
		echo "<option>preset_number_e</option>";
		echo "<option>preset_number_f</option>";
		echo "<option>preset_dtmf_a</option>";
		echo "<option>preset_dtmf_b</option>";
		echo "<option>did_id</option>";
		echo "<option>did_extension</option>";
		echo "<option>did_pattern</option>";
		echo "<option>did_description</option>";
		echo "<option>closecallid</option>";
		echo "<option>xfercallid</option>";
		echo "<option>agent_log_id</option>";
		echo "<option>entry_list_id</option>";
		echo "<option>call_id</option>";
		echo "<option>user_group</option>";
		echo "<option>called_count</option>";
		echo "<option>TABLEper_call_notes</option>";
		echo "<option>agent_email</option>";
		echo "</select>";
		echo "<input type=\"button\" name=\"insertField\" value=\""._QXZ("Insert")."\" onClick=\"scriptInsertField();\"><BR>";
		# END Insert Field
		echo "<TEXTAREA NAME=script_text ROWS=20 COLS=50>$script_text</TEXTAREA> $NWB#scripts-script_text$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";



		echo "</TABLE><BR><BR>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><B> "._QXZ("CAMPAIGNS USING THIS SCRIPT").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where ( (campaign_script='$script_id') or (campaign_script_two='$script_id') ) $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$camps_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($camps_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><a href=\"$PHP_SELF?ADD=31&campaign_id=$row[0]\">$row[0] </a></TD><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE><BR><BR>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><B> "._QXZ("IN-GROUPS USING THIS SCRIPT").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT group_id,group_name from vicidial_inbound_groups where ( (ingroup_script='$script_id') or (ingroup_script_two='$script_id') ) $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$camps_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($camps_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><a href=\"$PHP_SELF?ADD=3111&group_id=$row[0]\">$row[0] </a></TD><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE><BR><BR>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><B> "._QXZ("LIST OVERRIDES USING THIS SCRIPT").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT list_id,list_name from vicidial_lists where agent_script_override='$script_id' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$camps_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($camps_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><a href=\"$PHP_SELF?ADD=311&list_id=$row[0]\">$row[0] </a></TD><TD> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>$row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE><BR><BR>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><B> "._QXZ("USER GROUP OVERRIDES USING THIS SCRIPT").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT user_group,group_name from vicidial_user_groups where script_id='$script_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$camps_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($camps_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><a href=\"$PHP_SELF?ADD=311111&user_group=$row[0]\">$row[0] </a></TD><TD> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>$row[1]<BR></TD></TR>\n";
			$o++;
			}


		if ( ($SSagent_soundboards > 0) and (preg_match("/vdc_soundboard_display/",$script_text)) )
			{
			$sb_check = preg_replace('~[\r\n]+~', '', $script_text);
			$sb_lines = explode("vdc_soundboard_display",$sb_check);
			$sb_content = explode('"',$sb_lines[1]);
			$sb_id = explode('soundboard_id=',$sb_content[0]);
			if ($DB) {echo "|$sb_check|\n|$sb_lines[1]|\n|$sb_content[0]|\n|$sb_id[1]|\n";}
			echo "</TABLE><BR><BR>\n";
			echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><B> "._QXZ("AGENT SOUNDBOARD USED WITHIN THIS SCRIPT").":</B><BR>\n";
			echo "<TABLE>\n";

			$stmt="SELECT avatar_id,avatar_name from vicidial_avatars where avatar_id='$sb_id[1]' $LOGadmin_viewable_groupsSQL;";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			$sb_to_print = mysqli_num_rows($rslt);
			$o=0;
			while ($sb_to_print > $o) 
				{
				$row=mysqli_fetch_row($rslt);
				echo "<TR><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><a href=\"admin_soundboard.php?ADD=362111111111&soundboard_id=$row[0]\">$row[0] </a></TD><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2> $row[1]<BR></TD></TR>\n";
				$o++;
				}
			}

		echo "</TABLE><TABLE><TR><TD><BR><BR><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>\n";

		if ($LOGdelete_scripts > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=5111111&script_id=$script_id\">"._QXZ("DELETE THIS SCRIPT")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=SCRIPTS&stage=$script_id\">"._QXZ("Click here to see Admin changes to this script")."</FONT>\n";
			}

		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=31111111 modify filter info in the system
######################
if ($ADD==31111111)
	{
	if ($LOGmodify_filters==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=31111111&lead_filter_id=$lead_filter_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT lead_filter_id,lead_filter_name,lead_filter_comments,lead_filter_sql,user_group from vicidial_lead_filters where lead_filter_id='$lead_filter_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$lead_filter_name =		$row[1];
		$lead_filter_comments =	$row[2];
		$lead_filter_sql =		stripslashes($row[3]);
		$user_group =			$row[4];

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("MODIFY A FILTER")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=41111111>\n";
		echo "<input type=hidden name=DB value=\"$DB\">\n";
		echo "<input type=hidden name=lead_filter_id value=\"$lead_filter_id\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Filter ID").": </td><td align=left><B>$lead_filter_id</B>$NWB#lead_filters-lead_filter_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Filter Name").": </td><td align=left><input type=text name=lead_filter_name size=40 maxlength=50 value=\"$lead_filter_name\"> ("._QXZ("short description of the filter").")$NWB#lead_filters-lead_filter_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Filter Comments").": </td><td align=left><input type=text name=lead_filter_comments size=50 maxlength=255 value=\"$lead_filter_comments\"> $NWB#lead_filters-lead_filter_comments$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">".(preg_match('/\-\-ALL\-\-/', $user_group) ? _QXZ("$user_group") : $user_group)."</option>\n";
		echo "</select>$NWB#lead_filters-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Filter SQL").":</td><td align=left><TEXTAREA NAME=lead_filter_sql ROWS=20 COLS=50>$lead_filter_sql</TEXTAREA> $NWB#lead_filters-lead_filter_sql$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center></form>\n";

		##### get campaigns listing for dynamic pulldown
		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campaigns_to_print = mysqli_num_rows($rslt);
		$campaigns_list='';

		$o=0;
		while ($campaigns_to_print > $o)
			{
			$rowx=mysqli_fetch_row($rslt);
			$campaigns_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}

		echo "<BR><BR>";
		echo "<br>"._QXZ("TEST ON CAMPAIGN").": <form action=$PHP_SELF method=POST target=\"_blank\">\n";
		echo "<input type=hidden name=lead_filter_id value=\"$lead_filter_id\">\n";
		echo "<input type=hidden name=ADD value=\"73\">\n";
		echo "<input type=hidden name=DB value=\"$DB\">\n";
		echo "<select size=1 name=campaign_id>\n";
		echo "$campaigns_list";
		echo "</select>\n";
		echo "<input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'>\n";


		echo "<BR><BR><B>"._QXZ("CAMPAIGNS USING THIS FILTER").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where lead_filter_id='$lead_filter_id' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campin_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($campin_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=31&campaign_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE>\n";
		echo "<BR><B>"._QXZ("USERS USING THIS FILTER").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT user,full_name from vicidial_users where lead_filter_id='$lead_filter_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$userin_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($userin_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=3&user=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE>\n";


		if ($LOGdelete_filters > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=51111111&lead_filter_id=$lead_filter_id\">"._QXZ("DELETE THIS FILTER")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=FILTERS&stage=$lead_filter_id\">"._QXZ("Click here to see Admin changes to this filter")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=321111111 modify call time definition info in the system, ADD/REMOVE
######################
if ($ADD==321111111)
	{
	if ($LOGmodify_call_times==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=311111111&call_time_id=$call_time_id";
			$modify_footer_refresh=1;
			}
		### add-remove state rule
		if ( ($stage=="ADD") and (strlen($state_rule)>0) )
			{
			$stmt="SELECT ct_state_call_times from vicidial_call_times where call_time_id='$call_time_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			$ct_state_call_times = $row[0];

			if (preg_match('/\|$/i',$ct_state_call_times))
				{$ct_state_call_times = "$ct_state_call_times$state_rule\|";}
			else
				{$ct_state_call_times = "$ct_state_call_times\|$state_rule\|";}
			$stmt="UPDATE vicidial_call_times set ct_state_call_times='$ct_state_call_times' where call_time_id='$call_time_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='CALLTIMES', event_type='MODIFY', record_id='$call_time_id', event_code='ADMIN MODIFY CALL TIME ADD STATE RULE', event_sql=\"$SQL_log\", event_notes='State Rule Added: $state_rule';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo _QXZ("State Rule Added").": $state_rule<BR>\n";
			}
		if ( ($stage=="REMOVE") and (strlen($state_rule)>0) )
			{
			$stmt="SELECT ct_state_call_times from vicidial_call_times where call_time_id='$call_time_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			$ct_state_call_times = $row[0];

			$ct_state_call_times = preg_replace("/\|$state_rule\|/i", '|',$ct_state_call_times);
			$stmt="UPDATE vicidial_call_times set ct_state_call_times='$ct_state_call_times' where call_time_id='$call_time_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='CALLTIMES', event_type='MODIFY', record_id='$call_time_id', event_code='ADMIN MODIFY CALL TIME REMOVE STATE RULE', event_sql=\"$SQL_log\", event_notes='State Rule Removed: $state_rule';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo _QXZ("State Rule Removed").": $state_rule<BR>\n";
			}
		### add-remove holiday rule
		if ( ($stage=="ADD") and (strlen($holiday_rule)>0) )
			{
			$stmt="SELECT ct_holidays from vicidial_call_times where call_time_id='$call_time_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			$ct_holidays = $row[0];

			if (preg_match('/\|$/i',$ct_holidays))
				{$ct_holidays = "$ct_holidays$holiday_rule\|";}
			else
				{$ct_holidays = "$ct_holidays\|$holiday_rule\|";}
			$stmt="UPDATE vicidial_call_times set ct_holidays='$ct_holidays' where call_time_id='$call_time_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='CALLTIMES', event_type='MODIFY', record_id='$call_time_id', event_code='ADMIN MODIFY CALL TIME ADD HOLIDAY RULE', event_sql=\"$SQL_log\", event_notes='Holiday Rule Added: $holiday_rule';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo _QXZ("Holiday Rule Added").": $holiday_rule<BR>\n";
			}
		if ( ($stage=="REMOVE") and (strlen($holiday_rule)>0) )
			{
			$stmt="SELECT ct_holidays from vicidial_call_times where call_time_id='$call_time_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			$ct_holidays = $row[0];

			$ct_holidays = preg_replace("/\|$holiday_rule\|/i", '|',$ct_holidays);
			$stmt="UPDATE vicidial_call_times set ct_holidays='$ct_holidays' where call_time_id='$call_time_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='CALLTIMES', event_type='MODIFY', record_id='$call_time_id', event_code='ADMIN MODIFY CALL TIME REMOVE HOLIDAY RULE', event_sql=\"$SQL_log\", event_notes='Holiday Rule Removed: $holiday_rule';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo _QXZ("Holiday Rule Removed").": $holiday_rule<BR>\n";
			}

		$ADD=311111111;
		}
	else
		{
		echo _QXZ("You are not authorized to view this page. Please go back.");
		}
	}


######################
# ADD=322111111 modify state call time definition info in the system, ADD/REMOVE
######################
if ($ADD==322111111)
	{
	if ($LOGmodify_call_times==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=3111111111&call_time_id=$call_time_id";
			$modify_footer_refresh=1;
			}
		### add-remove holiday rule
		if ( ($stage=="ADD") and (strlen($holiday_rule)>0) )
			{
			$stmt="SELECT ct_holidays from vicidial_state_call_times where state_call_time_id='$call_time_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			$ct_holidays = $row[0];

			if (preg_match('/\|$/i',$ct_holidays))
				{$ct_holidays = "$ct_holidays$holiday_rule\|";}
			else
				{$ct_holidays = "$ct_holidays\|$holiday_rule\|";}
			$stmt="UPDATE vicidial_state_call_times set ct_holidays='$ct_holidays' where state_call_time_id='$call_time_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='CALLTIMES', event_type='MODIFY', record_id='$call_time_id', event_code='ADMIN MODIFY STATE CALL TIME ADD HOLIDAY RULE', event_sql=\"$SQL_log\", event_notes='Holiday Rule Added: $holiday_rule';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo _QXZ("Holiday Rule Added").": $holiday_rule<BR>\n";
			}
		if ( ($stage=="REMOVE") and (strlen($holiday_rule)>0) )
			{
			$stmt="SELECT ct_holidays from vicidial_state_call_times where state_call_time_id='$call_time_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$row=mysqli_fetch_row($rslt);
			$ct_holidays = $row[0];

			$ct_holidays = preg_replace("/\|$holiday_rule\|/i",'|',$ct_holidays);
			$stmt="UPDATE vicidial_state_call_times set ct_holidays='$ct_holidays' where state_call_time_id='$call_time_id';";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='CALLTIMES', event_type='MODIFY', record_id='$call_time_id', event_code='ADMIN MODIFY STATE CALL TIME REMOVE HOLIDAY RULE', event_sql=\"$SQL_log\", event_notes='Holiday Rule Removed: $holiday_rule';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo _QXZ("Holiday Rule Removed").": $holiday_rule<BR>\n";
			}

		$ADD=3111111111;
		}
	else
		{
		echo _QXZ("You are not authorized to view this page. Please go back.");
		}
	}


######################
# ADD=311111111 modify call time definition info in the system
######################
if ($ADD==311111111)
	{
	if ($LOGmodify_call_times==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=311111111&call_time_id=$call_time_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT call_time_id,call_time_name,call_time_comments,ct_default_start,ct_default_stop,ct_sunday_start,ct_sunday_stop,ct_monday_start,ct_monday_stop,ct_tuesday_start,ct_tuesday_stop,ct_wednesday_start,ct_wednesday_stop,ct_thursday_start,ct_thursday_stop,ct_friday_start,ct_friday_stop,ct_saturday_start,ct_saturday_stop,ct_state_call_times,default_afterhours_filename_override,sunday_afterhours_filename_override,monday_afterhours_filename_override,tuesday_afterhours_filename_override,wednesday_afterhours_filename_override,thursday_afterhours_filename_override,friday_afterhours_filename_override,saturday_afterhours_filename_override,user_group,ct_holidays from vicidial_call_times where call_time_id='$call_time_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$call_time_name =		$row[1];
		$call_time_comments =	$row[2];
		$ct_default_start =		$row[3];
		$ct_default_stop =		$row[4];
		$ct_sunday_start =		$row[5];
		$ct_sunday_stop =		$row[6];
		$ct_monday_start =		$row[7];
		$ct_monday_stop =		$row[8];
		$ct_tuesday_start =		$row[9];
		$ct_tuesday_stop =		$row[10];
		$ct_wednesday_start =	$row[11];
		$ct_wednesday_stop =	$row[12];
		$ct_thursday_start =	$row[13];
		$ct_thursday_stop =		$row[14];
		$ct_friday_start =		$row[15];
		$ct_friday_stop =		$row[16];
		$ct_saturday_start =	$row[17];
		$ct_saturday_stop =		$row[18];
		$ct_state_call_times =	$row[19];
		$default_afterhours_filename_override =		$row[20];
		$sunday_afterhours_filename_override =		$row[21];
		$monday_afterhours_filename_override =		$row[22];
		$tuesday_afterhours_filename_override =		$row[23];
		$wednesday_afterhours_filename_override =	$row[24];
		$thursday_afterhours_filename_override =	$row[25];
		$friday_afterhours_filename_override =		$row[26];
		$saturday_afterhours_filename_override =	$row[27];
		$user_group =			$row[28];
		$ct_holidays =			$row[29];

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("MODIFY A CALL TIME")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=411111111>\n";
		echo "<input type=hidden name=DB value=\"$DB\">\n";
		echo "<input type=hidden name=call_time_id value=\"$call_time_id\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Call Time ID").": </td><td align=left colspan=3><B>$call_time_id</B>$NWB#call_times-call_time_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Call Time Name").": </td><td align=left colspan=3><input type=text name=call_time_name size=40 maxlength=50 value=\"$call_time_name\"> ("._QXZ("short description of the call time").")$NWB#call_times-call_time_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Call Time Comments").": </td><td align=left colspan=3><input type=text name=call_time_comments size=50 maxlength=255 value=\"$call_time_comments\"> $NWB#call_times-call_time_comments$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left colspan=3><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">"._QXZ("$user_group")."</option>\n";
		echo "</select>$NWB#call_times-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Default Start").":</td><td align=left><input type=text name=ct_default_start size=5 maxlength=4 value=\"$ct_default_start\"> </td><td align=right>"._QXZ("Default Stop").":</td><td align=left nowrap><input type=text name=ct_default_stop size=5 maxlength=4 value=\"$ct_default_stop\"> $NWB#call_times-ct_default_start$NWE &nbsp; &nbsp; &nbsp; "._QXZ("AH Override").": <input type=text name=default_afterhours_filename_override id=default_afterhours_filename_override size=20 maxlength=255 value=\"$default_afterhours_filename_override\"> <a href=\"javascript:launch_chooser('default_afterhours_filename_override','date');\">"._QXZ("audio chooser")."</a> $NWB#call_times-default_afterhours_filename_override$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Sunday Start").":</td><td align=left><input type=text name=ct_sunday_start size=5 maxlength=4 value=\"$ct_sunday_start\"> </td><td align=right>"._QXZ("Sunday Stop").":</td><td align=left><input type=text name=ct_sunday_stop size=5 maxlength=4 value=\"$ct_sunday_stop\"> $NWB#call_times-ct_sunday_start$NWE &nbsp; &nbsp; &nbsp; "._QXZ("AH Override").": <input type=text name=sunday_afterhours_filename_override id=sunday_afterhours_filename_override size=20 maxlength=255 value=\"$sunday_afterhours_filename_override\"> <a href=\"javascript:launch_chooser('sunday_afterhours_filename_override','date');\">"._QXZ("audio chooser")."</a> $NWB#call_times-default_afterhours_filename_override$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Monday Start").":</td><td align=left><input type=text name=ct_monday_start size=5 maxlength=4 value=\"$ct_monday_start\"> </td><td align=right>"._QXZ("Monday Stop").":</td><td align=left><input type=text name=ct_monday_stop size=5 maxlength=4 value=\"$ct_monday_stop\"> $NWB#call_times-ct_sunday_start$NWE &nbsp; &nbsp; &nbsp; "._QXZ("AH Override").": <input type=text name=monday_afterhours_filename_override id=monday_afterhours_filename_override size=20 maxlength=255 value=\"$monday_afterhours_filename_override\"> <a href=\"javascript:launch_chooser('monday_afterhours_filename_override','date');\">"._QXZ("audio chooser")."</a> $NWB#call_times-default_afterhours_filename_override$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Tuesday Start").":</td><td align=left><input type=text name=ct_tuesday_start size=5 maxlength=4 value=\"$ct_tuesday_start\"> </td><td align=right>"._QXZ("Tuesday Stop").":</td><td align=left><input type=text name=ct_tuesday_stop size=5 maxlength=4 value=\"$ct_tuesday_stop\"> $NWB#call_times-ct_sunday_start$NWE &nbsp; &nbsp; &nbsp; "._QXZ("AH Override").": <input type=text name=tuesday_afterhours_filename_override id=tuesday_afterhours_filename_override size=20 maxlength=255 value=\"$tuesday_afterhours_filename_override\"> <a href=\"javascript:launch_chooser('tuesday_afterhours_filename_override','date');\">"._QXZ("audio chooser")."</a> $NWB#call_times-default_afterhours_filename_override$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Wednesday Start").":</td><td align=left><input type=text name=ct_wednesday_start size=5 maxlength=4 value=\"$ct_wednesday_start\"> </td><td align=right>"._QXZ("Wednesday Stop").":</td><td align=left><input type=text name=ct_wednesday_stop size=5 maxlength=4 value=\"$ct_wednesday_stop\"> $NWB#call_times-ct_sunday_start$NWE &nbsp; &nbsp; &nbsp; "._QXZ("AH Override").": <input type=text name=wednesday_afterhours_filename_override id=wednesday_afterhours_filename_override size=20 maxlength=255 value=\"$wednesday_afterhours_filename_override\"> <a href=\"javascript:launch_chooser('wednesday_afterhours_filename_override','date');\">"._QXZ("audio chooser")."</a> $NWB#call_times-default_afterhours_filename_override$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Thursday Start").":</td><td align=left><input type=text name=ct_thursday_start size=5 maxlength=4 value=\"$ct_thursday_start\"> </td><td align=right>"._QXZ("Thursday Stop").":</td><td align=left><input type=text name=ct_thursday_stop size=5 maxlength=4 value=\"$ct_thursday_stop\"> $NWB#call_times-ct_sunday_start$NWE &nbsp; &nbsp; &nbsp; "._QXZ("AH Override").": <input type=text name=thursday_afterhours_filename_override id=thursday_afterhours_filename_override size=20 maxlength=255 value=\"$thursday_afterhours_filename_override\"> <a href=\"javascript:launch_chooser('thursday_afterhours_filename_override','date');\">"._QXZ("audio chooser")."</a> $NWB#call_times-default_afterhours_filename_override$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Friday Start").":</td><td align=left><input type=text name=ct_friday_start size=5 maxlength=4 value=\"$ct_friday_start\"> </td><td align=right>"._QXZ("Friday Stop").":</td><td align=left><input type=text name=ct_friday_stop size=5 maxlength=4 value=\"$ct_friday_stop\"> $NWB#call_times-ct_sunday_start$NWE &nbsp; &nbsp; &nbsp; "._QXZ("AH Override").": <input type=text name=friday_afterhours_filename_override id=friday_afterhours_filename_override size=20 maxlength=255 value=\"$friday_afterhours_filename_override\"> <a href=\"javascript:launch_chooser('friday_afterhours_filename_override','date');\">"._QXZ("audio chooser")."</a> $NWB#call_times-default_afterhours_filename_override$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Saturday Start").":</td><td align=left><input type=text name=ct_saturday_start size=5 maxlength=4 value=\"$ct_saturday_start\"> </td><td align=right>"._QXZ("Saturday Stop").":</td><td align=left><input type=text name=ct_saturday_stop size=5 maxlength=4 value=\"$ct_saturday_stop\"> $NWB#call_times-ct_sunday_start$NWE &nbsp; &nbsp; &nbsp; "._QXZ("AH Override").": <input type=text name=saturday_afterhours_filename_override id=saturday_afterhours_filename_override size=20 maxlength=255 value=\"$saturday_afterhours_filename_override\"> <a href=\"javascript:launch_chooser('saturday_afterhours_filename_override','date');\">"._QXZ("audio chooser")."</a> $NWB#call_times-default_afterhours_filename_override$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=4><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></FORM></td></tr>\n";

		$ct_srs=1;
		$b=0;
		$srs_SQL ='';
		if (strlen($ct_state_call_times)>2)
			{
			$state_rules = explode('|',$ct_state_call_times);
			$ct_srs = ((count($state_rules)) - 1);
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center rowspan=$ct_srs>"._QXZ("Active State Call Time Definitions for this Record").": </td>\n";
		echo "<td align=center colspan=3>&nbsp;</td></tr>\n";
		while($ct_srs >= $b)
			{
			if (strlen($state_rules[$b])>0)
				{
				$stmt="SELECT state_call_time_state,state_call_time_name from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right colspan=2><a href=\"$PHP_SELF?ADD=3111111111&call_time_id=$state_rules[$b]\">$state_rules[$b] </a> - <a href=\"$PHP_SELF?ADD=321111111&call_time_id=$call_time_id&state_rule=$state_rules[$b]&stage=REMOVE\">"._QXZ("REMOVE")." </a></td><td align=left>$row[0] - $row[1]</td></tr>\n";
				$srs_SQL .= "'$state_rules[$b]',";
				$srs_state_SQL .= "'$row[0]',";
				}
			$b++;
			}
		if (strlen($srs_SQL)>2)
			{
			$srs_SQL = "$srs_SQL''";
			$srs_state_SQL = "$srs_state_SQL''";
			$srs_SQL = "where state_call_time_id NOT IN($srs_SQL) and state_call_time_state NOT IN($srs_state_SQL) $LOGadmin_viewable_groupsSQL";
			}
		else
			{$srs_SQL="$whereLOGadmin_viewable_groupsSQL";}
		$stmt="SELECT state_call_time_id,state_call_time_name from vicidial_state_call_times $srs_SQL order by state_call_time_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$sct_to_print = mysqli_num_rows($rslt);
		$sct_list='';

		$o=0;
		while ($sct_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$sct_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=321111111>\n";
		echo "<input type=hidden name=stage value=\"ADD\">\n";
		echo "<input type=hidden name=call_time_id value=\"$call_time_id\">\n";
		echo _QXZ("Add state call time rule").": </td><td align=left colspan=2><select size=1 name=state_rule>\n";
		echo "$sct_list";
		echo "</select></td>\n";
		echo "<td align=center colspan=4><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></FORM></td></tr>\n";


		$ct_hrs=1;
		$b=0;
		$hrs_SQL ='';
		if (strlen($ct_holidays)>2)
			{
			$holiday_rules = explode('|',$ct_holidays);
			$ct_hrs = ((count($holiday_rules)) - 1);
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center rowspan=$ct_hrs>"._QXZ("Active Holiday Definitions for this Record").": </td>\n";
		echo "<td align=center colspan=3>&nbsp;</td></tr>\n";
		while($ct_hrs >= $b)
			{
			if (strlen($holiday_rules[$b])>0)
				{
				$stmt="SELECT holiday_date,holiday_name from vicidial_call_time_holidays where holiday_id='$holiday_rules[$b]';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right colspan=2><a href=\"$PHP_SELF?ADD=3211111111&holiday_id=$holiday_rules[$b]\">$holiday_rules[$b] </a> - <a href=\"$PHP_SELF?ADD=321111111&call_time_id=$call_time_id&holiday_rule=$holiday_rules[$b]&stage=REMOVE\">"._QXZ("REMOVE")."</a></td><td align=left>$row[0] - $row[1]</td></tr>\n";
				$hrs_SQL .= "'$holiday_rules[$b]',";
				$hrs_holiday_SQL .= "'$row[0]',";
				}
			$b++;
			}
		if (strlen($hrs_SQL)>2)
			{
			$hrs_SQL = "$hrs_SQL''";
			$hrs_holiday_SQL = "$hrs_holiday_SQL''";
		#	$hrs_SQL = "where holiday_id NOT IN($hrs_SQL) and holiday_date NOT IN($hrs_holiday_SQL) $LOGadmin_viewable_groupsSQL";
			$hrs_SQL = "where holiday_id NOT IN($hrs_SQL) $LOGadmin_viewable_groupsSQL";
			}
		else
			{$hrs_SQL="$whereLOGadmin_viewable_groupsSQL";}
		$stmt="SELECT holiday_id,holiday_date from vicidial_call_time_holidays $hrs_SQL order by holiday_date;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$hct_to_print = mysqli_num_rows($rslt);
		if ($DB > 0) {echo "|$hct_to_print|$stmt|";}
		$hct_list='';

		$o=0;
		while ($hct_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$hct_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=321111111>\n";
		echo "<input type=hidden name=stage value=\"ADD\">\n";
		echo "<input type=hidden name=call_time_id value=\"$call_time_id\">\n";
		echo _QXZ("Add holiday rule").": </td><td align=left colspan=2><select size=1 name=holiday_rule>\n";
		echo "$hct_list";
		echo "</select></td>\n";
		echo "<td align=center colspan=4><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></FORM></td></tr>\n";


		echo "</TABLE><BR><BR>\n";
		echo "<B>"._QXZ("CAMPAIGNS USING THIS CALL TIME").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where local_call_time='$call_time_id' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$camps_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($camps_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=31&campaign_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE><BR>\n";
		echo "<B>"._QXZ("INBOUND GROUPS USING THIS CALL TIME").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT group_id,group_name from vicidial_inbound_groups where call_time_id='$call_time_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$camps_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($camps_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=3111&group_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE><BR>\n";
		echo "<B>"._QXZ("CALL MENUS USING THIS CALL TIME").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT menu_id,menu_name from vicidial_call_menu where call_time_id='$call_time_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$menus_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($menus_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=3511&menu_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE><BR>\n";
		echo "<B>"._QXZ("LISTS SET TO THIS CALL TIME").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT list_id,list_name from vicidial_lists where local_call_time='$call_time_id' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$lists_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($lists_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=311&list_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE>\n";
		echo "</center><BR><BR>\n";

		if ($LOGdelete_call_times > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=511111111&call_time_id=$call_time_id\">"._QXZ("DELETE THIS CALL TIME DEFINITION")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=CALLTIMES&stage=$call_time_id\">"._QXZ("Click here to see Admin changes to this call time")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You are not authorized to view this page. Please go back.");
		}

	}


######################
# ADD=3111111111 modify state call time definition info in the system
######################
if ($ADD==3111111111)
	{
	if ($LOGmodify_call_times==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=3111111111&call_time_id=$call_time_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT state_call_time_id,state_call_time_state,state_call_time_name,state_call_time_comments,sct_default_start,sct_default_stop,sct_sunday_start,sct_sunday_stop,sct_monday_start,sct_monday_stop,sct_tuesday_start,sct_tuesday_stop,sct_wednesday_start,sct_wednesday_stop,sct_thursday_start,sct_thursday_stop,sct_friday_start,sct_friday_stop,sct_saturday_start,sct_saturday_stop,user_group,ct_holidays from vicidial_state_call_times where state_call_time_id='$call_time_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$state_call_time_state =$row[1];
		$call_time_name =		$row[2];
		$call_time_comments =	$row[3];
		$ct_default_start =		$row[4];
		$ct_default_stop =		$row[5];
		$ct_sunday_start =		$row[6];
		$ct_sunday_stop =		$row[7];
		$ct_monday_start =		$row[8];
		$ct_monday_stop =		$row[9];
		$ct_tuesday_start =		$row[10];
		$ct_tuesday_stop =		$row[11];
		$ct_wednesday_start =	$row[12];
		$ct_wednesday_stop =	$row[13];
		$ct_thursday_start =	$row[14];
		$ct_thursday_stop =		$row[15];
		$ct_friday_start =		$row[16];
		$ct_friday_stop =		$row[17];
		$ct_saturday_start =	$row[18];
		$ct_saturday_stop =		$row[19];
		$user_group =			$row[20];
		$ct_holidays =			$row[21];

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("MODIFY A STATE CALL TIME")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=4111111111>\n";
		echo "<input type=hidden name=DB value=\"$DB\">\n";
		echo "<input type=hidden name=call_time_id value=\"$call_time_id\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Call Time ID").": </td><td align=left colspan=3><B>$call_time_id</B>$NWB#call_times-call_time_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("State Call Time State").": </td><td align=left colspan=3><input type=text name=state_call_time_state size=4 maxlength=2 value=\"$state_call_time_state\"> $NWB#call_times-state_call_time_state$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("State Call Time Name").": </td><td align=left colspan=3><input type=text name=call_time_name size=40 maxlength=50 value=\"$call_time_name\"> (short description of the call time)$NWB#call_times-call_time_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("State Call Time Comments").": </td><td align=left colspan=3><input type=text name=call_time_comments size=50 maxlength=255 value=\"$call_time_comments\"> $NWB#call_times-call_time_comments$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left colspan=3><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">$user_group</option>\n";
		echo "</select>$NWB#call_times-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Default Start").":</td><td align=left><input type=text name=ct_default_start size=5 maxlength=4 value=\"$ct_default_start\"> </td><td align=right>"._QXZ("Default Stop").":</td><td align=left><input type=text name=ct_default_stop size=5 maxlength=4 value=\"$ct_default_stop\"> $NWB#call_times-ct_default_start$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Sunday Start").":</td><td align=left><input type=text name=ct_sunday_start size=5 maxlength=4 value=\"$ct_sunday_start\"> </td><td align=right>"._QXZ("Sunday Stop").":</td><td align=left><input type=text name=ct_sunday_stop size=5 maxlength=4 value=\"$ct_sunday_stop\"> $NWB#call_times-ct_sunday_start$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Monday Start").":</td><td align=left><input type=text name=ct_monday_start size=5 maxlength=4 value=\"$ct_monday_start\"> </td><td align=right>"._QXZ("Monday Stop").":</td><td align=left><input type=text name=ct_monday_stop size=5 maxlength=4 value=\"$ct_monday_stop\"> $NWB#call_times-ct_sunday_start$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Tuesday Start").":</td><td align=left><input type=text name=ct_tuesday_start size=5 maxlength=4 value=\"$ct_tuesday_start\"> </td><td align=right>"._QXZ("Tuesday Stop").":</td><td align=left><input type=text name=ct_tuesday_stop size=5 maxlength=4 value=\"$ct_tuesday_stop\"> $NWB#call_times-ct_sunday_start$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Wednesday Start").":</td><td align=left><input type=text name=ct_wednesday_start size=5 maxlength=4 value=\"$ct_wednesday_start\"> </td><td align=right>"._QXZ("Wednesday Stop").":</td><td align=left><input type=text name=ct_wednesday_stop size=5 maxlength=4 value=\"$ct_wednesday_stop\"> $NWB#call_times-ct_sunday_start$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Thursday Start").":</td><td align=left><input type=text name=ct_thursday_start size=5 maxlength=4 value=\"$ct_thursday_start\"> </td><td align=right>"._QXZ("Thursday Stop").":</td><td align=left><input type=text name=ct_thursday_stop size=5 maxlength=4 value=\"$ct_thursday_stop\"> $NWB#call_times-ct_sunday_start$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Friday Start").":</td><td align=left><input type=text name=ct_friday_start size=5 maxlength=4 value=\"$ct_friday_start\"> </td><td align=right>"._QXZ("Friday Stop").":</td><td align=left><input type=text name=ct_friday_stop size=5 maxlength=4 value=\"$ct_friday_stop\"> $NWB#call_times-ct_sunday_start$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Saturday Start").":</td><td align=left><input type=text name=ct_saturday_start size=5 maxlength=4 value=\"$ct_saturday_start\"> </td><td align=right>"._QXZ("Saturday Stop").":</td><td align=left><input type=text name=ct_saturday_stop size=5 maxlength=4 value=\"$ct_saturday_stop\"> $NWB#call_times-ct_sunday_start$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=4><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=4>&nbsp;</form></td></tr>\n";



		$ct_hrs=1;
		$b=0;
		$hrs_SQL ='';
		if (strlen($ct_holidays)>2)
			{
			$holiday_rules = explode('|',$ct_holidays);
			$ct_hrs = ((count($holiday_rules)) - 1);
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center rowspan=$ct_hrs>"._QXZ("Active Outbound Holiday Definitions for this Record").": </td>\n";
		echo "<td align=center colspan=3>&nbsp;</td></tr>\n";
		while($ct_hrs >= $b)
			{
			if (strlen($holiday_rules[$b])>0)
				{
				$stmt="SELECT holiday_date,holiday_name from vicidial_call_time_holidays where holiday_id='$holiday_rules[$b]';";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				echo "<tr bgcolor=#$SSstd_row4_background><td align=right colspan=2><a href=\"$PHP_SELF?ADD=3211111111&holiday_id=$holiday_rules[$b]\">$holiday_rules[$b] </a> - <a href=\"$PHP_SELF?ADD=322111111&call_time_id=$call_time_id&holiday_rule=$holiday_rules[$b]&stage=REMOVE\">"._QXZ("REMOVE")."</a></td><td align=left>$row[0] - $row[1]</td></tr>\n";
				$hrs_SQL .= "'$holiday_rules[$b]',";
				$hrs_holiday_SQL .= "'$row[0]',";
				}
			$b++;
			}
		if (strlen($hrs_SQL)>2)
			{
			$hrs_SQL = "$hrs_SQL''";
			$hrs_holiday_SQL = "$hrs_holiday_SQL''";
			$hrs_SQL = "where holiday_id NOT IN($hrs_SQL) and holiday_date NOT IN($hrs_holiday_SQL) $LOGadmin_viewable_groupsSQL";
			}
		else
			{$hrs_SQL="$whereLOGadmin_viewable_groupsSQL";}
		$stmt="SELECT holiday_id,holiday_date from vicidial_call_time_holidays $hrs_SQL order by holiday_date;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$hct_to_print = mysqli_num_rows($rslt);
		$hct_list='';

		$o=0;
		while ($hct_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$hct_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=322111111>\n";
		echo "<input type=hidden name=stage value=\"ADD\">\n";
		echo "<input type=hidden name=call_time_id value=\"$call_time_id\">\n";
		echo _QXZ("Add outbound holiday rule").": </td><td align=left colspan=2><select size=1 name=holiday_rule>\n";
		echo "$hct_list";
		echo "</select></td>\n";
		echo "<td align=center colspan=4><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></FORM></td></tr>\n";



		# echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=4><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE><BR><BR>\n";
		echo "<B>"._QXZ("CALL TIMES USING THIS STATE CALL TIME").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT call_time_id,call_time_name from vicidial_call_times where ct_state_call_times LIKE \"%|$call_time_id|%\" $LOGadmin_viewable_call_timesSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$camps_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($camps_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=311111111&call_time_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE>\n";
		echo "</center><BR><BR>\n";

		if ($LOGdelete_call_times > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=5111111111&call_time_id=$call_time_id\">"._QXZ("DELETE THIS STATE CALL TIME DEFINITION")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=CALLTIMES_STATE&stage=$call_time_id\">"._QXZ("Click here to see Admin changes to this call time")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You are not authorized to view this page. Please go back.");
		}
	}


######################
# ADD=3211111111 modify holiday definition info in the system
######################
if ($ADD==3211111111)
	{
	if ($LOGmodify_call_times==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=3211111111&holiday_id=$holiday_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT holiday_id,holiday_date,holiday_name,holiday_comments,holiday_status,ct_default_start,ct_default_stop,user_group,default_afterhours_filename_override,holiday_method from vicidial_call_time_holidays where holiday_id='$holiday_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$holiday_date =							$row[1];
		$holiday_name =							$row[2];
		$holiday_comments =						$row[3];
		$holiday_status =						$row[4];
		$ct_default_start =						$row[5];
		$ct_default_stop =						$row[6];
		$user_group =							$row[7];
		$default_afterhours_filename_override =	$row[8];
		$holiday_method =						$row[9];

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("MODIFY A HOLIDAY")."<form action=$PHP_SELF method=POST id=vicidial_report name=vicidial_report>\n";
		echo "<input type=hidden name=ADD value=4211111111>\n";
		echo "<input type=hidden name=DB value=\"$DB\">\n";
		echo "<input type=hidden name=holiday_id value=\"$holiday_id\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Holiday ID").": </td><td align=left colspan=3><B>$holiday_id</B>$NWB#call_times-holiday_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Holiday Name").": </td><td align=left colspan=3><input type=text name=holiday_name size=40 maxlength=100 value=\"$holiday_name\"> (short description of the holiday)$NWB#call_times-holiday_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Holiday Comments").": </td><td align=left colspan=3><input type=text name=holiday_comments size=50 maxlength=255 value=\"$holiday_comments\"> $NWB#call_times-holiday_comments$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left colspan=3><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">$user_group</option>\n";
		echo "</select>$NWB#call_times-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Default Start").":</td><td align=left><input type=text name=ct_default_start size=5 maxlength=4 value=\"$ct_default_start\"> </td><td align=right>"._QXZ("Default Stop").":</td><td align=left><input type=text name=ct_default_stop size=5 maxlength=4 value=\"$ct_default_stop\"> $NWB#call_times-ct_default_start$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("AH Override").": </td><td align=left colspan=3><input type=text name=default_afterhours_filename_override id=default_afterhours_filename_override size=50 maxlength=255 value=\"$default_afterhours_filename_override\"> <a href=\"javascript:launch_chooser('default_afterhours_filename_override','date');\">"._QXZ("audio chooser")."</a> $NWB#call_times-default_afterhours_filename_override$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Holiday Date").": </td><td align=left colspan=3><input type=text name=holiday_date id=holiday_date size=10 maxlength=10 value=\"$holiday_date\">\n";
		echo "<script language=\"JavaScript\">\n";
		echo "var o_cal = new tcal ({\n";
		echo "	// form name\n";
		echo "	'formname': 'vicidial_report',\n";
		echo "	// input name\n";
		echo "	'controlname': 'holiday_date'\n";
		echo "});\n";
		echo "o_cal.a_tpl.yearscroll = false;\n";
		echo "// o_cal.a_tpl.weekstart = 1; // Monday week start\n";
		echo "</script> $NWB#call_times-holiday_date$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Holiday Status").": </td><td align=left colspan=3><select size=1 name=holiday_status><option value='ACTIVE'>"._QXZ("ACTIVE")."</option><option value='INACTIVE'>"._QXZ("INACTIVE")."</option><option value='EXPIRED'>"._QXZ("EXPIRED")."</option><option value='$holiday_status' SELECTED>"._QXZ("$holiday_status")."</option></select>$NWB#call_times-holiday_status$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Holiday Inbound Method").": </td><td align=left colspan=3><select size=1 name=holiday_method><option value='REPLACE'>"._QXZ("REPLACE")."</option><option value='ADDITION_REVERSE'>"._QXZ("ADDITION_REVERSE")."</option><option value='$holiday_method' SELECTED>"._QXZ("$holiday_method")."</option></select>$NWB#call_times-holiday_method$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=4><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE><BR><BR>\n";
		echo "<B>"._QXZ("CALL TIMES USING THIS HOLIDAY").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT call_time_id,call_time_name from vicidial_call_times where ct_holidays LIKE \"%|$holiday_id|%\" $LOGadmin_viewable_call_timesSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$camps_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($camps_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=311111111&call_time_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE><BR><BR>\n";
		echo "<B>"._QXZ("STATE CALL TIMES USING THIS HOLIDAY").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT state_call_time_id,state_call_time_state,state_call_time_name from vicidial_state_call_times where ct_holidays LIKE \"%|$holiday_id|%\";";
		$rslt=mysql_to_mysqli($stmt, $link);
		$camps_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($camps_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=3111111111&call_time_id=$row[0]\">$row[0] </a></TD><TD> $row[1] - $row[2]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE>\n";
		echo "</center><BR><BR>\n";

		if ($LOGdelete_call_times > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=5211111111&holiday_id=$holiday_id\">"._QXZ("DELETE THIS HOLIDAY DEFINITION")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=HOLIDAYS&stage=$holiday_id\">"._QXZ("Click here to see Admin changes to this holiday")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You are not authorized to view this page. Please go back.");
		}
	}


######################
# ADD=331111111 modify shift definition info in the system
######################
if ($ADD==331111111)
	{
	if ( ($LOGmodify_call_times==1) or ($LOGmodify_shifts==1) )
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=331111111&shift_id=$shift_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT shift_id,shift_name,shift_start_time,shift_length,shift_weekdays,report_option,user_group,report_rank from vicidial_shifts where shift_id='$shift_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$shift_name =		$row[1];
		$shift_start_time =	$row[2];
		$shift_length =		$row[3];
		$shift_weekdays =	$row[4];
		$report_option =	$row[5];
		$user_group =		$row[6];
		$report_rank =		$row[7];

		$shift_start_hour = substr($shift_start_time,0,2);
		$shift_start_min = substr($shift_start_time,2,2);
		$shift_length_hour = substr($shift_length,0,2);
		$shift_length_min = substr($shift_length,3,2);
		$shift_end_hour = ($shift_start_hour + $shift_length_hour);
		$shift_end_min = ($shift_start_min + $shift_length_min);
		if ($shift_end_min >=60) 
			{
			$shift_end_min = ($shift_end_min - 60);
			$shift_end_hour++;
			}
		if ($shift_end_hour >=24) 
			{
			$shift_end_hour = ($shift_end_hour - 24);
			}
		$shift_end_hour = sprintf("%02s", $shift_end_hour);	
		$shift_end_min = sprintf("%02s", $shift_end_min);	
		$shift_end = "$shift_end_hour$shift_end_min";

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("MODIFY A SHIFT")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=431111111>\n";
		echo "<input type=hidden name=DB value=\"$DB\">\n";
		echo "<input type=hidden name=shift_id value=\"$shift_id\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Shift ID").": </td><td align=left><B>$shift_id</B></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Shift Name").": </td><td align=left><input type=text name=shift_name size=50 maxlength=50 value=\"$shift_name\"> ("._QXZ("short description of the shift").")$NWB#shifts-shift_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">"._QXZ("$user_group")."</option>\n";
		echo "</select>$NWB#shifts-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Shift Start Time").": </td><td align=left><input type=text name=shift_start_time size=5 maxlength=4 id=shift_start_time value=\"$shift_start_time\">\n";
		echo " &nbsp; "._QXZ("Shift End Time").": <input type=text name=shift_end_time size=5 maxlength=4 id=shift_end_time value=\"$shift_end\">\n";
		echo "<input style='background-color:#$SSbutton_color' type=button name=shift_calc value=\""._QXZ("Calculate Shift Length")."\" onClick=\"shift_time();\"> $NWB#shifts-shift_start_time$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Shift Length").": </td><td align=left><input type=text name=shift_length id=shift_length size=6 maxlength=5 value=\"$shift_length\"> $NWB#shifts-shift_length$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Shift Weekdays").": <BR>$NWB#shifts-shift_weekdays$NWE</td><td align=left>\n";
		echo "<input type=\"checkbox\" name=\"shift_weekdays[]\" value=\"0\"";
			if (preg_match('/0/',$shift_weekdays)) {echo " CHECKED";}
		echo ">"._QXZ("Sunday")."<BR>\n";
		echo "<input type=\"checkbox\" name=\"shift_weekdays[]\" value=\"1\"";
			if (preg_match('/1/',$shift_weekdays)) {echo " CHECKED";}
		echo ">"._QXZ("Monday")."<BR>\n";
		echo "<input type=\"checkbox\" name=\"shift_weekdays[]\" value=\"2\"";
			if (preg_match('/2/',$shift_weekdays)) {echo " CHECKED";}
		echo ">"._QXZ("Tuesday")."<BR>\n";
		echo "<input type=\"checkbox\" name=\"shift_weekdays[]\" value=\"3\"";
			if (preg_match('/3/',$shift_weekdays)) {echo " CHECKED";}
		echo ">"._QXZ("Wednesday")."<BR>\n";
		echo "<input type=\"checkbox\" name=\"shift_weekdays[]\" value=\"4\"";
			if (preg_match('/4/',$shift_weekdays)) {echo " CHECKED";}
		echo ">"._QXZ("Thursday")."<BR>\n";
		echo "<input type=\"checkbox\" name=\"shift_weekdays[]\" value=\"5\"";
			if (preg_match('/5/',$shift_weekdays)) {echo " CHECKED";}
		echo ">"._QXZ("Friday")."<BR>\n";
		echo "<input type=\"checkbox\" name=\"shift_weekdays[]\" value=\"6\"";
			if (preg_match('/6/',$shift_weekdays)) {echo " CHECKED";}
		echo ">"._QXZ("Saturday")."<BR>\n";
		echo "</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Report Option").": </td><td align=left><select size=1 name=report_option><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$report_option' SELECTED>"._QXZ("$report_option")."</option></select>$NWB#shifts-report_option$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Report Rank").": </td><td align=left><select size=1 name=report_rank><option SELECTED>$report_rank</option>";
		$k=1;
		while ($k < 100)
			{
			echo "<option>$k</option>\n";
			$k++;
			}
		echo "</select>$NWB#shifts-report_rank$NWE</td></tr>\n";
		
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";

		echo "</TABLE><BR><BR>\n";
		echo "<B>"._QXZ("USER GROUPS USING THIS SHIFT").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT user_group,group_name from vicidial_user_groups where group_shifts LIKE\"% $shift_id %\" $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$camps_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($camps_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=311111&user_group=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE>\n";
		echo "</center><BR><BR>\n";

		if ($LOGdelete_call_times > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=531111111&shift_id=$shift_id\">"._QXZ("DELETE THIS SHIFT DEFINITION")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=SHIFTS&stage=$shift_id\">"._QXZ("Click here to see Admin changes to this shift")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You are not authorized to view this page. Please go back.");
		}

	}


######################
# ADD=31111111111 modify phone record in the system
######################
if ($ADD==31111111111)
	{
	if ( ($LOGast_admin_access==1) or ($LOGmodify_phones==1) )
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=31111111111&extension=$extension&server_ip=$server_ip";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,messages,old_messages,protocol,local_gmt,ASTmgrUSERNAME,ASTmgrSECRET,login_user,login_pass,login_campaign,park_on_extension,conf_on_extension,VICIDIAL_park_on_extension,VICIDIAL_park_on_filename,monitor_prefix,recording_exten,voicemail_exten,voicemail_dump_exten,ext_context,dtmf_send_extension,call_out_number_group,client_browser,install_directory,local_web_callerID_URL,VICIDIAL_web_URL,AGI_call_logging_enabled,user_switching_enabled,conferencing_enabled,admin_hangup_enabled,admin_hijack_enabled,admin_monitor_enabled,call_parking_enabled,updater_check_enabled,AFLogging_enabled,QUEUE_ACTION_enabled,CallerID_popup_enabled,voicemail_button_enabled,enable_fast_refresh,fast_refresh_rate,enable_persistant_mysql,auto_dial_next_number,VDstop_rec_after_each_call,DBX_server,DBX_database,DBX_user,DBX_pass,DBX_port,DBY_server,DBY_database,DBY_user,DBY_pass,DBY_port,outbound_cid,enable_sipsak_messages,email,template_id,conf_override,phone_context,phone_ring_timeout,conf_secret,delete_vm_after_email,is_webphone,use_external_server_ip,codecs_list,codecs_with_template,webphone_dialpad,on_hook_agent,webphone_auto_answer,voicemail_timezone,voicemail_options,user_group,voicemail_greeting,voicemail_dump_exten_no_inst,voicemail_instructions,on_login_report,unavail_dialplan_fwd_exten,unavail_dialplan_fwd_context,nva_call_url,nva_search_method,nva_error_filename,nva_new_list_id,nva_new_phone_code,nva_new_status,webphone_dialbox,webphone_mute,webphone_volume,webphone_debug,outbound_alt_cid,conf_qualify,webphone_layout,mohsuggest,webphone_settings from phones where extension='$extension' and server_ip='$server_ip' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);

		echo "<br>"._QXZ("MODIFY A PHONE RECORD").": $row[1]<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=41111111111>\n";
		echo "<input type=hidden name=old_extension value=\"$row[0]\">\n";
		echo "<input type=hidden name=old_server_ip value=\"$row[5]\">\n";
		echo "<input type=hidden name=client_browser value=\"$row[34]\">\n";
		echo "<input type=hidden name=install_directory value=\"$row[35]\">\n";

		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Phone Extension").": </td><td align=left><input type=text name=extension size=20 maxlength=100 value=\"$row[0]\">$NWB#phones-extension$NWE <i></i></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Dial Plan Number").": </td><td align=left><input type=text name=dialplan_number size=15 maxlength=20 value=\"$row[1]\"> ("._QXZ("digits only").")$NWB#phones-dialplan_number$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Voicemail Box").": </td><td align=left><input type=text name=voicemail_id size=10 maxlength=10 value=\"$row[2]\"> ("._QXZ("digits only").")$NWB#phones-voicemail_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Outbound CallerID").": </td><td align=left><input type=text name=outbound_cid size=10 maxlength=20 value=\"$row[65]\"> ("._QXZ("digits only").")$NWB#phones-outbound_cid$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Outbound Alt CallerID").": </td><td align=left><input type=text name=outbound_alt_cid size=10 maxlength=20 value=\"$row[100]\"> <i>"._QXZ("optional")."</i> ("._QXZ("digits only").")$NWB#phones-outbound_alt_cid$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$row[83]\">"._QXZ("$row[83]")."</option>\n";
		echo "</select>$NWB#phones-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Phone IP address").": </td><td align=left><input type=text name=phone_ip size=20 maxlength=15 value=\"$row[3]\"> ("._QXZ("optional").")$NWB#phones-phone_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Computer IP address").": </td><td align=left><input type=text name=computer_ip size=20 maxlength=15 value=\"$row[4]\"> ("._QXZ("optional").")$NWB#phones-computer_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=311111111111&server_ip=$row[5]\">"._QXZ("Server IP")."</a>: </td><td align=left><select size=1 name=server_ip>\n";

		echo "$servers_list";
		echo "<option SELECTED>$row[5]</option>\n";
		echo "</select>$NWB#phones-server_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Screen Login").": </td><td align=left><input type=text name=login size=15 maxlength=15 value=\"$row[6]\">$NWB#phones-login$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Login Password").": </td><td align=left><input type=text name=pass size=40 maxlength=100 value=\"$row[7]\">$NWB#phones-pass$NWE</td></tr>\n";
		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Registration Password").": </td><td align=left style=\"display:table-cell; vertical-align:middle;\" NOWRAP><input type=text id=reg_pass name=conf_secret size=40 maxlength=100 value=\"$row[72]\" onkeyup=\"return pwdChanged('reg_pass','reg_pass_img','pass_length','$SSrequire_password_length');\">$NWB#phones-conf_secret$NWE &nbsp; &nbsp; <font size=1>"._QXZ("Strength").":</font> <IMG id=reg_pass_img src='images/pixel.gif' style=\"vertical-align:middle;\" onLoad=\"return pwdChanged('reg_pass','reg_pass_img','pass_length','$SSrequire_password_length');\"> &nbsp; <font size=1> "._QXZ("Length").": <span id=pass_length name=pass_length>0</span></font></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Set As Webphone").": </td><td align=left><select size=1 name=is_webphone><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option>Y_API_LAUNCH</option><option selected value='$row[74]'>"._QXZ("$row[74]")."</option></select>$NWB#phones-is_webphone$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Webphone Dialpad").": </td><td align=left><select size=1 name=webphone_dialpad><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='TOGGLE'>"._QXZ("TOGGLE")."</option><option value='TOGGLE_OFF'>"._QXZ("TOGGLE_OFF")."</option><option value=\"$row[78]\" SELECTED>"._QXZ("$row[78]")."</option></select>$NWB#phones-webphone_dialpad$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Webphone Auto-Answer").": </td><td align=left><select size=1 name=webphone_auto_answer><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option SELECTED value='$row[80]'>"._QXZ("$row[80]")."</option></select>$NWB#phones-webphone_auto_answer$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Webphone Dialbox").": </td><td align=left><select size=1 name=webphone_dialbox><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option SELECTED value='$row[96]'>"._QXZ("$row[96]")."</option></select>$NWB#phones-webphone_dialbox$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Webphone Mute").": </td><td align=left><select size=1 name=webphone_mute><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option SELECTED value='$row[97]'>"._QXZ("$row[97]")."</option></select>$NWB#phones-webphone_mute$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Webphone Volume").": </td><td align=left><select size=1 name=webphone_volume><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option SELECTED value='$row[98]'>"._QXZ("$row[98]")."</option></select>$NWB#phones-webphone_volume$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Webphone Debug").": </td><td align=left><select size=1 name=webphone_debug><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option SELECTED value='$row[99]'>"._QXZ("$row[99]")."</option></select>$NWB#phones-webphone_debug$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Webphone Layout").": </td><td align=left><input type=text name=webphone_layout size=60 maxlength=255 value=\"$row[102]\">$NWB#phones-webphone_layout$NWE</td></tr>\n";

		##### get container listings for dynamic WEBPHONE_SETTINGS container pulldown menu
		$stmt="SELECT container_id,container_notes from vicidial_settings_containers where container_type='WEBPHONE_SETTINGS' $LOGadmin_viewable_groupsSQL order by container_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$pws_to_print = mysqli_num_rows($rslt);
		$webphone_settings_menu='';
		$pws_selected=0;
		$o=0;
		while ($pws_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			if (mb_strlen($rowx[1],'utf-8')>40)
				{$rowx[1] = mb_substr($rowx[1],0,40,'utf-8') . '...';}
			$webphone_settings_menu .= "<option ";
			if ($row[104] == "$rowx[0]") 
				{
				$webphone_settings_menu .= "SELECTED ";
				$pws_selected++;
				}
			$webphone_settings_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>";
		if ($pws_selected > 0)
			{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$row[104]\">"._QXZ("Webphone Extra Settings")."</a>";}
		else
			{echo _QXZ("Webphone Extra Settings");}
		echo ": </td><td align=left nowrap><select size=1 name=webphone_settings><option value=''>"._QXZ("DISABLED")."</option>$webphone_settings_menu</select>$NWB#phones-webphone_settings$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Use External Server IP").": </td><td align=left><select size=1 name=use_external_server_ip><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option selected value='$row[75]'>"._QXZ("$row[75]")."</option></select>$NWB#phones-use_external_server_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Status").": </td><td align=left><select size=1 name=status><option value='ACTIVE'>"._QXZ("ACTIVE")."</option><option value='SUSPENDED'>"._QXZ("SUSPENDED")."</option><option value='CLOSED'>"._QXZ("CLOSED")."</option><option value='PENDING'>"._QXZ("PENDING")."</option><option value='ADMIN'>"._QXZ("ADMIN")."</option><option value='$row[8]' selected>"._QXZ("$row[8]")."</option></select>$NWB#phones-status$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active Account").": </td><td align=left><select size=1 name=active><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$row[9]' selected>"._QXZ("$row[9]")."</option></select>$NWB#phones-active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Phone Type").": </td><td align=left><input type=text name=phone_type size=20 maxlength=50 value=\"$row[10]\">$NWB#phones-phone_type$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Full Name").": </td><td align=left><input type=text name=fullname size=20 maxlength=50 value=\"$row[11]\">$NWB#phones-fullname$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Email").": </td><td align=left><input type=text name=email size=50 maxlength=100 value=\"$row[67]\"> $NWB#phones-email$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Delete Voicemail After Email").": </td><td align=left><select size=1 name=delete_vm_after_email><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$row[73]' selected>"._QXZ("$row[73]")."</option></select>$NWB#phones-delete_vm_after_email$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Voicemail Zone").": </td><td align=left><select size=1 name=voicemail_timezone>";
		$vm_zones = explode("\n",$SSvoicemail_timezones);
		$z=0;
		$vm_zones_ct = count($vm_zones);
		while($vm_zones_ct > $z)
			{
			if (strlen($vm_zones[$z]) > 5)
				{
				$vm_specs = explode("=",$vm_zones[$z]);
				$vm_abb = $vm_specs[0];
				$vm_details = explode('|',$vm_specs[1]);
				$vm_location = 	$vm_details[0];
				echo "<option value=\"$vm_abb\">$vm_abb - $vm_location</option>\n";
				}
			$z++;
			}
		echo "<option selected value='$row[81]'>"._QXZ("$row[81]")."</option></select> $NWB#phones-voicemail_timezone$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Voicemail Options").": </td><td align=left><input type=hidden name=old_voicemail_greeting value=\"$row[84]\"><input type=text name=voicemail_options size=50 maxlength=100 value=\"$row[82]\">$NWB#phones-voicemail_options$NWE</td></tr>\n";
		if ($SSallow_voicemail_greeting > 0)
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Voicemail Greeting").": </td><td><input type=text size=50 maxlength=100 name=voicemail_greeting id=voicemail_greeting value=\"$row[84]\"> <a href=\"javascript:launch_chooser('voicemail_greeting','date');\">"._QXZ("audio chooser")."</a>  $NWB#phones-voicemail_greeting$NWE</td></tr>\n";
			}
		else
			{
			echo "<input type=hidden name=voicemail_greeting value=\"$row[84]\">";
			echo "<input type=hidden name=old_voicemail_greeting value=\"$row[84]\">";
			}
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Voicemail Instructions").": </td><td align=left><select size=1 name=voicemail_instructions><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$row[86]' selected>"._QXZ("$row[86]")."</option></select>$NWB#phones-voicemail_instructions$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Show VM on Summary Screen").": </td><td align=left><select size=1 name=show_vm_on_summary><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$row[87]' selected>"._QXZ("$row[87]")."</option></select>$NWB#phones-show_vm_on_summary$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Unavailable Dialplan Forward").": </td><td align=left><input type=text name=unavail_dialplan_fwd_exten size=20 maxlength=40 value=\"$row[88]\"> "._QXZ("context").": <input type=text name=unavail_dialplan_fwd_context size=20 maxlength=100 value=\"$row[89]\">$NWB#phones-unavail_dialplan_fwd_exten$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Music on Hold Suggest").": </td><td><input type=text size=50 maxlength=100 name=mohsuggest id=mohsuggest value=\"$row[103]\"> <a href=\"javascript:launch_moh_chooser('mohsuggest','moh');\">"._QXZ("moh chooser")."</a>  $NWB#phones-mohsuggest$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Company").": </td><td align=left><input type=text name=company size=10 maxlength=10 value=\"$row[12]\">$NWB#phones-company$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Picture").": </td><td align=left><input type=text name=picture size=20 maxlength=19 value=\"$row[13]\">$NWB#phones-picture$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("New Messages").": </td><td align=left><b>$row[14]</b>$NWB#phones-messages$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Old Messages").": </td><td align=left><b>$row[15]</b>$NWB#phones-old_messages$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Client Protocol").": </td><td align=left><select size=1 name=protocol>";
		if ( ($SSallowed_sip_stacks == 'SIP') or ($SSallowed_sip_stacks == 'SIP_and_PJSIP') ) {echo "<option>SIP</option>";}
		if ( ($SSallowed_sip_stacks == 'PJSIP') or ($SSallowed_sip_stacks == 'SIP_and_PJSIP') ) {echo "<option>PJSIP</option>";}
		echo "<option>Zap</option>";
		echo "<option>IAX2</option>";
		echo "<option value='EXTERNAL'>"._QXZ("EXTERNAL")."</option>";
		echo "<option>DAHDI</option>";
		echo "<option selected value='$row[16]'>"._QXZ("$row[16]")."</option></select>$NWB#phones-protocol$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Local GMT").": </td><td align=left><select size=1 name=local_gmt><option>12.75</option><option>12.00</option><option>11.00</option><option>10.00</option><option>9.50</option><option>9.00</option><option>8.00</option><option>7.00</option><option>6.50</option><option>6.00</option><option>5.75</option><option>5.50</option><option>5.00</option><option>4.50</option><option>4.00</option><option>3.50</option><option>3.00</option><option>2.00</option><option>1.00</option><option>0.00</option><option>-1.00</option><option>-2.00</option><option>-3.00</option><option>-3.50</option><option>-4.00</option><option>-5.00</option><option>-6.00</option><option>-7.00</option><option>-8.00</option><option>-9.00</option><option>-10.00</option><option>-11.00</option><option>-12.00</option><option selected value='$row[17]'>"._QXZ("$row[17]")."</option></select> ("._QXZ("Do NOT Adjust for DST").")$NWB#phones-local_gmt$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Phone Ring Timeout").": </td><td align=left><input type=text name=phone_ring_timeout size=4 maxlength=5 value=\"$row[71]\">$NWB#phones-phone_ring_timeout$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("On-Hook Agent").": </td><td align=left><select size=1 name=on_hook_agent><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option selected value='$row[79]'>"._QXZ("$row[79]")."</option></select>$NWB#phones-on_hook_agent$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Manager Login").": </td><td align=left><input type=text name=ASTmgrUSERNAME size=20 maxlength=20 value=\"$row[18]\">$NWB#phones-ASTmgrUSERNAME$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Manager Secret").": </td><td align=left><input type=text name=ASTmgrSECRET size=20 maxlength=20 value=\"$row[19]\">$NWB#phones-ASTmgrSECRET$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent  Default User").": </td><td align=left><input type=text name=login_user size=20 maxlength=20 value=\"$row[20]\">$NWB#phones-login_user$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Default Pass").": </td><td align=left><input type=text name=login_pass size=20 maxlength=20 value=\"$row[21]\">$NWB#phones-login_pass$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Default Campaign").": </td><td align=left><input type=text name=login_campaign size=10 maxlength=10 value=\"$row[22]\">$NWB#phones-login_campaign$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Park Exten").": </td><td align=left><input type=text name=park_on_extension size=10 maxlength=10 value=\"$row[23]\">$NWB#phones-park_on_extension$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Conf Exten").": </td><td align=left><input type=text name=conf_on_extension size=10 maxlength=10 value=\"$row[24]\">$NWB#phones-conf_on_extension$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Park Exten").": </td><td align=left><input type=text name=VICIDIAL_park_on_extension size=10 maxlength=10 value=\"$row[25]\">$NWB#phones-agent_park_on_extension$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Park File").": </td><td align=left><input type=text name=VICIDIAL_park_on_filename size=10 maxlength=10 value=\"$row[26]\">$NWB#phones-park_on_filename$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Monitor Prefix").": </td><td align=left><input type=text name=monitor_prefix size=10 maxlength=10 value=\"$row[27]\">$NWB#phones-monitor_prefix$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Recording Exten").": </td><td align=left><input type=text name=recording_exten size=10 maxlength=10 value=\"$row[28]\">$NWB#phones-recording_exten$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("VMailMain Exten").": </td><td align=left><input type=text name=voicemail_exten size=10 maxlength=10 value=\"$row[29]\">$NWB#phones-voicemail_exten$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("VMailDump Exten").": </td><td align=left><input type=text name=voicemail_dump_exten size=20 maxlength=20 value=\"$row[30]\">$NWB#phones-voicemail_dump_exten$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("VMailDump Exten NI").": </td><td align=left><input type=text name=voicemail_dump_exten_no_inst size=20 maxlength=20 value=\"$row[85]\">$NWB#phones-voicemail_dump_exten_no_inst$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Exten Context").": </td><td align=left><input type=text name=ext_context size=20 maxlength=20 value=\"$row[31]\">$NWB#phones-ext_context$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Phone Context").": </td><td align=left><input type=text name=phone_context size=20 maxlength=20 value=\"$row[70]\">$NWB#phones-phone_context$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Allowed Codecs").": </td><td align=left><input type=text name=codecs_list size=40 maxlength=100 value=\"$row[76]\">$NWB#phones-codecs_list$NWE</td></tr>\n";
		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Allowed Codecs With Template").": </td><td align=left><select size=1 name=codecs_with_template><option>1</option><option>0</option><option selected>$row[77]</option></select>$NWB#phones-codecs_with_template$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Conf Qualify").": </td><td align=left><select size=1 name=conf_qualify><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value=\"$row[101]\" SELECTED>"._QXZ("$row[101]")."</option></select>$NWB#phones-conf_qualify$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("DTMFSend Channel").": </td><td align=left><input type=text name=dtmf_send_extension size=40 maxlength=100 value=\"$row[32]\">$NWB#phones-dtmf_send_extension$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Outbound Call Group").": </td><td align=left><input type=text name=call_out_number_group size=40 maxlength=100 value=\"$row[33]\">$NWB#phones-call_out_number_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("CallerID URL").": </td><td align=left><input type=text name=local_web_callerID_URL size=40 maxlength=255 value=\"$row[36]\">$NWB#phones-local_web_callerID_URL$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Default URL").": </td><td align=left><input type=text name=agent_web_URL size=40 maxlength=255 value=\"$row[37]\">$NWB#phones-agent_web_URL$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("NVA Call URL").": </td><td align=left><input type=text name=nva_call_url size=40 maxlength=2000 value=\"$row[90]\">$NWB#phones-nva_call_url$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("NVA Search Method").": </td><td align=left><input type=text name=nva_search_method size=20 maxlength=40 value=\"$row[91]\">$NWB#phones-nva_search_method$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("NVA Error Filename").": </td><td align=left colspan=3><input type=text name=nva_error_filename id=nva_error_filename size=40 maxlength=255 value=\"$row[92]\"> <a href=\"javascript:launch_chooser('nva_error_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#phones-nva_error_filename$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("NVA New List ID").": </td><td align=left><input type=text name=nva_new_list_id size=15 maxlength=14 value=\"$row[93]\">$NWB#phones-nva_new_list_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("NVA New Phone Code").": </td><td align=left><input type=text name=nva_new_phone_code size=11 maxlength=10 value=\"$row[94]\">$NWB#phones-nva_new_phone_code$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("NVA New Status").": </td><td align=left><input type=text name=nva_new_status size=7 maxlength=6 value=\"$row[95]\">$NWB#phones-nva_new_status$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Call Logging").": </td><td align=left><select size=1 name=AGI_call_logging_enabled><option>1</option><option>0</option><option selected>$row[38]</option></select>$NWB#phones-AGI_call_logging_enabled$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User Switching").": </td><td align=left><select size=1 name=user_switching_enabled><option>1</option><option>0</option><option selected>$row[39]</option></select>$NWB#phones-user_switching_enabled$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Conferencing").": </td><td align=left><select size=1 name=conferencing_enabled><option>1</option><option>0</option><option selected>$row[40]</option></select>$NWB#phones-conferencing_enabled$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin Hang Up").": </td><td align=left><select size=1 name=admin_hangup_enabled><option>1</option><option>0</option><option selected>$row[41]</option></select>$NWB#phones-admin_hangup_enabled$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin Hijack").": </td><td align=left><select size=1 name=admin_hijack_enabled><option>1</option><option>0</option><option selected>$row[42]</option></select>$NWB#phones-admin_hijack_enabled$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin Monitor").": </td><td align=left><select size=1 name=admin_monitor_enabled><option>1</option><option>0</option><option selected>$row[43]</option></select>$NWB#phones-admin_monitor_enabled$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Call Park").": </td><td align=left><select size=1 name=call_parking_enabled><option>1</option><option>0</option><option selected>$row[44]</option></select>$NWB#phones-call_parking_enabled$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Updater Check").": </td><td align=left><select size=1 name=updater_check_enabled><option>1</option><option>0</option><option selected>$row[45]</option></select>$NWB#phones-updater_check_enabled$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("AF Logging").": </td><td align=left><select size=1 name=AFLogging_enabled><option>1</option><option>0</option><option selected>$row[46]</option></select>$NWB#phones-AFLogging_enabled$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Queue Enabled").": </td><td align=left><select size=1 name=QUEUE_ACTION_enabled><option>1</option><option>0</option><option selected>$row[47]</option></select>$NWB#phones-QUEUE_ACTION_enabled$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("CallerID Popup").": </td><td align=left><select size=1 name=CallerID_popup_enabled><option>1</option><option>0</option><option selected>$row[48]</option></select>$NWB#phones-CallerID_popup_enabled$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("VMail Button").": </td><td align=left><select size=1 name=voicemail_button_enabled><option>1</option><option>0</option><option selected>$row[49]</option></select>$NWB#phones-voicemail_button_enabled$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Fast Refresh").": </td><td align=left><select size=1 name=enable_fast_refresh><option>1</option><option>0</option><option selected>$row[50]</option></select>$NWB#phones-enable_fast_refresh$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Fast Refresh Rate").": </td><td align=left><input type=text size=5 name=fast_refresh_rate value=\"$row[51]\">("._QXZ("in ms").")$NWB#phones-fast_refresh_rate$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Persistant MySQL").": </td><td align=left><select size=1 name=enable_persistant_mysql><option>1</option><option>0</option><option selected>$row[52]</option></select>$NWB#phones-enable_persistant_mysql$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Auto Dial Next Number").": </td><td align=left><select size=1 name=auto_dial_next_number><option>1</option><option>0</option><option selected>$row[53]</option></select>$NWB#phones-auto_dial_next_number$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Stop Rec after each call").": </td><td align=left><select size=1 name=VDstop_rec_after_each_call><option>1</option><option>0</option><option selected>$row[54]</option></select>$NWB#phones-VDstop_rec_after_each_call$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Enable SIPSAK Messages").": </td><td align=left><select size=1 name=enable_sipsak_messages><option>1</option><option>0</option><option selected>$row[66]</option></select>$NWB#phones-enable_sipsak_messages$NWE</td></tr>\n";

		# unused old DB connection fields
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right colspan=2><input type=hidden name=DBX_server value=\"$row[55]\"><input type=hidden name=DBX_database value=\"$row[56]\"><input type=hidden name=DBX_user value=\"$row[57]\"><input type=hidden name=DBX_pass value=\"$row[58]\"><input type=hidden name=DBX_port value=\"$row[59]\"><input type=hidden name=DBY_server value=\"$row[60]\"><input type=hidden name=DBY_database value=\"$row[61]\"><input type=hidden name=DBY_user value=\"$row[62]\"><input type=hidden name=DBY_pass value=\"$row[63]\"><input type=hidden name=DBY_port value=\"$row[64]\"></td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=331111111111&template_id=$row[68]\">"._QXZ("Template ID")."</a>: </td><td align=left><select size=1 name=template_id>\n";
		$stmt="SELECT template_id,template_name from vicidial_conf_templates $whereLOGadmin_viewable_groupsSQL order by template_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$templates_to_print = mysqli_num_rows($rslt);
		$templates_list='<option value=\'--NONE--\' SELECTED>--'._QXZ("NONE").'--</option>';
		$o=0;
		while ($templates_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$templates_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		echo "$templates_list";
		echo "<option SELECTED value='$row[68]'>"._QXZ("$row[68]")."</option>\n";
		echo "</select>$NWB#phones-template_id$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Conf Override").": </td><td align=left><TEXTAREA NAME=conf_override ROWS=10 COLS=70>$row[69]</TEXTAREA> $NWB#phones-conf_override$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";

		echo "<br><br><a href=\"./phone_stats.php?extension=$row[0]&server_ip=$row[5]\">"._QXZ("Click here for phone stats")."</a>\n";

		echo "<br><br><a href=\"./user_stats.php?user=$row[0]\">"._QXZ("Click here for phone call recordings")."</a>\n";

		if ($LOGast_delete_phones > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=51111111111&extension=$extension&server_ip=$server_ip\">"._QXZ("DELETE THIS PHONE")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=PHONES&stage=$extension\">"._QXZ("Click here to see Admin changes to this phone")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=32111111111 modify phone alias record in the system
######################
if ($ADD==32111111111)
	{
	if ( ($LOGast_admin_access==1) or ($LOGmodify_phones==1) )
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=32111111111&alias_id=$alias_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT alias_id,alias_name,logins_list,user_group from phones_alias where alias_id='$alias_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);

		echo "<br>"._QXZ("MODIFY A PHONE ALIAS RECORD").": $row[0]<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=42111111111>\n";
		echo "<input type=hidden name=alias_id value=\"$row[0]\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Alias ID").": </td><td align=left><B>$row[0]</B> $NWB#phones-alias_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Alias Name").": </td><td align=left><input type=text name=alias_name size=30 maxlength=50 value=\"$row[1]\"> $NWB#phones-alias_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$row[3]\">"._QXZ("$row[3]")."</option>\n";
		echo "</select>$NWB#phones-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Phones Logins List").": </td><td align=left><input type=text name=logins_list size=50 maxlength=255 value=\"$row[2]\"> ("._QXZ("comma separated").")$NWB#phones-logins_list$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";


		### list of phones in this phones alias
		$phone_alias_SQL = preg_replace('/,/', "','",$row[2]);
	 
		echo "<center>\n";
		echo "<br><b>"._QXZ("PHONES WITHIN THIS PHONES ALIAS").":</b><br>\n";
		echo "<TABLE width=600 cellspacing=3>\n";
		echo "<tr><td>"._QXZ("LOGIN")."</td><td>"._QXZ("EXTENSION")."</td><td>"._QXZ("SERVER")."</td><td>"._QXZ("PROTOCOL")."</td><td>"._QXZ("IP")."</td></tr>\n";

		$stmt="SELECT login,extension,server_ip,protocol,phone_ip from phones where login IN ('$phone_alias_SQL') $LOGadmin_viewable_groupsSQL;";
		if ($DB) {echo "|$stmt|";}
		$rsltx=mysql_to_mysqli($stmt, $link);
		$lists_to_print = mysqli_num_rows($rsltx);

		$o=0;
		while ($lists_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rsltx);
			$o++;

			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

			echo "<tr $bgcolor><td><font size=1><a href=\"$PHP_SELF?ADD=31111111111&extension=$rowx[1]&server_ip=$rowx[2]\">$rowx[0]</a></td><td><font size=1>$rowx[1]</td><td><font size=1>$rowx[2]</td><td><font size=1>$rowx[3]</td><td><font size=1>$rowx[4]</td></tr>\n";
			}

		echo "</table></center><br>\n";

		if ($LOGast_delete_phones > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=52111111111&alias_id=$row[0]\">"._QXZ("DELETE THIS PHONE ALIAS")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=PHONEALIASES&stage=$alias_id\">"._QXZ("Click here to see Admin changes to this phone alias")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=33111111111 modify group alias record in the system
######################
if ($ADD==33111111111)
	{
	if ( ($LOGast_admin_access==1) or ($LOGmodify_phones==1) )
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=33111111111&group_alias_id=$group_alias_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT group_alias_id,group_alias_name,caller_id_number,caller_id_name,active,user_group from groups_alias where group_alias_id='$group_alias_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);

		echo "<br>"._QXZ("MODIFY A GROUP ALIAS RECORD").": $row[0]<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=43111111111>\n";
		echo "<input type=hidden name=group_alias_id value=\"$row[0]\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group Alias ID").": </td><td align=left><B>$row[0]</B> $NWB#phones-group_alias_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group Alias Name").": </td><td align=left><input type=text name=group_alias_name size=30 maxlength=50 value=\"$row[1]\"> $NWB#phones-group_alias_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$row[5]\">"._QXZ("$row[5]")."</option>\n";
		echo "</select>$NWB#phones-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("CallerID Number").": </td><td align=left><input type=text name=caller_id_number size=20 maxlength=20 value=\"$row[2]\"> $NWB#phones-caller_id_number$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("CallerID Name").": </td><td align=left><input type=text name=caller_id_name size=20 maxlength=20 value=\"$row[3]\"> $NWB#phones-caller_id_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option selected value='$row[4]'>"._QXZ("$row[4]")."</option></select></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";


		if ($LOGast_delete_phones > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=53111111111&group_alias_id=$row[0]\">"._QXZ("DELETE THIS GROUP ALIAS")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=GROUPALIASES&stage=$group_alias_id\">"._QXZ("Click here to see Admin changes to this group alias")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=311111111111 modify server record in the system
######################
if ($ADD==311111111111)
	{
	if ($LOGmodify_servers==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=311111111111&server_id=$server_id&server_ip=$server_ip";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT server_id,server_description,server_ip,active,asterisk_version,max_vicidial_trunks,telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,local_gmt,voicemail_dump_exten,answer_transfer_agent,ext_context,sys_perf_log,vd_server_logs,agi_output,vicidial_balance_active,balance_trunks_offlimits,recording_web_link,alt_server_ip,active_asterisk_server,generate_vicidial_conf,rebuild_conf_files,outbound_calls_per_second,sysload,channels_total,cpu_idle_percent,disk_usage,sounds_update,vicidial_recording_limit,carrier_logging_active,vicidial_balance_rank,rebuild_music_on_hold,active_agent_login_server,conf_secret,external_server_ip,custom_dialplan_entry,active_twin_server_ip,user_group,system_uptime,auto_restart_asterisk,asterisk_temp_no_restart,voicemail_dump_exten_no_inst,gather_asterisk_output,web_socket_url,conf_qualify,routing_prefix,external_web_socket_url,conf_engine,conf_update_interval,ara_url from servers where ( (server_id='$server_id') or (server_ip='$server_ip') ) $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$server_id =					$row[0];
		$server_description =			$row[1];
		$server_ip =					$row[2];
		$active =						$row[3];
		$asterisk_version =				$row[4];
		$max_vicidial_trunks =			$row[5];
		$telnet_host =					$row[6];
		$telnet_port =					$row[7];
		$ASTmgrUSERNAME =				$row[8];
		$ASTmgrSECRET =					$row[9];
		$ASTmgrUSERNAMEupdate =			$row[10];
		$ASTmgrUSERNAMElisten =			$row[11];
		$ASTmgrUSERNAMEsend =			$row[12];
		$local_gmt =					$row[13];
		$voicemail_dump_exten =			$row[14];
		$answer_transfer_agent =		$row[15];
		$ext_context =					$row[16];
		$sys_perf_log =					$row[17];
		$vd_server_logs =				$row[18];
		$agi_output =					$row[19];
		$vicidial_balance_active =		$row[20];
		$balance_trunks_offlimits =		$row[21];
		$recording_web_link =			$row[22];
		$alt_server_ip =				$row[23];
		$active_asterisk_server =		$row[24];
		$generate_vicidial_conf =		$row[25];
		$rebuild_conf_files =			$row[26];
		$outbound_calls_per_second =	$row[27];
		$sysload =						$row[28];
		$channels_total =				$row[29];
		$cpu_idle_percent =				$row[30];
		$disk_usage =					$row[31];
		$sounds_update =				$row[32];
		$vicidial_recording_limit =		$row[33];
		$carrier_logging_active =		$row[34];
		$vicidial_balance_rank =		$row[35];
		$rebuild_music_on_hold =		$row[36];
		$active_agent_login_server =	$row[37];
		$conf_secret =					$row[38];
		$external_server_ip =			$row[39];
		$custom_dialplan_entry =		$row[40];
		$active_twin_server_ip =		$row[41];
		$user_group =					$row[42];
		$system_uptime =				$row[43];
		$auto_restart_asterisk =		$row[44];
		$asterisk_temp_no_restart =		$row[45];
		$voicemail_dump_exten_no_inst = $row[46];
		$gather_asterisk_output =		$row[47];
		$web_socket_url =				$row[48];
		$conf_qualify =					$row[49];
		$routing_prefix =				$row[50];
		$external_web_socket_url =		$row[51];
		$conf_engine = 					$row[52];
		$conf_update_interval = 		$row[53];
		$ara_url =						$row[54];

		$stmt="SELECT count(*) from vicidial_live_agents where server_ip='$server_ip';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$live_agents = $row[0];
		if ($DB > 0) {echo "|$live_agents|$stmt|\n";}

		$cpu = (100 - $cpu_idle_percent);
		$disk_usage = preg_replace("/ /"," - ",$disk_usage);
		$disk_usage = preg_replace("/\|/","% &nbsp; &nbsp; ",$disk_usage);

		echo "<br>"._QXZ("MODIFY A SERVER RECORD").": $server_id<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=411111111111>\n";
		echo "<input type=hidden name=old_server_id value=\"$server_id\">\n";
		echo "<input type=hidden name=old_server_ip value=\"$server_ip\">\n";
		echo "<input type=hidden name=DB value=$DB>\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Server ID").": </td><td align=left><input type=text name=server_id size=10 maxlength=10 value=\"$server_id\">$NWB#servers-server_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Server Description").": </td><td align=left><input type=text name=server_description size=30 maxlength=255 value=\"$server_description\">$NWB#servers-server_description$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Server IP Address").": </td><td align=left><input type=text name=server_ip size=20 maxlength=15 value=\"$server_ip\">$NWB#servers-server_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$active' SELECTED>"._QXZ("$active")."</option></select>$NWB#servers-active$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("System Load").": </td><td align=left>$sysload - $cpu% &nbsp; $NWB#servers-sysload$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Live Channels").": </td><td align=left>$channels_total &nbsp; &nbsp; "._QXZ("Agents").": $live_agents &nbsp; $NWB#servers-channels_total$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Disk Usage").": </td><td align=left><font size=0>$disk_usage</font> &nbsp; $NWB#servers-disk_usage$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("System Uptime").": </td><td align=left>$system_uptime &nbsp; $NWB#servers-system_uptime$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">".(preg_match('/\-\-\ALL\-\-/', $user_group) ? _QXZ("$user_group") : $user_group)."</option>\n";
		echo "</select>$NWB#servers-user_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Asterisk Version").": </td><td align=left><input type=text name=asterisk_version size=20 maxlength=20 value=\"$asterisk_version\">$NWB#servers-asterisk_version$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Max Trunks").": </td><td align=left><input type=text name=max_vicidial_trunks size=5 maxlength=4 value=\"$max_vicidial_trunks\">$NWB#servers-max_trunks$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Max Calls per Second").": </td><td align=left><input type=text name=outbound_calls_per_second size=5 maxlength=4 value=\"$outbound_calls_per_second\">$NWB#servers-outbound_calls_per_second$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Balance Dialing").": </td><td align=left><select size=1 name=vicidial_balance_active><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option selected value='$vicidial_balance_active'>"._QXZ("$vicidial_balance_active")."</option></select>$NWB#servers-balance_active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Balance Rank").": </td><td align=left><input type=text name=vicidial_balance_rank size=4 maxlength=2 value=\"$vicidial_balance_rank\">$NWB#servers-balance_rank$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Balance Offlimits").": </td><td align=left><input type=text name=balance_trunks_offlimits size=5 maxlength=4 value=\"$balance_trunks_offlimits\">$NWB#servers-balance_trunks_offlimits$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Telnet Host").": </td><td align=left><input type=text name=telnet_host size=20 maxlength=20 value=\"$telnet_host\">$NWB#servers-telnet_host$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Telnet Port").": </td><td align=left><input type=text name=telnet_port size=6 maxlength=5 value=\"$telnet_port\">$NWB#servers-telnet_port$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Manager User").": </td><td align=left><input type=text name=ASTmgrUSERNAME size=20 maxlength=20 value=\"$ASTmgrUSERNAME\">$NWB#servers-ASTmgrUSERNAME$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Manager Secret").": </td><td align=left><input type=text name=ASTmgrSECRET size=20 maxlength=20 value=\"$ASTmgrSECRET\">$NWB#servers-ASTmgrSECRET$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Manager Update User").": </td><td align=left><input type=text name=ASTmgrUSERNAMEupdate size=20 maxlength=20 value=\"$ASTmgrUSERNAMEupdate\">$NWB#servers-ASTmgrUSERNAMEupdate$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Manager Listen User").": </td><td align=left><input type=text name=ASTmgrUSERNAMElisten size=20 maxlength=20 value=\"$ASTmgrUSERNAMElisten\">$NWB#servers-ASTmgrUSERNAMElisten$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Manager Send User").": </td><td align=left><input type=text name=ASTmgrUSERNAMEsend size=20 maxlength=20 value=\"$ASTmgrUSERNAMEsend\">$NWB#servers-ASTmgrUSERNAMEsend$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Conf File Secret").": </td><td align=left style=\"display:table-cell; vertical-align:middle;\" NOWRAP><input type=text id=reg_pass name=conf_secret size=40 maxlength=100 value=\"$conf_secret\" onkeyup=\"return pwdChanged('reg_pass','reg_pass_img','pass_length','$SSrequire_password_length');\">$NWB#servers-conf_secret$NWE &nbsp; &nbsp; <font size=1>"._QXZ("Strength").":</font> <IMG id=reg_pass_img src='images/pixel.gif' style=\"vertical-align:middle;\" onLoad=\"return pwdChanged('reg_pass','reg_pass_img','pass_length','$SSrequire_password_length');\"> &nbsp; <font size=1> "._QXZ("Length").": <span id=pass_length name=pass_length>0</span></font></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Local GMT").": </td><td align=left><select size=1 name=local_gmt><option>12.75</option><option>12.00</option><option>11.00</option><option>10.00</option><option>9.50</option><option>9.00</option><option>8.00</option><option>7.00</option><option>6.50</option><option>6.00</option><option>5.75</option><option>5.50</option><option>5.00</option><option>4.50</option><option>4.00</option><option>3.50</option><option>3.00</option><option>2.00</option><option>1.00</option><option>0.00</option><option>-1.00</option><option>-2.00</option><option>-3.00</option><option>-3.50</option><option>-4.00</option><option>-5.00</option><option>-6.00</option><option>-7.00</option><option>-8.00</option><option>-9.00</option><option>-10.00</option><option>-11.00</option><option>-12.00</option><option selected>$local_gmt</option></select> ("._QXZ("Do NOT Adjust for DST").")$NWB#servers-local_gmt$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("VMail Dump Exten").": </td><td align=left><input type=text name=voicemail_dump_exten size=20 maxlength=20 value=\"$voicemail_dump_exten\">$NWB#servers-voicemail_dump_exten$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("VMail Dump Exten NI").": </td><td align=left><input type=text name=voicemail_dump_exten_no_inst size=20 maxlength=20 value=\"$voicemail_dump_exten_no_inst\">$NWB#servers-voicemail_dump_exten_no_inst$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("auto dial extension").": </td><td align=left><input type=text name=answer_transfer_agent size=20 maxlength=20 value=\"$answer_transfer_agent\">$NWB#servers-answer_transfer_agent$NWE";

		$major_version = explode('.',$asterisk_version);
		if ($major_version[0] >= 12)
			{
			echo " &nbsp; &nbsp; "._QXZ("prefix").": <input type=text name=routing_prefix size=10 maxlength=10 value=\"$routing_prefix\">$NWB#servers-routing_prefix$NWE";
			}
		else
			{echo "<input type=hidden name=routing_prefix value=\"$routing_prefix\">";}
		echo "</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Default Context").": </td><td align=left><input type=text name=ext_context size=20 maxlength=20 value=\"$ext_context\">$NWB#servers-ext_context$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("System Performance").": </td><td align=left><select size=1 name=sys_perf_log><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$sys_perf_log' selected>"._QXZ("$sys_perf_log")."</option></select>$NWB#servers-sys_perf_log$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Server Logs").": </td><td align=left><select size=1 name=vd_server_logs><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$vd_server_logs' selected>"._QXZ("$vd_server_logs")."</option></select>$NWB#servers-vd_server_logs$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("AGI Output").": </td><td align=left><select size=1 name=agi_output><option value='NONE'>"._QXZ("NONE")."</option><option value='STDERR'>"._QXZ("STDERR")."</option><option value='FILE'>"._QXZ("FILE")."</option><option value='BOTH'>"._QXZ("BOTH")."</option><option value='$agi_output' selected>"._QXZ("$agi_output")."</option></select>$NWB#servers-agi_output$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Carrier Logging Active").": </td><td align=left><select size=1 name=carrier_logging_active><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$carrier_logging_active' selected>"._QXZ("$carrier_logging_active")."</option></select>$NWB#servers-carrier_logging_active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Gather Asterisk Output").": </td><td align=left><select size=1 name=gather_asterisk_output><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$gather_asterisk_output' selected>"._QXZ("$gather_asterisk_output")."</option></select>$NWB#servers-gather_asterisk_output$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Conf Qualify").": </td><td align=left><select size=1 name=conf_qualify><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$conf_qualify' selected>"._QXZ("$conf_qualify")."</option></select>$NWB#servers-conf_qualify$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Recording Web Link").": </td><td align=left><select size=1 name=recording_web_link><option value='SERVER_IP'>"._QXZ("SERVER_IP")."</option><option value='ALT_IP'>"._QXZ("ALT_IP")."</option><option value='EXTERNAL_IP'>"._QXZ("EXTERNAL_IP")."</option><option value='$recording_web_link' selected>"._QXZ("$recording_web_link")."</option></select>$NWB#servers-recording_web_link$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Alternate Recording Server IP").": </td><td align=left><input type=text name=alt_server_ip size=30 maxlength=100 value=\"$alt_server_ip\">$NWB#servers-alt_server_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("External Server IP").": </td><td align=left><input type=text name=external_server_ip size=30 maxlength=100 value=\"$external_server_ip\">$NWB#servers-external_server_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Web Socket URL").": </td><td align=left><input type=text name=web_socket_url size=30 maxlength=255 value=\"$web_socket_url\">$NWB#servers-web_socket_url$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("External Web Socket URL").": </td><td align=left><input type=text name=external_web_socket_url size=30 maxlength=255 value=\"$external_web_socket_url\">$NWB#servers-external_web_socket_url$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active Twin Server IP").": </td><td align=left><input type=text name=active_twin_server_ip size=16 maxlength=15 value=\"$active_twin_server_ip\">$NWB#servers-active_twin_server_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Conferencing Engine").": </td><td align=left><select size=1 name=conf_engine><option value='MEETME'>"._QXZ("MEETME")."</option><option value='CONFBRIDGE'>"._QXZ("CONFBRIDGE")."</option><option selected value='$conf_engine'>"._QXZ("$conf_engine")."</option></select>$NWB#servers-conf_engine$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Conf Update Interval").": </td><td align=left><input type=text name=conf_update_interval size=5 maxlength=6 value=\"$conf_update_interval\">$NWB#servers-conf_update_interval$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active Asterisk Server").": </td><td align=left><select size=1 name=active_asterisk_server><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option selected value='$active_asterisk_server'>"._QXZ("$active_asterisk_server")."</option></select>$NWB#servers-active_asterisk_server$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Auto-Restart Asterisk").": </td><td align=left> &nbsp; &nbsp; <select size=1 name=auto_restart_asterisk><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option selected value='$auto_restart_asterisk'>"._QXZ("$auto_restart_asterisk")."</option></select>$NWB#servers-auto_restart_asterisk$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Temp No-Restart Asterisk").": </td><td align=left> &nbsp; &nbsp; <select size=1 name=asterisk_temp_no_restart><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option selected value='$asterisk_temp_no_restart'>"._QXZ("$asterisk_temp_no_restart")."</option></select>$NWB#servers-asterisk_temp_no_restart$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Asterisk Restart URL").": </td><td align=left> &nbsp; &nbsp; <input type=text name=ara_url size=40 maxlength=1000 value=\"$ara_url\">$NWB#servers-ara_url$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active Agent Server").": </td><td align=left><select size=1 name=active_agent_login_server><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option selected value='$active_agent_login_server'>"._QXZ("$active_agent_login_server")."</option></select>$NWB#servers-active_agent_login_server$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Generate conf files").": </td><td align=left><select size=1 name=generate_vicidial_conf><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option selected value='$generate_vicidial_conf'>"._QXZ("$generate_vicidial_conf")."</option></select>$NWB#servers-generate_conf$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Rebuild conf files").": </td><td align=left><select size=1 name=rebuild_conf_files><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option selected value='$rebuild_conf_files'>"._QXZ("$rebuild_conf_files")."</option></select>$NWB#servers-rebuild_conf_files$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Rebuild Music On Hold").": </td><td align=left><select size=1 name=rebuild_music_on_hold><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option selected value='$rebuild_music_on_hold'>"._QXZ("$rebuild_music_on_hold")."</option></select>$NWB#servers-rebuild_music_on_hold$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Sounds Update").": </td><td align=left><select size=1 name=sounds_update><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$sounds_update' selected>"._QXZ("$sounds_update")."</option></select>$NWB#servers-sounds_update$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Recording Limit").": </td><td align=left><input type=text name=vicidial_recording_limit size=8 maxlength=6 value=\"$vicidial_recording_limit\">$NWB#servers-recording_limit$NWE</td></tr>\n";

		if ( ($SSallow_custom_dialplan > 0) and ($LOGmodify_custom_dialplans > 0) )
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>"._QXZ("Custom Dialplan Entry").": $NWB#servers-custom_dialplan_entry$NWE <TEXTAREA NAME=custom_dialplan_entry ROWS=5 COLS=80>$custom_dialplan_entry</TEXTAREA></td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom Dialplan Entry").": </td><td align=left>Disabled <input type=hidden name=custom_dialplan_entry value=\"\">$NWB#servers-custom_dialplan_entry$NWE</td></tr>\n";
			}



		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center></form>\n";


		### vicidial server trunk records for this server
		echo "<br><br><b>"._QXZ("TRUNKS FOR THIS SERVER").": &nbsp; $NWB#server_trunks$NWE</b><br>\n";
		echo "<TABLE width=500 cellspacing=3>\n";
		echo "<tr><td> "._QXZ("CAMPAIGN")."</td><td> "._QXZ("TRUNKS")." </td><td> "._QXZ("RESTRICTION")." </td><td> </td><td> "._QXZ("DELETE")." </td></tr>\n";

		$stmt="SELECT server_ip,campaign_id,dedicated_trunks,trunk_restriction from vicidial_server_trunks where server_ip='$server_ip' $LOGallowed_campaignsSQL order by campaign_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$recycle_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($recycle_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$o++;

			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

			echo "<tr $bgcolor><td><font size=1>$rowx[1]<form action=$PHP_SELF method=POST>\n";
			echo "<input type=hidden name=server_ip value=\"$server_ip\">\n";
			echo "<input type=hidden name=campaign_id value=\"$rowx[1]\">\n";
			echo "<input type=hidden name=ADD value=421111111111></td>\n";
			echo "<td><font size=1><input size=6 maxlength=4 name=dedicated_trunks value=\"$rowx[2]\"></td>\n";
			echo "<td><select size=1 name=trunk_restriction><option value='MAXIMUM_LIMIT'>"._QXZ("MAXIMUM_LIMIT")."</option><option value='OVERFLOW_ALLOWED'>"._QXZ("OVERFLOW_ALLOWED")."</option><option value='$rowx[3]' SELECTED>"._QXZ("$rowx[3]")."</option></select></td>\n";
			echo "<td><font size=1><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("MODIFY")."'></form></td>\n";
			echo "<td><font size=1><a href=\"$PHP_SELF?ADD=621111111111&campaign_id=$rowx[1]&server_ip=$server_ip\">"._QXZ("DELETE")."</a></td></tr>\n";
			}

		echo "</table>\n";

		echo "<br><b>"._QXZ("ADD NEW SERVER TRUNK RECORD")."</b><BR><form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=221111111111>\n";
		echo "<input type=hidden name=server_ip value=\"$server_ip\">\n";
		echo _QXZ("TRUNKS").": <input size=6 maxlength=4 name=dedicated_trunks><BR>\n";
		echo _QXZ("CAMPAIGN").": <select size=1 name=campaign_id>\n";
		echo "$campaigns_list\n";
		echo "</select><BR>\n";
		echo _QXZ("RESTRICTION").": <select size=1 name=trunk_restriction><option value='MAXIMUM_LIMIT'>"._QXZ("MAXIMUM_LIMIT")."</option><option value='OVERFLOW_ALLOWED'>"._QXZ("OVERFLOW_ALLOWED")."</option></select><BR>\n";
		echo "<input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("ADD")."'><BR>\n";

		echo "</center></FORM><br>\n";


		### list of carriers on this server
		echo "<center>\n";
		echo "<br><b>"._QXZ("CARRIERS WITHIN THIS SERVER").":</b><br>\n";
		echo "<TABLE width=600 cellspacing=3>\n";
		echo "<tr><td>"._QXZ("CARRIER ID")."</td><td>"._QXZ("NAME")."</td><td>"._QXZ("REGISTRATION")."</td><td>"._QXZ("ACTIVE")."</td></tr>\n";

		$active_carriers = 0;
		$inactive_carriers = 0;
		$stmt="SELECT carrier_id,carrier_name,registration_string,active from vicidial_server_carriers where server_ip IN('$server_ip','0.0.0.0') $LOGadmin_viewable_groupsSQL;";
		$rsltx=mysql_to_mysqli($stmt, $link);
		$carriers_to_print = mysqli_num_rows($rsltx);
		if ($DB > 0) {echo "|$carriers_to_print|$stmt|\n";}
		$camp_lists='';

		$o=0;
		while ($carriers_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rsltx);
			$o++;
			if (preg_match('/Y/', $rowx[3])) {$active_carriers++;}
			if (preg_match('/N/', $rowx[3])) {$inactive_carriers++;}

			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

			echo "<tr $bgcolor><td><font size=1><a href=\"$PHP_SELF?ADD=341111111111&carrier_id=$rowx[0]\">$rowx[0]</a></td><td><font size=1>$rowx[1]</td><td><font size=1>$rowx[2]</td><td><font size=1>"._QXZ("$rowx[3]")."</td></tr>\n";
			}

		echo "</table></center><br>\n";


		### list of phones on this server
		echo "<center>\n";
		echo "<br><b>"._QXZ("PHONES WITHIN THIS SERVER").":</b><br>\n";
		echo "<TABLE width=400 cellspacing=3>\n";
		echo "<tr><td>"._QXZ("EXTENSION")."</td><td>"._QXZ("NAME")."</td><td>"._QXZ("ACTIVE")."</td></tr>\n";

		$active_phones = 0;
		$inactive_phones = 0;
		$stmt="SELECT extension,active,fullname from phones where server_ip='$server_ip' $LOGadmin_viewable_groupsSQL;";
		$rsltx=mysql_to_mysqli($stmt, $link);
		$lists_to_print = mysqli_num_rows($rsltx);
		if ($DB > 0) {echo "|$lists_to_print|$stmt|\n";}
		$camp_lists='';

		$o=0;
		while ($lists_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rsltx);
			$o++;
			if (preg_match('/Y/', $rowx[1])) {$active_phones++;   $camp_lists .= "'$rowx[0]',";}
			if (preg_match('/N/', $rowx[1])) {$inactive_phones++;}

			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

			echo "<tr $bgcolor><td><font size=1><a href=\"$PHP_SELF?ADD=31111111111&extension=$rowx[0]&server_ip=$server_ip\">$rowx[0]</a></td><td><font size=1>$rowx[2]</td><td><font size=1>"._QXZ("$rowx[1]")."</td></tr>\n";
			}

		echo "</table></center><br>\n";


		### list of conferences on this server
		echo "<center>\n";
		echo "<br><b>"._QXZ("CONFERENCES WITHIN THIS SERVER").":</b><br>\n";
		echo "<TABLE width=400 cellspacing=3>\n";
		echo "<tr><td>"._QXZ("CONFERENCE")."</td><td>"._QXZ("EXTENSION")."</td></tr>\n";

		$active_confs = 0;
		$stmt="SELECT conf_exten,extension from conferences where server_ip='$server_ip'";
		$rsltx=mysql_to_mysqli($stmt, $link);
		$lists_to_print = mysqli_num_rows($rsltx);
		if ($DB > 0) {echo "|$lists_to_print|$stmt|\n";}
		$camp_lists='';

		$o=0;
		while ($lists_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rsltx);
			$o++;
			$active_confs++;

			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

			echo "<tr $bgcolor><td><font size=1><a href=\"$PHP_SELF?ADD=3111111111111&conf_exten=$rowx[0]&server_ip=$server_ip\">$rowx[0]</a></td><td><font size=1>$rowx[1]</td></tr>\n";
			}

		echo "</table></center><br>\n";


		### list of vicidial conferences on this server
		echo "<center>\n";
		echo "<br><b>"._QXZ("AGENT CONFERENCES WITHIN THIS SERVER").":</b><br>\n";
		echo "<TABLE width=400 cellspacing=3>\n";
		echo "<tr><td>"._QXZ("VD CONFERENCE")."</td><td>"._QXZ("EXTENSION")."</td></tr>\n";

		$active_vdconfs = 0;
		$stmt="SELECT conf_exten,extension from vicidial_conferences where server_ip='$server_ip'";
		$rsltx=mysql_to_mysqli($stmt, $link);
		$lists_to_print = mysqli_num_rows($rsltx);
		if ($DB > 0) {echo "|$lists_to_print|$stmt|\n";}
		$camp_lists='';

		$o=0;
		while ($lists_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rsltx);
			$o++;
			$active_vdconfs++;

			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

			echo "<tr $bgcolor><td><font size=1><a href=\"$PHP_SELF?ADD=31111111111111&conf_exten=$rowx[0]&server_ip=$server_ip\">$rowx[0]</a></td><td><font size=1>$rowx[1]</td></tr>\n";
			}

		echo "</table></center><br>\n";


		### list of vicidial confbridges on this server
		echo "<center>\n";
		echo "<br><b>"._QXZ("AGENT CONFBRIDGES WITHIN THIS SERVER").":</b><br>\n";
		echo "<TABLE width=400 cellspacing=3>\n";
		echo "<tr><td>"._QXZ("VD CONFBRIDGE")."</td><td>"._QXZ("EXTENSION")."</td></tr>\n";

		$active_vdconfs = 0;
		$stmt="SELECT conf_exten,extension from vicidial_confbridges where server_ip='$server_ip'";
		$rsltx=mysql_to_mysqli($stmt, $link);
		$lists_to_print = mysqli_num_rows($rsltx);
		if ($DB > 0) {echo "|$lists_to_print|$stmt|\n";}
		$camp_lists='';

		$o=0;
		while ($lists_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rsltx);
			$o++;
			$active_vdconfs++;

			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

			echo "<tr $bgcolor><td><font size=1><a href=\"$PHP_SELF?ADD=32111111111111&conf_exten=$rowx[0]&server_ip=$server_ip\">$rowx[0]</a></td><td><font size=1>$rowx[1]</td></tr>\n";
			}

		echo "</table></center><br>\n";


		echo "<center><b>\n";

			$camp_lists = preg_replace('/.$/i','',$camp_lists);
		echo _QXZ("This server has %1s active carriers and %2s inactive carriers",0,'',$active_carriers,$inactive_carriers)."<br><br>\n";
		echo _QXZ("This server has %1s active phones and %2s inactive phones",0,'',$active_phones,$inactive_phones)."<br><br>\n";
		echo _QXZ("This server has %1s active conferences",0,'',$active_confs)."<br><br>\n";
		echo _QXZ("This server has %1s active vicidial conferences",0,'',$active_vdconfs)."<br><br>\n";
		echo "</b></center>\n";
		if ($LOGast_delete_phones > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=521111111111&server_id=$server_id&server_ip=$server_ip\">"._QXZ("CLEAR ALL AGENT CONFERENCES")."</a>\n";
			}
		if ($LOGast_delete_phones > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=511111111111&server_id=$server_id&server_ip=$server_ip\">"._QXZ("DELETE THIS SERVER")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=SERVERS&stage=$server_id\">"._QXZ("Click here to see Admin changes to this server")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=331111111111 modify conf template record in the system
######################
if ($ADD==331111111111)
	{
	if ($LOGast_admin_access==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=331111111111&template_id=$template_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT template_id,template_name,template_contents,user_group from vicidial_conf_templates where template_id='$template_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$template_id =			$row[0];
		$template_name =		$row[1];
		$template_contents =	$row[2];
		$user_group =			$row[3];

		echo "<br>"._QXZ("MODIFY A CONF TEMPLATE RECORD").": $row[0]<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=431111111111>\n";
		echo "<input type=hidden name=template_id value=\"$template_id\">\n";

		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Template ID").": </td><td align=left><B>$template_id</B></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Template Name").": </td><td align=left><input type=text name=template_name size=40 maxlength=50 value=\"$template_name\">$NWB#conf_templates-template_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">$user_group</option>\n";
		echo "</select>$NWB#conf_templates-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Template Contents").": </td><td align=left><TEXTAREA NAME=template_contents ROWS=12 COLS=70>$template_contents</TEXTAREA> $NWB#conf_templates-template_contents$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";

		echo "<center><b>\n";

		### list of phones using this conf template
		echo "<center>\n";
		echo "<br><b>"._QXZ("PHONES USING THIS CONF TEMPLATE").":</b><br>\n";
		echo "<TABLE width=500 cellspacing=3>\n";
		echo "<tr><td>"._QXZ("EXTENSION")."</td><td>"._QXZ("NAME")."</td><td>"._QXZ("SERVER")."</td><td>"._QXZ("ACTIVE")."</td></tr>\n";

		$active_phones = 0;
		$inactive_phones = 0;
		$stmt="SELECT extension,active,fullname,server_ip from phones where template_id='$template_id' $LOGadmin_viewable_groupsSQL;";
		$rsltx=mysql_to_mysqli($stmt, $link);
		$lists_to_print = mysqli_num_rows($rsltx);
		$camp_lists='';

		$o=0;
		while ($lists_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rsltx);
			$o++;
			if (preg_match('/Y/', $rowx[1])) {$active_phones++;   $camp_lists .= "'$rowx[0]',";}
			if (preg_match('/N/', $rowx[1])) {$inactive_phones++;}

			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

			echo "<tr $bgcolor><td><font size=1><a href=\"$PHP_SELF?ADD=31111111111&extension=$rowx[0]&server_ip=$rowx[3]\">$rowx[0]</a></td><td><font size=1>$rowx[2]</td><td><font size=1>$rowx[3]</td><td><font size=1>$rowx[1]</td></tr>\n";
			}

		echo "</table></center><br>\n";

		### list of carriers using this conf template
		echo "<center>\n";
		echo "<br><b>"._QXZ("CARRIERS USING THIS CONF TEMPLATE").":</b><br>\n";
		echo "<TABLE width=500 cellspacing=3>\n";
		echo "<tr><td>"._QXZ("CARRIER")."</td><td>"._QXZ("NAME")."</td><td>"._QXZ("SERVER")."</td><td>"._QXZ("ACTIVE")."</td></tr>\n";

		$active_phones = 0;
		$inactive_phones = 0;
		$stmt="SELECT carrier_id,active,carrier_name,server_ip from vicidial_server_carriers where template_id='$template_id' $LOGadmin_viewable_groupsSQL;";
		$rsltx=mysql_to_mysqli($stmt, $link);
		$lists_to_print = mysqli_num_rows($rsltx);
		$camp_lists='';

		$o=0;
		while ($lists_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rsltx);
			$o++;
			if (preg_match('/Y/', $rowx[1])) {$active_phones++;   $camp_lists .= "'$rowx[0]',";}
			if (preg_match('/N/', $rowx[1])) {$inactive_phones++;}

			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

			echo "<tr $bgcolor><td><font size=1><a href=\"$PHP_SELF?ADD=341111111111&carrier_id=$rowx[0]\">$rowx[0]</a></td><td><font size=1>$rowx[2]</td><td><font size=1>$rowx[3]</td><td><font size=1>$rowx[1]</td></tr>\n";
			}

		echo "</table></center><br>\n";



		if ($LOGast_delete_phones > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=531111111111&template_id=$template_id&template_name=$template_name\">"._QXZ("DELETE THIS CONF TEMPLATE")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=CONFTEMPLATES&stage=$template_id\">"._QXZ("Click here to see Admin changes to this conf template")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=341111111111 modify carrier record in the system
######################
if ($ADD==341111111111)
	{
	if ( ( ($LOGast_admin_access==1) or ($LOGmodify_carriers==1) ) and ($x_ra_carrier < 1) )
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=341111111111&carrier_id=$carrier_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT carrier_id,carrier_name,registration_string,template_id,account_entry,protocol,globals_string,dialplan_entry,server_ip,active,carrier_description,user_group from vicidial_server_carriers where carrier_id='$carrier_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$carrier_id =			$row[0];
		$carrier_name =			$row[1];
		$registration_string =	$row[2];
		$template_id =			$row[3];
		$account_entry =		$row[4];
		$protocol =				$row[5];
		$globals_string =		$row[6];
		$dialplan_entry =		$row[7];
		$server_ip =			$row[8];
		$active =				$row[9];
		$carrier_description =	$row[10];
		$user_group =			$row[11];

		echo "<br>"._QXZ("MODIFY A CARRIER RECORD").": $row[0]<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=441111111111>\n";
		echo "<input type=hidden name=carrier_id value=\"$carrier_id\">\n";

		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Carrier ID").": </td><td align=left><B>$carrier_id</B></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Carrier Name").": </td><td align=left><input type=text name=carrier_name size=40 maxlength=50 value=\"$carrier_name\">$NWB#server_carriers-carrier_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Carrier Description").": </td><td align=left><input type=text name=carrier_description size=70 maxlength=255 value=\"$carrier_description\">$NWB#server_carriers-carrier_description$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">".(preg_match('/\-\-ALL\-\-/', $user_group) ? _QXZ("$user_group") : $user_group)."</option>\n";
		echo "</select>$NWB#server_carriers-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Registration String").": </td><td align=left><input type=text name=registration_string size=50 maxlength=255 value=\"$registration_string\">$NWB#server_carriers-registration_string$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=331111111111&template_id=$template_id\">"._QXZ("Template ID")."</a>: </td><td align=left><select size=1 name=template_id>\n";
		$stmt="SELECT template_id,template_name from vicidial_conf_templates $whereLOGadmin_viewable_groupsSQL order by template_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$templates_to_print = mysqli_num_rows($rslt);
		$templates_list='<option value=\'--NONE--\' SELECTED>--'._QXZ("NONE").'--</option>';
		$o=0;
		while ($templates_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$templates_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		echo "$templates_list";
		echo "<option SELECTED value='$template_id'>".(preg_match('/\-\-NONE\-\-/', $template_id) ? _QXZ("$template_id") : $template_id)."</option>\n";
		echo "</select>$NWB#server_carriers-template_id$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Account Entry").": </td><td align=left><TEXTAREA NAME=account_entry ROWS=10 COLS=70>$account_entry</TEXTAREA> $NWB#server_carriers-account_entry$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Protocol").": </td><td align=left><select size=1 name=protocol>";
		if ( ($SSallowed_sip_stacks == 'SIP') or ($SSallowed_sip_stacks == 'SIP_and_PJSIP') ) {echo "<option>SIP</option>";}
		if ( ($SSallowed_sip_stacks == 'PJSIP') or ($SSallowed_sip_stacks == 'SIP_and_PJSIP') ) {echo "<option>PJSIP</option><option>PJSIP_WIZ</option>";}
		echo "<option>Zap</option>";
		echo "<option>IAX2</option>";
		echo "<option value='EXTERNAL'>"._QXZ("EXTERNAL")."</option>";
		echo "<option SELECTED value='$protocol'>".(!preg_match('/^SIP|^PJSIP|^Zap|^IAX2/i', $protocol) ? _QXZ("$protocol") : $protocol)."</option></select>$NWB#server_carriers-protocol$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Globals String").": </td><td align=left><input type=text name=globals_string size=50 maxlength=255 value=\"$globals_string\">$NWB#server_carriers-globals_string$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Dialplan Entry").": </td><td align=left><TEXTAREA NAME=dialplan_entry ROWS=10 COLS=70>$dialplan_entry</TEXTAREA> $NWB#server_carriers-dialplan_entry$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Server IP").": </td><td align=left><select size=1 name=server_ip>\n";
		echo "$servers_list";
		echo "<option value=\"0.0.0.0\">0.0.0.0 - ALL SERVERS</option>\n";
		echo "<option SELECTED>$server_ip</option>\n";
		echo "</select> <i>(0.0.0.0 "._QXZ("is all servers").")</i>$NWB#server_carriers-server_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$active' SELECTED>"._QXZ("$active")."</option></select>$NWB#server_carriers-active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";

		echo "<center><b>\n";
		if ($LOGast_delete_phones > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=541111111111&carrier_id=$carrier_id&carrier_name=$carrier_name\">"._QXZ("DELETE THIS CARRIER")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=CARRIERS&stage=$carrier_id\">"._QXZ("Click here to see Admin changes to this carrier")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=351111111111 modify tts record in the system
######################
if ($ADD==351111111111)
	{
	if ( ($LOGast_admin_access==1) or ($LOGmodify_tts==1) )
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=351111111111&tts_id=$tts_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT tts_id,tts_name,active,tts_text,tts_voice,user_group from vicidial_tts_prompts where tts_id='$tts_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$tts_id =		$row[0];
		$tts_name =		$row[1];
		$active =		$row[2];
		$tts_text =		$row[3];
		$tts_voice =	$row[4];
		$user_group =	$row[5];

		echo "<br>"._QXZ("MODIFY A TTS RECORD").": $tts_id<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=451111111111>\n";
		echo "<input type=hidden name=tts_id value=\"$tts_id\">\n";

		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("TTS ID").": </td><td align=left><B>$tts_id</B></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("TTS Name").": </td><td align=left><input type=text name=tts_name size=50 maxlength=100 value=\"$tts_name\">$NWB#tts_prompts-tts_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$active' SELECTED>"._QXZ("$active")."</option></select>$NWB#tts_prompts-active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">".(preg_match('/\-\-ALL\-\-/', $user_group) ? _QXZ("$user_group") : $user_group)."</option>\n";
		echo "</select>$NWB#tts_prompts-user_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("TTS Voice").": </td><td align=left><input type=text name=tts_voice size=20 maxlength=100 value=\"$tts_voice\">$NWB#tts_prompts-tts_voice$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("TTS Text").": </td><td align=left><TEXTAREA NAME=tts_text ROWS=20 COLS=70>$tts_text</TEXTAREA> $NWB#tts_prompts-tts_text$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";

		echo "<center><b>\n";
		if ($LOGast_delete_phones > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=551111111111&tts_id=$tts_id&tts_name=$tts_name\">"._QXZ("DELETE THIS TTS ENTRY")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=TTS&stage=$tts_id\">"._QXZ("Click here to see Admin changes to this TTS entry")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=361111111111 modify music on hold record in the system
######################
if ($ADD==361111111111)
	{
	if ( ($LOGast_admin_access==1) or ($LOGmodify_moh==1) )
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=361111111111&moh_id=$moh_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT moh_id,moh_name,active,random,user_group from vicidial_music_on_hold where moh_id='$moh_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$moh_id =		$row[0];
		$moh_name =		$row[1];
		$active =		$row[2];
		$random =		$row[3];
		$user_group =	(preg_match('/\-\-ALL\-\-/', $row[4]) ? _QXZ("$row[4]") : $row[4]);

		echo "<br>"._QXZ("MODIFY A MUSIC ON HOLD RECORD").": $moh_id<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=461111111111>\n";
		echo "<input type=hidden name=moh_id value=\"$moh_id\">\n";

		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Music On Hold ID").": </td><td align=left><B>$moh_id</B></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Music On Hold Name").": </td><td align=left><input type=text name=moh_name size=50 maxlength=100 value=\"$moh_name\">$NWB#music_on_hold-moh_name$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">$user_group</option>\n";
		echo "</select>$NWB#music_on_hold-user_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$active' SELECTED>"._QXZ("$active")."</option></select>$NWB#music_on_hold-active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Random Order").": </td><td align=left><select size=1 name=random><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$random' SELECTED>"._QXZ("$random")."</option></select>$NWB#music_on_hold-random$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Audio Files").": </td><td align=left>\n";
		##### get files listing for rank/delete options
		$stmt="SELECT filename,rank from vicidial_music_on_hold_files where moh_id='$moh_id' order by rank;";
		$rsltx=mysql_to_mysqli($stmt, $link);
		$mohfiles_to_print = mysqli_num_rows($rsltx);
		$ranks = ($mohfiles_to_print + 2);
		$o=0;
		while ($mohfiles_to_print > $o)
			{
			$rowx=mysqli_fetch_row($rsltx);
			echo "<font size=2>"._QXZ("Rank").": </font><select size=1 name=$rowx[0]>\n";
			echo "<option SELECTED>$rowx[1]</option>\n";
			$k=1;
			while ($ranks > $k)
				{
				echo "<option>$k</option>\n";
				$k++;
				}
			echo "</select>\n";

			echo " &nbsp; <B>$rowx[0]</B> - <a href=\"$PHP_SELF?ADD=461111111111&moh_id=$moh_id&stage=FILEDELETE&filename=$rowx[0]\">"._QXZ("DELETE")."</a><BR>\n";
			$o++;
			}

		echo "</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row2_background><td align=right>"._QXZ("Add An Audio File").": </td><td><input type=text size=50 maxlength=50 name=filename id=filename value=\"\"> <a href=\"javascript:launch_chooser('filename','date');\">"._QXZ("audio chooser")."</a>  $NWB#music_on_hold-filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";

		echo "<center><b>\n";
		if ($LOGast_delete_phones > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=561111111111&moh_id=$moh_id&moh_name=$moh_name\">"._QXZ("DELETE MUSIC ON HOLD ENTRY")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=MOH&stage=$moh_id\">"._QXZ("Click here to see Admin changes to this Music On Hold entry")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=397111111111 modify VM Message Group record in the system
######################
if ($ADD==397111111111)
	{
	if ($LOGmodify_statuses==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=397111111111&leave_vm_message_group_id=$leave_vm_message_group_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT leave_vm_message_group_id,leave_vm_message_group_notes,active,user_group from leave_vm_message_groups where leave_vm_message_group_id='$leave_vm_message_group_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$leave_vm_message_group_id =		$row[0];
		$leave_vm_message_group_notes =		$row[1];
		$active =							$row[2];
		$user_group =	(preg_match('/\-\-ALL\-\-/', $row[3]) ? _QXZ("$row[3]") : $row[3]);

		echo "<br>"._QXZ("MODIFY A VM MESSAGE GROUP RECORD").": $leave_vm_message_group_id<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=497111111111>\n";
		echo "<input type=hidden name=DB value=$DB>\n";
		echo "<input type=hidden name=leave_vm_message_group_id value=\"$leave_vm_message_group_id\">\n";

		echo "<center><TABLE width=900 cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("VM Message Group ID").": </td><td align=left><B>$leave_vm_message_group_id</B></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("VM Message Group Notes").": </td><td align=left><input type=text name=leave_vm_message_group_notes size=50 maxlength=255 value=\"$leave_vm_message_group_notes\">$NWB#vm_message_groups$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">$user_group</option>\n";
		echo "</select>$NWB#vm_message_groups$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$active' SELECTED>"._QXZ("$active")."</option></select>$NWB#vm_message_groups$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Audio Files").": </td><td align=left>\n";
		echo "<table border=0>";
		##### get files listing for rank/delete options
		$stmt="SELECT audio_filename,audio_name,rank,time_start,time_end from leave_vm_message_groups_entries where leave_vm_message_group_id='$leave_vm_message_group_id' order by rank;";
		$rsltx=mysql_to_mysqli($stmt, $link);
		$vmmgfiles_to_print = mysqli_num_rows($rsltx);
		$ranks = ($vmmgfiles_to_print + 2);
		$o=0;
		if ($vmmgfiles_to_print > 0)
			{echo "<tr><td><font size=2>"._QXZ("Rank")." &nbsp; "._QXZ("Time Range")."</td><td><font size=2>"._QXZ("Display")."</td><td><font size=2> &nbsp; "._QXZ("File name")."</td><td></td><tr>\n";}
		while ($vmmgfiles_to_print > $o)
			{
			$rowx=mysqli_fetch_row($rsltx);
			echo "<tr><td nowrap>";
			echo "<select size=1 name=$rowx[0]>\n";
			echo "<option SELECTED>$rowx[2]</option>\n";
			$k=1;
			while ($ranks > $k)
				{
				echo "<option>$k</option>\n";
				$k++;
				}
					$Ffilename_start = "TM_START_$vmmgfiles[$o]";
					$Ffilename_end = "TM_END_$vmmgfiles[$o]";
					$Ffilename_name = "DS_NAME_$vmmgname[$o]";
			echo "</select> &nbsp; \n";
			echo "<input type=text size=4 maxlength=4 value=\"$rowx[3]\" name=\"TM_START_$rowx[0]\"> - ";
			echo "<input type=text size=4 maxlength=4 value=\"$rowx[4]\" name=\"TM_END_$rowx[0]\"> &nbsp; ";
			echo "</td><td nowrap>";

			echo "<input type=text size=20 maxlength=255 value=\"$rowx[1]\" name=\"DS_NAME_$rowx[0]\">";
			echo "</td><td nowrap>";

			echo "<font size=2> &nbsp; <B>$rowx[0]</B></td><td nowrap><font size=2> - <a href=\"$PHP_SELF?ADD=497111111111&leave_vm_message_group_id=$leave_vm_message_group_id&stage=FILEDELETE&audio_filename=$rowx[0]\">"._QXZ("DELETE")."</a>";
			$o++;
			echo "</td></tr>";
			}
		if ($o < 1) {echo "<tr><td>"._QXZ("No Audio Files Set")."</td></tr>\n";}

		echo "</table></td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row2_background><td align=right valign=top>"._QXZ("Add An Audio File").": </td><td><input type=text size=50 maxlength=255 name=audio_filename id=audio_filename value=\"\"> <a href=\"javascript:launch_chooser('audio_filename','date');\">"._QXZ("audio chooser")."</a> $NWB#vm_message_groups$NWE<br>\n";
		echo ""._QXZ("Display Name").": <input type=text size=20 maxlength=255 name=audio_name value=\"\"> &nbsp; "._QXZ("Time Range").": <input type=text size=4 maxlength=4 name=time_start value=\"0000\"> "._QXZ("to")." <input type=text size=4 maxlength=4 name=time_end value=\"2400\">\n";
		echo "</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";

		echo "<center><b>\n";

		echo "<BR><BR><B>"._QXZ("CAMPAIGNS USING THIS VM MESSAGE GROUP").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where leave_vm_message_group_id='$leave_vm_message_group_id' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$camps_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($camps_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=31&campaign_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}
		echo "</TABLE><BR>\n";

		if ($LOGast_delete_phones > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=597111111111&leave_vm_message_group_id=$leave_vm_message_group_id&leave_vm_message_group_notes=$leave_vm_message_group_notes\">"._QXZ("DELETE VM MESSAGE GROUP ENTRY")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=VMMGROUP&stage=$leave_vm_message_group_id\">"._QXZ("Click here to see Admin changes to this VM Mesage Group entry")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=398111111111 modify Queue Group record in the system
######################
if ($ADD==398111111111)
	{
	if ($LOGmodify_statuses==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=398111111111&queue_group_name=$queue_group_name";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT queue_group,queue_group_name,active,user_group,included_campaigns,included_inbound_groups from vicidial_queue_groups where queue_group='$queue_group' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$queue_group =				$row[0];
		$queue_group_name =			$row[1];
		$active =					$row[2];
		$user_group =	(preg_match('/\-\-ALL\-\-/', $row[3]) ? _QXZ("$row[3]") : $row[3]);
		$included_campaigns =		$row[4];
		$included_inbound_groups =	$row[5];

		echo "<br>"._QXZ("MODIFY A QUEUE GROUP RECORD").": $queue_group<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=498111111111>\n";
		echo "<input type=hidden name=DB value=$DB>\n";
		echo "<input type=hidden name=queue_group value=\"$queue_group\">\n";

		echo "<center><TABLE width=900 cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Queue Group ID").": </td><td align=left><B>$queue_group</B></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Queue Group Name").": </td><td align=left><input type=text name=queue_group_name size=50 maxlength=255 value=\"$queue_group_name\">$NWB#queue_groups$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">$user_group</option>\n";
		echo "</select>$NWB#queue_groups$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$active' SELECTED>"._QXZ("$active")."</option></select>$NWB#queue_groups$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top>"._QXZ("Included Campaigns").": <BR>$NWB#queue_groups$NWE</td><td align=left>\n";
		echo "$qg_campaigns_list";
		echo " <BR>&nbsp;</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top>"._QXZ("Included Inbound Groups").": <BR>$NWB#queue_groups$NWE</td><td align=left>\n";
		echo "$qg_groups_list";
		echo " <BR>&nbsp;</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";

		echo "<center><b>\n";

		if ($LOGast_delete_phones > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=598111111111&queue_group=$queue_group&queue_group_name=$queue_group_name\">"._QXZ("DELETE QUEUE GROUP ENTRY")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=QUEUEGROUP&stage=$queue_group\">"._QXZ("Click here to see Admin changes to this Queue Group entry")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=371111111111 modify voicemail box in the system
######################
if ($ADD==371111111111)
	{
	if ( ($LOGast_admin_access==1) or ($LOGmodify_voicemail==1) )
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=371111111111&voicemail_id=$voicemail_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT voicemail_id,pass,fullname,active,email,messages,old_messages,delete_vm_after_email,voicemail_timezone,voicemail_options,user_group,voicemail_greeting,on_login_report from vicidial_voicemail where voicemail_id='$voicemail_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$voicemail_id =				$row[0];
		$pass =						$row[1];
		$fullname =					$row[2];
		$active =					$row[3];
		$email =					$row[4];
		$messages =					$row[5];
		$old_messages =				$row[6];
		$delete_vm_after_email =	$row[7];
		$voicemail_timezone =		$row[8];
		$voicemail_options =		$row[9];
		$user_group =				$row[10];
		$voicemail_greeting =		$row[11];
		$show_vm_on_summary = 		$row[12];

		echo "<br>"._QXZ("MODIFY A VOICEMAIL BOX").": $voicemail_id<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=471111111111>\n";
		echo "<input type=hidden name=DB value=$DB>\n";
		echo "<input type=hidden name=voicemail_id value=\"$voicemail_id\">\n";

		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Voicemail ID").": </td><td align=left><B>$voicemail_id</B></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Password").": </td><td align=left><input type=text name=pass size=12 maxlength=10 value=\"$pass\">$NWB#voicemail-pass$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Name").": </td><td align=left><input type=text name=fullname size=50 maxlength=100 value=\"$fullname\">$NWB#voicemail-fullname$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Email").": </td><td align=left><input type=text name=email size=50 maxlength=100 value=\"$email\">$NWB#voicemail-email$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$active' SELECTED>"._QXZ("$active")."</option></select>$NWB#voicemail-active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">$user_group</option>\n";
		echo "</select>$NWB#voicemail-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Delete Voicemail After Email").": </td><td align=left><select size=1 name=delete_vm_after_email><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$delete_vm_after_email' selected>"._QXZ("$delete_vm_after_email")."</option></select>$NWB#voicemail-delete_vm_after_email$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Show VM on Summary Screen").": </td><td align=left><select size=1 name=show_vm_on_summary><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$show_vm_on_summary' selected>"._QXZ("$show_vm_on_summary")."</option></select>$NWB#voicemail-show_vm_on_summary$NWE</td></tr>\n";
		if ($SSallow_voicemail_greeting > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Voicemail Greeting").": </td><td><input type=hidden name=old_voicemail_greeting value=\"$voicemail_greeting\"><input type=text size=50 maxlength=100 name=voicemail_greeting id=voicemail_greeting value=\"$voicemail_greeting\"> <a href=\"javascript:launch_chooser('voicemail_greeting','date');\">"._QXZ("audio chooser")."</a>  $NWB#voicemail-voicemail_greeting$NWE</td></tr>\n";
			}
		else
			{
			echo "<input type=hidden name=voicemail_greeting value=\"$voicemail_greeting\">";
			echo "<input type=hidden name=old_voicemail_greeting value=\"$voicemail_greeting\">";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Voicemail Zone").": </td><td align=left><select size=1 name=voicemail_timezone>";
		$vm_zones = explode("\n",$SSvoicemail_timezones);
		$z=0;
		$vm_zones_ct = count($vm_zones);
		while($vm_zones_ct > $z)
			{
			if (strlen($vm_zones[$z]) > 5)
				{
				$vm_specs = explode("=",$vm_zones[$z]);
				$vm_abb = $vm_specs[0];
				$vm_details = explode('|',$vm_specs[1]);
				$vm_location = 	$vm_details[0];
				echo "<option value=\"$vm_abb\">$vm_abb - $vm_location</option>\n";
				}
			$z++;
			}
		echo "<option selected>$voicemail_timezone</option></select> $NWB#voicemail-voicemail_timezone$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Voicemail Options").": </td><td align=left><input type=text name=voicemail_options size=50 maxlength=100 value=\"$voicemail_options\">$NWB#voicemail-voicemail_options$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("New Messages").": </td><td align=left><B>$messages</B></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Old Messages").": </td><td align=left><B>$old_messages</B></td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";

		echo "<center><b>\n";

		if (file_exists('options.php'))
			{require('options.php');}
		if (strlen($vm_view_messages_link) > 5)
			{
			$temp_vm_view_messages_link = preg_replace("/voicemail_id/",$voicemail_id,$vm_view_messages_link);
			echo "<br><br><a href=\"$temp_vm_view_messages_link\">"._QXZ("View Messages");
			}

		if ($LOGast_delete_phones > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=571111111111&voicemail_id=$voicemail_id&fullname=$fullname\">"._QXZ("DELETE THIS VOICEMAIL BOX")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=VOICEMAIL&stage=$voicemail_id\">"._QXZ("Click here to see Admin changes to this voicemail box")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=381111111111 modify screen label in the system
######################
if ($ADD==381111111111)
	{
	if ( ($LOGast_admin_access==1) or ($LOGmodify_labels==1) )
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=381111111111&label_id=$label_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT label_id,label_name,active,label_hide_field_logs,label_title,label_first_name,label_middle_initial,label_last_name,label_address1,label_address2,label_address3,label_city,label_state,label_province,label_postal_code,label_vendor_lead_code,label_gender,label_phone_number,label_phone_code,label_alt_phone,label_security_phrase,label_email,label_comments,user_group,label_lead_id,label_list_id,label_entry_date,label_gmt_offset_now,label_source_id,label_called_since_last_reset,label_status,label_user,label_date_of_birth,label_country_code,label_last_local_call_time,label_called_count,label_rank,label_owner,label_entry_list_id from vicidial_screen_labels where label_id='$label_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$label_id =					$row[0];
		$label_name =				$row[1];
		$active =					$row[2];
		$label_hide_field_logs =	$row[3];
		$label_title =				$row[4];
		$label_first_name =			$row[5];
		$label_middle_initial =		$row[6];
		$label_last_name =			$row[7];
		$label_address1 =			$row[8];
		$label_address2 =			$row[9];
		$label_address3 =			$row[10];
		$label_city =				$row[11];
		$label_state =				$row[12];
		$label_province =			$row[13];
		$label_postal_code =		$row[14];
		$label_vendor_lead_code =	$row[15];
		$label_gender =				$row[16];
		$label_phone_number =		$row[17];
		$label_phone_code =			$row[18];
		$label_alt_phone =			$row[19];
		$label_security_phrase =	$row[20];
		$label_email =				$row[21];
		$label_comments =			$row[22];
		$user_group =				$row[23];
		$label_lead_id =			$row[24];
		$label_list_id =			$row[25];
		$label_entry_date =			$row[26];
		$label_gmt_offset_now =		$row[27];
		$label_source_id =			$row[28];
		$label_called_since_last_reset = $row[29];
		$label_status =				$row[30];
		$label_user =				$row[31];
		$label_date_of_birth =		$row[32];
		$label_country_code =		$row[33];
		$label_last_local_call_time = $row[34];
		$label_called_count =		$row[35];
		$label_rank =				$row[36];
		$label_owner =				$row[37];
		$label_entry_list_id =		$row[38];

		echo "<br>"._QXZ("MODIFY SCREEN LABEL").": $label_id<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=481111111111>\n";
		echo "<input type=hidden name=label_id value=\"$label_id\">\n";

		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label ID").": </td><td align=left><B>$label_id</B></td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Name").": </td><td align=left><input type=text name=label_name size=50 maxlength=100 value=\"$label_name\">$NWB#screen_labels-label_name$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$active' SELECTED>"._QXZ("$active")."</option></select>$NWB#screen_labels-active$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">".(preg_match('/\-\-ALL\-\-/', $user_group) ? _QXZ("$user_group") : $user_group)."</option>\n";
		echo "</select>$NWB#screen_labels-user_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Hide Label in Call Logs").": </td><td align=left><select size=1 name=label_hide_field_logs><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$label_hide_field_logs' SELECTED>"._QXZ("$label_hide_field_logs")."</option></select>$NWB#screen_labels-label_hide_field_logs$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Title").": </td><td align=left><input type=text name=label_title size=20 maxlength=60 value=\"$label_title\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label First Name").": </td><td align=left><input type=text name=label_first_name size=20 maxlength=60 value=\"$label_first_name\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Middle Initial").": </td><td align=left><input type=text name=label_middle_initial size=20 maxlength=60 value=\"$label_middle_initial\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Last Name").": </td><td align=left><input type=text name=label_last_name size=20 maxlength=60 value=\"$label_last_name\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Address1").": </td><td align=left><input type=text name=label_address1 size=20 maxlength=60 value=\"$label_address1\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Address2").": </td><td align=left><input type=text name=label_address2 size=20 maxlength=60 value=\"$label_address2\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Address3").": </td><td align=left><input type=text name=label_address3 size=20 maxlength=60 value=\"$label_address3\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label City").": </td><td align=left><input type=text name=label_city size=20 maxlength=60 value=\"$label_city\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label State").": </td><td align=left><input type=text name=label_state size=20 maxlength=60 value=\"$label_state\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Province").": </td><td align=left><input type=text name=label_province size=20 maxlength=60 value=\"$label_province\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Postal Code").": </td><td align=left><input type=text name=label_postal_code size=20 maxlength=60 value=\"$label_postal_code\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Vendor Lead Code").": </td><td align=left><input type=text name=label_vendor_lead_code size=20 maxlength=60 value=\"$label_vendor_lead_code\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Gender").": </td><td align=left><input type=text name=label_gender size=20 maxlength=60 value=\"$label_gender\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Phone Number").": </td><td align=left><input type=text name=label_phone_number size=20 maxlength=60 value=\"$label_phone_number\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Phone Code").": </td><td align=left><input type=text name=label_phone_code size=20 maxlength=60 value=\"$label_phone_code\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Alt Phone").": </td><td align=left><input type=text name=label_alt_phone size=20 maxlength=60 value=\"$label_alt_phone\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Security Phrase").": </td><td align=left><input type=text name=label_security_phrase size=20 maxlength=60 value=\"$label_security_phrase\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Email").": </td><td align=left><input type=text name=label_email size=20 maxlength=60 value=\"$label_email\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Comments").": </td><td align=left><input type=text name=label_comments size=20 maxlength=60 value=\"$label_comments\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Lead ID").": </td><td align=left><input type=text name=label_lead_id size=20 maxlength=60 value=\"$label_lead_id\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label List ID").": </td><td align=left><input type=text name=label_list_id size=20 maxlength=60 value=\"$label_list_id\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Entry Date").": </td><td align=left><input type=text name=label_entry_date size=20 maxlength=60 value=\"$label_entry_date\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Timezone").": </td><td align=left><input type=text name=label_gmt_offset_now size=20 maxlength=60 value=\"$label_gmt_offset_now\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Source ID").": </td><td align=left><input type=text name=label_source_id size=20 maxlength=60 value=\"$label_source_id\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Reset Code").": </td><td align=left><input type=text name=label_called_since_last_reset size=20 maxlength=60 value=\"$label_called_since_last_reset\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Status").": </td><td align=left><input type=text name=label_status size=20 maxlength=60 value=\"$label_status\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label User").": </td><td align=left><input type=text name=label_user size=20 maxlength=60 value=\"$label_user\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Date of Birth").": </td><td align=left><input type=text name=label_date_of_birth size=20 maxlength=60 value=\"$label_date_of_birth\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Country Code").": </td><td align=left><input type=text name=label_country_code size=20 maxlength=60 value=\"$label_country_code\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Last Call").": </td><td align=left><input type=text name=label_last_local_call_time size=20 maxlength=60 value=\"$label_last_local_call_time\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Called Count").": </td><td align=left><input type=text name=label_called_count size=20 maxlength=60 value=\"$label_called_count\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Rank").": </td><td align=left><input type=text name=label_rank size=20 maxlength=60 value=\"$label_rank\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Owner").": </td><td align=left><input type=text name=label_owner size=20 maxlength=60 value=\"$label_owner\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Label Entry List ID").": </td><td align=left><input type=text name=label_entry_list_id size=20 maxlength=60 value=\"$label_entry_list_id\">$NWB#screen_labels-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";

		echo "<center><b>\n";


		echo "</TABLE><BR><BR>\n";
		echo "<B> "._QXZ("CAMPAIGNS USING THIS SCREEN LABEL").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where screen_labels='$label_id' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$camps_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($camps_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=31&campaign_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE><BR><BR>\n";

		if ($LOGast_delete_phones > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=581111111111&label_id=$label_id&label_name=$label_name\">"._QXZ("DELETE THIS SCREEN LABEL")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=LABEL&stage=$label_id\">"._QXZ("Click here to see Admin changes to this screen label")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=382111111111 modify screen colors in the system
######################
if ($ADD==382111111111)
	{
	if ( ($LOGast_admin_access==1) or ($LOGmodify_colors==1) )
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=382111111111&colors_id=$colors_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT colors_id,colors_name,active,menu_background,frame_background,std_row1_background,std_row2_background,std_row3_background,std_row4_background,std_row5_background,alt_row1_background,alt_row2_background,alt_row3_background,user_group,web_logo,button_color from vicidial_screen_colors where colors_id='$colors_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$colors_id =				$row[0];
		$colors_name =				$row[1];
		$active =					$row[2];
		$menu_background =			$row[3];
		$frame_background =			$row[4];
		$std_row1_background =		$row[5];
		$std_row2_background =		$row[6];
		$std_row3_background =		$row[7];
		$std_row4_background =		$row[8];
		$std_row5_background =		$row[9];
		$alt_row1_background =		$row[10];
		$alt_row2_background =		$row[11];
		$alt_row3_background =		$row[12];
		$user_group =				$row[13];
		$web_logo =					$row[14];
		$button_color =		$row[15];

		echo "<br>"._QXZ("MODIFY SCREEN COLORS").": $colors_id<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=482111111111>\n";
		echo "<input type=hidden name=colors_id value=\"$colors_id\">\n";

		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Colors ID").": </td><td align=left colspan=2><B>$colors_id</B></td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Colors Name").": </td><td align=left colspan=2><input type=text name=colors_name size=50 maxlength=100 value=\"$colors_name\">$NWB#screen_colors-colors_name$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left colspan=2><select size=1 name=active><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$active' SELECTED>"._QXZ("$active")."</option></select>$NWB#screen_colors-active$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left colspan=2><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">".(preg_match('/\-\-ALL\-\-/', $user_group) ? _QXZ("$user_group") : $user_group)."</option>\n";
		echo "</select>$NWB#screen_colors-user_group$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Menu Background")." <font size=2>(<a href=\"javascript:launch_color_chooser('menu_background','color','2');\">"._QXZ("color chooser")."</a>)</font>: </td><td align=left bgcolor=\"$menu_background\" id=\"menu_background_td\" colspan=2><input type=text name=menu_background id=menu_background size=7 maxlength=6 value=\"$menu_background\"> $NWB#screen_colors-menu_background$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Frame Background")." <font size=2>(<a href=\"javascript:launch_color_chooser('frame_background','color','2');\">"._QXZ("color chooser")."</a>)</font>: </td><td align=left bgcolor=\"$frame_background\" id=\"frame_background_td\" colspan=2><input type=text name=frame_background id=frame_background size=7 maxlength=6 value=\"$frame_background\"> $NWB#screen_colors-frame_background$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Standard Row 1 Background")." <font size=2>(<a href=\"javascript:launch_color_chooser('std_row1_background','color','2');\">"._QXZ("color chooser")."</a>)</font>: </td><td align=left bgcolor=\"$std_row1_background\" id=\"std_row1_background_td\" colspan=2><input type=text name=std_row1_background id=std_row1_background size=7 maxlength=6 value=\"$std_row1_background\"> $NWB#screen_colors-std_row_background$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Standard Row 2 Background")." <font size=2>(<a href=\"javascript:launch_color_chooser('std_row2_background','color','2');\">"._QXZ("color chooser")."</a>)</font>: </td><td align=left bgcolor=\"$std_row2_background\" id=\"std_row2_background_td\" colspan=2><input type=text name=std_row2_background id=std_row2_background size=7 maxlength=6 value=\"$std_row2_background\"> $NWB#screen_colors-std_row_background$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Standard Row 3 Background")." <font size=2>(<a href=\"javascript:launch_color_chooser('std_row3_background','color','2');\">"._QXZ("color chooser")."</a>)</font>: </td><td align=left bgcolor=\"$std_row3_background\" id=\"std_row3_background_td\" colspan=2><input type=text name=std_row3_background id=std_row3_background size=7 maxlength=6 value=\"$std_row3_background\"> $NWB#screen_colors-std_row_background$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Standard Row 4 Background")." <font size=2>(<a href=\"javascript:launch_color_chooser('std_row4_background','color','2');\">"._QXZ("color chooser")."</a>)</font>: </td><td align=left bgcolor=\"$std_row4_background\" id=\"std_row4_background_td\" colspan=2><input type=text name=std_row4_background id=std_row4_background size=7 maxlength=6 value=\"$std_row4_background\"> $NWB#screen_colors-std_row_background$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Standard Row 5 Background")." <font size=2>(<a href=\"javascript:launch_color_chooser('std_row5_background','color','2');\">"._QXZ("color chooser")."</a>)</font>: </td><td align=left bgcolor=\"$std_row5_background\" id=\"std_row5_background_td\" colspan=2><input type=text name=std_row5_background id=std_row5_background size=7 maxlength=6 value=\"$std_row5_background\"> $NWB#screen_colors-std_row_background$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Alternate Row 1 Background")." <font size=2>(<a href=\"javascript:launch_color_chooser('alt_row1_background','color','2');\">"._QXZ("color chooser")."</a>)</font>: </td><td align=left bgcolor=\"$alt_row1_background\" id=\"alt_row1_background_td\" colspan=2><input type=text name=alt_row1_background id=alt_row1_background size=7 maxlength=6 value=\"$alt_row1_background\"> $NWB#screen_colors-alt_row_background$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Alternate Row 2 Background")." <font size=2>(<a href=\"javascript:launch_color_chooser('alt_row2_background','color','2');\">"._QXZ("color chooser")."</a>)</font>: </td><td align=left bgcolor=\"$alt_row2_background\" id=\"alt_row2_background_td\" colspan=2><input type=text name=alt_row2_background id=alt_row2_background size=7 maxlength=6 value=\"$alt_row2_background\"> $NWB#screen_colors-alt_row_background$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Alternate Row 3 Background")." <font size=2>(<a href=\"javascript:launch_color_chooser('alt_row3_background','color','2');\">"._QXZ("color chooser")."</a>)</font>: </td><td align=left bgcolor=\"$alt_row3_background\" id=\"alt_row3_background_td\" colspan=2><input type=text name=alt_row3_background id=alt_row3_background size=7 maxlength=6 value=\"$alt_row3_background\"> $NWB#screen_colors-alt_row_background$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background valign=top><td align=right valign=top>"._QXZ("Web Logo").": </td><td align=left valign=top><select size=1 name=web_logo>\n";

		$logo_new=0;
		$logo_old=0;
		$logo_small_old=0;
		if (file_exists('./images/vicidial_admin_web_logo.png')) {$logo_new++;}
		if (file_exists('vicidial_admin_web_logo_small.gif')) {$logo_small_old++;}
		if (file_exists('vicidial_admin_web_logo.gif')) {$logo_old++;}

		if ($logo_new) {echo "<option value=\"default_new\">default_new</option>\n";}
		if ($logo_old) {echo "<option value=\"default_old\">default_old</option>\n";}

		if ($dir_handle = opendir('./images'))
			{
			while (false !== ($entry = readdir($dir_handle))) 
				{
				if ( (preg_match("/vicidial_admin_web_logo/",$entry)) and (!preg_match("/vicidial_admin_web_logo\.png/",$entry)) and (preg_match("/\.gif$|\.jpg$|\.png$/",$entry)) )
					{
					$entry = preg_replace("/vicidial_admin_web_logo/",'',$entry);
					echo "<option value=\"$entry\">$entry</option>\n";
					}
				}
			closedir($dir_handle);
			}

		if ($web_logo=='default_new')
			{
			$selected_logo = "./images/vicidial_admin_web_logo.png";
			}
		if ( ($web_logo=='default_old') and ($logo_old > 0) )
			{
			$selected_logo = "./vicidial_admin_web_logo.gif";
			}
		if ( ($web_logo!='default_new') and ($web_logo!='default_old') )
			{
			if (file_exists("./images/vicidial_admin_web_logo$web_logo")) 
				{
				$selected_logo = "./images/vicidial_admin_web_logo$web_logo";
				}
			}

		echo "<option SELECTED value=\"$web_logo\">$web_logo</option>\n";
		echo "</select>$NWB#screen_colors-web_logo$NWE &nbsp; &nbsp; </td><td align=left valign=top bgcolor=#$menu_background><img src=\"$selected_logo\"></td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Button Color")." <font size=2>(<a href=\"javascript:launch_color_chooser('button_color','color','2');\">"._QXZ("color chooser")."</a>)</font>: </td><td align=left bgcolor=\"$button_color\" id=\"button_color_td\" colspan=2><input type=text name=button_color id=button_color size=7 maxlength=6 value=\"$button_color\"> $NWB#screen_colors-alt_row_background$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=3><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";

		echo "<center><b>\n";


		echo "</TABLE><BR><BR>\n";

		if ($LOGast_delete_phones > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=582111111111&colors_id=$colors_id&colors_name=$colors_name\">"._QXZ("DELETE THIS SCREEN COLORS ENTRY")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=COLORS&stage=$colors_id\">"._QXZ("Click here to see Admin changes to this screen colors entry")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=391111111111 modify contact in the system
######################
if ($ADD==391111111111)
	{
	if ( ($LOGast_admin_access==1) or ($LOGmodify_contacts==1) )
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=391111111111&contact_id=$contact_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		if ( (preg_match("/contact_information/",$SStables_use_alt_log_db)) and (strlen($SSalt_log_server_ip)>4) and (strlen($SSalt_log_dbname)>0) )
			{
			$linkALT=mysqli_connect("$SSalt_log_server_ip", "$SSalt_log_login", "$SSalt_log_pass", "$SSalt_log_dbname");
				if (!$linkALT) 
					{
					die('MySQL '._QXZ("connect ERROR").': ' . mysqli_connect_error());
					}
			}
		else
			{$linkALT = $link;}
		$stmt="SELECT first_name,last_name,office_num,cell_num,other_num1,other_num2,bu_name,department,group_name,job_title,location from contact_information where contact_id='$contact_id';";
		$rslt=mysql_to_mysqli($stmt, $linkALT);
		$row=mysqli_fetch_row($rslt);
		$first_name =	$row[0];
		$last_name =	$row[1];
		$office_num =	$row[2];
		$cell_num =		$row[3];
		$other_num1 =	$row[4];
		$other_num2 =	$row[5];
		$bu_name =		$row[6];
		$department =	$row[7];
		$group_name =	$row[8];
		$job_title =	$row[9];
		$location =		$row[10];

		echo "<br>"._QXZ("MODIFY CONTACT").": $tts_id<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=491111111111>\n";
		echo "<input type=hidden name=contact_id value=\"$contact_id\">\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("First Name").": </td><td align=left><input type=text name=first_name value=\"$first_name\" size=50 maxlength=50>$NWB#contact_information$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Last Name").": </td><td align=left><input type=text name=last_name value=\"$last_name\" size=50 maxlength=50>$NWB#contact_information$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Office Number").": </td><td align=left><input type=text name=office_num value=\"$office_num\" size=20 maxlength=20>$NWB#contact_information$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Cell Number").": </td><td align=left><input type=text name=cell_num value=\"$cell_num\" size=20 maxlength=20>$NWB#contact_information$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Other Number")." 1: </td><td align=left><input type=text name=other_num1 value=\"$other_num1\" size=20 maxlength=20>$NWB#contact_information$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Other Number")." 2: </td><td align=left><input type=text name=other_num2 value=\"$other_num2\" size=20 maxlength=20>$NWB#contact_information$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("BU Name").": </td><td align=left><input type=text name=bu_name value=\"$bu_name\" size=50 maxlength=100>$NWB#contact_information$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Department").": </td><td align=left><input type=text name=department value=\"$department\" size=50 maxlength=100>$NWB#contact_information$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Group").": </td><td align=left><input type=text name=group_name value=\"$group_name\" size=50 maxlength=100>$NWB#contact_information$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Job Title").": </td><td align=left><input type=text name=job_title value=\"$job_title\" size=50 maxlength=100>$NWB#contact_information$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Location").": </td><td align=left><input type=text name=location value=\"$location\" size=50 maxlength=100>$NWB#contact_information$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";

		echo "<center><b>\n";

		if ($LOGast_delete_phones > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=591111111111&contact_id=$contact_id&first_name=$first_name&last_name=$last_name\">"._QXZ("DELETE THIS CONTACT")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=CONTACTS&stage=$contact_id\">"._QXZ("Click here to see Admin changes to this contact")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=392111111111 modify settings container in the system
######################
if ($ADD==392111111111)
	{
	if ( ($LOGast_admin_access==1) and ($LOGmodify_servers==1) )
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=392111111111&container_id=$container_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT container_notes,container_type,user_group,container_entry from vicidial_settings_containers where container_id='$container_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$container_notes =			$row[0];
		$container_type =			$row[1];
		$user_group =				$row[2];
		$container_entry =			$row[3];

		echo "<br>"._QXZ("MODIFY SETTINGS CONTAINER").": $container_id<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=492111111111>\n";
		echo "<input type=hidden name=container_id value=\"$container_id\">\n";
		echo "<input type=hidden name=stage value=\"$container_type\">\n";

		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Container ID").": </td><td align=left><B>$container_id</B></td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Container Notes").": </td><td align=left><input type=text name=container_notes size=50 maxlength=255 value=\"$container_notes\">$NWB#settings_containers-container_notes$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Container Type").": </td><td align=left><select size=1 name=container_type>
		<option value='2FA_SETTINGS'>"._QXZ("2FA_SETTINGS")."</option>
		<option value='AGI'>"._QXZ("AGI")."</option>
		<option value='AMD_AGENT_OPTIONS'>"._QXZ("AMD_AGENT_OPTIONS")."</option>
		<option value='CALL_LIMITS_OVERRIDE'>"._QXZ("CALL_LIMITS_OVERRIDE")."</option>
		<option value='CALL_QUOTA'>"._QXZ("CALL_QUOTA")."</option>
		<option value='CALLS_IN_QUEUE_COUNT'>"._QXZ("CALLS_IN_QUEUE_COUNT")."</option>
		<option value='CAMPAIGN_LIST'>"._QXZ("CAMPAIGN_LIST")."</option>
		<option value='CM_VIDPROMPT_SPECIAL'>"._QXZ("CM_VIDPROMPT_SPECIAL")."</option>
		<option value='DEMOGRAPHIC_QUOTAS'>"._QXZ("DEMOGRAPHIC_QUOTAS")."</option>
		<option value='DIAL_TIMEOUTS'>"._QXZ("DIAL_TIMEOUTS")."</option>
		<option value='DID_RECENT_CALL'>"._QXZ("DID_RECENT_CALL")."</option>
		<option value='DISPO_FILTER'>"._QXZ("DISPO_FILTER")."</option>
		<option value='EMAIL_TEMPLATE'>"._QXZ("EMAIL_TEMPLATE")."</option>
		<option value='INGROUP_LIST'>"._QXZ("INGROUP_LIST")."</option>
		<option value='KHOMP_SETTINGS'>"._QXZ("KHOMP_SETTINGS")."</option>
		<option value='LIST_WEEKDAY_RESETS'>"._QXZ("LIST_WEEKDAY_RESETS")."</option>
		<option value='OTHER'>"._QXZ("OTHER")."</option>
		<option value='PAUSE_CODES_LIST'>"._QXZ("PAUSE_CODES_LIST")."</option>
		<option value='PERL_CLI'>"._QXZ("PERL_CLI")."</option>
		<option value='PHONE_DEFAULTS'>"._QXZ("PHONE_DEFAULTS")."</option>
		<option value='PHONE_NUMBERS'>"._QXZ("PHONE_NUMBERS")."</option>
		<option value='QC_TEMPLATE'>"._QXZ("QC_TEMPLATE")."</option>
		<option value='READ_ONLY'>"._QXZ("READ_ONLY")."</option>
		<option value='SIP_EVENT_ACTIONS'>"._QXZ("SIP_EVENT_ACTIONS")."</option>
		<option value='STATE_DESCRIPTIONS'>"._QXZ("STATE_DESCRIPTIONS")."</option>
		<option value='TIMEZONE_LIST'>"._QXZ("TIMEZONE_LIST")."</option>
		<option value='WEBPHONE_SETTINGS'>"._QXZ("WEBPHONE_SETTINGS")."</option>
		<option value='WEEKDAY_TIMERANGE_SECONDS'>"._QXZ("WEEKDAY_TIMERANGE_SECONDS")."</option>
		<option SELECTED value='$container_type'>"._QXZ("$container_type")."</option>
		</select>$NWB#settings_containers-container_type$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">".(preg_match('/\-\-ALL\-\-/', $user_group) ? _QXZ("$user_group") : $user_group)."</option>\n";
		echo "</select>$NWB#settings_containers-user_group$NWE</td></tr>\n";

		if ($container_type == 'READ_ONLY')
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Container Entry").": </td><td align=left><PRE>$container_entry</PRE> $NWB#settings_containers-container_entry$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Container Entry").": </td><td align=left><TEXTAREA NAME=container_entry ROWS=25 COLS=75>$container_entry</TEXTAREA> $NWB#settings_containers-container_entry$NWE</td></tr>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";

		echo "<center><b>\n";


		echo "</TABLE><BR><BR>\n";

		if (preg_match("/WEEKDAY_TIMERANGE_SECONDS|CALL_QUOTA|CALL_LIMITS_OVERRIDE|SIP_EVENT_ACTIONS|CALLS_IN_QUEUE_COUNT|TIMEZONE_LIST|PHONE_NUMBERS|DIAL_TIMEOUTS|INGROUP_LIST|PAUSE_CODES_LIST|DEMOGRAPHIC_QUOTAS|STATE_DESCRIPTIONS/",$container_type))
			{
			echo "<B>"._QXZ("CAMPAIGNS USING THIS SETTINGS CONTAINER").":</B><BR>\n";
			echo "<TABLE>\n";

			$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where ( (in_man_dial_next_ready_seconds_override='$container_id') or (pause_max_exceptions='$container_id') or (call_quota_lead_ranking='$container_id') or (call_limit_24hour_override='$container_id') or (inbound_no_agents_no_dial_container='$container_id') or (dial_timeout_lead_container='$container_id') or (three_way_record_stop_exception='$container_id') or (leave_3way_start_recording_exception='$container_id') or (scheduled_callbacks_timezones_container='$container_id') or (in_man_dial_next_ready_seconds_override='$container_id') or (sip_event_logging='$container_id') or (calls_inqueue_count_one='$container_id') or (calls_inqueue_count_two='$container_id') or (demographic_quotas_container='$container_id') or (state_descriptions='$container_id') ) $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$ig_to_print = mysqli_num_rows($rslt);
			if ($DB > 0) {echo "$ig_to_print|$stmt<br>\n";}
			$o=0;
			while ($ig_to_print > $o) 
				{
				$row=mysqli_fetch_row($rslt);
				echo "<TR><TD><a href=\"$PHP_SELF?ADD=31&campaign_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
				$o++;
				}

			echo "</TABLE><BR>\n";

			echo "<B>"._QXZ("IN-GROUPS USING THIS SETTINGS CONTAINER").":</B><BR>\n";
			echo "<TABLE>\n";

			$stmt="SELECT group_id,group_name from vicidial_inbound_groups where ( (drop_call_seconds_override='$container_id') or (in_queue_nanque_exceptions='$container_id') or (second_alert_container='$container_id') or (third_alert_container='$container_id') or (state_descriptions='$container_id') ) $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$ig_to_print = mysqli_num_rows($rslt);
			if ($DB > 0) {echo "$ig_to_print|$stmt<br>\n";}
			$o=0;
			while ($ig_to_print > $o) 
				{
				$row=mysqli_fetch_row($rslt);
				echo "<TR><TD><a href=\"$PHP_SELF?ADD=3111&group_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
				$o++;
				}

			echo "</TABLE><BR>\n";

			echo "<B>"._QXZ("INBOUND DIDS USING THIS SETTINGS CONTAINER").":</B><BR>\n";
			echo "<TABLE>\n";

			$stmt="SELECT did_pattern,did_description,did_id from vicidial_inbound_dids where ( (pre_filter_recent_call='$container_id') or (pre_filter_recent_call='$container_id') ) $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$did_to_print = mysqli_num_rows($rslt);
			if ($DB > 0) {echo "$did_to_print|$stmt<br>\n";}
			$o=0;
			while ($did_to_print > $o) 
				{
				$row=mysqli_fetch_row($rslt);
				echo "<TR><TD><a href=\"$PHP_SELF?ADD=3311&did_id=$row[2]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
				$o++;
				}

			echo "</TABLE><BR>\n";
			}

		if (preg_match("/WEBPHONE_SETTINGS/",$container_type))
			{
			echo "<B>"._QXZ("PHONES USING THIS SETTINGS CONTAINER").":</B><BR>\n";
			echo "<TABLE>\n";

			$stmt="SELECT extension,server_ip from phones where (webphone_settings='$container_id') $LOGadmin_viewable_groupsSQL order by server_ip,extension;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$p_to_print = mysqli_num_rows($rslt);
			if ($DB > 0) {echo "$p_to_print|$stmt<br>\n";}
			$o=0;
			while ($p_to_print > $o) 
				{
				$row=mysqli_fetch_row($rslt);
				echo "<TR><TD><a href=\"$PHP_SELF?ADD=31111111111&extension=$row[0]&server_ip=$row[1]\"><font size=2>$row[0] - $row[1]</a></TD><TD><font size=2> $row[1]<BR></TD></TR>\n";
				$o++;
				}

			echo "</TABLE><BR>\n";
			}

		if (preg_match("/LIST_WEEKDAY_RESETS/",$container_type))
			{
			echo "<B>"._QXZ("LISTS USING THIS SETTINGS CONTAINER").":</B><BR>\n";
			echo "<TABLE>\n";

			$stmt="SELECT list_id,list_name,campaign_id from vicidial_lists where (weekday_resets_container='$container_id') $LOGallowed_campaignsSQL order by list_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$p_to_print = mysqli_num_rows($rslt);
			if ($DB > 0) {echo "$p_to_print|$stmt<br>\n";}
			$o=0;
			while ($p_to_print > $o) 
				{
				$row=mysqli_fetch_row($rslt);
				echo "<TR><TD><a href=\"$PHP_SELF?ADD=311&list_id=$row[0]\"><font size=2>$row[0] - $row[1]</a></TD><TD><font size=2> $row[0] - $row[1] - $row[2]<BR></TD></TR>\n";
				$o++;
				}

			echo "</TABLE><BR>\n";
			}

		if (preg_match("/CM_VIDPROMPT_SPECIAL/",$container_type))
			{
			echo "<B>"._QXZ("CALL MENUS USING THIS SETTINGS CONTAINER").":</B><BR>\n";
			echo "<TABLE>\n";

			$stmt="SELECT distinct op.menu_id,menu_name from vicidial_call_menu_options op,vicidial_call_menu cm where option_route_value_context LIKE \"%,$container_id\" and op.menu_id=cm.menu_id $LOGadmin_viewable_groupsSQL order by menu_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$p_to_print = mysqli_num_rows($rslt);
			if ($DB > 0) {echo "$p_to_print|$stmt<br>\n";}
			$o=0;
			while ($p_to_print > $o) 
				{
				$row=mysqli_fetch_row($rslt);
				echo "<TR><TD><a href=\"$PHP_SELF?ADD=3511&menu_id==$row[0]\"><font size=2>$row[0] - $row[1]</a></TD><TD><font size=2> $row[0] - $row[1] - $row[2]<BR></TD></TR>\n";
				$o++;
				}

			echo "</TABLE><BR>\n";
			}

		if ($LOGast_delete_phones > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=592111111111&container_id=$container_id&container_notes=$container_notes\">"._QXZ("DELETE THIS SETTINGS CONTAINER")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=CONTAINERS&stage=$container_id\">"._QXZ("Click here to see Admin changes to this settings container")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=393111111111 modify status group in the system
######################
if ($ADD==393111111111)
	{
	if ( ($LOGast_admin_access==1) and ($LOGmodify_statuses==1) )
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=393111111111&status_group_id=$status_group_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT status_group_notes,user_group from vicidial_status_groups where status_group_id='$status_group_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$status_group_notes =		$row[0];
		$user_group =				$row[1];

		echo "<br>"._QXZ("MODIFY STATUS GROUP").": $status_group_id<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=493111111111>\n";
		echo "<input type=hidden name=status_group_id value=\"$status_group_id\">\n";

		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Status Group ID").": </td><td align=left><B>$status_group_id</B></td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Status Group Notes").": </td><td align=left><input type=text name=status_group_notes size=50 maxlength=255 value=\"$status_group_notes\">$NWB#status_groups$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">".(preg_match('/\-\-ALL\-\-/', $user_group) ? _QXZ("$user_group") : $user_group)."</option>\n";
		echo "</select>$NWB#status_groups$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center></form>\n";

		echo "<center><b>\n";


		##### get status category listings for dynamic pulldown
		$stmt="SELECT vsc_id,vsc_name from vicidial_status_categories order by vsc_id desc;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$cats_to_print = mysqli_num_rows($rslt);
		$cats_list="";

		$o=0;
		while ($cats_to_print > $o)
			{
			$rowx=mysqli_fetch_row($rslt);
			$cats_list .= "<option value=\"$rowx[0]\">$rowx[0] - " . substr($rowx[1],0,20) . "</option>\n";
			$catsname_list["$rowx[0]"] = substr($rowx[1],0,20);
			$o++;
			}

		echo "<TABLE width=700 cellspacing=3>\n";
		echo "<tr height='250'><td align=center valign=bottom><font size=2><b>"._QXZ("STATUS")."</b></font></td>\n";
		echo "<td align=center valign=bottom><font size=2><b>"._QXZ("DESCRIPTION")."</td>\n";
		echo "<td align=center valign=bottom><font size=2><b>"._QXZ("CATEGORY")."</td>\n";
		echo "<td align=center valign=top bgcolor=\"#ccffff\"><font size=2 class='vertical-text'><b>"._QXZ("AGENT SELECTABLE")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#99ffcc\"><font size=2 class='vertical-text'><b>"._QXZ("HUMAN ANSWER")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#ccffff\"><font size=2 class='vertical-text'><b>"._QXZ("SALE")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#99ffcc\"><font size=2 class='vertical-text'><b>"._QXZ("DNC")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#ccffff\"><font size=2 class='vertical-text'><b>"._QXZ("CUSTOMER CONTACT")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#99ffcc\"><font size=2 class='vertical-text'><b>"._QXZ("NOT INTERESTED")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#ccffff\"><font size=2 class='vertical-text'><b>"._QXZ("UNWORKABLE")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#99ffcc\"><font size=2 class='vertical-text'><b>"._QXZ("SCHEDULED CALLBACK")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#ccffff\"><font size=2 class='vertical-text'><b>"._QXZ("COMPLETED")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#99ffcc\"><font size=2 class='vertical-text'><b>"._QXZ("ANSWERING MACHINE")."</B></font></td>\n";
		echo "<td align=center valign=bottom><font size=1><b>"._QXZ("MIN SEC")."</td>\n";
		echo "<td align=center valign=bottom><font size=1><b>"._QXZ("MAX SEC")."</td>\n";
		echo "<td align=center valign=bottom><font size=2><b>"._QXZ("MODIFY/DELETE")."</td>\n";
		echo "</tr>\n";


		$stmt="SELECT status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable,scheduled_callback,completed,min_sec,max_sec,answering_machine from vicidial_campaign_statuses where campaign_id='$status_group_id' $LOGallowed_campaignsSQL order by status;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$statuses_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($statuses_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$AScategory = $rowx[4];
			$o++;

			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

			echo "<tr $bgcolor><td><form action=$PHP_SELF method=POST>\n";
			echo "<input type=hidden name=ADD value=493111111111>\n";
			echo "<input type=hidden name=stage value=modify>\n";
			echo "<input type=hidden name=status value=\"$rowx[0]\">\n";
			echo "<input type=hidden name=status_group_id value=\"$status_group_id\">\n";
			echo "<font size=2><B>$rowx[0]</B></td>\n";
			echo "<td><input type=text name=status_name size=20 maxlength=30 value=\"$rowx[1]\"></td>\n";
			echo "<td>\n";
			echo "<select size=1 name=category class=\"cust_form\">\n";
			echo "$cats_list";
			echo "<option selected value=\"$AScategory\">$AScategory - $catsname_list[$AScategory]</option>\n";
			echo "</select>\n";
			echo "\n";
			echo "</td><td bgcolor=\"#ccffff\"><select size=1 name=selectable class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option selected value='$rowx[2]'>"._QXZ("$rowx[2]")."</option></select>\n";
			echo "</td><td bgcolor=\"#99ffcc\"><select size=1 name=human_answered class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option selected value='$rowx[3]'>"._QXZ("$rowx[3]")."</option></select>\n";
			echo "</td><td bgcolor=\"#ccffff\"><select size=1 name=sale class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option selected value='$rowx[5]'>"._QXZ("$rowx[5]")."</option></select>\n";
			echo "</td><td bgcolor=\"#99ffcc\"><select size=1 name=dnc class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option selected value='$rowx[6]'>"._QXZ("$rowx[6]")."</option></select>\n";
			echo "</td><td bgcolor=\"#ccffff\"><select size=1 name=customer_contact class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option selected value='$rowx[7]'>"._QXZ("$rowx[7]")."</option></select>\n";
			echo "</td><td bgcolor=\"#99ffcc\"><select size=1 name=not_interested class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option selected value='$rowx[8]'>"._QXZ("$rowx[8]")."</option></select>\n";
			echo "</td><td bgcolor=\"#ccffff\"><select size=1 name=unworkable class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option selected value='$rowx[9]'>"._QXZ("$rowx[9]")."</option></select>\n";
			echo "</td><td bgcolor=\"#99ffcc\"><select size=1 name=scheduled_callbacks class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option selected value='$rowx[10]'>"._QXZ("$rowx[10]")."</option></select>\n";
			echo "</td><td bgcolor=\"#ccffff\"><select size=1 name=completed class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option selected value='$rowx[11]'>"._QXZ("$rowx[11]")."</option></select>\n";
			echo "</td><td bgcolor=\"#99ffcc\"><select size=1 name=answering_machine class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option selected value='$rowx[14]'>"._QXZ("$rowx[14]")."</option></select>\n";
			echo "</td>\n";
			echo "<td><input type=text name=min_sec size=3 maxlength=5 value=\"$rowx[12]\" class=\"cust_form\"></td>\n";
			echo "<td><input type=text name=max_sec size=3 maxlength=5 value=\"$rowx[13]\" class=\"cust_form\"></td>\n";
			echo "</td><td align=center nowrap><font size=1><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("MODIFY")."'> &nbsp; &nbsp; &nbsp; &nbsp; \n";
			echo " &nbsp; \n";
			
			if (preg_match("/^B$|^NA$|^DNC$|^NA$|^DROP$|^INCALL$|^QUEUE$|^NEW$/i",$rowx[0]))
				{
				echo "<DEL>"._QXZ("DELETE")."</DEL>\n";
				}
			else
				{
				echo "<a href=\"$PHP_SELF?ADD=493111111111&status_group_id=$status_group_id&status=$rowx[0]&stage=delete\">"._QXZ("DELETE")."</a>\n";
				}
			echo "</form></td></tr>\n";
			}

		echo "</table>\n";


		echo "<br>"._QXZ("ADD NEW CUSTOM CAMPAIGN STATUS")."<BR><form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=493111111111>\n";
		echo "<input type=hidden name=stage value=add>\n";
		echo "<input type=hidden name=status_group_id value=\"$status_group_id\">\n";
		echo _QXZ("Status").": <input type=text name=status_id size=8 maxlength=6> &nbsp; \n";
		echo _QXZ("Description").": <input type=text name=status_name size=20 maxlength=30> &nbsp; \n";
		echo _QXZ("Selectable").": <select size=1 name=selectable><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Human Answer").": <select size=1 name=human_answered><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; <BR>\n";
		echo _QXZ("Sale").": <select size=1 name=sale><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("DNC").": <select size=1 name=dnc><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Customer Contact").": <select size=1 name=customer_contact><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Not Interested").": <select size=1 name=not_interested><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp;  <BR>\n";
		echo _QXZ("Unworkable").": <select size=1 name=unworkable><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Callback").": <select size=1 name=scheduled_callbacks><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Completed").": <select size=1 name=completed><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Answering Machine").": <select size=1 name=answering_machine><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Category").": \n";
		echo "<select size=1 name=category>\n";
		echo "$cats_list";
		echo "<option selected value=\"$AScategory\">$AScategory - $catsname_list[$AScategory]</option>\n";
		echo "</select> &nbsp; <BR>\n";
		echo "<input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("ADD")."'><BR>\n";

		echo "</FORM><br>\n";


		echo "</TABLE><BR><BR>\n";

		echo "<B>"._QXZ("IN-GROUPS USING THIS STATUS GROUP").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT group_id,group_name from vicidial_inbound_groups where status_group_id='$status_group_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$ig_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($ig_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=3111&group_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE><BR>\n";

		echo "<B>"._QXZ("LISTS USING THIS STATUS GROUP").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT list_id,list_name from vicidial_lists where status_group_id='$status_group_id' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$list_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($list_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=311&list_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE><BR>\n";

		if ($LOGast_delete_phones > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=593111111111&status_group_id=$status_group_id&status_group_notes=$status_group_notes\">"._QXZ("DELETE THIS STATUS GROUP")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=STATUSGROUPS&stage=$status_group_id\">"._QXZ("Click here to see Admin changes to this status group")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=394111111111 modify automated report info in the system
######################
if ($ADD==394111111111)
	{
	if ($LOGmodify_auto_reports==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=394111111111&report_id=$report_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		##### get server listing for dynamic pulldown 
		$stmt="SELECT server_ip,server_description,external_server_ip from servers order by server_ip";
		$rsltx=mysql_to_mysqli($stmt, $link);
		$servers_to_print = mysqli_num_rows($rsltx);
		$servers_list='';
		$o=0;
		while ($servers_to_print > $o)
			{
			$rowx=mysqli_fetch_row($rsltx);
			$servers_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}

		$stmt="SELECT report_id,report_name,report_last_run,report_last_length,report_server,report_times,report_weekdays,report_monthdays,report_destination,email_from,email_to,email_subject,ftp_server,ftp_user,ftp_pass,ftp_directory,report_url,run_now_trigger,active,user_group,filename_override from vicidial_automated_reports where report_id='$report_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$report_id =			$row[0];
		$report_name =			$row[1];
		$report_last_run =		$row[2];
		$report_last_length =	$row[3];
		$report_server =		$row[4];
		$report_times =			$row[5];
		$report_weekdays =		$row[6];
		$report_monthdays =		$row[7];
		$report_destination =	$row[8];
		$email_from =			$row[9];
		$email_to =				$row[10];
		$email_subject =		$row[11];
		$ftp_server =			$row[12];
		$ftp_user =				$row[13];
		$ftp_pass =				$row[14];
		$ftp_directory =		$row[15];
		$report_url =			$row[16];
		$run_now_trigger =		$row[17];
		$active =				$row[18];
		$user_group =			$row[19];
		$filename_override =	$row[20];

		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("MODIFY AN AUTOMATED REPORT")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=494111111111>\n";
		echo "<input type=hidden name=DB value=\"$DB\">\n";
		echo "<input type=hidden name=report_id value=\"$report_id\">\n";
		echo "<center><TABLE width=980 cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Report ID").": </td><td align=left><B>$report_id</B></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Last Run Time").": </td><td align=left><B>$report_last_run</B> &nbsp; <font size=1>($report_last_length "._QXZ("seconds").")</font></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Report Name").": </td><td align=left><input type=text name=report_name size=60 maxlength=100 value=\"$report_name\"> $NWB#auto_reports-report_name$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">".(preg_match('/\-\-ALL\-\-/', $user_group) ? _QXZ("$user_group") : $user_group)."</option>\n";
		echo "</select>$NWB#auto_reports-user_group$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Run Server").": </td><td align=left><select size=1 name=report_server>\n";
		echo "<option>active_voicemail_server</option>\n";
		echo "$servers_list";
		echo "<option SELECTED>$report_server</option>\n";
		echo "</select>$NWB#auto_reports-report_server$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Report Times").": </td><td align=left><input type=text name=report_times size=80 maxlength=255 id=report_times value=\"$report_times\">$NWB#auto_reports-report_times$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right NOWRAP>"._QXZ("Report Weekdays").":</td><td align=left NOWRAP>\n";
		echo "<input type=\"checkbox\" name=\"report_weekdays[]\" value=\"0\"";
			if (preg_match('/0/',$report_weekdays)) {echo " CHECKED";}
		echo ">"._QXZ("Sunday")." &nbsp; \n";
		echo "<input type=\"checkbox\" name=\"report_weekdays[]\" value=\"1\"";
			if (preg_match('/1/',$report_weekdays)) {echo " CHECKED";}
		echo ">"._QXZ("Monday")." &nbsp; \n";
		echo "<input type=\"checkbox\" name=\"report_weekdays[]\" value=\"2\"";
			if (preg_match('/2/',$report_weekdays)) {echo " CHECKED";}
		echo ">"._QXZ("Tuesday")." &nbsp; \n";
		echo "<input type=\"checkbox\" name=\"report_weekdays[]\" value=\"3\"";
			if (preg_match('/3/',$report_weekdays)) {echo " CHECKED";}
		echo ">"._QXZ("Wednesday")." &nbsp; \n";
		echo "<input type=\"checkbox\" name=\"report_weekdays[]\" value=\"4\"";
			if (preg_match('/4/',$report_weekdays)) {echo " CHECKED";}
		echo ">"._QXZ("Thursday")." &nbsp; \n";
		echo "<input type=\"checkbox\" name=\"report_weekdays[]\" value=\"5\"";
			if (preg_match('/5/',$report_weekdays)) {echo " CHECKED";}
		echo ">"._QXZ("Friday")." &nbsp; \n";
		echo "<input type=\"checkbox\" name=\"report_weekdays[]\" value=\"6\"";
			if (preg_match('/6/',$report_weekdays)) {echo " CHECKED";}
		echo ">"._QXZ("Saturday")." &nbsp; \n";
		echo "$NWB#auto_reports-report_weekdays$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Report Month Days").": </td><td align=left><input type=text name=report_monthdays size=60 maxlength=100 id=report_monthdays value=\"$report_monthdays\">$NWB#auto_reports-report_monthdays$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Report Destination").": </td><td align=left><select size=1 name=report_destination>\n";
		echo "<option value=\"EMAIL\">"._QXZ("EMAIL")."</option>\n";
		echo "<option value=\"FTP\">"._QXZ("FTP")."</option>\n";
		echo "<option value=\"$report_destination\" SELECTED>"._QXZ("$report_destination")."</option>\n";
		echo "</select>$NWB#auto_reports-report_destination$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Email From").": </td><td align=left><input type=text name=email_from size=40 maxlength=100 value=\"$email_from\">$NWB#auto_reports-email_from$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Email To").": </td><td align=left><input type=text name=email_to size=70 maxlength=100 value=\"$email_to\">$NWB#auto_reports-email_to$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Email Subject").": </td><td align=left><input type=text name=email_subject size=60 maxlength=100 value=\"$email_subject\">$NWB#auto_reports-email_subject$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>";
		if (preg_match("/^SFTPCNTR|^FTPSCNTR/",$ftp_server))
			{
			$temp_container_id = preg_replace("/^SFTPCNTR|^FTPSCNTR/",'',$ftp_server);
			echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$temp_container_id\">"._QXZ("FTP Server")."</a>";
			}
		else
			{echo ""._QXZ("FTP Server")."";}
		echo "</td><td align=left><input type=text name=ftp_server size=40 maxlength=100 value=\"$ftp_server\">$NWB#auto_reports-ftp_server$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("FTP User").": </td><td align=left><input type=text name=ftp_user size=40 maxlength=100 value=\"$ftp_user\">$NWB#auto_reports-ftp_user$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("FTP Pass").": </td><td align=left><input type=text name=ftp_pass size=40 maxlength=100 value=\"$ftp_pass\">$NWB#auto_reports-ftp_pass$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("FTP Directory").": </td><td align=left><input type=text name=ftp_directory size=60 maxlength=100 value=\"$ftp_directory\">$NWB#auto_reports-ftp_directory$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Filename Override").": </td><td align=left><input type=text name=filename_override size=80 maxlength=255 value=\"$filename_override\">$NWB#auto_reports-filename_override$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active>\n";
		echo "<option value=\"Y\">"._QXZ("YES")."</option>\n";
		echo "<option value=\"N\">"._QXZ("NO")."</option>\n";
		echo "<option value=\"$active\" SELECTED>"._QXZ("$active")."</option>\n";
		echo "</select>$NWB#auto_reports-active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Run Now Trigger").": </td><td align=left><select size=1 name=run_now_trigger>\n";
		echo "<option value=\"Y\">"._QXZ("YES")."</option>\n";
		echo "<option value=\"N\">"._QXZ("NO")."</option>\n";
		echo "<option value=\"$run_now_trigger\" SELECTED>"._QXZ("$run_now_trigger")."</option>\n";
		echo "</select>$NWB#auto_reports-run_now_trigger$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Report URL").": </td><td align=left><TEXTAREA NAME=report_url ROWS=25 COLS=75>$report_url</TEXTAREA> $NWB#auto_reports-report_url$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center>\n";

		echo "</center><BR><BR>\n";

		if ($LOGmodify_auto_reports > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=594111111111&report_id=$report_id\">"._QXZ("DELETE THIS AUTOMATED REPORT")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=AUTOREPORTS&stage=$report_id\">"._QXZ("Click here to see Admin changes to this automated report")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You are not authorized to view this page. Please go back.");
		}

	}


######################
# ADD=395111111111 modify IP Lists screen
######################
if ($ADD==395111111111)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ($LOGmodify_ip_lists==1)
		{
		$stmt = "SELECT count(*) FROM vicidial_ip_lists where ip_list_id='$ip_list_id';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$vig_exists = $row[0];

		if ($vig_exists > 0)
			{
			### read in all ip_addresses in this IP List
			$stmt = "SELECT ip_address FROM vicidial_ip_list_entries where ip_list_id='$ip_list_id' order by ip_address;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$vaf_ct = mysqli_num_rows($rslt);
			$vaf=0;
			while ($vaf_ct > $vaf)
				{
				$row=mysqli_fetch_row($rslt);
				$vaf_list[$vaf] = $row[0];
				$vaf_count[$vaf] = 0;
				$vaf++;
				}

			$stmt_log='';   $log_notes='';
			if (strlen($ip_address) > 2)
				{
				$PN = explode("\n",$ip_address);
				$PNct = count($PN);
				$p=0;   $ip_added=0;   $ip_removed=0;
				while ($p < $PNct)
					{
					if (strlen($PN[$p]) > 0)
						{
						$PN[$p] = preg_replace("/\r|\n|\t/",'',$PN[$p]);
						$ac_found=0;
						$vaf=0;
						while ($vaf_ct > $vaf)
							{
							if ($PN[$p] == $vaf_list[$vaf]) 
								{
								$vaf_count[$vaf]++;
								$ac_found++;
								}
							$vaf++;
							}
						if ($ac_found < 1)
							{
							$stmt="SELECT count(*) from vicidial_ip_list_entries where ip_address='$PN[$p]' and ip_list_id='$ip_list_id';";
							$rslt=mysql_to_mysqli($stmt, $link);
							$row=mysqli_fetch_row($rslt);
							if ($row[0] < 1)
								{
								$stmt="INSERT INTO vicidial_ip_list_entries (ip_address,ip_list_id) values('$PN[$p]','$ip_list_id');";
								$rslt=mysql_to_mysqli($stmt, $link);
								$stmt_log .= "$stmt|";
								$ip_added++;
								if ($DB > 0) {echo "Added ip_address $PN[$p]<br>\n";}
								}
							else
								{if ($DB > 0) {echo "Skipped add, already exists: $PN[$p]<br>\n";}}
							}
						}
					$p++;
					}

				$vaf=0;
				while ($vaf_ct > $vaf)
					{
					if ($vaf_count[$vaf] < 1)
						{
						$stmt="SELECT count(*) from vicidial_ip_list_entries where ip_address='$vaf_list[$vaf]' and ip_list_id='$ip_list_id';";
						$rslt=mysql_to_mysqli($stmt, $link);
						$row=mysqli_fetch_row($rslt);
						if ($row[0] > 0)
							{
							$stmt="DELETE FROM vicidial_ip_list_entries where ip_address='$vaf_list[$vaf]' and ip_list_id='$ip_list_id';";
							$rslt=mysql_to_mysqli($stmt, $link);
							$stmt_log .= "$stmt|";
							$ip_removed++;
							if ($DB > 0) {echo "Removed ip_address $vaf_list[$vaf]<br>\n";}
							}
						else
							{if ($DB > 0) {echo "Skipped delete, already removed: $vaf_list[$vaf]<br>\n";}}
						}
					$vaf++;
					}
				$log_notes .= "$ip_added IPs Added|$ip_removed IPs Removed|";
				}

			if ( (strlen($ip_list_name) > 2) and (strlen($active) > 0) )
				{
				$stmt="UPDATE vicidial_ip_lists set ip_list_name='$ip_list_name',active='$active',user_group='$user_group' where ip_list_id='$ip_list_id' $LOGadmin_viewable_groupsSQL;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$stmt_log .= "$stmt|";
				$ILaffected_rows = mysqli_affected_rows($link);
				if ($ILaffected_rows > 0)
					{$log_notes .= "main entry edited|";}
				}
			else
				{
				$stmt="SELECT ip_list_id,ip_list_name,active,user_group from vicidial_ip_lists where ip_list_id='$ip_list_id' $LOGadmin_viewable_groupsSQL;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$row=mysqli_fetch_row($rslt);
				$ip_list_id =			$row[0];
				$ip_list_name =			$row[1];
				$active =				$row[2];
				$user_group =			$row[3];
				}

			if (strlen($stmt_log) > 10)
				{
				echo "<br>"._QXZ("IP LIST MODIFIED").": $ip_list_id\n";

				### LOG INSERTION Admin Log Table ###
				$SQL_log = "$stmt_log|";
				$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='IPLISTS', event_type='MODIFY', record_id='$ip_list_id', event_code='ADMIN MODIFY IP LIST', event_sql=\"$SQL_log\", event_notes='$log_notes';";
				if ($DB) {echo "|$stmt|\n";}
				$rslt=mysql_to_mysqli($stmt, $link);
				}

			### read in all ip_addresses in this IP List
			$stmt = "SELECT ip_address FROM vicidial_ip_list_entries where ip_list_id='$ip_list_id' order by ip_address;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$vaf_ct = mysqli_num_rows($rslt);
			$vaf=0;   $vaf_textarea='';
			while ($vaf_ct > $vaf)
				{
				$row=mysqli_fetch_row($rslt);
				$vaf_textarea .= "$row[0]\n";
				$vaf++;
				}

			echo "<br>"._QXZ("MODIFY IP LIST")."<form action=$PHP_SELF method=POST>\n";
			echo "<input type=hidden name=ADD value=395111111111>\n";
			echo "<input type=hidden name=ip_list_id value=\"$ip_list_id\">\n";
			echo "<input type=hidden name=DB value=\"$DB\">\n";
			echo "<center><TABLE width=800 cellspacing=3>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("IP List").": </td><td align=left><b>$ip_list_id</b></td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("IP List Name").": </td><td align=left><input type=text name=ip_list_name size=60 maxlength=100 value=\"$ip_list_name\"> $NWB#ip_lists-ip_list_name$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Active").": </td><td align=left><select size=1 name=active>\n";
			echo "<option value=\"Y\">"._QXZ("YES")."</option>\n";
			echo "<option value=\"N\">"._QXZ("NO")."</option>\n";
			echo "<option value=\"$active\" SELECTED>"._QXZ("$active")."</option>\n";
			echo "</select>$NWB#ip_lists-active$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
			echo "$UUgroups_list";
			echo "<option SELECTED value=\"$user_group\">".(preg_match('/\-\-ALL\-\-/', $user_group) ? _QXZ("$user_group") : $user_group)."</option>\n";
			echo "</select>$NWB#ip_lists-user_group$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("IP Addresses").": <BR><BR> ("._QXZ("one ip address per line only").")<BR>$NWB#ip_lists-ip_address$NWE</td><td align=left><TEXTAREA name=ip_address ROWS=20 COLS=45>$vaf_textarea</TEXTAREA></td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
			echo "</FORM></TABLE></center><BR>\n";

			echo "<B>"._QXZ("USER GROUPS USING THIS IP LIST").":</B><BR>\n";
			echo "<TABLE>\n";
			$stmt="SELECT distinct user_group,group_name from vicidial_user_groups where ( (admin_ip_list='$ip_list_id') or (agent_ip_list='$ip_list_id') or (api_ip_list='$ip_list_id') ) $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$ugs_to_print = mysqli_num_rows($rslt);
			$o=0;
			while ($ugs_to_print > $o) 
				{
				$row=mysqli_fetch_row($rslt);
				echo "<TR><TD><a href=\"$PHP_SELF?ADD=311111&user_group=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
				$o++;
				}
			echo "</TABLE><BR>\n";

			}
		else
			{
			echo _QXZ("You must use a valid IP List")."\n";
			exit;
			}

		if ($LOGmodify_ip_lists > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=595111111111&ip_list_id=$ip_list_id\">"._QXZ("DELETE THIS IP LIST")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=IPLISTS&stage=$ip_list_id\">"._QXZ("Click here to see Admin changes to this IP List")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}




######################
# ADD=396111111111 modify CID group in the system
######################
if ($ADD==396111111111)
	{
	if ( ($LOGast_admin_access==1) and ($LOGmodify_statuses==1) )
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=396111111111&cid_group_id=$cid_group_id";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$not_allowed_campaigns_ct=0;
		$stmt="SELECT count(*) from vicidial_campaigns where ( (cid_group_id='$cid_group_id') or (cid_group_id_two='$cid_group_id') ) $notLOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$accidsX_to_print = mysqli_num_rows($rslt);
		if ($accidsX_to_print > 0) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$not_allowed_campaigns_ct = $rowx[0];
			}

		if ($not_allowed_campaigns_ct > 0)
			{
			echo "<br>"._QXZ("CID GROUP NOT AVAILABLE - this CID Group is assigned to a campaign you are not allowed to view")."<br>\n";
			exit;
			}

		$stmt="SELECT cid_group_notes,cid_group_type,user_group,cid_auto_rotate_minutes,cid_auto_rotate_minimum,cid_auto_rotate_calls,cid_last_auto_rotate,cid_auto_rotate_cid from vicidial_cid_groups where cid_group_id='$cid_group_id' $LOGadmin_viewable_groupsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$cid_group_notes =			$row[0];
		$cid_group_type =			$row[1];
		$user_group =				$row[2];
		$cid_auto_rotate_minutes =	$row[3];
		$cid_auto_rotate_minimum =	$row[4];
		$cid_auto_rotate_calls =	$row[5];
		$cid_last_auto_rotate =		$row[6];
		$cid_auto_rotate_cid =		$row[7];

		echo "<br>"._QXZ("MODIFY CID GROUP").": $cid_group_id<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=496111111111>\n";
		echo "<input type=hidden name=cid_group_id value=\"$cid_group_id\">\n";

		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("CID Group ID").": </td><td align=left><B>$cid_group_id</B></td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("CID Group Notes").": </td><td align=left><input type=text name=cid_group_notes size=50 maxlength=255 value=\"$cid_group_notes\">$NWB#cid_groups$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("CID Group Type").": </td><td align=left><B>"._QXZ("$cid_group_type")."</B>$NWB#cid_groups$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Group").": </td><td align=left><select size=1 name=user_group>\n";
		echo "$UUgroups_list";
		echo "<option SELECTED value=\"$user_group\">".(preg_match('/\-\-ALL\-\-/', $user_group) ? _QXZ("$user_group") : $user_group)."</option>\n";
		echo "</select>$NWB#cid_groups$NWE</td></tr>\n";

		if ($cid_group_type == 'NONE')
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("CID Auto Rotate Minutes").": </td><td align=left><input type=text name=cid_auto_rotate_minutes size=8 maxlength=7 value=\"$cid_auto_rotate_minutes\">$NWB#cid_groups-cid_auto_rotate_minutes$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("CID Auto Rotate Minimum").": </td><td align=left><input type=text name=cid_auto_rotate_minimum size=8 maxlength=7 value=\"$cid_auto_rotate_minimum\">$NWB#cid_groups-cid_auto_rotate_minimum$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("CID Auto Rotate Calls, CID and Time").": </td><td align=left><B>$cid_auto_rotate_calls - $cid_auto_rotate_cid - $cid_last_auto_rotate </B>$NWB#cid_groups-cid_auto_rotate_calls$NWE\n";
			if (strlen($cid_auto_rotate_cid) > 5)
				{
				echo "<font size=1> <BR> &nbsp; <a href=\"$PHP_SELF?ADD=496111111111&stage=SKIP&cid_group_id=$cid_group_id&outbound_cid=$cid_auto_rotate_cid\">"._QXZ("Skip and NOROTATE current CID")."</a></font>\n";
				}
			echo "</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right><input type=hidden name=cid_auto_rotate_minutes value=\"$cid_auto_rotate_minutes\">\n";
			echo "<input type=hidden name=cid_auto_rotate_minimum value=\"$cid_auto_rotate_minimum\"></td></tr>\n";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center></form>\n";

		echo "<center><b>\n";

		$checkbox_list='';
		$checkbox_count=0;
		echo "<br><br><b>"._QXZ("CIDS FOR THIS CID GROUP").": &nbsp; $NWB#cid_groups$NWE</b><br>\n";
		echo "<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=496111111111>\n";
		echo "<input type=hidden name=stage value=MODIFY>\n";
		echo "<input type=hidden name=DB value=\"$DB\">\n";
		echo "<input type=hidden name=cid_group_id value=\"$cid_group_id\">\n";
		echo "<center><TABLE width=700 cellspacing=2>\n";

		$stmt="SELECT areacode,outbound_cid,active,cid_description,call_count_today from vicidial_campaign_cid_areacodes where campaign_id='$cid_group_id' order by areacode,outbound_cid;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$accids_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($accids_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$Xareacode[$o] =			$rowx[0];
			$Xoutbound_cid[$o] =		$rowx[1];
			$Xactive[$o] =				$rowx[2];
			$Xcid_description[$o] =		$rowx[3];
			$Xcall_count_today[$o] =	$rowx[4];
			$checkbox_list .= "|active_$Xareacode[$o]_$Xoutbound_cid[$o]";
			$o++;
			$checkbox_count++;
			}

		echo "<tr><td>#</td><td>"._QXZ("$cid_group_type")."</td><td>"._QXZ("CID NUMBER")."</td><td>"._QXZ("DESCRIPTION")."</td><td>"._QXZ("ACTIVE")."<br><span id=ACCID_link><a href=\"#\" onclick=\"FORM_selectall('$checkbox_count','$checkbox_list','on','ACCID_link');return false;\"><font size=1>"._QXZ("select all")."</font></a></span></td><td>"._QXZ("CALLS")."</td><td>"._QXZ("DELETE")."</td></tr>\n";

		$o=0;
		while ($accids_to_print > $o) 
			{
			$ct = ($o + 1);
			if ($ct == '1')
				{
				$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';
				$bgac = $Xareacode[$o];
				} 
			else
				{
				if ($Xareacode[$o] != $bgac)
					{
					if (preg_match("/1$|3$|5$|7$|9$/i", $bgct))
						{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';} 
					else
						{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';}
					$bgct++;
					$bgac = $Xareacode[$o];
					}
				}

			$DID_edit_link_BEGIN='';
			$DID_edit_link_END='';
			if (strlen($Xoutbound_cid[$o]) > 0)
				{
				$stmt="SELECT did_id from vicidial_inbound_dids where did_pattern='$Xoutbound_cid[$o]' $LOGadmin_viewable_groupsSQL limit 1;";
				$rslt=mysql_to_mysqli($stmt, $link);
				$dids_to_print = mysqli_num_rows($rslt);
				if ($dids_to_print > 0) 
					{
					$rowx=mysqli_fetch_row($rslt);
					$DID_edit_link_BEGIN = "<a href=\"$PHP_SELF?ADD=3311&did_id=$rowx[0]\">";
					$DID_edit_link_END='</a>';
					}
				}
			echo "<tr $bgcolor><td><font size=2> &nbsp; $ct</font></td>\n";
			echo "<td><font size=2> &nbsp; $Xareacode[$o]</font></td>\n";
			echo "<td><font size=2> &nbsp; $DID_edit_link_BEGIN$Xoutbound_cid[$o]$DID_edit_link_END</font></td>\n";
			echo "<td><input type=text size=30 maxlength=100 name=cid_description_$Xareacode[$o]_$Xoutbound_cid[$o] value=\"$Xcid_description[$o]\" style=\"font-family: sans-serif; font-size: 10px;\"></td>\n";
			echo "<td>\n";
			if ($Xactive[$o] == 'Y')
				{
				echo "<input type=\"checkbox\" name=\"active_$Xareacode[$o]_$Xoutbound_cid[$o]\" id=\"active_$Xareacode[$o]_$Xoutbound_cid[$o]\" value=\"Y\" CHECKED>";
				}
			else
				{
				echo "<input type=\"checkbox\" name=\"active_$Xareacode[$o]_$Xoutbound_cid[$o]\" id=\"active_$Xareacode[$o]_$Xoutbound_cid[$o]\" value=\"Y\">";
				}
			echo "</td>\n";
			echo "<td><font size=2> &nbsp; $Xcall_count_today[$o]</font></td>\n";
			echo "<td><font size=1> &nbsp; <a href=\"$PHP_SELF?ADD=496111111111&stage=DELETE&cid_group_id=$cid_group_id&areacode=$Xareacode[$o]&outbound_cid=$Xoutbound_cid[$o]\">"._QXZ("DELETE")."</a></td></tr>\n";
			$o++;
			}

		echo "</table>\n";
		echo "<input style='background-color:#$SSbutton_color' type=submit name=submit value=\""._QXZ("SUBMIT CHANGES")."\"></form><br><br>\n";

		echo "<br>"._QXZ("ADD NEW $cid_group_type CID")."<BR><form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=496111111111>\n";
		echo "<input type=hidden name=stage value=ADD>\n";
		echo "<input type=hidden name=DB value=\"$DB\">\n";
		echo "<input type=hidden name=cid_group_id value=\"$cid_group_id\">\n";
		if ($cid_group_type == 'NONE')
			{echo "<input type=hidden name=areacode value=\"NONE\">\n";}
		else
			{echo _QXZ("$cid_group_type").": <input type=text size=7 maxlength=5 name=areacode>\n";}
		echo _QXZ("Outbound CID").": <input type=text size=20 maxlength=20 name=outbound_cid><BR>\n";
		echo _QXZ("Description").": <input type=text size=50 maxlength=100 name=cid_description>\n";
		echo "<input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("ADD")."'><BR>\n";

		echo "</center></FORM><br></center>\n";

		echo "<B>"._QXZ("CAMPAIGNS USING THIS CID GROUP").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where ( (cid_group_id='$cid_group_id') or (cid_group_id_two='$cid_group_id') ) $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$camps_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($camps_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=31&campaign_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE><BR><BR>\n";

		echo "<B>"._QXZ("LISTS USING THIS CID GROUP").":</B><BR>\n";
		echo "<TABLE>\n";

		$stmt="SELECT list_id,list_name from vicidial_lists where cid_group_id='$cid_group_id' $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$lists_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($lists_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			echo "<TR><TD><a href=\"$PHP_SELF?ADD=311&list_id=$row[0]\">$row[0] </a></TD><TD> $row[1]<BR></TD></TR>\n";
			$o++;
			}

		echo "</TABLE><BR><center>\n";

		if (($LOGast_admin_access==1) and ($LOGmodify_statuses==1))
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=596111111111&cid_group_id=$cid_group_id\">"._QXZ("DELETE THIS CID GROUP")."</a>\n";
			}
		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=CIDGROUPS&stage=$cid_group_id\">"._QXZ("Click here to see Admin changes to this CID GROUP")."\n";

			echo "<br><br><a href=\"list_download.php?group_id=$cid_group_id&download_type=cidgroup\">"._QXZ("Click here to download this CID GROUP")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}



######################
# ADD=3111111111111 modify conference record in the system
######################
if ($ADD==3111111111111)
	{
	if ($LOGast_admin_access==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=3111111111111&conf_exten=$conf_exten&server_ip=$server_ip";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT conf_exten,server_ip,extension from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$conf_exten = $row[0];
		$server_ip = $row[1];

		echo "<br>"._QXZ("MODIFY A CONFERENCE RECORD").": $row[0]<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=4111111111111>\n";
		echo "<input type=hidden name=old_conf_exten value=\"$row[0]\">\n";
		echo "<input type=hidden name=old_server_ip value=\"$row[1]\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Conference").": </td><td align=left><input type=text name=conf_exten size=10 maxlength=7 value=\"$row[0]\">$NWB#conferences-conf_exten$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=311111111111&server_ip=$row[1]\">"._QXZ("Server IP")."</a>: </td><td align=left><select size=1 name=server_ip>\n";

		echo "$servers_list";
		echo "<option SELECTED>$row[1]</option>\n";
		echo "</select>$NWB#conferences-server_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Current Extension").": </td><td align=left><input type=text name=extension size=20 maxlength=20 value=\"$row[2]\"></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";

		echo "<center><b>\n";
		if ($LOGast_delete_phones > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=5111111111111&conf_exten=$conf_exten&server_ip=$server_ip\">"._QXZ("DELETE THIS CONFERENCE")."</a>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=31111111111111 modify vicidial conference record in the system
######################
if ($ADD==31111111111111)
	{
	if ($LOGast_admin_access==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=31111111111111&conf_exten=$conf_exten&server_ip=$server_ip";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT conf_exten,server_ip,extension,leave_3way,leave_3way_datetime from vicidial_conferences where conf_exten='$conf_exten' and server_ip='$server_ip';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$conf_exten = $row[0];
		$server_ip = $row[1];

		echo "<br>"._QXZ("MODIFY AN AGENT CONFERENCE RECORD").": $row[0]<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=41111111111111>\n";
		echo "<input type=hidden name=old_conf_exten value=\"$row[0]\">\n";
		echo "<input type=hidden name=old_server_ip value=\"$row[1]\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Conference").": </td><td align=left><input type=text name=conf_exten size=10 maxlength=7 value=\"$row[0]\">$NWB#conferences-conf_exten$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=311111111111&server_ip=$row[1]\">"._QXZ("Server IP")."</a>: </td><td align=left><select size=1 name=server_ip>\n";

		echo "$servers_list";
		echo "<option SELECTED>$row[1]</option>\n";
		echo "</select>$NWB#conferences-server_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Current Extension").": </td><td align=left><input type=text name=extension size=20 maxlength=20 value=\"$row[2]\"></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";

		echo "<center><b>\n";
		if ($LOGast_delete_phones > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=51111111111111&conf_exten=$conf_exten&server_ip=$server_ip\">"._QXZ("DELETE THIS AGENT CONFERENCE")."</a>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=32111111111111 modify vicidial ConfBridge record in the system
######################
if ($ADD==32111111111111)
	{
	if ($LOGast_admin_access==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=32111111111111&conf_exten=$conf_exten&server_ip=$server_ip";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT conf_exten,server_ip,extension,leave_3way,leave_3way_datetime from vicidial_confbridges where conf_exten='$conf_exten' and server_ip='$server_ip';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$conf_exten = $row[0];
		$server_ip = $row[1];

		echo "<br>"._QXZ("MODIFY AN AGENT CONFBRIDGE RECORD").": $row[0]<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=42111111111111>\n";
		echo "<input type=hidden name=old_conf_exten value=\"$row[0]\">\n";
		echo "<input type=hidden name=old_server_ip value=\"$row[1]\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("ConfBridge").": </td><td align=left><input type=text name=conf_exten size=10 maxlength=7 value=\"$row[0]\">$NWB#conferences-conf_exten$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=311111111111&server_ip=$row[1]\">"._QXZ("Server IP")."</a>: </td><td align=left><select size=1 name=server_ip>\n";

		echo "$servers_list";
		echo "<option SELECTED>$row[1]</option>\n";
		echo "</select>$NWB#conferences-server_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Current Extension").": </td><td align=left><input type=text name=extension size=20 maxlength=20 value=\"$row[2]\"></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";

		echo "<center><b>\n";
		if ($LOGast_delete_phones > 0)
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=52111111111111&conf_exten=$conf_exten&server_ip=$server_ip\">"._QXZ("DELETE THIS AGENT CONFBRIDGE")."</a>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=311111111111111 modify vicidial system settings
######################
if ($ADD==311111111111111)
	{
	if ($LOGmodify_servers==1)
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=311111111111111";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_settings.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT count(*) from vicidial_phone_codes;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$vicidial_phone_codes_count =	$row[0];

		$stmt="SELECT count(*) from vicidial_postal_codes;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$vicidial_postal_codes_count =	$row[0];

		$stmt="SELECT count(*) from vicidial_postal_codes_cities;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$vicidial_postal_codes_cities_count =	$row[0];

		$stmt="SELECT count(*) from vicidial_nanpa_prefix_codes;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$vicidial_nanpa_prefix_codes_count =	$row[0];

		$stmt="SELECT count(*) from nanpa_prefix_exchanges_master;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$nanpa_prefix_exchanges_master_count =	$row[0];

		$stmt="SELECT count(*) from nanpa_prefix_exchanges_fast;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$nanpa_prefix_exchanges_fast_count =	$row[0];

		$stmt="SELECT count(*) from nanpa_wired_to_wireless;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$nanpa_wired_to_wireless_count =	$row[0];

		$stmt="SELECT count(*) from nanpa_wireless_to_wired;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$nanpa_wireless_to_wired_count =	$row[0];

		$stmt="SELECT sum(total_calls) from vicidial_daily_max_stats where stats_flag='OPEN' and stats_type!='TOTAL';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$stats_to_print = mysqli_num_rows($rslt);
		if ($stats_to_print > 0) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$ALLtotal_calls = $rowx[0];
			}

		$stmt="SELECT max(max_inbound) from vicidial_daily_max_stats where stats_flag='OPEN' and stats_type='INGROUP';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$stats_to_print = mysqli_num_rows($rslt);
		if ($stats_to_print > 0) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$ALLmax_inbound = $rowx[0];
			}

		$stmt="SELECT max(max_outbound) from vicidial_daily_max_stats where stats_flag='OPEN' and stats_type='CAMPAIGN';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$stats_to_print = mysqli_num_rows($rslt);
		if ($stats_to_print > 0) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$ALLmax_outbound = $rowx[0];
			}

		$stmt="SELECT max_channels,max_calls,max_agents from vicidial_daily_max_stats where stats_flag='OPEN' and stats_type='TOTAL';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$stats_to_print = mysqli_num_rows($rslt);
		if ($stats_to_print > 0) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$ALLchannels_count =	$rowx[0];
			$ALLcalls_count =		$rowx[1];
			$ALLagent_count =		$rowx[2];
			}

		$stmt="SELECT version,install_date,use_non_latin,webroot_writable,enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_url,queuemetrics_log_id,queuemetrics_eq_prepend,vicidial_agent_disable,allow_sipsak_messages,admin_home_url,enable_agc_xfer_log,db_schema_version,auto_user_add_value,timeclock_end_of_day,timeclock_last_reset_date,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,vdc_agent_api_active,qc_last_pull_time,enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url,qc_features_active,outbound_autodial_active,outbound_calls_per_second,enable_tts_integration,agentonly_callback_campaign_lock,sounds_central_control_active,sounds_web_server,sounds_web_directory,active_voicemail_server,auto_dial_limit,user_territories_active,allow_custom_dialplan,db_schema_update_date,enable_second_webform,default_webphone,default_external_server_ip,webphone_url,enable_agc_dispo_log,custom_dialplan_entry,queuemetrics_loginout,callcard_enabled,queuemetrics_callstatus,default_codecs,admin_web_directory,label_title,label_first_name,label_middle_initial,label_last_name,label_address1,label_address2,label_address3,label_city,label_state,label_province,label_postal_code,label_vendor_lead_code,label_gender,label_phone_number,label_phone_code,label_alt_phone,label_security_phrase,label_email,label_comments,custom_fields_enabled,slave_db_server,reports_use_slave_db,webphone_systemkey,first_login_trigger,default_phone_registration_password,default_phone_login_password,default_server_password,admin_modify_refresh,nocache_admin,generate_cross_server_exten,queuemetrics_addmember_enabled,queuemetrics_dispo_pause,label_hide_field_logs,queuemetrics_pe_phone_append,test_campaign_calls,agents_calls_reset,default_voicemail_timezone,default_local_gmt,noanswer_log,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,did_agent_log,campaign_cid_areacodes_enabled,pllb_grouping_limit,did_ra_extensions_enabled,expanded_list_stats,contacts_enabled,call_menu_qualify_enabled,admin_list_counts,allow_voicemail_greeting,svn_revision,queuemetrics_socket,queuemetrics_socket_url,enhanced_disconnect_logging,allow_emails,level_8_disable_add,pass_hash_enabled,pass_key,pass_cost,disable_auto_dial,queuemetrics_record_hold,country_code_list_stats,reload_timestamp,queuemetrics_pause_type,frozen_server_call_clear,callback_time_24hour,allow_chats,chat_url,chat_timeout,enable_languages,language_method,meetme_enter_login_filename,meetme_enter_leave3way_filename,enable_did_entry_list_id,enable_third_webform,agent_debug_logging,default_language,agent_whisper_enabled,user_hide_realtime_enabled,usacan_phone_dialcode_fix,cache_carrier_stats_realtime,oldest_logs_date,log_recording_access,report_default_format,alt_ivr_logging,default_phone_code,admin_row_click,admin_screen_colors,ofcom_uk_drop_calc,agent_screen_colors,script_remove_js,manual_auto_next,user_new_lead_limit,agent_xfer_park_3way,rec_prompt_count,agent_soundboards,web_loader_phone_length,agent_script,agent_chat_screen_colors,enable_auto_reports,enable_pause_code_limits,enable_drop_lists,allow_ip_lists,system_ip_blacklist,agent_push_events,agent_push_url,hide_inactive_lists,allow_manage_active_lists,expired_lists_inactive,did_system_filter,anyone_callback_inactive_lists,enable_gdpr_download_deletion,source_id_display,agent_logout_link,manual_dial_validation,mute_recordings,user_admin_redirect,list_status_modification_confirmation,sip_event_logging,call_quota_lead_ranking,enable_second_script,enable_first_webform,recording_buttons,opensips_cid_name,require_password_length,user_account_emails,outbound_cid_any,entries_per_page,browser_call_alerts,queuemetrics_pausereason,inbound_answer_config,enable_international_dncs,web_loader_phone_strip,manual_dial_phone_strip,daily_call_count_limit,allow_shared_dial,agent_search_method,phone_defaults_container,qc_claim_limit,qc_expire_days,two_factor_auth_hours,two_factor_container,agent_hidden_sound,agent_hidden_sound_volume,agent_hidden_sound_seconds,agent_screen_timer,label_lead_id,label_list_id,label_entry_date,label_gmt_offset_now,label_source_id,label_called_since_last_reset,label_status,label_user,label_date_of_birth,label_country_code,label_last_local_call_time,label_called_count,label_rank,label_owner,label_entry_list_id,call_limit_24hour,allowed_sip_stacks,agent_hide_hangup,allow_web_debug,max_logged_in_agents,user_codes_admin,login_kickall,abandon_check_queue,agent_notifications,demographic_quotas,log_latency_gaps,inbound_credits,weekday_resets,two_factor_auth_agent_hours,highest_lead_id,hopper_hold_inserts,coldstorage_server_ip,coldstorage_dbname,coldstorage_login,coldstorage_pass,coldstorage_port,enhanced_agent_monitoring,agent_hide_dial_fail,agent_man_dial_filter,agent_3way_dial_filter,stereo_recording,recording_dtmf_detection,recording_dtmf_muting,stereo_parallel_recording from system_settings;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$version =						$row[0];
		$install_date =					$row[1];
		$use_non_latin =				$row[2];
		$webroot_writable =				$row[3];
		$enable_queuemetrics_logging =	$row[4];
		$queuemetrics_server_ip =		$row[5];
		$queuemetrics_dbname =			$row[6];
		$queuemetrics_login =			$row[7];
		$queuemetrics_pass =			$row[8];
		$queuemetrics_url =				$row[9];
		$queuemetrics_log_id =			$row[10];
		$queuemetrics_eq_prepend =		$row[11];
		$vicidial_agent_disable =		$row[12];
		$allow_sipsak_messages =		$row[13];
		$admin_home_url =				$row[14];
		$enable_agc_xfer_log =			$row[15];
		$db_schema_version =			$row[16];
		$auto_user_add_value =			$row[17];
		$timeclock_end_of_day =			$row[18];
		$timeclock_last_reset_date =	$row[19];
		$vdc_header_date_format =		$row[20];
		$vdc_customer_date_format =		$row[21];
		$vdc_header_phone_format =		$row[22];
		$vdc_agent_api_active =			$row[23];
		$qc_last_pull_time = 			$row[24];
		$enable_vtiger_integration = 	$row[25];
		$vtiger_server_ip = 			$row[26];
		$vtiger_dbname = 				$row[27];
		$vtiger_login = 				$row[28];
		$vtiger_pass = 					$row[29];
		$vtiger_url = 					$row[30];
		$qc_features_active =			$row[31];
		$outbound_autodial_active =		$row[32];
		$outbound_calls_per_second =	$row[33];
		$enable_tts_integration =		$row[34];
		$agentonly_callback_campaign_lock = $row[35];
		$sounds_central_control_active = $row[36];
		$sounds_web_server =			$row[37];
		$sounds_web_directory =			$row[38];
		$active_voicemail_server =		$row[39];
		$auto_dial_limit =				$row[40];
		$user_territories_active =		$row[41];
		$allow_custom_dialplan =		$row[42];
		$db_schema_update_date =		$row[43];
		$enable_second_webform =		$row[44];
		$default_webphone =				$row[45];
		$default_external_server_ip =	$row[46];
		$webphone_url =					$row[47];
		$enable_agc_dispo_log =			$row[48];
		$custom_dialplan_entry =		$row[49];
		$queuemetrics_loginout =		$row[50];
		$callcard_enabled =				$row[51];
		$queuemetrics_callstatus =		$row[52];
		$default_codecs =				$row[53];
		$admin_web_directory =			$row[54];
		$label_title =					$row[55];
		$label_first_name =				$row[56];
		$label_middle_initial =			$row[57];
		$label_last_name =				$row[58];
		$label_address1 =				$row[59];
		$label_address2 =				$row[60];
		$label_address3 =				$row[61];
		$label_city =					$row[62];
		$label_state =					$row[63];
		$label_province =				$row[64];
		$label_postal_code =			$row[65];
		$label_vendor_lead_code =		$row[66];
		$label_gender =					$row[67];
		$label_phone_number =			$row[68];
		$label_phone_code =				$row[69];
		$label_alt_phone =				$row[70];
		$label_security_phrase =		$row[71];
		$label_email =					$row[72];
		$label_comments =				$row[73];
		$custom_fields_enabled =		$row[74];
		$slave_db_server =				$row[75];
		$reports_use_slave_db =			$row[76];
		$webphone_systemkey =			$row[77];
		$first_login_trigger =			$row[78];
		$default_phone_registration_password =	$row[79];
		$default_phone_login_password =	$row[80];
		$default_server_password =		$row[81];
		$admin_modify_refresh =			$row[82];
		$nocache_admin =				$row[83];
		$generate_cross_server_exten =	$row[84];
		$queuemetrics_addmember_enabled =	$row[85];
		$queuemetrics_dispo_pause =		$row[86];
		$label_hide_field_logs = 		$row[87];
		$queuemetrics_pe_phone_append = $row[88];
		$test_campaign_calls =			$row[89];
		$agents_calls_reset =			$row[90];
		$default_voicemail_timezone =	$row[91];
		$default_local_gmt =			$row[92];
		$noanswer_log =					$row[93];
		$alt_log_server_ip =			$row[94];
		$alt_log_dbname =				$row[95];
		$alt_log_login =				$row[96];
		$alt_log_pass =					$row[97];
		$tables_use_alt_log_db =		$row[98];
		$did_agent_log =				$row[99];
		$campaign_cid_areacodes_enabled = $row[100];
		$pllb_grouping_limit =			$row[101];
		$did_ra_extensions_enabled =	$row[102];
		$expanded_list_stats =			$row[103];
		$contacts_enabled =				$row[104];
		$call_menu_qualify_enabled =	$row[105];
		$admin_list_counts =			$row[106];
		$allow_voicemail_greeting =		$row[107];
		$svn_revision =					$row[108];
		$queuemetrics_socket =			$row[109];
		$queuemetrics_socket_url =		$row[110];
		$enhanced_disconnect_logging =	$row[111];
		$allow_emails =					$row[112];
		$level_8_disable_add =			$row[113];
		$pass_hash_enabled =			$row[114];
		$pass_key =						$row[115];
		$pass_cost =					$row[116];
		$disable_auto_dial =			$row[117];
		$queuemetrics_record_hold =		$row[118];
		$country_code_list_stats =		$row[119];
		$reload_timestamp =				$row[120];
		$queuemetrics_pause_type =		$row[121];
		$frozen_server_call_clear =		$row[122];
		$callback_time_24hour =			$row[123];
		$allow_chats =					$row[124];
		$chat_url =						$row[125];
		$chat_timeout =					$row[126];
		$enable_languages =				$row[127];
		$language_method =				$row[128];
		$meetme_enter_login_filename =	$row[129];
		$meetme_enter_leave3way_filename =	$row[130];
		$enable_did_entry_list_id =		$row[131];
		$enable_third_webform =			$row[132];
		$agent_debug_logging =			$row[133];
		$default_language =				$row[134];
		$agent_whisper_enabled =		$row[135];
		$user_hide_realtime_enabled =	$row[136];
		$usacan_phone_dialcode_fix =	$row[137];
		$cache_carrier_stats_realtime = $row[138];
		$oldest_logs_date =				$row[139];
		$log_recording_access =			$row[140];
		$report_default_format =		$row[141];
		$alt_ivr_logging =				$row[142];
		$default_phone_code =			$row[143];
		$admin_row_click =				$row[144];
		$admin_screen_colors =			$row[145];
		$ofcom_uk_drop_calc =			$row[146];
		$agent_screen_colors =			$row[147];
		$script_remove_js =				$row[148];
		$manual_auto_next =				$row[149];
		$user_new_lead_limit =			$row[150];
		$agent_xfer_park_3way =			$row[151];
		$rec_prompt_count =				$row[152];
		$agent_soundboards =			$row[153];
		$web_loader_phone_length =		$row[154];
		$agent_script =					$row[155];
		$agent_chat_screen_colors =		$row[156];
		$enable_auto_reports =			$row[157];
		$enable_pause_code_limits =		$row[158];
		$enable_drop_lists =			$row[159];
		$allow_ip_lists =				$row[160];
		$system_ip_blacklist =			$row[161];
		$agent_push_events =			$row[162];
		$agent_push_url =				$row[163];
		$hide_inactive_lists =			$row[164];
		$allow_manage_active_lists =	$row[165];
		$expired_lists_inactive =		$row[166];
		$did_system_filter =			$row[167];
		$anyone_callback_inactive_lists = $row[168];
		$enable_gdpr_download_deletion = $row[169];
		$source_id_display =			$row[170];
		$agent_logout_link =			$row[171];
		$manual_dial_validation =		$row[172];
		$mute_recordings =				$row[173];
		$user_admin_redirect =			$row[174];
		$list_status_modification_confirmation = $row[175];
		$sip_event_logging =			$row[176];
		$call_quota_lead_ranking =		$row[177];
		$enable_second_script =			$row[178];
		$enable_first_webform =			$row[179];
		$recording_buttons =			$row[180];
		$opensips_cid_name =			$row[181];
		$require_password_length =		$row[182];
		$user_account_emails =			$row[183];
		$outbound_cid_any =				$row[184];
		$entries_per_page =				$row[185];
		$browser_call_alerts =			$row[186];
		$queuemetrics_pausereason =		$row[187];
		$inbound_answer_config =		$row[188];
		$enable_international_dncs =	$row[189];
		$web_loader_phone_strip =		$row[190];
		$manual_dial_phone_strip =		$row[191];
		$daily_call_count_limit =		$row[192];
		$allow_shared_dial =			$row[193];
		$agent_search_method =			$row[194];
		$phone_defaults_container =		$row[195];
		$qc_claim_limit =				$row[196];
		$qc_expire_days =				$row[197];
		$two_factor_auth_hours =		$row[198];
		$two_factor_container =			$row[199];
		$agent_hidden_sound =			$row[200];
		$agent_hidden_sound_volume =	$row[201];
		$agent_hidden_sound_seconds =	$row[202];
		$agent_screen_timer =			$row[203];
		$label_lead_id =				$row[204];
		$label_list_id =				$row[205];
		$label_entry_date =				$row[206];
		$label_gmt_offset_now =			$row[207];
		$label_source_id =				$row[208];
		$label_called_since_last_reset = $row[209];
		$label_status =					$row[210];
		$label_user =					$row[211];
		$label_date_of_birth =			$row[212];
		$label_country_code =			$row[213];
		$label_last_local_call_time =	$row[214];
		$label_called_count =			$row[215];
		$label_rank =					$row[216];
		$label_owner =					$row[217];
		$label_entry_list_id =			$row[218];
		$call_limit_24hour =			$row[219];
		$allowed_sip_stacks =			$row[220];
		$agent_hide_hangup =			$row[221];
		$allow_web_debug =				$row[222];
		$max_logged_in_agents =			$row[223];
		$user_codes_admin =				$row[224];
		$login_kickall =				$row[225];
		$abandon_check_queue =			$row[226];
		$agent_notifications =			$row[227];
		$demographic_quotas =			$row[228];
		$log_latency_gaps =				$row[229];
		$inbound_credits =				$row[230];
		$weekday_resets =				$row[231];
		$two_factor_auth_agent_hours =	$row[232];
		$highest_lead_id =				$row[233];
		$hopper_hold_inserts =			$row[234];
		$coldstorage_server_ip =		$row[235];
		$coldstorage_dbname =			$row[236];
		$coldstorage_login =			$row[237];
		$coldstorage_pass =				$row[238];
		$coldstorage_port =				$row[239];
		$enhanced_agent_monitoring =	$row[240];
		$agent_hide_dial_fail =			$row[241];
		$agent_man_dial_filter =		$row[242];
		$agent_3way_dial_filter =		$row[243];
		$stereo_recording =				$row[244];
		$recording_dtmf_detection =		$row[245];
		$recording_dtmf_muting =		$row[246];
		$stereo_parallel_recording =	$row[247];

		if ($pass_hash_enabled > 0) {$pass_hash_enabled = 'ENABLED';}
		else {$pass_hash_enabled = 'DISABLED';}
		if (strlen($pass_key) > 12) {$pass_key = 'S1';}
		else {$pass_key = 'S0';}
		if ($pass_cost > 0) {$pass_cost = 'C1';}
		else {$pass_cost = 'C0';}

		echo "<br>"._QXZ("MODIFY SYSTEM SETTINGS")."<form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=411111111111111>\n";
		echo "<input type=hidden name=DB value='$DB'>\n";
		echo "<input type=hidden name=sounds_web_directory value=\"$sounds_web_directory\">\n";
		echo "<center><TABLE width=900 cellspacing=3>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Version").": </td><td align=left> $version</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("SVN Version").": </td><td align=left> <a href=\"$PHP_SELF?ADD=999991\">$svn_revision</a></td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("DB Schema Version").": </td><td align=left> $db_schema_version";
		if ($db_schema_version != "$ExpectedDBSchema")
			{
			echo "<font color=red><b> &nbsp; "._QXZ("WARNING: Code expects different schema").": $ExpectedDBSchema</b></font>\n";
			}
		echo "</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("DB Schema Update Date").": </td><td align=left> $db_schema_update_date</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Password Encryption").": </td><td align=left> "._QXZ("$pass_hash_enabled")." - $pass_key - $pass_cost</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Auto User-add Value").": </td><td align=left> $auto_user_add_value</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Recording Prompt Count").": </td><td align=left> $rec_prompt_count</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Highest Lead ID").": </td><td align=left> $highest_lead_id</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Install Date").": </td><td align=left> $install_date</td></tr>\n";
		$pcblinkB=''; $pcblinkE='';
		if ($vicidial_phone_codes_count < 1000) {$pcblinkB='<b><font color=red><blink>'; $pcblinkE='</blink></font></b>';}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=999988\">"._QXZ("Phone Codes")."</a>: </td><td align=left> $pcblinkB$vicidial_phone_codes_count - $vicidial_postal_codes_count - $vicidial_postal_codes_cities_count - $vicidial_nanpa_prefix_codes_count$pcblinkE - $nanpa_prefix_exchanges_master_count - $nanpa_prefix_exchanges_fast_count - $nanpa_wired_to_wireless_count - $nanpa_wireless_to_wired_count</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Today System Stats").": </td><td align=left> $ALLtotal_calls - $ALLmax_inbound - $ALLmax_outbound - $ALLchannels_count - $ALLcalls_count - $ALLagent_count</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Use Non-Latin")."(UTF-8): </td><td align=left><select size=1 name=use_non_latin><option>1</option><option>0</option><option selected>$use_non_latin</option></select>$NWB#settings-use_non_latin$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Enable Languages").": </td><td align=left><select size=1 name=enable_languages><option>1</option><option>0</option><option selected>$enable_languages</option></select>$NWB#settings-enable_languages$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Language Method").": </td><td align=left><select size=1 name=language_method><option>"._QXZ("DISABLED")."</option><option>"._QXZ("MYSQL")."</option><option value=\"$language_method\" SELECTED>"._QXZ("$language_method")."</option></select>$NWB#settings-language_method$NWE</td></tr>\n";

		if ($SSenable_languages > 0)
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Default Language").": </td><td align=left><select size=1 name=default_language><option value=\"default English\">"._QXZ("default English")."</option>\n";
			$stmt="SELECT language_id,language_description from vicidial_languages where active='Y' $LOGadmin_viewable_groupsSQL order by language_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$languages_to_print = mysqli_num_rows($rslt);
			$languages_list='';
			$o=0;
			while ($languages_to_print > $o) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$languages_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
				$o++;
				}
			echo "$languages_list";
			echo "<option SELECTED value='$default_language'>$default_language</option></select>$NWB#settings-default_language$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right></td><td align=left><input type=hidden name=default_language value=\"$default_language\"></td></tr>\n";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Webroot Writable").": </td><td align=left><select size=1 name=webroot_writable><option>1</option><option>0</option><option selected>$webroot_writable</option></select>$NWB#settings-webroot_writable$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Disable Display").": </td><td align=left><select size=1 name=vicidial_agent_disable>\n";
		echo "<option value=\"NOT_ACTIVE\">"._QXZ("NOT_ACTIVE")."</option>\n";
		echo "<option value=\"LIVE_AGENT\">"._QXZ("LIVE_AGENT")."</option>\n";
		echo "<option value=\"EXTERNAL\">"._QXZ("EXTERNAL")."</option>\n";
		echo "<option value=\"ALL\">"._QXZ("ALL")."</option>\n";
		echo "<option selected value=\"$vicidial_agent_disable\">"._QXZ("$vicidial_agent_disable")."</option>\n";
		echo "</select>$NWB#settings-agent_disable$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Clear Frozen Calls").": </td><td align=left><select size=1 name=frozen_server_call_clear><option>1</option><option>0</option><option selected>$frozen_server_call_clear</option></select>$NWB#settings-frozen_server_call_clear$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Allowed SIP Stacks").": </td><td align=left><select size=1 name=allowed_sip_stacks>";
		echo "<option value=\"SIP\">"._QXZ("SIP")."</option>\n";
		echo "<option value=\"PJSIP\">"._QXZ("PJSIP")."</option>\n";
		echo "<option value=\"SIP_and_PJSIP\">"._QXZ("SIP_and_PJSIP")."</option>\n";
		echo "<option selected value=\"$allowed_sip_stacks\">"._QXZ("$allowed_sip_stacks")."</option>\n";
		echo "</select>$NWB#settings-allowed_sip_stacks$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Allow SIPSAK Messages").": </td><td align=left><select size=1 name=allow_sipsak_messages><option>1</option><option>0</option><option selected>$allow_sipsak_messages</option></select>$NWB#settings-allow_sipsak_messages$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin Modify Auto-Refresh").": </td><td align=left><input type=text name=admin_modify_refresh size=6 maxlength=5 value=\"$admin_modify_refresh\">$NWB#settings-admin_modify_refresh$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin No-Cache").": </td><td align=left><select size=1 name=nocache_admin><option>1</option><option>0</option><option selected>$nocache_admin</option></select>$NWB#settings-nocache_admin$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin Row Click").": </td><td align=left><select size=1 name=admin_row_click><option>1</option><option>0</option><option selected>$admin_row_click</option></select>$NWB#settings-admin_row_click$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin Records Per Page").": </td><td align=left><input type=text name=entries_per_page size=6 maxlength=5 value=\"$entries_per_page\">$NWB#settings-entries_per_page$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin User Redirect").": </td><td align=left><select size=1 name=user_admin_redirect><option>1</option><option>0</option><option selected>$user_admin_redirect</option></select>$NWB#settings-user_admin_redirect$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Enable Agent Transfer Logfile").": </td><td align=left><select size=1 name=enable_agc_xfer_log><option>1</option><option>0</option><option selected>$enable_agc_xfer_log</option></select>$NWB#settings-enable_agc_xfer_log$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Enable Agent Disposition Logfile").": </td><td align=left><select size=1 name=enable_agc_dispo_log><option>1</option><option>0</option><option selected>$enable_agc_dispo_log</option></select>$NWB#settings-enable_agc_dispo_log$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Timeclock End Of Day").": </td><td align=left><input type=text name=timeclock_end_of_day size=5 maxlength=4 value=\"$timeclock_end_of_day\">$NWB#settings-timeclock_end_of_day$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Default Local GMT").": </td><td align=left><select size=1 name=default_local_gmt><option>12.75</option><option>12.00</option><option>11.00</option><option>10.00</option><option>9.50</option><option>9.00</option><option>8.00</option><option>7.00</option><option>6.50</option><option>6.00</option><option>5.75</option><option>5.50</option><option>5.00</option><option>4.50</option><option>4.00</option><option>3.50</option><option>3.00</option><option>2.00</option><option>1.00</option><option>0.00</option><option>-1.00</option><option>-2.00</option><option>-3.00</option><option>-3.50</option><option>-4.00</option><option>-5.00</option><option>-6.00</option><option>-7.00</option><option>-8.00</option><option>-9.00</option><option>-10.00</option><option>-11.00</option><option>-12.00</option><option selected>$default_local_gmt</option></select> ("._QXZ("Do NOT Adjust for DST").")$NWB#settings-default_local_gmt$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Default Voicemail Zone").": </td><td align=left><select size=1 name=default_voicemail_timezone>";
		$vm_zones = explode("\n",$SSvoicemail_timezones);
		$z=0;
		$vm_zones_ct = count($vm_zones);
		while($vm_zones_ct > $z)
			{
			if (strlen($vm_zones[$z]) > 5)
				{
				$vm_specs = explode("=",$vm_zones[$z]);
				$vm_abb = $vm_specs[0];
				$vm_details = explode('|',$vm_specs[1]);
				$vm_location = 	$vm_details[0];
				echo "<option value=\"$vm_abb\">$vm_abb - $vm_location</option>\n";
				}
			$z++;
			}
		echo "<option selected>$default_voicemail_timezone</option></select> $NWB#settings-default_voicemail_timezone$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agents Calls Reset").": </td><td align=left><select size=1 name=agents_calls_reset><option>1</option><option>0</option><option selected>$agents_calls_reset</option></select>$NWB#settings-agents_calls_reset$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Timeclock Last Auto Logout").": </td><td align=left> $timeclock_last_reset_date</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Oldest Logs Date").": </td><td align=left> $oldest_logs_date</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Screen Header Date Format").": </td><td align=left><select size=1 name=vdc_header_date_format>\n";
		echo "<option>MS_DASH_24HR  2008-06-24 23:59:59</option>\n";
		echo "<option>US_SLASH_24HR 06/24/2008 23:59:59</option>\n";
		echo "<option>EU_SLASH_24HR 24/06/2008 23:59:59</option>\n";
		echo "<option>AL_TEXT_24HR  JUN 24 23:59:59</option>\n";
		echo "<option>MS_DASH_AMPM  2008-06-24 11:59:59 PM</option>\n";
		echo "<option>US_SLASH_AMPM 06/24/2008 11:59:59 PM</option>\n";
		echo "<option>EU_SLASH_AMPM 24/06/2008 11:59:59 PM</option>\n";
		echo "<option>AL_TEXT_AMPM  JUN 24 11:59:59 PM</option>\n";
		echo "<option selected value=\"$vdc_header_date_format\">$vdc_header_date_format</option>\n";
		echo "</select>$NWB#settings-vdc_header_date_format$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Screen Customer Date Format").": </td><td align=left><select size=1 name=vdc_customer_date_format>\n";
		echo "<option>MS_DASH_24HR  2008-06-24 23:59:59</option>\n";
		echo "<option>US_SLASH_24HR 06/24/2008 23:59:59</option>\n";
		echo "<option>EU_SLASH_24HR 24/06/2008 23:59:59</option>\n";
		echo "<option>AL_TEXT_24HR  JUN 24 23:59:59</option>\n";
		echo "<option>MS_DASH_AMPM  2008-06-24 11:59:59 PM</option>\n";
		echo "<option>US_SLASH_AMPM 06/24/2008 11:59:59 PM</option>\n";
		echo "<option>EU_SLASH_AMPM 24/06/2008 11:59:59 PM</option>\n";
		echo "<option>AL_TEXT_AMPM  JUN 24 11:59:59 PM</option>\n";
		echo "<option selected value=\"$vdc_customer_date_format\">$vdc_customer_date_format</option>\n";
		echo "</select>$NWB#settings-vdc_customer_date_format$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Screen Customer Phone Format").": </td><td align=left><select size=1 name=vdc_header_phone_format>\n";
		echo "<option>US_DASH 000-000-0000</option>\n";
		echo "<option>US_PARN (000)000-0000</option>\n";
		echo "<option>MS_NODS 0000000000</option>\n";
		echo "<option>UK_DASH 00 0000-0000</option>\n";
		echo "<option>AU_SPAC 000 000 000</option>\n";
		echo "<option>IT_DASH 0000-000-000</option>\n";
		echo "<option>FR_SPAC 00 00 00 00 00</option>\n";
		echo "<option selected value=\"$vdc_header_phone_format\">$vdc_header_phone_format</option>\n";
		echo "</select>$NWB#settings-vdc_header_phone_format$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent API Active").": </td><td align=left><select size=1 name=vdc_agent_api_active><option>1</option><option>0</option><option selected>$vdc_agent_api_active</option></select>$NWB#settings-vdc_agent_api_active$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Allow Agent API Notifications").": </td><td align=left><select size=1 name=agent_notifications><option>1</option><option>0</option><option selected>$agent_notifications</option></select>$NWB#settings-agent_notifications$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Allow Hide Customer Hangup Button").": </td><td align=left><select size=1 name=agent_hide_hangup><option>1</option><option>0</option><option selected>$agent_hide_hangup</option></select>$NWB#settings-agent_hide_hangup$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Screen Park Xfer Button").": </td><td align=left><select size=1 name=agent_xfer_park_3way><option>1</option><option>0</option><option selected>$agent_xfer_park_3way</option></select>$NWB#settings-agent_xfer_park_3way$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Screen Logout Link Credentials").": </td><td align=left><select size=1 name=agent_logout_link><option>1</option><option>0</option><option selected>$agent_logout_link</option><option>2</option><option>3</option><option>4</option></select>$NWB#settings-agent_logout_link$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Soundboards").": </td><td align=left><select size=1 name=agent_soundboards><option>1</option><option>0</option><option selected>$agent_soundboards</option></select>$NWB#settings-agent_soundboards$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Browser Call Alerts").": </td><td align=left><select size=1 name=browser_call_alerts><option>2</option><option>1</option><option>0</option><option selected>$browser_call_alerts</option></select>$NWB#settings-browser_call_alerts$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=392111111111&container_id=FAILED_DIAL_MESSAGE_OVERRIDE\">"._QXZ("Hide Agent Failed Dial Codes")."</a>: </td><td align=left><select size=1 name=agent_hide_dial_fail><option>1</option><option>0</option><option selected>$agent_hide_dial_fail</option></select>$NWB#settings-agent_hide_dial_fail$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Login Kick-all").": </td><td align=left><select size=1 name=login_kickall><option>1</option><option>0</option><option selected>$login_kickall</option></select>$NWB#settings-login_kickall$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Agent Hidden Browser Sound").": </td><td align=left><select size=1 name='agent_hidden_sound' id='agent_hidden_sound'>\n";
		$browser_alert_sounds_listARY = explode(',',$browser_alert_sounds_list);
		$browser_alert_sounds_listARY_ct = count($browser_alert_sounds_listARY);
		$bas=0;   $bas_output='';
		while ($browser_alert_sounds_listARY_ct > $bas)
			{
			$bas_output .= "<option value='$browser_alert_sounds_listARY[$bas]'>"._QXZ("$browser_alert_sounds_listARY[$bas]")."</option>";
			$bas++;
			}
		echo "$bas_output";
		echo "<option value='---NONE---'>---"._QXZ("NONE")."---</option>";
		echo "<option value='$agent_hidden_sound' selected>"._QXZ("$agent_hidden_sound")."</option>";
		echo "</select> &nbsp; \n";
		echo " "._QXZ("volume").": <select size=1 name='agent_hidden_sound_volume' id='agent_hidden_sound_volume'>";
		$bav=100;
		while ($bav >= 0)
			{
			if ($bav == 0)
				{echo "<option>1</option>";}
			echo "<option>$bav</option>";
			$bav = ($bav - 5);
			}
		echo "<option selected>$agent_hidden_sound_volume</option></select> &nbsp; ";
		echo "<a href=\"#\" onclick=\"play_browser_sound('agent_hidden_sound','agent_hidden_sound_volume');return false;\"><font size=2 color=black>"._QXZ("play selected sound")."</font></a> $NWB#settings-agent_hidden_sound$NWE &nbsp; </td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Agent Hidden Browser Sound Seconds").": </td><td align=left><select size=1 name='agent_hidden_sound_seconds' id='agent_hidden_sound_seconds'>";
		$bav=600;
		while ($bav >= 0)
			{
			echo "<option>$bav</option>";
			$bav = ($bav - 5);
			}
		echo "<option selected>$agent_hidden_sound_seconds</option></select> $NWB#settings-agent_hidden_sound_seconds$NWE &nbsp; </td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Enable Pause Code Time Limits").": </td><td align=left><select size=1 name=enable_pause_code_limits><option>1</option><option>0</option><option selected>$enable_pause_code_limits</option></select>$NWB#settings-enable_pause_code_limits$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Agent Only Callback Campaign Lock").": </td><td align=left><select size=1 name=agentonly_callback_campaign_lock><option>1</option><option>0</option><option selected>$agentonly_callback_campaign_lock</option></select>$NWB#settings-agentonly_callback_campaign_lock$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Callback Time 24 Hours").": </td><td align=left><select size=1 name=callback_time_24hour><option>1</option><option>0</option><option selected>$callback_time_24hour</option></select>$NWB#settings-callback_time_24hour$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Anyone Callback Inactive Lists").": </td><td align=left><select size=1 name=anyone_callback_inactive_lists><option>default</option><option value='NO_ADD_TO_HOPPER'>"._QXZ("NO_ADD_TO_HOPPER")."</option><option value='KEEP_IN_HOPPER'>"._QXZ("KEEP_IN_HOPPER")."</option><option selected value='$anyone_callback_inactive_lists'>"._QXZ("$anyone_callback_inactive_lists")."</option></select>$NWB#settings-anyone_callback_inactive_lists$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Central Sound Control Active").": </td><td align=left><select size=1 name=sounds_central_control_active><option>1</option><option>0</option><option selected>$sounds_central_control_active</option></select>$NWB#settings-sounds_central_control_active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Sounds Web Server").": </td><td align=left><input type=text name=sounds_web_server size=30 maxlength=50 value=\"$sounds_web_server\">$NWB#settings-sounds_web_server$NWE</td></tr>\n";


		$admin_web_dir='';
		if (preg_match("/\//",$admin_web_directory))
			{$admin_web_dir = dirname("$admin_web_directory");   $admin_web_dir .= "/";}
		if (!preg_match("/^http:|^https:/i",$sounds_web_server))
			{$sounds_web_server = "http://".$sounds_web_server;}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Sounds Web Directory").": </td><td align=left><a href=\"$sounds_web_server/$admin_web_dir$sounds_web_directory\">$sounds_web_directory</a> $NWB#settings-sounds_web_directory$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom Agent Login Sound").": </td><td><input type=text size=50 maxlength=255 name=meetme_enter_login_filename id=meetme_enter_login_filename value=\"$meetme_enter_login_filename\"> <a href=\"javascript:launch_chooser('meetme_enter_login_filename','date');\">"._QXZ("audio chooser")."</a>  $NWB#settings-meetme_enter_login_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom Agent Leave 3way Sound").": </td><td><input type=text size=50 maxlength=255 name=meetme_enter_leave3way_filename id=meetme_enter_leave3way_filename value=\"$meetme_enter_leave3way_filename\"> <a href=\"javascript:launch_chooser('meetme_enter_leave3way_filename','date');\">"._QXZ("audio chooser")."</a>  $NWB#settings-meetme_enter_leave3way_filename$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin Home URL").": </td><td align=left><input type=text name=admin_home_url size=50 maxlength=255 value=\"$admin_home_url\">$NWB#settings-admin_home_url$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin Web Directory").": </td><td align=left><input type=text name=admin_web_directory size=50 maxlength=255 value=\"$admin_web_directory\">$NWB#settings-admin_web_directory$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Screen Script").": </td><td align=left><input type=text name=agent_script size=50 maxlength=100 value=\"$agent_script\">$NWB#settings-agent_script$NWE</td></tr>\n";

		$stmt="SELECT server_id,active,active_asterisk_server from servers where server_ip='$active_voicemail_server' $LOGadmin_viewable_groupsSQL limit 1;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$servers_to_print = mysqli_num_rows($rslt);
		$avmMESSAGE='';
		$AVMactive=0;
		$AVMlinkA='';   $AVMlinkB='';
		if ($servers_to_print > 0) 
			{
			$rowx=mysqli_fetch_row($rslt);
			if ( ($rowx[1] == 'Y') and ($rowx[2] == 'Y') )
				{$AVMactive++;}
			$AVMlinkA = "<a href=\"$PHP_SELF?ADD=311111111111&server_id=$rowx[0]\">\n";
			$AVMlinkB = "</a>";
			}
		if ($AVMactive < 1)
			{
			$avmMESSAGE .= "<BR><font size=2 color=red><b>"._QXZ("WARNING! The defined Active Voicemail Server is not an active server!")."</b></font>\n";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>$AVMlinkA"._QXZ("Active Voicemail Server")."$AVMlinkB: </td><td align=left><select size=1 name=active_voicemail_server>\n";
		echo "$servers_list";
		echo "<option SELECTED>$active_voicemail_server</option>\n";
		echo "</select>$NWB#settings-active_voicemail_server$NWE$avmMESSAGE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Allow Voicemail Greeting Chooser").": </td><td align=left><select size=1 name=allow_voicemail_greeting><option>1</option><option>0</option><option selected>$allow_voicemail_greeting</option></select>$NWB#settings-allow_voicemail_greeting$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Auto Dial Limit").": </td><td align=left><select size=1 name=auto_dial_limit><option selected>$auto_dial_limit</option>\n";
		$adl=1;
		while($adl < 1000)
			{
			echo "<option>$adl</option>\n";
			if ($adl < 3)
				{$adl = ($adl + 0.1);}
			else
				{
				if ($adl < 4)
					{$adl = ($adl + 0.25);}
				else
					{
					if ($adl < 5)
						{$adl = ($adl + 0.5);}
					else
						{
						if ($adl < 20)
							{$adl = ($adl + 1);}
						else
							{
							if ($adl < 40)
								{$adl = ($adl + 2);}
							else
								{
								if ($adl < 100)
									{$adl = ($adl + 5);}
								else
									{
									if ($adl < 200)
										{$adl = ($adl + 10);}
									else
										{
										if ($adl < 400)
											{$adl = ($adl + 50);}
										else
											{
											if ($adl < 1000)
												{$adl = ($adl + 100);}
											else
												{$adl = ($adl + 1);}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		echo "<option>$adl</option></select>$NWB#settings-auto_dial_limit$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Allow Campaign Agent Limits").": </td><td align=left><select size=1 name=max_logged_in_agents><option>1</option><option>0</option><option selected>$max_logged_in_agents</option></select>$NWB#settings-max_logged_in_agents$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Outbound Auto-Dial Active").": </td><td align=left><select size=1 name=outbound_autodial_active><option>1</option><option>0</option><option selected>$outbound_autodial_active</option></select>$NWB#settings-outbound_autodial_active$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Lead Hopper Hold Inserts Allowed").": </td><td align=left><select size=1 name=hopper_hold_inserts><option>1</option><option>2</option><option>0</option><option selected>$hopper_hold_inserts</option></select>$NWB#settings-hopper_hold_inserts$NWE</td></tr>\n";

		$apinewlead_url='';
		$stmt="SELECT url_address from vicidial_url_multi where campaign_id='-SYSTEM-API-NEWLEAD-' and entry_type='system' and url_type='apinewlead';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$urls_to_print = mysqli_num_rows($rslt);
		if ($urls_to_print > 0) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$apinewlead_url = $rowx[0];
			}
		else
			{
			$stmt="INSERT INTO vicidial_url_multi SET campaign_id='-SYSTEM-API-NEWLEAD-', entry_type='system', url_type='apinewlead', active='Y', url_address='';";
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("API New Lead URL").": </td><td align=left NOWRAP><input type=text size=75 maxlength=5000 name=apinewlead_url value=\"$apinewlead_url\">$NWB#settings-apinewlead_url$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Shared Agent Campaign Dialing").": </td><td align=left><select size=1 name=allow_shared_dial><option>5</option><option>4</option><option>3</option><option>2</option><option>1</option><option>0</option><option selected>$allow_shared_dial</option></select>$NWB#settings-allow_shared_dial$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Search Method Override").": </td><td align=left><select size=1 name=agent_search_method><option>3</option><option>2</option><option>1</option><option>0</option><option selected>$agent_search_method</option></select>$NWB#settings-agent_search_method$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("UK OFCOM Drop Calculation").": </td><td align=left><select size=1 name=ofcom_uk_drop_calc><option>1</option><option>0</option><option selected>$ofcom_uk_drop_calc</option></select>$NWB#settings-ofcom_uk_drop_calc$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Disable Auto-Dial").": </td><td align=left>$disable_auto_dial &nbsp; $NWB#settings-disable_auto_dial$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Max FILL Calls per Second").": </td><td align=left><input type=text name=outbound_calls_per_second size=5 maxlength=4 value=\"$outbound_calls_per_second\">$NWB#settings-outbound_calls_per_second$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Web Lead Loader Phone Length").": </td><td align=left><select size=1 name=web_loader_phone_length><option>"._QXZ("DISABLED")."</option><option>"._QXZ("CHOOSE")."</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option><option>10</option><option>11</option><option>12</option><option>13</option><option>14</option><option>15</option><option>16</option><option>17</option><option>18</option><option value=\"$web_loader_phone_length\" SELECTED>"._QXZ("$web_loader_phone_length")."</option></select>$NWB#settings-web_loader_phone_length$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Web Lead Loader Phone Prefix Strip").": </td><td align=left><input type=text name=web_loader_phone_strip size=11 maxlength=10 value=\"$web_loader_phone_strip\">$NWB#settings-web_loader_phone_strip$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Manual Dial Phone Prefix Strip").": </td><td align=left><input type=text name=manual_dial_phone_strip size=11 maxlength=10 value=\"$manual_dial_phone_strip\">$NWB#settings-manual_dial_phone_strip$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Agent Manual Dialstring Filter").": </td><td align=left><input type=text name=agent_man_dial_filter size=20 maxlength=20 value=\"$agent_man_dial_filter\">$NWB#settings-agent_man_dial_filter$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Agent 3-Way Dialstring Filter").": </td><td align=left><input type=text name=agent_3way_dial_filter size=20 maxlength=20 value=\"$agent_3way_dial_filter\">$NWB#settings-agent_3way_dial_filter$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Allow Custom Dialplan Entries").": </td><td align=left><select size=1 name=allow_custom_dialplan><option>1</option><option>0</option><option selected>$allow_custom_dialplan</option></select>$NWB#settings-allow_custom_dialplan$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("PLLB Grouping Limit").": </td><td align=left><input type=text name=pllb_grouping_limit size=4 maxlength=3 value=\"$pllb_grouping_limit\">$NWB#settings-pllb_grouping_limit$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Generate Cross-Server Phone Extensions").": </td><td align=left><select size=1 name=generate_cross_server_exten><option>1</option><option>0</option><option selected>$generate_cross_server_exten</option></select>$NWB#settings-generate_cross_server_exten$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("USA-Canada Phone Number Dialcode Fix").": </td><td align=left><select size=1 name=usacan_phone_dialcode_fix><option>1</option><option>0</option><option selected>$usacan_phone_dialcode_fix</option></select>$NWB#settings-usacan_phone_dialcode_fix$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Default Phone Code").": </td><td align=left><input type=text name=default_phone_code size=8 maxlength=8 value=\"$default_phone_code\">$NWB#settings-default_phone_code$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User Territories Active").": </td><td align=left><select size=1 name=user_territories_active><option>1</option><option>0</option><option selected>$user_territories_active</option></select>$NWB#settings-user_territories_active$NWE</td></tr>\n";

		##### get container entry for USER_LOCATIONS_SYSTEM for pulldown menu
		$user_locations_ct=0;
		$raw_location_data=";location|description\n|default\n";
		$stmt="SELECT container_entry from vicidial_settings_containers where container_id='USER_LOCATIONS_SYSTEM';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$loc_to_print = mysqli_num_rows($rslt);
		if ($loc_to_print > 0)
			{
			$rowx=mysqli_fetch_row($rslt);
			$raw_location_data = $rowx[0];
			}
		$location_ARY = explode("\n",$raw_location_data);
		$location_ct = count($location_ARY);
		$o=0;
		while ($location_ct > $o) 
			{
			if ( (!preg_match("/^;/",$location_ARY[$o])) and (strlen($location_ARY[$o]) > 2) and (preg_match("/\|/",$location_ARY[$o])) )
				{
				$user_locations_ct++;
				}
			$o++;
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=392111111111&container_id=USER_LOCATIONS_SYSTEM\">"._QXZ("User Locations")."</a>: </td><td align=left>$user_locations_ct &nbsp; $NWB#users-user_location$NWE</td></tr>\n";

		##### get container entry for USER_CODES_SYSTEM for pulldown menu
		$user_codes_ct=0;
		$raw_user_codes_admin_data="|empty\n";
		if ($SSuser_codes_admin == '2')
			{
			if (file_exists('user_codes_admin.txt'))
				{
				$user_codes_admin_ARY = file('user_codes_admin.txt');
				}
			}
		else
			{
			$stmt="SELECT container_entry from vicidial_settings_containers where container_id='USER_CODES_SYSTEM';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$uc_to_print = mysqli_num_rows($rslt);
			if ($uc_to_print > 0)
				{
				$rowx=mysqli_fetch_row($rslt);
				$raw_user_codes_admin_data = $rowx[0];
				}
			$user_codes_admin_ARY = explode("\n",$raw_user_codes_admin_data);
			}
		$user_codes_admin_ct = count($user_codes_admin_ARY);
		$o=0;
		while ($user_codes_admin_ct > $o) 
			{
			if ( (!preg_match("/^;/",$user_codes_admin_ARY[$o])) and (strlen($user_codes_admin_ARY[$o]) > 0) )
				{
				$user_codes_ct++;
				}
			$o++;
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>";
		if ( ($SSuser_codes_admin == '2') and (file_exists('user_codes_admin.txt')) )
			{echo "<a href=\"user_codes_admin.txt\">"._QXZ("User Codes Admin Pulldown")."</a>";}
		else
			{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=USER_CODES_SYSTEM\">"._QXZ("User Codes Admin Pulldown")."</a>";}

		echo ": </td><td align=left><select size=1 name=user_codes_admin><option>0</option><option>1</option><option>2</option><option selected>$user_codes_admin</option></select> &nbsp; count: $user_codes_ct &nbsp; $NWB#settings-user_codes_admin$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("List Status Modification Confirmation").": </td><td align=left><select size=1 name=list_status_modification_confirmation><option>1</option><option>0</option><option selected>$list_status_modification_confirmation</option></select>$NWB#settings-list_status_modification_confirmation$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Enable First Webform").": </td><td align=left><select size=1 name=enable_first_webform><option>1</option><option>0</option><option selected>$enable_first_webform</option></select>$NWB#settings-enable_first_webform$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Enable Second Webform").": </td><td align=left><select size=1 name=enable_second_webform><option>1</option><option>0</option><option selected>$enable_second_webform</option></select>$NWB#settings-enable_second_webform$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Enable Third Webform").": </td><td align=left><select size=1 name=enable_third_webform><option>1</option><option>0</option><option selected>$enable_third_webform</option></select>$NWB#settings-enable_third_webform$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Enable Second Script Tab").": </td><td align=left><select size=1 name=enable_second_script><option>1</option><option>0</option><option selected>$enable_second_script</option></select>$NWB#settings-enable_second_script$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Enable TTS Integration").": </td><td align=left><select size=1 name=enable_tts_integration><option>1</option><option>0</option><option selected>$enable_tts_integration</option></select>$NWB#settings-enable_tts_integration$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Enable CallCard").": </td><td align=left><select size=1 name=callcard_enabled><option>1</option><option>0</option><option selected>$callcard_enabled</option></select>$NWB#settings-callcard_enabled$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Enable Campaign Test Calls").": </td><td align=left><select size=1 name=test_campaign_calls><option>1</option><option>0</option><option selected>$test_campaign_calls</option></select>$NWB#settings-test_campaign_calls$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Enable International DNCs").": </td><td align=left><select size=1 name=enable_international_dncs><option>1</option><option>0</option><option selected>$enable_international_dncs</option></select>$NWB#settings-enable_international_dncs$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=3311&did_id=did_system_filter\">"._QXZ("DID System Filter")."</a>: </td><td align=left><select size=1 name=did_system_filter><option>1</option><option>0</option><option selected>$did_system_filter</option></select>$NWB#settings-did_system_filter$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Inbound Answer Configuration").": </td><td align=left><select size=1 name=inbound_answer_config><option>1</option><option>0</option><option selected>$inbound_answer_config</option></select>$NWB#settings-inbound_answer_config$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Inbound Calls Credits").": </td><td align=left><select size=1 name=inbound_credits><option>1</option><option>0</option><option selected>$inbound_credits</option></select>$NWB#settings-inbound_credits$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Enable Abandon Check Queue").": </td><td align=left><select size=1 name=abandon_check_queue><option>1</option><option>0</option><option selected>$abandon_check_queue</option></select>$NWB#settings-abandon_check_queue$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("New Leads Per List Limit").": </td><td align=left><select size=1 name=user_new_lead_limit><option>1</option><option>0</option><option selected>$user_new_lead_limit</option></select>$NWB#settings-user_new_lead_limit$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Enable Daily Called Count Limits").": </td><td align=left><select size=1 name=daily_call_count_limit><option>1</option><option>0</option><option selected>$daily_call_count_limit</option></select>$NWB#settings-daily_call_count_limit$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Enable 24-Hour Called Count Limits").": </td><td align=left><select size=1 name=call_limit_24hour><option>1</option><option>0</option><option selected>$call_limit_24hour</option></select>$NWB#settings-call_limit_24hour$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Call Quota Lead Ranking").": </td><td align=left><select size=1 name=call_quota_lead_ranking><option>1</option><option>0</option><option selected>$call_quota_lead_ranking</option></select>$NWB#settings-call_quota_lead_ranking$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Demographic Quotas").": </td><td align=left><select size=1 name=demographic_quotas><option>1</option><option>0</option><option selected>$demographic_quotas</option></select>$NWB#settings-demographic_quotas$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Enable Custom List Fields").": </td><td align=left><select size=1 name=custom_fields_enabled><option>1</option><option>0</option><option selected>$custom_fields_enabled</option></select>$NWB#settings-custom_fields_enabled$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Enable Expanded List Stats").": </td><td align=left><select size=1 name=expanded_list_stats><option>1</option><option>0</option><option selected>$expanded_list_stats</option></select>$NWB#settings-expanded_list_stats$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Hide Inactive Lists").": </td><td align=left><select size=1 name=hide_inactive_lists><option>1</option><option>0</option><option selected>$hide_inactive_lists</option></select>$NWB#settings-hide_inactive_lists$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Country Code List Stats").": </td><td align=left><select size=1 name=country_code_list_stats><option>1</option><option>0</option><option selected>$country_code_list_stats</option></select>$NWB#settings-country_code_list_stats$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Enable DID Entry List ID").": </td><td align=left><select size=1 name=enable_did_entry_list_id><option>1</option><option>0</option><option selected>$enable_did_entry_list_id</option></select>$NWB#settings-enable_did_entry_list_id$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Enable List Weekday Resets").": </td><td align=left><select size=1 name=weekday_resets><option>1</option><option>0</option><option selected>$weekday_resets</option></select>$NWB#settings-weekday_resets$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Lead Manager Active Lists").": </td><td align=left><select size=1 name=allow_manage_active_lists><option>1</option><option>0</option><option selected>$allow_manage_active_lists</option></select>$NWB#settings-allow_manage_active_lists$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Enable GDPR-compliant Data Download Deletion").": </td><td align=left><select size=1 name=enable_gdpr_download_deletion><option>2</option><option>1</option><option>0</option><option selected>$enable_gdpr_download_deletion</option></select>$NWB#settings-enable_gdpr_download_deletion$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Expired Lists Auto Inactive").": </td><td align=left><select size=1 name=expired_lists_inactive><option>1</option><option>0</option><option selected>$expired_lists_inactive</option></select>$NWB#settings-expired_lists_inactive$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Enable Drop Lists").": </td><td align=left><select size=1 name=enable_drop_lists><option>0</option><option>1</option><option>2</option><option selected>$enable_drop_lists</option></select>$NWB#settings-enable_drop_lists$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Admin Lead Source ID Display").": </td><td align=left><select size=1 name=source_id_display><option>0</option><option>1</option><option selected>$source_id_display</option></select>$NWB#settings-source_id_display$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Allow Web DB Debug").": </td><td align=left><select size=1 name=allow_web_debug><option>0</option><option>1</option><option selected>$allow_web_debug</option></select>$NWB#settings-allow_web_debug$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Screen Debug Logging").": </td><td align=left><input type=text name=agent_debug_logging size=20 maxlength=20 value=\"$agent_debug_logging\">$NWB#settings-agent_debug_logging$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=392111111111&container_id=AGENT_LATENCY_LOGGING\">"._QXZ("Agent Latency Gaps Logging")."</a>: </td><td align=left><select size=1 name=log_latency_gaps><option>0</option><option>1</option><option>2</option><option selected>$log_latency_gaps</option></select>$NWB#settings-log_latency_gaps$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Screen Timer").": </td><td align=left><select size=1 name=agent_screen_timer><option>setTimeout</option><option>setTimeoutAudioLoop</option><option>EventSource</option><option selected>$agent_screen_timer</option></select>$NWB#settings-agent_screen_timer$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Enhanced Disconnect Logging").": </td><td align=left><select size=1 name=enhanced_disconnect_logging><option>6</option><option>5</option><option>4</option><option>3</option><option>2</option><option>1</option><option>0</option><option selected>$enhanced_disconnect_logging</option></select>$NWB#settings-enhanced_disconnect_logging$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("SIP Event Logging").": </td><td align=left><select size=1 name=sip_event_logging><option>1</option><option>0</option><option selected>$sip_event_logging</option></select>$NWB#settings-sip_event_logging$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Cached Realtime Carrier Stats").": </td><td align=left><select size=1 name=cache_carrier_stats_realtime><option>1</option><option>0</option><option selected>$cache_carrier_stats_realtime</option></select>$NWB#settings-cache_carrier_stats_realtime$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Enable CID Groups and Campaign Areacode CID").": </td><td align=left><select size=1 name=campaign_cid_areacodes_enabled><option>1</option><option>0</option><option selected>$campaign_cid_areacodes_enabled</option></select>$NWB#settings-campaign_cid_areacodes_enabled$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Outbound Call Any CID").": </td><td align=left><select size=1 name=outbound_cid_any><option value=\"DISABLED\">"._QXZ("DISABLED")."</option><option value=\"API_ONLY\">"._QXZ("API_ONLY")."</option><option selected value=\"$outbound_cid_any\">"._QXZ("$outbound_cid_any")."</option></select>$NWB#settings-outbound_cid_any$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("OpenSIPs CID Name Support").": </td><td align=left><select size=1 name=opensips_cid_name><option>1</option><option>0</option><option selected>$opensips_cid_name</option></select>$NWB#settings-opensips_cid_name$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Enable Remote Agent Extension Overrides").": </td><td align=left><select size=1 name=did_ra_extensions_enabled><option>1</option><option>0</option><option selected>$did_ra_extensions_enabled</option></select>$NWB#settings-did_ra_extensions_enabled$NWE</td></tr>\n";

		# check if any servers are using CONFBRIDGE, if not, don't allow Enable Enhanced Agent Monitoring to be enabled
		$CB_ct=0;
		$stmt="SELECT count(*) from servers where active='Y' and conf_engine='CONFBRIDGE';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$cbs_to_print = mysqli_num_rows($rslt);
		if ($cbs_to_print > 0)
			{
			$rowx=mysqli_fetch_row($rslt);
			$CB_ct = $rowx[0];
			}

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Enable Enhanced Agent Monitoring").": </td><td align=left><select size=1 name=enhanced_agent_monitoring>";
		if ($CB_ct > 0)
			{echo "<option>1</option>";}
		echo "<option>0</option><option selected>$enhanced_agent_monitoring</option></select>$NWB#settings-enhanced_agent_monitoring$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Enable Agent Whisper Monitoring").": </td><td align=left><select size=1 name=agent_whisper_enabled><option>1</option><option>0</option><option selected>$agent_whisper_enabled</option></select>$NWB#settings-agent_whisper_enabled$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Enable User Hide RealTime").": </td><td align=left><select size=1 name=user_hide_realtime_enabled><option>1</option><option>0</option><option selected>$user_hide_realtime_enabled</option></select>$NWB#settings-user_hide_realtime_enabled$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Enable Manual Dial Auto Next").": </td><td align=left><select size=1 name=manual_auto_next><option>1</option><option>0</option><option selected>$manual_auto_next</option></select>$NWB#settings-manual_auto_next$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Enable Manual Dial Validation").": </td><td align=left><select size=1 name=manual_dial_validation><option>0</option><option>1</option><option>2</option><option selected>$manual_dial_validation</option></select>$NWB#settings-manual_dial_validation$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Enable Contacts").": </td><td align=left><select size=1 name=contacts_enabled><option>1</option><option>0</option><option selected>$contacts_enabled</option></select>$NWB#settings-contacts_enabled$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Call Menu Qualify Enabled").": </td><td align=left><select size=1 name=call_menu_qualify_enabled><option>1</option><option>0</option><option selected>$call_menu_qualify_enabled</option></select>$NWB#settings-call_menu_qualify_enabled$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Call Menu Alt DTMF Logging").": </td><td align=left><select size=1 name=alt_ivr_logging><option>1</option><option>0</option><option selected>$alt_ivr_logging</option></select>$NWB#settings-alt_ivr_logging$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Allow IP Lists").": </td><td align=left><select size=1 name=allow_ip_lists><option>1</option><option>0</option><option selected>$allow_ip_lists</option></select>$NWB#settings-allow_ip_lists$NWE</td></tr>\n";

		##### get ip lists listing for dynamic pulldown 
		$stmt="SELECT ip_list_id,ip_list_name from vicidial_ip_lists where active='Y' order by ip_list_id;";
		$rsltx=mysql_to_mysqli($stmt, $link);
		$iplists_to_print = mysqli_num_rows($rsltx);
		$ip_list='';
		$o=0;
		while ($iplists_to_print > $o)
			{
			$rowx=mysqli_fetch_row($rsltx);
			$ip_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}

		if (strlen($system_ip_blacklist) < 1)
			{
			$ip_list_link_BEGIN = "";   $ip_list_link_END = "";
			$ip_list_menu = "<option value=\"\" SELECTED>--- "._QXZ("DISABLED")." ---</option>\n";
			}
		else
			{
			$ip_list_link_BEGIN = "<a href='$PHP_SELF?ADD=395111111111&ip_list_id=$system_ip_blacklist'>";   $ip_list_link_END = "</a>";
			$ip_list_menu = "<option value=\"\">--- "._QXZ("DISABLED")." ---</option>\n";
			$ip_list_menu .= "<option SELECTED>$system_ip_blacklist</option>\n";
			}

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>$ip_list_link_BEGIN"._QXZ("System IP Blacklist")."$ip_list_link_END: </td><td align=left><select size=1 name=system_ip_blacklist>\n";
		echo "$ip_list$ip_list_menu";
		echo "</select>$NWB#settings-system_ip_blacklist$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Level 8 Disable Add").": </td><td align=left><select size=1 name=level_8_disable_add><option>1</option><option>0</option><option selected>$level_8_disable_add</option></select>$NWB#settings-level_8_disable_add$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Script Text Remove JS").": </td><td align=left><select size=1 name=script_remove_js><option>1</option><option>0</option><option selected>$script_remove_js</option></select>$NWB#settings-script_remove_js$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Admin List Counts Link").": </td><td align=left><select size=1 name=admin_list_counts><option>1</option><option>0</option><option selected>$admin_list_counts</option></select>$NWB#settings-admin_list_counts$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Allow Emails").": </td><td align=left><select size=1 name=allow_emails><option>1</option><option>0</option><option selected>$allow_emails</option></select>$NWB#settings-allow_emails$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Allow Chats").": </td><td align=left><select size=1 name=allow_chats><option>1</option><option>0</option><option selected>$allow_chats</option></select>$NWB#settings-allow_chats$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Chat Timeout in seconds").": </td><td align=left><input type=text name=chat_timeout size=3 maxlength=3 value=\"$chat_timeout\">$NWB#settings-chat_timeout$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Chat URL").": </td><td align=left><input type=text name=chat_url size=50 maxlength=255 value=\"$chat_url\">$NWB#settings-chat_url$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Push Events").": </td><td align=left><select size=1 name=agent_push_events><option>1</option><option>0</option><option selected>$agent_push_events</option></select>$NWB#settings-agent_push_events$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Agent Push URL").": </td><td align=left><input type=text name=agent_push_url size=50 maxlength=1000 value=\"$agent_push_url\">$NWB#settings-agent_push_url$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Log Recording Access").": </td><td align=left><select size=1 name=log_recording_access><option>1</option><option>0</option><option selected>$log_recording_access</option></select>$NWB#settings-log_recording_access$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Recording Buttons Type").": </td><td align=left><select size=1 name=recording_buttons>
		<option value='START_STOP'>"._QXZ("START_STOP")."</option>
		<option value='START_STOP_NOGAP'>"._QXZ("START_STOP_NOGAP")."</option>
		<option value='RECORDING'>"._QXZ("RECORDING")."</option>
		<option value='RECORDING_NOGAP'>"._QXZ("RECORDING_NOGAP")."</option>
		<option value='2xHEIGHT_RECORDING'>"._QXZ("2xHEIGHT_RECORDING")."</option>
		<option value='2xHEIGHT_RECORDING_NOGAP'>"._QXZ("2xHEIGHT_RECORDING_NOGAP")."</option>
		<option selected value='$recording_buttons'>"._QXZ("$recording_buttons")."</option>
		</select>$NWB#settings-recording_buttons$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Allow Mute Recordings").": </td><td align=left><select size=1 name=mute_recordings><option>1</option><option>0</option><option selected>$mute_recordings</option></select>$NWB#settings-mute_recordings$NWE</td></tr>\n";

		if ($stereo_dev_mode > 0)
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Allow Stereo Recordings").": </td><td align=left><select size=1 name=stereo_recording><option>1</option><option>0</option><option selected>$stereo_recording</option></select>$NWB#settings-stereo_recording$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Enable Stereo Parallel Recordings").": </td><td align=left><select size=1 name=stereo_parallel_recording><option>1</option><option>0</option><option selected>$stereo_parallel_recording</option></select>$NWB#settings-stereo_parallel_recording$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Allow Recording DTMF Detection").": </td><td align=left><select size=1 name=recording_dtmf_detection><option>1</option><option>0</option><option selected>$recording_dtmf_detection</option></select>$NWB#settings-recording_dtmf_detection$NWE</td></tr>\n";
			echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Allow Recording DTMF Muting").": </td><td align=left><select size=1 name=recording_dtmf_muting><option>1</option><option>0</option><option selected>$recording_dtmf_muting</option></select>$NWB#settings-recording_dtmf_muting$NWE</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row3_background><td colspan=2>\n";
			echo "<input type=hidden name=stereo_recording value=\"$stereo_recording\">";
			echo "<input type=hidden name=stereo_parallel_recording value=\"$stereo_parallel_recording\">";
			echo "<input type=hidden name=recording_dtmf_detection value=\"$recording_dtmf_detection\">";
			echo "<input type=hidden name=recording_dtmf_muting value=\"$recording_dtmf_muting\">";
			echo "</td></tr>\n";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("First Login Trigger").": </td><td align=left><input type=hidden name=first_login_trigger value=\"$first_login_trigger\"> "._QXZ("$first_login_trigger")." &nbsp; $NWB#settings-first_login_trigger$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User Password Minimum Length").": </td><td align=left><select size=1 name=require_password_length><option>0</option><option>12</option><option>14</option><option>16</option><option>18</option><option>20</option><option>25</option><option>30</option><option>35</option><option>40</option><option>45</option><option>50</option><option>60</option><option>70</option><option selected>$require_password_length</option></select>$NWB#settings-require_password_length$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><img src=\"images/2FA_icon.png\" alt=\"Two-Factor-Authentication Admin\" width=12 height=12> "._QXZ("Two-Factor Admin Auth Hours").": </td><td align=left><input type=text name=two_factor_auth_hours size=5 maxlength=4 value=\"$two_factor_auth_hours\">$NWB#settings-two_factor_auth_hours$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><img src=\"images/2FA_icon.png\" alt=\"Two-Factor-Authentication Agent\" width=12 height=12> "._QXZ("Two-Factor Agent Auth Hours").": </td><td align=left><input type=text name=two_factor_auth_agent_hours size=5 maxlength=4 value=\"$two_factor_auth_agent_hours\">$NWB#settings-two_factor_auth_agent_hours$NWE</td></tr>\n";

		$two_factor_container_stmt="SELECT container_id from vicidial_settings_containers where container_type='2FA_SETTINGS' order by container_id asc";
		$two_factor_container_rslt=mysql_to_mysqli($two_factor_container_stmt, $link);
		$two_factor_container_list="<option value='---DISABLED---'>---DISABLED---</option>\n";
		while ($pcr_row=mysqli_fetch_row($two_factor_container_rslt))
			{
			$two_factor_container_list.="<option value='$pcr_row[0]'>$pcr_row[0]</option>\n";
			}
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><img src=\"images/2FA_icon.png\" alt=\"Two-Factor-Authentication\" width=12 height=12> ";
		if ( (strlen($two_factor_container) > 0) and ($two_factor_container != '---DISABLED---') )
			{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$two_factor_container\">"._QXZ("Two-Factor Auth Config Container")."</a>";}
		else
			{echo _QXZ("Two-Factor Auth Config Container");}
		echo ": </td><td align=left><select size=1 name=two_factor_container>$two_factor_container_list<option selected value=\"$two_factor_container\">"._QXZ("$two_factor_container")."</option></select>$NWB#settings-two_factor_container$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User Login Link Emails Allowed").": </td><td align=left><select size=1 name=user_account_emails><option value=\"DISABLED\">"._QXZ("DISABLED")."</option><option value=\"SEND_NO_PASS\">"._QXZ("SEND_NO_PASS")."</option><option value=\"SEND_WITH_PASS\">"._QXZ("SEND_WITH_PASS")."</option><option selected value=\"$user_account_emails\">"._QXZ("$user_account_emails")."</option></select>$NWB#settings-user_account_emails$NWE</td></tr>\n";

		$phone_container_stmt="select container_id from vicidial_settings_containers where container_type='PHONE_DEFAULTS' order by container_id asc";
		$phone_container_rslt=mysql_to_mysqli($phone_container_stmt, $link);
		$phone_defaults_container_list="<option value='---DISABLED---'>---DISABLED---</option>\n";
		while ($pcr_row=mysqli_fetch_row($phone_container_rslt))
			{
			$phone_defaults_container_list.="<option value='$pcr_row[0]'>$pcr_row[0]</option>\n";
			}
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>";
		if ( (strlen($phone_defaults_container) > 0) and ($phone_defaults_container != '---DISABLED---') )
			{echo "<a href=\"$PHP_SELF?ADD=392111111111&container_id=$phone_defaults_container\">"._QXZ("Default Phone Settings Container")."</a>";}
		else
			{echo _QXZ("Default Phone Settings Container");}
		echo ": </td><td align=left><select size=1 name=phone_defaults_container>$phone_defaults_container_list<option selected value=\"$phone_defaults_container\">"._QXZ("$phone_defaults_container")."</option></select>$NWB#settings-phone_defaults_container$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Default Phone Registration Password").": </td><td align=left style=\"display:table-cell; vertical-align:middle;\" NOWRAP><input type=text id=reg_passX name=default_phone_registration_password size=40 maxlength=100 value=\"$default_phone_registration_password\" onkeyup=\"return pwdChanged('reg_passX','reg_pass_imgX','pass_lengthX','$SSrequire_password_length');\">$NWB#settings-default_phone_registration_password$NWE &nbsp; &nbsp; <font size=1>"._QXZ("Strength").":</font> <IMG id=reg_pass_imgX src='images/pixel.gif' style=\"vertical-align:middle;\" onLoad=\"return pwdChanged('reg_passX','reg_pass_imgX','pass_lengthX','$SSrequire_password_length');\"> &nbsp; <font size=1> "._QXZ("Length").": <span id=pass_lengthX name=pass_lengthX>0</span></font></td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Default Phone Login Password").": </td><td align=left style=\"display:table-cell; vertical-align:middle;\" NOWRAP><input type=text id=reg_passY name=default_phone_login_password size=40 maxlength=100 value=\"$default_phone_login_password\" onkeyup=\"return pwdChanged('reg_passY','reg_pass_imgY','pass_lengthY','$SSrequire_password_length');\">$NWB#settings-default_phone_login_password$NWE &nbsp; &nbsp; <font size=1>"._QXZ("Strength").":</font> <IMG id=reg_pass_imgY src='images/pixel.gif' style=\"vertical-align:middle;\" onLoad=\"return pwdChanged('reg_passY','reg_pass_imgY','pass_lengthY','$SSrequire_password_length');\"> &nbsp; <font size=1> "._QXZ("Length").": <span id=pass_lengthY name=pass_lengthY>0</span></font></td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Default Server Password").": </td><td align=left style=\"display:table-cell; vertical-align:middle;\" NOWRAP><input type=text id=reg_passZ name=default_server_password size=40 maxlength=100 value=\"$default_server_password\" onkeyup=\"return pwdChanged('reg_passZ','reg_pass_imgZ','pass_lengthZ','$SSrequire_password_length');\">$NWB#settings-default_server_password$NWE &nbsp; &nbsp; <font size=1>"._QXZ("Strength").":</font> <IMG id=reg_pass_imgZ src='images/pixel.gif' style=\"vertical-align:middle;\" onLoad=\"return pwdChanged('reg_passZ','reg_pass_imgZ','pass_lengthZ','$SSrequire_password_length');\"> &nbsp; <font size=1> "._QXZ("Length").": <span id=pass_lengthZ name=pass_lengthZ>0</span></font></td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Enable Automated Reports").": </td><td align=left><select size=1 name=enable_auto_reports><option>1</option><option>0</option><option selected>$enable_auto_reports</option></select>$NWB#settings-enable_auto_reports$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Report Default Format").": </td><td align=left><select size=1 name=report_default_format><option value=
		'TEXT'>"._QXZ("TEXT")."</option><option value='HTML'>"._QXZ("HTML")."</option><option selected value='$report_default_format'>"._QXZ("$report_default_format")."</option></select>$NWB#settings-report_default_format$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Secondary Database Server").": </td><td align=left><input type=text name=slave_db_server size=30 maxlength=50 value=\"$slave_db_server\">$NWB#settings-slave_db_server$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Reports to use Secondary DB").": </td><td align=left><select MULTIPLE size=5 name=reports_use_slave_db[]>\n";

		$Vreports_ARY = explode(',',$Vreports);
		$Vreports_ct = count($Vreports_ARY);
		$b=0;
		while ($b < $Vreports_ct)
			{
			$field_selected='';
			trim($Vreports_ARY[$b]);
			if (preg_match("/$Vreports_ARY[$b]/",$reports_use_slave_db))
				{$field_selected = 'SELECTED';}
			echo "<option value=\"$Vreports_ARY[$b]\" $field_selected>"._QXZ("$Vreports_ARY[$b]")."</option>\n";
			$b++;
			}
		echo "</select>$NWB#settings-reports_use_slave_db$NWE</td></tr>\n";

		$custom_stmt="show tables like 'vicidial_custom_reports'";
		$custom_rslt=mysql_to_mysqli($custom_stmt, $link);
		if (mysqli_num_rows($custom_rslt)>0) 
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom Reports to use Secondary DB").": </td><td align=left><select MULTIPLE size=5 name=custom_reports_use_slave_db[]>\n";
			echo "<option value='--NONE--'>"._QXZ("NONE")."</option>\n";
			$allowed_rpt_stmt="SELECT allowed_custom_reports from vicidial_user_groups where user_group='$LOGuser_group'";
			$allowed_rpt_rslt=mysql_to_mysqli($allowed_rpt_stmt, $link);
			$allowed_rpt_row=mysqli_fetch_row($allowed_rpt_rslt);
			$allowed_rpt_array=explode("|", $allowed_rpt_row[0]);

			if (count($allowed_rpt_array)>0) 
				{
				$custom_rpt_stmt="SELECT custom_reports_use_slave_db from system_settings";
				$custom_rpt_rslt=mysql_to_mysqli($custom_rpt_stmt, $link);
				$custom_rpt_row=mysqli_fetch_row($custom_rpt_rslt);
				$custom_rpt_array=explode(",", $custom_rpt_row[0]);

				for ($q=0; $q<count($allowed_rpt_array); $q++)
					{
					$report_name=$allowed_rpt_array[$q];
					if ($report_name!="") 
						{
						if (in_array($report_name, $custom_rpt_array)) {$x="selected";} else {$x="";}
						echo "<option value='$report_name' $x>"._QXZ("$report_name")."</option>\n";
						}
					}
				}
			echo "</select>$NWB#settings-custom_reports_use_slave_db$NWE";
			echo "</td></tr>";
			}

		if ( ($SSallow_custom_dialplan > 0) and ($LOGmodify_custom_dialplans > 0) )
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>"._QXZ("Custom Dialplan Entry").": $NWB#settings-custom_dialplan_entry$NWE <TEXTAREA NAME=custom_dialplan_entry ROWS=8 COLS=80>$custom_dialplan_entry</TEXTAREA></td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Reload Dialplan On Servers").": </td><td align=left><select size=1 name=reload_dialplan_on_servers><option>1</option><option selected>0</option></select>$NWB#settings-reload_dialplan_on_servers$NWE &nbsp;  &nbsp; "._QXZ("Last").": $reload_timestamp</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Custom Dialplan Entry").": </td><td align=left>Disabled <input type=hidden name=custom_dialplan_entry value=\"\">$NWB#settings-custom_dialplan_entry$NWE</td></tr>\n";
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Hide Label in Call Logs").": </td><td align=left><select size=1 name=label_hide_field_logs><option value='N'>"._QXZ("N")."</option><option value='Y'>"._QXZ("Y")."</option><option value='$label_hide_field_logs' SELECTED>"._QXZ("$label_hide_field_logs")."</option></select>$NWB#settings-label_hide_field_logs$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Title").": </td><td align=left><input type=text name=label_title size=20 maxlength=60 value=\"$label_title\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label First Name").": </td><td align=left><input type=text name=label_first_name size=20 maxlength=60 value=\"$label_first_name\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Middle Initial").": </td><td align=left><input type=text name=label_middle_initial size=20 maxlength=60 value=\"$label_middle_initial\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Last Name").": </td><td align=left><input type=text name=label_last_name size=20 maxlength=60 value=\"$label_last_name\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Address")."1: </td><td align=left><input type=text name=label_address1 size=20 maxlength=60 value=\"$label_address1\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Address")."2: </td><td align=left><input type=text name=label_address2 size=20 maxlength=60 value=\"$label_address2\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Address")."3: </td><td align=left><input type=text name=label_address3 size=20 maxlength=60 value=\"$label_address3\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label City").": </td><td align=left><input type=text name=label_city size=20 maxlength=60 value=\"$label_city\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label State").": </td><td align=left><input type=text name=label_state size=20 maxlength=60 value=\"$label_state\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Province").": </td><td align=left><input type=text name=label_province size=20 maxlength=60 value=\"$label_province\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Postal Code").": </td><td align=left><input type=text name=label_postal_code size=20 maxlength=60 value=\"$label_postal_code\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Vendor Lead Code").": </td><td align=left><input type=text name=label_vendor_lead_code size=20 maxlength=60 value=\"$label_vendor_lead_code\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Gender").": </td><td align=left><input type=text name=label_gender size=20 maxlength=60 value=\"$label_gender\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Phone Number").": </td><td align=left><input type=text name=label_phone_number size=20 maxlength=60 value=\"$label_phone_number\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Phone Code").": </td><td align=left><input type=text name=label_phone_code size=20 maxlength=60 value=\"$label_phone_code\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Alt Phone").": </td><td align=left><input type=text name=label_alt_phone size=20 maxlength=60 value=\"$label_alt_phone\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Security Phrase").": </td><td align=left><input type=text name=label_security_phrase size=20 maxlength=60 value=\"$label_security_phrase\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Email").": </td><td align=left><input type=text name=label_email size=20 maxlength=60 value=\"$label_email\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Comments").": </td><td align=left><input type=text name=label_comments size=20 maxlength=60 value=\"$label_comments\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Lead ID").": </td><td align=left><input type=text name=label_lead_id size=20 maxlength=60 value=\"$label_lead_id\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label List ID").": </td><td align=left><input type=text name=label_list_id size=20 maxlength=60 value=\"$label_list_id\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Entry Date").": </td><td align=left><input type=text name=label_entry_date size=20 maxlength=60 value=\"$label_entry_date\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Timezone").": </td><td align=left><input type=text name=label_gmt_offset_now size=20 maxlength=60 value=\"$label_gmt_offset_now\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Source ID").": </td><td align=left><input type=text name=label_source_id size=20 maxlength=60 value=\"$label_source_id\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Reset Code").": </td><td align=left><input type=text name=label_called_since_last_reset size=20 maxlength=60 value=\"$label_called_since_last_reset\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Status").": </td><td align=left><input type=text name=label_status size=20 maxlength=60 value=\"$label_status\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label User").": </td><td align=left><input type=text name=label_user size=20 maxlength=60 value=\"$label_user\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Date of Birth").": </td><td align=left><input type=text name=label_date_of_birth size=20 maxlength=60 value=\"$label_date_of_birth\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Country Code").": </td><td align=left><input type=text name=label_country_code size=20 maxlength=60 value=\"$label_country_code\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Last Call").": </td><td align=left><input type=text name=label_last_local_call_time size=20 maxlength=60 value=\"$label_last_local_call_time\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Called Count").": </td><td align=left><input type=text name=label_called_count size=20 maxlength=60 value=\"$label_called_count\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Rank").": </td><td align=left><input type=text name=label_rank size=20 maxlength=60 value=\"$label_rank\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Owner").": </td><td align=left><input type=text name=label_owner size=20 maxlength=60 value=\"$label_owner\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCCCCC><td align=right>"._QXZ("Label Entry List ID").": </td><td align=left><input type=text name=label_entry_list_id size=20 maxlength=60 value=\"$label_entry_list_id\">$NWB#settings-default_field_labels$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a name=\"screen_colors\"><a href=\"$PHP_SELF?ADD=382111111111&colors_id=$admin_screen_colors\"><font color=black>"._QXZ("Admin Screen Colors")."</font></a>: </td><td align=left><select size=1 name=admin_screen_colors><option value=\"default\">"._QXZ("default")."</option>\n";
		$stmt="SELECT colors_id,colors_name from vicidial_screen_colors where active='Y' $LOGadmin_viewable_groupsSQL order by colors_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$colors_to_print = mysqli_num_rows($rslt);
		$colors_list='';
		$o=0;
		while ($colors_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$colors_list .= "<option value=\"$rowx[0]\">"._QXZ("$rowx[0]")." - $rowx[1]</option>\n";
			$o++;
			}
		echo "$colors_list";
		echo "<option SELECTED value='$admin_screen_colors'>"._QXZ("$admin_screen_colors")."</option></select>$NWB#settings-admin_screen_colors$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=382111111111&colors_id=$agent_screen_colors\"><font color=black>"._QXZ("Agent Screen Colors")."</font></a>: </td><td align=left><select size=1 name=agent_screen_colors><option value=\"default\">"._QXZ("default")."</option>\n";
		$stmt="SELECT colors_id,colors_name from vicidial_screen_colors where active='Y' $LOGadmin_viewable_groupsSQL order by colors_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$colors_to_print = mysqli_num_rows($rslt);
		$colors_list='';
		$o=0;
		while ($colors_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$colors_list .= "<option value=\"$rowx[0]\">"._QXZ("$rowx[0]")." - $rowx[1]</option>\n";
			$o++;
			}
		echo "$colors_list";
		echo "<option SELECTED value='$agent_screen_colors'>"._QXZ("$agent_screen_colors")."</option></select>$NWB#settings-agent_screen_colors$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href=\"$PHP_SELF?ADD=382111111111&colors_id=$agent_chat_screen_colors\"><font color=black>"._QXZ("Agent Chat Screen Colors")."</font></a>: </td><td align=left><select size=1 name=agent_chat_screen_colors><option value=\"default\">"._QXZ("default")."</option>\n";
		$stmt="SELECT colors_id,colors_name from vicidial_screen_colors where active='Y' $LOGadmin_viewable_groupsSQL order by colors_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$colors_to_print = mysqli_num_rows($rslt);
		$colors_list='';
		$o=0;
		while ($colors_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$colors_list .= "<option value=\"$rowx[0]\">"._QXZ("$rowx[0]")." - $rowx[1]</option>\n";
			$o++;
			}
		echo "$colors_list";
		echo "<option SELECTED value='$agent_chat_screen_colors'>"._QXZ("$agent_chat_screen_colors")."</option></select>$NWB#settings-agent_chat_screen_colors$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("QC Features Active").": </td><td align=left><select size=1 name=qc_features_active><option>1</option><option>0</option><option selected>$qc_features_active</option></select>$NWB#settings-qc_features_active$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("QC Claim Limit").": </td><td align=left><input type='text' size='2' maxlength='3' name=qc_claim_limit value='$qc_claim_limit'>$NWB#settings-qc_claim_limit$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("QC Expire Days").": </td><td align=left><input type='text' size='2' maxlength='3' name=qc_expire_days value='$qc_expire_days'>$NWB#settings-qc_expire_days$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("QC Last Pull Time").": </td><td align=left> $qc_last_pull_time</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Default Codecs").": </td><td align=left><input type=text name=default_codecs size=40 maxlength=100 value=\"$default_codecs\">$NWB#settings-default_codecs$NWE</td></tr>\n";
		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Default Webphone").": </td><td align=left><select size=1 name=default_webphone><option>1</option><option>0</option><option selected>$default_webphone</option></select>$NWB#settings-default_webphone$NWE</td></tr>\n";
		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Default External Server IP").": </td><td align=left><select size=1 name=default_external_server_ip><option>1</option><option>0</option><option selected>$default_external_server_ip</option></select>$NWB#settings-default_external_server_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Webphone URL").": </td><td align=left><input type=text name=webphone_url size=50 maxlength=255 value=\"$webphone_url\">$NWB#settings-webphone_url$NWE</td></tr>\n";
		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Webphone System Key").": </td><td align=left><input type=text name=webphone_systemkey size=50 maxlength=100 value=\"$webphone_systemkey\">$NWB#settings-webphone_systemkey$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("No-Answer Log").": </td><td align=left><select size=1 name=noanswer_log><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$noanswer_log' selected>"._QXZ("$noanswer_log")."</option></select>$NWB#settings-noanswer_log$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("DID Agent Log").": </td><td align=left><select size=1 name=did_agent_log><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$did_agent_log' selected>"._QXZ("$did_agent_log")."</option></select>$NWB#settings-did_agent_log$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Alt-Log DB Server").": </td><td align=left><input type=text name=alt_log_server_ip size=18 maxlength=50 value=\"$alt_log_server_ip\">$NWB#settings-alt_log_server_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Alt-Log DB Name").": </td><td align=left><input type=text name=alt_log_dbname size=18 maxlength=50 value=\"$alt_log_dbname\">$NWB#settings-alt_log_dbname$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Alt-Log DB Login").": </td><td align=left><input type=text name=alt_log_login size=18 maxlength=50 value=\"$alt_log_login\">$NWB#settings-alt_log_login$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Alt-Log DB Password").": </td><td align=left><input type=text name=alt_log_pass size=18 maxlength=50 value=\"$alt_log_pass\">$NWB#settings-alt_log_pass$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Alt-Log Tables").": </td><td align=left><select MULTIPLE size=4 name=tables_use_alt_log_db[]>\n";
		$Vtables_ARY = explode(',',$Vtables);
		$Vtables_ct = count($Vtables_ARY);
		$b=0;
		while ($b < $Vtables_ct)
			{
			$field_selected='';
			trim($Vtables_ARY[$b]);
			if (preg_match("/$Vtables_ARY[$b]/",$tables_use_alt_log_db))
				{$field_selected = 'SELECTED';}
			echo "<option value=\"$Vtables_ARY[$b]\" $field_selected>"._QXZ("$Vtables_ARY[$b]")."</option>\n";
			$b++;
			}
		echo "</select>$NWB#settings-tables_use_alt_log_db$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Cold-Storage DB Server").": </td><td align=left><input type=text name=coldstorage_server_ip size=18 maxlength=50 value=\"$coldstorage_server_ip\">$NWB#settings-coldstorage_server_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Cold-Storage DB Name").": </td><td align=left><input type=text name=coldstorage_dbname size=18 maxlength=50 value=\"$coldstorage_dbname\">$NWB#settings-coldstorage_dbname$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Cold-Storage DB Login").": </td><td align=left><input type=text name=coldstorage_login size=18 maxlength=50 value=\"$coldstorage_login\">$NWB#settings-coldstorage_login$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Cold-Storage DB Password").": </td><td align=left><input type=text name=coldstorage_pass size=18 maxlength=50 value=\"$coldstorage_pass\">$NWB#settings-coldstorage_pass$NWE</td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row3_background><td align=right>"._QXZ("Cold-Storage DB Port").": </td><td align=left><input type=text name=coldstorage_port size=18 maxlength=50 value=\"$coldstorage_port\">$NWB#settings-coldstorage_port$NWE</td></tr>\n";

		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("Enable QueueMetrics Logging").": </td><td align=left><select size=1 name=enable_queuemetrics_logging><option>1</option><option>0</option><option selected>$enable_queuemetrics_logging</option></select>$NWB#settings-enable_queuemetrics_logging$NWE</td></tr>\n";
		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("QueueMetrics Server IP").": </td><td align=left><input type=text name=queuemetrics_server_ip size=18 maxlength=15 value=\"$queuemetrics_server_ip\">$NWB#settings-queuemetrics_server_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("QueueMetrics DB Name").": </td><td align=left><input type=text name=queuemetrics_dbname size=18 maxlength=50 value=\"$queuemetrics_dbname\">$NWB#settings-queuemetrics_dbname$NWE</td></tr>\n";
		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("QueueMetrics DB Login").": </td><td align=left><input type=text name=queuemetrics_login size=18 maxlength=50 value=\"$queuemetrics_login\">$NWB#settings-queuemetrics_login$NWE</td></tr>\n";
		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("QueueMetrics DB Password").": </td><td align=left><input type=text name=queuemetrics_pass size=18 maxlength=50 value=\"$queuemetrics_pass\">$NWB#settings-queuemetrics_pass$NWE</td></tr>\n";
		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("QueueMetrics URL").": </td><td align=left><input type=text name=queuemetrics_url size=50 maxlength=255 value=\"$queuemetrics_url\">$NWB#settings-queuemetrics_url$NWE</td></tr>\n";
		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("QueueMetrics Log ID").": </td><td align=left><input type=text name=queuemetrics_log_id size=12 maxlength=10 value=\"$queuemetrics_log_id\">$NWB#settings-queuemetrics_log_id$NWE</td></tr>\n";
		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("QueueMetrics EnterQueue Prepend").": </td><td align=left><select size=1 name=queuemetrics_eq_prepend>\n";
		echo "<option value=\"NONE\">"._QXZ("NONE")."</option>\n";
		echo "<option value=\"lead_id\">"._QXZ("lead_id")."</option>\n";
		echo "<option value=\"list_id\">"._QXZ("list_id")."</option>\n";
		echo "<option value=\"source_id\">"._QXZ("source_id")."</option>\n";
		echo "<option value=\"vendor_lead_code\">"._QXZ("vendor_lead_code")."</option>\n";
		echo "<option value=\"address3\">"._QXZ("address3")."</option>\n";
		echo "<option value=\"security_phrase\">"._QXZ("security_phrase")."</option>\n";
		echo "<option selected value=\"$queuemetrics_eq_prepend\">"._QXZ("$queuemetrics_eq_prepend")."</option>\n";
		echo "</select>$NWB#settings-queuemetrics_eq_prepend$NWE</td></tr>\n";
		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("QueueMetrics Login-Out").": </td><td align=left><select size=1 name=queuemetrics_loginout>\n";
		echo "<option value=\"STANDARD\">"._QXZ("STANDARD")."</option>\n";
		echo "<option value=\"CALLBACK\">"._QXZ("CALLBACK")."</option>\n";
		echo "<option value=\"NONE\">"._QXZ("NONE")."</option>\n";
		echo "<option selected value=\"$queuemetrics_loginout\">"._QXZ("$queuemetrics_loginout")."</option>\n";
		echo "</select>$NWB#settings-queuemetrics_loginout$NWE</td></tr>\n";
		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("QueueMetrics CallStatus").": </td><td align=left><select size=1 name=queuemetrics_callstatus><option>1</option><option>0</option><option selected>$queuemetrics_callstatus</option></select>$NWB#settings-queuemetrics_callstatus$NWE</td></tr>\n";
		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("QueueMetrics Addmember Enabled").": </td><td align=left><select size=1 name=queuemetrics_addmember_enabled><option>1</option><option>0</option><option selected>$queuemetrics_addmember_enabled</option></select>$NWB#settings-queuemetrics_addmember_enabled$NWE</td></tr>\n";
		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("QueueMetrics Dispo Pause Code").": </td><td align=left><input type=text name=queuemetrics_dispo_pause size=8 maxlength=6 value=\"$queuemetrics_dispo_pause\">$NWB#settings-queuemetrics_dispo_pause$NWE</td></tr>\n";
		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("QueueMetrics Pause Type Logging").": </td><td align=left><select size=1 name=queuemetrics_pause_type><option>1</option><option>0</option><option selected>$queuemetrics_pause_type</option></select>$NWB#settings-queuemetrics_pause_type$NWE</td></tr>\n";
		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("QueueMetrics PAUSEREASON Logging").": </td><td align=left><select size=1 name=queuemetrics_pausereason><option>STANDARD</option><option>EVERY_NEW</option><option>EVERY_NEW_ADMINCALL</option><option>EVERY_NEW_ALLCALL</option><option selected>$queuemetrics_pausereason</option></select>$NWB#settings-queuemetrics_pausereason$NWE</td></tr>\n";
		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("QueueMetrics Phone Environment Phone Append").": </td><td align=left><select size=1 name=queuemetrics_pe_phone_append><option>1</option><option>0</option><option selected>$queuemetrics_pe_phone_append</option></select>$NWB#settings-queuemetrics_pe_phone_append$NWE</td></tr>\n";
		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("QueueMetrics Hold Call Log").": </td><td align=left><select size=1 name=queuemetrics_record_hold><option>1</option><option>0</option><option selected>$queuemetrics_record_hold</option></select>$NWB#settings-queuemetrics_record_hold$NWE</td></tr>\n";
		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("QueueMetrics Socket Send").": </td><td align=left><select size=1 name=queuemetrics_socket><option value='NONE'>"._QXZ("NONE")."</option><option value='CONNECT_COMPLETE'>"._QXZ("CONNECT_COMPLETE")."</option><option selected value='$queuemetrics_socket'>"._QXZ("$queuemetrics_socket")."</option></select>$NWB#settings-queuemetrics_socket$NWE</td></tr>\n";
		echo "<tr bgcolor=#99FFCC><td align=right>"._QXZ("QueueMetrics Socket Send URL").": </td><td align=left><input type=text name=queuemetrics_socket_url size=60 maxlength=2000 value=\"$queuemetrics_socket_url\">$NWB#settings-queuemetrics_socket_url$NWE</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Enable Vtiger Integration").": </td><td align=left><select size=1 name=enable_vtiger_integration><option>1</option><option>0</option><option selected>$enable_vtiger_integration</option></select>$NWB#settings-enable_vtiger_integration$NWE\n";
		echo " &nbsp; <a href=\"./vtiger_user.php\" target=\"_blank\">"._QXZ("Click here to Synchronize users with Vtiger")."</a>\n";
		echo "</td></tr>\n";

		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Vtiger DB Server IP").": </td><td align=left><input type=text name=vtiger_server_ip size=18 maxlength=15 value=\"$vtiger_server_ip\">$NWB#settings-vtiger_server_ip$NWE</td></tr>\n";
		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Vtiger DB Name").": </td><td align=left><input type=text name=vtiger_dbname size=18 maxlength=50 value=\"$vtiger_dbname\">$NWB#settings-vtiger_dbname$NWE</td></tr>\n";
		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Vtiger DB Login").": </td><td align=left><input type=text name=vtiger_login size=18 maxlength=50 value=\"$vtiger_login\">$NWB#settings-vtiger_login$NWE</td></tr>\n";
		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Vtiger DB Password").": </td><td align=left><input type=text name=vtiger_pass size=18 maxlength=50 value=\"$vtiger_pass\">$NWB#settings-vtiger_pass$NWE</td></tr>\n";
		echo "<tr bgcolor=#CCFFFF><td align=right>"._QXZ("Vtiger URL").": </td><td align=left><input type=text name=vtiger_url size=50 maxlength=255 value=\"$vtiger_url\">$NWB#settings-vtiger_url$NWE</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("SUBMIT")."'</td></tr>\n";
		echo "</TABLE></center>\n";
		echo "</form>\n";

		$bas=0;   $bas_embed_output='';
		while ($browser_alert_sounds_listARY_ct > $bas)
			{
			$bas_embed_output .= "<audio id='BAS_$browser_alert_sounds_listARY[$bas]'><source src=\"../agc/sounds/".$browser_alert_sounds_listARY[$bas].".mp3\" type=\"audio/mpeg\"></audio>\n";
			$bas++;
			}
		echo "$bas_embed_output";
		echo "\n";

		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<br><br><a href=\"$PHP_SELF?ADD=720000000000000&category=SYSTEMSETTINGS&stage=system_settings\">"._QXZ("Click here to see Admin changes to the system settings")."</FONT>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=321111111111111 modify vicidial system statuses
######################
if ($ADD==321111111111111)
	{
	if ( ($LOGmodify_servers==1) or ($LOGmodify_statuses==1) )
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=321111111111111";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_statuses.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>\n";
		echo "<b>"._QXZ("STATUSES WITHIN THIS SYSTEM").": &nbsp; $NWB#system_statuses$NWE</b><br>\n";
		echo "<center><TABLE width=700 cellspacing=3>\n";
		echo "<tr height='250'><td align=center valign=bottom><font size=2><b>"._QXZ("STATUS")."</b></font></td>\n";
		echo "<td align=center valign=bottom><font size=2><b>"._QXZ("DESCRIPTION")."</td>\n";
		echo "<td align=center valign=bottom><font size=2><b>"._QXZ("CATEGORY")."</td>\n";
		echo "<td align=center valign=top bgcolor=\"#ccffff\"><font size=2 class='vertical-text'><b>"._QXZ("AGENT SELECTABLE")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#99ffcc\"><font size=2 class='vertical-text'><b>"._QXZ("HUMAN ANSWER")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#ccffff\"><font size=2 class='vertical-text'><b>"._QXZ("SALE")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#99ffcc\"><font size=2 class='vertical-text'><b>"._QXZ("DNC")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#ccffff\"><font size=2 class='vertical-text'><b>"._QXZ("CUSTOMER CONTACT")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#99ffcc\"><font size=2 class='vertical-text'><b>"._QXZ("NOT INTERESTED")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#ccffff\"><font size=2 class='vertical-text'><b>"._QXZ("UNWORKABLE")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#99ffcc\"><font size=2 class='vertical-text'><b>"._QXZ("SCHEDULED CALLBACK")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#ccffff\"><font size=2 class='vertical-text'><b>"._QXZ("COMPLETED")."</B></font></td>\n";
		echo "<td align=center valign=top bgcolor=\"#99ffcc\"><font size=2 class='vertical-text'><b>"._QXZ("ANSWERING MACHINE")."</B></font></td>\n";
		echo "<td align=center valign=bottom><font size=1><b>"._QXZ("MIN SEC")."</td>\n";
		echo "<td align=center valign=bottom><font size=1><b>"._QXZ("MAX SEC")."</td>\n";
		echo "<td align=center valign=bottom><font size=2><b>"._QXZ("MODIFY/DELETE")."</td>\n";
		echo "</tr>\n";

		##### get status category listings for dynamic pulldown
		$stmt="SELECT vsc_id,vsc_name from vicidial_status_categories order by vsc_id desc";
		$rslt=mysql_to_mysqli($stmt, $link);
		$cats_to_print = mysqli_num_rows($rslt);
		$cats_list="";

		$o=0;
		while ($cats_to_print > $o)
			{
			$rowx=mysqli_fetch_row($rslt);
			$cats_list .= "<option value=\"$rowx[0]\">$rowx[0] - " . substr($rowx[1],0,20) . "</option>\n";
			$catsname_list["$rowx[0]"] = substr($rowx[1],0,20);
			$o++;
			}

		$stmt="SELECT status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable,scheduled_callback,completed,min_sec,max_sec,answering_machine from vicidial_statuses order by status;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$statuses_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($statuses_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$AScategory = $rowx[4];
			$o++;

			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

			echo "<tr $bgcolor><td><form action=$PHP_SELF method=POST>\n";
			echo "<input type=hidden name=ADD value=421111111111111>\n";
			echo "<input type=hidden name=stage value=modify>\n";
			echo "<input type=hidden name=status value=\"$rowx[0]\">\n";
			echo "<font size=2><B>$rowx[0]</B></td>\n";
			echo "<td><input type=text name=status_name size=20 maxlength=30 value=\"$rowx[1]\"></td>\n";
			echo "<td>\n";
			echo "<select size=1 name=category class=\"cust_form\">\n";
			echo "$cats_list";
			echo "<option selected value=\"$AScategory\">$AScategory - $catsname_list[$AScategory]</option>\n";
			echo "</select>\n";
			echo "\n";
			echo "</td><td bgcolor=\"#ccffff\"><select size=1 name=selectable class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$rowx[2]' selected>"._QXZ("$rowx[2]")."</option></select>\n";
			echo "</td><td bgcolor=\"#99ffcc\"><select size=1 name=human_answered class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$rowx[3]' selected>"._QXZ("$rowx[3]")."</option></select>\n";
			echo "</td><td bgcolor=\"#ccffff\"><select size=1 name=sale class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$rowx[5]' selected>"._QXZ("$rowx[5]")."</option></select>\n";
			echo "</td><td bgcolor=\"#99ffcc\"><select size=1 name=dnc class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$rowx[6]' selected>"._QXZ("$rowx[6]")."</option></select>\n";
			echo "</td><td bgcolor=\"#ccffff\"><select size=1 name=customer_contact class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$rowx[7]' selected>"._QXZ("$rowx[7]")."</option></select>\n";
			echo "</td><td bgcolor=\"#99ffcc\"><select size=1 name=not_interested class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$rowx[8]' selected>"._QXZ("$rowx[8]")."</option></select>\n";
			echo "</td><td bgcolor=\"#ccffff\"><select size=1 name=unworkable class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$rowx[9]' selected>"._QXZ("$rowx[9]")."</option></select>\n";
			echo "</td><td bgcolor=\"#99ffcc\"><select size=1 name=scheduled_callbacks class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$rowx[10]' selected>"._QXZ("$rowx[10]")."</option></select>\n";
			echo "</td><td bgcolor=\"#ccffff\"><select size=1 name=completed class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$rowx[11]' selected>"._QXZ("$rowx[11]")."</option></select>\n";
			echo "</td><td bgcolor=\"#99ffcc\"><select size=1 name=answering_machine class=\"cust_form\"><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$rowx[14]' selected>"._QXZ("$rowx[14]")."</option></select>\n";
			echo "</td>\n";
			echo "<td><input type=text name=min_sec size=3 maxlength=5 value=\"$rowx[12]\" class=\"cust_form\"></td>\n";
			echo "<td><input type=text name=max_sec size=3 maxlength=5 value=\"$rowx[13]\" class=\"cust_form\"></td>\n";
			echo "</td><td align=center nowrap><font size=1><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("MODIFY")."'> &nbsp; &nbsp; &nbsp; &nbsp; \n";
			echo " &nbsp; \n";
			
			if (preg_match("/^B$|^NA$|^DNC$|^NA$|^DROP$|^INCALL$|^QUEUE$|^NEW$/i",$rowx[0]))
				{
				echo "<DEL>"._QXZ("DELETE")."</DEL>\n";
				}
			else
				{
				echo "<a href=\"$PHP_SELF?ADD=421111111111111&status=$rowx[0]&stage=delete\">"._QXZ("DELETE")."</a>\n";
				}
			echo "</form></td></tr>\n";
			}

		echo "</table>\n";

		echo "<br>"._QXZ("ADD NEW SYSTEM STATUS")."<BR><form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=221111111111111>\n";
		echo _QXZ("Status").": <input type=text name=status_id size=7 maxlength=6> &nbsp; \n";
		echo _QXZ("Description").": <input type=text name=status_name size=30 maxlength=30> &nbsp; \n";
		echo _QXZ("Selectable").": <select size=1 name=selectable><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Human Answer").": <select size=1 name=human_answered><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option></select> <BR>\n";
		echo _QXZ("Sale").": <select size=1 name=sale><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("DNC").": <select size=1 name=dnc><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Customer Contact").": <select size=1 name=customer_contact><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Not Interested").": <select size=1 name=not_interested><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp;  <BR>\n";
		echo _QXZ("Unworkable").": <select size=1 name=unworkable><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Callback").": <select size=1 name=scheduled_callbacks><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Completed").": <select size=1 name=completed><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Answering Machine").": <select size=1 name=answering_machine><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Category").": \n";
		echo "<select size=1 name=category>\n";
		echo "$cats_list";
		echo "<option selected value=\"$AScategory\">$AScategory - $catsname_list[$AScategory]</option>\n";
		echo "</select> &nbsp; <BR>\n";
		echo "<input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("ADD")."'><BR>\n";

		echo "</FORM><br>\n";

		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=331111111111111 modify vicidial status categories
######################
if ($ADD==331111111111111)
	{
	if ( ($LOGmodify_servers==1) or ($LOGmodify_statuses==1) )
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=331111111111111";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_statusgroups.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br><center>\n";
		echo "<b>"._QXZ("STATUS CATEGORIES").": &nbsp; $NWB#status_categories$NWE</b><br>\n";
		echo "<TABLE width=700 cellspacing=3>\n";
		echo "<tr><td>"._QXZ("CATEGORY")."</td><td>"._QXZ("NAME")."</td><td>"._QXZ("STATUSES IN THIS CATEGORY")."</td></tr>\n";

		$stmt="SELECT vsc_id,vsc_name,vsc_description,tovdad_display,sale_category,dead_lead_category from vicidial_status_categories order by vsc_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$statuses_to_print = mysqli_num_rows($rslt);
		$o=0;
		while ($statuses_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			$Avsc_id[$o] =				$rowx[0];
			$Avsc_name[$o] =			$rowx[1];
			$Avsc_description[$o] =		$rowx[2];
			$Atovdad_display[$o] =		$rowx[3];
			$Asale_category[$o] =		$rowx[4];
			$Adead_lead_category[$o] =	$rowx[5];
			$o++;
			}
		$p=0;
		while ($o > $p)
			{
			if (preg_match("/1$|3$|5$|7$|9$/i", $p))
				{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
			else
				{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

			$CATstatuses='';
			$stmt="SELECT status from vicidial_statuses where category='$Avsc_id[$p]' order by status;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$statuses_to_print = mysqli_num_rows($rslt);
			$q=0;
			while ($statuses_to_print > $q) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$CATstatuses.=" $rowx[0]";
				$q++;
				}
			$stmt="SELECT status from vicidial_campaign_statuses where category='$Avsc_id[$p]' $LOGallowed_campaignsSQL order by status;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$statuses_to_print = mysqli_num_rows($rslt);
			$q=0;
			while ($statuses_to_print > $q) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$CATstatuses.=" $rowx[0]";
				$q++;
				}

			echo "<tr $bgcolor><td><form action=$PHP_SELF method=POST>\n";
			echo "<input type=hidden name=ADD value=431111111111111>\n";
			echo "<input type=hidden name=stage value=modify>\n";
			echo "<input type=hidden name=vsc_id value=\"$Avsc_id[$p]\">\n";
			echo "<font size=2><B>$Avsc_id[$p]</B></td>\n";
			echo "<td><input type=text name=vsc_name size=30 maxlength=50 value=\"$Avsc_name[$p]\"></td>\n";
			echo "<td><font size=1>\n";
			echo "$CATstatuses";
			echo "</td></tr>\n";
			echo "<tr $bgcolor>\n";
			echo "<td colspan=3>"._QXZ("To Realtime Display").": <select size=1 name=tovdad_display><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$Atovdad_display[$p]' selected>"._QXZ("$Atovdad_display[$p]")."</option></select> &nbsp; &nbsp; "._QXZ("Sale Category").": <select size=1 name=sale_category><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$Asale_category[$p]' selected>"._QXZ("$Asale_category[$p]")."</option></select> &nbsp; &nbsp; "._QXZ("Dead Lead Category").": <select size=1 name=dead_lead_category><option value='Y'>"._QXZ("Y")."</option><option value='N'>"._QXZ("N")."</option><option value='$Adead_lead_category[$p]' selected>"._QXZ("$Adead_lead_category[$p]")."</option></select> &nbsp; </td></tr>\n";
			echo "<tr $bgcolor><td colspan=3><font size=1>"._QXZ("Description").": <input type=text name=vsc_description size=90 maxlength=255 value=\"$Avsc_description[$p]\"></td></tr>\n";
			echo "<tr $bgcolor><td colspan=3 align=center><font size=1><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("MODIFY")."'> &nbsp; &nbsp; &nbsp; &nbsp; \n";
			echo " &nbsp; <a href=\"$PHP_SELF?ADD=431111111111111&vsc_id=$Avsc_id[$p]&stage=delete\">"._QXZ("DELETE")."</a></td></tr>\n";
			echo "<tr><td colspan=4><font size=1> &nbsp; </form></td></tr>\n";

			$p++;
			}
	
		echo "</table>\n";

		echo "<br>"._QXZ("ADD NEW STATUS CATEGORY")."<BR><form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=231111111111111>\n";
		echo _QXZ("Category ID").": <input type=text name=vsc_id size=20 maxlength=20> &nbsp; \n";
		echo _QXZ("Name").": <input type=text name=vsc_name size=20 maxlength=50> &nbsp; <BR>\n";
		echo _QXZ("TimeOnVDAD Display").": <select size=1 name=tovdad_display><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Sale Category").": <select size=1 name=sale_category><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; \n";
		echo _QXZ("Dead Lead Category").": <select size=1 name=dead_lead_category><option value='Y'>"._QXZ("Y")."</option><option value='N' SELECTED>"._QXZ("N")."</option></select> &nbsp; <BR>\n";
		echo _QXZ("Description").": <input type=text name=vsc_description size=80 maxlength=255> &nbsp; \n";
		echo "<input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("ADD")."'><BR>\n";

		echo "</FORM><br>\n";

		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=241111111111111 adds the new qc status code to the system
######################
if ($ADD==241111111111111)
	{
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
	$stmt="SELECT count(*) from vicidial_qc_codes where code='$code';";
	$rslt=mysql_to_mysqli($stmt, $link);
	$row=mysqli_fetch_row($rslt);
	if ($row[0] > 0)
		{echo "<br>"._QXZ("QC STATUS CODE NOT ADDED - there is already a qc status code in the system with this name").": $row[0]\n";}
	else
		{
		if ( (strlen($code) < 1) or (strlen($code_name) < 2) )
			{
			echo "<br>"._QXZ("QC STATUS CODE NOT ADDED - Please go back and look at the data you entered")."\n";
			echo "<br>"._QXZ("code must be between 1 and 8 characters in length")."\n";
			echo "<br>"._QXZ("code name must be between 2 and 30 characters in length")."\n";
			}
		else
			{
			echo "<br><b>"._QXZ("QC STATUS CODE ADDED").": $code_name - $code</B>\n";
			if (isset($_POST["qc_category"])) {$qc_category=$_POST["qc_category"];}

			$stmt="INSERT INTO vicidial_qc_codes (code,code_name,qc_result_type) values('$code','$code_name','$qc_category');";
			$rslt=mysql_to_mysqli($stmt, $link);

			### LOG INSERTION Admin Log Table ###
			$SQL_log = "$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='QCSTATUSES', event_type='ADD', record_id='$code', event_code='ADMIN ADD QC STATUS', event_sql=\"$SQL_log\", event_notes='';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}
		}
	$ADD=341111111111111;
	}


######################
# ADD=341111111111111 modify vicidial QC status code
######################
if ($ADD==341111111111111)
	{
	if ( ($LOGmodify_servers==1) and ($SSqc_features_active > 0) )
		{
		if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) )
			{
			$modify_url = "$PHP_SELF?ADD=341111111111111";
			$modify_footer_refresh=1;
			}
		echo "<TABLE><TR><TD>\n";
		echo "<img src=\"images/icon_black_qc.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br><center>\n";
		echo "<b>"._QXZ("QC STATUS CODES WITHIN THIS SYSTEM").": &nbsp; $NWB#vicidial_qc_status_codes$NWE</b><br>\n";
		echo "<TABLE width=600 cellspacing=3>\n";
		echo "<tr><td>"._QXZ("STATUS CODE")."</td><td>"._QXZ("DESCRIPTION")."</td><td>"._QXZ("QC CATEGORY")."</td><td>"._QXZ("MODIFY/DELETE")."</td></tr>\n";

		##### go through each QC status code
		$stmt="SELECT count(*) from vicidial_qc_codes;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$rowx=mysqli_fetch_row($rslt);
		if ($rowx[0] > 0)
			{
			$stmt="SELECT code,code_name,qc_result_type from vicidial_qc_codes order by code;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$statuses_to_print = mysqli_num_rows($rslt);
			$o=0;
			while ($statuses_to_print > $o)
				{
				$rowx=mysqli_fetch_row($rslt);
				$o++;

				if (preg_match("/1$|3$|5$|7$|9$/i", $o))
					{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';}
				else
					{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}

				echo "<tr $bgcolor><td><form action=$PHP_SELF method=POST>\n";
				echo "<input type=hidden name=ADD value=441111111111111>\n";
				echo "<input type=hidden name=stage value=modify>\n";
				echo "<input type=hidden name=code value=\"$rowx[0]\">\n";
				echo "<font size=2><B>$rowx[0]</B></td>\n";
				echo "<td><input type=text name=code_name size=20 maxlength=30 value=\"$rowx[1]\"></td>\n";
				echo "<td><font size=2><B>"._QXZ("$rowx[2]")."</B></td>\n";
				echo "<td align=center nowrap><font size=1><input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("MODIFY")."'> &nbsp; &nbsp; &nbsp; &nbsp; \n";
				echo " &nbsp; \n";

				if (preg_match("/^B$|^NA$|^DNC$|^NA$|^DROP$|^INCALL$|^QUEUE$|^NEW$/i",$rowx[0]))
					{
					echo "<DEL>"._QXZ("DELETE")."</DEL>\n";
					}
				else
					{
					echo "<a href=\"$PHP_SELF?ADD=441111111111111&code=$rowx[0]&stage=delete\">"._QXZ("DELETE")."</a>\n";
					}
				echo "</form></td></tr>\n";
				}
			}
		echo "</table>\n";

		echo "<br>"._QXZ("ADD NEW QC STATUS CODE")."<BR><form action=$PHP_SELF method=POST>\n";
		echo "<input type=hidden name=ADD value=241111111111111>\n";
		echo _QXZ("Status").": <input type=text name=code size=9 maxlength=8> &nbsp; \n";
		echo _QXZ("Description").": <input type=text name=code_name size=25 maxlength=30> \n";
		echo _QXZ("QC Category").": <select name=qc_category><option selected value=''>-"._QXZ("Choose")."-</option><option value='PASS'>"._QXZ("PASS")."</option><option value='FAIL'>"._QXZ("FAIL")."</option><option value='CANCEL'>"._QXZ("CANCEL")."</option><option value='COMMIT'>"._QXZ("COMMIT")."</option><BR>\n";
		echo "<input style='background-color:#$SSbutton_color' type=submit name=submit value='"._QXZ("ADD")."'><BR>\n";

		echo "</FORM><br>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=550 user search form
######################
if ($ADD==550)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	echo "<br>"._QXZ("SEARCH FOR A USER")."<form action=$PHP_SELF method=POST>\n";
	echo "<input type=hidden name=ADD value=660>\n";
	echo "<center><TABLE width=$section_width cellspacing=3>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User Number").": </td><td align=left><input type=text name=user size=20 maxlength=20></td></tr>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Full Name").": </td><td align=left><input type=text name=full_name size=30 maxlength=30></td></tr>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User Level").": </td><td align=left><select size=1 name=user_level><option selected>0</option><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option></select></td></tr>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("User Group").": </td><td align=left><select size=1 name=user_group>\n";

	$stmt="SELECT user_group,group_name from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group";
	$rslt=mysql_to_mysqli($stmt, $link);
	$groups_to_print = mysqli_num_rows($rslt);
	$o=0;
	$groups_list='';
	while ($groups_to_print > $o) 
		{
		$rowx=mysqli_fetch_row($rslt);
		$groups_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
		$o++;
		}
	echo "$groups_list</select></td></tr>\n";

	echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=search value='"._QXZ("search")."'></td></tr>\n";
	echo "</TABLE></center>\n";
	}


######################
# ADD=660 user search results
######################
if ($ADD==660)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$SQL = '';
	if ($user) {$SQL .= " user LIKE \"%$user%\" and";}
	if ($full_name) {$SQL .= " full_name LIKE \"%$full_name%\" and";}
	if ($user_level > 0) {$SQL .= " user_level LIKE \"%$user_level%\" and";}
	if ($user_group) {$SQL .= " user_group = '$user_group' and";}
	$SQL = preg_replace('/\sand$/i', '', $SQL);
	if (strlen($SQL)>5) {$SQL = "and $SQL";}

	$stmt="SELECT user_id,user,pass,full_name,user_level,user_group,phone_login,phone_pass,delete_users,delete_user_groups,delete_lists,delete_campaigns,delete_ingroups,delete_remote_agents,load_leads,campaign_detail,ast_admin_access,ast_delete_phones,delete_scripts,modify_leads,hotkeys_active,change_agent_campaign,agent_choose_ingroups,closer_campaigns,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,delete_filters,alter_agent_interface_options,closer_default_blended,delete_call_times,modify_call_times,modify_users,modify_campaigns,modify_lists,modify_scripts,modify_filters,modify_ingroups,modify_usergroups,modify_remoteagents,modify_servers,view_reports,vicidial_recording_override,alter_custdata_override,qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit,add_timeclock_log,modify_timeclock_log,delete_timeclock_log,alter_custphone_override,vdc_agent_api_access,modify_inbound_dids,delete_inbound_dids,active,alert_enabled,download_lists,agent_shift_enforcement_override,manager_shift_enforcement_override,shift_override_flag,export_reports,delete_from_dnc,email,user_code,territory,allow_alerts,export_gdpr_leads from vicidial_users where user_level <= $LOGuser_level $LOGadmin_viewable_groupsSQL $SQL order by full_name desc;";
#	echo "\n|$stmt|\n";
	$rslt=mysql_to_mysqli($stmt, $link);
	$people_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("SEARCH RESULTS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";

	$o=0;
	while ($people_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
		else
			{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}
		echo "<tr $bgcolor><td><font size=1>$row[1]</td><td><font size=1>$row[3]</td><td><font size=1>$row[4]</td><td><font size=1>$row[5]</td>";
		echo "<td><font size=1><a href=\"$PHP_SELF?ADD=3&user=$row[1]\">"._QXZ("MODIFY")."</a> | <a href=\"./user_stats.php?user=$row[1]\">"._QXZ("STATS")."</a> | <a href=\"./user_status.php?user=$row[1]\">"._QXZ("STATUS")."</a> | <a href=\"./AST_agent_time_sheet.php?agent=$row[1]\">"._QXZ("TIME")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";

	}


######################################################################################################
######################################################################################################
#######   8 series, Callback lists
######################################################################################################
######################################################################################################

######################
# ADD=8 find all callbacks on hold by a User
######################
if ($ADD==8)
	{
	if ($LOGmodify_users==1)
		{
		if ($SUB==89)
			{
			$stmt="UPDATE vicidial_callbacks SET status='INACTIVE' where user='$user' and status IN('LIVE','ACTIVE') and callback_time < '$past_month_date';";
			$rslt=mysql_to_mysqli($stmt, $link);
			echo "<br>"._QXZ("User")."($user) "._QXZ("callback listings LIVE for more than one month have been made INACTIVE")."\n";
			}
		if ($SUB==899)
			{
			$stmt="UPDATE vicidial_callbacks SET status='INACTIVE' where user='$user' and status IN('LIVE','ACTIVE') and callback_time < '$past_week_date';";
			$rslt=mysql_to_mysqli($stmt, $link);
			echo "<br>"._QXZ("User")."($user) "._QXZ("callback listings LIVE for more than one week have been made INACTIVE")."\n";
			}
		}
	$CBinactiveLINK = "<BR><a href=\"./callbacks_bulk_move.php?days_uncalled=31&user=$user\">"._QXZ("Remove LIVE Callbacks older than one month for this user")."</a><BR><a href=\"./callbacks_bulk_move.php?days_uncalled=7&user=$user\">"._QXZ("Remove LIVE Callbacks older than one week for this user")."</a><BR>";

	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$CBquerySQLwhere = "and user='$user'";

	echo "<br>"._QXZ("USER CALLBACK HOLD LISTINGS").": $user\n";
	$oldADD = "ADD=8&user=$user";
	$ADD='82';
	}


######################
# ADD=81 find all callbacks on hold within a Campaign
######################
if ($ADD==81)
	{
	if ($LOGmodify_campaigns==1)
		{
		if ($SUB==89)
			{
			$stmt="UPDATE vicidial_callbacks SET status='INACTIVE' where campaign_id='$campaign_id' and status IN('LIVE','ACTIVE') and callback_time < '$past_month_date';";
			$rslt=mysql_to_mysqli($stmt, $link);
			echo "<br>"._QXZ("campaign")."($campaign_id) "._QXZ("callback listings LIVE for more than one month have been made INACTIVE")."\n";
			}
		if ($SUB==899)
			{
			$stmt="UPDATE vicidial_callbacks SET status='INACTIVE' where campaign_id='$campaign_id' and status IN('LIVE','ACTIVE') and callback_time < '$past_week_date';";
			$rslt=mysql_to_mysqli($stmt, $link);
			echo "<br>"._QXZ("campaign")."($campaign_id) "._QXZ("callback listings LIVE for more than one week have been made INACTIVE")."\n";
			}
		}
	$CBinactiveLINK = "<BR><a href=\"./callbacks_bulk_move.php?days_uncalled=31&campaign_id=$campaign_id\">"._QXZ("Remove LIVE Callbacks older than one month for this campaign")."</a><BR><a href=\"./callbacks_bulk_move.php?days_uncalled=7&campaign_id=$campaign_id\">"._QXZ("Remove LIVE Callbacks older than one week for this campaign")."</a><BR>";

	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$CBquerySQLwhere = "and campaign_id='$campaign_id'";

	echo "<br>"._QXZ("CAMPAIGN CALLBACK HOLD LISTINGS").": $campaign_id\n";
	$oldADD = "ADD=81&campaign_id=$campaign_id";
	$ADD='82';
	}


######################
# ADD=811 find all callbacks on hold within a List
######################
if ($ADD==811)
	{
	if ($LOGmodify_lists==1)
		{
		if ($SUB==89)
			{
			$stmt="UPDATE vicidial_callbacks SET status='INACTIVE' where list_id='$list_id' and status IN('LIVE','ACTIVE') and callback_time < '$past_month_date';";
			$rslt=mysql_to_mysqli($stmt, $link);
			echo "<br>"._QXZ("list")."($list_id) "._QXZ("callback listings LIVE for more than one month have been made INACTIVE")."\n";
			}
		if ($SUB==899)
			{
			$stmt="UPDATE vicidial_callbacks SET status='INACTIVE' where list_id='$list_id' and status IN('LIVE','ACTIVE') and callback_time < '$past_week_date';";
			$rslt=mysql_to_mysqli($stmt, $link);
			echo "<br>"._QXZ("list")."($list_id) "._QXZ("callback listings LIVE for more than one week have been made INACTIVE")."\n";
			}
		}
	$CBinactiveLINK = "<BR><a href=\"./callbacks_bulk_move.php?days_uncalled=31&list_id=$list_id\">"._QXZ("Remove LIVE Callbacks older than one month for this list")."</a><BR><a href=\"./callbacks_bulk_move.php?days_uncalled=7&list_id=$list_id\">"._QXZ("Remove LIVE Callbacks older than one week for this list")."</a><BR>";

	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$CBquerySQLwhere = "and list_id='$list_id'";

	echo "<br>"._QXZ("LIST CALLBACK HOLD LISTINGS").": $list_id\n";
	$oldADD = "ADD=811&list_id=$list_id";
	$ADD='82';
	}


######################
# ADD=8111 find all callbacks on hold within a user group
######################
if ($ADD==8111)
	{
	if ($LOGmodify_usergroups==1)
		{
		if ($SUB==89)
			{
			$stmt="UPDATE vicidial_callbacks SET status='INACTIVE' where user_group='$user_group' and status IN('LIVE','ACTIVE') and callback_time < '$past_month_date';";
			$rslt=mysql_to_mysqli($stmt, $link);
			echo "<br>"._QXZ("user group")."($user_group) "._QXZ("callback listings LIVE for more than one month have been made INACTIVE")."\n";
			}
		if ($SUB==899)
			{
			$stmt="UPDATE vicidial_callbacks SET status='INACTIVE' where user_group='$user_group' and status IN('LIVE','ACTIVE') and callback_time < '$past_week_date';";
			$rslt=mysql_to_mysqli($stmt, $link);
			echo "<br>"._QXZ("user group")."($user_group) "._QXZ("callback listings LIVE for more than one week have been made INACTIVE")."\n";
			}
		}
	$CBinactiveLINK = "<BR><a href=\"./callbacks_bulk_move.php?days_uncalled=31&user_group=$user_group\">"._QXZ("Remove LIVE Callbacks older than one month for this user group")."</a><BR><a href=\"./callbacks_bulk_move.php?days_uncalled=7&user_group=$user_group\">"._QXZ("Remove LIVE Callbacks older than one week for this user group")."</a><BR>";

	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$CBquerySQLwhere = "and user_group='$user_group'";

	echo "<br>"._QXZ("USER GROUP CALLBACK HOLD LISTINGS").": $list_id\n";
	$oldADD = "ADD=8111&user_group=$user_group";
	$ADD='82';
	}


######################
# ADD=82 display all callbacks on hold
######################
if ($ADD==82)
	{
	$USERlink='stage=USERIDDOWN';
	$GROUPlink='stage=GROUPDOWN';
	$ENDATElink='stage=ENDATEDOWN';
	$SQLorder='order by ';
	if (preg_match("/USERIDDOWN/i",$stage)) {$SQLorder='order by user desc,';   $USERlink='stage=USERIDUP';}
	if (preg_match("/GROUPDOWN/i",$stage)) {$SQLorder='order by user_group desc,';   $NAMElink='stage=NAMEUP';}
	if (preg_match("/ENDATEDOWN/i",$stage)) {$SQLorder='order by entry_time desc,';   $LEVELlink='stage=LEVELUP';}

	$stmt="SELECT callback_id,lead_id,list_id,campaign_id,status,entry_time,callback_time,modify_date,user,recipient,comments,user_group from vicidial_callbacks where status IN('ACTIVE','LIVE') $CBquerySQLwhere $SQLorder recipient,status desc,callback_time;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$cb_to_print = mysqli_num_rows($rslt);

	echo "<TABLE><TR><TD>\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>\n";
	echo "<td><font size=1 color=white>"._QXZ("LEAD")."</td><td><font size=1 color=white>"._QXZ("LIST")."</td>\n";
	echo "<td><font size=1 color=white> "._QXZ("CAMPAIGN")."</td>\n";
	echo "<td><a href=\"$PHP_SELF?$oldADD&$ENDATElink\"><font size=1 color=white><B>"._QXZ("ENTRY DATE")."</B></a></td>\n";
	echo "<td><font size=1 color=white>"._QXZ("CALLBACK DATE")."</td>\n";
	echo "<td><a href=\"$PHP_SELF?$oldADD&$USERlink\"><font size=1 color=white><B>"._QXZ("USER")."</B></a></td>\n";
	echo "<td><font size=1 color=white>"._QXZ("RECIPIENT")."</td>\n";
	echo "<td><font size=1 color=white>"._QXZ("STATUS")."</td>\n";
	echo "<td><a href=\"$PHP_SELF?$oldADD&$GROUPlink\"><font size=1 color=white><B>"._QXZ("GROUP")."</B></a></td></tr>\n";

	$o=0;
	while ($cb_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
		else
			{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}
		echo "<tr $bgcolor>";
		echo "<td><font size=1><A HREF=\"admin_modify_lead.php?lead_id=$row[1]\" onclick=\"javascript:window.open('admin_modify_lead.php?lead_id=$row[1]', '_blank');return false;\">$row[1]</A></font></td>\n";
		echo "<td><font size=1><A HREF=\"$PHP_SELF?ADD=311&list_id=$row[2]\">$row[2]</A></td>";
		echo "<td><font size=1><A HREF=\"$PHP_SELF?ADD=31&campaign_id=$row[3]\">$row[3]</A></td>";
		echo "<td><font size=1>$row[5]</td>";
		echo "<td><font size=1>$row[6]</td>";
		echo "<td><font size=1><A HREF=\"$PHP_SELF?ADD=3&user=$row[8]\">$row[8]</A></td>";
		echo "<td><font size=1>"._QXZ("$row[9]")."</td>";
		echo "<td><font size=1>"._QXZ("$row[4]")."</td>";
		echo "<td><font size=1><A HREF=\"$PHP_SELF?ADD=311111&user_group=$row[11]\">$row[11]</A></td>";
		echo "</tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";

	echo "$CBinactiveLINK";
	}





######################################################################################################
######################################################################################################
#######   0 series, displays and searches
######################################################################################################
######################################################################################################

######################
# ADD=0A display all active users
######################
if ($ADD=="0A")
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
	echo "<img src=\"images/icon_black_users.png\" alt=\"Users\" width=42 height=42> "._QXZ("USER LISTINGS").": ";
	if (preg_match('/display_all/',$status))
		{
		$SQLstatus = '';
		echo " &nbsp; <a href=\"$PHP_SELF?ADD=0A\"><font size=1 color=black>"._QXZ("show only active users")."</a>\n";
		}
	else
		{
		$SQLstatus = "and active='Y'";
		echo " &nbsp; <a href=\"$PHP_SELF?ADD=0A&status=display_all\"><font size=1 color=black>"._QXZ("show all users")."</a>\n";
		}

	$USERlink='stage=USERIDDOWN';
	$USERNUMlink='stage=USERIDNUMDOWN';
	$NAMElink='stage=NAMEDOWN';
	$LEVELlink='stage=LEVELDOWN';
	$GROUPlink='stage=GROUPDOWN';
	$SQLorder='order by full_name';
	if (preg_match("/USERIDUP/i",$stage)) {$SQLorder='order by user asc';   $USERlink='stage=USERIDDOWN';}
	if (preg_match("/USERIDDOWN/i",$stage)) {$SQLorder='order by user desc';   $USERlink='stage=USERIDUP';}
	if (preg_match("/USERIDNUMUP/i",$stage)) {$SQLorder='order by CAST(user as SIGNED INTEGER) desc';   $USERNUMlink='stage=USERIDNUMDOWN';}
	if (preg_match("/USERIDNUMDOWN/i",$stage)) {$SQLorder='order by CAST(user as SIGNED INTEGER) asc';   $USERNUMlink='stage=USERIDNUMUP';}
	if (preg_match("/NAMEUP/i",$stage)) {$SQLorder='order by full_name asc';   $NAMElink='stage=NAMEDOWN';}
	if (preg_match("/NAMEDOWN/i",$stage)) {$SQLorder='order by full_name desc';   $NAMElink='stage=NAMEUP';}
	if (preg_match("/LEVELUP/i",$stage)) {$SQLorder='order by user_level asc';   $LEVELlink='stage=LEVELDOWN';}
	if (preg_match("/LEVELDOWN/i",$stage)) {$SQLorder='order by user_level desc';   $LEVELlink='stage=LEVELUP';}
	if (preg_match("/GROUPUP/i",$stage)) {$SQLorder='order by user_group asc';   $GROUPlink='stage=GROUPDOWN';}
	if (preg_match("/GROUPDOWN/i",$stage)) {$SQLorder='order by user_group desc';   $GROUPlink='stage=GROUPUP';}
	$stmt="SELECT user,full_name,user_level,user_group,active from vicidial_users  where user_level <= $LOGuser_level $LOGadmin_viewable_groupsSQL $SQLstatus $SQLorder";
	$rslt=mysql_to_mysqli($stmt, $link);
	$people_to_print = mysqli_num_rows($rslt);

	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><a href=\"$PHP_SELF?ADD=0A&status=$status&$USERlink\"><font size=1 color=white><B>"._QXZ("USER ID")."</B></a> &nbsp; ";
	echo "<a href=\"$PHP_SELF?ADD=0A&status=$status&$USERNUMlink\"><font size=1 color=white><B>- # -</B></a></td>";
	echo "<td><a href=\"$PHP_SELF?ADD=0A&status=$status&$NAMElink\"><font size=1 color=white><B>"._QXZ("FULL NAME")."</B></a></td>";
	echo "<td><a href=\"$PHP_SELF?ADD=0A&status=$status&$LEVELlink\"><font size=1 color=white><B>"._QXZ("LEVEL")."</B></a></td>";
	echo "<td><a href=\"$PHP_SELF?ADD=0A&status=$status&$GROUPlink\"><font size=1 color=white><B>"._QXZ("GROUP")."</B></a></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ACTIVE")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("STATS")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("STATUS")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("TIME")."</B></td>";
	echo "</tr>\n";

	$o=0;
	while ($people_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';} 
		echo "<tr $bgcolor><td"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=3&user=$row[0]'\"";} echo "><a href=\"$PHP_SELF?ADD=3&user=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=3&user=$row[0]'\"";} echo "><font size=1>$row[1]</td>";
		echo "<td"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=3&user=$row[0]'\"";} echo "><font size=1>$row[2]</td>";
		echo "<td"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=3&user=$row[0]'\"";} echo "><font size=1>$row[3]</td>";
		echo "<td"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=3&user=$row[0]'\"";} echo "><font size=1>"._QXZ("$row[4]")."</td>";
		echo "<td align=center"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=3&user=$row[0]'\"";} echo "><font size=1><a href=\"$PHP_SELF?ADD=3&user=$row[0]\">"._QXZ("MODIFY")."</a></td>";
		echo "<td align=center"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='./user_stats.php?user=$row[0]'\"";} echo "><font size=1><a href=\"./user_stats.php?user=$row[0]\">"._QXZ("STATS")."</a></td>";
		echo "<td align=center"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='./user_status.php?user=$row[0]'\"";} echo "><font size=1><a href=\"./user_status.php?user=$row[0]\">"._QXZ("STATUS")."</a></td>";
		echo "<td align=center"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='./AST_agent_time_sheet.php?agent=$row[0]'\"";} echo "><font size=1><a href=\"./AST_agent_time_sheet.php?agent=$row[0]\">"._QXZ("TIME")."</a></td>\n";
		echo "</tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=10 display all campaigns
######################
if ($ADD==10)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if (file_exists('options.php'))
		{require('options.php');}

	echo "<img src=\"images/icon_black_campaigns.png\" alt=\"Campaigns\" width=42 height=42> "._QXZ("CAMPAIGN LISTINGS").":\n";
	if ( (preg_match('/display_active/',$status)) or ( (!preg_match('/display_all/',$status)) and ($active_only_default_campaigns > 0) ) )
		{
		$SQLstatus = 'Y';
		echo " &nbsp; <a href=\"$PHP_SELF?ADD=10&status=display_all\"><font size=1 color=black>"._QXZ("show all campaigns")."</a>\n";
		}
	else
		{
		$SQLstatus = '';
		echo " &nbsp; <a href=\"$PHP_SELF?ADD=10&status=display_active\"><font size=1 color=black>"._QXZ("show only active campaigns")."</a>\n";
		}

	$camp_group_SQL = $LOGadmin_viewable_groupsSQL;
	if (strlen($whereLOGallowed_campaignsSQL) < 6)
		{$camp_group_SQL = $whereLOGadmin_viewable_groupsSQL;}
	$stmt="SELECT campaign_id,campaign_name,active,dial_method,auto_dial_level,lead_order,dial_statuses,user_group,dial_prefix,three_way_dial_prefix,manual_dial_prefix from vicidial_campaigns $whereLOGallowed_campaignsSQL $camp_group_SQL order by campaign_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$campaigns_to_print = mysqli_num_rows($rslt);

	echo "<center><TABLE width=900 cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td NOWRAP><font size=1 color=white align=left><B>"._QXZ("CAMPAIGN ID")."</B></td>";
	echo "<td NOWRAP><font size=1 color=white><CENTER><B>"._QXZ("NAME")."</B></CENTER></td>";
	echo "<td NOWRAP><font size=1 color=white><B>"._QXZ("ACTIVE")." &nbsp; </B></td>";
	echo "<td NOWRAP><font size=1 color=white><B>"._QXZ("GROUP")." &nbsp; </B></td>";
	if ($SSoutbound_autodial_active > 0)
		{
		echo "<td NOWRAP><font size=1 color=white><B>"._QXZ("DIAL METHOD")." &nbsp; </B></td>";
		echo "<td NOWRAP><font size=1 color=white><B> "._QXZ("LEVEL")." &nbsp; </B></td>";
		echo "<td NOWRAP><font size=1 color=white><B>"._QXZ("LEAD ORDER")." &nbsp; </B></td>";
		echo "<td NOWRAP><font size=1 color=white><B>"._QXZ("DIAL STATUSES")." &nbsp; </B></td>";
		echo "<td NOWRAP><font size=1 color=white><B>"._QXZ("DP")." &nbsp; </B></td>";
		}
	echo "<td align=center NOWRAP><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0; $p=0;
	while ($campaigns_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		if ( ($SQLstatus!='') and ($row[2]=='N') )
			{$skip_display=1;}
		else
			{
			if (preg_match('/1$|3$|5$|7$|9$/i', $p))
				{$bgcolor='class="records_list_x"';} 
			else
				{$bgcolor='class="records_list_y"';}
			echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=34&campaign_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=34&campaign_id=$row[0]\"><font size=1 color=black>$row[0]</a> &nbsp; </td>";
			echo "<td><font size=1>$row[1] &nbsp; </td>";
			echo "<td><font size=1>"._QXZ("$row[2]")." &nbsp; </td>";
			echo "<td><font size=1>".(preg_match('/\-\-ALL\-\-/', $row[7]) ? _QXZ("$row[7]") : $row[7])." &nbsp; </td>";
			if ($SSoutbound_autodial_active > 0)
				{
				$dial_prefix =				$row[8];
				$three_way_dial_prefix =	$row[9];
				$manual_dial_prefix =		$row[10];
				$adtl_prefix=0;
				$dial_prefix_display = "$dial_prefix";
				if ( (strlen($manual_dial_prefix) > 0) and (!preg_match("/^$dial_prefix$/",$manual_dial_prefix)) )
					{$dial_prefix_display .= " - $manual_dial_prefix";   $adtl_prefix++;}
				if ( (strlen($three_way_dial_prefix) > 0) and (!preg_match("/^$dial_prefix$/",$three_way_dial_prefix)) )
					{$dial_prefix_display .= " - $three_way_dial_prefix";   $adtl_prefix++;}
				if ($adtl_prefix > 0)
					{$dial_prefix_display .= " &nbsp;";}
				
				echo "<td><font size=1>"._QXZ("$row[3]")." &nbsp; </td>";
				echo "<td><font size=1>$row[4] &nbsp; </td>";
				echo "<td><font size=1>"._QXZ("$row[5]")." &nbsp; </td>";
				echo "<td><font size=1>$row[6]</td>";
				echo "<td NOWRAP><font size=1> $dial_prefix_display </td>";
				}
			echo "<td><font size=1><a href=\"$PHP_SELF?ADD=31&campaign_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
			$p++;
			}
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=100 display all lists
######################
if ($ADD==100)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	##### get list of campaign IDs for validation of list campaign
	$stmt="SELECT campaign_id from vicidial_campaigns;";
	$rsltx=mysql_to_mysqli($stmt, $link);
	$camps_to_print = mysqli_num_rows($rsltx);
	$camp_list='|';
	$o=0;
	while ($camps_to_print > $o)
		{
		$rowx=mysqli_fetch_row($rsltx);
		$camp_list .= "$rowx[0]|";
		$o++;
		}

	$LISTlink='stage=LISTIDDOWN';
	$NAMElink='stage=LISTNAMEDOWN';
	$CALLTIMElink='stage=CALLTIMEDOWN';
	$TALLYlink='stage=TALLYDOWN';
	$ACTIVElink='stage=ACTIVEDOWN';
	$CAMPAIGNlink='stage=CAMPAIGNDOWN';
	$CALLDATElink='stage=CALLDATEDOWN';
	$SQLorder='order by list_id';
	if (preg_match('/LISTIDUP/i', $stage))		{$SQLorder='order by list_id asc';				$LISTlink='stage=LISTIDDOWN';}
	if (preg_match('/LISTIDDOWN/i', $stage))	{$SQLorder='order by list_id desc';				$LISTlink='stage=LISTIDUP';}
	if (preg_match('/LISTNAMEUP/i', $stage))	{$SQLorder='order by list_name asc';			$NAMElink='stage=LISTNAMEDOWN';}
	if (preg_match('/LISTNAMEDOWN/i', $stage))	{$SQLorder='order by list_name desc';			$NAMElink='stage=LISTNAMEUP';}
	if (preg_match('/CALLTIMEUP/i', $stage))	{$SQLorder='order by local_call_time asc';		$CALLTIMElink='stage=CALLTIMEDOWN';}
	if (preg_match('/CALLTIMEDOWN/i', $stage))	{$SQLorder='order by local_call_time desc';		$CALLTIMElink='stage=CALLTIMEUP';}	
	if (preg_match('/TALLYUP/i', $stage))		{$SQLorder='order by tally asc';				$TALLYlink='stage=TALLYDOWN';}
	if (preg_match('/TALLYDOWN/i', $stage))		{$SQLorder='order by tally desc';				$TALLYlink='stage=TALLYUP';}
	if (preg_match('/ACTIVEUP/i', $stage))		{$SQLorder='order by active asc';				$ACTIVElink='stage=ACTIVEDOWN';}
	if (preg_match('/ACTIVEDOWN/i', $stage))	{$SQLorder='order by active desc';				$ACTIVElink='stage=ACTIVEUP';}
	if (preg_match('/CAMPAIGNUP/i',$stage))		{$SQLorder='order by campaign_id asc';			$CAMPAIGNlink='stage=CAMPAIGNDOWN';}
	if (preg_match('/CAMPAIGNUP/i', $stage))	{$SQLorder='order by campaign_id desc';			$CAMPAIGNlink='stage=CAMPAIGNUP';}
	if (preg_match('/CALLDATEUP/i', $stage))	{$SQLorder='order by list_lastcalldate asc';	$CALLDATElink='stage=CALLDATEDOWN';}
	if (preg_match('/CALLDATEDOWN/i', $stage))	{$SQLorder='order by list_lastcalldate desc';	$CALLDATElink='stage=CALLDATEUP';}

	$list_hideSQL='';
	if ( ($SShide_inactive_lists > 0) and ($status != 'display_all') )
		{$list_hideSQL = "and active='Y'";}

	$stmt="SELECT vls.list_id,list_name,list_description,count(*) as tally,active,list_lastcalldate,campaign_id,reset_time,DATE_FORMAT(expiration_date,'%Y%m%d'),local_call_time from vicidial_lists vls,vicidial_list vl where vls.list_id=vl.list_id $LOGallowed_campaignsSQL $list_hideSQL group by list_id $SQLorder";
	if ( ($SSadmin_list_counts < 1) or ($rank != '999') )
		{$stmt="SELECT list_id,list_name,list_description,'X' as tally,active,list_lastcalldate,campaign_id,reset_time,DATE_FORMAT(expiration_date,'%Y%m%d'),local_call_time from vicidial_lists where active IN('Y','N') $list_hideSQL $LOGallowed_campaignsSQL $SQLorder";}
	$rslt=mysql_to_mysqli($stmt, $link);
	$lists_to_print = mysqli_num_rows($rslt);

	echo "<img src=\"images/icon_black_lists.png\" alt=\"Lists\" width=42 height=42> "._QXZ("LIST LISTINGS").": \n";
	$rankLINK="";
	if ($SSadmin_list_counts > 0)
		{
		if ($rank == '999')
			{
			$rankLINK = "&rank=999";
			echo " &nbsp; <a href=\"$PHP_SELF?ADD=100\"><font size=1 color=black>"._QXZ("hide list leads counts")."</font></a>\n";
			}
		else
			{
			$rankLINK = "";
			echo " &nbsp; <a href=\"$PHP_SELF?ADD=100&rank=999\"><font size=1 color=black>"._QXZ("show list leads counts")."</font></a>\n";
			}
		}
	if ($SShide_inactive_lists > 0)
		{
		if ($status == 'display_all')
			{
			echo " &nbsp; &nbsp; <a href=\"$PHP_SELF?ADD=100$rankLINK\"><font size=1 color=black>"._QXZ("hide inactive lists")."</font></a>\n";
			$rankLINK .= "&status=display_all";
			}
		else
			{
			echo " &nbsp; &nbsp; <a href=\"$PHP_SELF?ADD=100&status=display_all$rankLINK\"><font size=1 color=black>"._QXZ("show all lists")."</font></a>\n";
			}
		}
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<TR BGCOLOR=BLACK>";
	echo "<TD><a href=\"$PHP_SELF?ADD=100&$LISTlink$rankLINK\"><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("LIST ID")."</B></a></TD>";
	echo "<TD><a href=\"$PHP_SELF?ADD=100&$NAMElink$rankLINK\"><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("LIST NAME")."</B></a></TD>";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("DESCRIPTION")."</B></TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("RTIME")."</B></TD>\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=100&$TALLYlink$rankLINK\"><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("LEADS COUNT")."</B></a></TD>\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=100&campaign_id=$campaign_id&$CALLTIMElink$rankLINK\"><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("CALL TIME")."</B></a></TD>";
	echo "<TD><a href=\"$PHP_SELF?ADD=100&$ACTIVElink$rankLINK\"><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("ACTIVE")."</B></a></TD>";
	echo "<TD><a href=\"$PHP_SELF?ADD=100&$CALLDATElink$rankLINK\"><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("LAST CALL DATE")."</B></a></TD>";
	echo "<TD><a href=\"$PHP_SELF?ADD=100&$CAMPAIGNlink$rankLINK\"><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("CAMPAIGN")."</B></a></TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("MODIFY")."</TD>\n";
	echo "</TR>\n";

	$lists_printed = '';
	$o=0;
	while ($lists_to_print > $o)
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=311&list_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=311&list_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1> $row[1]</td>";
		echo "<td><font size=1> $row[2]</td>";
		echo "<td><font size=1> $row[7]</td>";
		echo "<td><font size=1> $row[3]</td>";
		if ($row[9] == 'campaign')
			{echo "<td><font size=1> $row[9]</td>";}
		else
			{echo "<td><font size=1><a href=\"$PHP_SELF?ADD=311111111&call_time_id=$row[9]\"> $row[9]</a></td>";}
		echo "<td><font size=1> "._QXZ("$row[4]");
		if ($row[8] < $EXPtestdate)
			{echo " <font color=red><B>"._QXZ("EXP")."</B></font>";}
		echo "</td>";
		echo "<td><font size=1> $row[5]</td>";
		if (!preg_match("/\|$row[6]\|/",$camp_list))
			{echo "<td><font size=1> <font color=red><B>$row[6]</B></font></td>";}
		else
			{echo "<td><font size=1> $row[6]</td>";}
		echo "<td><font size=1><a href=\"$PHP_SELF?ADD=311&list_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$lists_printed .= "'$row[0]',";
		$o++;
		}

	$stmt="SELECT list_id,list_name,list_description,0,active,list_lastcalldate,campaign_id,reset_time,DATE_FORMAT(expiration_date,'%Y%m%d'),local_call_time from vicidial_lists where list_id NOT IN($lists_printed'') $list_hideSQL $LOGallowed_campaignsSQL;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$lists_to_print = mysqli_num_rows($rslt);
	$p=0;
	while ($lists_to_print > $p)
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor><td><a href=\"$PHP_SELF?ADD=311&list_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1> $row[1]</td>";
		echo "<td><font size=1> $row[2]</td>";
		echo "<td><font size=1> $row[7]</td>";
		echo "<td><font size=1> $row[3]</td>";
		if ($row[9] == 'campaign')
			{echo "<td><font size=1> $row[9]</td>";}
		else
			{echo "<td><font size=1><a href=\"$PHP_SELF?ADD=311111111&call_time_id=$row[9]\"> $row[9]</a></td>";}
		echo "<td><font size=1> $row[4]";
		if ($row[8] < $EXPtestdate)
			{echo " <font color=red><B>"._QXZ("EXP")."</B></font>";}
		echo "</td>";
		echo "<td><font size=1> $row[5]</td>";
		if (!preg_match("/\|$row[6]\|/",$camp_list))
			{echo "<td><font size=1> <font color=red><B>$row[6]</B></font></td>";}
		else
			{echo "<td><font size=1> $row[6]</td>";}
		echo "<td><font size=1><a href=\"$PHP_SELF?ADD=311&list_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$p++;
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=130 display all drop lists
######################
if ($ADD==130)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT dl_id,dl_name,last_run,active,list_id,user_group,closer_campaigns from vicidial_drop_lists $whereLOGadmin_viewable_groupsSQL order by dl_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$droplists_to_print = mysqli_num_rows($rslt);

	echo _QXZ("DROP LISTS LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<TR BGCOLOR=BLACK>";
	echo "<TD><font size=1 color=white>"._QXZ("ID")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("DROP LIST NAME")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("LAST RUN")."</TD>\n";
	echo "<TD><font size=1 color=white>"._QXZ("ACTIVE")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("LIST ID")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("INGROUPS")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("ADMIN GROUP")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("MODIFY")."</TD>\n";
	echo "</TR>\n";

	$dl_id_ary = $MT;
	$dl_name_ary = $MT;
	$last_run_ary = $MT;
	$dl_active_ary = $MT;
	$list_id_ary = $MT;
	$group_group_ary = $MT;
	$closer_campaigns_ary = $MT;

	$o=0;
	while ($droplists_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		$dl_id_ary[$o] =			$row[0];
		$dl_name_ary[$o] =			$row[1];
		$last_run_ary[$o] =			$row[2];
		$dl_active_ary[$o] =		$row[3];
		$list_id_ary[$o] =			$row[4];
		$group_group_ary[$o] =		$row[5];
		$closer_campaigns_ary[$o] =	$row[6];
		$o++;
		}

	$o=0;
	while ($droplists_to_print > $o) 
		{
		$closer_campaigns_ary[$o] = preg_replace("/^ |^  | -$/",'',$closer_campaigns_ary[$o]);
		$ingroups_ary = explode(" ",$closer_campaigns_ary[$o]);
		$ingroups_ary_ct = count($ingroups_ary);
		$s=0;   $ingroups_ct=0;
		while($s < $ingroups_ary_ct)
			{
			if (strlen($ingroups_ary[$s])>1)
				{$ingroups_ct++;}
			$s++;
			}
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';}
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=331&dl_id=$dl_id_ary[$o]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=331&dl_id=$dl_id_ary[$o]\"><font size=1 color=black>$dl_id_ary[$o]</a></td>";
		echo "<td><font size=1> $dl_name_ary[$o]</td>";
		echo "<td><font size=1> $last_run_ary[$o]</td>";
		echo "<td><font size=1> "._QXZ("$dl_active_ary[$o]")."</td>";
		echo "<td><font size=1> $list_id_ary[$o]</td>";
		echo "<td><font size=1> $ingroups_ct</td>";
		echo "<td><font size=1>".(preg_match('/\-\-ALL\-\-/', $group_group_ary[$o]) ? _QXZ("$group_group_ary[$o]") : $group_group_ary[$o])."</td>";
		echo "<td><font size=1><a href=\"$PHP_SELF?ADD=331&dl_id=$dl_id_ary[$o]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=1001 display all inbound sections
######################
if ($ADD==1001)
	{
	$subhead_font = "style=\"font-family:HELVETICA;font-size:14;color:BLACK;font-weight:bold;\"";
	?>

	</head><BODY BGCOLOR=WHITE>
	<img src="images/icon_black_inbound.png" alt="Inbound" width=42 height=42> <FONT FACE="ARIAL,HELVETICA" SIZE=4><B> <?php echo _QXZ("Inbound"); ?></B></FONT><BR><CENTER>
	<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=0 WIDTH=800>
	<?php
	echo "<TR>\n";
	echo "<TD ALIGN=LEFT VALIGN=TOP WIDTH=100>&nbsp;\n";
	echo "</TD>\n";
	echo "<TD ALIGN=LEFT VALIGN=TOP WIDTH=720>\n";
	echo "<TABLE BORDER=0 CELLPADDING=3 CELLSPACING=5 WIDTH=100%>\n";
	echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1000';\"";} echo ">\n";
	echo "<TD ROWSPAN=3><a href=\"$PHP_SELF?ADD=1000\"><img src=\"images/icon_black_inbound.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
	echo "<TD ROWSPAN=3><a href=\"$PHP_SELF?ADD=1000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Inbound Groups")." </SPAN></a></TD>\n";
	echo "<TD CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1000';\"";} echo "><a href=\"$PHP_SELF?ADD=1000\" STYLE=\"text-decoration:none;\"><img src=\"images/icon_black_inbound.png\" border=0 width=11 height=11 valign=middle><FONT STYLE=\"font-family:HELVETICA;font-size:11;color:BLACK;\"> "._QXZ("Show In-Groups")." </FONT></a></TD></TR>\n";
	if ($add_copy_disabled < 1) {
	echo "<TD CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1111';\"";} echo "><a href=\"$PHP_SELF?ADD=1111\" STYLE=\"text-decoration:none;\"><img src=\"images/blank.gif\" border=0 alt=\" \" width=11 height=11 valign=middle><FONT STYLE=\"font-family:HELVETICA;font-size:11;color:BLACK;\"> "._QXZ("Add A New In-Group")." </FONT></a></TD></TR>\n";
	echo "<TD CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1211';\"";} echo "><a href=\"$PHP_SELF?ADD=1211\" STYLE=\"text-decoration:none;\"><img src=\"images/blank.gif\" border=0 alt=\" \" width=11 height=11 valign=middle><FONT STYLE=\"font-family:HELVETICA;font-size:11;color:BLACK;\"> "._QXZ("Copy In-Group")." </FONT></a></TD>\n";
	} else {echo "<TD></TD></TR><TD></TD>";}
	echo "</TR>\n";
	if ($SSemail_enabled>0) 
		{
		echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1800';\"";} echo ">\n";
		echo "<TD ROWSPAN=3><a href=\"$PHP_SELF?ADD=1800\"><img src=\"images/icon_email.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
		echo "<TD ROWSPAN=3><a href=\"$PHP_SELF?ADD=1800\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Email Groups")." </SPAN></a></TD>\n";
		echo "<TD CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1800';\"";} echo "><a href=\"$PHP_SELF?ADD=1800\" STYLE=\"text-decoration:none;\"><img src=\"images/icon_email.png\" border=0 alt=\"Email Groups\" width=11 height=11 valign=middle><FONT STYLE=\"font-family:HELVETICA;font-size:11;color:BLACK;\"> "._QXZ("Show Email Groups")." </FONT></a></TD></TR>\n";
		if ($add_copy_disabled < 1) {
		echo "<TD CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1811';\"";} echo "><a href=\"$PHP_SELF?ADD=1811\" STYLE=\"text-decoration:none;\"><img src=\"images/blank.gif\" border=0 alt=\" \" width=11 height=11 valign=middle><FONT STYLE=\"font-family:HELVETICA;font-size:11;color:BLACK;\"> "._QXZ("Add A New Email Group")." </FONT></a></TD></TR>\n";
		echo "<TD CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1911';\"";} echo "><a href=\"$PHP_SELF?ADD=1911\" STYLE=\"text-decoration:none;\"><img src=\"images/blank.gif\" border=0 alt=\" \" width=11 height=11 valign=middle><FONT STYLE=\"font-family:HELVETICA;font-size:11;color:BLACK;\"> "._QXZ("Copy Email Group")." </FONT></a></TD>\n";
		} else {echo "<TD></TD></TR><TD></TD>";}
		echo "</TR>\n";
		}
	if ($SSchat_enabled>0) 
		{
		echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1900';\"";} echo ">\n";
		echo "<TD ROWSPAN=3><a href=\"$PHP_SELF?ADD=1900\"><img src=\"images/icon_chat.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
		echo "<TD ROWSPAN=3><a href=\"$PHP_SELF?ADD=1900\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Chat Groups")." </SPAN></a></TD>\n";
		echo "<TD CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1900';\"";} echo "><a href=\"$PHP_SELF?ADD=1900\" STYLE=\"text-decoration:none;\"><img src=\"images/icon_chat.png\" border=0 alt=\" Chat Groups\" width=11 height=11 valign=middle><FONT STYLE=\"font-family:HELVETICA;font-size:11;color:BLACK;\"> "._QXZ("Show Chat Groups")." </FONT></a></TD></TR>\n";
		if ($add_copy_disabled < 1) {
		echo "<TD CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=18111';\"";} echo "><a href=\"$PHP_SELF?ADD=18111\" STYLE=\"text-decoration:none;\"><img src=\"images/blank.gif\" border=0 alt=\" \" width=11 height=11 valign=middle><FONT STYLE=\"font-family:HELVETICA;font-size:11;color:BLACK;\"> "._QXZ("Add A New Chat Group")." </FONT></a></TD></TR>\n";
		echo "<TD CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=19111';\"";} echo "><a href=\"$PHP_SELF?ADD=19111\" STYLE=\"text-decoration:none;\"><img src=\"images/blank.gif\" border=0 alt=\" \" width=11 height=11 valign=middle><FONT STYLE=\"font-family:HELVETICA;font-size:11;color:BLACK;\"> "._QXZ("Copy Chat Group")." </FONT></a></TD>\n";
		} else {echo "<TD></TD></TR><TD></TD>";}
		echo "</TR>\n";
		}
	echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1300';\"";} echo ">\n";
	echo "<TD ROWSPAN=3><a href=\"$PHP_SELF?ADD=1300\"><img src=\"images/icon_cidgroups.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
	echo "<TD ROWSPAN=3><a href=\"$PHP_SELF?ADD=1300\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Inbound DIDs")." </SPAN></a></TD>\n";
	echo "<TD CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1300';\"";} echo "><a href=\"$PHP_SELF?ADD=1300\" STYLE=\"text-decoration:none;\"><img src=\"images/icon_cidgroups.png\" border=0 alt=\" DIDs\" width=11 height=11 valign=middle><FONT STYLE=\"font-family:HELVETICA;font-size:11;color:BLACK;\"> "._QXZ("Show DIDs")." </FONT></a></TD></TR>\n";
		if ($add_copy_disabled < 1) {
	echo "<TD CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1311';\"";} echo "><a href=\"$PHP_SELF?ADD=1311\" STYLE=\"text-decoration:none;\"><img src=\"images/blank.gif\" border=0 alt=\" \" width=11 height=11 valign=middle><FONT STYLE=\"font-family:HELVETICA;font-size:11;color:BLACK;\"> "._QXZ("Add A New DID")." </FONT></a></TD></TR>\n";
	echo "<TD CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1411';\"";} echo "><a href=\"$PHP_SELF?ADD=1411\" STYLE=\"text-decoration:none;\"><img src=\"images/blank.gif\" border=0 alt=\" \" width=11 height=11 valign=middle><FONT STYLE=\"font-family:HELVETICA;font-size:11;color:BLACK;\"> "._QXZ("Copy DID")." </FONT></a></TD>\n";
	} else {echo "<TD></TD></TR><TD></TD>";}
	if ($SSdid_ra_extensions_enabled > 0)
		{
		echo "</TR><TD></TD><TD></TD><TD CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1320';\"";} echo "><a href=\"$PHP_SELF?ADD=1320\" STYLE=\"text-decoration:none;\"><img src=\"images/blank.gif\" border=0 alt=\" \" width=11 height=11 valign=middle><FONT STYLE=\"font-family:HELVETICA;font-size:11;color:BLACK;\"> "._QXZ("RA Extensions")." </FONT></a></TD>\n";
		}
	echo "</TR>\n";
	echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1500';\"";} echo ">\n";
	echo "<TD ROWSPAN=3><a href=\"$PHP_SELF?ADD=1500\"><img src=\"images/icon_callmenu.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
	echo "<TD ROWSPAN=3><a href=\"$PHP_SELF?ADD=1500\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Call Menus")." </SPAN></a></TD>\n";
	echo "<TD CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1500';\"";} echo "><a href=\"$PHP_SELF?ADD=1500\" STYLE=\"text-decoration:none;\"><img src=\"images/icon_callmenu.png\" border=0 alt=\" Call Menus\" width=11 height=11 valign=middle><FONT STYLE=\"font-family:HELVETICA;font-size:11;color:BLACK;\"> "._QXZ("Show Call Menus")." </FONT></a></TD></TR>\n";
	if ($add_copy_disabled < 1) {
	echo "<TD CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1511';\"";} echo "><a href=\"$PHP_SELF?ADD=1511\" STYLE=\"text-decoration:none;\"><img src=\"images/blank.gif\" border=0 alt=\" \" width=11 height=11 valign=middle><FONT STYLE=\"font-family:HELVETICA;font-size:11;color:BLACK;\"> "._QXZ("Add A New Call Menu")." </FONT></a></TD></TR>\n";
	echo "<TD CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1611';\"";} echo "><a href=\"$PHP_SELF?ADD=1611\" STYLE=\"text-decoration:none;\"><img src=\"images/blank.gif\" border=0 alt=\" \" width=11 height=11 valign=middle><FONT STYLE=\"font-family:HELVETICA;font-size:11;color:BLACK;\"> "._QXZ("Copy Call Menu")." </FONT></a></TD>\n";
	} else {echo "<TD></TD></TR><TD></TD>";}
	echo "</TR>\n";
	if ($LOGdelete_from_dnc > 0) {$FPGlink = _QXZ("Add-Delete FPG Number");}
	else {$FPGlink = _QXZ("Add FPG Number");}
	echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1700';\"";} echo ">\n";
	echo "<TD ROWSPAN=3><a href=\"$PHP_SELF?ADD=1700\"><img src=\"images/icon_filterphonegroup.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
	echo "<TD ROWSPAN=3><a href=\"$PHP_SELF?ADD=1700\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Filter Phone Groups")." </SPAN></a></TD>\n";
	echo "<TD CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1700';\"";} echo "><a href=\"$PHP_SELF?ADD=1700\" STYLE=\"text-decoration:none;\"><img src=\"images/icon_filterphonegroup.png\" border=0 alt=\" Filter Phone Groups\" width=11 height=11 valign=middle><FONT STYLE=\"font-family:HELVETICA;font-size:11;color:BLACK;\"> "._QXZ("Filter Phone Groups")." </FONT></a></TD></TR>\n";
		if ($add_copy_disabled < 1) {
	echo "<TD CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1711';\"";} echo "><a href=\"$PHP_SELF?ADD=1711\" STYLE=\"text-decoration:none;\"><img src=\"images/blank.gif\" border=0 alt=\" \" width=11 height=11 valign=middle><FONT STYLE=\"font-family:HELVETICA;font-size:11;color:BLACK;\"> "._QXZ("Add Filter Phone Group")." </FONT></a></TD></TR>\n";
	} else {echo "<TD></TD></TR>";}
	echo "<TD CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=171';\"";} echo "><a href=\"$PHP_SELF?ADD=171\" STYLE=\"text-decoration:none;\"><img src=\"images/blank.gif\" border=0 alt=\" \" width=11 height=11 valign=middle><FONT STYLE=\"font-family:HELVETICA;font-size:11;color:BLACK;\"> $FPGlink </FONT></a></TD>\n";
	echo "</TR>\n";
	echo "</TABLE>\n";
	echo "</TD>\n";

	echo "<TD ALIGN=LEFT VALIGN=TOP WIDTH=220>\n";
	echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=5 WIDTH=100%><TR><TD> &nbsp; </TD></TR>\n";
	echo "</TABLE>\n";
	echo "</TD>\n";

	echo "<TD ALIGN=LEFT VALIGN=TOP WIDTH=220>\n";
	echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=5 WIDTH=100%><TR><TD> &nbsp; </TD></TR>\n";
	echo "</TABLE>\n";
	echo "</TD>\n";

	echo "<TD ALIGN=LEFT VALIGN=TOP WIDTH=220>\n";
	echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=5 WIDTH=100%><TR><TD> &nbsp; </TD></TR>\n";
	echo "</TABLE>\n";
	echo "</TD>\n";

	echo "<TD WIDTH=100> &nbsp; \n";
	}


######################
# ADD=1000 display all inbound groups
######################
if ($ADD==1000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT group_id,group_name,queue_priority,active,call_time_id,group_color,user_group from vicidial_inbound_groups where group_handling='PHONE' $LOGadmin_viewable_groupsSQL order by group_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$ingroups_to_print = mysqli_num_rows($rslt);

	echo "<img src=\"images/icon_black_inbound.png\" alt=\"Inbound Groups\" width=42 height=42> "._QXZ("INBOUND GROUP LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<TR BGCOLOR=BLACK>";
	echo "<TD><font size=1 color=white>"._QXZ("IN-GROUP")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("NAME")."</TD>";
	echo "<TD colspan=2><font size=1 color=white>"._QXZ("PRIORITY")."</TD>\n";
	echo "<TD><font size=1 color=white>"._QXZ("ACTIVE")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("ADMIN GROUP")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("TIME")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("COLOR")."</TD>\n";
	echo "<TD><font size=1 color=white>"._QXZ("MODIFY")."</TD>\n";
	echo "</TR>\n";

	$group_id_ary = $MT;
	$group_name_ary = $MT;
	$group_priority_ary = $MT;
	$group_active_ary = $MT;
	$group_time_ary = $MT;
	$group_color_ary = $MT;
	$group_group_ary = $MT;

	$o=0;
	while ($ingroups_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		$group_id_ary[$o] =			$row[0];
		$group_name_ary[$o] =		$row[1];
		$group_priority_ary[$o] =	$row[2];
		$group_active_ary[$o] =		$row[3];
		$group_time_ary[$o] =		$row[4];
		$group_color_ary[$o] =		$row[5];
		$group_group_ary[$o] =		$row[6];
		$o++;
		}

	$o=0;
	while ($ingroups_to_print > $o) 
		{
		$allowed_campaigns_count=0;
		$allowed_campaigns_warning='';
		$SQL_group_id = preg_replace("/_/",'\\_',$group_id_ary[$o]);
		$stmt="SELECT count(*) from vicidial_campaigns where closer_campaigns LIKE \"% $SQL_group_id %\" $LOGallowed_campaignsSQL;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$campin_to_print = mysqli_num_rows($rslt);
		$vc_allowed_ct=0;
		if ($campin_to_print > $vc_allowed_ct) 
			{
			$row=mysqli_fetch_row($rslt);
			$allowed_campaigns_count = $row[0];
			$vc_allowed_ct++;
			}
		if ($allowed_campaigns_count < 1)
			{$allowed_campaigns_warning='<font color=red><b> &nbsp; NA</b></font>';}

		$icbq_LIVE_count='';
		$stmt="SELECT count(*) from vicidial_inbound_callback_queue where group_id='$group_id_ary[$o]' and icbq_status='LIVE';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$icbq_to_print = mysqli_num_rows($rslt);
		if ($icbq_to_print > 0) 
			{
			$row=mysqli_fetch_row($rslt);
			if ($row[0] > 0)
				{$icbq_LIVE_count = "<font color=red><b> $row[0]</b></font>";}
			}

		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';}
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=3111&group_id=$group_id_ary[$o]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=3111&group_id=$group_id_ary[$o]\"><font size=1 color=black>$group_id_ary[$o]</a></td>";
		echo "<td><font size=1> $group_name_ary[$o]</td>";
		echo "<td><font size=1> $group_priority_ary[$o]</td>";
		echo "<td><font size=1> $icbq_LIVE_count</td>";
		echo "<td><font size=1> "._QXZ("$group_active_ary[$o]")." $allowed_campaigns_warning</td>";
		echo "<td><font size=1> ".(preg_match('/\-\-ALL\-\-/', $group_group_ary[$o]) ? _QXZ("$group_group_ary[$o]") : $group_group_ary[$o])."</td>";
		echo "<td><font size=1> $group_time_ary[$o]</td>";
		echo "<td bgcolor=\"$group_color_ary[$o]\"><font size=1> &nbsp;</td>";
		echo "<td><font size=1><a href=\"$PHP_SELF?ADD=3111&group_id=$group_id_ary[$o]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=1800 display all email groups
######################
if ( ($ADD==1800) and ($SSallow_emails>0) )
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT group_id,group_name,queue_priority,active,call_time_id,group_color,user_group from vicidial_inbound_groups where group_handling='EMAIL' $LOGadmin_viewable_groupsSQL order by group_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$ingroups_to_print = mysqli_num_rows($rslt);

	echo "<img src=\"images/icon_email.png\" alt=\"Email Groups\" width=42 height=42> "._QXZ("EMAIL GROUP LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<TR BGCOLOR=BLACK>";
	echo "<TD><font size=1 color=white>"._QXZ("IN-GROUP")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("NAME")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("PRIORITY")."</TD>\n";
	echo "<TD><font size=1 color=white>"._QXZ("ACTIVE")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("UNREAD EMAILS")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("ADMIN GROUP")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("TIME")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("COLOR")."</TD>\n";
	echo "<TD><font size=1 color=white>"._QXZ("MODIFY")."</TD>\n";
	echo "</TR>\n";

	$o=0;
	while ($ingroups_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);

		## Get unhandled count
		$ct_stmt="SELECT count(*) From vicidial_email_list where status='NEW' and group_id='$row[0]'";
		$ct_rslt=mysql_to_mysqli($ct_stmt, $link);
		$ct_row=mysqli_fetch_row($ct_rslt);
		$unhandled_emails=$ct_row[0];
		
		$allowed_campaigns_warning='';
		## Get campaign allowed count
		$SQL_group_id = preg_replace("/_/",'\\_',$row[0]);
		$ct_stmt="SELECT count(*) from vicidial_campaigns where closer_campaigns LIKE \"% $SQL_group_id %\" $LOGallowed_campaignsSQL;";
		$ct_rslt=mysql_to_mysqli($ct_stmt, $link);
		$ct_row=mysqli_fetch_row($ct_rslt);
		$email_allowed_campaigns_count=$ct_row[0];
		if ($email_allowed_campaigns_count < 1)
			{$allowed_campaigns_warning='<font color=red><b> &nbsp; NA</b></font>';}
		
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=3811&group_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=3811&group_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1> $row[1]</td>";
		echo "<td><font size=1> $row[2]</td>";
		echo "<td><font size=1> "._QXZ("$row[3]")." $allowed_campaigns_warning</td>";
		echo "<td><font size=1> $unhandled_emails</td>";
		echo "<td><font size=1> ".(preg_match('/\-\-ALL\-\-/', $row[6]) ? _QXZ("$row[6]") : $row[6])."</td>";
		echo "<td><font size=1> $row[4]</td>";
		echo "<td bgcolor=\"$row[5]\"><font size=1> &nbsp;</td>";
		echo "<td><font size=1><a href=\"$PHP_SELF?ADD=3811&group_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=1900 display all chat groups
######################
if ( ($ADD==1900) and ($SSallow_chats>0) )
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT group_id,group_name,queue_priority,active,call_time_id,group_color,user_group from vicidial_inbound_groups where group_handling='CHAT' $LOGadmin_viewable_groupsSQL order by group_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$ingroups_to_print = mysqli_num_rows($rslt);

	echo "<img src=\"images/icon_chat.png\" alt=\"Chat Groups\" width=42 height=42> "._QXZ("CHAT GROUP LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<TR BGCOLOR=BLACK>";
	echo "<TD><font size=1 color=white>"._QXZ("IN-GROUP")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("NAME")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("PRIORITY")."</TD>\n";
	echo "<TD><font size=1 color=white>"._QXZ("ACTIVE")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("ADMIN GROUP")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("TIME")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("COLOR")."</TD>\n";
	echo "<TD><font size=1 color=white>"._QXZ("MODIFY")."</TD>\n";
	echo "</TR>\n";

	$o=0;
	while ($ingroups_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);

		$allowed_campaigns_warning='';
		## Get campaign allowed count
		$SQL_group_id = preg_replace("/_/",'\\_',$row[0]);
		$ct_stmt="SELECT count(*) from vicidial_campaigns where closer_campaigns LIKE \"% $SQL_group_id %\" $LOGallowed_campaignsSQL;";
		$ct_rslt=mysql_to_mysqli($ct_stmt, $link);
		$ct_row=mysqli_fetch_row($ct_rslt);
		$chat_allowed_campaigns_count=$ct_row[0];
		if ($chat_allowed_campaigns_count < 1)
			{$allowed_campaigns_warning='<font color=red><b> &nbsp; NA</b></font>';}
		
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=3911&group_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=3911&group_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1> $row[1]</td>";
		echo "<td><font size=1> $row[2]</td>";
		echo "<td><font size=1> "._QXZ("$row[3]")." $allowed_campaigns_warning</td>";
		echo "<td><font size=1> ".(preg_match('/\-\-ALL\-\-/', $row[6]) ? _QXZ("$row[6]") : $row[6])."</td>";
		echo "<td><font size=1> $row[4]</td>";
		echo "<td bgcolor=\"$row[5]\"><font size=1> &nbsp;</td>";
		echo "<td><font size=1><a href=\"$PHP_SELF?ADD=3911&group_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=1300 display all inbound dids
######################
if ($ADD==1300)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$DIDlink="stage=DIDDOWN&status=$status";
	$DESClink="stage=DESCDOWN&status=$status";
	$CARRIERlink="stage=CARRIERDOWN&status=$status";
	$ACTIVElink="stage=ACTIVEDOWN&status=$status";
	$GROUPlink="stage=GROUPDOWN&status=$status";
	$ROUTElink="stage=ROUTEDOWN&status=$status";
	$REClink="stage=RECDOWN&status=$status";
	$SQLorder='order by did_pattern';

	if ($did_pattern_filter)
		{
		$dpf_clause="and did_pattern like '%".$did_pattern_filter."%'";
		$DPFlink="&did_pattern_filter=".$did_pattern_filter;
		}
	else
		{
		$dpf_clause="";
		$DPFlink="";
		}

	if (preg_match("/DIDUP/i",$stage)) {$SQLorder='order by did_pattern asc';   $DIDlink="stage=DIDDOWN&status=$status";}
	if (preg_match("/DIDDOWN/i",$stage)) {$SQLorder='order by did_pattern desc';   $DIDlink="stage=DIDUP&status=$status";}
	if (preg_match("/DESCUP/i",$stage)) {$SQLorder='order by did_description asc';   $DESClink="stage=DESCDOWN&status=$status";}
	if (preg_match("/DESCDOWN/i",$stage)) {$SQLorder='order by did_description desc';   $DESClink="stage=DESCUP&status=$status";}
	if (preg_match("/CARRIERUP/i",$stage)) {$SQLorder='order by did_carrier_description asc';   $CARRIERlink="stage=CARRIERDOWN&status=$status";}
	if (preg_match("/CARRIERDOWN/i",$stage)) {$SQLorder='order by did_carrier_description desc';   $CARRIERlink="stage=CARRIERUP&status=$status";}
	if (preg_match("/ACTIVEUP/i",$stage)) {$SQLorder='order by did_active asc';   $ACTIVElink="stage=ACTIVEDOWN&status=$status";}
	if (preg_match("/ACTIVEDOWN/i",$stage)) {$SQLorder='order by did_active desc';   $ACTIVElink="stage=ACTIVEUP&status=$status";}
	if (preg_match("/GROUPUP/i",$stage)) {$SQLorder='order by user_group asc';   $GROUPlink="stage=GROUPDOWN&status=$status";}
	if (preg_match("/GROUPDOWN/i",$stage)) {$SQLorder='order by user_group desc';   $GROUPlink="stage=GROUPUP&status=$status";}
	if (preg_match("/ROUTEUP/i",$stage)) {$SQLorder='order by did_route asc';   $ROUTElink="stage=ROUTEDOWN&status=$status";}
	if (preg_match("/ROUTEDOWN/i",$stage)) {$SQLorder='order by did_route desc';   $ROUTElink="stage=ROUTEUP&status=$status";}
	if (preg_match("/RECUP/i",$stage)) {$SQLorder='order by record_call asc';   $REClink="stage=RECDOWN&status=$status";}
	if (preg_match("/RECDOWN/i",$stage)) {$SQLorder='order by record_call desc';   $REClink="stage=RECUP&status=$status";}

	$limitSQL='';
	$next_prev_HTML='';
	if ($SSentries_per_page > 0)
		{
		$stmt="SELECT count(*) from vicidial_inbound_dids where did_pattern!='did_system_filter' $dpf_clause $LOGadmin_viewable_groupsSQL";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$dids_count = $row[0];

		if ( ($dids_count > $SSentries_per_page) and ($status != 'display_all') )
			{
			if (strlen($start_count) < 1) {$start_count=0;}
			$next_count = ($start_count + $SSentries_per_page);
			$nextnext_count = ($next_count + $SSentries_per_page);
			if ($next_count > $dids_count) 
				{$next_count = $dids_count;}
			else
				{
				if ($nextnext_count > $dids_count) 
					{
					$next_temp = ($dids_count - $next_count);
					$nextHTML = "<a href=\"$PHP_SELF?ADD=1300&start_count=$next_count&stage=$stage$DPFlink\">"._QXZ("NEXT")." $next_temp</a> &nbsp; ";
					}
				else
					{
					$nextHTML = "<a href=\"$PHP_SELF?ADD=1300&start_count=$next_count&stage=$stage$DPFlink\">"._QXZ("NEXT")." $SSentries_per_page</a> &nbsp; ";
					}
				}
			$next_prev_HTML .= _QXZ("RECORDS")." $start_count - $next_count &nbsp; ";
			$limitSQL="limit $SSentries_per_page";
			if ($start_count > 0)
				{
				$prev_count = ($start_count - $SSentries_per_page);
				$limitSQL="limit $start_count,$SSentries_per_page";
				$next_prev_HTML .= "<a href=\"$PHP_SELF?ADD=1300&start_count=$prev_count&stage=$stage$DPFlink\">"._QXZ("PREVIOUS")." $SSentries_per_page</a> &nbsp; ";
				}
			$next_prev_HTML .= $nextHTML;
			$next_prev_HTML .= " &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; </b><a href=\"$PHP_SELF?ADD=1300&status=display_all&stage=$stage$DPFlink\"><font size=1 color=black>"._QXZ("show all DIDs")."</font></a><b> &nbsp; ";
			}
		else if ($status == 'display_all')
			{
			$next_prev_HTML .= "</b><a href=\"$PHP_SELF?ADD=1300&status=&stage=$stage$DPFlink\"><font size=1 color=black>"._QXZ("Show paginated DIDs")."</font></a><b> &nbsp; ";
			}
		}

	$stmt="SELECT did_id,did_pattern,did_description,did_carrier_description,did_active,did_route,record_call,user_group from vicidial_inbound_dids where did_pattern!='did_system_filter' $dpf_clause $LOGadmin_viewable_groupsSQL $SQLorder $limitSQL;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$dids_to_print = mysqli_num_rows($rslt);

	echo "<img src=\"images/icon_cidgroups.png\" alt=\"Inbound DIDs\" width=42 height=42> "._QXZ("INBOUND DID LISTINGS").":\n";
	if (strlen($next_prev_HTML) > 10)
		{echo "<br><b> &nbsp; $next_prev_HTML</b><br>";}
	echo "<center>\n";
	echo "<span name='adminDIDdisplay' id='adminDIDdisplay'>\n";
	echo "<form action='$PHP_SELF'>\n";
	echo "<input type='hidden' name='ADD' id='ADD' value='1300'>\n";
	echo "<input type='hidden' name='status' id='status' value='$status'>\n";
	echo "<input type='hidden' name='stage' id='stage' value='$stage'>\n";
	echo "<input type='hidden' name='start_count' id='start_count' value='$start_count'>\n";
	echo "<TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<TR bgcolor='#e6e6e6'>";
	echo "<TD colspan='2' align='right'><font size=1 color=black>Filter/search DIDs:</TD>";
	echo "<TD align='left'><input type='text' class='form_field' name='did_pattern_filter' id='did_pattern_filter' value='$did_pattern_filter' size='10' maxlength='20'>$NWB#inbound_dids-filter_search$NWE</TD>";
	echo "<TD colspan='6' align='left'><input type='submit' class='blue_btn' value='FILTER DIDS'>";
	if ($did_pattern_filter)
		{
#		echo "&nbsp; &nbsp; <input type='button' class='green_btn' value='SHOW ALL FILTERED DIDS' onclick=\"window.document.location='$PHP_SELF?ADD=1300&status=display_all&stage=$stage$DPFlink'\">";
#		echo "&nbsp; &nbsp; <input type='button' class='red_btn' value='SHOW ALL DIDS' onclick=\"window.document.location='$PHP_SELF?ADD=1300&stage=$stage&status=$status'\">";
		if ($dids_count > $SSentries_per_page)
			{
			#if ($status == 'display_all')
			#	{echo "&nbsp; &nbsp; &nbsp; <a href='$PHP_SELF?ADD=1300&stage=$stage$DPFlink'><font size='1' color='white'>Show paginated filtered DIDs</a>";}
			#else
			#	{echo "&nbsp; &nbsp; &nbsp; <a href='$PHP_SELF?ADD=1300&stage=$stage&status=display_all$DPFlink'><font size='1' color='white'>Show all filtered DIDs</a>";}
			}
		echo "&nbsp; &nbsp; &nbsp; <a href='$PHP_SELF?ADD=1300&stage=$stage&status=$status'><font size='1' color='black'>Clear filter</a>";
		}
	echo "</TD>";
	echo "</TR>\n";
	echo "<TR BGCOLOR=BLACK>";
	echo "<TD><font size=1 color=white>#</TD>";
	echo "<TD><a href=\"$PHP_SELF?ADD=1300&$DIDlink$DPFlink\"><font size=1 color=white><B>"._QXZ("DID")."</B></a></TD>";
	echo "<TD><a href=\"$PHP_SELF?ADD=1300&$DESClink$DPFlink\"><font size=1 color=white><B>"._QXZ("DESCRIPTION")."</B></a></TD>\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=1300&$CARRIERlink$DPFlink\"><font size=1 color=white><B>"._QXZ("CARRIER")."</B></a></TD>\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=1300&$ACTIVElink$DPFlink\"><font size=1 color=white><B>"._QXZ("ACTIVE")."</B></a></TD>";
	echo "<TD><a href=\"$PHP_SELF?ADD=1300&$GROUPlink$DPFlink\"><font size=1 color=white><B>"._QXZ("ADMIN GROUP")."</B></a></TD>";
	echo "<TD><a href=\"$PHP_SELF?ADD=1300&$ROUTElink$DPFlink\"><font size=1 color=white><B>"._QXZ("ROUTE")."</B></a></TD>";
	echo "<TD><a href=\"$PHP_SELF?ADD=1300&$REClink$DPFlink\"><font size=1 color=white><B>"._QXZ("REC")."</B></a></TD>";
	echo "<TD><font size=1 color=white><B>"._QXZ("MODIFY")."</B></TD>\n";
	echo "</TR>\n";

	$o=0;
	while ($dids_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}

		# truncate description and carrier if they are more than 60 characters
		if (mb_strlen($row[2],'utf-8')>60)
			{
			while (mb_strlen($row[2],'utf-8')>60) {$row[2] = mb_substr("$row[2]", 0, -1,'utf-8');}
			$row[2] .= '...';
			}
		if (mb_strlen($row[3],'utf-8')>40)
			{
			while (mb_strlen($row[3],'utf-8')>40) {$row[3] = mb_substr("$row[3]", 0, -1,'utf-8');}
			$row[3] .= '...';
			}

		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=3311&did_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=3311&did_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1> $row[1]</td>";
		echo "<td><font size=1> $row[2]</td>";
		echo "<td><font size=1> $row[3]</td>";
		echo "<td><font size=1> "._QXZ("$row[4]")."</td>";
		echo "<td><font size=1> ".(preg_match('/\-\-ALL\-\-/', $row[7]) ? _QXZ("$row[7]") : $row[7])."</td>";
		echo "<td><font size=1> "._QXZ("$row[5]")."</td>";
		echo "<td><font size=1> "._QXZ("$row[6]")."</td>";
		echo "<td><font size=1><a href=\"$PHP_SELF?ADD=3311&did_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}
	echo "</TABLE>\n";
	echo "</form>\n";
	echo "</span>\n";
	echo "</center>\n";
	}


######################
# ADD=1500 display all call menus
######################
if ($ADD==1500)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT menu_id,menu_name,menu_prompt,menu_timeout,user_group from vicidial_call_menu $whereLOGadmin_viewable_groupsSQL order by menu_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$menus_to_print = mysqli_num_rows($rslt);

	echo "<img src=\"images/icon_callmenu.png\" alt=\"Call Menus\" width=42 height=42> "._QXZ("CALL MENU LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<TR BGCOLOR=BLACK>";
	echo "<TD><font size=1 color=white>"._QXZ("MENU ID")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("NAME")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("GROUP")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("PROMPT")."</TD>\n";
	echo "<TD><font size=1 color=white>"._QXZ("TIMEOUT")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("OPTIONS")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("MODIFY")."</TD>\n";
	echo "</TR>\n";

	$o=0;
	$menu_id = $MT;
	$menu_name = $MT;
	$menu_prompt = $MT;
	$menu_timeout = $MT;
	$menu_group = $MT;

	while ($menus_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		$menu_id[$o] =		$row[0];
		$menu_name[$o] =	$row[1];
		$menu_prompt[$o] =	$row[2];
		$menu_timeout[$o] =	$row[3];
		$menu_group[$o] =	$row[4];
		$o++;
		}

	$o=0;
	while ($menus_to_print > $o) 
		{
		$stmt="SELECT count(*) from vicidial_call_menu_options where menu_id=\"$menu_id[$o]\";";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=3511&menu_id=$menu_id[$o]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=3511&menu_id=$menu_id[$o]\"><font size=1 color=black>$menu_id[$o]</a></td>";
		echo "<td><font size=1> $menu_name[$o]</td>";
		echo "<td><font size=1> $menu_group[$o]</td>";
		echo "<td><font size=1> $menu_prompt[$o]</td>";
		echo "<td><font size=1> $menu_timeout[$o]</td>";
		echo "<td><font size=1> $row[0]</td>";
		echo "<td><font size=1><a href=\"$PHP_SELF?ADD=3511&menu_id=$menu_id[$o]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=1700 display all filter phone groups
######################
if ($ADD==1700)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT vfpg.filter_phone_group_id,filter_phone_group_name,filter_phone_group_description,count(*) as tally,user_group from vicidial_filter_phone_groups vfpg,vicidial_filter_phone_numbers vfpn where vfpg.filter_phone_group_id=vfpn.filter_phone_group_id $LOGadmin_viewable_groupsSQL group by filter_phone_group_id order by filter_phone_group_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$lists_to_print = mysqli_num_rows($rslt);

	echo "<img src=\"images/icon_filterphonegroup.png\" alt=\"Filter Phone Groups\" width=42 height=42> "._QXZ("FILTER PHONE GROUP LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<TR BGCOLOR=BLACK>";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("FPG ID")."</B></a></TD>";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("FPG NAME")."</B></TD>";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("DESCRIPTION")."</B></TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("ADMIN GROUP")."</B></TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("PHONES COUNT")."</B></a></TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("MODIFY")."</TD>\n";
	echo "</TR>\n";

	$lists_printed = '';
	$o=0;
	while ($lists_to_print > $o)
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=3711&filter_phone_group_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=3711&filter_phone_group_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1> $row[1]</td>";
		echo "<td><font size=1> $row[2]</td>";
		echo "<td><font size=1> ".(preg_match('/\-\-ALL\-\-/', $row[4]) ? _QXZ("$row[4]") : $row[4])."</td>";
		echo "<td><font size=1> $row[3]</td>";
		echo "<td><font size=1><a href=\"$PHP_SELF?ADD=3711&filter_phone_group_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$groups_printed .= "'$row[0]',";
		$o++;
		}

	$stmt="SELECT filter_phone_group_id,filter_phone_group_name,filter_phone_group_description,0,user_group from vicidial_filter_phone_groups where filter_phone_group_id NOT IN($groups_printed'') $LOGadmin_viewable_groupsSQL order by filter_phone_group_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$lists_to_print = mysqli_num_rows($rslt);
	$o=0;
	while ($lists_to_print > $o)
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=3711&filter_phone_group_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=3711&filter_phone_group_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1> $row[1]</td>";
		echo "<td><font size=1> $row[2]</td>";
		echo "<td><font size=1> ".(preg_match('/\-\-ALL\-\-/', $row[4]) ? _QXZ("$row[4]") : $row[4])."</td>";
		echo "<td><font size=1> $row[3]</td>";
		echo "<td><font size=1><a href=\"$PHP_SELF?ADD=3711&filter_phone_group_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=10000 display all remote agents
######################
if ($ADD==10000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	# gather list of allowed users
	$stmt="SELECT user from vicidial_users $whereLOGadmin_viewable_groupsSQL order by user;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$users_to_print = mysqli_num_rows($rslt);
	$o=0;
	$user_start_SQL='';
	while ($users_to_print > $o)
		{
		$row=mysqli_fetch_row($rslt);
		$user_start_SQL .= "'$row[0]',";
		$o++;
		}
	$user_start_SQL = preg_replace("/,$/","",$user_start_SQL);
	$OTHERuser_start_SQL='';
	if (strlen($whereLOGadmin_viewable_groupsSQL) < 1)
		{$OTHERuser_start_SQL="where user_start NOT IN($user_start_SQL)";}
	if (strlen($user_start_SQL) > 2)
		{$user_start_SQL = "user_start IN($user_start_SQL)";}

	$ra_user_SQL = "and $user_start_SQL";
	if (strlen($whereLOGallowed_campaignsSQL) < 6)
		{$ra_user_SQL = "where $user_start_SQL";}

	$stmt="SELECT remote_agent_id,user_start,number_of_lines,server_ip,conf_exten,extension_group,status,campaign_id from vicidial_remote_agents $whereLOGallowed_campaignsSQL $ra_user_SQL order by server_ip,campaign_id,user_start;";
	if ($DB) {echo "$stmt\n";}
	$rslt=mysql_to_mysqli($stmt, $link);
	$remoteagents_to_print = mysqli_num_rows($rslt);

	echo "<img src=\"images/icon_black_remoteagents.png\" alt=\"Remote Agents\" width=42 height=42> "._QXZ("REMOTE AGENTS LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white align=left><B>"._QXZ("USER")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("LINES")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("SERVER")." &nbsp; </B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("CONF-EXTEN")." &nbsp; </B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("GROUP")." &nbsp; </B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("STATUS")." &nbsp; </B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("CAMPAIGN")." &nbsp; </B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($remoteagents_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=31111&remote_agent_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=31111&remote_agent_id=$row[0]\"><font size=1 color=black>$row[1]</a></td>";
		echo "<td><font size=1> $row[2]</td>";
		echo "<td><font size=1> $row[3]</td>";
		echo "<td><font size=1> $row[4]</td>";
		echo "<td><font size=1> ".(preg_match('/^NONE$/', $row[5]) ? _QXZ("$row[5]") : $row[5])."</td>";
		echo "<td><font size=1> "._QXZ("$row[6]")."</td>";
		echo "<td><font size=1> $row[7]</td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=31111&remote_agent_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	### For users with no User Group restrictions, show all Remote Agents with no user attached
	if (strlen($OTHERuser_start_SQL) > 0)
		{
		$stmt="SELECT remote_agent_id,user_start,number_of_lines,server_ip,conf_exten,extension_group,status,campaign_id from vicidial_remote_agents $whereLOGallowed_campaignsSQL $OTHERuser_start_SQL order by server_ip,campaign_id,user_start;";
		if ($DB) {echo "$stmt\n";}
		$rslt=mysql_to_mysqli($stmt, $link);
		$OTHERremoteagents_to_print = mysqli_num_rows($rslt);

		$o=0;
		while ($OTHERremoteagents_to_print > $o) 
			{
			$row=mysqli_fetch_row($rslt);
			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='class="records_list_x"';} 
			else
				{$bgcolor='class="records_list_y"';}
			echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=31111&remote_agent_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=31111&remote_agent_id=$row[0]\"><font size=1 color=red><b>($row[1])</a></td>";
			echo "<td><font size=1> $row[2]</td>";
			echo "<td><font size=1> $row[3]</td>";
			echo "<td><font size=1> $row[4]</td>";
			echo "<td><font size=1> ".(preg_match('/^NONE$/', $row[5]) ? _QXZ("$row[5]") : $row[5])."</td>";
			echo "<td><font size=1> "._QXZ("$row[6]")."</td>";
			echo "<td><font size=1> $row[7]</td>";
			echo "<td align=center><a href=\"$PHP_SELF?ADD=31111&remote_agent_id=$row[0]\"><font size=1 color=red><b>"._QXZ("MODIFY")."</a></td></tr>\n";
			$o++;
			}
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=12000 display all extension group entries
######################
if ($ADD==12000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT extension_id,extension_group_id,extension,rank,campaign_groups,call_count_today,last_call_time,last_callerid from vicidial_extension_groups $whereLOGadmin_viewable_groupsSQL order by extension_group_id,rank,extension;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$extensiongroups_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("EXTENSION GROUP LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white><B>"._QXZ("GROUP")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("EXTENSION")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("RANK")." &nbsp; </B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("RESTRICT")." &nbsp; </B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("COUNT")." &nbsp; </B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("LAST CALL")." &nbsp; </B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("LAST ID")." &nbsp; </B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($extensiongroups_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=32111&extension_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=32111&extension_id=$row[0]\"><font size=1 color=black>$row[1]</a></td>";
		echo "<td><font size=1> $row[2]</td>";
		echo "<td><font size=1> $row[3]</td>";
		echo "<td><font size=1> $row[4]</td>";
		echo "<td><font size=1> $row[5]</td>";
		echo "<td><font size=1> $row[6]</td>";
		echo "<td><font size=1> $row[7]</td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=32111&extension_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=100000 display all user groups
######################
if ($ADD==100000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT user_group,group_name,forced_timeclock_login from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$usergroups_to_print = mysqli_num_rows($rslt);

	echo "<img src=\"images/icon_black_usergroups.png\" alt=\"User Groups\" width=42 height=42> "._QXZ("USER GROUPS LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white align=left><B>"._QXZ("USER GROUP")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("GROUP NAME")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("USERS")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ACTIVE")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("2ND")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("FORCE TIMECLOCK")." &nbsp; </B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	$Uuser_group = $MT;
	$Ugroup_name = $MT;
	$Uforced_timeclock_login = $MT;

	while ($usergroups_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		$Uuser_group[$o] =				$row[0];
		$Ugroup_name[$o] =				$row[1];
		$Uforced_timeclock_login[$o] =	$row[2];
		$o++;
		}

	$o=0;
	while ($usergroups_to_print > $o) 
		{
		$stmt="SELECT count(*) from vicidial_users where user_group='$Uuser_group[$o]' $LOGadmin_viewable_groupsSQL";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$users_count = $row[0];

		$stmt="SELECT count(*) from vicidial_users where user_group='$Uuser_group[$o]' and active='Y' $LOGadmin_viewable_groupsSQL";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$active_count = $row[0];

		$stmt="SELECT count(*) from vicidial_users where user_group_two='$Uuser_group[$o]' $LOGadmin_viewable_groupsSQL";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$second_count = $row[0];

		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=311111&user_group=$Uuser_group[$o]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=311111&user_group=$Uuser_group[$o]\"><font size=1 color=black>$Uuser_group[$o]</a></td>";
		echo "<td><font size=1> $Ugroup_name[$o]</td>";
		echo "<td><font size=1> $users_count</td>";
		echo "<td><font size=1> $active_count</td>";
		echo "<td><font size=1> $second_count</td>";
		echo "<td><font size=1> "._QXZ("$Uforced_timeclock_login[$o]")."</td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=311111&user_group=$Uuser_group[$o]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=1000000 display all scripts
######################
if ($ADD==1000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT script_id,script_name,active,user_group,script_color from vicidial_scripts $whereLOGadmin_viewable_groupsSQL order by script_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$scripts_to_print = mysqli_num_rows($rslt);

	echo "<img src=\"images/icon_black_scripts.png\" alt=\"Scripts\" width=42 height=42> "._QXZ("SCRIPTS LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white align=left><B>"._QXZ("SCRIPT ID")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("SCRIPT NAME")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ACTIVE")." &nbsp; </B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ADMIN GROUP")." &nbsp; </B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("COLOR")." &nbsp; </B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($scripts_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=3111111&script_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=3111111&script_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1> $row[1]</td>";
		echo "<td><font size=1> "._QXZ("$row[2]")."</td>";
		echo "<td><font size=1> ".(preg_match('/\-\-ALL\-\-/', $row[3]) ? _QXZ("$row[3]") : $row[3])."</td>";
		echo "<td bgcolor=\"$row[4]\"><font size=1> &nbsp;</td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=3111111&script_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=10000000 display all filters
######################
if ($ADD==10000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT lead_filter_id,lead_filter_name,user_group from vicidial_lead_filters $whereLOGadmin_viewable_groupsSQL order by lead_filter_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$filters_to_print = mysqli_num_rows($rslt);

	echo "<img src=\"images/icon_black_filters.png\" alt=\"Filters\" width=42 height=42> "._QXZ("LEAD FILTER LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white align=left><B>"._QXZ("FILTER ID")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("FILTER NAME")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ADMIN GROUP")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($filters_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=31111111&lead_filter_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=31111111&lead_filter_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1> $row[1]</td>";
		echo "<td><font size=1> ".(preg_match('/\-\-ALL\-\-/', $row[2]) ? _QXZ("$row[2]") : $row[2])."</td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=31111111&lead_filter_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=100000000 display all call times
######################
if ($ADD==100000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_calltimes.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if (strlen($whereLOGadmin_viewable_groupsSQL) > 0) {$tempLOGadmin_viewable_call_timesSQL = $LOGadmin_viewable_call_timesSQL;}
	else {$tempLOGadmin_viewable_call_timesSQL = $whereLOGadmin_viewable_call_timesSQL;}

	$stmt="SELECT call_time_id,call_time_name,ct_default_start,ct_default_stop,user_group from vicidial_call_times $whereLOGadmin_viewable_groupsSQL $tempLOGadmin_viewable_call_timesSQL order by call_time_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$calltimes_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("CALL TIME LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white align=left><B>"._QXZ("CALLTIME ID")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("CALLTIME NAME")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("DEFAULT START")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("DEFAULT STOP")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ADMIN GROUP")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($calltimes_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=311111111&call_time_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=311111111&call_time_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1> $row[1]</td>";
		echo "<td><font size=1> $row[2] </td>";
		echo "<td><font size=1> $row[3] </td>";
		echo "<td><font size=1> $row[4] </td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=311111111&call_time_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=1000000000 display all state call times
######################
if ($ADD==1000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_calltimes.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT state_call_time_id,state_call_time_state,state_call_time_name,sct_default_start,sct_default_stop,user_group from vicidial_state_call_times $whereLOGadmin_viewable_groupsSQL order by state_call_time_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$statecalltimes_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("STATE CALL TIME LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white align=left><B>"._QXZ("CALLTIME ID")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("CALLTIME STATE")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("CALLTIME NAME")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("DEFAULT START")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("DEFAULT STOP")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ADMIN GROUP")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($statecalltimes_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=3111111111&call_time_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=3111111111&call_time_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1> $row[1]</td>";
		echo "<td><font size=1> $row[2]</td>";
		echo "<td><font size=1> $row[3] </td>";
		echo "<td><font size=1> $row[4] </td>";
		echo "<td><font size=1> $row[5] </td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=3111111111&call_time_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=1200000000 display all holidays
######################
if ($ADD==1200000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_calltimes.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT holiday_id,holiday_date,holiday_name,holiday_status,ct_default_start,ct_default_stop,user_group from vicidial_call_time_holidays $whereLOGadmin_viewable_groupsSQL order by holiday_date,holiday_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$holidays_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("HOLIDAY LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white align=left><B>"._QXZ("HOLIDAY ID")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("DATE")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("NAME")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("STATUS")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("START")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("STOP")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ADMIN GROUP")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($holidays_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=3211111111&holiday_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=3211111111&holiday_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1> $row[1]</td>";
		echo "<td><font size=1> $row[2]</td>";
		echo "<td><font size=1> $row[3] </td>";
		echo "<td><font size=1> $row[4] </td>";
		echo "<td><font size=1> $row[5] </td>";
		echo "<td><font size=1> $row[6] </td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=3211111111&holiday_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=130000000 display all shifts
######################
if ($ADD==130000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_shifts.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT shift_id,shift_name,shift_start_time,shift_length,shift_weekdays,user_group from vicidial_shifts $whereLOGadmin_viewable_groupsSQL order by shift_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$shifts_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("SHIFT LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white align=left><B>"._QXZ("SHIFT ID")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("SHIFT NAME")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("SHIFT START")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("SHIFT LENGTH")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("WEEKDAYS")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ADMIN GROUP")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($shifts_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=331111111&shift_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=331111111&shift_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1> $row[1]</td>";
		echo "<td><font size=1> $row[2] </td>";
		echo "<td><font size=1> $row[3] </td>";
		echo "<td><font size=1> $row[4] </td>";
		echo "<td><font size=1> $row[5] </td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=331111111&shift_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=10000000000 display all phones
######################
if ($ADD==10000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_phones.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$EXTENlink="stage=EXTENDOWN&status=$status";
	$EXTENNUMlink="stage=EXTENNUMDOWN&status=$status";
	$PROTOlink="stage=PROTODOWN&status=$status";
	$SERVERlink="stage=SERVERDOWN&status=$status";
	$STATUSlink="stage=STATUSDOWN&status=$status";
	$SQLorder='order by extension,server_ip';

	if (preg_match("/EXTENUP/i",$stage)) {$SQLorder='order by extension asc';   $EXTENlink="stage=EXTENDOWN&status=$status";}
	if (preg_match("/EXTENDOWN/i",$stage)) {$SQLorder='order by extension desc';   $EXTENlink="stage=EXTENUP&status=$status";}
	if (preg_match("/EXTENNUMUP/i",$stage)) {$SQLorder='order by CAST(extension as SIGNED INTEGER) desc';   $EXTENNUMlink="stage=EXTENNUMDOWN&status=$status";}
	if (preg_match("/EXTENNUMDOWN/i",$stage)) {$SQLorder='order by CAST(extension as SIGNED INTEGER) asc';   $EXTENNUMlink="stage=EXTENNUMUP&status=$status";}
	if (preg_match("/PROTOUP/i",$stage)) {$SQLorder='order by protocol asc';   $PROTOlink="stage=PROTODOWN&status=$status";}
	if (preg_match("/PROTODOWN/i",$stage)) {$SQLorder='order by protocol desc';   $PROTOlink="stage=PROTOUP&status=$status";}
	if (preg_match("/SERVERUP/i",$stage)) {$SQLorder='order by server_ip asc';   $SERVERlink="stage=SERVERDOWN&status=$status";}
	if (preg_match("/SERVERDOWN/i",$stage)) {$SQLorder='order by server_ip desc';   $SERVERlink="stage=SERVERUP&status=$status";}
	if (preg_match("/STATUSUP/i",$stage)) {$SQLorder='order by status asc';   $STATUSlink="stage=STATUSDOWN&status=$status";}
	if (preg_match("/STATUSDOWN/i",$stage)) {$SQLorder='order by status desc';   $STATUSlink="stage=STATUSUP&status=$status";}

	$limitSQL='';
	$next_prev_HTML='';
	if ($SSentries_per_page > 0)
		{
		$stmt="SELECT count(*) from phones $whereLOGadmin_viewable_groupsSQL";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$phones_count = $row[0];

		if ( ($phones_count > $SSentries_per_page) and ($status != 'display_all') )
			{
			if (strlen($start_count) < 1) {$start_count=0;}
			$next_count = ($start_count + $SSentries_per_page);
			$nextnext_count = ($next_count + $SSentries_per_page);
			if ($next_count > $phones_count) 
				{$next_count = $phones_count;}
			else
				{
				if ($nextnext_count > $phones_count) 
					{
					$next_temp = ($phones_count - $next_count);
					$nextHTML = "<a href=\"$PHP_SELF?ADD=10000000000&start_count=$next_count&stage=$stage\">"._QXZ("NEXT")." $next_temp</a> &nbsp; ";
					}
				else
					{
					$nextHTML = "<a href=\"$PHP_SELF?ADD=10000000000&start_count=$next_count&stage=$stage\">"._QXZ("NEXT")." $SSentries_per_page</a> &nbsp; ";
					}
				}
			$next_prev_HTML .= _QXZ("RECORDS")." $start_count - $next_count &nbsp; ";
			$limitSQL="limit $SSentries_per_page";
			if ($start_count > 0)
				{
				$prev_count = ($start_count - $SSentries_per_page);
				$limitSQL="limit $start_count,$SSentries_per_page";
				$next_prev_HTML .= "<a href=\"$PHP_SELF?ADD=10000000000&start_count=$prev_count&stage=$stage\">"._QXZ("PREVIOUS")." $SSentries_per_page</a> &nbsp; ";
				}
			$next_prev_HTML .= $nextHTML;
			$next_prev_HTML .= " &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; </b><a href=\"$PHP_SELF?ADD=10000000000&status=display_all&stage=$stage\"><font size=1 color=black>"._QXZ("show all phones")."</font></a><b> &nbsp; ";
			}
		}

	$stmt="SELECT extension,protocol,server_ip,dialplan_number,voicemail_id,status,fullname,messages,old_messages,user_group,is_webphone from phones $whereLOGadmin_viewable_groupsSQL $SQLorder $limitSQL";
	$rslt=mysql_to_mysqli($stmt, $link);
	$phones_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("PHONE LISTINGS").":\n";
	if (strlen($next_prev_HTML) > 10)
		{echo "<br><br><b> &nbsp; $next_prev_HTML</b><br>";}
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><a href=\"$PHP_SELF?ADD=10000000000&$EXTENlink\"><font size=1 color=white><B>"._QXZ("EXTEN")."</B></a> &nbsp; ";
	echo "<a href=\"$PHP_SELF?ADD=10000000000&$EXTENNUMlink\"><font size=1 color=white><B>- # -</B></a></td>";
	echo "<td><a href=\"$PHP_SELF?ADD=10000000000&$PROTOlink\"><font size=1 color=white><B>"._QXZ("PROTO")."</B></a></td>";
	echo "<td><a href=\"$PHP_SELF?ADD=10000000000&$SERVERlink\"><font size=1 color=white><B>"._QXZ("SERVER")."</B></a></td>";
	echo "<td colspan=2><font size=1 color=white><B>"._QXZ("DIAL PLAN")."</B></td>";
	echo "<td><a href=\"$PHP_SELF?ADD=10000000000&$STATUSlink\"><font size=1 color=white><B>"._QXZ("STATUS")."</B></a></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("NAME")."</B></td>";
	echo "<td colspan=2><font size=1 color=white><B>"._QXZ("VMAIL")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("GROUP")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("LINKS")."</B></td></tr>\n";

	$o=0;
	while ($phones_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		$TEMPprotocol = $row[1];
		if ( ($row[10] == 'Y') or ($row[10] == 'Y_API_LAUNCH') ) {$TEMPprotocol = "$row[1]<i>(w)</i>";}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=31111111111&extension=$row[0]&server_ip=$row[2]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=31111111111&extension=$row[0]&server_ip=$row[2]\"><font size=1 color=black>$row[0]</font></a></td>
		<td><font size=1>$TEMPprotocol</td>
		<td><font size=1>"._QXZ("$row[2]")."</td>
		<td><font size=1>$row[3]</td>
		<td><font size=1>$row[4]</td>
		<td><font size=1>"._QXZ("$row[5]")."</td>
		<td><font size=1>$row[6]</td>
		<td><font size=1>$row[7]</td>
		<td><font size=1>$row[8]</td>
		<td><font size=1>"._QXZ("$row[9]")."</td>";
		echo "<td><font size=1><a href=\"$PHP_SELF?ADD=31111111111&extension=$row[0]&server_ip=$row[2]\">"._QXZ("MODIFY")."</a> | <a href=\"./phone_stats.php?extension=$row[0]&server_ip=$row[2]\">"._QXZ("STATS")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=12000000000 display all phones alias
######################
if ($ADD==12000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_phones.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT alias_id,alias_name,logins_list,user_group from phones_alias $whereLOGadmin_viewable_groupsSQL order by alias_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$phonealias_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("PHONE ALIAS LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white><B>"._QXZ("ALIAS ID")."</B></a></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ALIAS NAME")."</B></a></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("PHONE LOGINS LIST")."</B></a></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("GROUP")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($phonealias_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=32111111111&alias_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=32111111111&alias_id=$row[0]\"><font size=1 color=black>$row[0]</font></a></td>";
		echo "<td><font size=1>$row[1]</td>";
		echo "<td><font size=1>$row[2]</td>";
		echo "<td><font size=1>"._QXZ("$row[3]")."</td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=32111111111&alias_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=13000000000 display all group alias
######################
if ($ADD==13000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_phones.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT group_alias_id,group_alias_name,caller_id_number,caller_id_name,active,user_group from groups_alias $whereLOGadmin_viewable_groupsSQL order by group_alias_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$phonealias_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("GROUP ALIAS LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white><B>"._QXZ("GROUP ALIAS ID")."</B></a></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("GROUP ALIAS NAME")."</B></a></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("CID NUMBER")."</B></a></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("CID NAME")."</B></a></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ACTIVE")."</B></a></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ADMIN GROUP")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($phonealias_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=33111111111&group_alias_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=33111111111&group_alias_id=$row[0]\"><font size=1 color=black>$row[0]</font></a></td>";
		echo "<td><font size=1>$row[1]</td>";
		echo "<td><font size=1>$row[2]</td>";
		echo "<td><font size=1>$row[3]</td>";
		echo "<td><font size=1>"._QXZ("$row[4]")."</td>";
		echo "<td><font size=1>"._QXZ("$row[5]")."</td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=33111111111&group_alias_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=100000000000 display all servers
######################
if ($ADD==100000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_servers.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT server_id,server_description,server_ip,active,asterisk_version,max_vicidial_trunks,local_gmt,active_agent_login_server from servers $whereLOGadmin_viewable_groupsSQL order by server_id";
	$rslt=mysql_to_mysqli($stmt, $link);
	$servers_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("SERVER LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white align=left><B>"._QXZ("SERVER ID")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("NAME")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("SERVER IP")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ACTIVE")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("AGENT")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ASTERISK")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("TRUNKS")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("GMT")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($servers_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=311111111111&server_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=311111111111&server_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1>$row[1]</td>";
		echo "<td><font size=1>$row[2]</td>";
		echo "<td><font size=1>"._QXZ("$row[3]")."</td>";
		echo "<td><font size=1>"._QXZ("$row[7]")."</td>";
		echo "<td><font size=1>$row[4]</td>";
		echo "<td><font size=1>$row[5]</td>";
		echo "<td><font size=1>$row[6]</td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=311111111111&server_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=130000000000 display all conf templates
######################
if ($ADD==130000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_templates.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT template_id,template_name,user_group from vicidial_conf_templates $whereLOGadmin_viewable_groupsSQL order by template_id";
	$rslt=mysql_to_mysqli($stmt, $link);
	$templates_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("CONF TEMPLATE LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white align=left><B>"._QXZ("Template ID")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Template Name")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ADMIN GROUP")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($templates_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=331111111111&template_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=331111111111&template_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1>$row[1]</td>";
		echo "<td><font size=1>"._QXZ("$row[2]")."</td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=331111111111&template_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=140000000000 display all carriers
######################
if ($ADD==140000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_carriers.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT carrier_id,carrier_name,server_ip,protocol,registration_string,active,user_group from vicidial_server_carriers $whereLOGadmin_viewable_groupsSQL order by carrier_id";
	$rslt=mysql_to_mysqli($stmt, $link);
	$carriers_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("CARRIER LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white align=left><B>"._QXZ("Carrier ID")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Carrier Name")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Server IP")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Protocol")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Registration")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Active")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ADMIN GROUP")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($carriers_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		if (mb_strlen($row[4],'utf-8')>14)
			{
			while (mb_strlen($row[4],'utf-8')>14) {$row[4] = mb_substr("$row[4]", 0, -1,'utf-8');}
			$row[4] .= '...';
			}
		if ($row[2] == '0.0.0.0') {$row[2]='ALL SERVERS';}
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=341111111111&carrier_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=341111111111&carrier_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1>$row[1]</td>";
		echo "<td><font size=1>".(preg_match('/[A-Z]/', $row[2]) ? _QXZ("$row[2]") : $row[2])."</td>";
		echo "<td><font size=1>".(!preg_match('/^SIP|IAX2/', $row[3]) ? _QXZ("$row[3]") : $row[3])."</td>";
		echo "<td><font size=1>$row[4]</td>";
		echo "<td><font size=1>"._QXZ("$row[5]")."</td>";
		echo "<td><font size=1>"._QXZ("$row[6]")."</td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=341111111111&carrier_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=150000000000 display all tts entries
######################
if ($ADD==150000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_texttospeech.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT tts_id,tts_name,active,tts_text,tts_voice,user_group from vicidial_tts_prompts $whereLOGadmin_viewable_groupsSQL order by tts_id";
	$rslt=mysql_to_mysqli($stmt, $link);
	$tts_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("TEXT-TO-SPEECH(TTS) LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white align=left><B>"._QXZ("TTS ID")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("TTS Name")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Active")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("TTS Voice")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("TTS Text")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ADMIN GROUP")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($tts_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		$row[3]=preg_replace('/;|<|>/', '', $row[3]);
		while(mb_strlen($row[3],'utf-8') > 50) {$row[3] = mb_substr("$row[3]", 0, -1,'utf-8');}
		if(mb_strlen($row[3],'utf-8') > 47) {$row[3] = "$row[3]...";}

		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=351111111111&tts_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=351111111111&tts_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1>$row[1]</td>";
		echo "<td><font size=1>"._QXZ("$row[2]")."</td>";
		echo "<td><font size=1>$row[4]</td>";
		echo "<td><font size=1>$row[3]</td>";
		echo "<td><font size=1>".(preg_match('/\-\-ALL\-\-/', $row[5]) ? _QXZ("$row[5]") : $row[5])."</td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=351111111111&tts_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=160000000000 display all music on hold entries
######################
if ($ADD==160000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_musiconhold.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT moh_id,moh_name,active,random,user_group from vicidial_music_on_hold where remove='N' $LOGadmin_viewable_groupsSQL order by moh_id";
	$rslt=mysql_to_mysqli($stmt, $link);
	$moh_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("MUSIC-ON-HOLD(MOH) LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white align=left><B>"._QXZ("MOH ID")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("MOH Name")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Active")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Random Order")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ADMIN GROUP")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($moh_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		$row[3]=preg_replace('/;|<|>/', '', $row[3]);
		while(mb_strlen($row[3],'utf-8') > 50) {$row[3] = mb_substr("$row[3]", 0, -1,'utf-8');}
		if(mb_strlen($row[3],'utf-8') > 47) {$row[3] = "$row[3]...";}

		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=361111111111&moh_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=361111111111&moh_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1>$row[1]</td>";
		echo "<td><font size=1>"._QXZ("$row[2]")."</td>";
		echo "<td><font size=1>"._QXZ("$row[3]")."</td>";
		echo "<td><font size=1>".(preg_match('/\-\-ALL\-\-/', $row[4]) ? _QXZ("$row[4]") : $row[4])."</td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=361111111111&moh_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=170000000000 display all voicemail entries
######################
if ($ADD==170000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_voicemail.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT voicemail_id,fullname,active,messages,old_messages,delete_vm_after_email,user_group from vicidial_voicemail $whereLOGadmin_viewable_groupsSQL order by voicemail_id";
	$rslt=mysql_to_mysqli($stmt, $link);
	$vm_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("VOICEMAIL BOXES").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white align=left><B>"._QXZ("VOICEMAIL ID")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Name")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Active")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("New Messages")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Old Messages")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Delete")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ADMIN GROUP")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($vm_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);

		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=371111111111&voicemail_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=371111111111&voicemail_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1>$row[1]</td>";
		echo "<td><font size=1>"._QXZ("$row[2]")."</td>";
		echo "<td><font size=1>$row[3]</td>";
		echo "<td><font size=1>$row[4]</td>";
		echo "<td><font size=1>"._QXZ("$row[5]")."</td>";
		echo "<td><font size=1>".(preg_match('/\-\-ALL\-\-/', $row[6]) ? _QXZ("$row[6]") : $row[6])."</td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=371111111111&voicemail_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=180000000000 display all screen label entries
######################
if ($ADD==180000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_screenlabels.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT label_id,label_name,active,user_group from vicidial_screen_labels $whereLOGadmin_viewable_groupsSQL order by label_id";
	$rslt=mysql_to_mysqli($stmt, $link);
	$lb_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("Agent Screen Labels").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white align=left><B>"._QXZ("LABEL ID")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Name")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Active")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ADMIN GROUP")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($lb_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);

		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=381111111111&label_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=381111111111&label_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1>$row[1]</td>";
		echo "<td><font size=1>"._QXZ("$row[2]")."</td>";
		echo "<td><font size=1>".(preg_match('/\-\-ALL\-\-/', $row[3]) ? _QXZ("$row[3]") : $row[3])."</td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=381111111111&label_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=182000000000 display all screen colors entries
######################
if ($ADD==182000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_screencolors.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT colors_id,colors_name,active,user_group,menu_background,frame_background,std_row1_background,web_logo from vicidial_screen_colors $whereLOGadmin_viewable_groupsSQL order by colors_id";
	$rslt=mysql_to_mysqli($stmt, $link);
	$lb_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("Screen Colors").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white align=left><B>"._QXZ("COLORS ID")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Name")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Active")."</B></td>";
	echo "<td colspan=3><font size=1 color=white><B>"._QXZ("Menu Colors")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Logo")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ADMIN GROUP")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($lb_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);

		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=382111111111&colors_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=382111111111&colors_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1>$row[1]</td>";
		echo "<td><font size=1>"._QXZ("$row[2]")."</td>";
		echo "<td bgcolor=#$row[4]><font size=1> &nbsp; </td>";
		echo "<td bgcolor=#$row[5]><font size=1> &nbsp; </td>";
		echo "<td bgcolor=#$row[6]><font size=1> &nbsp; </td>";

		$logo_new=0;
		$logo_old=0;
		$logo_small_old=0;
		if (file_exists('./images/vicidial_admin_web_logo.png')) {$logo_new++;}
		if (file_exists('vicidial_admin_web_logo_small.gif')) {$logo_small_old++;}
		if (file_exists('vicidial_admin_web_logo.gif')) {$logo_old++;}

		if ($row[7]=='default_new')
			{
			$selected_logo = "./images/vicidial_admin_web_logo.png";
			}
		if ( ($row[7]=='default_old') and ($logo_old > 0) )
			{
			$selected_logo = "./vicidial_admin_web_logo.gif";
			}
		if ( ($row[7]!='default_new') and ($row[7]!='default_old') )
			{
			if (file_exists("./images/vicidial_admin_web_logo$row[7]")) 
				{
				$selected_logo = "./images/vicidial_admin_web_logo$row[7]";
				}
			}

		echo "<td bgcolor=#$row[4] width=91><img src=\"$selected_logo\" height=22 width=85></td>";
		echo "<td><font size=1>".(preg_match('/\-\-ALL\-\-/', $row[3]) ? _QXZ("$row[3]") : $row[3])."</td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=382111111111&colors_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=190000000000 display all contacts entries
######################
if ($ADD==190000000000)
	{
	echo "<CENTER><TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_contacts.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (preg_match("/contact_information/",$SStables_use_alt_log_db)) and (strlen($SSalt_log_server_ip)>4) and (strlen($SSalt_log_dbname)>0) )
		{
		$linkALT=mysqli_connect("$SSalt_log_server_ip", "$SSalt_log_login", "$SSalt_log_pass", "$SSalt_log_dbname");
			if (!$linkALT) 
				{
				die('MySQL '._QXZ("connect ERROR").': ' . mysqli_connect_error());
				}
		}
	else
		{$linkALT = $link;}
	$stmt="SELECT contact_id,first_name,last_name,office_num,bu_name,department,group_name,job_title,location from contact_information order by first_name,last_name,office_num limit 20000;";
	$rslt=mysql_to_mysqli($stmt, $linkALT);
	$lb_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("Contacts").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white align=left><B>"._QXZ("NAME")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Office Number")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("BU Name")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Department")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Group")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Job Title")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Location")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($lb_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		while (mb_strlen($row[4],'utf-8')>20) {$row[4] = mb_substr("$row[4]", 0, -1,'utf-8');}
		while (mb_strlen($row[5],'utf-8')>20) {$row[5] = mb_substr("$row[5]", 0, -1,'utf-8');}
		while (mb_strlen($row[6],'utf-8')>20) {$row[6] = mb_substr("$row[6]", 0, -1,'utf-8');}
		while (mb_strlen($row[7],'utf-8')>20) {$row[7] = mb_substr("$row[7]", 0, -1,'utf-8');}
		while (mb_strlen($row[8],'utf-8')>20) {$row[8] = mb_substr("$row[8]", 0, -1,'utf-8');}

		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=391111111111&contact_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=391111111111&contact_id=$row[0]\"><font size=1 color=black>$row[1] $row[2]</a></td>";
		echo "<td><font size=1>$row[3]</td>";
		echo "<td><font size=1>$row[4]</td>";
		echo "<td><font size=1>$row[5]</td>";
		echo "<td><font size=1>$row[6]</td>";
		echo "<td><font size=1>$row[7]</td>";
		echo "<td><font size=1>$row[8]</td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=391111111111&contact_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=192000000000 display all settings containers entries
######################
if ($ADD==192000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_settingscontainer.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT container_id,container_notes,container_type,user_group,container_entry from vicidial_settings_containers $whereLOGadmin_viewable_groupsSQL order by container_type,container_id";
	$rslt=mysql_to_mysqli($stmt, $link);
	$sc_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("Settings Containers").":\n";
	echo "<center><TABLE width=900 cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white align=left><B>"._QXZ("Container ID")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Notes")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Type")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Length")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ADMIN GROUP")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($sc_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);

		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=392111111111&container_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=392111111111&container_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1>$row[1]</td>";
		echo "<td><font size=1>"._QXZ("$row[2]")."</td>";
		echo "<td><font size=1>".strlen($row[4])."</td>";
		echo "<td><font size=1>".(preg_match('/\-\-ALL\-\-/', $row[3]) ? _QXZ("$row[3]") : $row[3])."</td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=392111111111&container_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=193000000000 display all status group entries
######################
if ($ADD==193000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_statusgroups.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT status_group_id,status_group_notes,user_group from vicidial_status_groups $whereLOGadmin_viewable_groupsSQL order by status_group_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$status_groups_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("STATUS GROUP LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<TR BGCOLOR=BLACK>";
	echo "<TD><font size=1 color=white>"._QXZ("STATUS GROUP ID")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("NOTES")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("GROUP")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("STATUSES")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("MODIFY")."</TD>\n";
	echo "</TR>\n";

	$o=0;
	$status_group_id = $MT;
	$status_group_notes = $MT;
	$admin_group = $MT;

	while ($status_groups_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		$status_group_id[$o] =		$row[0];
		$status_group_notes[$o] =	$row[1];
		$admin_group[$o] =			(preg_match('/\-\-ALL\-\-/', $row[2]) ? _QXZ("$row[2]") : $row[2]);
		$o++;
		}

	$o=0;
	while ($status_groups_to_print > $o) 
		{
		$stmt="SELECT count(*) from vicidial_campaign_statuses where campaign_id=\"$status_group_id[$o]\";";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=393111111111&status_group_id=$status_group_id[$o]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=393111111111&status_group_id=$status_group_id[$o]\"><font size=1 color=black>$status_group_id[$o]</a></td>";
		echo "<td><font size=1> $status_group_notes[$o]</td>";
		echo "<td><font size=1> $admin_group[$o]</td>";
		echo "<td><font size=1> $row[0]</td>";
		echo "<td><font size=1><a href=\"$PHP_SELF?ADD=393111111111&status_group_id=$status_group_id[$o]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=194000000000 display all automated report entries
######################
if ($ADD==194000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_autoreports.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT report_id,report_name,report_destination,active,user_group,report_last_run,report_last_length,report_server from vicidial_automated_reports $whereLOGadmin_viewable_groupsSQL order by report_destination,report_id";
	$rslt=mysql_to_mysqli($stmt, $link);
	$sc_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("Automated Reports").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white align=left><B>"._QXZ("Auto Report ID")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Name")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Type")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Active")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("ADMIN GROUP")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Last Run")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Length")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("Server")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($sc_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);

		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=394111111111&report_id=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=394111111111&report_id=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1>$row[1]</td>";
		echo "<td><font size=1>"._QXZ("$row[2]")."</td>";
		echo "<td><font size=1>"._QXZ("$row[3]")."</td>";
		echo "<td><font size=1>".(preg_match('/\-\-ALL\-\-/', $row[4]) ? _QXZ("$row[4]") : $row[4])."</td>";
		echo "<td><font size=1>$row[5]</td>";
		echo "<td><font size=1>$row[6]</td>";
		echo "<td><font size=1>$row[7]</td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=394111111111&report_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=195000000000 display all IP List entries
######################
if ($ADD==195000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_iplists.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT ip_list_id,ip_list_name,active,user_group from vicidial_ip_lists $whereLOGadmin_viewable_groupsSQL order by ip_list_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$ip_lists_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("IP LIST LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<TR BGCOLOR=BLACK>";
	echo "<TD><font size=1 color=white>"._QXZ("IP LIST ID")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("NAME")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("ACTIVE")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("GROUP")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("IPS")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("MODIFY")."</TD>\n";
	echo "</TR>\n";

	$Xip_list_id = $MT;
	$ip_list_name = $MT;
	$active = $MT;
	$admin_group = $MT;

	$o=0;
	while ($ip_lists_to_print > $o)
		{
		$row=mysqli_fetch_row($rslt);
		$Xip_list_id[$o] =		$row[0];
		$ip_list_name[$o] =		$row[1];
		$active[$o] =			_QXZ("$row[2]");
		$admin_group[$o] =		(preg_match('/\-\-ALL\-\-/', $row[3]) ? _QXZ("$row[3]") : $row[3]);
		$o++;
		}

	$o=0;
	while ($ip_lists_to_print > $o)
		{
		$stmt="SELECT count(*) from vicidial_ip_list_entries where ip_list_id=\"$Xip_list_id[$o]\";";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=395111111111&ip_list_id=$Xip_list_id[$o]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=395111111111&ip_list_id=$Xip_list_id[$o]\"><font size=1 color=black>$Xip_list_id[$o]</a></td>";
		echo "<td><font size=1> $ip_list_name[$o]</td>";
		echo "<td><font size=1> $active[$o]</td>";
		echo "<td><font size=1> $admin_group[$o]</td>";
		echo "<td><font size=1> $row[0]</td>";
		echo "<td><font size=1><a href=\"$PHP_SELF?ADD=395111111111&ip_list_id=$Xip_list_id[$o]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=196000000000 display all CID group entries
######################
if ($ADD==196000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_cidgroups.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT cid_group_id,cid_group_notes,cid_group_type,user_group,cid_auto_rotate_minutes from vicidial_cid_groups $whereLOGadmin_viewable_groupsSQL order by cid_group_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$cid_groups_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("CID GROUP LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<TR BGCOLOR=BLACK>";
	echo "<TD><font size=1 color=white>"._QXZ("CID GROUP ID")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("NOTES")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("TYPE")."</TD>";
	echo "<TD align=left><font size=1 color=white> &nbsp; </TD>";
	echo "<TD><font size=1 color=white>"._QXZ("GROUP")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("CIDS")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("MODIFY")."</TD>\n";
	echo "</TR>\n";

	$o=0;
	$cid_group_id = $MT;
	$cid_group_notes = $MT;
	$cid_group_type = $MT;
	$admin_group = $MT;
	$cid_auto_rotate_minutes = $MT;

	while ($cid_groups_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		$cid_group_id[$o] =			$row[0];
		$cid_group_notes[$o] =		$row[1];
		$cid_group_type[$o] =		_QXZ("$row[2]");
		$admin_group[$o] =		(preg_match('/\-\-ALL\-\-/', $row[3]) ? _QXZ("$row[3]") : $row[3]);
		$cid_auto_rotate_minutes[$o] =	'';
		if ($row[4] > 0) {$cid_auto_rotate_minutes[$o] =	' &nbsp; AR &nbsp; ';}
		$o++;
		}

	$o=0;
	while ($cid_groups_to_print > $o) 
		{
		$stmt="SELECT count(*) from vicidial_campaign_cid_areacodes where campaign_id=\"$cid_group_id[$o]\";";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=396111111111&cid_group_id=$cid_group_id[$o]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=396111111111&cid_group_id=$cid_group_id[$o]\"><font size=1 color=black>$cid_group_id[$o]</a></td>";
		echo "<td><font size=1> $cid_group_notes[$o]</td>";
		echo "<td><font size=1> $cid_group_type[$o]</td>";
		echo "<td align=left><font size=1> <b>$cid_auto_rotate_minutes[$o]</b></td>";
		echo "<td><font size=1> $admin_group[$o]</td>";
		echo "<td><font size=1>$row[0]</td>";
		echo "<td><font size=1><a href=\"$PHP_SELF?ADD=396111111111&cid_group_id=$cid_group_id[$o]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=197000000000 display all VM Message group entries
######################
if ($ADD==197000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_vm_messages.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT leave_vm_message_group_id,leave_vm_message_group_notes,active,user_group from leave_vm_message_groups $whereLOGadmin_viewable_groupsSQL order by leave_vm_message_group_id;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$vmm_groups_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("VM MESSAGE GROUP LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<TR BGCOLOR=BLACK>";
	echo "<TD><font size=1 color=white>"._QXZ("VMM GROUP ID")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("NOTES")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("ACTIVE")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("GROUP")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("MSGS")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("MODIFY")."</TD>\n";
	echo "</TR>\n";

	$o=0;
	$leave_vm_message_group_id = $MT;
	$leave_vm_message_group_notes = $MT;
	$VMMGactive = $MT;
	$admin_group = $MT;

	while ($vmm_groups_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		$leave_vm_message_group_id[$o] =		$row[0];
		$leave_vm_message_group_notes[$o] =		$row[1];
		$VMMGactive[$o] =	_QXZ("$row[2]");
		$admin_group[$o] =		(preg_match('/\-\-ALL\-\-/', $row[3]) ? _QXZ("$row[3]") : $row[3]);
		$o++;
		}

	$o=0;
	while ($vmm_groups_to_print > $o) 
		{
		$stmt="SELECT count(*) from leave_vm_message_groups_entries where leave_vm_message_group_id=\"$leave_vm_message_group_id[$o]\";";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=397111111111&leave_vm_message_group_id=$leave_vm_message_group_id[$o]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=397111111111&leave_vm_message_group_id=$leave_vm_message_group_id[$o]\"><font size=1 color=black>$leave_vm_message_group_id[$o]</a></td>";
		echo "<td><font size=1> $leave_vm_message_group_notes[$o]</td>";
		echo "<td><font size=1> "._QXZ("$VMMGactive[$o]")."</td>";
		echo "<td><font size=1> $admin_group[$o]</td>";
		echo "<td><font size=1> $row[0]</td>";
		echo "<td><font size=1><a href=\"$PHP_SELF?ADD=397111111111&leave_vm_message_group_id=$leave_vm_message_group_id[$o]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=198000000000 display all Queue Group entries
######################
if ($ADD==198000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_queuegroups.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT queue_group,queue_group_name,active,user_group,included_campaigns,included_inbound_groups from vicidial_queue_groups $whereLOGadmin_viewable_groupsSQL order by queue_group;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$queue_groups_to_print = mysqli_num_rows($rslt);
	if ($DB) {echo "|$queue_groups_to_print|$stmt|\n";}

	echo "<br>"._QXZ("QUEUE GROUP LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<TR BGCOLOR=BLACK>";
	echo "<TD><font size=1 color=white>"._QXZ("QUEUE GROUP ID")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("NOTES")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("ACTIVE")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("GROUP")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("#")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("ENTRIES")."</TD>";
	echo "<TD><font size=1 color=white>"._QXZ("MODIFY")."</TD>\n";
	echo "</TR>\n";

	$o=0;
	$queue_group_ids = $MT;
	$queue_group_names = $MT;
	$QGactive = $MT;
	$QGentries = $MT;
	$admin_group = $MT;

	while ($queue_groups_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		$queue_group_ids[$o] =		$row[0];
		$queue_group_names[$o] =	$row[1];
		$QGactive[$o] =	_QXZ("$row[2]");
		$admin_group[$o] =		(preg_match('/\-\-ALL\-\-/', $row[3]) ? _QXZ("$row[3]") : $row[3]);
		$temp_included_campaigns =	$row[4];
		$temp_included_campaigns = preg_replace("/ -$/",'',$temp_included_campaigns);
		$temp_included_inbound_groups =	$row[5];
		$temp_included_inbound_groups = preg_replace("/ -$/",'',$temp_included_inbound_groups);
		$QGentries[$o] = "$temp_included_campaigns$temp_included_inbound_groups";
		if ($DB) {echo "<br>$o|$queue_group_ids[$o]|$queue_group_names[$o]|$QGentries[$o]|\n";}
		$o++;
		}

	$o=0;
	while ($queue_groups_to_print > $o) 
		{
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		$temp_entries_ct=0;
		if (preg_match("/ /",$QGentries[$o]))
			{
			$temp_entries_ARY = explode(' ',$QGentries[$o]);
			$temp_entries_ct = count($temp_entries_ARY);
			while(strlen($QGentries[$o]) > 40) {$QGentries[$o] = preg_replace("/.$/",'',$QGentries[$o]);}
			if (strlen($QGentries[$o]) >= 40) {$QGentries[$o] .= "...";}
			}

		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=398111111111&queue_group=$queue_group_ids[$o]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=398111111111&queue_group=$queue_group_ids[$o]\"><font size=1 color=black>$queue_group_ids[$o]</a></td>";
		echo "<td><font size=1> $queue_group_names[$o]</td>";
		echo "<td><font size=1> "._QXZ("$QGactive[$o]")."</td>";
		echo "<td><font size=1> $admin_group[$o]</td>";
		echo "<td><font size=1> $temp_entries_ct</td>";
		echo "<td><font size=1> $QGentries[$o]</td>";
		echo "<td><font size=1><a href=\"$PHP_SELF?ADD=398111111111&queue_group=$queue_group_ids[$o]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=1000000000000 display all conferences
######################
if ($ADD==1000000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_conferences.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT conf_exten,server_ip,extension from conferences order by conf_exten";
	$rslt=mysql_to_mysqli($stmt, $link);
	$conferences_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("CONFERENCE LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white align=left><B>"._QXZ("CONFERENCE")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("SERVER IP")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("EXTENSION")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($conferences_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=3111111111111&conf_exten=$row[0]&server_ip=$row[1]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=3111111111111&conf_exten=$row[0]&server_ip=$row[1]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1>$row[1]</td>";
		echo "<td><font size=1>$row[2]</td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=3111111111111&conf_exten=$row[0]&server_ip=$row[1]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=10000000000000 display all vicidial conferences
######################
if ($ADD==10000000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_conferences.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT conf_exten,server_ip,extension from vicidial_conferences order by conf_exten";
	$rslt=mysql_to_mysqli($stmt, $link);
	$vicidialconf_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("AGENT CONFERENCE LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white align=left><B>"._QXZ("CONFERENCE")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("SERVER IP")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("EXTENSION")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($vicidialconf_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=31111111111111&conf_exten=$row[0]&server_ip=$row[1]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=31111111111111&conf_exten=$row[0]&server_ip=$row[1]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1> $row[1]</td>";
		echo "<td><font size=1> $row[2]</td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=31111111111111&conf_exten=$row[0]&server_ip=$row[1]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=12000000000000 display all vicidial confbridges
######################
if ($ADD==12000000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<img src=\"images/icon_conferences.png\" width=42 height=42 align=left> <FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$stmt="SELECT conf_exten,server_ip,extension from vicidial_confbridges order by conf_exten";
	$rslt=mysql_to_mysqli($stmt, $link);
	$vicidialconf_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("AGENT CONFBRIDGE LISTINGS").":\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<tr bgcolor=black>";
	echo "<td><font size=1 color=white align=left><B>"._QXZ("CONFBRIDGE")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("SERVER IP")."</B></td>";
	echo "<td><font size=1 color=white><B>"._QXZ("EXTENSION")."</B></td>";
	echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></td></tr>\n";

	$o=0;
	while ($vicidialconf_to_print > $o) 
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=32111111111111&conf_exten=$row[0]&server_ip=$row[1]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=32111111111111&conf_exten=$row[0]&server_ip=$row[1]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1> $row[1]</td>";
		echo "<td><font size=1> $row[2]</td>";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=32111111111111&conf_exten=$row[0]&server_ip=$row[1]\">"._QXZ("MODIFY")."</a></td></tr>\n";
		$o++;
		}

	echo "</TABLE></center>\n";
	}


######################
# ADD=100000000000000 display all qc campaigns
######################
if (($ADD==100000000000000) && ($qc_auth=='1'))
	{
    echo "<TABLE><TR><TD>\n";
    echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";


    echo "<img src=\"images/icon_black_qc.png\" alt=\"Quality Control\" width=42 height=42> "._QXZ("Quality Control Listings").":\n";

	if (!$qc_display_group_type) {$qc_display_group_type="CAMPAIGN";}

	if ($qc_display_group_type=="CAMPAIGN")
		{
		$stmt="SELECT campaign_id,campaign_name,qc_statuses_id from vicidial_campaigns where active = 'Y' and qc_statuses_id!='' and qc_scorecard_id!='' $LOGqc_allowed_campaignsSQL order by campaign_name";
		$rslt=mysql_to_mysqli($stmt, $link);
		$vicidialconf_to_print = mysqli_num_rows($rslt);

		echo "<BR><BR><B>"._QXZ("Campaigns").":</B><BR><center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
		echo "<tr bgcolor=black>";
		echo "<td><font size=1 color=white align=left><B>"._QXZ("CAMPAIGN ID")."</B></font></td>";
		echo "<td><font size=1 color=white><B>"._QXZ("CAMPAIGN NAME")."</B></font></td>";
		echo "<td><font size=1 color=white><B>"._QXZ("QC STATUSES")."</B></font></td>";
		echo "<td><font size=1 color=white><B>"._QXZ("QUALIFYING CALLS")."</B></font></td>";
		echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></font></td></tr>\n";

		$count_column="campaign_id";
		}
	else if ($qc_display_group_type=="INGROUP") 
		{
		$stmt="SELECT group_id,group_name,qc_statuses_id from vicidial_inbound_groups where active = 'Y' and qc_statuses_id!='' and qc_scorecard_id!='' $LOGqc_allowed_campaignsSQL order by group_id";
		$rslt=mysql_to_mysqli($stmt, $link);
		$vicidialconf_to_print = mysqli_num_rows($rslt);

		echo "<BR><BR><B>"._QXZ("Ingroups").":</B><BR><center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
		echo "<tr bgcolor=black>";
		echo "<td><font size=1 color=white align=left><B>"._QXZ("GROUP ID")."</B></font></td>";
		echo "<td><font size=1 color=white><B>"._QXZ("GROUP NAME")."</B></font></td>";
		echo "<td><font size=1 color=white><B>"._QXZ("QC STATUSES")."</B></font></td>";
		echo "<td><font size=1 color=white><B>"._QXZ("QUALIFYING CALLS")."</B></font></td>";
		echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></font></td></tr>\n";

		$count_column="group_id";
		}
	else if ($qc_display_group_type=="LIST") 
		{
	    $stmt="SELECT list_id,list_name,qc_statuses_id from vicidial_lists where active = 'Y' and qc_statuses_id!='' and qc_scorecard_id!='' $LOGqc_allowed_campaignsSQL order by list_id";
	    $rslt=mysql_to_mysqli($stmt, $link);
		# echo $stmt;
	    $vicidialconf_to_print = mysqli_num_rows($rslt);

		echo "<BR><BR><B>"._QXZ("Lists").":</B><BR><center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
		echo "<tr bgcolor=black>";
		echo "<td><font size=1 color=white align=left><B>"._QXZ("LIST ID")."</B></font></td>";
		echo "<td><font size=1 color=white><B>"._QXZ("LIST NAME")."</B></font></td>";
		echo "<td><font size=1 color=white><B>"._QXZ("QC STATUSES")."</B></font></td>";
		echo "<td><font size=1 color=white><B>"._QXZ("QUALIFYING CALLS")."</B></font></td>";
		echo "<td align=center><font size=1 color=white><B>"._QXZ("MODIFY")."</B></font></td></tr>\n";

		$count_column="list_id";
		}

	if ($vicidialconf_to_print==0) 
		{
		echo "<tr><td align='center' colspan='5'><font size=1><B>*** "._QXZ("NO ".$qc_display_group_type."S CONFIGURED FOR QC")." ***</B></font></td></tr>";
		}

	# $DB=1;
	if ($DB) {echo "$qc_display_group_type|$stmt<BR>";}

    $o=0;
    while ($vicidialconf_to_print > $o) 
		{
        $row=mysqli_fetch_row($rslt);
		if (preg_match("/1$|3$|5$|7$|9$/i", $o))
			{
            $bgcolor='class="records_list_x"';
			}
        else 
			{
            $bgcolor='class="records_list_y"';
			}

		#$qc_statuses=explode(' ',$qc_status_list);
		$qc_status_list=array();
		$qc_status_container_stmt="select container_entry from vicidial_settings_containers where container_id='$row[2]'";
		$qc_status_container_rslt=mysql_to_mysqli($qc_status_container_stmt, $link);
		while ($qcsc_row=mysqli_fetch_row($qc_status_container_rslt))
			{
			$container_text=preg_split('/\r|\n/', $qcsc_row[0]);
			for ($q=0; $q<count($container_text); $q++)
				{
				$line=trim($container_text[$q]);
				if (!preg_match('/^[\#|\;]/', $line) && strlen($line)>0)
					{
					$qc_status_list=preg_split('/,/', $line); 
					break;
					}
				}
			}

#		$qc_ct_stmt="select count(*) from vicidial_list inner join vicidial_lists on vicidial_list.list_id=vicidial_lists.list_id and status in ('".implode("','", $qc_statuses)."') where campaign_id='$row[0]'"; 

		$total_qc_count=0;
		# Campaign
		if ($qc_display_group_type=="CAMPAIGN")
			{
			$qc_ct_stmt="select count(*) From vicidial_agent_log where campaign_id='$row[0]' and status in ('".implode("','", $qc_status_list)."') and event_time+INTERVAL (pause_sec+wait_sec) SECOND>=now()-INTERVAL $SSqc_expire_days DAY"; 
			if ($DB) {echo "|$qc_ct_stmt|<BR>\n";}
			$qc_ct_rslt=mysql_to_mysqli($qc_ct_stmt, $link);
			$qc_ct_row=mysqli_fetch_row($qc_ct_rslt);
			$total_qc_count=$qc_ct_row[0];
			}

		# List
		if ($qc_display_group_type=="LIST")
			{
			$agent_log_stmt="select lead_id From vicidial_agent_log where status in ('".implode("','", $qc_status_list)."') and event_time+INTERVAL (pause_sec+wait_sec) SECOND>=now()-INTERVAL $SSqc_expire_days DAY"; 
			if ($DB) {echo "|$agent_log_stmt|<BR>\n";}
			$agent_log_rslt=mysql_to_mysqli($agent_log_stmt, $link);
			while ($agent_log_row=mysqli_fetch_array($agent_log_rslt))
				{
				$lead_id=$agent_log_row["lead_id"];
				$list_id_stmt="select count(*) from vicidial_list where list_id='$row[0]' and lead_id='$lead_id'";
				# if ($DB) {echo "|$list_id_stmt|<BR>\n";}
				$list_id_rslt=mysql_to_mysqli($list_id_stmt, $link);
				$lid_row=mysqli_fetch_row($list_id_rslt);
				$total_qc_count+=$lid_row[0];
				}
			}

		# Ingroup
		if ($qc_display_group_type=="INGROUP")
			{
			$qc_ct_stmt="select count(*) From vicidial_closer_log where campaign_id='$row[0]' and status in ('".implode("','", $qc_status_list)."') and call_date>=now()-INTERVAL $SSqc_expire_days DAY"; 
			if ($DB) {echo "|$qc_ct_stmt|<BR>\n";}
			$qc_ct_rslt=mysql_to_mysqli($qc_ct_stmt, $link);
			$qc_ct_row=mysqli_fetch_row($qc_ct_rslt);
			$total_qc_count=$qc_ct_row[0];
			}

		$qc_grabbed_stmt="select count(*) From quality_control_queue where $count_column='$row[0]' and status in ('".implode("','", $qc_status_list)."') and call_date>=now()-INTERVAL $SSqc_expire_days DAY";
		if ($DB) {echo "|$qc_grabbed_stmt|<BR>\n";}
		$qc_grabbed_rslt=mysql_to_mysqli($qc_grabbed_stmt, $link);
		$qc_grabbed_row=mysqli_fetch_row($qc_grabbed_rslt);
		$total_grabbed_count=$qc_grabbed_row[0];

        echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=881&qc_display_group_type=$qc_display_group_type&$count_column=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=881&qc_display_group_type=$qc_display_group_type&$count_column=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
        echo "<td><font size=1> $row[1]</td>";
        echo "<td><font size=1> ".implode(", ", $qc_status_list)."</td>";
        echo "<td><font size=1> ".($total_qc_count-$total_grabbed_count+0)."</td>";
        echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=31&campaign_id=$row[0]\">"._QXZ("MODIFY")."</a></td></tr>\n";
        $o++;
		}
    echo "</TABLE></center>\n";
	}


######################
# ADD=881 VIEW one qc campaign
######################
if (($ADD==881) && ($qc_auth=='1')) 
	{

	if (!$qc_display_group_type) {$qc_display_group_type=="CAMPAIGN";}

	$referring_URL_string="&referring_section=$qc_display_group_type";
	switch($qc_display_group_type)	
		{
		case "CAMPAIGN":
			$referring_URL_string.="&referring_element=$campaign_id";
			break;
		case "LIST":
			$referring_URL_string.="&referring_element=$list_id";
			break;
		case "INGROUP":
			$referring_URL_string.="&referring_element=$group_id";
			break;
		}

	$qc_claim_stmt="select count(*) from quality_control_queue where qc_agent='$PHP_AUTH_USER' and qc_status='CLAIMED'"; #  $LOGqc_allowed_campaignsSQL
	if ($DB) {echo $qc_claim_stmt."<BR>\n";}
	$qc_claim_rslt=mysql_to_mysqli($qc_claim_stmt, $link);
	$queue_ct_row=mysqli_fetch_row($qc_claim_rslt);

	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
	# echo "<TABLE>\n";
	
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";

	if ($queue_ct_row[0]>0)
		{
		echo "<tr bgcolor='black'>"; # #".$SSmenu_background."
		echo "<td colspan='5'><font size=1 color=white align=left><B>"._QXZ("YOUR CURRENT UNFINISHED QC CALLS")." ($queue_ct_row[0] "._QXZ("records").")</B></td>";
		echo "</tr>";
		echo "<tr bgcolor='black'>"; # #".$SSmenu_background."
		echo "<td><font size=1 color=white align=left><B>"._QXZ("QC ID")."</B></td>";
		echo "<td><font size=1 color=white align=left><B>"._QXZ("LEAD ID")."</B></td>";
		echo "<td><font size=1 color=white><B>"._QXZ("NAME")."</B></td>";
		echo "<td><font size=1 color=white><B>"._QXZ("Date Claimed")."</B></td>";
		echo "<td><font size=1 color=white><B>"._QXZ("Date Modified")."</B></td></tr>\n";
		$queue_stmt="select * from quality_control_queue where qc_agent='$PHP_AUTH_USER' and qc_status='CLAIMED' order by date_claimed";
		if ($DB) {echo $queue_stmt."<BR>\n";}
		$queue_rslt=mysql_to_mysqli($queue_stmt, $link);
		$q=0;
		while ($queue_row=mysqli_fetch_array($queue_rslt)) 
			{
			$qc_id=$queue_row["qc_log_id"];
			$lead_id=$queue_row["lead_id"];
			$date_claimed=$queue_row["date_claimed"];
			$date_modified=$queue_row["date_modified"];
			$name_stmt="select concat(first_name, ' ', last_name) from vicidial_list where lead_id='$lead_id'";
			$name_rslt=mysql_to_mysqli($name_stmt, $link);
			$name_row=mysqli_fetch_row($name_rslt);
			$full_name=trim($name_row[0]);

			if (preg_match("/1$|3$|5$|7$|9$/i", $q))
				{
				$bgcolor='class="records_list_x"';
				}
			else
				{
				$bgcolor='class="records_list_y"';
				}
			echo "<tr $bgcolor>";
			echo "<td><font size=1 align=left><B> <a href=\"qc_modify_lead.php?qc_log_id=$qc_id&lead_id=$lead_id$referring_URL_string\">$qc_id</a></B></td>";
			echo "<td><font size=1 align=left><B> $lead_id</B></td>";
			echo "<td><font size=1><B> $full_name</B></td>";
			echo "<td><font size=1><B> $date_claimed</B></td>";
			echo "<td><font size=1><B> $date_modified</B></td></tr>\n";
			$q++;
			}
		echo "<tr>"; # #".$SSmenu_background."
		echo "<td colspan='5'>&nbsp;</td>";
		echo "</tr>";
		}


	if ($queue_ct_row[0]<$SSqc_claim_limit)
		{

		if ($qc_display_group_type=="CAMPAIGN") 
			{
			$stmt="SELECT campaign_id,campaign_name, qc_statuses_id, 'CALL' as qc_display_method, qc_scorecard_id from vicidial_campaigns where active='Y' and qc_statuses_id!='' and qc_scorecard_id!='' and campaign_id='$campaign_id'";
			$campaign_clause=" and campaign_id='$campaign_id'"; # Used further down
			$display_clause=" and campaign_id='$campaign_id'"; # Used further down
			}
		else if ($qc_display_group_type=="LIST")
			{
			$stmt="SELECT list_id,list_name, qc_statuses_id, 'CALL' as qc_display_method, qc_scorecard_id from vicidial_lists where active='Y' and qc_statuses_id!='' and qc_scorecard_id!='' and list_id='$list_id'";
			$campaign_clause="";
			$display_clause=" and list_id='$list_id'"; # Used further down
			}
		else if ($qc_display_group_type=="INGROUP")
			{
			$stmt="SELECT group_id,group_name, qc_statuses_id, 'CALL' as qc_display_method, qc_scorecard_id from vicidial_inbound_groups where active='Y' and qc_statuses_id!='' and qc_scorecard_id!='' and group_id='$group_id'";
			$campaign_clause=" and comments in ('CHAT', 'EMAIL', 'INBOUND')";
			$display_clause=" and comments in ('CHAT', 'EMAIL', 'INBOUND')"; # Used further down
			}

		# $DB=1;
		# $stmt="SELECT campaign_id,campaign_name, qc_statuses, 'LEAD' as qc_display_method, qc_scorecard_id from vicidial_campaigns where active = 'Y' and qc_enabled='Y' and campaign_id='$campaign_id' $LOGqc_allowed_campaignsSQL limit 1";
		if ($DB) {echo $stmt."<BR>\n";}
		$rslt=mysql_to_mysqli($stmt, $link);
		$vicidialconf_to_print = mysqli_num_rows($rslt);
		if ($vicidialconf_to_print > 0) 
			{
			$row=mysqli_fetch_row($rslt);
			# $qc_status_list=substr($row[2],0,strlen($row[2])-2);
			$qc_display_method=$row[3];
			$qc_scorecard_id=$row[4];

			$qc_status_list=array();
			$qc_status_container_stmt="select container_entry from vicidial_settings_containers where container_id='$row[2]'";
			$qc_status_container_rslt=mysql_to_mysqli($qc_status_container_stmt, $link);
			while ($qcsc_row=mysqli_fetch_row($qc_status_container_rslt))
				{
				$container_text=preg_split('/\r|\n/', $qcsc_row[0]);
				for ($q=0; $q<count($container_text); $q++)
					{
					$line=trim($container_text[$q]);
					if (!preg_match('/^[\#|\;]/', $line) && strlen($line)>0)
						{
						$qc_status_list=preg_split('/,/', $line); 
						break;
						}
					}
				}

			echo "<br><B>"._QXZ("$qc_display_group_type")." $row[0] - "._QXZ("Quality Control Queue")."<br>"._QXZ("QC statuses").": ".implode(", ", $qc_status_list)."</B><BR><BR>\n";

			switch ($qc_sort_method) 
				{
				case "STATUS":
					$sort_clause_call="order by status, call_date";
					$sort_clause_lead="order by status, modify_date, last_local_call_time";
					break;
				case "CALL_DATE":
					$sort_clause_call="order by call_date, status";
					$sort_clause_lead="order by last_local_call_time, status, modify_date";
					break;
				case "STATUS_DESC":
					$sort_clause_call="order by status desc, call_date";
					$sort_clause_lead="order by status desc, modify_date, last_local_call_time";
					break;
				case "CALL_DATE_DESC":
					$sort_clause_call="order by call_date desc, status";
					$sort_clause_lead="order by last_local_call_time desc, status, modify_date desc";
					break;
				}

			sort($qc_status_list);
			foreach ( $qc_status_list as $qc_status ) 
				{
				#if ($qc_display_method=="CALL") 
				#	{
				$stmt="select lead_id, agent_log_id, event_time+INTERVAL (wait_sec+pause_sec) SECOND as call_date, user, status, uniqueid from vicidial_agent_log where lead_id is not null and status='$qc_status' and event_time+INTERVAL (wait_sec+pause_sec) SECOND>=now()-INTERVAL $SSqc_expire_days DAY $campaign_clause $sort_clause_call";
				if ($DB) {echo $stmt."<BR>\n";}
				#	}
				#else
				#	{
				#	$stmt="SELECT lead_id,first_name,last_name,modify_date,user from vicidial_list inner join vicidial_lists on vicidial_list.list_id=vicidial_lists.list_id where campaign_id='$campaign_id' and status='$qc_status' order by status, modify_date $sort_clause_lead";
				#	}
				$rslt=mysql_to_mysqli($stmt, $link);
				$vicidialconf_to_print = mysqli_num_rows($rslt);
				$o=0; $q=0;
				$prev_status="";
				while ($vicidialconf_to_print > $o) 
					{
					$row=mysqli_fetch_array($rslt);
					$current_status=$row["status"];
					$lead_id=$row["lead_id"];
					$agent_log_id=$row["agent_log_id"];
					$uniqueid=$row["uniqueid"];
					$comments=$row["comments"];

					# if ($qc_display_method=="CALL") {$display_clause="agent_log_id='$agent_log_id'";} else {$display_clause="lead_id='$lead_id'";}

					if ($qc_display_group_type=="LIST")
						{
						# Check if call belongs to selected list, otherwise skip
						$followup_stmt="select count(*) From vicidial_list where lead_id='$lead_id' and list_id='$list_id'";
						$followup_rslt=mysql_to_mysqli($followup_stmt, $link);
						$followup_row=mysqli_fetch_row($followup_rslt);
						$matched_qc_record=$followup_row[0];
						}
					else if ($qc_display_group_type=="INGROUP")
						{
						# Check if call came in on selected ingroup, otherwise skip
						$followup_stmt="select count(*) From vicidial_closer_log where uniqueid='$uniqueid' and lead_id='$lead_id' and campaign_id='$group_id'";
						$followup_rslt=mysql_to_mysqli($followup_stmt, $link);
						$followup_row=mysqli_fetch_row($followup_rslt);
						$matched_qc_record=$followup_row[0];
						}
					else
						{
						# Matching campaign was already established so no skip
						$matched_qc_record=1;
						}

					if(($prev_status!=$current_status && $qc_sort_method=="STATUS") || $o==0)
						{
						echo "<tr bgcolor=black>";
						echo "<td><font size=1 color=white align=left><B>$qc_status</B></td>";
						echo "<td><font size=1 color=white align=left><B>"._QXZ("LEAD ID")."</B></td>";
						echo "<td><font size=1 color=white><B>"._QXZ("NAME")."</B></td>";
						echo "<td><font size=1 color=white><B>"._QXZ("CALL DATE")."</B></td>";
						echo "<td align=center><font size=1 color=white><B>"._QXZ("UserID")."</B></td></tr>\n";
						}
					if ($matched_qc_record)
						{
						# Only display records that are NOT in queue/claimed already.
						$qc_check_stmt="select count(*) from quality_control_queue where agent_log_id='$agent_log_id'";
						# echo $qc_check_stmt;
						$qc_check_rslt=mysql_to_mysqli($qc_check_stmt, $link);
						$qc_check_row=mysqli_fetch_row($qc_check_rslt);
						if($qc_check_row[0]==0)
							{
							$name_stmt="select concat(first_name, ' ', last_name) from vicidial_list where lead_id='$row[lead_id]'";
							$name_rslt=mysql_to_mysqli($name_stmt, $link);
							$name_row=mysqli_fetch_row($name_rslt);
							$lead_name=trim($name_row[0]);

							if (preg_match("/1$|3$|5$|7$|9$/i", $q))
								{
								$bgcolor='class="records_list_x"';
								}
							else
								{
								$bgcolor='class="records_list_y"';
								}
							echo "<tr $bgcolor><td><font size=1>&nbsp;</td>";
							echo "<td><font size=1><a href=\"qc_modify_lead.php?claim_QC=CLAIM&qc_display_method=$qc_display_method&qc_display_group_type=$qc_display_group_type$referring_URL_string&agent_log_id=$agent_log_id&qc_status=$qc_status&lead_id=$row[lead_id]&campaign_id=$campaign_id&list_id=$list_id&group_id=$group_id&lead_name=$lead_nameENC\"> $row[lead_id]</a></td>";
							$lead_nameENC=urlencode($lead_name);
							if (strlen($lead_name)<1) $lead_name='No Name';
							echo "<td><font size=1><a href=\"qc_modify_lead.php?claim_QC=CLAIM&qc_display_method=$qc_display_method&qc_display_group_type=$qc_display_group_type$referring_URL_string&agent_log_id=$agent_log_id&qc_status=$qc_status&lead_id=$row[lead_id]&campaign_id=$campaign_id&list_id=$list_id&group_id=$group_id&lead_name=$lead_nameENC\">$lead_name</a></td>";
							echo "<td><font size=1> <a href=\"qc_modify_lead.php?claim_QC=CLAIM&qc_display_method=$qc_display_method&qc_display_group_type=$qc_display_group_type$referring_URL_string&agent_log_id=$agent_log_id&qc_status=$qc_status&lead_id=$row[lead_id]&campaign_id=$campaign_id&list_id=$list_id&group_id=$group_id&lead_name=$lead_nameENC\">$row[call_date]</a></td>";
							echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=3&user=$row[user]\">$row[user]</a></td></tr>\n";
							$q++;
							}

						$prev_status=$row["status"];
						}
					$o++;
					}
				if ($DB) {echo $followup_stmt."<BR>\n";}
				}
			}
		else
			{
			echo "<B>"._QXZ("ERROR: No QC")." "._QXZ(strtolower($qc_display_group_type))." "._QXZ("available").": $campaign_id$list_id$group_id</B><BR><BR>\n";
			}

		echo "</TABLE></center>\n";
		}
	else
		{
		echo "</TABLE></center>\n";
		echo "<BR><B>*** "._QXZ("You have too many QC calls to finish to claim any more")." ***</B>\n"; # ($queue_ct_row[0] < $SSqc_claim_limit)
		}
	}


######################
# ADD=700000000000000 view all activity in the admin log
######################
if ($ADD==700000000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ($stage > 4999)
		{
		$next_limit = ($stage + 5000);
		$limitSQL = "5000 offset $stage";
		}
	else
		{
		$next_limit = "5000";
		$limitSQL = "5000";
		}

	$stmt="SELECT admin_log_id,event_date,user,ip_address,event_section,event_type,record_id,event_code,user_group from vicidial_admin_log $whereLOGadmin_viewable_groupsSQL order by event_date desc limit $limitSQL;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$logs_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("ADMIN CHANGE LOG").": ("._QXZ("Last 5000 records").")\n";
	echo "<center><TABLE width=980 cellspacing=0 cellpadding=1>\n";
	echo "<TR BGCOLOR=BLACK>";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("ID")."</B></TD>";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("DATE TIME")."</B></TD>";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("USER")."</B></TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("IP")."</TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("SECTION")."</TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("TYPE")."</TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("RECORD ID")."</TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("GROUP")."</TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("DESCRIPTION")."</TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("GOTO")."</TD>\n";
	echo "</TR>\n";

	$logs_printed = '';
	$o=0;
	while ($logs_to_print > $o)
		{
		$row=mysqli_fetch_row($rslt);
		if (preg_match('/USER|AGENT/i', $row[4])) {$record_link = "$PHP_SELF?ADD=3&user=$row[6]";}
		if (preg_match('/CAMPAIGN/i', $row[4])) {$record_link = "$PHP_SELF?ADD=31&campaign_id=$row[6]";}
		if (preg_match('/LIST/i', $row[4])) {$record_link = "$PHP_SELF?ADD=311&list_id=$row[6]";}
		if (preg_match('/CUSTOM_FIELDS/i', $row[4])) {$record_link = "./$admin_lists_custom?action=MODIFY_CUSTOM_FIELDS&list_id=$row[6]";}
		if (preg_match('/SCRIPT/i', $row[4])) {$record_link = "$PHP_SELF?ADD=3111111&script_id=$row[6]";}
		if (preg_match('/FILTER/i', $row[4])) {$record_link = "$PHP_SELF?ADD=31111111&lead_filter_id=$row[6]";}
		if (preg_match('/INGROUP/i', $row[4])) {$record_link = "$PHP_SELF?ADD=3111&group_id=$row[6]";}
		if (preg_match('/DID/i', $row[4])) {$record_link = "$PHP_SELF?ADD=3311&did_id=$row[6]";}
		if (preg_match('/USERGROUP/i', $row[4])) {$record_link = "$PHP_SELF?ADD=311111&user_group=$row[6]";}
		if (preg_match('/REMOTEAGENT/i', $row[4])) {$record_link = "$PHP_SELF?ADD=31111&remote_agent_id=$row[6]";}
		if (preg_match('/PHONE/i', $row[4])) {$record_link = "$PHP_SELF?ADD=10000000000";}
		if (preg_match('/CALLTIME/i', $row[4])) {$record_link = "$PHP_SELF?ADD=311111111&call_time_id=$row[6]";}
		if (preg_match('/SHIFT/i', $row[4])) {$record_link = "$PHP_SELF?ADD=331111111&shift_id=$row[6]";}
		if (preg_match('/CONFTEMPLATE/i', $row[4])) {$record_link = "$PHP_SELF?ADD=331111111111&template_id=$row[6]";}
		if (preg_match('/CARRIER/i', $row[4])) {$record_link = "$PHP_SELF?ADD=341111111111&carrier_id=$row[6]";}
		if (preg_match('/SERVER/i', $row[4])) {$record_link = "$PHP_SELF?ADD=311111111111&server_id=$row[6]";}
		if (preg_match('/CONFERENCE/i', $row[4])) {$record_link = "$PHP_SELF?ADD=1000000000000";}
		if (preg_match('/SYSTEM/i', $row[4])) {$record_link = "$PHP_SELF?ADD=311111111111111";}
		if (preg_match('/CATEGOR/i', $row[4])) {$record_link = "$PHP_SELF?ADD=331111111111111";}
		if (preg_match('/GROUPALIAS/i', $row[4])) {$record_link = "$PHP_SELF?ADD=33111111111&group_alias_id=$row[6]";}
		if (preg_match('/LEADS/i',$row[4])) {$record_link = "admin_modify_lead.php?lead_id=$row[6]\" onclick=\"javascript:window.open('admin_modify_lead.php?lead_id=$row[6]', '_blank');return false;";}

		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=730000000000000&stage=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=730000000000000&stage=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1> $row[1]</td>";
		echo "<td><font size=1> <a href=\"$PHP_SELF?ADD=710000000000000&stage=$row[2]\">$row[2]</a></td>";
		echo "<td><font size=1> $row[3]</td>";
		echo "<td><font size=1> "._QXZ("$row[4]")."</td>";
		echo "<td><font size=1> "._QXZ("$row[5]")."</td>";
		echo "<td><font size=1> <a href=\"$PHP_SELF?ADD=720000000000000&category=$row[4]&stage=$row[6]\">$row[6]</a></td>";
		echo "<td><font size=1> $row[8]</td>";
		echo "<td><font size=1> "._QXZ("$row[7]")."</td>";
		echo "<td><font size=1> <a href=\"$record_link\">"._QXZ("GOTO")."</a></td>";
		echo "</tr>\n";
		$logs_printed .= "'$row[0]',";
		$o++;
		}
	echo "</TABLE><BR><BR>\n";
	echo "<a href=\"$PHP_SELF?ADD=700000000000000&stage=$next_limit\">"._QXZ("NEXT")."</a>\n";
	echo "</center>\n";
	}


######################
# ADD=710000000000000 view all activity in the admin log made by one user
######################
if ($ADD==710000000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$user_name='';

	$stmt="SELECT full_name from vicidial_users where user='$stage' $LOGadmin_viewable_groupsSQL;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$names_to_print = mysqli_num_rows($rslt);
	if ($names_to_print > 0)
		{
		$row=mysqli_fetch_row($rslt);
		$user_name = $row[0];
		}

	$stmt="SELECT admin_log_id,event_date,user,ip_address,event_section,event_type,record_id,event_code,user_group from vicidial_admin_log where user='$stage' $LOGadmin_viewable_groupsSQL order by event_date desc limit 5000;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$logs_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("ADMIN CHANGE LOG: Changes made by")." $stage - $user_name\n";
	echo "<center><TABLE width=980 cellspacing=0 cellpadding=1>\n";
	echo "<TR BGCOLOR=BLACK>";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("ID")."</B></TD>";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("DATE TIME")."</B></TD>";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("USER")."</B></TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("IP")."</TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("SECTION")."</TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("TYPE")."</TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("RECORD ID")."</TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("GROUP")."</TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("DESCRIPTION")."</TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("GOTO")."</TD>\n";
	echo "</TR>\n";

	$logs_printed = '';
	$o=0;
	while ($logs_to_print > $o)
		{
		$row=mysqli_fetch_row($rslt);

		if (preg_match('/USER|AGENT/i', $row[4])) {$record_link = "$PHP_SELF?ADD=3&user=$row[6]";}
		if (preg_match('/CAMPAIGN/i', $row[4])) {$record_link = "$PHP_SELF?ADD=31&campaign_id=$row[6]";}
		if (preg_match('/LIST/i', $row[4])) {$record_link = "$PHP_SELF?ADD=311&list_id=$row[6]";}
		if (preg_match('/CUSTOM_FIELDS/i', $row[4])) {$record_link = "./$admin_lists_custom?action=MODIFY_CUSTOM_FIELDS&list_id=$row[6]";}
		if (preg_match('/SCRIPT/i', $row[4])) {$record_link = "$PHP_SELF?ADD=3111111&script_id=$row[6]";}
		if (preg_match('/FILTER/i', $row[4])) {$record_link = "$PHP_SELF?ADD=31111111&lead_filter_id=$row[6]";}
		if (preg_match('/INGROUP/i', $row[4])) {$record_link = "$PHP_SELF?ADD=3111&group_id=$row[6]";}
		if (preg_match('/DID/i', $row[4])) {$record_link = "$PHP_SELF?ADD=3311&did_id=$row[6]";}
		if (preg_match('/USERGROUP/i', $row[4])) {$record_link = "$PHP_SELF?ADD=311111&user_group=$row[6]";}
		if (preg_match('/REMOTEAGENT/i', $row[4])) {$record_link = "$PHP_SELF?ADD=31111&remote_agent_id=$row[6]";}
		if (preg_match('/PHONE/i', $row[4])) {$record_link = "$PHP_SELF?ADD=10000000000";}
		if (preg_match('/CALLTIME/i', $row[4])) {$record_link = "$PHP_SELF?ADD=311111111&call_time_id=$row[6]";}
		if (preg_match('/SHIFT/i', $row[4])) {$record_link = "$PHP_SELF?ADD=331111111&shift_id=$row[6]";}
		if (preg_match('/CONFTEMPLATE/i', $row[4])) {$record_link = "$PHP_SELF?ADD=331111111111&template_id=$row[6]";}
		if (preg_match('/CARRIER/i', $row[4])) {$record_link = "$PHP_SELF?ADD=341111111111&carrier_id=$row[6]";}
		if (preg_match('/SERVER/i', $row[4])) {$record_link = "$PHP_SELF?ADD=311111111111&server_id=$row[6]";}
		if (preg_match('/CONFERENCE/i', $row[4])) {$record_link = "$PHP_SELF?ADD=1000000000000";}
		if (preg_match('/SYSTEM/i', $row[4])) {$record_link = "$PHP_SELF?ADD=311111111111111";}
		if (preg_match('/CATEGOR/i', $row[4])) {$record_link = "$PHP_SELF?ADD=331111111111111";}
		if (preg_match('/GROUPALIAS/i', $row[4])) {$record_link = "$PHP_SELF?ADD=33111111111&group_alias_id=$row[6]";}

		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}
		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=730000000000000&stage=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=730000000000000&stage=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1> $row[1]</td>";
		echo "<td><font size=1> <a href=\"$PHP_SELF?ADD=710000000000000&stage=$row[2]\">$row[2]</a></td>";
		echo "<td><font size=1> $row[3]</td>";
		echo "<td><font size=1> $row[4]</td>";
		echo "<td><font size=1> $row[5]</td>";
		echo "<td><font size=1> <a href=\"$PHP_SELF?ADD=720000000000000&category=$row[4]&stage=$row[6]\">$row[6]</a></td>";
		echo "<td><font size=1> $row[8]</td>";
		echo "<td><font size=1> $row[7]</td>";
		echo "<td><font size=1> <a href=\"$record_link\">"._QXZ("GOTO")."</a></td>";
		echo "</tr>\n";
		$logs_printed .= "'$row[0]',";
		$o++;
		}
	echo "</TABLE><BR><BR>\n";
	echo "\n";
	echo "</center>\n";
	}


######################
# ADD=720000000000000 view all activity in the admin log made to one section/value
######################
if ($ADD==720000000000000)
	{
	if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
		{
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$sectionSQL = "event_section='$category'";
		if (preg_match("/CAMPAIGNS/",$category))
			{$sectionSQL = "event_section IN('CAMPAIGNS','CAMPAIGN_SURVEY','CAMPAIGN_LISTMIX','CAMPAIGN_PRESET','CAMPAIGN_QC','CAMPAIGN_PAUSECODE','CAMPAIGN_RECYCLE','CAMPAIGN_HOTKEY','CAMPAIGN_STATUS','CAMPAIGN_DIALSTATUSES','CAMPAIGN_DIALSTATUS','CAMPAIGN_AC-CID')";}
		if (preg_match("/DIDS/",$category))
			{$sectionSQL = "event_section IN('DIDS','DID_RA-EXTEN')";}

		$stmt="SELECT admin_log_id,event_date,user,ip_address,event_section,event_type,record_id,event_code,user_group from vicidial_admin_log where $sectionSQL and record_id='$stage' $LOGadmin_viewable_groupsSQL order by event_date desc limit 5000;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$logs_to_print = mysqli_num_rows($rslt);

		echo "<br>"._QXZ("ADMIN CHANGE LOG: Section Records")." - $category - $stage\n";
		echo "<center><TABLE width=980 cellspacing=0 cellpadding=1>\n";
		echo "<TR BGCOLOR=BLACK>";
		echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("ID")."</B></TD>";
		echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("DATE TIME")."</B></TD>";
		echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("USER")."</B></TD>\n";
		echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("IP")."</TD>\n";
		echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("SECTION")."</TD>\n";
		echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("TYPE")."</TD>\n";
		echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("RECORD ID")."</TD>\n";
		echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("GROUP")."</TD>\n";
		echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("DESCRIPTION")."</TD>\n";
		echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("GOTO")."</TD>\n";
		echo "</TR>\n";

		$logs_printed = '';
		$o=0;
		while ($logs_to_print > $o)
			{
			$row=mysqli_fetch_row($rslt);

			if (preg_match('/USER|AGENT/i', $row[4])) {$record_link = "$PHP_SELF?ADD=3&user=$row[6]";}
			if (preg_match('/CAMPAIGN/i', $row[4])) {$record_link = "$PHP_SELF?ADD=31&campaign_id=$row[6]";}
			if (preg_match('/LIST/i', $row[4])) {$record_link = "$PHP_SELF?ADD=311&list_id=$row[6]";}
			if (preg_match('/CUSTOM_FIELDS/i', $row[4])) {$record_link = "./$admin_lists_custom?action=MODIFY_CUSTOM_FIELDS&list_id=$row[6]";}
			if (preg_match('/SCRIPT/i', $row[4])) {$record_link = "$PHP_SELF?ADD=3111111&script_id=$row[6]";}
			if (preg_match('/FILTER/i', $row[4])) {$record_link = "$PHP_SELF?ADD=31111111&lead_filter_id=$row[6]";}
			if (preg_match('/INGROUP/i', $row[4])) {$record_link = "$PHP_SELF?ADD=3111&group_id=$row[6]";}
			if (preg_match('/DID/i', $row[4])) {$record_link = "$PHP_SELF?ADD=3311&did_id=$row[6]";}
			if (preg_match('/USERGROUP/i', $row[4])) {$record_link = "$PHP_SELF?ADD=311111&user_group=$row[6]";}
			if (preg_match('/REMOTEAGENT/i', $row[4])) {$record_link = "$PHP_SELF?ADD=31111&remote_agent_id=$row[6]";}
			if (preg_match('/PHONE/i', $row[4])) {$record_link = "$PHP_SELF?ADD=10000000000";}
			if (preg_match('/CALLTIME/i', $row[4])) {$record_link = "$PHP_SELF?ADD=311111111&call_time_id=$row[6]";}
			if (preg_match('/CALLTIMES_STATE/i',$row[4])) {$record_link = "$PHP_SELF?ADD=3111111111&call_time_id=$row[6]";}
			if (preg_match('/HOLIDAY/i',$row[4])) {$record_link = "$PHP_SELF?ADD=3211111111&holiday_id=$row[6]";}
			if (preg_match('/SHIFT/i', $row[4])) {$record_link = "$PHP_SELF?ADD=331111111&shift_id=$row[6]";}
			if (preg_match('/CONFTEMPLATE/i', $row[4])) {$record_link = "$PHP_SELF?ADD=331111111111&template_id=$row[6]";}
			if (preg_match('/CARRIER/i', $row[4])) {$record_link = "$PHP_SELF?ADD=341111111111&carrier_id=$row[6]";}
			if (preg_match('/SERVER/i', $row[4])) {$record_link = "$PHP_SELF?ADD=311111111111&server_id=$row[6]";}
			if (preg_match('/CONFERENCE/i', $row[4])) {$record_link = "$PHP_SELF?ADD=1000000000000";}
			if (preg_match('/SYSTEM/i', $row[4])) {$record_link = "$PHP_SELF?ADD=311111111111111";}
			if (preg_match('/CATEGOR/i', $row[4])) {$record_link = "$PHP_SELF?ADD=331111111111111";}
			if (preg_match('/GROUPALIAS/i', $row[4])) {$record_link = "$PHP_SELF?ADD=33111111111&group_alias_id=$row[6]";}
			if (preg_match('/LEADS/i',$row[4])) {$record_link = "admin_modify_lead.php?lead_id=$row[6]\" onclick=\"javascript:window.open('admin_modify_lead.php?lead_id=$row[6]', '_blank');return false;";}
			if (preg_match('/VOICEMAIL/i', $row[4])) {$record_link="$PHP_SELF?ADD=371111111111&voicemail_id=$row[6]";}
			if (preg_match('/^EMAIL$/i',$row[4])) {$record_link = "./admin_email_accounts.php?eact=UPDATE&email_account_id=$row[6]";}

			if (preg_match('/1$|3$|5$|7$|9$/i', $o))
				{$bgcolor='class="records_list_x"';} 
			else
				{$bgcolor='class="records_list_y"';}
			echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=730000000000000&stage=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=730000000000000&stage=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
			echo "<td><font size=1> $row[1]</td>";
			echo "<td><font size=1> <a href=\"$PHP_SELF?ADD=710000000000000&stage=$row[2]\">$row[2]</a></td>";
			echo "<td><font size=1> $row[3]</td>";
			echo "<td><font size=1> $row[4]</td>";
			echo "<td><font size=1> $row[5]</td>";
			echo "<td><font size=1> $row[6]</td>";
			echo "<td><font size=1> $row[8]</td>";
			echo "<td><font size=1> $row[7]</td>";
			echo "<td><font size=1> <a href=\"$record_link\">"._QXZ("GOTO")."</a></td>";
			echo "</tr>\n";
			$logs_printed .= "'$row[0]',";
			$o++;
			}
		echo "</TABLE><BR><BR>\n";
		echo "\n";
		echo "</center>\n";
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=730000000000000 detail view of one admin log entry
######################
if ($ADD==730000000000000)
	{
	if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
		{
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT admin_log_id,event_date,user,ip_address,event_section,event_type,record_id,event_code,event_notes,event_sql,user_group from vicidial_admin_log where admin_log_id='$stage' $LOGadmin_viewable_groupsSQL;";
		if ($DB > 0) {echo "$stmt\n";}
		$rslt=mysql_to_mysqli($stmt, $link);
		$logs_to_print = mysqli_num_rows($rslt);

		if ($logs_to_print > 0)
			{
			$row=mysqli_fetch_row($rslt);

			$log_id =				$row[0];
			$log_date_time =		$row[1];
			$log_user =				$row[2];
			$log_ip =				$row[3];
			$log_section =			$row[4];
			$log_type =				$row[5];
			$log_record_id =		$row[6];
			$log_description =		$row[7];
			$log_notes =			$row[8];
			$log_sql =				$row[9];
			$new_sql =				$row[9];
			$log_user_group =		$row[10];

			$stmt="SELECT full_name from vicidial_users where user='$log_user';";
			if ($DB > 0) {echo "$stmt\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			$user_to_print = mysqli_num_rows($rslt);
			if ($user_to_print > 0)
				{
				$rowx=mysqli_fetch_row($rslt);
				$log_full_name =		$rowx[0];
				}

			echo "<br>"._QXZ("ADMIN CHANGE LOG: Record Detail")." - $stage<BR><BR>\n";
			echo "<center><TABLE width=$section_width cellspacing=5 cellpadding=0>\n";
			echo "<TR>";
			echo "<TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\" size=2>"._QXZ("ID").": </B></TD>";
			echo "<TD ALIGN=LEFT><FONT FACE=\"Arial,Helvetica\" size=2>$log_id</TD>";
			echo "</TR><TR>\n";
			echo "<TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\" size=2>"._QXZ("DATE TIME").": </B></TD>";
			echo "<TD ALIGN=LEFT><FONT FACE=\"Arial,Helvetica\" size=2>$log_date_time</TD>";
			echo "</TR><TR>\n";
			echo "<TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\" size=2>"._QXZ("USER").": </B></TD>";
			echo "<TD ALIGN=LEFT><FONT FACE=\"Arial,Helvetica\" size=2>$log_user - $log_full_name</TD>";
			echo "</TR><TR>\n";
			echo "<TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\" size=2>"._QXZ("IP").": </B></TD>";
			echo "<TD ALIGN=LEFT><FONT FACE=\"Arial,Helvetica\" size=2>$log_ip</TD>";
			echo "</TR><TR>\n";
			echo "<TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\" size=2>"._QXZ("SECTION").": </B></TD>";
			echo "<TD ALIGN=LEFT><FONT FACE=\"Arial,Helvetica\" size=2>$log_section</TD>";
			echo "</TR><TR>\n";
			echo "<TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\" size=2>"._QXZ("TYPE").": </B></TD>";
			echo "<TD ALIGN=LEFT><FONT FACE=\"Arial,Helvetica\" size=2>$log_type</TD>";
			echo "</TR><TR>\n";
			echo "<TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\" size=2>"._QXZ("RECORD ID").": </B></TD>";
			echo "<TD ALIGN=LEFT><FONT FACE=\"Arial,Helvetica\" size=2>$log_record_id</TD>";
			echo "</TR><TR>\n";
			echo "<TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\" size=2>"._QXZ("DESCRIPTION").": </B></TD>";
			echo "<TD ALIGN=LEFT><FONT FACE=\"Arial,Helvetica\" size=1>$log_description</TD>";
			echo "</TR><TR>\n";
			echo "<TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\" size=2>"._QXZ("ADMIN GROUP").": </B></TD>";
			echo "<TD ALIGN=LEFT><FONT FACE=\"Arial,Helvetica\" size=1>$log_user_group</TD>";
			echo "</TR><TR>\n";
			echo "<TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\" size=2>"._QXZ("NOTES").": </B></TD>";
			echo "<TD ALIGN=LEFT><FONT FACE=\"Arial,Helvetica\" size=1>$log_notes</TD>";
			echo "</TR><TR>\n";

			$log_sql = preg_replace('/\',/i', '\' ,',$log_sql);
			$log_sql = preg_replace("/\|/","<BR>",$log_sql);
			echo "<TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\" size=2>"._QXZ("SQL").": </B></TD>";
			echo "<TD ALIGN=LEFT width=700><p style=\"width: 700; text-wrap: normal; word-wrap: break-word\"><FONT FACE=\"Arial,Helvetica\" size=1>$log_sql</TD>";

			$stmt="SELECT admin_log_id,event_date,user,ip_address,event_section,event_type,record_id,event_code,event_notes,event_sql,user_group from vicidial_admin_log where event_section='$log_section' and event_type='$log_type' and record_id='$log_record_id' and event_code='$log_description' and admin_log_id < $log_id $LOGadmin_viewable_groupsSQL order by admin_log_id desc;";
			if ($DB > 0) {echo "$stmt\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			$last_to_print = mysqli_num_rows($rslt);

			if ($last_to_print > 0)
				{
				$rowx=mysqli_fetch_row($rslt);
				echo "</TR><TR>\n";
				echo "<TD ALIGN=CENTER COLSPAN=2><B><FONT FACE=\"Arial,Helvetica\" size=2><BR>"._QXZ("DIFF TO LAST CHANGE")."<BR>"._QXZ("ID").": <a href=\"$PHP_SELF?ADD=730000000000000&stage=$rowx[0]\">$rowx[0]</a> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"._QXZ("DATE TIME").": $rowx[1] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"._QXZ("USER").": $rowx[2]</B></TD></TR>";
				echo "<TR><TD ALIGN=LEFT COLSPAN=2>";

				// include the Diff class
				require_once './class.Diff.php';

				// output the result of comparing two files as HTML
				if ( ($log_description == 'ADMIN MODIFY LEAD') and (strlen($log_notes) > 50) )
					{
					$log_notes_ARY = explode("---ORIG---NEW---",$log_notes);
					$log_notes_ARY[0] = preg_replace('/\',/i', '\' ,',$log_notes_ARY[0]);
					$log_notes_ARY[0] = preg_replace('/\|/', "\n",$log_notes_ARY[0]);
					$log_notes_ARY[1] = preg_replace('/\',/i', '\' ,',$log_notes_ARY[1]);
					$log_notes_ARY[1] = preg_replace('/\|/', "\n",$log_notes_ARY[1]);
					echo Diff::toTable(Diff::compare($log_notes_ARY[0], $log_notes_ARY[1]));
					}
				else
					{
					$new_sql = preg_replace('/\',/i', '\' ,',$new_sql);
					$new_sql = preg_replace('/ ,/', "\n",$new_sql);
					$rowx[9] = preg_replace('/\',/i', '\' ,',$rowx[9]);
					$rowx[9] = preg_replace('/ ,/', "\n",$rowx[9]);
					echo Diff::toTable(Diff::compare($rowx[9], $new_sql));
					}
				}
			else
				{
				if ( ($log_description == 'ADMIN MODIFY LEAD') and (strlen($log_notes) > 50) )
					{
					echo "</TR><TR>\n";
					echo "<TD ALIGN=CENTER COLSPAN=2><B><FONT FACE=\"Arial,Helvetica\" size=2><BR>"._QXZ("DIFF FROM PREVIOUS VALUES")."</B></TD></TR>";
					echo "<TR><TD ALIGN=LEFT COLSPAN=2>";

					// include the Diff class
					require_once './class.Diff.php';

					$log_notes_ARY = explode("---ORIG---NEW---",$log_notes);
					$log_notes_ARY[0] = preg_replace('/\',/i', '\' ,',$log_notes_ARY[0]);
					$log_notes_ARY[0] = preg_replace('/\|/', "\n",$log_notes_ARY[0]);
					$log_notes_ARY[1] = preg_replace('/\',/i', '\' ,',$log_notes_ARY[1]);
					$log_notes_ARY[1] = preg_replace('/\|/', "\n",$log_notes_ARY[1]);
					echo Diff::toTable(Diff::compare($log_notes_ARY[0], $log_notes_ARY[1]));
					}
				}

			echo "</TD>";
			echo "</TR>\n";
			echo "</TABLE><BR><BR>\n";
			echo "\n";
			echo "</center>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=800000000000000 view all activity in the admin report log
######################
if ($ADD==800000000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ($stage > 4999)
		{
		$next_limit = ($stage + 5000);
		$limitSQL = "5000 offset $stage";
		}
	else
		{
		$next_limit = "5000";
		$limitSQL = "5000";
		}

	$stmt="SELECT report_log_id,event_date,user,ip_address,report_name,browser,referer,notes,url,run_time from vicidial_report_log order by event_date desc limit $limitSQL;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$logs_to_print = mysqli_num_rows($rslt);


	echo "<br>"._QXZ("ADMIN REPORT LOG: (Last 5000 records)")."\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<TR BGCOLOR=BLACK>";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("ID")."</B></TD>";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("DATE TIME")."</B></TD>";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("USER")."</B></TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("IP")."</TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("REPORT")."</TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("RUN TIME")."</TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("GOTO")."</TD>\n";
	echo "</TR>\n";

	$logs_printed = '';
	$o=0;
	while ($logs_to_print > $o)
		{
		$row=mysqli_fetch_row($rslt);

		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}

		$run_color='color=blue';
		if ($row[9] > 5) {$run_color='color=black';} 
		if ($row[9] > 10) {$run_color='color=purple';} 
		if ($row[9] > 30) {$run_color='color=red';} 

		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=830000000000000&stage=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=830000000000000&stage=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1> $row[1]</td>";
		echo "<td><font size=1> <a href=\"$PHP_SELF?ADD=810000000000000&stage=$row[2]\">$row[2]</a></td>";
		echo "<td><font size=1> $row[3]</td>";
		echo "<td><font size=1> $row[4]</td>";
		echo "<td><font size=1 $run_color> $row[9]</td>";
		echo "<td><font size=1> <a href=\"$PHP_SELF?ADD=830000000000000&stage=$row[0]\">"._QXZ("GOTO")."</a></td>";
		echo "</tr>\n";
		$logs_printed .= "'$row[0]',";
		$o++;
		}
	echo "</TABLE><BR><BR>\n";
	echo "<a href=\"$PHP_SELF?ADD=800000000000000&stage=$next_limit\">"._QXZ("NEXT")."</a>\n";
	echo "</center>\n";
	}


######################
# ADD=810000000000000 view all activity in the report log made by one user
######################
if ($ADD==810000000000000)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$user_name='';

	$stmt="SELECT full_name from vicidial_users where user='$stage' $LOGadmin_viewable_groupsSQL;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$names_to_print = mysqli_num_rows($rslt);
	if ($names_to_print > 0)
		{
		$row=mysqli_fetch_row($rslt);
		$user_name = $row[0];
		}

	$stmt="SELECT report_log_id,event_date,user,ip_address,report_name,browser,referer,notes,url,run_time from vicidial_report_log where user='$stage' order by event_date desc limit 5000;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$logs_to_print = mysqli_num_rows($rslt);

	echo "<br>"._QXZ("ADMIN REPORT LOG: Changes made by")." $stage - $user_name\n";
	echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
	echo "<TR BGCOLOR=BLACK>";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("ID")."</B></TD>";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("DATE TIME")."</B></TD>";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("USER")."</B></TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("IP")."</TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("REPORT")."</TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("RUN TIME")."</TD>\n";
	echo "<TD><B><FONT FACE=\"Arial,Helvetica\" size=1 color=white>"._QXZ("GOTO")."</TD>\n";
	echo "</TR>\n";

	$logs_printed = '';
	$o=0;
	while ($logs_to_print > $o)
		{
		$row=mysqli_fetch_row($rslt);

		if (preg_match('/1$|3$|5$|7$|9$/i', $o))
			{$bgcolor='class="records_list_x"';} 
		else
			{$bgcolor='class="records_list_y"';}

		$run_color='color=blue';
		if ($row[9] > 5) {$run_color='color=black';} 
		if ($row[9] > 10) {$run_color='color=purple';} 
		if ($row[9] > 30) {$run_color='color=red';} 

		echo "<tr $bgcolor"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=830000000000000&stage=$row[0]'\"";} echo "><td><a href=\"$PHP_SELF?ADD=830000000000000&stage=$row[0]\"><font size=1 color=black>$row[0]</a></td>";
		echo "<td><font size=1> $row[1]</td>";
		echo "<td><font size=1> <a href=\"$PHP_SELF?ADD=810000000000000&stage=$row[2]\">$row[2]</a></td>";
		echo "<td><font size=1> $row[3]</td>";
		echo "<td><font size=1> $row[4]</td>";
		echo "<td><font size=1 $run_color> $row[9]</td>";
		echo "<td><font size=1> <a href=\"$PHP_SELF?ADD=830000000000000&stage=$row[0]\">"._QXZ("GOTO")."</a></td>";
		echo "</tr>\n";
		$logs_printed .= "'$row[0]',";
		$o++;
		}
	echo "</TABLE><BR><BR>\n";
	echo "\n";
	echo "</center>\n";
	}


######################
# ADD=830000000000000 detail view of one report log entry
######################
if ($ADD==830000000000000)
	{
	if ($LOGuser_level >= 9)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$stmt="SELECT report_log_id,event_date,vrl.user,ip_address,report_name,browser,referer,notes,url,full_name,val.user_group,run_time from vicidial_report_log vrl, vicidial_users val where report_log_id='$stage' and val.user=vrl.user $valLOGadmin_viewable_groupsSQL;";
		if ($DB > 0) {echo "$stmt\n";}
		$rslt=mysql_to_mysqli($stmt, $link);
		$logs_to_print = mysqli_num_rows($rslt);

		if ($logs_to_print > 0)
			{
			$row=mysqli_fetch_row($rslt);

			$run_color='color=blue';
			if ($row[11] > 5) {$run_color='color=black';} 
			if ($row[11] > 10) {$run_color='color=purple';} 
			if ($row[11] > 30) {$run_color='color=red';}
			$row[5] = preg_replace("/\'|\"|\\\\|<|>/","",$row[5]);
			$row[6] = preg_replace("/\'|\"|\\\\|<|>/","",$row[6]);
			$row[8] = preg_replace("/\'|\"|\\\\|<|>/","",$row[8]);

			echo "<br>"._QXZ("ADMIN REPORT LOG: Record Detail")." - $stage<BR><BR>\n";
			echo "<center><TABLE width=$section_width cellspacing=5 cellpadding=0>\n";
			echo "<TR>";
			echo "<TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\" size=2>"._QXZ("ID").": </B></TD>";
			echo "<TD ALIGN=LEFT><FONT FACE=\"Arial,Helvetica\" size=2>$row[0]</TD>";
			echo "</TR><TR>\n";
			echo "<TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\" size=2>"._QXZ("DATE TIME").": </B></TD>";
			echo "<TD ALIGN=LEFT><FONT FACE=\"Arial,Helvetica\" size=2>$row[1]</TD>";
			echo "</TR><TR>\n";
			echo "<TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\" size=2>"._QXZ("RUN TIME").": </B></TD>";
			echo "<TD ALIGN=LEFT><FONT FACE=\"Arial,Helvetica\" size=2><font $run_color>$row[11]</font> "._QXZ("seconds")."</TD>";
			echo "</TR><TR>\n";
			echo "<TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\" size=2>"._QXZ("USER").": </B></TD>";
			echo "<TD ALIGN=LEFT><FONT FACE=\"Arial,Helvetica\" size=2>$row[2] - $row[9]</TD>";
			echo "</TR><TR>\n";
			echo "<TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\" size=2>"._QXZ("IP").": </B></TD>";
			echo "<TD ALIGN=LEFT><FONT FACE=\"Arial,Helvetica\" size=2>$row[3]</TD>";
			echo "</TR><TR>\n";
			echo "<TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\" size=2>"._QXZ("REPORT").": </B></TD>";
			echo "<TD ALIGN=LEFT><FONT FACE=\"Arial,Helvetica\" size=2>$row[4]</TD>";
			echo "</TR><TR>\n";
			echo "<TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\" size=2>"._QXZ("BROWSER").": </B></TD>";
			echo "<TD ALIGN=LEFT><FONT FACE=\"Arial,Helvetica\" size=1>$row[5]</TD>";
			echo "</TR><TR>\n";
			echo "<TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\" size=2>"._QXZ("NOTES").": </B></TD>";
			echo "<TD ALIGN=LEFT><FONT FACE=\"Arial,Helvetica\" size=1>$row[7]</TD>";
			echo "</TR><TR>\n";
			echo "<TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\" size=2>"._QXZ("REFERER").": </B></TD>";
			echo "<TD ALIGN=LEFT width=700><p style=\"width: 700; text-wrap: normal; word-wrap: break-word\"><FONT FACE=\"Arial,Helvetica\" size=1><a href=\"$row[6]\">$row[6]</a></TD>";
			echo "</TR><TR>\n";
			echo "<TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\" size=2>"._QXZ("URL").": </B></TD>";
			echo "<TD ALIGN=LEFT width=700><p style=\"width: 700; text-wrap: normal; word-wrap: break-word\"><FONT FACE=\"Arial,Helvetica\" size=1><a href=\"$row[8]\">$row[8]</a></TD>";
			echo "</TR>\n";
			echo "</TABLE><BR><BR>\n";
			echo "\n";
			echo "</center>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}


######################
# ADD=999999 display reports section
######################
if ($ADD==999999)
	{
	if ($LOGview_reports==1)
		{
		$server_id=$MT; $server_description=$MT; $server_ip=$MT; $active=$MT; $sysload=$MT; $channels_total=$MT; $cpu_idle_percent=$MT; $disk_usage=$MT; $active_agent_login_server=$MT; $active_asterisk_server=$MT;

		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		$server_id=$MT;
		$server_description=$MT;
		$server_ip=$MT;
		$active=$MT;
		$sysload=$MT;
		$channels_total=$MT;
		$cpu_idle_percent=$MT;
		$disk_usage=$MT;
		$active_agent_login_server=$MT;
		$active_asterisk_server=$MT;

		$stmt="SELECT server_id,server_description,server_ip,active,sysload,channels_total,cpu_idle_percent,disk_usage,active_agent_login_server,active_asterisk_server from servers order by server_id;";
		$rslt=mysql_to_mysqli($stmt, $link);
		if ($DB) {echo "$stmt\n";}
		$servers_to_print = mysqli_num_rows($rslt);
		$i=0;
		while ($i < $servers_to_print)
			{
			$row=mysqli_fetch_row($rslt);
			$server_id[$i] =					$row[0];
			$server_description[$i] =			$row[1];
			$server_ip[$i] =					$row[2];
			$active[$i] =						$row[3];
			$sysload[$i] =						$row[4];
			$channels_total[$i] =				$row[5];
			$cpu_idle_percent[$i] =				$row[6];
			$disk_usage[$i] =					$row[7];
			$active_agent_login_server[$i] =	$row[8];
			$active_asterisk_server[$i] =		$row[9];
			$i++;
			}

		$stmt="SELECT queuemetrics_url,vtiger_url from system_settings;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$queuemetrics_url_LU =		$row[0];
		$vtiger_url_LU =			$row[1];

		$stmt="SELECT count(*) from vicidial_list_update_log;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$list_update_count =		$row[0];

		$stmt="SELECT count(*) from dialable_inventory_snapshots;";
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$inventory_report_count =	$row[0];

		?>

		</head><BODY BGCOLOR=WHITE>
		<img src="images/icon_black_reports.png" alt="Reports" width=42 height=42 align=left> 
		<FONT SIZE=4><B><?php echo _QXZ("Server Stats and Reports"); ?></B></FONT><BR>
		<FONT SIZE=1><B> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (<a href="admin.php"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK><?php echo _QXZ("System Summary"); ?></font></a>)</B></FONT><BR><BR>
		<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=0><TR><TD VALIGN=TOP>
		 &nbsp; &nbsp; &nbsp;
		</TD><TD VALIGN=TOP>

		<?php

		echo "<B>"._QXZ("Real-Time Reports")."</B><BR>\n";
		echo "<UL>\n";
		if ( (preg_match("/VERM Reports/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"../VERM/VERM_admin.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("VERM - Enhanced Reporting Module")."</a></FONT>\n";}
		if ( (preg_match("/Real-Time Main Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"realtime_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Real-Time Main Report")."</a></FONT>\n";}
				#	echo "<BR> &nbsp; Real-Time SIP: <a href=\"AST_timeonVDADall.php?SIPmonitorLINK=1\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Listen")."</a></FONT> - <a href=\"AST_timeonVDADall.php?SIPmonitorLINK=2\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Barge")."</a></FONT>\n";
				#	echo "<BR> &nbsp; Real-Time IAX: <a href=\"AST_timeonVDADall.php?IAXmonitorLINK=1\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Listen")."</a></FONT> - <a href=\"AST_timeonVDADall.php?IAXmonitorLINK=2\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Barge")."</a></FONT><BR><BR>\n";
		if ( (preg_match("/Real-Time Campaign Summary/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_timeonVDADallSUMMARY.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Real-Time Campaign Summary")."</a></FONT>\n";}
		if ( (preg_match("/Real-Time Whiteboard Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_rt_whiteboard_rpt.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Real-Time Whiteboard Report")."</a></FONT>\n";}
		echo "</UL><BR>\n";
		echo "<B>"._QXZ("Inbound and Outbound Calling Reports")."</B><BR>\n";
		echo "<UL>\n";
		if ( (preg_match("/VERM Reports/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"../VERM/VERM_admin.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("VERM - Enhanced Reporting Module")."</a></FONT>\n";}
		if ( (preg_match("/Inbound Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_CLOSERstats.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Inbound Report")."</a></FONT> - <a href=\"AST_CLOSERstats_v2.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("v2")."</a></FONT>\n";}
		if ( (preg_match("/Inbound Report by DID/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_CLOSERstats.php?DID=Y\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Inbound Report by DID")."</a></FONT>\n";}
		if ( (preg_match("/Inbound Service Level Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_CLOSER_service_level.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Inbound Service Level Report")."</a></FONT>\n";}
		if ( (preg_match("/Inbound Summary Hourly Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_CLOSERsummary_hourly.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Inbound Summary Hourly Report")."</a></FONT>\n";}
		if ( (preg_match("/Inbound Daily Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_inbound_daily_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Inbound Daily Report")."</a></FONT>\n";}
		if ( (preg_match("/Inbound DID Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_DIDstats.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Inbound DID Report")."</a></FONT>\n";}
		if ( (preg_match("/Inbound DID Summary Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo " - <a href=\"AST_DIDstats_v2.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("DID Summary")."</a></FONT>\n";}
		if ( (preg_match("/Agent DID Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo " - <a href=\"AST_agentDIDstats.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Agent DID")."</a></FONT>\n";}
		if ( (preg_match("/Inbound IVR Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_IVRstats.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Inbound IVR Report")."</a></FONT>\n";}
		if ( (preg_match("/Inbound Forecasting Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{
			echo "<LI><a href=\"AST_inbound_forecasting.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Inbound Forecasting Report")."</a></FONT>";
			if ( (preg_match("/Advanced Forecasting Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
				{echo " - <a href=\"Erlang_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Advanced")."</a></FONT>";}
			echo "\n";
			}
		if ( (preg_match("/Outbound Calling Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_VDADstats.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Outbound Calling Report")."</a></FONT>\n";}
		if ( (preg_match("/Outbound Summary Interval Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_OUTBOUNDsummary_interval.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Outbound Summary Interval Report")."</a></FONT>\n";}
		if ( (preg_match("/Outbound IVR Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{
			echo "<LI><a href=\"AST_IVRstats.php?type=outbound\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Outbound IVR Report")."</a>";
			if ($LOGexport_reports >= 1)
				{
				if ( (preg_match("/Export Calls Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
					{echo " - <a href=\"call_report_export.php?ivr_export=YES\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Export")."</a></FONT>";}
				}
			echo "</FONT>\n";
			if ( (preg_match("/Callmenu Survey Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
				{echo " - <a href=\"AST_CMstats.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Callmenu Agent")."</a></FONT>\n";}
			}
		if ( (preg_match("/Outbound Lead Source Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_source_vlc_status_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Outbound Lead Source Report")."</a></FONT>\n";}
		if ( (preg_match("/Fronter - Closer Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"fcstats.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Fronter - Closer Report")."</a></FONT>\n";}
		if ( (preg_match("/Fronter - Closer Detail Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo " - <a href=\"fcstats_detail.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Detail")."</a></FONT>\n";}
		if ( (preg_match("/Lists Pass Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_LISTS_pass_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Lists Pass Report")."</a></FONT>\n";}
		if ( (preg_match("/Lists Campaign Statuses Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_LISTS_campaign_stats.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Lists Campaign Statuses Report")."</a></FONT>\n";}
		if ( (preg_match("/Called Counts List IDs Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"called_counts_multilist_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Called Counts List IDs Report")."</a></FONT>\n";}

		if ( (preg_match("/Campaign Status List Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_campaign_status_list_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Campaign Status List Report")."</a></FONT>\n";}
				# echo "<LI><a href=\"vicidial_sales_viewer.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("AGENT SPREADSHEET PERFORMANCE")."</a></FONT>\n";
		if ( ( (preg_match("/Dialer Inventory Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) and ($inventory_report_count > 0) )
			{echo "<LI><a href=\"AST_dialer_inventory_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Dialer Inventory Report")."</a></FONT>\n";}
		if ($SSemail_enabled > 0)
			{
			if ( ( (preg_match("/Inbound Report/",$LOGallowed_reports)) and (preg_match("/Inbound Email Report/",$LOGallowed_reports)) ) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
				{echo "<LI><a href=\"AST_CLOSERstats_v2.php?EMAIL=Y\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Inbound Email Report")."</a></FONT>\n";}
			if ( (preg_match("/Email Log Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
				{echo "<LI><a href=\"AST_email_log_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Email Log Report")."</a></FONT>\n";}
			}
		if ($SSallow_chats > 0)
			{
			if ( ( (preg_match("/Inbound Report/",$LOGallowed_reports)) and (preg_match("/Inbound Chat Report/",$LOGallowed_reports)) ) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
				{echo "<LI><a href=\"AST_CLOSERstats_v2.php?CHAT=Y\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Inbound Chat Report")."</a></FONT>\n";}
			}
		if ($LOGexport_reports >= 1)
			{
			if ( (preg_match("/Export Calls Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
				{echo "<LI><a href=\"call_report_export.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Export Calls Report")."</a></FONT>\n";}
			if ( (preg_match("/Export Leads Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
				{echo "<LI><a href=\"lead_report_export.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Export Leads Report")."</a></FONT>\n";}
			}
		echo "</UL>\n";
		echo "</TD><TD VALIGN=TOP>\n";
		echo " &nbsp; &nbsp; &nbsp;\n";
		echo "</TD><TD VALIGN=TOP>\n";
		echo "<B>"._QXZ("Agent Reports")."</B><BR>\n";
		echo "<UL>\n";
		if ( (preg_match("/VERM Reports/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"../VERM/VERM_admin.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("VERM - Enhanced Reporting Module")."</a></FONT>\n";}
		if ( (preg_match("/Agent Time Detail/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_agent_time_detail.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Agent Time Detail")."</a></FONT>\n";}
		if ( (preg_match("/Agent Status Detail/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_agent_status_detail.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Agent Status Detail")."</a></FONT>\n";}
		if ( (preg_match("/Agent Inbound Status Summary/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo " - <a href=\"AST_agent_inbound_status.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Inbound Summary")."</a></FONT>\n";}
		if ( (preg_match("/Agent Performance Detail/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_agent_performance_detail.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Agent Performance Detail")."</a></FONT>\n";}
		if ( (preg_match("/Team Performance Detail/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_team_performance_detail.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Team Performance Detail")."</a></FONT>\n";}
		if ( (preg_match("/Performance Comparison Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_performance_comparison_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Performance Comparison Report")."</a></FONT>\n";}
		if ( (preg_match("/Single Agent Daily$/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_agent_days_detail.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Single Agent Daily")."</a></FONT>\n";}
		if ( (preg_match("/Single Agent Daily Time/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo " - <a href=\"AST_agent_days_time.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Time")."</a></FONT>\n";}
		if ( (preg_match("/User Group Login Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_usergroup_login_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("User Group Login Report")."</a></FONT>\n";}
		if ( (preg_match("/User Group Hourly Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_user_group_hourly_detail.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("User Group Hourly Report")."</a></FONT> - <a href=\"AST_user_group_hourly_detail_v2.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("v2")."</a></FONT>\n";}
		if ( (preg_match("/User Stats/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"user_stats.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("User Stats")."</a></FONT>\n";}
		if ( (preg_match("/User Time Sheet/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_agent_time_sheet.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("User Time Sheet")."</a></FONT>\n";}
		echo "</UL><BR>\n";
		echo "<B>"._QXZ("Time Clock Reports")."</B><BR>\n";
		echo "<UL>\n";
		if ( (preg_match("/User Timeclock Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"timeclock_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("User Timeclock Report")."</a></FONT>\n";}
		if ( (preg_match("/User Group Timeclock Status Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"timeclock_status.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("User Group Timeclock Status Report")."</a></FONT>\n";}
		if ( (preg_match("/User Timeclock Detail Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_agent_timeclock_detail.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("User Timeclock Detail Report")."</a></FONT>\n";}
		echo "</UL><BR>\n";
		echo "<B>"._QXZ("Other Reports and Links")."</B><BR>\n";
		echo "<UL>\n";
		if ( (preg_match("/Server Performance Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"AST_server_performance.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Server Performance Report")."</a></FONT>\n";}

		if ( (preg_match("/Maximum System Stats/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"admin.php?ADD=999992&stage=TOTAL\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Maximum System Stats")."</a></FONT>\n";}

		if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<LI><a href=\"$PHP_SELF?ADD=700000000000000\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Administration Change Log")."</a></FONT>\n";
			}
		if ($SSenable_queuemetrics_logging > 0)
			{
			echo "<LI><a href=\"$queuemetrics_url_LU\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("QueueMetrics Reports")."</a></FONT>\n";
			}
		if ($SSenable_vtiger_integration > 0)
			{
			echo "<LI><a href=\"$vtiger_url_LU\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("VtigerCRM Home")."</a></FONT>\n";
			}
		if ( ($list_update_count > 0) and ( (preg_match("/List Update Stats/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<LI><a href=\"./AST_LIST_UPDATEstats.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("List Update Stats")."</a></FONT>\n";
			}
		if ($SScallcard_enabled > 0)
			{
			if ( (preg_match("/CallCard Search/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
				{echo "<LI><a href=\"callcard_admin.php?action=SEARCH\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("CallCard Search")."</a></FONT>\n";}
			}
		if ($SSqc_features_active > 0)
			{
			if ( (preg_match("/Quality Control Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
				{echo "<LI><a href=\"AST_quality_control_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("Quality Control Report")."</a></FONT>\n";}
			}

		echo "</UL>\n";

		$custom_stmt="show tables like 'vicidial_custom_reports'";
		$custom_rslt=mysql_to_mysqli($custom_stmt, $link);
		if (mysqli_num_rows($custom_rslt)>0) 
			{
			$allowed_rpt_stmt="SELECT allowed_custom_reports from vicidial_user_groups where user_group='$LOGuser_group' and allowed_custom_reports!=''";
			$allowed_rpt_rslt=mysql_to_mysqli($allowed_rpt_stmt, $link);
			if (mysqli_num_rows($allowed_rpt_rslt)>0) 
				{
				$allowed_rpt_row=mysqli_fetch_row($allowed_rpt_rslt);
				$allowed_custom_reports=$allowed_rpt_row[0];
				$allowed_reports_array=explode("|", $allowed_custom_reports);
				if (count($allowed_reports_array)>0) 
					{
					echo "<BR>\n";
					echo "<B>"._QXZ("Custom Reports")."</B><BR>\n";
					echo "<UL>\n";
					$report_links_stmt="SELECT report_name, domain, path_name, custom_variables from vicidial_custom_reports where report_name in ('".implode("','", $allowed_reports_array)."')";
					$report_links_rslt=mysql_to_mysqli($report_links_stmt, $link);
					while ($report_links_row=mysqli_fetch_array($report_links_rslt))
						{
						$domain=$report_links_row["domain"];
						$path_name=$report_links_row["path_name"];
						$custom_variables=ConvertPresets($report_links_row["custom_variables"]);
						# $custom_variables=$report_links_row["custom_variables"];
						$report_name=$report_links_row["report_name"];

						echo "<LI><a href=\"".$domain.$path_name."?".$custom_variables."\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("$report_name")."</a></FONT>\n";
						}
					echo "</UL>\n";
					}
				}
			}

		echo "</TD></TR></TABLE>\n";

		if ( (file_exists('custom_report_links.html')) and ( (preg_match("/Custom Reports Links/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			readfile('custom_report_links.html');
			}


		if ( ($reports_only_user < 1) and ( (preg_match("/Report Page Servers Summary/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
			{
			echo "<PRE><TABLE BORDER=1 CELLPADDING=2 cellspacing=0>\n";

			if ($stage == 'TIME')
				{
				echo "<TR bgcolor=#$SSstd_row4_background><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("SERVER")." <a href=\"$PHP_SELF?ADD=999999\">-</a></TD>";
				echo "<TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("DESCRIPTION")."</TD><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("IP")."</TD><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("ACT")."</TD><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("LOAD")."</TD><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("CHAN")."</TD><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("AGNT")."</TD><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("DISK")."</TD><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("TIME")."</TD><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("VER")."</TD></TR>\n";
				}
			else
				{
				echo "<TR bgcolor=#$SSstd_row4_background><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("SERVER")." <a href=\"$PHP_SELF?ADD=999999&stage=TIME\">+</a></TD>";
				echo "<TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("DESCRIPTION")."</TD><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("IP")."</TD><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("ACT")."</TD><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("LOAD")."</TD><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("CHAN")."</TD><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("AGNT")."</TD><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("DISK")."</TD><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("OUTBOUND")."</TD><TD><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("INBOUND")."</TD></TR>\n";
				}

			$o=0;
			$web_u_time = date('U');
			while ($servers_to_print > $o)
				{
				$cpu = (100 - $cpu_idle_percent[$o]);
				$disk = '';
				$disk_ary = explode('|',$disk_usage[$o]);
				$disk_ary_ct = count($disk_ary);
				$k=0;
				while ($k < $disk_ary_ct)
					{
					$disk_ary[$k] = preg_replace("/^\d* /","",$disk_ary[$k]);
					if ($k<1) {$disk = "$disk_ary[$k]";}
					else
						{
						if ($disk_ary[$k] > $disk) {$disk = "$disk_ary[$k]";}
						}
					$k++;
					}
				$disk = "$disk%";
				$s_time='&nbsp;';
				$s_ver='&nbsp;';
				$u_time=$web_u_time;
				$reset_time=$web_u_time;
				$Sdb_time=$web_u_time;
				$stmt="SELECT last_update,UNIX_TIMESTAMP(last_update),UNIX_TIMESTAMP(db_time) from server_updater where server_ip='$server_ip[$o]';";
				$rslt=mysql_to_mysqli($stmt, $link);
				if ($DB) {echo "$stmt\n";}
				$servertime_to_print = mysqli_num_rows($rslt);
				if ($servertime_to_print)
					{
					$row=mysqli_fetch_row($rslt);
					$s_time =		$row[0];
					$u_time =		($row[1] + 10);
					$reset_time =	($row[1] + 90);
					$Sdb_time =		($row[2] + 10);
					}
				$agnt=0;
				$stmt="SELECT count(*) from vicidial_live_agents where server_ip='$server_ip[$o]';";
				$rslt=mysql_to_mysqli($stmt, $link);
				if ($DB) {echo "$stmt\n";}
				$agnt_to_print = mysqli_num_rows($rslt);
				if ($agnt_to_print)
					{
					$row=mysqli_fetch_row($rslt);
					$agnt =		$row[0];
					}
				$server_bgcolor=' bgcolor="#B1E4BB"';
				$FROZEN_output='';
				if ($web_u_time > $u_time)
					{$server_bgcolor=' bgcolor=red';}
				if ( ($web_u_time > $reset_time) and ($web_u_time > $Sdb_time) and ($SSfrozen_server_call_clear > 0) )
					{
					#### if server is more than 90 seconds out of sync and no longer updating, check for live calls and agents and delete them
					$servercalls_count=0;
					$stmt="SELECT count(*) from vicidial_auto_calls where server_ip='$server_ip[$o]';";
					$rslt=mysql_to_mysqli($stmt, $link);
					if ($DB) {echo "$stmt\n";}
					$servercalls_to_print = mysqli_num_rows($rslt);
					if ($servercalls_to_print)
						{
						$row=mysqli_fetch_row($rslt);
						$servercalls_count =	$row[0];
						}
					if ($servercalls_count > 0)
						{
						$stmt="DELETE FROM vicidial_auto_calls where server_ip='$server_ip[$o]';";
						$rslt=mysql_to_mysqli($stmt, $link);
						$FCaffected_rows = mysqli_affected_rows($link);

						### LOG INSERTION Admin Log Table ###
						$SQL_log = "$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='$server_ip[$o]', event_section='SERVERS', event_type='CLEAR', record_id='$server_id[$o]', event_code='FROZEN SERVER CALL CLEAR ADMIN', event_sql=\"$SQL_log\", event_notes='$servercalls_count|$FCaffected_rows|$s_time($web_u_time|$Sdb_time)';";
						if ($DB) {echo "|$stmt|\n";}
						$rslt=mysql_to_mysqli($stmt, $link);

						$FROZEN_output = "<TR$server_bgcolor><TD> &nbsp; </TD><TD COLSPAN=8>"._QXZ("FROZEN CALLS CLEARED").": $servercalls_count|$FCaffected_rows</TD></TR>\n";
						}
					}
				echo "<TR$server_bgcolor>\n";
				echo "<TD NOWRAP><a href=\"$PHP_SELF?ADD=311111111111&server_id=$server_id[$o]\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>$server_id[$o]</a></TD>\n";
				echo "<TD NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>$server_description[$o]</TD>\n";
				echo "<TD NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>$server_ip[$o]</TD>\n";
				echo "<TD NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=1>"._QXZ("$active[$o]")." / "._QXZ("$active_asterisk_server[$o]")." / "._QXZ("$active_agent_login_server[$o]")."</TD>\n";
				echo "<TD NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>$sysload[$o] - $cpu%</TD>\n";
				echo "<TD NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>$channels_total[$o]</TD>\n";
				echo "<TD NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>$agnt</TD>\n";
				echo "<TD ALIGN=RIGHT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>$disk</TD>\n";
				if ($stage == 'TIME')
					{
					$stmt="SELECT svn_revision from servers where server_ip='$server_ip[$o]';";
					$rslt=mysql_to_mysqli($stmt, $link);
					if ($DB) {echo "$stmt\n";}
					$serverver_to_print = mysqli_num_rows($rslt);
					if ($serverver_to_print)
						{
						$row=mysqli_fetch_row($rslt);
						$s_ver = $row[0];
						}
					echo "<TD NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>$s_time</TD><TD NOWRAP>$s_ver</TD>";
					}
				else
					{
					if ( (preg_match("/Real-Time Main Report/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
						{
						echo "<TD NOWRAP><a href=\"AST_timeonVDAD.php?server_ip=$server_ip[$o]\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("LINK")."</a></TD>\n";
						echo "<TD NOWRAP><a href=\"AST_timeonVDAD.php?server_ip=$server_ip[$o]&closer_display=1\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("LINK")."</a></TD>\n";
						}
					else
						{
						echo "<TD NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2> &nbsp; </TD>\n";
						echo "<TD NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2> &nbsp; </TD>\n";
						}
					}
				echo "</TR>\n";
				echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>$FROZEN_output</FONT>";
				$o++;
				}

			if ($stage == 'TIME')
				{
				echo "<TR bgcolor=\"#B1E4BB\"><TD COLSPAN=2 NOWRAP> &nbsp; </TD><TD NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("PHP Time")."</TD><TD COLSPAN=5 NOWRAP> &nbsp; </TD><TD NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>" . date("Y-m-d H:i:s") . "</TD><TD NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2> &nbsp; </TD></TR>";

				$stmt="SELECT NOW();";
				$rslt=mysql_to_mysqli($stmt, $link);
				if ($DB) {echo "$stmt\n";}
				$dbtime_to_print = mysqli_num_rows($rslt);
				if ($dbtime_to_print)
					{
					$row=mysqli_fetch_row($rslt);
					echo "<TR bgcolor=\"#B1E4BB\"><TD COLSPAN=2 NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2> &nbsp; </TD><TD NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("DB Time")."</TD><TD COLSPAN=5 NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2> &nbsp; </TD><TD NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>$row[0]</TD><TD NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2> &nbsp; </TD></TR>";
					}
				}
			echo "</TABLE>\n";

			if ( ($LOGuser_level >= 9) and ( (preg_match("/Admin Utilities Page/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
				{
				echo "<BR><BR> &nbsp; <a href=\"$PHP_SELF?ADD=999994\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLUE SIZE=1>"._QXZ("Admin Utilities")."</a></FONT>\n";
				}
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}
##### END report links #####


######################
# ADD=999998 display admin links page
######################
if ($ADD==999998)
	{
	$subhead_font = "style=\"font-family:HELVETICA;font-size:14;color:BLACK;font-weight:bold;\"";
	?>

	</head><BODY BGCOLOR=WHITE>
	<img src="images/icon_black_admin.png" alt="Admin" width=42 height=42> <FONT FACE="ARIAL,HELVETICA" SIZE=4><B> <?php echo _QXZ("Administration"); ?></B></FONT><BR><CENTER>
	<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=0 WIDTH=800>
	<?php
	echo "<TR>\n";
	echo "<TD ALIGN=LEFT VALIGN=TOP WIDTH=100>&nbsp;\n";
	echo "</TD>\n";
	echo "<TD ALIGN=LEFT VALIGN=TOP WIDTH=220>\n";
	echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=5 WIDTH=100%>\n";
	echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=100000000';\"";} echo ">\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=100000000\"><img src=\"images/icon_calltimes.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=100000000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Call Times")." </SPAN></a></TD>\n";
	echo "</TR>\n";
	echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=130000000';\"";} echo ">\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=130000000\"><img src=\"images/icon_shifts.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=130000000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Shifts")." </SPAN></a></TD>\n";
	echo "</TR>\n";
	echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=10000000000';\"";} echo ">\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=10000000000\"><img src=\"images/icon_phones.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=10000000000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Phones")." </SPAN></a></TD>\n";
	echo "</TR>\n";
	echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=130000000000';\"";} echo ">\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=130000000000\"><img src=\"images/icon_templates.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=130000000000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Templates")." </SPAN></a></TD>\n";
	echo "</TR>\n";
	echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=140000000000';\"";} echo ">\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=140000000000\"><img src=\"images/icon_carriers.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=140000000000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Carriers")." </SPAN></a></TD>\n";
	echo "</TR>\n";
	echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=100000000000';\"";} echo ">\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=100000000000\"><img src=\"images/icon_servers.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=100000000000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Servers")." </SPAN></a></TD>\n";
	echo "</TR>\n";
	echo "</TABLE>\n";
	echo "</TD>\n";

	echo "<TD ALIGN=LEFT VALIGN=TOP WIDTH=220>\n";
	echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=5 WIDTH=100%>\n";
	echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=1000000000000';\"";} echo ">\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=1000000000000\"><img src=\"images/icon_conferences.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=1000000000000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Conferences")." </SPAN></a></TD>\n";
	echo "</TR>\n";
	echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=311111111111111';\"";} echo ">\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=311111111111111\"><img src=\"images/icon_settings.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=311111111111111\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("System Settings")." </SPAN></a></TD>\n";
	echo "</TR>\n";
	echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=180000000000';\"";} echo ">\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=180000000000\"><img src=\"images/icon_screenlabels.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=180000000000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Agent Screen Labels")." </SPAN></a></TD>\n";
	echo "</TR>\n";
	echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=182000000000';\"";} echo ">\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=182000000000\"><img src=\"images/icon_screencolors.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=182000000000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Screen Colors")." </SPAN></a></TD>\n";
	echo "</TR>\n";
	echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=321111111111111';\"";} echo ">\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=321111111111111\"><img src=\"images/icon_statuses.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=321111111111111\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("System Statuses")." </SPAN></a></TD>\n";
	echo "</TR>\n";
	echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=193000000000';\"";} echo ">\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=193000000000\"><img src=\"images/icon_statusgroups.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=193000000000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Status Groups")." </SPAN></a></TD>\n";
	echo "</TR>\n";
	if ($SScampaign_cid_areacodes_enabled == '1')
		{
		echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=196000000000';\"";} echo ">\n";
		echo "<TD><a href=\"$PHP_SELF?ADD=196000000000\"><img src=\"images/icon_cidgroups.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
		echo "<TD><a href=\"$PHP_SELF?ADD=196000000000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("CID Groups")." </SPAN></a></TD>\n";
		echo "</TR>\n";
		}
	echo "</TABLE>\n";
	echo "</TD>\n";

	echo "<TD ALIGN=LEFT VALIGN=TOP WIDTH=220>\n";
	echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=5 WIDTH=100%>\n";
	echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=170000000000';\"";} echo ">\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=170000000000\"><img src=\"images/icon_voicemail.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=170000000000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Voicemail")." </SPAN></a></TD>\n";
	echo "</TR>\n";
	if ($SSemail_enabled > 0)
		{
		echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='admin_email_accounts.php';\"";} echo ">\n";
		echo "<TD><a href=\"admin_email_accounts.php\"><img src=\"images/icon_email.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
		echo "<TD><a href=\"admin_email_accounts.php\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Email Accounts")." </SPAN></a></TD>\n";
		echo "</TR>\n";
		}
	if ( ($sounds_central_control_active > 0) or ($SSsounds_central_control_active > 0) )
		{
		echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='audio_store.php';\"";} echo ">\n";
		echo "<TD><a href=\"audio_store.php\"><img src=\"images/icon_audiostore.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
		echo "<TD><a href=\"audio_store.php\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Audio Store")." </SPAN></a></TD>\n";
		echo "</TR>\n";
		echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=160000000000';\"";} echo ">\n";
		echo "<TD><a href=\"$PHP_SELF?ADD=160000000000\"><img src=\"images/icon_musiconhold.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
		echo "<TD><a href=\"$PHP_SELF?ADD=160000000000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Music On Hold")." </SPAN></a></TD>\n";
		echo "</TR>\n";
		}
	if ($SSenable_languages > 0)
		{
		echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='admin_languages.php?ADD=163000000000';\"";} echo ">\n";
		echo "<TD><a href=\"admin_languages.php?ADD=163000000000\"><img src=\"images/icon_languages.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
		echo "<TD><a href=\"admin_languages.php?ADD=163000000000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Languages")." </SPAN></a></TD>\n";
		echo "</TR>\n";
		}
	if ( (preg_match("/soundboard/",$SSactive_modules) ) or ($SSagent_soundboards > 0) )
		{
		echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='admin_soundboard.php?ADD=162000000000';\"";} echo ">\n";
		echo "<TD><a href=\"admin_soundboard.php?ADD=162000000000\"><img src=\"images/icon_audiosoundboards.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
		echo "<TD><a href=\"admin_soundboard.php?ADD=162000000000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Audio Soundboards")." </SPAN></a></TD>\n";
		echo "</TR>\n";
		}
	echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='admin.php?ADD=197000000000';\"";} echo ">\n";
	echo "<TD><a href=\"admin.php?ADD=197000000000\"><img src=\"images/icon_vm_messages.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
	echo "<TD><a href=\"admin.php?ADD=197000000000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("VM Message Groups")." </SPAN></a></TD>\n";
	echo "</TR>\n";
	echo "</TABLE>\n";
	echo "</TD>\n";

	echo "<TD ALIGN=LEFT VALIGN=TOP WIDTH=220>\n";
	echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=5 WIDTH=100%>\n";
	if ($SSenable_tts_integration > 0)
		{
		echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=150000000000';\"";} echo ">\n";
		echo "<TD><a href=\"$PHP_SELF?ADD=150000000000\"><img src=\"images/icon_texttospeech.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
		echo "<TD><a href=\"$PHP_SELF?ADD=150000000000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Text To Speech")." </SPAN></a></TD>\n";
		echo "</TR>\n";
		}
	if ($SScallcard_enabled > 0)
		{
		echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='callcard_admin.php';\"";} echo ">\n";
		echo "<TD><a href=\"callcard_admin.php\"><img src=\"images/icon_callcard.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
		echo "<TD><a href=\"callcard_admin.php\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("CallCard Admin")." </SPAN></a></TD>\n";
		echo "</TR>\n";
		}
	if ($SScontacts_enabled > 0)
		{
		echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=190000000000';\"";} echo ">\n";
		echo "<TD><a href=\"$PHP_SELF?ADD=190000000000\"><img src=\"images/icon_contacts.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
		echo "<TD><a href=\"$PHP_SELF?ADD=190000000000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Contacts")." </SPAN></a></TD>\n";
		echo "</TR>\n";
		}
	echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=192000000000';\"";} echo ">\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=192000000000\"><img src=\"images/icon_settingscontainer.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=192000000000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Settings Containers")." </SPAN></a></TD>\n";
	echo "</TR>\n";
	if ($SSenable_auto_reports > 0)
		{
		echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=194000000000';\"";} echo ">\n";
		echo "<TD><a href=\"$PHP_SELF?ADD=194000000000\"><img src=\"images/icon_autoreports.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
		echo "<TD><a href=\"$PHP_SELF?ADD=194000000000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Automated Reports")." </SPAN></a></TD>\n";
		echo "</TR>\n";
		}
	if ($SSallow_ip_lists > 0)
		{
		echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=195000000000';\"";} echo ">\n";
		echo "<TD><a href=\"$PHP_SELF?ADD=195000000000\"><img src=\"images/icon_iplists.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
		echo "<TD><a href=\"$PHP_SELF?ADD=195000000000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("IP Lists")." </SPAN></a></TD>\n";
		echo "</TR>\n";
		}
	echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='$PHP_SELF?ADD=198000000000';\"";} echo ">\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=198000000000\"><img src=\"images/icon_queuegroups.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
	echo "<TD><a href=\"$PHP_SELF?ADD=198000000000\" STYLE=\"text-decoration:none;\"><SPAN $subhead_font> "._QXZ("Queue Groups")." </SPAN></a></TD>\n";
	echo "</TR>\n";

	echo "</TABLE>\n";
	echo "</TD><TD WIDTH=100> &nbsp; \n";
	}
##### END admin links #####


######################
# ADD=999997 - user force change password page
######################
if ($ADD==999997)
	{
	$show_form=1;
	if ( ($stage=='SUBMIT') or ($stage==_QXZ("SUBMIT")) )
		{
		if ( (mb_strlen($pass,'utf-8') > 100) or (strlen($pass) < 2) or ($pass==$PHP_AUTH_PW) or ( ($SSrequire_password_length > 0) and ($SSrequire_password_length > strlen($pass)) ) )
			{
			echo _QXZ("Password has not been changed, please try again")." |1|" . strlen($pass);
			if ( (mb_strlen($pass,'utf-8') > 100) or (strlen($pass) < 2) )
				{
				echo "<br>"._QXZ("Your password must be between 2 and 100 characters in length")."\n";
				}
			if ($pass==$PHP_AUTH_PW)
				{
				echo "<br>"._QXZ("You cannot use the same password as your last password")."\n";
				}
			if ($SSrequire_password_length > 0)
				{
				echo "<br>"._QXZ("Password must be at least $SSrequire_password_length characters long")."\n";
				}
			}
		else
			{
			$pass_hash='';
			$pass_checkSQL="pass='$pass'";
			if ( ($SSpass_hash_enabled > 0) and (strlen($pass) > 1) )
				{
				$pass = preg_replace("/\'|\"|\\\\|;|<|>| /","",$pass);
				$pass_hash = exec("../agc/bp.pl --pass=$pass");
				$pass_hash = preg_replace("/PHASH: |\n|\r|\t| /",'',$pass_hash);
				$pass_checkSQL="pass_hash='$pass_hash'";
				$pass='';
				}

			$stmt="SELECT count(*) from vicidial_users where user='$user' and active='Y' and user_level > 1;";
			$rslt=mysql_to_mysqli($stmt, $link);
			if ($DB) {echo "$stmt\n";}
			$userpass_to_print = mysqli_num_rows($rslt);
			if ($userpass_to_print < 1)
				{echo _QXZ("Password has not been changed, please try again")." |2|$userpass_to_print";}
			else
				{
				$row=mysqli_fetch_row($rslt);
				if ($row[0] < 1)
					{echo _QXZ("Password has not been changed, please try again")." |3|$row[0]";}
				else
					{
					$stmt="SELECT count(*) from vicidial_users where user='$user' and $pass_checkSQL;";
					$rslt=mysql_to_mysqli($stmt, $link);
					if ($DB) {echo "$stmt\n";}
					$userpass_to_print = mysqli_num_rows($rslt);
					if ($userpass_to_print < 1)
						{echo _QXZ("Password has not been changed, please try again")." |4|$userpass_to_print";}
					else
						{
						$row=mysqli_fetch_row($rslt);
						if ($row[0] > 0)
							{echo _QXZ("You cannot use the same password as your last password, please try again")." |5|$row[0]";}
						else
							{
							$show_form=0;

							$stmt="UPDATE vicidial_users SET pass='$pass',pass_hash='$pass_hash',force_change_password='N',failed_login_count=0 where user='$user' and force_change_password='Y' and active='Y' and user_level > 6;";
							$rslt=mysql_to_mysqli($stmt, $link);

							### LOG INSERTION Admin Log Table ###
							$SQL_log = "$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='$user', event_code='USER FORCE CHANGE PASSWORD', event_sql=\"$SQL_log\", event_notes='';";
							if ($DB) {echo "|$stmt|\n";}
							$rslt=mysql_to_mysqli($stmt, $link);

							echo _QXZ("Password has been updated, you may now continue")."\n";
							}
						}
					}
				}
			}
		}
	if ($show_form > 0)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("CHANGE PASSWORD")."<form action=$PHP_SELF method=POST name=userform id=userform>\n";
		echo "<input type=hidden name=ADD value=999997>\n";
		echo "<input type=hidden name=DB value=\"$DB\">\n";
		echo "<input type=hidden name=stage value=SUBMIT>\n";
		echo "<input type=hidden name=user value=\"$PHP_AUTH_USER\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("New Password").": </td><td align=left style=\"display:table-cell; vertical-align:middle;\" NOWRAP><input type=text id=reg_pass name=pass size=50 maxlength=100 onkeyup=\"return pwdChanged('reg_pass','reg_pass_img','pass_length','$SSrequire_password_length');\"> &nbsp; &nbsp; <font size=1>"._QXZ("Strength").":</font> <IMG id=reg_pass_img src='images/pixel.gif' style=\"vertical-align:middle;\" onLoad=\"return pwdChanged('reg_pass','reg_pass_img','pass_length','$SSrequire_password_length');\"> &nbsp; <font size=1> "._QXZ("Length").": <span id=pass_length name=pass_length>0</span></font></td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=left colspan=2>"._QXZ("You are required to change your password before you can continue on to Administration. The longer the password is, the stronger it will be. Your password must be from 2 to 100 characters in length and cannot contain any characters that are not letters or numbers. Be sure that this password is something that you can remember, because as soon as you make this change you will be prompted to enter your new password to log back in to Administration")."</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center></form>\n";
		}
	}
##### END user force change password page #####


######################
# ADD=99999701 - User 2FA(Two-Factor-Authentication) Page
######################
if ($ADD==99999701)
	{
	$subhead_font = "style=\"font-family:HELVETICA;font-size:14;color:BLACK;font-weight:bold;\"";

	echo "<img src=\"images/2FA_icon.png\" alt=\"Two-Factor-Authentication\" width=42 height=42> <FONT FACE=\"ARIAL,HELVETICA\" SIZE=4><B> "._QXZ("Two-Factor-Authentication"),"</B></FONT><BR><CENTER>\n";

	if ( ($SStwo_factor_auth_hours < 1) or ($SStwo_factor_container == '') or ($SStwo_factor_container == '---DISABLED---') )
		{
		echo _QXZ("Two-Factor-Authentication is disabled on your system. Please contact your system administrator")." $SStwo_factor_auth_hours|$SStwo_factor_container\n";
		exit;
		}

	$OBSCUREemail = $LOGemail;
	$OBSCUREmobile_number = $LOGmobile_number;

	# first character and last 6 characters
	$temp_emailARY = explode('@',$OBSCUREemail);
	$field_temp_val = $temp_emailARY[0];
	$OBSCUREemail = substr($field_temp_val,0,2) . str_repeat(".", (strlen($field_temp_val) - 2)) . '@' . $temp_emailARY[1];
	# first 3 digits and last 2 digits
	$field_temp_val = $OBSCUREmobile_number;
	$OBSCUREmobile_number = substr($field_temp_val,0,3) . str_repeat("x", (strlen($field_temp_val) - 5)) . substr($field_temp_val,-2,2);

	### BEGIN Gather 2FA settings container details ###
	$valid_2FA_config=0;
	$active_2FA_methods=0;
	$auth_code_expire_minutes='30';
	$auth_code_attempts='10';
	$auth_code_length='6';
	$email_auth='';
	$email_from='';
	$email_subject='';
	$email_message='';
	$phone_auth='';
	$phone_prefix='';
	$phone_server_ip='';
	$phone_cid_number='';
	$phone_message_override='';
	$sms_auth='';
	$sms_cid_number='';
	$sms_url='';
	$stmt = "SELECT container_entry FROM vicidial_settings_containers where container_id='$SStwo_factor_container';";
	$rslt=mysql_to_mysqli($stmt, $link);
	$SCinfo_ct = mysqli_num_rows($rslt);
	if ($DB) {echo "$SCinfo_ct|$stmt\n";}
	if ($SCinfo_ct > 0)
		{
		$row=mysqli_fetch_row($rslt);
		$TFAcontainer_entry =	$row[0];
		$TFAcontainer_entry = preg_replace("/\r|\t|\'|\"/",'',$TFAcontainer_entry);
		$TFAcontainer_entry = preg_replace("/ => | =>|=> /",'=>',$TFAcontainer_entry);
		$two_factor_settings = explode("\n",$TFAcontainer_entry);
		$two_factor_settings_ct = count($two_factor_settings);
		$tfal=0;
		while ($two_factor_settings_ct >= $tfal)
			{
			if (preg_match("/^auth_code_expire_minutes=>/",$two_factor_settings[$tfal]))
				{
				$two_factor_settings[$tfal] = preg_replace("/auth_code_expire_minutes=>/",'',$two_factor_settings[$tfal]);
				$auth_code_expire_minutes = $two_factor_settings[$tfal];
				}
			if (preg_match("/^auth_code_attempts=>/",$two_factor_settings[$tfal]))
				{
				$two_factor_settings[$tfal] = preg_replace("/auth_code_attempts=>/",'',$two_factor_settings[$tfal]);
				$auth_code_attempts = $two_factor_settings[$tfal];
				}
			if (preg_match("/^auth_code_length=>/",$two_factor_settings[$tfal]))
				{
				$two_factor_settings[$tfal] = preg_replace("/auth_code_length=>/",'',$two_factor_settings[$tfal]);
				$auth_code_length = $two_factor_settings[$tfal];
				}
			if (preg_match("/^email_auth=>/",$two_factor_settings[$tfal]))
				{
				$two_factor_settings[$tfal] = preg_replace("/email_auth=>/",'',$two_factor_settings[$tfal]);
				$email_auth = $two_factor_settings[$tfal];
				$active_2FA_methods++;
				}
			if (preg_match("/^email_from=>/",$two_factor_settings[$tfal]))
				{
				$two_factor_settings[$tfal] = preg_replace("/email_from=>/",'',$two_factor_settings[$tfal]);
				$email_from = $two_factor_settings[$tfal];
				$valid_2FA_config++;
				}
			if (preg_match("/^email_subject=>/",$two_factor_settings[$tfal]))
				{
				$two_factor_settings[$tfal] = preg_replace("/email_subject=>/",'',$two_factor_settings[$tfal]);
				$email_subject = $two_factor_settings[$tfal];
				}
			if (preg_match("/^email_message=>/",$two_factor_settings[$tfal]))
				{
				$two_factor_settings[$tfal] = preg_replace("/email_message=>/",'',$two_factor_settings[$tfal]);
				$email_message = $two_factor_settings[$tfal];
				}
			if (preg_match("/^phone_auth=>/",$two_factor_settings[$tfal]))
				{
				$two_factor_settings[$tfal] = preg_replace("/phone_auth=>/",'',$two_factor_settings[$tfal]);
				$phone_auth = $two_factor_settings[$tfal];
				$active_2FA_methods++;
				}
			if (preg_match("/^phone_prefix=>/",$two_factor_settings[$tfal]))
				{
				$two_factor_settings[$tfal] = preg_replace("/phone_prefix=>/",'',$two_factor_settings[$tfal]);
				$phone_prefix = $two_factor_settings[$tfal];
				}
			if (preg_match("/^phone_server_ip=>/",$two_factor_settings[$tfal]))
				{
				$two_factor_settings[$tfal] = preg_replace("/phone_server_ip=>/",'',$two_factor_settings[$tfal]);
				$phone_server_ip = $two_factor_settings[$tfal];
				$valid_2FA_config++;
				}
			if (preg_match("/^phone_cid_number=>/",$two_factor_settings[$tfal]))
				{
				$two_factor_settings[$tfal] = preg_replace("/phone_cid_number=>/",'',$two_factor_settings[$tfal]);
				$phone_cid_number = $two_factor_settings[$tfal];
				}
			if (preg_match("/^phone_message_override=>/",$two_factor_settings[$tfal]))
				{
				$two_factor_settings[$tfal] = preg_replace("/phone_message_override=>/",'',$two_factor_settings[$tfal]);
				$phone_message_override = $two_factor_settings[$tfal];
				}
			if (preg_match("/^sms_auth=>/",$two_factor_settings[$tfal]))
				{
				$two_factor_settings[$tfal] = preg_replace("/sms_auth=>/",'',$two_factor_settings[$tfal]);
				$sms_auth = $two_factor_settings[$tfal];
				$active_2FA_methods++;
				}
			if (preg_match("/^sms_cid_number=>/",$two_factor_settings[$tfal]))
				{
				$two_factor_settings[$tfal] = preg_replace("/sms_cid_number=>/",'',$two_factor_settings[$tfal]);
				$sms_cid_number = $two_factor_settings[$tfal];
				}
			if (preg_match("/^sms_url=>/",$two_factor_settings[$tfal]))
				{
				$two_factor_settings[$tfal] = preg_replace("/sms_url=>/",'',$two_factor_settings[$tfal]);
				$sms_url = $two_factor_settings[$tfal];
				$valid_2FA_config++;
				}

			$tfal++;
			}
		}
	### END Gather 2FA settings container details ###
	if ( ($valid_2FA_config < 1) or ($active_2FA_methods < 1) )
		{
		echo "<BR><b>"._QXZ("Two-Factor-Authentication is not properly configured on your system. Please contact your system administrator")." <BR><BR>$valid_2FA_config|$SStwo_factor_auth_hours|$SStwo_factor_container</b><BR>\n";
		exit;
		}
	if ( (strlen($LOGemail) < 4) and (strlen($LOGmobile_number) < 2) )
		{
		echo _QXZ("Your User account is not configured for Two-Factor-Authentication. Please contact your system administrator. (no email or mobile number)").".\n";
		exit;
		}

	$show_form=1;
	if ( ($stage=='SUBMIT') or ($stage==_QXZ("SUBMIT")) )
		{
		$auth_fail=0;
		echo "<br><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=3>";
		if (strlen($rank) < 2)
			{
			echo _QXZ("Please go back and enter a valid authorization code")." |1|" . strlen($rank) . "|";   $auth_fail++;
			}
		else
			{
			$stmt="SELECT count(*) from vicidial_two_factor_auth where user='$user' and auth_code='$rank' and auth_stage='0' and auth_code_exp_date > NOW() and (auth_attempts < $auth_code_attempts);";
			$rslt=mysql_to_mysqli($stmt, $link);
			if ($DB) {echo "$stmt\n";}
			$auth_check_to_print = mysqli_num_rows($rslt);
			if ($auth_check_to_print < 1)
				{echo _QXZ("Please go back and enter a valid authorization code")." |2|$auth_check_to_print";   $auth_fail++;}
			else
				{
				$row=mysqli_fetch_row($rslt);
				if ($row[0] < 1)
					{echo _QXZ("Please go back and enter a valid authorization code")." |3|$row[0]";   $auth_fail++;}
				else
					{
					$stmt="UPDATE vicidial_two_factor_auth SET auth_stage='1', auth_attempts=(auth_attempts + 1) where user='$user' and auth_stage='0' and auth_code='$rank';";
					$rslt=mysql_to_mysqli($stmt, $link);

					$stmt = "INSERT INTO vicidial_agent_function_log set agent_log_id='0',user='$user',function='2FA_good',event_time=NOW(),campaign_id='-ADMIN-',user_group='$LOGuser_group',lead_id='0',uniqueid='SUCCESS',caller_code='$ip',stage='',comments='';";
					if ($DB) {echo "|$stmt|\n";}
					$rslt=mysql_to_mysqli($stmt, $link);

					echo _QXZ("Authorization code accepted, your login is complete, you may now continue")."\n";
					}
				}
			}
		if ($auth_fail > 0)
			{
			$stmt="UPDATE vicidial_two_factor_auth SET auth_attempts=(auth_attempts + 1) where user='$user' and auth_stage='0';";
			$rslt=mysql_to_mysqli($stmt, $link);

			$auth_failed_attempts=1;
			$stmt="SELECT auth_attempts from vicidial_two_factor_auth where user='$user' and auth_stage='0' order by auth_code_exp_date desc limit 1;";
			$rslt=mysql_to_mysqli($stmt, $link);
			if ($DB) {echo "$stmt\n";}
			$auth_attempt_to_print = mysqli_num_rows($rslt);
			if ($auth_attempt_to_print > 0)
				{
				$row=mysqli_fetch_row($rslt);
				$auth_failed_attempts = $row[0];
				}
			if ($auth_failed_attempts >= $auth_code_attempts)
				{
				$stmt="UPDATE vicidial_users set failed_login_count='$auth_failed_attempts',last_ip='$ip' where user='$user';";
				$rslt=mysql_to_mysqli($stmt, $link);
				}
			}
		echo "<br></FONT>\n";
		exit;
		}

	##### BEGIN send out AUTH CODE and show auth-code entry page #####
	if ($auth_entry > 0)
		{
		$ACbegin =  '1';
		$ACend =	'9';
		$i=1;
		while($i < $auth_code_length)
			{
			$ACbegin .= '0';
			$ACend .=	'9';
			$i++;
			}
		$NEWauth_code = rand($ACbegin, $ACend);
		$auth_exp_date = date("Y-m-d H:i:s", mktime(date("H")+$SStwo_factor_auth_hours,date("i"),date("s"),date("m"),date("d"),date("Y")));
		$auth_code_exp_date = date("Y-m-d H:i:s", mktime(date("H"),date("i")+$auth_code_expire_minutes,date("s"),date("m"),date("d"),date("Y")));

		### insert auth_code into vicidial_two_factor_auth table
		$stmt="INSERT INTO vicidial_two_factor_auth SET auth_date=NOW(),auth_exp_date='$auth_exp_date',user='$user',auth_stage='0',auth_code='$NEWauth_code',auth_code_exp_date='$auth_code_exp_date',auth_method='$stage',auth_attempts='0';";
		$rslt=mysql_to_mysqli($stmt, $link);
		$affected_rows = mysqli_affected_rows($link);
		if ($DB) {echo "$affected_rows|$stmt\n";}

		# invalidate all older auth_code entries
		if ($affected_rows > 0)
			{
			$stmt="UPDATE vicidial_two_factor_auth SET auth_stage='6' where user='$user' and auth_stage!='6' and auth_code!='$NEWauth_code';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$affected_rows = mysqli_affected_rows($link);
			if ($DB) {echo "$affected_rows|$stmt\n";}
			}

		### Send auth code by EMAIL
		if ($stage == 'EMAIL')
			{
			$email_message = preg_replace('/--A--auth_code--B--/i',"$NEWauth_code",$email_message);
		
			// To send HTML mail, the Content-type header must be set
			$headers  = 'MIME-Version: 1.0' . "\r\n";
			$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	 
			// Create email headers
			$headers .= 'From: ' . $email_from . "\r\n" . 'Reply-To: ' . $email_from . "\r\n" . 'X-Mailer: PHP/' . phpversion();

			$body = "<html><body>" . $email_message . "</body></html>";
		
			$success = mail($LOGemail, $email_subject, $body, $headers );
			if ($success)
				{
				$stmt = "INSERT INTO vicidial_agent_function_log set agent_log_id='0',user='$user',function='2FA_send',event_time=NOW(),campaign_id='-ADMIN-',user_group='$LOGuser_group',lead_id='0',uniqueid='SUCCESS',caller_code='$ip',stage='$stage',comments='EMAIL: $LOGemail';";

				echo "<br><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=3>"._QXZ("Your authorization code has been sent by %1s to",0,'',$stage).": $OBSCUREemail<br></FONT>\n";
				}
			else
				{
				$stmt = "INSERT INTO vicidial_agent_function_log set agent_log_id='0',user='$user',function='2FA_send',event_time=NOW(),campaign_id='-ADMIN-',user_group='$LOGuser_group',lead_id='0',uniqueid='ERROR',caller_code='$ip',stage='$stage',comments='EMAIL: $LOGemail';";

				$error_msg = error_get_last()['message'];
				echo "$error_msg";
				}

			### LOG INSERTION Admin Log Table ###
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			}

		### Send auth code by PHONE
		if ($stage == 'PHONE')
			{
			$context_2FA = '2FA_say_auth_code';
			if (strlen($phone_message_override) > 0) {$context_2FA = $phone_message_override;}
			if (strlen($ext_context) < 1) {$ext_context='default';}
			$local_DEF = 'Local/';
			$local_AMP = '@';
			$Local_dial_timeout = '60000';
			$Ndialstring = "$phone_prefix$LOGmobile_number";
			$VMvariable = "Variable: access_code=$NEWauth_code";
			### insert a NEW record to the vicidial_manager table to be processed
			$stmtB = "INSERT INTO vicidial_manager(uniqueid,entry_date,status,response,server_ip,channel,action,callerid,cmd_line_b,cmd_line_c,cmd_line_d,cmd_line_e,cmd_line_f,cmd_line_g,cmd_line_h,cmd_line_i,cmd_line_j,cmd_line_k) values('',NOW(),'NEW','N','$phone_server_ip','','Originate','$VqueryCID','Exten: s','Context: $context_2FA','Channel: $local_DEF$Ndialstring$local_AMP$ext_context','Priority: 1','Callerid: $phone_cid_number','Timeout: $Local_dial_timeout','$VMvariable','','','')";
			$rslt=mysql_to_mysqli($stmtB, $link);

			$stmt = "INSERT INTO vicidial_agent_function_log set agent_log_id='0',user='$user',function='2FA_send',event_time=NOW(),campaign_id='-ADMIN-',user_group='$LOGuser_group',lead_id='0',uniqueid='SUCCESS',caller_code='$ip',stage='$stage',comments='PHONE: $LOGmobile_number';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=3>"._QXZ("Your authorization code has been sent by %1s to",0,'',$stage).": $OBSCUREmobile_number<br></FONT>\n";
			}

		### Send auth code by SMS
		if ($stage == 'SMS')
			{
			$sms_url = preg_replace('/--A--auth_code--B--/i',"$NEWauth_code",$sms_url);
			$sms_url = preg_replace('/--A--mobile_number--B--/i',"$LOGmobile_number",$sms_url);

			### insert a new url log entry
			$SQL_log = "$sms_url";
			$SQL_log = preg_replace('/;/','',$SQL_log);
			$SQL_log = addslashes($SQL_log);
			$stmt = "INSERT INTO vicidial_url_log SET uniqueid='2FA',url_date=NOW(),url_type='2FA_SMS',url='$SQL_log',url_response='';";
		#	if ($DB) {echo "$stmt\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			$affected_rows = mysqli_affected_rows($link);
			$url_id = mysqli_insert_id($link);

			$URLstart_sec = date("U");

			### grab the call_start_url ###
		#	if ($DB > 0) {echo "$sms_url<BR>\n";}
			$SCUfile = file("$sms_url");
			if ( !($SCUfile) )
				{
				$error_array = error_get_last();
				$error_type = $error_array["type"];
				$error_message = $error_array["message"];
				$error_line = $error_array["line"];
				$error_file = $error_array["file"];
				}

			if ($DB > 0) {echo "$SCUfile[0]<BR>\n";}

			### update url log entry
			$URLend_sec = date("U");
			$URLdiff_sec = ($URLend_sec - $URLstart_sec);
			if ($SCUfile)
				{
				$SCUfile_contents = implode("", $SCUfile);
				$SCUfile_contents = preg_replace('/;/','',$SCUfile_contents);
				$SCUfile_contents = addslashes($SCUfile_contents);
				}
			else
				{
				$SCUfile_contents = "PHP ERROR: Type=$error_type - Message=$error_message - Line=$error_line - File=$error_file";
				}
			$stmt = "UPDATE vicidial_url_log SET response_sec='$URLdiff_sec',url_response='$SCUfile_contents' where url_log_id='$url_id';";
			if ($DB) {echo "$stmt\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			$affected_rows = mysqli_affected_rows($link);

			$stmt = "INSERT INTO vicidial_agent_function_log set agent_log_id='0',user='$user',function='2FA_send',event_time=NOW(),campaign_id='-ADMIN-',user_group='$LOGuser_group',lead_id='0',uniqueid='SUCCESS',caller_code='$ip',stage='$stage',comments='SMS: $LOGmobile_number';";
			if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);

			echo "<br><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=3>"._QXZ("Your authorization code has been sent by %1s to",0,'',$stage).": $OBSCUREmobile_number<br></FONT>\n";
			}

		echo "<script language=\"JavaScript\">\n";
		echo "var method_selected=0;\n";
		echo "\n";
		echo "function code_2FA(temp_method)\n";
		echo "	{\n";
		echo "	if (method_selected < 1)\n";
		echo "		{\n";
		echo "	    document.userform.stage.value = 'SUBMIT';\n";
		echo "	    document.userform.rank.value = document.userform.authorization_code.value;\n";
		echo "	    document.userform.submit();\n";
		echo "		method_selected++;\n";
		echo "		}\n";
		echo "	}\n";
		echo "function back_2FA()\n";
		echo "	{\n";
		echo "	if (method_selected < 1)\n";
		echo "		{\n";
		echo "	    document.userform.stage.value = '';\n";
		echo "	    document.userform.auth_entry.value = '0';\n";
		echo "	    document.userform.submit();\n";
		echo "		method_selected++;\n";
		echo "		}\n";
		echo "	}\n";
		echo "</script>\n";

		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br><form action=$PHP_SELF method=POST name=userform id=userform>\n";
		echo "<input type=hidden name=ADD value=99999701>\n";
		echo "<input type=hidden name=DB value=\"$DB\">\n";
		echo "<input type=hidden name=stage value=SUBMIT>\n";
		echo "<input type=hidden name=auth_entry value='2'>\n";
		echo "<input type=hidden name=rank value=''>\n";
		echo "<input type=hidden name=user value=\"$PHP_AUTH_USER\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=left colspan=2>"._QXZ("Please enter the Auth Code that you have received by %1s into the field below, and click the SUBMIT button",0,'',$stage).". <a href=\"#\" onclick=\"back_2FA();\"><font color='black'>"._QXZ("To resend your auth code, click here to go back")."</font></a>.<br> &nbsp; </td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Authorization Code").": </td><td align=left style=\"display:table-cell; vertical-align:middle;\" NOWRAP><input type=text id=authorization_code name=authorization_code size=11 maxlength=10></td></tr>\n";


		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><button style='background-color:#$SSbutton_color' onclick=\"code_2FA();\">"._QXZ("SUBMIT")."</button></td></tr>\n";
		echo "</TABLE></center></form>\n";
		}
	##### END send out AUTH CODE and show auth-code entry page #####

	##### BEGIN choose how to send out AUTH CODE page #####
	else
		{
		if ($show_form > 0)
			{
			echo "<script language=\"JavaScript\">\n";
			echo "var method_selected=0;\n";
			echo "\n";
			echo "function send_2FA(temp_method)\n";
			echo "	{\n";
			echo "	if (method_selected < 1)\n";
			echo "		{\n";
			echo "	    document.userform.stage.value = temp_method;\n";
			echo "	    document.userform.submit();\n";
			echo "		method_selected++;\n";
			echo "		}\n";
			echo "	}\n";
			echo "</script>\n";

			echo "<TABLE><TR><TD>\n";
			echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

			echo "<br><form action=$PHP_SELF method=POST name=userform id=userform>\n";
			echo "<input type=hidden name=ADD value=99999701>\n";
			echo "<input type=hidden name=DB value=\"$DB\">\n";
			echo "<input type=hidden name=stage value=\"\">\n";
			echo "<input type=hidden name=auth_entry value='1'>\n";
			echo "<input type=hidden name=user value=\"$PHP_AUTH_USER\">\n";
			echo "<center><TABLE width=$section_width cellspacing=3>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=left colspan=2>"._QXZ("Your account has Two-Factor-Authorization enabled on it. In order to log in, you will need to verify your identity by submitting a temporary authorization code. Click on the icon below for the delivery method you would like to use to receive your authorization code").":</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=center><br>\n";

			echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=5 WIDTH=400>\n";
			$displayed_2FA=0;
			if ( (preg_match("/YES/i",$email_auth)) and (strlen($LOGemail) > 3) )
				{
				echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"send_2FA('EMAIL');\"";} echo ">\n";
				echo "<TD WIDTH=50 ALIGN=CENTER><a href=\"#\" onclick=\"send_2FA('EMAIL');\"><img src=\"images/icon_email.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
				echo "<TD WIDTH=350><a href=\"#\" STYLE=\"text-decoration:none;\" onclick=\"send_2FA('EMAIL');\"><SPAN $subhead_font> "._QXZ("Email you an auth code")." </SPAN></a><font face=\"Arial,Helvetica\" size=2><br> "._QXZ("Send an email to").": </font><font face=\"Courier\" size=2>$OBSCUREemail</font></TD>\n";
				echo "</TR>\n";
				$displayed_2FA++;
				}
			if ( (preg_match("/YES/i",$phone_auth)) and (strlen($LOGmobile_number) > 1) )
				{
				echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"send_2FA('PHONE');\"";} echo ">\n";
				echo "<TD WIDTH=50 ALIGN=CENTER><a href=\"#\" onclick=\"send_2FA('PHONE');\"><img src=\"images/icon_black_inbound.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
				echo "<TD WIDTH=350><a href=\"#\" STYLE=\"text-decoration:none;\" onclick=\"send_2FA('PHONE');\"><SPAN $subhead_font> "._QXZ("Call you and play an auth code")." </SPAN></a><font face=\"Arial,Helvetica\" size=2><br> "._QXZ("Place a phone call to").": </font><font face=\"Courier\" size=2>$OBSCUREmobile_number</font></TD>\n";
				echo "</TR>\n";
				$displayed_2FA++;
				}
			if ( (preg_match("/YES/i",$sms_auth)) and (strlen($LOGmobile_number) > 1) )
				{
				echo "<TR CLASS=\"adminmenu_style_selected\""; if ($SSadmin_row_click > 0) {echo " onclick=\"send_2FA('SMS');\"";} echo ">\n";
				echo "<TD WIDTH=50 ALIGN=CENTER><a href=\"#\" onclick=\"send_2FA('SMS');\"><img src=\"images/icon_chat.png\" border=0 width=42 height=42 valign=middle> </a></TD>\n";
				echo "<TD WIDTH=350><a href=\"#\" STYLE=\"text-decoration:none;\" onclick=\"send_2FA('SMS');\"><SPAN $subhead_font> "._QXZ("Text-Message you an auth code")." </SPAN></a><font face=\"Arial,Helvetica\" size=2><br> "._QXZ("Send a message to").": </font><font face=\"Courier\" size=2>$OBSCUREmobile_number</font></TD>\n";
				echo "</TR>\n";
				$displayed_2FA++;
				}
			if ($displayed_2FA < 1)
				{
				echo _QXZ("Your User account is not configured for Two-Factor-Authentication. Please contact your system administrator").".\n";
				exit;
				}
			echo "</TABLE><br> &nbsp;\n";

			echo "</td></tr>\n";

			#echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
			echo "</TABLE></center></form>\n";
			}
		}
	##### END choose how to send out AUTH CODE page #####
	}
##### END User 2FA(Two-Factor-Authentication) Page #####











######################
# ADD=999996 - initial install welcome page
######################
if ($ADD==999996)
	{
	if ($SSfirst_login_trigger=='Y')
		{
		$show_form=1;
		if ( ($stage=='SUBMIT') or ($stage==_QXZ("SUBMIT")) )
			{
			if ( (mb_strlen($pass,'utf-8') > 100) or (strlen($pass) < 2) or ($pass==$PHP_AUTH_PW) or ( ($SSrequire_password_length > 0) and ( ($SSrequire_password_length > strlen($default_phone_registration_password)) or ( ($SSrequire_password_length > strlen($default_phone_login_password)) or ( ($SSrequire_password_length > strlen($default_server_password)) ) ) or ($SSrequire_password_length > strlen($pass)) ) ) )
				{
				echo _QXZ("Password has not been changed, please try again")." |1|" . strlen($pass);
				if ($SSrequire_password_length > 0)
					{
					echo "<br>"._QXZ("All passwords must be at least $SSrequire_password_length characters long")."\n";
					}
				}
			else
				{
				$pass_hash='';
				$pass_checkSQL="pass='$pass'";
				if ( ($SSpass_hash_enabled > 0) and (strlen($pass) > 1) )
					{
					$pass = preg_replace("/\'|\"|\\\\|;|<|>| /","",$pass);
					$pass_hash = exec("../agc/bp.pl --pass=$pass");
					$pass_hash = preg_replace("/PHASH: |\n|\r|\t| /",'',$pass_hash);
					$pass_checkSQL="pass_hash='$pass_hash'";
					$pass='';
					}
				$stmt="SELECT count(*) from vicidial_users where user='$user' and active='Y' and user_level > 6;";
				$rslt=mysql_to_mysqli($stmt, $link);
				if ($DB) {echo "$stmt\n";}
				$userpass_to_print = mysqli_num_rows($rslt);
				if ($userpass_to_print < 1)
					{echo _QXZ("Password has not been changed, please try again")." |2|$userpass_to_print";}
				else
					{
					$row=mysqli_fetch_row($rslt);
					if ($row[0] < 1)
						{echo _QXZ("Password has not been changed, please try again")." |3|$row[0]";}
					else
						{
						$stmt="SELECT count(*) from vicidial_users where user='$user' and $pass_checkSQL;";
						$rslt=mysql_to_mysqli($stmt, $link);
						if ($DB) {echo "$stmt\n";}
						$userpass_to_print = mysqli_num_rows($rslt);
						if ($userpass_to_print < 1)
							{echo _QXZ("Password has not been changed, please try again")." |4|$userpass_to_print";}
						else
							{
							$row=mysqli_fetch_row($rslt);
							if ($row[0] > 0)
								{echo _QXZ("You cannot use the same password as your last password, please try again")." |5|$row[0]";}
							else
								{
								$show_form=0;

								if (strlen($default_phone_registration_password) < 2) {$default_phone_registration_password = $SSdefault_phone_registration_password;}
								if (strlen($default_phone_login_password) < 2) {$default_phone_login_password = $SSdefault_phone_login_password;}
								if (strlen($default_server_password) < 2) {$default_server_password = $SSdefault_server_password;}
								if (strlen($default_local_gmt) < 2) {$default_local_gmt = $SSdefault_local_gmt;}
								if (strlen($default_voicemail_timezone) < 2) {$default_voicemail_timezone = $SSdefault_voicemail_timezone;}

								$stmt="UPDATE vicidial_users SET pass='$pass',pass_hash='$pass_hash',force_change_password='N',failed_login_count=0 where user='$user' and active='Y' and user_level > 6;";
								$rslt=mysql_to_mysqli($stmt, $link);

								$stmtA="UPDATE system_settings SET first_login_trigger='N',default_phone_registration_password='$default_phone_registration_password',default_phone_login_password='$default_phone_login_password',default_server_password='$default_server_password',default_local_gmt='$default_local_gmt',default_voicemail_timezone='$default_voicemail_timezone';";
								$rslt=mysql_to_mysqli($stmtA, $link);

								$stmtB="UPDATE phones SET conf_secret='$default_phone_registration_password',pass='$default_phone_login_password',local_gmt='$default_local_gmt',voicemail_timezone='$default_voicemail_timezone';";
								$rslt=mysql_to_mysqli($stmtB, $link);

								$stmtC="UPDATE servers SET conf_secret='$default_server_password',rebuild_conf_files='Y';";
								$rslt=mysql_to_mysqli($stmtC, $link);

								### LOG INSERTION Admin Log Table ###
								$SQL_log = "$stmt|$stmtA|$stmtB|$stmtC|";
								$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='$user', event_code='INITIAL SETTINGS UPDATE', event_sql=\"$SQL_log\", event_notes='';";
								if ($DB) {echo "|$stmt|\n";}
								$rslt=mysql_to_mysqli($stmt, $link);

								echo _QXZ("Passwords have been updated, you may now continue on into Administration").". <BR><BR>"._QXZ("You may want to start by reading the ViciDial Manager Manual available at")." <a href=\"http://www.vicidial.org/store.php#MANAGER\" target=\"_blank\">vicidial.org</a> ("._QXZ("there is a free version available").")\n";
								}
							}
						}
					}
				}
			}
		if ($show_form > 0)
			{
			echo "<TABLE><TR><TD>\n";
			echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

			echo "<br><b>"._QXZ("Welcome to ViciDial, initial setup screen")."</b><br><br><form action=$PHP_SELF method=POST name=userform id=userform>\n";
			echo "<input type=hidden name=ADD value=999996>\n";
			echo "<input type=hidden name=DB value=\"$DB\">\n";
			echo "<input type=hidden name=stage value=SUBMIT>\n";
			echo "<input type=hidden name=user value=\"$PHP_AUTH_USER\">\n";
			echo "<center><TABLE width=$section_width cellspacing=3>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=left colspan=2>"._QXZ("You are required to change your password before you can continue on to Administration. The longer the password is, the stronger it will be. Your password must be from 2 to 100 characters in length and cannot contain any characters that are not letters or numbers. Be sure that this password is something that you can remember, because as soon as you complete this initial setup screen you will be prompted to enter your new password in again to log back in to Administration")."</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("New Password").": </td><td align=left style=\"display:table-cell; vertical-align:middle;\" NOWRAP><input type=text id=reg_pass name=pass size=50 maxlength=100 onkeyup=\"return pwdChanged('reg_pass','reg_pass_img','pass_length','$SSrequire_password_length');\"> &nbsp; &nbsp; <font size=1>"._QXZ("Strength").":</font> <IMG id=reg_pass_img src='images/pixel.gif' style=\"vertical-align:middle;\" onLoad=\"return pwdChanged('reg_pass','reg_pass_img','pass_length','$SSrequire_password_length');\"> &nbsp; <font size=1> "._QXZ("Length").": <span id=pass_length name=pass_length>0</span></font></td></tr>\n";

			echo "<tr><td colspan=2> &nbsp; </td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=left colspan=2>"._QXZ("The next three default passwords are defined in the System Settings section, and you can change them after you define them here. It is a good idea to make these passwords strong so that no one can hack into your phone accounts and place phone calls without you knowing. The default registration password used when new phones are added to the system as the SIP or IAX VOIP phone password. The default phone web login password used when new phones are added to the system, as the phone password that an agent would use in the ViciDial Agent Interface. The default server password used when new servers are added to the system for servers to communicate with each other.")."</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Default Phone Registration Password").": </td><td align=left style=\"display:table-cell; vertical-align:middle;\" NOWRAP><input type=text id=reg_passX name=default_phone_registration_password size=40 maxlength=100 value=\"$SSdefault_phone_registration_password\" onkeyup=\"return pwdChanged('reg_passX','reg_pass_imgX','pass_lengthX','$SSrequire_password_length');\"> &nbsp; &nbsp; <font size=1>"._QXZ("Strength").":</font> <IMG id=reg_pass_imgX src='images/pixel.gif' style=\"vertical-align:middle;\" onLoad=\"return pwdChanged('reg_passX','reg_pass_imgX','pass_lengthX','$SSrequire_password_length');\"> &nbsp; <font size=1> "._QXZ("Length").": <span id=pass_lengthX name=pass_lengthX>0</span></font></td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Default Phone Login Password").": </td><td align=left style=\"display:table-cell; vertical-align:middle;\" NOWRAP><input type=text id=reg_passY name=default_phone_login_password size=40 maxlength=100 value=\"$SSdefault_phone_login_password\" onkeyup=\"return pwdChanged('reg_passY','reg_pass_imgY','pass_lengthY','$SSrequire_password_length');\"> &nbsp; &nbsp; <font size=1>"._QXZ("Strength").":</font> <IMG id=reg_pass_imgY src='images/pixel.gif' style=\"vertical-align:middle;\" onLoad=\"return pwdChanged('reg_passY','reg_pass_imgY','pass_lengthY','$SSrequire_password_length');\"> &nbsp; <font size=1> "._QXZ("Length").": <span id=pass_lengthY name=pass_lengthY>0</span></font></td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Default Server Password").": </td><td align=left style=\"display:table-cell; vertical-align:middle;\" NOWRAP><input type=text id=reg_passZ name=default_server_password size=40 maxlength=100 value=\"$SSdefault_server_password\" onkeyup=\"return pwdChanged('reg_passZ','reg_pass_imgZ','pass_lengthZ','$SSrequire_password_length');\"> &nbsp; &nbsp; <font size=1>"._QXZ("Strength").":</font> <IMG id=reg_pass_imgZ src='images/pixel.gif' style=\"vertical-align:middle;\" onLoad=\"return pwdChanged('reg_passZ','reg_pass_imgZ','pass_lengthZ','$SSrequire_password_length');\"> &nbsp; <font size=1> "._QXZ("Length").": <span id=pass_lengthZ name=pass_lengthZ>0</span></font></td></tr>\n";

			echo "<tr><td colspan=2> &nbsp; </td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=left colspan=2>"._QXZ("The next two settings are also defined in the System Settings section, and you can change them after you define them here. You should set the Default Local GMT to the timezone that your agents want to be in. The Voicemail zone is the listing of voicemail timezones that voicemail messages will be time logged with when new messages are left.")."</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Default Local GMT").": </td><td align=left><select size=1 name=default_local_gmt><option>12.75</option><option>12.00</option><option>11.00</option><option>10.00</option><option>9.50</option><option>9.00</option><option>8.00</option><option>7.00</option><option>6.50</option><option>6.00</option><option>5.75</option><option>5.50</option><option>5.00</option><option>4.50</option><option>4.00</option><option>3.50</option><option>3.00</option><option>2.00</option><option>1.00</option><option>0.00</option><option>-1.00</option><option>-2.00</option><option>-3.00</option><option>-3.50</option><option>-4.00</option><option>-5.00</option><option>-6.00</option><option>-7.00</option><option>-8.00</option><option>-9.00</option><option>-10.00</option><option>-11.00</option><option>-12.00</option><option selected>$SSdefault_local_gmt</option></select> ("._QXZ("Do NOT Adjust for DST").")$NWB#settings-default_local_gmt$NWE</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Default Voicemail Zone").": </td><td align=left><select size=1 name=default_voicemail_timezone>";
			$vm_zones = explode("\n",$SSvoicemail_timezones);
			$z=0;
			$vm_zones_ct = count($vm_zones);
			while($vm_zones_ct > $z)
				{
				if (strlen($vm_zones[$z]) > 5)
					{
					$vm_specs = explode("=",$vm_zones[$z]);
					$vm_abb = $vm_specs[0];
					$vm_details = explode('|',$vm_specs[1]);
					$vm_location = 	$vm_details[0];
					echo "<option value=\"$vm_abb\">$vm_abb - $vm_location</option>\n";
					}
				$z++;
				}
			echo "<option selected>$SSdefault_voicemail_timezone</option></select> $NWB#settings-default_voicemail_timezone$NWE</td></tr>\n";

			echo "<tr><td colspan=2> &nbsp; </td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
			echo "</TABLE></center></form>\n";
			}
		}
	}
##### END initial install welcome page #####


######################
# ADD=999995 - copyright trademark license page
######################
if ($ADD==999995)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	echo "<br><B> "._QXZ("Welcome to ViciDial: copyright, trademark and license page")."</B><BR><BR>\n";
	echo "<center><TABLE width=$section_width cellspacing=5 cellpadding=2>\n";

	echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top><B><font size=3>"._QXZ("Copyright").": </B></td><td align=left> &nbsp; "._QXZ("The ViciDial Contact Center Suite is maintained by the")." <a href=\"http://www.vicidial.com/\" target=\"_blank\">ViciDial Group</a>, &copy; 2025</td></tr>\n";

	echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top><B><font size=3>"._QXZ("Trademark").": </B></td><td align=left> &nbsp; \"VICIDIAL\" "._QXZ("is a registered trademark of the")." <a href=\"http://www.vicidial.com/\" target=\"_blank\">ViciDial Group</a>. Here is our <a href=\"http://www.vicidial.com/?page_id=262\" target=\"_blank\">"._QXZ("trademark use policy")."</a></td></tr>\n";

	echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top><B><font size=3>"._QXZ("License").": </B></td><td align=left> &nbsp; "._QXZ("The ViciDial Contact Center Suite is released under the")." <a href=\"http://www.vicidial.com/?page_id=260\" target=\"_blank\">AGPLv2 "._QXZ("open source license")."</a>.</td></tr>\n";

	echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top nowrap><B><font size=3>"._QXZ("Source Code").": </B></td><td align=left> &nbsp; "._QXZ("The ViciDial Call Center Suite software is available for download, and for use, free of cost. You can download the easy to install")." <a href=\"http://vicibox.com/server/index.html\" target=\"_blank\">"._QXZ("ViciBox CD ISO version")."</a>, "._QXZ("or only the")." <a href=\"http://sourceforge.net/projects/astguiclient/files/\" target=\"_blank\">"._QXZ("source code")."</a></td></tr>\n";

	echo "</TABLE></center>\n";

	if ($first_login_link > 0)
		{
		echo "<BR><BR>";
		echo "<BR><center><a href=\"$PHP_SELF?ADD=999996\"><B><font size=4>"._QXZ("Continue on to the Initial Setup")."</font></b></a></center><BR><BR><BR> &nbsp; \n";
		}

	echo "<br><br><B> "._QXZ("Other integrated software disclaimers").":</B><BR><BR>\n";

	echo "<center><TABLE width=$section_width cellspacing=5 cellpadding=2>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=middle rowspan=3 nowrap><B><font size=3>"._QXZ("Matex").": </B></td>";
	echo "<td align=right valign=top><B><font size=2>"._QXZ("Copyright").": </B></td><td align=left><font size=1> &nbsp; "._QXZ("Matex PHP Mathematical expression parser and evaluator library was written by Dorin Marcoci").", &copy; 2023</td></tr>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top><B><font size=2>"._QXZ("License").": </B></td><td align=left><font size=1> &nbsp; "._QXZ("Matex is licensed under the")." <a href=\"https://github.com/madorin/matex/blob/master/LICENSE.md\" target=\"_blank\">MIT "._QXZ("open source license")."</a></td></tr>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top nowrap><B><font size=2>"._QXZ("Source Code").": </B></td><td align=left><font size=1> &nbsp; "._QXZ("Matex original source code is available at")." <a href=\"https://github.com/madorin/matex\" target=\"_blank\">"._QXZ("this link")."</a>.</td></tr>\n";

	echo "<tr><td colspan=3> &nbsp; </tr>";

	echo "<center><TABLE width=$section_width cellspacing=5 cellpadding=2>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=middle rowspan=3 nowrap><B><font size=3>"._QXZ("Pure-knob").": </B></td>";
	echo "<td align=right valign=top><B><font size=2>"._QXZ("Copyright").": </B></td><td align=left><font size=1> &nbsp; "._QXZ("The pure-knob javascript library was written by Andre Pl&ouml;tze").", &copy; 2018</td></tr>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top><B><font size=2>"._QXZ("License").": </B></td><td align=left><font size=1> &nbsp; "._QXZ("Pure-knob is licensed under the")." <a href=\"https://github.com/andrepxx/pure-knob/blob/master/LICENSE\" target=\"_blank\">Apache 2.0 "._QXZ("open source license")."</a></td></tr>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top nowrap><B><font size=2>"._QXZ("Source Code").": </B></td><td align=left><font size=1> &nbsp; "._QXZ("Pure-knob original source code is available at")." <a href=\"https://github.com/andrepxx/pure-knob/\" target=\"_blank\">"._QXZ("this link")."</a>.</td></tr>\n";

	echo "<tr><td colspan=3> &nbsp; </tr>";

	echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=middle rowspan=3 nowrap><B><font size=3>"._QXZ("Chart.js").": </B></td>";
	echo "<td align=right valign=top><B><font size=2>"._QXZ("Copyright").": </B></td><td align=left><font size=1> &nbsp; "._QXZ("The Chart.js javascript library was written by Chart.js Contributors").", &copy; 2018</td></tr>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top><B><font size=2>"._QXZ("License").": </B></td><td align=left><font size=1> &nbsp; "._QXZ("Chart.js is licensed under the")." <a href=\"https://github.com/chartjs/Chart.js/blob/master/LICENSE.md\" target=\"_blank\">MIT "._QXZ("open source license")."</a></td></tr>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top nowrap><B><font size=2>"._QXZ("Source Code").": </B></td><td align=left><font size=1> &nbsp; "._QXZ("Chart.js original source code is available at")." <a href=\"https://github.com/chartjs/Chart.js\" target=\"_blank\">"._QXZ("this link")."</a>.</td></tr>\n";

	echo "<tr><td colspan=3> &nbsp; </tr>";

	echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=middle rowspan=3 nowrap><B><font size=3>"._QXZ("classAudioFile").": </B></td>";
	echo "<td align=right valign=top><B><font size=2>"._QXZ("Copyright").": </B></td><td align=left><font size=1> &nbsp; "._QXZ("The classAudioFile PHP library was written by Michael Kamleitner").", &copy; 2003</td></tr>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top><B><font size=2>"._QXZ("License").": </B></td><td align=left><font size=1> &nbsp; "._QXZ("classAudioFile is licensed under the")." <a href=\"http://www.opensource.org/licenses/gpl-license.html\" target=\"_blank\">GPL "._QXZ("open source license")."</a></td></tr>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top nowrap><B><font size=2>"._QXZ("Source Code").": </B></td><td align=left><font size=1> &nbsp; "._QXZ("classAudioFile original source code is available at")." <a href=\"https://www.phpclasses.org/audiofile\" target=\"_blank\">"._QXZ("this link")."</a>.</td></tr>\n";

	echo "<tr><td colspan=3> &nbsp; </tr>";

	echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=middle rowspan=3 nowrap><B><font size=3>"._QXZ("Dygraphs").": </B></td>";
	echo "<td align=right valign=top><B><font size=2>"._QXZ("Copyright").": </B></td><td align=left><font size=1> &nbsp; "._QXZ("The Dygraphs javascript library was written by Dygraphs Contributors").", &copy; 2023</td></tr>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top><B><font size=2>"._QXZ("License").": </B></td><td align=left><font size=1> &nbsp; "._QXZ("Dygraphs is licensed under the")." <a href=\"https://dygraphs.com/LICENSE.txt\" target=\"_blank\">MIT "._QXZ("open source license")."</a></td></tr>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top nowrap><B><font size=2>"._QXZ("Source Code").": </B></td><td align=left><font size=1> &nbsp; "._QXZ("Dygraphs original source code is available at")." <a href=\"https://dygraphs.com/download.html\" target=\"_blank\">"._QXZ("this link")."</a>.</td></tr>\n";

	echo "<tr><td colspan=3> &nbsp; </tr>";

	echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=middle rowspan=3 nowrap><B><font size=3>"._QXZ("Jquery").": </B></td>";
	echo "<td align=right valign=top><B><font size=2>"._QXZ("Copyright").": </B></td><td align=left><font size=1> &nbsp; "._QXZ("The Jquery javascript library was written by OpenJS Foundation contributors").", &copy; 2023</td></tr>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top><B><font size=2>"._QXZ("License").": </B></td><td align=left><font size=1> &nbsp; "._QXZ("Jquery is licensed under the")." <a href=\"https://jquery.org/license/\" target=\"_blank\">MIT "._QXZ("open source license")."</a></td></tr>\n";
	echo "<tr bgcolor=#$SSstd_row4_background><td align=right valign=top nowrap><B><font size=2>"._QXZ("Source Code").": </B></td><td align=left><font size=1> &nbsp; "._QXZ("Jquery original source code is available at")." <a href=\"https://jquery.com/download/\" target=\"_blank\">"._QXZ("this link")."</a>.</td></tr>\n";

	echo "</TABLE></center>\n";
	}
##### END copyright trademark license page #####


######################
# ADD=999994 - admin hidden utilities page
######################
if ($ADD==999994)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	echo "<br><B> "._QXZ("Administration: hidden utilities page - If you do not know what these utilities do, you probably should not use them")."</B><BR><BR>\n";
	echo "<center><TABLE width=$section_width cellspacing=5 cellpadding=2><tr bgcolor=#$SSstd_row4_background><td align=left valign=top>\n";

	if ( ($LOGuser_level >= 9) and ( (preg_match("/Admin Utilities Page/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) )
		{
		echo "<UL>\n";
	#	echo "<LI><a href=\"welcome_languages.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Welcome Languages Page")."</a></FONT>\n";
		echo "<LI><a href=\"help.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Old Help Page")."</a></FONT>\n";
		echo "<LI><a href=\"$PHP_SELF?ADD=999991\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Servers Versions")."</a></FONT>\n";
		if ( (preg_match("/VERM Reports/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
			{echo "<LI><a href=\"../VERM/VERM_admin.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK size=2>"._QXZ("VERM - Enhanced Reporting Module")."</a></FONT>\n";}
		echo "<BR><BR>\n";
		echo "<LI><a href=\"settings_compare.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Settings Compare Utility")."</a></FONT> | <a href=\"db_schema_compare.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("DB Schema Compare Utility")."</a></FONT>\n";
		echo "<LI><a href=\"campaign_debug.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Campaign Debug Page")."</a></FONT>\n";
		echo "<LI><a href=\"shared_debug.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Shared Debug Page")."</a></FONT> | <a href=\"demographic_quotas_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Demographic Quotas Report")."</a></FONT>\n";
		echo "<LI><a href=\"AST_dial_log_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Dial Log Report")."</a></FONT>\n";
		echo "<LI><a href=\"AST_carrier_log_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Carrier Log Report")."</a></FONT>\n";
		echo "<LI><a href=\"callerID_log_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Caller ID Log Report")."</a></FONT>\n";
		echo "<LI><a href=\"AST_hangup_cause_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Hangup Cause Report")."</a></FONT>\n";
		echo "<LI><a href=\"AST_SIP_event_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("SIP Event Report")."</a></FONT>\n";
		echo "<LI><a href=\"AST_AMD_log_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("AMD Log Report")."</a></FONT>\n";
		echo "<LI><a href=\"AST_3way_press_log_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("3-Way Press Log Report")."</a></FONT>\n";
		echo "<LI><a href=\"AST_DIDdetail.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Inbound DID Detail Report")."</a></FONT> | <a href=\"admin_user_inbound.php?user=---ALL---\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("User Inbound Calls Today")."</a></FONT>\n";
		if ($KHOMP_enabled > 0)
			{echo "<LI><a href=\"KHOMP_admin.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Dialer KHOMP Admin Tool")."</a></FONT> | <a href=\"khomp_quick_stats.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Khomp Quick Stats Report")."</a></FONT>\n";}
		echo "<LI><a href=\"asterisk_debug.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Asterisk Debug Page")."</a></FONT>\n";
		echo "<LI><a href=\"call_report_export_carrier.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Export Calls Report Carrier")."</a></FONT>\n";
		echo "<LI><a href=\"AST_url_log_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("URL Log Report")."</a></FONT>\n";
		echo "<LI><a href=\"AST_webserver_url_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Webserver-URL Report")."</a></FONT>\n";
		echo "<LI><a href=\"AST_LAGGED_log_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Agent LAGGED Report")."</a></FONT> | <a href=\"AST_LAGGED_log_report_summary.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("LAGGED Summary")."</a></FONT> | <a href=\"user_latency_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Agent Latency Report")."</a></FONT> | <a href=\"AST_latency_gaps_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Latency Gaps")."</a></FONT>\n";
		echo "<LI><a href=\"AST_usergroup_login_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("User Group Login Report")."</a></FONT>\n";
		echo "<LI><a href=\"user_logins_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("User Logins Report")."</a></FONT>\n";
		echo "<LI><a href=\"AST_agent_debug_log_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Agent Debug Log Report")."</a></FONT>\n";
		echo "<LI><a href=\"AST_rt_monitor_log_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Real-Time Monitoring Log Report")."</a></FONT>\n";
		echo "<LI><a href=\"AST_parkstats.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Agent Parked Call Report")."</a></FONT>\n";
		echo "<LI><a href=\"AST_chat_log_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Agent-Manager Chat Log")."</a></FONT>\n";
		echo "<LI><a href=\"agent_timeoff_interface.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Agent Time-Off Interface")."</a></FONT>\n";
		echo "<LI><a href=\"AST_API_log_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("API Log Report")."</a></FONT>\n";
		echo "<LI><a href=\"AST_recording_log_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Recording Access Log")."</a></FONT>\n";
		echo "<LI><a href=\"admin.php?ADD=800000000000000\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Admin Report Log Viewer")."</a></FONT>\n";
		echo "<BR><BR>\n";
		echo "<LI><a href=\"admin_bulk_tools.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Admin Bulk Tools")."</FONT></a> | <a href=\"admin_phones_bulk_insert.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Bulk Phone Insert Page")."</FONT></a>\n";
		echo "<LI><a href=\"lead_tools.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Basic Lead Management Tools")."</FONT></a> | <a href=\"lead_tools_advanced.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Advanced Lead Management Tools")."</FONT></a> | <a href=\"list_split.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("List Split")."</FONT></a> | <a href=\"list_merge.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("List Merge")."</FONT></a>\n";
		echo "<LI><a href=\"reset_campaign_lists.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Reset Campaign Lists")."</a></FONT>\n";
		echo "<LI><a href=\"callbacks_bulk_change.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Callbacks Transferral Page")."</a></FONT> | <a href=\"callbacks_bulk_move.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Callbacks Bulk Move")."</FONT></a> | <a href=\"callbacks_export.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Callbacks Export")."</FONT></a>\n";
		if ($SSenable_international_dncs)
			{echo "<LI><a href=\"Vicidial_international_DNC_interface.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("International DNC Loader")."</a></FONT></a>\n";}
		echo "<LI><a href=\"vicidial_custom_reports_admin.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Custom Reports Admin Page")."</a></FONT></a>\n";
		echo "<LI><a href=\"send_CID_call.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Send a Call With Custom CID Page")."</a></FONT>\n";
		echo "<LI><a href=\"voice_lab.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Speech Voice Lab Page")."</a></FONT>\n";
		echo "<LI><a href=\"../agc/phone_only.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Webphone Only Page")."</a></FONT>\n";
		echo "<LI><a href=\"admin_NANPA_updater.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("NANPA batch updater")."</a></FONT>\n";
		echo "</UL>\n<BR>&nbsp;\n";
		}

	echo "</td></tr></TABLE></center>\n";
	}
##### END admin hidden utilities page #####


######################
# ADD=999993 - max stats detail report
######################
if ($ADD==999993)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	if ( (preg_match("/Maximum Stats Detail/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
		{
		$day_count=30;
		if (strlen($SUB) > 0)
			{$day_count = $SUB;}
		if ($stage == 'in-group')
			{
			$in_out = 'in-group';
			$max_type = 'max_inbound';
			$modify_link = "<a href=\"$PHP_SELF?ADD=3111&group_id=$campaign_id\">";
			$stmt="SELECT group_name from vicidial_inbound_groups where group_id='$campaign_id' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$rows_to_print = mysqli_num_rows($rslt);
			if ($rows_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$campaign_name = $rowx[0];
				}
			else
				{echo _QXZ("Not found");   exit;}
			}
		elseif ($stage == 'remote-agent')
			{
			$remote_agent_id='';
			$stmt="SELECT remote_agent_id from vicidial_remote_agents where user_start='$campaign_id';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$rows_to_print = mysqli_num_rows($rslt);
			if ($rows_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$remote_agent_id = $rowx[0];
				}
			else
				{echo _QXZ("Not found");   exit;}
			$modify_link = "<a href=\"$PHP_SELF?ADD=31111&remote_agent_id=$remote_agent_id\">";
			$campaign_name=$campaign_id;
			}
		else
			{
			$in_out = 'campaign';
			$max_type = 'max_outbound';
			$modify_link = "<a href=\"$PHP_SELF?ADD=31&campaign_id=$campaign_id\">";
			$stmt="SELECT campaign_name from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$rows_to_print = mysqli_num_rows($rslt);
			if ($rows_to_print > 0) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$campaign_name = $rowx[0];
				}
			else
				{echo _QXZ("Not found");   exit;}
			}

		echo "<br><b>"._QXZ("Administration: Maximum Stats Detail for")." $stage $modify_link$campaign_id</a> - $campaign_name</B> &nbsp; $NWB#max_stats$NWE<BR>\n";

		echo "<form action=$PHP_SELF method=GET>\n";
		echo "<input type=hidden name=ADD value=999993>\n";
		echo "<input type=hidden name=DB value=\"$DB\">\n";
		echo "<input type=hidden name=stage value=\"$stage\">\n";
		echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
		echo "Days: <input type=text id=SUB name=SUB size=5 maxlength=4 value=\"$day_count\"> &nbsp; &nbsp;<input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'>\n";
		echo "</form>\n";
		
		echo "<center><TABLE width=$section_width cellspacing=5 cellpadding=2>\n";

		if ($stage == 'remote-agent')
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>\n";
				$temp_chart_title = "$day_count " . _QXZ("Day call count for this remote-agent");
				horizontal_bar_chart($campaign_id,$day_count,$stage,$link,'ra_total_calls','call count',0,'','',$temp_chart_title);
			echo "</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>\n";
				$temp_chart_title = "$day_count " . _QXZ("Day most concurrent calls for this remote-agent");
				horizontal_bar_chart($campaign_id,$day_count,$stage,$link,'ra_concurrent_calls','most concurrent calls',0,'','',$temp_chart_title);
			echo "</td></tr>\n";
			}
		else
			{
			echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>\n";
				$temp_chart_title = "$day_count " . _QXZ("Day inbound call count for this in-group");
				if ($in_out=='campaign') {$temp_chart_title = "$day_count " . _QXZ("Day outbound call count for this campaign");}
				horizontal_bar_chart($campaign_id,$day_count,$in_out,$link,'total_calls','call count',0,'','',$temp_chart_title);
			echo "</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>\n";
				$temp_chart_title = "$day_count " . _QXZ("Day inbound most concurrent calls for this in-group");
				if ($in_out=='campaign') {$temp_chart_title = "$day_count " . _QXZ("Day outbound most concurrent calls for this campaign");}
				horizontal_bar_chart($campaign_id,$day_count,$in_out,$link,$max_type,'most concurrent calls',0,'','',$temp_chart_title);
			echo "</td></tr>\n";

			echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>\n";
				$temp_chart_title = "$day_count " . _QXZ("Day inbound most concurrent agents for this in-group");
				if ($in_out=='campaign') {$temp_chart_title = "$day_count " . _QXZ("Day outbound most concurrent agents for this campaign");}
				horizontal_bar_chart($campaign_id,$day_count,$in_out,$link,'max_agents','most concurrent agents',0,'','',$temp_chart_title);
			echo "</td></tr>\n";
			}
		}
	else
		{echo "You do not have permission to view this page";}

	echo "</TABLE></center>\n";
	}
##### END max stats detail report #####


######################
# ADD=999992 - max system stats report
######################
if ($ADD==999992)
	{
	if (!$query_date) {$query_date=date("Y-m-d", time()-(29*86400));}
	if (!$end_date) {
		$end_date=date("Y-m-d", time());
	} else if (strtotime($end_date)>strtotime(date("Y-m-d"))) {
		$end_date=date("Y-m-d");
	}
	if ($query_date>$end_date) {$query_date=$end_date;}

	
	$num_graph_days = ceil(abs(strtotime($end_date) - strtotime($query_date)) / 86400)+1;

	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	echo "<br><b> "._QXZ("Administration: Maximum System Stats")." &nbsp; $NWB#max_stats$NWE</B><BR><BR>\n";
	echo "<form name=\"vicidial_report\" action=\"admin.php\"><INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">";

	echo "<script language=\"JavaScript\">\n";
	echo "var o_cal = new tcal ({\n";
	echo "	// form name\n";
	echo "	'formname': 'vicidial_report',\n";
	echo "	// input name\n";
	echo "	'controlname': 'query_date'\n";
	echo "});\n";
	echo "o_cal.a_tpl.yearscroll = false;\n";
	echo "// o_cal.a_tpl.weekstart = 1; // Monday week start\n";
	echo "</script>\n";

	echo " "._QXZ("to")." <INPUT TYPE=TEXT NAME=end_date SIZE=10 MAXLENGTH=10 VALUE=\"$end_date\">";

	echo "<script language=\"JavaScript\">\n";
	echo "var o_cal = new tcal ({\n";
	echo "	// form name\n";
	echo "	'formname': 'vicidial_report',\n";
	echo "	// input name\n";
	echo "	'controlname': 'end_date'\n";
	echo "});\n";
	echo "o_cal.a_tpl.yearscroll = false;\n";
	echo "// o_cal.a_tpl.weekstart = 1; // Monday week start\n";
	echo "</script>&nbsp;&nbsp;&nbsp;&nbsp;<input style='background-color:#$SSbutton_color' type='submit' name='max_system_stats_submit' VALUE='"._QXZ("ADJUST DATE RANGE")."'><input type='hidden' name='ADD' value='$ADD'><input type='hidden' name='stage' value='$stage'></form><BR>\n";
	echo "<center><a href='$PHP_SELF?query_date=$query_date&end_date=$end_date&max_system_stats_submit=$max_system_stats_submit&ADD=$ADD&stage=$stage&download_max_system_stats_metric_name=ALL'>["._QXZ("DOWNLOAD ALL")."]</a><TABLE width=$section_width cellspacing=5 cellpadding=2>\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_to_mysqli($stmt, $link);
		$rows_to_print = mysqli_num_rows($rslt);
		if ($rows_to_print > 0) 
			{
			$rowx=mysqli_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_to_mysqli($stmt, $link);
			}

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>\n";
			$download_link="<font size='-2'><a href='$PHP_SELF?query_date=$query_date&end_date=$end_date&max_system_stats_submit=$max_system_stats_submit&ADD=$ADD&stage=$stage&download_max_system_stats_metric_name=total+call+count+in+and+out'>["._QXZ("DOWNLOAD")."]</a></font>";
			$temp_chart_title = "$num_graph_days " . _QXZ("Day total call count in and out for this system");
			horizontal_bar_chart($campaign_id,$num_graph_days,'system',$link,'total_calls','total call count in and out',0,$end_date,$download_link,$temp_chart_title);
		echo "</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>\n";
			$download_link="<font size='-2'><a href='$PHP_SELF?query_date=$query_date&end_date=$end_date&max_system_stats_submit=$max_system_stats_submit&ADD=$ADD&stage=$stage&download_max_system_stats_metric_name=total+inbound+call+count'>["._QXZ("DOWNLOAD")."]</a></font>";
			$temp_chart_title = "$num_graph_days " . _QXZ("Day total inbound call count for this system");
			horizontal_bar_chart($campaign_id,$num_graph_days,'system',$link,'total_calls_inbound_all','total inbound call count',0,$end_date,$download_link,$temp_chart_title);
		echo "</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>\n";
			$download_link="<font size='-2'><a href='$PHP_SELF?query_date=$query_date&end_date=$end_date&max_system_stats_submit=$max_system_stats_submit&ADD=$ADD&stage=$stage&download_max_system_stats_metric_name=total+outbound+call+count'>["._QXZ("DOWNLOAD")."]</a></font>";
			$temp_chart_title = "$num_graph_days " . _QXZ("Day total outbound call count for this system");
			horizontal_bar_chart($campaign_id,$num_graph_days,'system',$link,'total_calls_outbound_all','total outbound call count',0,$end_date,$download_link,$temp_chart_title);
		echo "</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>\n";
			$download_link="<font size='-2'><a href='$PHP_SELF?query_date=$query_date&end_date=$end_date&max_system_stats_submit=$max_system_stats_submit&ADD=$ADD&stage=$stage&download_max_system_stats_metric_name=most+concurrent+calls+in+and+out'>["._QXZ("DOWNLOAD")."]</a></font>";
			$temp_chart_title = "$num_graph_days " . _QXZ("Day most concurrent calls in and out for this system");
			horizontal_bar_chart($campaign_id,$num_graph_days,'system',$link,'(max_inbound + max_outbound)','most concurrent calls in and out',0,$end_date,$download_link,$temp_chart_title);
		echo "</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>\n";
			$download_link="<font size='-2'><a href='$PHP_SELF?query_date=$query_date&end_date=$end_date&max_system_stats_submit=$max_system_stats_submit&ADD=$ADD&stage=$stage&download_max_system_stats_metric_name=most+concurrent+calls+inbound+total'>["._QXZ("DOWNLOAD")."]</a></font>";
			$temp_chart_title = "$num_graph_days " . _QXZ("Day most concurrent calls inbound total for this system");
			horizontal_bar_chart($campaign_id,$num_graph_days,'system',$link,'max_inbound','most concurrent calls inbound total',0,$end_date,$download_link,$temp_chart_title);
		echo "</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>\n";
			$download_link="<font size='-2'><a href='$PHP_SELF?query_date=$query_date&end_date=$end_date&max_system_stats_submit=$max_system_stats_submit&ADD=$ADD&stage=$stage&download_max_system_stats_metric_name=most+concurrent+calls+outbound+total'>["._QXZ("DOWNLOAD")."]</a></font>";
			$temp_chart_title = "$num_graph_days " . _QXZ("Day most concurrent calls outbound total for this system");
			horizontal_bar_chart($campaign_id,$num_graph_days,'system',$link,'max_outbound','most concurrent calls outbound total',0,$end_date,$download_link,$temp_chart_title);
		echo "</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2>\n";
			$download_link="<font size='-2'><a href='$PHP_SELF?query_date=$query_date&end_date=$end_date&max_system_stats_submit=$max_system_stats_submit&ADD=$ADD&stage=$stage&download_max_system_stats_metric_name=most+concurrent+agents'>["._QXZ("DOWNLOAD")."]</a></font>";
			$temp_chart_title = "$num_graph_days " . _QXZ("Day most concurrent agents for this system");
			horizontal_bar_chart($campaign_id,$num_graph_days,'system',$link,'max_agents','most concurrent agents',0,$end_date,$download_link,$temp_chart_title);
		echo "</td></tr>\n";
		}
	else
		{echo "You do not have permission to view this page";}
	echo "</TABLE></center>\n";
	}
##### END max system stats report #####

######################
# ADD=999990 - new main landing page with system stats
######################
if ($ADD==999990)
	{
	if ( (preg_match("/Front Page System Summary/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) )
		{
		$stmt="SELECT closer_campaigns from vicidial_campaigns $whereLOGallowed_campaignsSQL;";
		if ($DB) {echo "|$stmt|\n";}
		$rslt=mysql_to_mysqli($stmt, $link);
		$row=mysqli_fetch_row($rslt);
		$closer_campaigns = preg_replace("/^ | -$/","",$row[0]);
		$closer_campaigns = preg_replace("/ /","','",$closer_campaigns);
		$closer_campaigns = "'$closer_campaigns'";

		$stmt="SELECT status from vicidial_auto_calls where status NOT IN('XFER') and ( (call_type='IN' and campaign_id IN($closer_campaigns)) or (call_type='OUT' $LOGallowed_campaignsSQL) );";
		if ($DB) {echo "|$stmt|\n";}
		$rslt=mysql_to_mysqli($stmt, $link);
		$active_calls=mysqli_num_rows($rslt);
		$ringing_calls=0;
		if ($active_calls>0) 
			{
			while ($row=mysqli_fetch_row($rslt)) 
				{
				if (!preg_match("/LIVE|CLOSER/i",$row[0])) 
					{$ringing_calls++;}
				}
			}

		$active_stmt="SELECT active from vicidial_users $whereLOGadmin_viewable_groupsSQL";
		if ($DB) {echo "|$active_stmt|\n";}
		$active_rslt=mysql_to_mysqli($active_stmt, $link);
		while ($active_row=mysqli_fetch_array($active_rslt)) 
			{
			$users[$active_row["active"]]++;
			}

		$active_stmt="SELECT active from vicidial_campaigns $whereLOGallowed_campaignsSQL";
		if ($DB) {echo "|$active_stmt|\n";}
		$active_rslt=mysql_to_mysqli($active_stmt, $link);
		while ($active_row=mysqli_fetch_array($active_rslt)) 
			{
			$campaigns[$active_row["active"]]++;
			}

		$active_stmt="SELECT active from vicidial_lists $whereLOGallowed_campaignsSQL";
		if ($DB) {echo "|$active_stmt|\n";}
		$active_rslt=mysql_to_mysqli($active_stmt, $link);
		while ($active_row=mysqli_fetch_array($active_rslt)) 
			{
			$lists[$active_row["active"]]++;
			}

		$active_stmt="SELECT did_active from vicidial_inbound_dids $whereLOGadmin_viewable_groupsSQL";
		if ($DB) {echo "|$active_stmt|\n";}
		$active_rslt=mysql_to_mysqli($active_stmt, $link);
		while ($active_row=mysqli_fetch_array($active_rslt)) 
			{
			$dids[$active_row["did_active"]]++;
			}

		$active_stmt="SELECT active from vicidial_inbound_groups $whereLOGadmin_viewable_groupsSQL";
		if ($DB) {echo "|$active_stmt|\n";}
		$active_rslt=mysql_to_mysqli($active_stmt, $link);
		while ($active_row=mysqli_fetch_array($active_rslt)) 
			{
			$ingroups[$active_row["active"]]++;
			}

		$stmt="SELECT extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents $whereLOGallowed_campaignsSQL";
		if ($DB) {echo "|$stmt|\n";}
		$rslt=mysql_to_mysqli($stmt, $link);
		$agent_incall=0; $agent_total=0;
		while($row=mysqli_fetch_array($rslt)) 
			{
			$status=$row[3];
			$agent_total++;
			if ( (preg_match("/INCALL/i",$status)) or (preg_match("/QUEUE/i",$status)) ) {$agent_incall++; }
			}
		if (preg_match("/MXAG/",$SShosted_settings))
			{
			$vla_set = $SShosted_settings;
			$vla_set = preg_replace("/.*MXAG|_BUILD_|DRA|_MXCS\d+|_MXTR\d+| /",'',$vla_set);
			$vla_set = preg_replace('/[^0-9]/','',$vla_set);
			if (strlen($vla_set)>0)
				{
				$AAf=''; $AAb='';
				if ($agent_total >= $vla_set)
					{$AAf='<font color=red>'; $AAb='<font>';}
				$agent_total = "$AAf$agent_total / $vla_set$AAb";
				}
			}

		$section_width=700;
		echo "<BR><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<center>";
		echo "<TABLE width=$section_width cellpadding=6 cellspacing=0>\n";
		echo "<tr"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='realtime_report.php?report_display_type=HTML';\"";} echo ">";
		echo "<td align='center' valign='middle' bgcolor='#$SSmenu_background' rowspan=2><a href=\"realtime_report.php?report_display_type=HTML\"><img src=\"images/icon_users.png\" width=42 height=42 border=0></a></td>";
		echo "<td align='center' valign='middle' bgcolor='#$SSmenu_background'><font style=\"font-family:HELVETICA;font-size:11;color:white;font-weight:bold;\">"._QXZ("Agents Logged In")."</font></td>";
		echo "<td width=10 rowspan=2> &nbsp; </td>";
		echo "<td align='center' valign='middle' bgcolor='#$SSmenu_background' rowspan=2><a href=\"realtime_report.php?report_display_type=HTML\"><img src=\"images/icon_agentsincalls.png\" width=42 height=42 border=0></a></td>";
		echo "<td align='center' valign='middle' bgcolor='#$SSmenu_background'><font style=\"font-family:HELVETICA;font-size:11;color:white;font-weight:bold;\">"._QXZ("Agents In Calls")."</font></td>";
		echo "<td width=10 rowspan=2> &nbsp; </td>";
		echo "<td align='center' valign='middle' bgcolor='#$SSmenu_background' rowspan=2><a href=\"realtime_report.php?report_display_type=HTML\"><img src=\"images/icon_calls.png\" width=42 height=42 border=0></a></td>";
		echo "<td align='center' valign='middle' bgcolor='#$SSmenu_background'><font style=\"font-family:HELVETICA;font-size:11;color:white;font-weight:bold;\">"._QXZ("Active Calls")."</font></td>";
		echo "<td width=10 rowspan=2> &nbsp; </td>";
		echo "<td align='center' valign='middle' bgcolor='#$SSmenu_background' rowspan=2><a href=\"realtime_report.php?report_display_type=HTML\"><img src=\"images/icon_ringing.png\" width=42 height=42 border=0></a></td>";
		echo "<td align='center' valign='middle' bgcolor='#$SSmenu_background'><font style=\"font-family:HELVETICA;font-size:11;color:white;font-weight:bold;\">"._QXZ("Calls Ringing")."</font></td>";
		echo "</tr>";
		echo "<tr"; if ($SSadmin_row_click > 0) {echo " onclick=\"window.document.location='realtime_report.php?report_display_type=HTML';\"";} echo ">";
		echo "<td align='center' valign='middle' bgcolor='#$SSmenu_background'><font style=\"font-family:HELVETICA;font-size:18;color:white;font-weight:bold;\">$agent_total</font></td>";
		echo "<td align='center' valign='middle' bgcolor='#$SSmenu_background'><font style=\"font-family:HELVETICA;font-size:18;color:white;font-weight:bold;\">$agent_incall</font></td>";
		echo "<td align='center' valign='middle' bgcolor='#$SSmenu_background'><font style=\"font-family:HELVETICA;font-size:18;color:white;font-weight:bold;\">$agent_incall</font></td>";
		echo "<td align='center' valign='middle' bgcolor='#$SSmenu_background'><font style=\"font-family:HELVETICA;font-size:18;color:white;font-weight:bold;\">$ringing_calls</font></td>";
		echo "</tr>";
		echo "</TABLE>";
		echo "<br><br>";


		echo "<TABLE width=$section_width cellspacing=2>\n";
		echo "<tr>";
		echo "<td align='left' colspan='4'><font style=\"font-family:HELVETICA;font-size:16;color:black;font-weight:bold;\">"._QXZ("System Summary").":</font></td>";
		echo "</tr>";

		echo "<tr bgcolor=black>";
		echo "<td align='center'><font style=\"font-family:HELVETICA;font-size:14;color:white;font-weight:bold;\">&nbsp; "._QXZ("Records")." &nbsp;</font></td>";
		echo "<td align='center'><font style=\"font-family:HELVETICA;font-size:14;color:white;font-weight:bold;\">&nbsp; "._QXZ("Active")." &nbsp;</font></td>";
		echo "<td align='center'><font style=\"font-family:HELVETICA;font-size:14;color:white;font-weight:bold;\">&nbsp; "._QXZ("Inactive")." &nbsp;</font></td>";
		echo "<td align='center'><font style=\"font-family:HELVETICA;font-size:14;color:white;font-weight:bold;\">&nbsp; "._QXZ("Total")." &nbsp;</font></td>";
		echo "</tr>";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href='$PHP_SELF?ADD=0A' STYLE=\"text-decoration:none;\"><font color=black>"._QXZ("Users").": </a></td><td align=center><b>".($users["Y"]+0)."</b></td><td align=center><b>".($users["N"]+0)."</b></td><td align=center><b>".($users["Y"]+$users["N"]+0)."</b></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href='$PHP_SELF?ADD=10' STYLE=\"text-decoration:none;\"><font color=black>"._QXZ("Campaigns").": </a></td><td align=center><b>".($campaigns["Y"]+0)."</b></td><td align=center><b>".($campaigns["N"]+0)."</b></td><td align=center><b>".($campaigns["Y"]+$campaigns["N"]+0)."</b></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href='$PHP_SELF?ADD=100' STYLE=\"text-decoration:none;\"><font color=black>"._QXZ("Lists").": </a></td><td align=center><b>".($lists["Y"]+0)."</b></td><td align=center><b>".($lists["N"]+0)."</b></td><td align=center><b>".($lists["Y"]+$lists["N"]+0)."</b></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href='$PHP_SELF?ADD=1000' STYLE=\"text-decoration:none;\"><font color=black>"._QXZ("In-Groups").": </a></td><td align=center><b>".($ingroups["Y"]+0)."</b></td><td align=center><b>".($ingroups["N"]+0)."</b></td><td align=center><b>".($ingroups["Y"]+$ingroups["N"]+0)."</b></td></tr>\n";
		echo "<tr bgcolor=#$SSstd_row4_background><td align=right><a href='$PHP_SELF?ADD=1300' STYLE=\"text-decoration:none;\"><font color=black>"._QXZ("DIDs").": </a></td><td align=center><b>".($dids["Y"]+0)."</b></td><td align=center><b>".($dids["N"]+0)."</b></td><td align=center><b>".($dids["Y"]+$dids["N"]+0)."</b></td></tr>\n";
	
		// New voicemailbox code
		$stmt="(SELECT voicemail_id,count(*),messages,old_messages,'vm','vm' from vicidial_voicemail where on_login_report='Y' $LOGadmin_viewable_groupsSQL group by voicemail_id) UNION (SELECT voicemail_id,count(*),messages,old_messages,extension,server_ip from phones where on_login_report='Y' $LOGadmin_viewable_groupsSQL group by voicemail_id) order by voicemail_id;";
		if ($DB) {echo "|$stmt|\n";}
		$rslt=mysql_to_mysqli($stmt, $link);
		$vm_rows=mysqli_num_rows($rslt);
		if ($vm_rows>0) 
			{
			echo "<tr>";
			echo "<td align='left' colspan='4'>&nbsp;</td>";  # Padding
			echo "</tr>";
			echo "<tr bgcolor=black>";
			echo "<td  align='center'><font style=\"font-family:HELVETICA;font-size:14;color:white;font-weight:bold;\">&nbsp; "._QXZ("Voicemail Box")." &nbsp;</font></td>\n";
			echo "<td  align='center'><font style=\"font-family:HELVETICA;font-size:14;color:white;font-weight:bold;\">&nbsp; "._QXZ("New")." &nbsp;</font></td>\n";
			echo "<td  align='center'><font style=\"font-family:HELVETICA;font-size:14;color:white;font-weight:bold;\">&nbsp; "._QXZ("Old")." &nbsp;</font></td>\n";
			echo "<td  align='center'><font style=\"font-family:HELVETICA;font-size:14;color:white;font-weight:bold;\">&nbsp; "._QXZ("Total")." &nbsp;</font></td>\n";
			echo "</tr>\n";
	
			while($row=mysqli_fetch_array($rslt)) 
				{
				echo "<tr bgcolor='#$SSstd_row2_background'>\n";
				if ($row[4] == 'vm')
					{
					echo "<td align='right'><a href='$PHP_SELF?ADD=371111111111&voicemail_id=$row[0]' STYLE=\"text-decoration:none;\"><font color=black>$row[0]:</a></font></td>\n";
					}
				else
					{
					echo "<td align='right'><a href='$PHP_SELF?ADD=31111111111&extension=$row[4]&server_ip=$row[5]' STYLE=\"text-decoration:none;\"><font color=black>$row[0]:</a></font></td>\n";
					}
				echo "<td align='center'>$row[2]</font></td>\n";
				echo "<td align='center'>$row[3]</font></td>\n";
				echo "<td align='center'>".($row[2]+$row[3])."</font></td>\n";
				echo "</tr>\n";
				}
			}
		// End new voicemail box code

		if ($SSqc_features_active>0) 
			{
			echo "<tr>";
			echo "<td align='left' colspan='4'>&nbsp;</td>";  # Padding
			echo "</tr>";
			echo "<tr>";
			echo "<td align='left' colspan='4'><font style=\"font-family:HELVETICA;font-size:16;color:black;font-weight:bold;\">"._QXZ("Quality Control stats").":</font></td>";
			echo "</tr>";

			echo "<tr bgcolor=black>";
			echo "<td align='center'><font style=\"font-family:HELVETICA;font-size:14;color:white;font-weight:bold;\"><B>&nbsp; "._QXZ("Campaign")."</font></td>";
			echo "<td align='center'><font style=\"font-family:HELVETICA;font-size:14;color:white;font-weight:bold;\"><B>&nbsp; "._QXZ("Unclaimed Calls")."</font></td>";
			echo "<td align='center'><font style=\"font-family:HELVETICA;font-size:14;color:white;font-weight:bold;\"><B>&nbsp; "._QXZ("In Review")."</font></td>";
			echo "<td align='center'><font style=\"font-family:HELVETICA;font-size:14;color:white;font-weight:bold;\"><B>&nbsp; "._QXZ("Finished today")."</font></td>";
			echo "</tr>";

			# $stmt="SELECT campaign_id, qc_statuses from vicidial_campaigns where active = 'Y' and qc_enabled='Y' $LOGqc_allowed_campaignsSQL order by campaign_id";
			$stmt="SELECT campaign_id,campaign_name,qc_statuses_id from vicidial_campaigns where active = 'Y' and qc_statuses_id!='' and qc_scorecard_id!='' $LOGqc_allowed_campaignsSQL order by campaign_name";

		if ($DB) {echo "|$stmt|\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			$vicidialconf_to_print = mysqli_num_rows($rslt);
			if ($vicidialconf_to_print > 0) 
				{
				while ($row=mysqli_fetch_array($rslt)) 
					{
					$campaign_id=$row[0];

					$qc_status_list=array();
					$qc_status_container_stmt="select container_entry from vicidial_settings_containers where container_id='$row[2]'";
					$qc_status_container_rslt=mysql_to_mysqli($qc_status_container_stmt, $link);
					while ($qcsc_row=mysqli_fetch_row($qc_status_container_rslt))
						{
						$container_text=preg_split('/\r|\n/', $qcsc_row[0]);
						for ($q=0; $q<count($container_text); $q++)
							{
							$line=trim($container_text[$q]);
							if (!preg_match('/^[\#|\;]/', $line) && strlen($line)>0)
								{
								$qc_status_list=preg_split('/,/', $line); 
								break;
								}
							}
						}

					$total_qc_count=0;
					$qc_ct_stmt="select count(*) From vicidial_agent_log where campaign_id='$campaign_id' and status in ('".implode("','", $qc_status_list)."') and event_time+INTERVAL (pause_sec+wait_sec) SECOND>=now()-INTERVAL $SSqc_expire_days DAY"; 
					if ($DB) {echo "|$qc_ct_stmt|<BR>\n";}
					$qc_ct_rslt=mysql_to_mysqli($qc_ct_stmt, $link);
					$qc_ct_row=mysqli_fetch_row($qc_ct_rslt);
					$total_qc_count=$qc_ct_row[0];
				
					$qc_grabbed_stmt="select count(*) From quality_control_queue where campaign_id='$campaign_id' and call_date>=now()-INTERVAL $SSqc_expire_days DAY and qc_status='CLAIMED'";
					if ($DB) {echo "|$qc_grabbed_stmt|<BR>\n";}
					$qc_grabbed_rslt=mysql_to_mysqli($qc_grabbed_stmt, $link);
					$qc_grabbed_row=mysqli_fetch_row($qc_grabbed_rslt);
					$total_inreview_count=$qc_grabbed_row[0];

					$qc_finished_stmt="select count(*), sum(if(call_date>=date(now()),1,0)) as finished_today From quality_control_queue where campaign_id='$campaign_id' and call_date>=now()-INTERVAL $SSqc_expire_days DAY and qc_status='FINISHED'";
					if ($DB) {echo "|$qc_finished_stmt|<BR>\n";}
					$qc_finished_rslt=mysql_to_mysqli($qc_finished_stmt, $link);
					$qc_finished_row=mysqli_fetch_row($qc_finished_rslt);
					$total_finish_count=$qc_finished_row[0];
					$today_finish_count=$qc_finished_row[1];

					echo "<tr bgcolor='#$SSstd_row2_background'>";
				#	echo "<td align='left'><font size=1>".$row["campaign_id"]."</font></td>";
					echo "<td align='right'><font style=\"font-family:HELVETICA;font-size:14;\">".$campaign_id.":</font></td>";
					echo "<td align='center'><font style=\"font-family:HELVETICA;font-size:14;\">".($total_qc_count-$total_inreview_count-$total_finish_count+0)."</font></td>";
					echo "<td align='center'><font style=\"font-family:HELVETICA;font-size:14;\">".($total_inreview_count+0)."</font></td>";
					echo "<td align='center'><font style=\"font-family:HELVETICA;font-size:14;\">".($today_finish_count+0)."</font></td>";
					echo "</tr>";
					}
				} 
			else 
				{
				echo "<tr bgcolor='#$SSstd_row2_background'>";
				echo "<td align='center' colspan='4'><font size=1>*** "._QXZ("NO ACTIVITY FOR")." $today ***</font></td>";
				echo "</tr>";
				}


			}

			echo "</TABLE></center>\n";

			echo "<BR>\n";

		$today=date("Y-m-d");
		$yesterday=date("Y-m-d", mktime(0,0,0,date("m"),date("d")-1,date("Y")));
		$thirtydays=date("Y-m-d", mktime(0,0,0,date("m"),date("d")-29,date("Y")));

		$total_calls=0;
		$total_inbound=0;
		$total_outbound=0;
		$stmt="SELECT stats_type,sum(total_calls) from vicidial_daily_max_stats where campaign_id!='' and stats_flag='OPEN' and stats_date='$today' $LOGallowed_campaignsSQL group by stats_type;";
		if ($DB) {echo "|$stmt|\n";}
		$rslt=mysql_to_mysqli($stmt, $link);
		$rows_to_print = mysqli_num_rows($rslt);
		if ($rows_to_print > 0) 
			{
			while ($rowx=mysqli_fetch_row($rslt)) 
				{
				$total_calls += $rowx[1];
				if (preg_match('/INGROUP/', $rowx[0])) {$total_inbound+=$rowx[1];}
				if (preg_match('/CAMPAIGN/', $rowx[0])) {$total_outbound+=$rowx[1];}
				}
			}

		$stmt="SELECT * from vicidial_daily_max_stats where stats_date='$today' and stats_flag='OPEN' and stats_type='TOTAL' $LOGallowed_campaignsSQL order by stats_date, campaign_id asc";
		if ($DB) {echo "|$stmt|\n";}
		$rslt=mysql_to_mysqli($stmt, $link);
		echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
		echo "<tr>";
		echo "<td align='left' colspan='3'><font style=\"font-family:HELVETICA;font-size:12;color:black;font-weight:bold;\">"._QXZ("Total Stats for Today").":</font></td>";
		echo "<td align='right'><font size=1><a href='$PHP_SELF?query_date=$thirtydays&end_date=$today&max_system_stats_submit=ADJUST+DATE+RANGE&ADD=999992&stage=TOTAL'>["._QXZ("view max stats")."]</a></font></td>";
		echo "</tr>";
		echo "<tr bgcolor=black>";
		# echo "<td><font size=1 color=white align=left><B>CAMPAIGN ID</B></font></td>";
		echo "<td><font size=1 color=white><B>&nbsp; "._QXZ("Total Calls")." &nbsp;</B></font></td>";
		echo "<td><font size=1 color=white><B>&nbsp; "._QXZ("Total Inbound Calls")." &nbsp;</B></font></td>";
		echo "<td><font size=1 color=white><B>&nbsp; "._QXZ("Total Outbound Calls")." &nbsp;</B></font></td>";
		echo "<td><font size=1 color=white><B>&nbsp; "._QXZ("Maximum Agents")." &nbsp;</B></font></td>";

		if (mysqli_num_rows($rslt)>0) 
			{
			while ($row=mysqli_fetch_array($rslt)) 
				{
				echo "<tr bgcolor='#$SSstd_row2_background'>";
			#	echo "<td align='left'><font size=1>".$row["campaign_id"]."</font></td>";
				echo "<td align='center'><font size=1>".($total_calls+0)."</font></td>";
				echo "<td align='center'><font size=1>".($total_inbound+0)."</font></td>";
				echo "<td align='center'><font size=1>".($total_outbound+0)."</font></td>";
				echo "<td align='center'><font size=1>".($row["max_agents"]+0)."</font></td>";
				echo "</tr>";
				}
			} 
		else 
			{
			echo "<tr bgcolor='#$SSstd_row2_background'>";
			echo "<td align='center' colspan='4'><font size=1>*** "._QXZ("NO ACTIVITY FOR")." $today ***</font></td>";
			echo "</tr>";
			}
		echo "</TABLE></center>\n";

		$total_calls=0;
		$total_inbound=0;
		$total_outbound=0;
		$stmt="SELECT stats_type,sum(total_calls) from vicidial_daily_max_stats where campaign_id!='' and stats_flag='CLOSED' and stats_date='$yesterday' $LOGallowed_campaignsSQL group by stats_type;";
		if ($DB) {echo "|$stmt|\n";}
		$rslt=mysql_to_mysqli($stmt, $link);
		$rows_to_print = mysqli_num_rows($rslt);
		if ($rows_to_print > 0) 
			{
			while ($rowx=mysqli_fetch_row($rslt)) 
				{
				$total_calls += $rowx[1];
				if (preg_match('/INGROUP/', $rowx[0])) {$total_inbound+=$rowx[1];}
				if (preg_match('/CAMPAIGN/', $rowx[0])) {$total_outbound+=$rowx[1];}
				}
			}

		echo "<center><TABLE width=$section_width cellspacing=0 cellpadding=1>\n";
		echo "<tr>";
		echo "<td align='left' colspan='3'><font style=\"font-family:HELVETICA;font-size:12;color:black;font-weight:bold;\">"._QXZ("Total Stats for Yesterday").":</font></td>";
		echo "<td align='right'><font size=1><a href='$PHP_SELF?query_date=$thirtydays&end_date=$today&max_system_stats_submit=ADJUST+DATE+RANGE&ADD=999992&stage=TOTAL'>["._QXZ("view max stats")."]</a></font></td>";
		echo "</tr>";
		echo "<tr bgcolor=black>";
	#	echo "<td><font size=1 color=white align=left><B>CAMPAIGN ID</B></font></td>";
		echo "<td><font size=1 color=white><B>&nbsp; "._QXZ("Total Calls")." &nbsp;</B></font></td>";
		echo "<td><font size=1 color=white><B>&nbsp; "._QXZ("Total Inbound Calls")." &nbsp;</B></font></td>";
		echo "<td><font size=1 color=white><B>&nbsp; "._QXZ("Total Outbound Calls")." &nbsp;</B></font></td>";
		echo "<td><font size=1 color=white><B>&nbsp; "._QXZ("Maximum Agents")." &nbsp;</B></font></td>";

		$stmt="SELECT * from vicidial_daily_max_stats where stats_date='$yesterday' and stats_type='TOTAL' $LOGallowed_campaignsSQL order by stats_date, campaign_id asc";
		if ($DB) {echo "|$stmt|\n";}
		$rslt=mysql_to_mysqli($stmt, $link);
		if (mysqli_num_rows($rslt)>0) 
			{
			while ($row=mysqli_fetch_array($rslt)) 
				{
				echo "<tr bgcolor='#$SSstd_row2_background'>";
				#echo "<td align='left'><font size=1>".$row["campaign_id"]."</font></td>";
				echo "<td align='center'><font size=1>".($row["total_calls"]+0)." / ".($total_calls+0)."</font></td>";
				echo "<td align='center'><font size=1>".($total_inbound+0)."</font></td>";
				echo "<td align='center'><font size=1>".($total_outbound+0)."</font></td>";
				echo "<td align='center'><font size=1>".($row["max_agents"]+0)."</font></td>";
				echo "</tr>";
				}
			} 
		else 
			{
			echo "<tr bgcolor='#$SSstd_row2_background'>";
			echo "<td align='center' colspan='4'><font size=1>*** "._QXZ("NO ACTIVITY FOR")." $today ***</font></td>";
			echo "</tr>";
			}

		echo "</FONT><BR><BR>";
		}
	else
		{
		$section_width=640;
		echo "<BR><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
		echo "<center><TABLE width=$section_width cellspacing=2>\n";
		echo "<tr>";
		echo "<td align='left' colspan='4'>"._QXZ("Welcome")."</td>";
		echo "</tr>";

		echo "</FONT><BR><BR>";
		}
	}

##### If report run, update the time in the vicidial_report_log table #####
if ( ($ADD==999993) or ($ADD==999992) or ($ADD==730000000000000) or ($ADD==830000000000000) )
	{
	$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);
	}


######################
# ADD=999991 display server version info
######################
if ($ADD==999991)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	echo "<br><b> "._QXZ("Administration: Server Version Information")."</B><BR><BR>\n";

	if ($LOGview_reports==1)
		{
		if ($reports_only_user < 1)
			{
			$server_id = $MT;
			$server_description = $MT;
			$server_ip = $MT;
			$active = $MT;
			$sysload = $MT;
			$channels_total = $MT;
			$cpu_idle_percent = $MT;
			$disk_usage = $MT;

			echo "<PRE><TABLE BORDER=1 CELLPADDING=4 cellspacing=0>\n";

			echo "<TR><TD>"._QXZ("SERVER")."</TD>";
			echo "<TD>"._QXZ("DESCRIPTION")."</TD><TD>"._QXZ("IP")."</TD><TD>"._QXZ("ACT")."</TD><TD>"._QXZ("LOAD")."</TD><TD>"._QXZ("CHAN")."</TD><TD>"._QXZ("DISK")."</TD><TD>"._QXZ("TIME")."</TD><TD>"._QXZ("VER")."</TD></TR>\n";

			$stmt="SELECT server_id,server_description,server_ip,active,sysload,channels_total,cpu_idle_percent,disk_usage from servers order by server_id;";
			$rslt=mysql_to_mysqli($stmt, $link);
			if ($DB) {echo "$stmt\n";}
			$servers_to_print = mysqli_num_rows($rslt);
			$i=0;
			while ($i < $servers_to_print)
				{
				$row=mysqli_fetch_row($rslt);
				$server_id[$i] =			$row[0];
				$server_description[$i] =	$row[1];
				$server_ip[$i] =			$row[2];
				$active[$i] =				$row[3];
				$sysload[$i] =				$row[4];
				$channels_total[$i] =		$row[5];
				$cpu_idle_percent[$i] =		$row[6];
				$disk_usage[$i] =			$row[7];
				$i++;
				}

			$o=0;
			while ($servers_to_print > $o)
				{
				$cpu = (100 - $cpu_idle_percent[$o]);
				$disk = '';
				$disk_ary = explode('|',$disk_usage[$o]);
				$disk_ary_ct = count($disk_ary);
				$k=0;
				while ($k < $disk_ary_ct)
					{
					$disk_ary[$k] = preg_replace("/^\d* /","",$disk_ary[$k]);
					if ($k<1) {$disk = "$disk_ary[$k]";}
					else
						{
						if ($disk_ary[$k] > $disk) {$disk = "$disk_ary[$k]";}
						}
					$k++;
					}
				$disk = "$disk%";
				echo "<TR>\n";
				echo "<TD><a href=\"$PHP_SELF?ADD=311111111111&server_id=$server_id[$o]\">$server_id[$o]</a></TD>\n";
				echo "<TD>$server_description[$o]</TD>\n";
				echo "<TD>$server_ip[$o]</TD>\n";
				echo "<TD>$active[$o]</TD>\n";
				echo "<TD>$sysload[$o] - $cpu%</TD>\n";
				echo "<TD>$channels_total[$o]</TD>\n";
				echo "<TD ALIGN=RIGHT>$disk</TD>\n";

				$s_time='&nbsp;';
				$s_ver='&nbsp;';
				$s_info_print=_QXZ("no svn information");
				$stmt="SELECT last_update from server_updater where server_ip='$server_ip[$o]';";
				$rslt=mysql_to_mysqli($stmt, $link);
				if ($DB) {echo "$stmt\n";}
				$servertime_to_print = mysqli_num_rows($rslt);
				if ($servertime_to_print)
					{
					$row=mysqli_fetch_row($rslt);
					$s_time = $row[0];
					}
				$stmt="SELECT svn_revision,svn_info from servers where server_ip='$server_ip[$o]';";
				$rslt=mysql_to_mysqli($stmt, $link);
				if ($DB) {echo "$stmt\n";}
				$serverver_to_print = mysqli_num_rows($rslt);
				if ($serverver_to_print)
					{
					$row=mysqli_fetch_row($rslt);
					$s_ver = $row[0];
					$s_info = $row[1];
					$s_info_print = preg_replace("/\n/",'<BR>',$s_info);
					}
				if (strlen($s_info_print) < 1) {$s_info_print='no svn information';}
				echo "<TD NOWRAP>$s_time</TD><TD NOWRAP>$s_ver</TD></TR>";
				echo "<TR><TD NOWRAP>&nbsp;</TD><TD COLSPAN=8 NOWRAP>$s_info_print</TD>";

				echo "</TR>\n";
				$o++;
				}
			echo "</TABLE>\n";
			}
		}
	else
		{
		echo _QXZ("You do not have permission to view this page")."\n";
		exit;
		}
	}
##### END server version info #####


######################
# ADD=999989 - user change language page
######################
if ($ADD==999989)
	{
	$show_form=1;
	if ( ($stage=='SUBMIT') or ($stage==_QXZ("SUBMIT")) )
		{
		if ( (mb_strlen($selected_language,'utf-8') > 100) or (strlen($selected_language) < 1) or (strlen($PHP_AUTH_USER)<2) )
			{echo _QXZ("Language has not been changed, please try again")." |1|" . strlen($selected_language);}
		else
			{
			$stmt="SELECT count(*) from vicidial_languages where language_id='$selected_language' and active='Y' $LOGadmin_viewable_groupsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			if ($DB) {echo "$stmt\n";}
			$lang_to_print = mysqli_num_rows($rslt);
			if ( ($lang_to_print < 1) and ($selected_language != 'default English') )
				{echo _QXZ("Language is not valid, please try again")." |2|$selected_language";}
			else
				{
				$row=mysqli_fetch_row($rslt);
				if ( ($row[0] < 1) and ($selected_language != 'default English') )
					{echo _QXZ("Language is not valid, please try again")." |3|$selected_language";}
				else
					{
					$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and ( (user_choose_language='1') or (user_level > 6) );";
					$rslt=mysql_to_mysqli($stmt, $link);
					if ($DB) {echo "$stmt\n";}
					$user_to_print = mysqli_num_rows($rslt);
					if ($user_to_print < 1)
						{echo _QXZ("You are not allowed to change your language")." |4|$PHP_AUTH_USER";}
					else
						{
						$row=mysqli_fetch_row($rslt);
						if ($row[0] < 1)
							{echo _QXZ("You are not allowed to change your language")." |5|$PHP_AUTH_USER";}
						else
							{
							$show_form=0;
							$VUselected_language = $selected_language;

							$stmt="UPDATE vicidial_users SET selected_language='$selected_language' where user='$PHP_AUTH_USER' and ( (user_choose_language='1') or (user_level > 6) );";
							$rslt=mysql_to_mysqli($stmt, $link);

							### LOG INSERTION Admin Log Table ###
							$SQL_log = "$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='$PHP_AUTH_USER', event_code='USER CHANGE LANGUAGE', event_sql=\"$SQL_log\", event_notes='';";
							if ($DB) {echo "|$stmt|\n";}
							$rslt=mysql_to_mysqli($stmt, $link);

							echo _QXZ("Language has been updated, you may now continue").": $selected_language\n";
							}
						}
					}
				}
			}
		}
	if ($show_form > 0)
		{
		echo "<TABLE><TR><TD>\n";
		echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

		echo "<br>"._QXZ("CHANGE LANGUAGE")."<form action=$PHP_SELF method=POST name=userform id=userform>\n";
		echo "<input type=hidden name=ADD value=999989>\n";
		echo "<input type=hidden name=DB value=\"$DB\">\n";
		echo "<input type=hidden name=stage value=SUBMIT>\n";
		echo "<input type=hidden name=user value=\"$PHP_AUTH_USER\">\n";
		echo "<center><TABLE width=$section_width cellspacing=3>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("Current Language").": </td><td align=left style=\"display:table-cell; vertical-align:middle;\">$VUselected_language</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=right>"._QXZ("New Language").": </td><td align=left style=\"display:table-cell; vertical-align:middle;\">";

		$stmt="SELECT language_id,language_description from vicidial_languages where active='Y' $LOGadmin_viewable_groupsSQL order by language_id";
		$rslt=mysql_to_mysqli($stmt, $link);
		$langs_to_print = mysqli_num_rows($rslt);

		echo "<select size=1 name=selected_language id=selected_language>\n";
		echo "<option value=\"\">-- "._QXZ("PLEASE SELECT A LANGUAGE")." --</option>\n";

		$o=0;
		$langSELECTED=0;
		while ($langs_to_print > $o) 
			{
			$rowx=mysqli_fetch_row($rslt);
			echo "<option value=\"$rowx[0]\"";
			if ($VUselected_language == "$rowx[0]") {echo " SELECTED"; $langSELECTED++;}
			echo ">$rowx[0] - $rowx[1]</option>\n";
			$o++;
			}
		echo "<option value=\"default English\"";
		if ($langSELECTED < 1) {echo " SELECTED"; $langSELECTED++;}
		echo ">default English</option>\n";
		echo "</select>\n";
		echo "</td></tr>\n";

		echo "<tr bgcolor=#$SSstd_row4_background><td align=center colspan=2><input style='background-color:#$SSbutton_color' type=submit name=SUBMIT value='"._QXZ("SUBMIT")."'></td></tr>\n";
		echo "</TABLE></center></form>\n";
		}
	}
##### END user change language page #####


######################
# ADD=999988 - available timezones display page
######################
if ($ADD==999988)
	{
	$orig_zone = date_default_timezone_get();

	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	echo "<br>"._QXZ("AVAILABLE TIMEZONES")."\n";
	echo "<center><TABLE width=$section_width cellspacing=3>\n";
	echo "<tr bgcolor=#$SSstd_row3_background>\n";
	echo "<td align=center><B>"._QXZ("Country")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("Zone")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("DST")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("Description")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("Offset")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("Current Time")."</B></td>\n";
	echo "</tr>\n";

	$stmt="select count(*),tz_code,GMT_offset,country,country_name,geographic_description,dst,php_tz from vicidial_phone_codes p,vicidial_country_iso_tld i where i.iso3=p.country and php_tz!='' group by country,tz_code,GMT_offset,dst,php_tz order by country,CAST(GMT_offset as SIGNED INTEGER) desc,tz_code,dst,php_tz;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$zones_to_print = mysqli_num_rows($rslt);
	$o=0;
	$row_color=0;   $last_country='';
	while ($zones_to_print > $o) 
		{
		$rowx=mysqli_fetch_row($rslt);
		date_default_timezone_set("$rowx[7]");
		$tz_time = date("Y-m-d H:i:s");

		if ($rowx[3] != "$last_country") {$row_color++;   $last_country = $rowx[3];}
		if (preg_match('/1$|3$|5$|7$|9$/i', $row_color))
			{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
		else
			{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}
		echo "<tr $bgcolor>\n";
		echo "<td align=center><font size=1>$rowx[3]</font></td>\n";
		echo "<td align=center><font size=1>$rowx[1]</font></td>\n";
		echo "<td align=center><font size=1>$rowx[6]</font></td>\n";
		echo "<td align=left><font size=1> &nbsp; $rowx[4] - $rowx[5]</font></td>\n";
		echo "<td align=center><font size=1>$rowx[2]</font></td>\n";
		echo "<td align=left><font size=1> &nbsp; $tz_time</font></td>\n";
		echo "</tr>\n";
		$o++;
		}
	echo "</TABLE></center></form>\n";
	date_default_timezone_set($orig_zone);
	}
# JCJ - date_default_timezone_set($orig_zone);
##### END available timezones display page #####


######################
# ADD=999987 - phone_codes display page
######################
if ($ADD==999987)
	{
	$orig_zone = date_default_timezone_get();

	$PCfilterSQL='';
	$PCfilterTEXT='';
	if ( (strlen($stage) > 2) and (preg_match("/-/",$stage)) )
		{
		$PSstage = explode('-',$stage);
		$PCfilterSQL = "and country_code='$PSstage[0]' and state='$PSstage[1]'";
		$PCfilterTEXT = " ("._QXZ("Country Code").": $PSstage[0] &nbsp; "._QXZ("State").": $PSstage[1]) &nbsp; <a href=\"$PHP_SELF?ADD=999987\">"._QXZ("reset")."</a> ";
		}
	
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	# country_code | country | areacode | state | GMT_offset | DST  | DST_range | geographic_description | tz_code | php_tz
	$stmt="SELECT count(*),tz_code,GMT_offset,country_code,country,country_name,areacode,state,geographic_description,dst,php_tz FROM vicidial_phone_codes p,vicidial_country_iso_tld i where i.iso3=p.country and php_tz!='' $PCfilterSQL group by country_code,areacode,state,tz_code,GMT_offset,dst,php_tz order by country_code,areacode,CAST(GMT_offset as SIGNED INTEGER) desc,tz_code,dst,php_tz;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$zones_to_print = mysqli_num_rows($rslt);

	echo "<br><b>"._QXZ("PHONE CODES")."</b><br>\n";
	echo "<br><font size=1>$zones_to_print "._QXZ("RECORDS")." &nbsp; $PCfilterTEXT</font><br>\n";
	echo "<center><TABLE width=1100 cellspacing=3>\n";
	echo "<tr bgcolor=#$SSstd_row3_background>\n";
	echo "<td align=center><B>"._QXZ("Code")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("Country")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("AreaCode")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("State")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("DST")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("Description")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("Offset")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("TZ Code")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("Current Time")."</B></td>\n";
	echo "</tr>\n";

	$o=0;
	$row_color=0;   $last_country='';
	while ($zones_to_print > $o) 
		{
		$rowx=mysqli_fetch_row($rslt);
		date_default_timezone_set($rowx[10]);
		$tz_time = date("Y-m-d H:i:s");

		if ($rowx[3] != "$last_country") {$row_color++;   $last_country = $rowx[3];}
		if (preg_match('/1$|3$|5$|7$|9$/i', $row_color))
			{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
		else
			{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}
		echo "<tr $bgcolor>\n";

		echo "<td align=center><font size=1>$rowx[3]</font></td>\n";
		echo "<td align=center><font size=1>$rowx[4] - $rowx[5]</font></td>\n";
		echo "<td align=center><font size=1>$rowx[6]</font></td>\n";
		echo "<td align=center><font size=1><a href=\"$PHP_SELF?ADD=999987&stage=$rowx[3]-$rowx[7]\"><font color=black>$rowx[7]</font></a></font></td>\n";
		echo "<td align=center><font size=1>$rowx[9]</font></td>\n";
		echo "<td align=left><font size=1> &nbsp; $rowx[8] - $rowx[5]</font></td>\n";
		echo "<td align=center><font size=1>$rowx[2]</font></td>\n";
		echo "<td align=center><font size=1>$rowx[1]</font></td>\n";
		echo "<td align=left><font size=1> &nbsp; $tz_time</font></td>\n";
		echo "</tr>\n";
		$o++;
		}
	echo "</TABLE></center></form>\n";
	date_default_timezone_set($orig_zone);
	}
#JCJ - date_default_timezone_set($orig_zone);
##### END available phone_codes display page #####


######################
# ADD=999986 - postal_codes display page
######################
if ($ADD==999986)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$limitSQL='';
	$next_prev_HTML='';
	$PCentries_per_page='2000';

	$stmt="SELECT count(*) from vicidial_postal_codes;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$row=mysqli_fetch_row($rslt);
	$pc_count = $row[0];

	if ( ($pc_count > $PCentries_per_page) and ($status != 'display_all') )
		{
		if (strlen($start_count) < 1) {$start_count=0;}
		$next_count = ($start_count + $PCentries_per_page);
		$nextnext_count = ($next_count + $PCentries_per_page);
		if ($next_count > $pc_count) 
			{$next_count = $pc_count;}
		else
			{
			if ($nextnext_count > $pc_count) 
				{
				$next_temp = ($pc_count - $next_count);
				$nextHTML = "<a href=\"$PHP_SELF?ADD=999986&start_count=$next_count&stage=$stage\">"._QXZ("NEXT")." $next_temp</a> &nbsp; ";
				}
			else
				{
				$nextHTML = "<a href=\"$PHP_SELF?ADD=999986&start_count=$next_count&stage=$stage\">"._QXZ("NEXT")." $PCentries_per_page</a> &nbsp; ";
				}
			}
		$next_prev_HTML .= _QXZ("RECORDS")." $start_count - $next_count &nbsp; <font size=1>"._QXZ("of")." $pc_count</font> &nbsp; &nbsp; ";
		$limitSQL="limit $PCentries_per_page";
		if ($start_count > 0)
			{
			$prev_count = ($start_count - $PCentries_per_page);
			$limitSQL="limit $start_count,$PCentries_per_page";
			$next_prev_HTML .= "<a href=\"$PHP_SELF?ADD=999986&start_count=$prev_count&stage=$stage\">"._QXZ("PREVIOUS")." $PCentries_per_page</a> &nbsp; ";
			}
		$next_prev_HTML .= $nextHTML;
		$next_prev_HTML .= " &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; </b><a href=\"$PHP_SELF?ADD=999986&status=display_all&stage=$stage\"><font size=1 color=black>"._QXZ("show all postal codes")."</font></a><b> &nbsp; ";
		}

	echo "<br><b>"._QXZ("POSTAL CODES")."</b><br>\n";
	echo "<br>$next_prev_HTML\n";
	echo "<center><TABLE width=$section_width cellspacing=3>\n";
	echo "<tr bgcolor=#$SSstd_row3_background>\n";
	echo "<td align=center><B>"._QXZ("Country")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("Postal Code")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("State")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("DST")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("Offset")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("Current Time")."</B></td>\n";
	echo "</tr>\n";

	# postal_code | state | GMT_offset | DST  | DST_range | country | country_code
	$stmt="SELECT count(*),GMT_offset,country,country_name,postal_code,state,dst FROM vicidial_postal_codes p,vicidial_country_iso_tld i where i.iso3=p.country group by country_code,postal_code,state,GMT_offset,dst order by country_code,postal_code,CAST(GMT_offset as SIGNED INTEGER) desc,dst $limitSQL;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$zones_to_print = mysqli_num_rows($rslt);
	$o=0;
	$row_color=0;   $last_country='';
	while ($zones_to_print > $o) 
		{
		$rowx=mysqli_fetch_row($rslt);
		$temp_postal_gmt_offset = $rowx[1];
		if ($rowx[6] == 'Y') {$temp_postal_gmt_offset = ($temp_postal_gmt_offset + 1);}
		$LOCALzone=(3600 * $temp_postal_gmt_offset);
		$LOCALdate=gmdate("D j M Y H:i", time() + $LOCALzone);

		if ($rowx[3] != "$last_country") {$row_color++;   $last_country = $rowx[3];}
		if (preg_match('/1$|3$|5$|7$|9$/i', $row_color))
			{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
		else
			{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}
		echo "<tr $bgcolor>\n";

		echo "<td align=center><font size=1>$rowx[2] - $rowx[3]</font></td>\n";
		echo "<td align=center><font size=1>$rowx[4]</font></td>\n";
		echo "<td align=center><font size=1>$rowx[5]</font></td>\n";
		echo "<td align=center><font size=1>$rowx[6]</font></td>\n";
		echo "<td align=center><font size=1>$rowx[1]</font></td>\n";
		echo "<td align=left><font size=1> &nbsp; $LOCALdate</font></td>\n";
		echo "</tr>\n";
		$o++;
		}
	echo "</TABLE></center></form>\n";
	}
##### END available postal_codes display page #####


######################
# ADD=999985 - postal_codes_cities display page
######################
if ($ADD==999985)
	{
	echo "<TABLE><TR><TD>\n";
	echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";

	$limitSQL='';
	$next_prev_HTML='';
	$PCentries_per_page='1000';

	$stageSQL='';
	$stateSQL='';
	$citySQL='';
	$countySQL='';
	$acSQL='';
	if (strlen($stage) > 0)			{$stageSQL = "and postal_code='$stage'";}
	if (strlen($state_rule) > 0)	{$stateSQL = "and state='$state_rule'";}
	if (strlen($city_rule) > 0)		{$citySQL = "and city='$city_rule'";}
	if (strlen($county_rule) > 0)	{$countySQL = "and county='$county_rule'";}
	if (strlen($ac_rule) > 0)		{$acSQL = "and areacode='$ac_rule'";}

	$stmt="SELECT count(*) from vicidial_postal_codes_cities where postal_code!='' $stageSQL $stateSQL $citySQL $countySQL $acSQL;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$row=mysqli_fetch_row($rslt);
	$pc_count = $row[0];

	if ( ($pc_count > $PCentries_per_page) and ($status != 'display_all') )
		{
		if (strlen($start_count) < 1) {$start_count=0;}
		$next_count = ($start_count + $PCentries_per_page);
		$nextnext_count = ($next_count + $PCentries_per_page);
		if ($next_count > $pc_count) 
			{$next_count = $pc_count;}
		else
			{
			if ($nextnext_count > $pc_count) 
				{
				$next_temp = ($pc_count - $next_count);
				$nextHTML = "<a href=\"$PHP_SELF?ADD=999985&start_count=$next_count&stage=$stage&city_rule=$city_rule&county_rule=$county_rule&state_rule=$state_rule&ac_rule=$ac_rule\">"._QXZ("NEXT")." $next_temp</a> &nbsp; ";
				}
			else
				{
				$nextHTML = "<a href=\"$PHP_SELF?ADD=999985&start_count=$next_count&stage=$stage&city_rule=$city_rule&county_rule=$county_rule&state_rule=$state_rule&ac_rule=$ac_rule\">"._QXZ("NEXT")." $PCentries_per_page</a> &nbsp; ";
				}
			}
		$next_prev_HTML .= _QXZ("RECORDS")." $start_count - $next_count &nbsp; <font size=1>"._QXZ("of")." $pc_count</font> &nbsp; &nbsp; ";
		$limitSQL="limit $PCentries_per_page";
		if ($start_count > 0)
			{
			$prev_count = ($start_count - $PCentries_per_page);
			$limitSQL="limit $start_count,$PCentries_per_page";
			$next_prev_HTML .= "<a href=\"$PHP_SELF?ADD=999985&start_count=$prev_count&stage=$stage&city_rule=$city_rule&county_rule=$county_rule&state_rule=$state_rule&ac_rule=$ac_rule\">"._QXZ("PREVIOUS")." $PCentries_per_page</a> &nbsp; ";
			}
		$next_prev_HTML .= $nextHTML;
		$next_prev_HTML .= " &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; </b><a href=\"$PHP_SELF?ADD=999985&status=display_all&stage=$stage&city_rule=$city_rule&county_rule=$county_rule&state_rule=$state_rule&ac_rule=$ac_rule\"><font size=1 color=black>"._QXZ("show all postal codes")."</font></a><b> &nbsp; ";
		}
	else
		{$next_prev_HTML .= _QXZ("RECORDS")." 1 - $pc_count &nbsp; <font size=1>"._QXZ("of")." $pc_count</font> &nbsp; &nbsp; ";}

	echo "<table border=0 width=900><tr><td valign=middle>";
	echo "<br><b>"._QXZ("POSTAL CODES CITIES")."</b><br>\n";
	echo "<br></td><td valign=middle align=right><font size=1> &nbsp; <br></font><form>"._QXZ("Search")."-";
	echo "<input type=hidden name=ADD value=\"$ADD\">";
	echo "&nbsp; <font size=2>"._QXZ("postal").":</font><input type=text size=5 maxlength=10 name=stage value=\"$stage\" class=\"cust_form\">";
	echo "&nbsp; <font size=2>"._QXZ("city").":</font><input type=text size=15 maxlength=60 name=city_rule value=\"$city_rule\" class=\"cust_form\">";
	echo "&nbsp; <font size=2>"._QXZ("county").":</font><input type=text size=15 maxlength=60 name=county_rule value=\"$county_rule\" class=\"cust_form\">";
	echo "&nbsp; <font size=2>"._QXZ("state").":</font><input type=text size=2 maxlength=4 name=state_rule value=\"$state_rule\" class=\"cust_form\">";
	echo "&nbsp; <font size=2>"._QXZ("ac").":</font><input type=text size=3 maxlength=4 name=ac_rule value=\"$ac_rule\" class=\"cust_form\">";
	echo "<input type=submit value=submit>";
	echo "</form></td></tr></table>";
	echo "<br>$next_prev_HTML\n";
	echo "<center><TABLE width=$section_width cellspacing=3>\n";
	echo "<tr bgcolor=#$SSstd_row3_background>\n";
	echo "<td align=center><B>"._QXZ("Country")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("Postal Code")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("State")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("County")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("City")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("Areacode")."</B></td>\n";
	echo "<td align=center><B>"._QXZ("Latitude x Longitude")."</B></td>\n";
	echo "</tr>\n";

	# postal_code | state | city | county | latitude | longitude | areacode | country_code | country
	$stmt="SELECT count(*),city,country,country_name,postal_code,state,county,areacode,latitude,longitude FROM vicidial_postal_codes_cities p,vicidial_country_iso_tld i where i.iso3=p.country $stageSQL $stateSQL $citySQL $countySQL $acSQL group by country_code,postal_code,state,city,county,areacode,latitude,longitude order by country_code,postal_code $limitSQL;";
	$rslt=mysql_to_mysqli($stmt, $link);
	$zones_to_print = mysqli_num_rows($rslt);
	if ($DB > 0) {echo "$zones_to_print|$stmt\n";}
	$o=0;
	$row_color=0;   $last_country='';
	while ($zones_to_print > $o) 
		{
		$rowx=mysqli_fetch_row($rslt);
		if ($rowx[3] != "$last_country") {$row_color++;   $last_country = $rowx[3];}
		if (preg_match('/1$|3$|5$|7$|9$/i', $row_color))
			{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';} 
		else
			{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}
		echo "<tr $bgcolor>\n";

		echo "<td align=center><font size=1>$rowx[2] - $rowx[3]</font></td>\n";
		echo "<td align=center><font size=1>$rowx[4]</font></td>\n";
		echo "<td align=center><font size=1>$rowx[5]</font></td>\n";
		echo "<td align=center><font size=1>$rowx[6]</font></td>\n";
		echo "<td align=center><font size=1>$rowx[1]</font></td>\n";
		echo "<td align=center><font size=1>$rowx[7]</font></td>\n";
		echo "<td align=left><font size=1> &nbsp; $rowx[8] x $rowx[9] - (<a href=\"https://www.openstreetmap.org/?mlat=$rowx[8]&mlon=$rowx[9]\">OpenSM</a> | <a href=\"https://www.google.com/maps/search/$rowx[8],$rowx[9]\">google</a> | <a href=\"https://www.bing.com/maps/?v=2&cp=$rowx[8]~$rowx[9]&style=r&lvl=12&sp=Point.$rowx[8]_$rowx[9]_$rowx[4]-postal-code\">bing</a>)</font></td>\n";
		echo "</tr>\n";
		$o++;
		}
	echo "</TABLE></center></form>\n";
	}
##### END available postal_codes_cities display page #####


echo "</TD></TR></TABLE></center>\n";
echo "</TD></TR></TABLE></center>\n";

$ENDtime = date("U");

$RUNtime = ($ENDtime - $STARTtime);

echo "</TD></TR>\n";
echo "<TR><TD bgcolor=#$SSmenu_background ALIGN=CENTER>\n";
echo "<FONT STYLE=\"font-family:HELVETICA;font-size:9;color:white;\"><br><br><!-- RUNTIME: $RUNtime seconds<BR> -->";
echo _QXZ("VERSION").": $admin_version<BR>";
echo _QXZ("BUILD").": $build\n";
if (!preg_match("/_BUILD_/",$SShosted_settings))
	{echo "<BR><a href=\"$PHP_SELF?ADD=999995\"><font color=white>&copy; 2025 ViciDial Group</font></a><BR><img src=\"images/pixel.gif\">";}
echo "</FONT>\n";
?>

</TD><TD BGCOLOR=#<?php echo $SSframe_background ?>>
</TD></TR><TABLE>
</body>
<script language="Javascript">
if (!window.A_TCALSIDX)
	{
	if (document.addEventListener)
		window.removeEventListener('scroll', f_tcalHideAll);
	if (window.attachEvent)
		window.detachEvent('onscroll', f_tcalHideAll);
	}
</script>
<?php

if ( ($SSnocache_admin=='1') or ( ($SSadmin_modify_refresh > 1) and ($modify_footer_refresh > 0) and (strlen($modify_url)>10) ) )
	{
	echo "<head>\n";
	if ($SSnocache_admin=='1')
		{
		echo "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n";
		echo "<META HTTP-EQUIV=\"Expires\" CONTENT=\"-1\">\n";
		echo "<META HTTP-EQUIV=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\">\n";
		}
	if ( ($SSadmin_modify_refresh > 1) and ($modify_footer_refresh > 0) and (strlen($modify_url)>10) )
		{
		echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"$SSadmin_modify_refresh;URL=$modify_url\">\n";
		}
	echo "</head>\n";
	}

echo "</html>\n";

	
exit;


##### CALCULATE COMPLETE LEADS #####
function complete_leads($DB,$link,$dial_statuses,$camp_lists,$call_count_limit,$single_status,$campaign_id)
{
if (isset($camp_lists))
	{
	if (strlen($camp_lists)>1)
		{
		if (strlen($dial_statuses)>2)
			{
			$dial_statuses = preg_replace("/ -$/","",$dial_statuses);
			$Dstatuses = explode(" ", $dial_statuses);
			$Ds_to_print = (count($Dstatuses) - 0);
			$Dsql = '';
			$o=0;
			while ($Ds_to_print > $o) 
				{
				$o++;
				$Dsql .= "'$Dstatuses[$o]',";
				}
			$Dsql = preg_replace("/,$/","",$Dsql);
			if (strlen($Dsql) < 2) {$Dsql = "''";}

			$CCLsql = "(called_count < 0) or";
			if ($call_count_limit > 0)
				{$CCLsql = "(called_count >= $call_count_limit) or";}

			$complete_statuses='';
			$stmt="SELECT status from vicidial_statuses where completed='Y';";
			$rslt=mysql_to_mysqli($stmt, $link);
			$statuses_to_print = mysqli_num_rows($rslt);
			$q=0;
			while ($statuses_to_print > $q) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$complete_statuses.="'$rowx[0]',";
				$q++;
				}
			$stmt="SELECT status from vicidial_campaign_statuses where completed='Y' $LOGallowed_campaignsSQL;";
			$rslt=mysql_to_mysqli($stmt, $link);
			$statuses_to_print = mysqli_num_rows($rslt);
			$q=0;
			while ($statuses_to_print > $q) 
				{
				$rowx=mysqli_fetch_row($rslt);
				$complete_statuses.="'$rowx[0]',";
				$q++;
				}
			$complete_statuses = preg_replace("/,$/","",$complete_statuses);
			if (strlen($complete_statuses) < 2) {$complete_statuses = "''";}
			$CSsql = "status IN($complete_statuses)";

			$stmt="SELECT count(*) FROM vicidial_list where ( (status IN($Dsql)) and (list_id IN($camp_lists)) and ( $CCLsql ($CSsql) ) );";
			#$DB=1;
			if ($DB) {echo "$stmt\n";}
			$rslt=mysql_to_mysqli($stmt, $link);
			$rslt_rows = mysqli_num_rows($rslt);
			if ($rslt_rows)
				{
				$rowx=mysqli_fetch_row($rslt);
				$complete_leads = $rowx[0];
				}
			else {$complete_leads = '0';}

			if ($DB > 0) {echo "|$DB|\n";}
			if ($single_status > 0)
				{return $complete_leads;}
			else
				{echo "There are $complete_leads completed leads in those lists\n";}
			}
		else
			{
			echo _QXZ("no dial statuses selected for this campaign")."\n";
			}
		}
	else
		{
		echo _QXZ("no active lists selected for this campaign")."\n";
		}
	}
else
	{
	echo _QXZ("no active lists selected for this campaign")."\n";
	}
}

?>
