From cb91a9a1a6704070bf2b19f577161988b55741f7 Mon Sep 17 00:00:00 2001 From: mattf Date: Fri, 8 Apr 2011 08:52:01 +0000 Subject: [PATCH] Added reload dialplan system settings option Added MULTI_LEAD option to the Auto-Alt-Dial setting in campaigns git-svn-id: svn://192.168.202.10@1636 3d104415-ff17-0410-8863-d5cf3c621b8a --- UPGRADE | 10 + .../TO_BE_TRANSLATED_2.4.txt | 6 + www/vicidial/admin.php | 585 ++++++++++-------- www/vicidial/admin_campaign_multi_alt.php | 433 +++++++++++++ 4 files changed, 792 insertions(+), 242 deletions(-) create mode 100644 www/vicidial/admin_campaign_multi_alt.php diff --git a/UPGRADE b/UPGRADE index 3098f22c..7297cd01 100644 --- a/UPGRADE +++ b/UPGRADE @@ -527,6 +527,16 @@ OTHER CHANGES: level recording settings for the start user of the remote agent will also be followed. +121. Added MULTI_LEAD option for Auto-Alt-Dialing. Using MULTI_LEAD allows you + to use a separate lead for each number on a customer account that all + share a common vendor_lead_code, and the type of phone number for each + is defined with a label in the Owner field. This option will disable + some options on the Modify Campaign screen and show a link to the + Multi-Alt Settings page which allows you to set which phone number types + , defined by the label of each lead, will be dialed and in what order. + This will create a special lead filter and will alter the Rank field of + all of the leads inside the lists set to this campaign in order to call + them in the order you have specified. diff --git a/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt b/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt index c17b9404..f2873fd8 100644 --- a/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt +++ b/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt @@ -554,8 +554,14 @@ Auto Resume Pre-Call Work|| In auto-dial mode, this setting if enabled will set the agent to active automatically when the agent clicks out of, or cancels, on any of the following functions that requires them to be paused- Manual Dial, Fast Dial, Lead Search, Call Log View, Callbacks Check, Enter Pause Code. Default is N for inactive|| Auto Pause Pre-Call Code|| If the Auto Pause Pre-Call Work function above is active, and Agent Pause Codes is active, this setting will be the pause code that is used when the agent is paused for these activities. Default is PRECAL|| +This campaign is not set to Auto-Alt-Dial|| +Multi-Alt-Settings|| +Reload Dialplan On Servers|| +This option allows you to force a reload of the dialplan on all Asterisk servers in the cluster. If you made changes in the Custom Dialplan Entry above you should set this to 1 and submit to have those changes go into effect on the servers|| +Using MULTI_LEAD allows you to use a separate lead for each number on a customer account that all share a common vendor_lead_code, and the type of phone number for each is defined with a label in the Owner field. This option will disable some options on the Modify Campaign screen and show a link to the Multi-Alt Settings page which allows you to set which phone number types, defined by the label of each lead, will be dialed and in what order. This will create a special lead filter and will alter the Rank field of all of the leads inside the lists set to this campaign in order to call them in the order you have specified|| +admin_campaign_multi_alt.php AST_LISTS_campaign_stats.php AST_VICIDIAL_ingrouplist.php admin_lists_custom.php diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index 59c47bb0..e92b47f8 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -1526,6 +1526,8 @@ if (isset($_GET["auto_resume_precall"])) {$auto_resume_precall=$_GET["auto_res 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["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($script_id)) {$script_id= strtoupper($script_id);} @@ -1762,6 +1764,7 @@ if ($non_latin < 1) $queuemetrics_addmember_enabled = ereg_replace("[^0-9]","",$queuemetrics_addmember_enabled); $modify_page = ereg_replace("[^0-9]","",$modify_page); $on_hook_ring_time = ereg_replace("[^0-9]","",$on_hook_ring_time); + $reload_dialplan_on_servers = ereg_replace("[^0-9]","",$reload_dialplan_on_servers); $drop_call_seconds = ereg_replace("[^-0-9]","",$drop_call_seconds); @@ -2677,12 +2680,13 @@ else # 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 # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time -$admin_version = '2.4-306a'; -$build = '110310-0311'; +$admin_version = '2.4-307a'; +$build = '110408-0433'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -4331,7 +4335,7 @@ if ($ADD==99999)

- Auto Alt-Number Dialing - This setting is used to automatically dial alternate number fields while dialing in the RATIO and ADAPT dial methods when there is no contact at the main phone number for a lead, the NA, B, DC and N statuses. This setting is not used by the MANUAL dial method. EXTENDED alternate numbers are numbers loaded into the system outside of the standard lead information screen. Using EXTENDED you can have hundreds of phone numbers for a single customer record. + Auto Alt-Number Dialing - This setting is used to automatically dial alternate number fields while dialing in the RATIO and ADAPT dial methods when there is no contact at the main phone number for a lead, the NA, B, DC and N statuses. This setting is not used by the MANUAL dial method. EXTENDED alternate numbers are numbers loaded into the system outside of the standard lead information screen. Using EXTENDED you can have hundreds of phone numbers for a single customer record. Using MULTI_LEAD allows you to use a separate lead for each number on a customer account that all share a common vendor_lead_code, and the type of phone number for each is defined with a label in the Owner field. This option will disable some options on the Modify Campaign screen and show a link to the Multi-Alt Settings page which allows you to set which phone number types, defined by the label of each lead, will be dialed and in what order. This will create a special lead filter and will alter the Rank field of all of the leads inside the lists set to this campaign in order to call them in the order you have specified.
@@ -7347,6 +7351,11 @@ if ($ADD==99999)
Custom Dialplan Entry - This field allows you to enter in any dialplan elements that you want for all of the asterisk servers, the lines will be added to the default context. +
+
+
+ Reload Dialplan On Servers - This option allows you to force a reload of the dialplan on all Asterisk servers in the cluster. If you made changes in the Custom Dialplan Entry above you should set this to 1 and submit to have those changes go into effect on the servers. +

@@ -15524,8 +15533,14 @@ if ($ADD==411111111111111) $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='$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='$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='$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='" . mysql_real_escape_string($webphone_url) . "',enable_agc_dispo_log='$enable_agc_dispo_log',custom_dialplan_entry='$custom_dialplan_entry',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',custom_fields_enabled='$custom_fields_enabled',slave_db_server='$slave_db_server',reports_use_slave_db='$reports_use_slave_db',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';"; $rslt=mysql_query($stmt, $link); + if ($reload_dialplan_on_servers > 0) + { + $stmtB="UPDATE servers set rebuild_conf_files='Y' where active='Y' and active_asterisk_server='Y' and generate_vicidial_conf='Y';"; + $rslt=mysql_query($stmtB, $link); + } + ### LOG INSERTION Admin Log Table ### - $SQL_log = "$stmt|"; + $SQL_log = "$stmt|$stmtB|"; $SQL_log = ereg_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='';"; @@ -18566,6 +18581,12 @@ if ($ADD==31) else {$DEFlistDISABLE = 'disabled'; $DEFstatusDISABLED=1;} + if ($auto_alt_dial == 'MULTI_LEAD') + {$ALTmultiDISABLE=1; $ALTmultiLINK="
Multi-Alt-Settings";} + else + {$ALTmultiDISABLE=0; $ALTmultiLINK='';} + + $stmt="SELECT count(*) from vicidial_campaigns_list_mix where campaign_id='$campaign_id' and status='ACTIVE'"; $rslt=mysql_query($stmt, $link); $rowx=mysql_fetch_row($rslt); @@ -18839,128 +18860,173 @@ if ($ADD==31) echo "   \n"; echo "     $NWB#vicidial_campaigns-dial_status$NWE\n"; - echo "List Order: $NWB#vicidial_campaigns-lead_order$NWE\n"; - - echo "List Order Randomize: $NWB#vicidial_campaigns-lead_order_randomize$NWE\n"; - - echo "List Order Secondary: $NWB#vicidial_campaigns-lead_order_secondary$NWE\n"; - - echo "List Mix: $ALTmultiLINK"; + } else - {echo "\n";} - echo "$NWB#vicidial_campaigns-list_order_mix$NWE\n"; + { + echo "$NWB#vicidial_campaigns-lead_order$NWE\n"; + } - echo "Lead Filter: $NWB#vicidial_campaigns-lead_filter_id$NWE\n"; + echo "\n"; + echo "List Order Randomize: "; + if ($ALTmultiDISABLE > 0) + { + echo " $ALTmultiLINK"; + } + else + { + echo "$NWB#vicidial_campaigns-lead_order_randomize$NWE"; + } + echo "\n"; + + echo "List Order Secondary: "; + if ($ALTmultiDISABLE > 0) + { + echo " $ALTmultiLINK"; + } + else + { + echo "$NWB#vicidial_campaigns-lead_order_secondary$NWE"; + } + echo "\n"; + + echo "List Mix: "; + if ($ALTmultiDISABLE > 0) + { + echo " $ALTmultiLINK"; + } + else + { + echo "$NWB#vicidial_campaigns-list_order_mix$NWE"; + } + echo "\n"; + + echo "Lead Filter: "; + if ($ALTmultiDISABLE > 0) + { + echo " $ALTmultiLINK"; + } + else + { + echo "$NWB#vicidial_campaigns-lead_filter_id$NWE"; + } + echo "\n"; echo "Drop Lockout Time: $NWB#vicidial_campaigns-drop_lockout_time$NWE\n"; @@ -19144,7 +19210,7 @@ if ($ADD==31) echo "Inbound Queue No Dial: $NWB#vicidial_campaigns-inbound_queue_no_dial$NWE\n"; - echo "Auto Alt-Number Dialing: $NWB#vicidial_campaigns-auto_alt_dial$NWE\n"; + echo "Auto Alt-Number Dialing: $NWB#vicidial_campaigns-auto_alt_dial$NWE $ALTmultiLINK\n"; } echo "Next Agent Call: $NWB#vicidial_campaigns-next_agent_call$NWE\n"; @@ -19568,7 +19634,7 @@ if ($ADD==31) else {$fSQL = '';} - $camp_lists = eregi_replace(".$","",$camp_lists); + $camp_lists = eregi_replace(".$","",$camp_lists); echo "
This campaign has $active_lists active lists and $inactive_lists inactive lists

\n"; @@ -20335,6 +20401,7 @@ if ($ADD==34) $display_dialable_count = $row[39]; $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]; @@ -20352,6 +20419,11 @@ if ($ADD==34) else {$DEFlistDISABLE = 'disabled'; $DEFstatusDISABLED=1;} + if ($auto_alt_dial == 'MULTI_LEAD') + {$ALTmultiDISABLE=1; $ALTmultiLINK="Multi-Alt-Settings";} + else + {$ALTmultiDISABLE=0; $ALTmultiLINK='';} + $stmt="SELECT status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable,scheduled_callback from vicidial_statuses order by status"; $rslt=mysql_query($stmt, $link); $statuses_to_print = mysql_num_rows($rslt); @@ -20496,124 +20568,151 @@ if ($ADD==34) echo "   \n"; echo "     $NWB#vicidial_campaigns-dial_status$NWE\n"; - echo "List Order: $NWB#vicidial_campaigns-lead_order$NWE\n"; - - echo "List Mix: $ALTmultiLINK"; + } else - {echo "\n";} - echo "$NWB#vicidial_campaigns-list_order_mix$NWE\n"; + { + echo "$NWB#vicidial_campaigns-lead_order$NWE"; + } + echo "\n"; - echo "Lead Filter: $NWB#vicidial_campaigns-lead_filter_id$NWE\n"; + echo "List Mix: "; + if ($ALTmultiDISABLE > 0) + { + echo " $ALTmultiLINK"; + } + else + { + echo "$NWB#vicidial_campaigns-list_order_mix$NWE"; + } + echo "\n"; + + echo "Lead Filter: "; + if ($ALTmultiDISABLE > 0) + { + echo " $ALTmultiLINK"; + } + else + { + echo "$NWB#vicidial_campaigns-lead_filter_id$NWE"; + } + echo "\n"; echo "Minimum Hopper Level: $NWB#vicidial_campaigns-hopper_level$NWE\n"; @@ -26318,6 +26417,8 @@ if ($ADD==311111111111111) if ($SSallow_custom_dialplan > 0) { echo "Custom Dialplan Entry: $NWB#settings-custom_dialplan_entry$NWE \n"; + + echo "Reload Dialplan On Servers: $NWB#settings-reload_dialplan_on_servers$NWE\n"; } else { diff --git a/www/vicidial/admin_campaign_multi_alt.php b/www/vicidial/admin_campaign_multi_alt.php new file mode 100644 index 00000000..1c928a46 --- /dev/null +++ b/www/vicidial/admin_campaign_multi_alt.php @@ -0,0 +1,433 @@ + LICENSE: AGPLv2 +# +# this screen will control the campaign settings needed for alternate number +# dialing using multiple leads with the same account number and different phone +# numbers. the leads will use different owner values and this script will alter +# the ranks for those leads as well as alter the special campaign filter and +# change some campaign settings. +# +# changes: +# 110317-1219 - First Build +# 110406-1818 - Updated logging +# + +$admin_version = '2.4-2'; +$build = '110406-1818'; + + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["action"])) {$action=$_GET["action"];} + elseif (isset($_POST["action"])) {$action=$_POST["action"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +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["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + + +if (strlen($action) < 2) + {$action = 'BLANK';} +if (strlen($DB) < 1) + {$DB=0;} + + +if ($non_latin < 1) + { + $PHP_AUTH_USER = ereg_replace("[^-_0-9a-zA-Z]","",$PHP_AUTH_USER); + $PHP_AUTH_PW = ereg_replace("[^-_0-9a-zA-Z]","",$PHP_AUTH_PW); + $campaign_id = ereg_replace("[^-_0-9a-zA-Z]","",$campaign_id); + $lead_order_randomize = ereg_replace("[^-_0-9a-zA-Z]","",$lead_order_randomize); + $lead_order_secondary = ereg_replace("[^-_0-9a-zA-Z]","",$lead_order_secondary); + } # end of non_latin +else + { + $PHP_AUTH_USER = ereg_replace("'|\"|\\\\|;","",$PHP_AUTH_USER); + $PHP_AUTH_PW = ereg_replace("'|\"|\\\\|;","",$PHP_AUTH_PW); + } + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin FROM system_settings;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$ss_conf_ct = mysql_num_rows($rslt); +if ($ss_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + } +##### END SETTINGS LOOKUP ##### +########################################### + + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7 and modify_campaigns='1';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id' and auto_alt_dial='MULTI_LEAD';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$camp_multi=$row[0]; + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$user = $PHP_AUTH_USER; + +if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } +else + { + if ($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name,modify_campaigns,user_level from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname = $row[0]; + $LOGmodify_campaigns = $row[1]; + $LOGuser_level = $row[2]; + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +?> + + + + +ADMINISTRATION: Campaign Multi-Alt-Leads +<?php + + +##### BEGIN Set variables to make header show properly ##### +$ADD = '31'; +$SUB = '26'; +$hh = 'campaigns'; +$sh = 'detail'; +$LOGast_admin_access = '1'; +$SSoutbound_autodial_active = '1'; +$ADMIN = 'admin.php'; +$page_width='770'; +$section_width='750'; +$header_font_size='3'; +$subheader_font_size='2'; +$subcamp_font_size='2'; +$header_selected_bold='<b>'; +$header_nonselected_bold=''; +$campaigns_color = '#FFFF99'; +$campaigns_font = 'BLACK'; +$campaigns_color = '#E6E6E6'; +$subcamp_color = '#C6C6C6'; +##### END Set variables to make header show properly ##### + +require("admin_header.php"); + +if ( ($LOGast_admin_access < 1) or ($LOGuser_level < 8) ) + { + echo "You are not authorized to view this section\n"; + exit; + } +if ($camp_multi < 1) + { + echo "This campaign is not set to Auto-Alt-Dial MULTI_LEAD\n"; + exit; + } + +if ($DB > 0) + { + echo "$DB,$action,$campaign_id,$lead_order_randomize,$lead_order_secondary\n<BR>"; + } + +$stmt="SELECT list_id,active from vicidial_lists where campaign_id='$campaign_id' order by list_id;"; +$rslt=mysql_query($stmt, $link); +$lists_to_print = mysql_num_rows($rslt); +$o=0; +while ($lists_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (ereg('Y',$row[1])) + { + $active_lists++; + $camp_lists .= "'$row[0]',"; + } + else + { + $inactive_lists++; + $camp_lists .= "'$row[0]',"; + } + $o++; + } +$camp_lists = eregi_replace(".$","",$camp_lists); + + + + +################################################################################ +##### BEGIN multi-lead alt dial submit form +if ($action == "ALT_MULTI_SUBMIT") + { + $settings_updated=0; + if ( (strlen($lead_order_randomize) > 0) and (strlen($lead_order_secondary) > 0) ) + { + $stmt="SELECT distinct owner from vicidial_list where list_id IN($camp_lists) limit 1000;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $do_values_ct = mysql_num_rows($rslt); + $o=0; + while ($do_values_ct > $o) + { + $row=mysql_fetch_row($rslt); + $owners[$o] = $row[0]; + $o++; + } + + $o=0; + $update_stmts=''; + $new_filter_sql=''; + while ($do_values_ct > $o) + { + $owner_check=''; + $owner_rank=''; + $owner_raw = $owners[$o]; + $owner = preg_replace('/ |\n|\r|\t/','',$owner_raw); + if (isset($_GET["$campaign_id$US$owner"])) {$owner_check=$_GET["$campaign_id$US$owner"];} + elseif (isset($_POST["$campaign_id$US$owner"])) {$owner_check=$_POST["$campaign_id$US$owner"];} + if (isset($_GET["rank_$campaign_id$US$owner"])) {$owner_rank=$_GET["rank_$campaign_id$US$owner"];} + elseif (isset($_POST["rank_$campaign_id$US$owner"])) {$owner_rank=$_POST["rank_$campaign_id$US$owner"];} + + if ($owner_check=='YES') + {$new_filter_sql .= "'$owner_raw',";} + + $stmt = "UPDATE vicidial_list SET rank='$owner_rank' where list_id IN($camp_lists) and owner='$owner_raw';"; + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + if ($DB > 0) {echo "OWNER: $o|$campaign_id|$owner|$owner_check|$owner_rank|$affected_rows\n<BR>";} + $update_stmts .= "|$affected_rows|$owner_check|$stmt"; + $o++; + } + + $filter_stmt="INSERT IGNORE INTO vicidial_lead_filters SET lead_filter_id='ML$campaign_id',lead_filter_name='DO NOT DELETE MULTI_$campaign_id',lead_filter_comments=NOW(),lead_filter_sql=\"owner IN($new_filter_sql'99827446572348452235')\" ON DUPLICATE KEY UPDATE lead_filter_comments=NOW(),lead_filter_sql=\"owner IN($new_filter_sql'99827446572348452235')\";"; + $rslt=mysql_query($filter_stmt, $link); + $affected_rows = mysql_affected_rows($link); + if ($DB > 0) {echo "$affected_rows|$filter_stmt\n<BR>";} + + $stmt = "UPDATE vicidial_campaigns SET lead_order_randomize='$lead_order_randomize',lead_order_secondary='$lead_order_secondary',lead_filter_id='ML$campaign_id',lead_order='DOWN RANK',campaign_changedate=NOW() where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + if ($DB > 0) {echo "$campaign_id|$lead_order_randomize|$lead_order_secondary|ML$campaign_id|DOWN RANK|$affected_rows|$stmt\n<BR>";} + + if ($affected_rows > 0) + { + $phone_alias_entry[$p] .= "$login,"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|$filter_stmt|$update_stmts|"; + $SQL_log = ereg_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='CAMPAIGNS', event_type='MODIFY', record_id='$campaign_id', event_code='MODIFY CAMPAIGN MULTI LEAD', event_sql=\"$SQL_log\", event_notes='';"; + $rslt=mysql_query($stmt, $link); + if ($DB > 0) {echo "$campaign_id|$stmt\n<BR>";} + + echo "<BR><b>MULTI-LEAD ALT DIAL SETTINGS UPDATED</b><BR><BR>"; + + } + else + {echo "ERROR: Problem updating campaign: $affected_rows|$stmt\n<BR>";} + + } + else + {echo "ERROR: problem with data: $campaign_id\n<BR>";} + + $action='BLANK'; + } +### END multi-lead alt dial submit form + + + + + +################################################################################ +##### BEGIN multi-lead alt dial control form +if ($action == "BLANK") + { + $stmt = "SELECT lead_order_randomize,lead_order_secondary FROM vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $vc_values_ct = mysql_num_rows($rslt); + if ($vc_values_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_order_randomize = $row[0]; + $lead_order_secondary = $row[1]; + } + + $lead_filter_sql=''; + $lead_filter_comments=''; + $stmt = "SELECT lead_filter_sql,lead_filter_comments FROM vicidial_lead_filters where lead_filter_id='ML$campaign_id' and lead_filter_name='DO NOT DELETE MULTI_$campaign_id';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $vlf_values_ct = mysql_num_rows($rslt); + if ($vlf_values_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_filter_sql = $row[0]; + $lead_filter_comments = $row[1]; + if ($DB) {echo "$lead_filter_sql|$lead_filter_comments";} + } + + echo "<TABLE><TR><TD>\n"; + echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"; + echo "<br>Multi-Lead Auto Alt Dialing Settings Form<form action=$PHP_SELF method=POST>\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=action value=ALT_MULTI_SUBMIT>\n"; + echo "<center><TABLE width=$section_width cellspacing=3>\n"; + echo "<tr><td align=center colspan=2>\n"; + + + echo "<br><b>PHONE TYPES WITHIN THE LISTS FOR THIS CAMPAIGN: <a href=\"./admin.php?ADD=31&campaign_id=$campaign_id\">$campaign_id</a></b>\n"; + echo "<TABLE width=700 cellspacing=3>\n"; + echo "<tr><td>PHONE NUMBER TYPE</td><td>CALLED</td><td>NOT CALLED</td><td>SELECTED</td><td>OLD RANK</td><td>NEW RANK</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(*),rank from vicidial_list where list_id IN($camp_lists) group by owner,rank,called_since_last_reset order by rank,owner,called_since_last_reset limit 1000;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $types_to_print = mysql_num_rows($rslt); + + $o=0; + $lead_list['count'] = 0; + $lead_list['Y_count'] = 0; + $lead_list['N_count'] = 0; + while ($types_to_print > $o) + { + $rowx=mysql_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])) + { + $owner_var = preg_replace('/ |\n|\r|\t/','',$owner); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $o++; + echo "<tr $bgcolor>"; + echo "<td><font size=1>$owner</td>"; + echo "<td><font size=1>".$lead_list['Y'][$owner]."</td>"; + echo "<td><font size=1>".$lead_list['N'][$owner]." </td>"; + echo "<td><font size=1>"; + if (preg_match("/\\\'$owner\\\'|'$owner'/",$lead_filter_sql)) + {echo "<input type=checkbox name=\"$campaign_id$US$owner_var\" id=\"$campaign_id$US$owner_var\" value=\"YES\" CHECKED>";} + else + {echo "<input type=checkbox name=\"$campaign_id$US$owner_var\" id=\"$campaign_id$US$owner_var\" value=\"YES\">";} + echo "</td>"; + echo "<td><font size=1>$o</td>"; + echo "<td><font size=1><input type=text size=3 maxlength=3 name=\"rank_$campaign_id$US$owner_var\" id=\"rank_$campaign_id$US$owner_var\" value=\"$o\"></td>"; + echo "</tr>\n"; + } + } + + 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=\"#9BB9FB\"><td><font size=1>TOTAL</td><td colspan=3 align=center><font size=1>$lead_list[count]</td><td align=center><font size=1>$o</td></tr>\n"; + + echo "</table></center><br>\n"; + unset($lead_list); + + + echo "</td></tr>\n"; + + echo "<tr bgcolor=#B6D3FC><td align=right>List Order Randomize: </td><td align=left><select size=1 name=lead_order_randomize><option>Y</option><option>N</option><option SELECTED>$lead_order_randomize</option></select></td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>List Order Secondary: </td><td align=left><select size=1 name=lead_order_secondary><option>LEAD_ASCEND</option><option>LEAD_DESCEND</option><option>CALLTIME_ASCEND</option><option>CALLTIME_DESCEND</option><option SELECTED>$lead_order_secondary</option></select></td></tr>\n"; + + echo "<tr bgcolor=#B6D3FC><td align=center colspan=2><input type=submit name=SUBMIT value=SUBMIT></td></tr>\n"; + echo "</TABLE></center>\n"; + echo "</TD></TR></TABLE>\n"; + } +### END multi-lead alt dial control form + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $STARTtime); +echo "\n\n\n<br><br><br>\n<font size=1> runtime: $RUNtime seconds         Version: $admin_version     Build: $build</font>"; + +?> + +</body> +</html>