diff --git a/UPGRADE b/UPGRADE index ed283dcb..d991a0a5 100644 --- a/UPGRADE +++ b/UPGRADE @@ -867,6 +867,10 @@ OTHER CHANGES: 247. Added archived-log cold-storage options and scripts. See LOG_ARCHIVING_AND_COLD_STORAGE.txt document for more infomation. +248. Added "API New Lead URL" feature to System Settings, with per List override + setting. This can send a URL request when new leads are added to the + system through the "add_lead" Non-Agent API function. + diff --git a/extras/MySQL_AST_CREATE_tables.sql b/extras/MySQL_AST_CREATE_tables.sql index bfa6feef..92308dc2 100644 --- a/extras/MySQL_AST_CREATE_tables.sql +++ b/extras/MySQL_AST_CREATE_tables.sql @@ -3779,9 +3779,9 @@ PRIMARY KEY (manager_chat_id) CREATE TABLE vicidial_url_multi ( url_id INT(9) UNSIGNED NOT NULL AUTO_INCREMENT, campaign_id VARCHAR(20) NOT NULL, -entry_type ENUM('campaign','ingroup','list','') default '', +entry_type ENUM('campaign','ingroup','list','system','') default '', active ENUM('Y','N') default 'N', -url_type ENUM('dispo','start','addlead','noagent','') default '', +url_type ENUM('dispo','start','addlead','noagent','apinewlead','') default '', url_rank SMALLINT(5) default '1', url_statuses VARCHAR(1000) default '', url_description VARCHAR(255) default '', @@ -5740,4 +5740,4 @@ INSERT INTO `wallboard_reports` VALUES ('AGENTS_AND_QUEUES','Agents and Queues', UPDATE system_settings set vdc_agent_api_active='1'; -UPDATE system_settings SET db_schema_version='1725',db_schema_update_date=NOW(),reload_timestamp=NOW(); +UPDATE system_settings SET db_schema_version='1726',db_schema_update_date=NOW(),reload_timestamp=NOW(); diff --git a/extras/upgrade_2.14.sql b/extras/upgrade_2.14.sql index 643294b1..1360c39a 100644 --- a/extras/upgrade_2.14.sql +++ b/extras/upgrade_2.14.sql @@ -2871,3 +2871,8 @@ INSERT INTO vicidial_settings_containers(container_id,container_notes,container_ ALTER TABLE system_settings ADD agent_hide_dial_fail ENUM('0','1','2','3','4','5','6') default '0'; UPDATE system_settings SET db_schema_version='1725',db_schema_update_date=NOW() where db_schema_version < 1725; + +ALTER TABLE vicidial_url_multi MODIFY entry_type ENUM('campaign','ingroup','list','system','') default ''; +ALTER TABLE vicidial_url_multi MODIFY url_type ENUM('dispo','start','addlead','noagent','apinewlead','') default ''; + +UPDATE system_settings SET db_schema_version='1726',db_schema_update_date=NOW() where db_schema_version < 1726; diff --git a/www/vicidial/AST_url_log_report.php b/www/vicidial/AST_url_log_report.php index a0f4d9de..518d4590 100644 --- a/www/vicidial/AST_url_log_report.php +++ b/www/vicidial/AST_url_log_report.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2025 Joe Johnson, Matt Florell LICENSE: AGPLv2 # # CHANGES # 130620-0806 - First build @@ -16,6 +16,7 @@ # 220812-0931 - Added User Group report permissions checking # 230310-1051 - Added more missing url types # 240801-1130 - Code updates for PHP8 compatibility +# 250620-1112 - Added new URL types: apinewlead # $startMS = microtime(); @@ -272,7 +273,7 @@ while($i < $url_type_ct) $i++; } -$LISTurltypes=array("abandonchk","add_lead","ccc_look","custom","dead","DID_FILTER","dispo","DNCcom","enter_ig","event","na_callurl","non-agent","nva_phone","other","park_ivr_c","pause_max","qm_socket","sc_callurl","start","start_ra","TCPAlit","2FA_SMS","TILTX_SHAK","wcu_off","wcu_on","webform"); +$LISTurltypes=array("abandonchk","add_lead","apinewlead","ccc_look","custom","dead","DID_FILTER","dispo","DNCcom","enter_ig","event","na_callurl","non-agent","nva_phone","other","park_ivr_c","pause_max","qm_socket","sc_callurl","start","start_ra","TCPAlit","2FA_SMS","TILTX_SHAK","wcu_off","wcu_on","webform"); $url_types_to_print=count($LISTurltypes); $i=0; diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index 5ce87201..2235720f 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -2844,6 +2844,8 @@ if (isset($_GET["enhanced_agent_monitoring"])) {$enhanced_agent_monitoring=$_G 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"];} $DB=preg_replace("/[^0-9a-zA-Z]/","",$DB); @@ -5172,6 +5174,10 @@ $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 @@ -6232,12 +6238,13 @@ if ($SSscript_remove_js > 0) # 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 +# 240620-1001 - Added apinewlead options for system settings and lists # # 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-938a'; -$build = '250424-0715'; +$admin_version = '2.14-939a'; +$build = '240620-1001'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -18372,6 +18379,31 @@ if ($ADD==411) echo "
"._QXZ("LIST MODIFIED").": $list_id\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); @@ -18381,10 +18413,10 @@ if ($ADD==411) if ($DB) {echo "|$stmt|$stmtQC|\n";} ### LOG INSERTION Admin Log Table ### - $SQL_log = "$stmt|$stmtQC|"; + $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='';"; + $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); @@ -21281,6 +21313,12 @@ if ($ADD==411111111111111) } } + # 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'$custom_dialplanSQL;"; $rslt=mysql_to_mysqli($stmt, $link); $update_main_rows=mysqli_affected_rows($link); @@ -21308,10 +21346,10 @@ if ($ADD==411111111111111) } ### LOG INSERTION Admin Log Table ### - $SQL_log = "$stmt|$stmtB|$stmtC|"; + $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';"; + $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); } @@ -32573,6 +32611,17 @@ if ($ADD==311) echo ""._QXZ("No Agent Call URL").": $NWB#lists-na_call_url$NWE\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 ""._QXZ("API New Lead URL").": $NWB#lists-apinewlead_url$NWE\n"; + echo ""._QXZ("Auto Alt Threshold Override").": "._QXZ("number only")." $NWB#lists-auto_alt_threshold$NWE\n"; if ($LOGmodify_dial_prefix > 0) @@ -44661,6 +44710,22 @@ if ($ADD==311111111111111) echo ""._QXZ("Lead Hopper Hold Inserts Allowed").": $NWB#settings-hopper_hold_inserts$NWE\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 ""._QXZ("API New Lead URL").": $NWB#settings-apinewlead_url$NWE\n"; + echo ""._QXZ("Shared Agent Campaign Dialing").": $NWB#settings-allow_shared_dial$NWE\n"; echo ""._QXZ("Agent Search Method Override").": $NWB#settings-agent_search_method$NWE\n"; diff --git a/www/vicidial/help_documentation.txt b/www/vicidial/help_documentation.txt index a9baab9a..f24b72e3 100644 --- a/www/vicidial/help_documentation.txt +++ b/www/vicidial/help_documentation.txt @@ -1,4 +1,4 @@ -# version: 20250326201901 +# version: 20250620085201 users-user User ID This field is where you put the users ID number, can be up to 20 digits in length, Must be at least 2 characters in length. We strongly recommend not reusing user accounts for different users, for reporting accuracy. To disable a user account, set the Active option to -N-. users-pass Password This field is where you put the users password. Must be at least 2 characters in length, unless the User Password Minimum Length system setting is enabled, which will require a longer password. Only letters and numbers are allowed in user passwords. A medium strength user password will be at least 10 characters in length, and a strong user password will be at least 20 characters in length and have letters as well as at least one number. It is recommended that you use a longer password if possible, stringing together several unrelated words with no spaces, and a number somewhere in the string. The maximum size of a password is 100 characters. users-force_change_password Force Change Password If this option is set to Y then the user will be prompted to change their password the next time they log in to the administration webpage or the agent screen. Default is N. @@ -470,6 +470,7 @@ lists-drop_inbound_group_override Drop Inbound Group Override If this field lists-status_group_id Status Group Override If this field is set, this Status Group will be used instead of the campaign statuses for calls handled by agents from this list. This does not affect System Statuses which will always be shown. Statuses defined within this status group will not be available with Campaign HotKeys unless they are defined in Campaign Statuses. Default is not set. lists-web_form_address Web Form Override This is the custom address that clicking on the WEB FORM button in the agent screen will take you to for calls that come in on this list. If you want to use custom fields in a web form address, you need to add &CF_uses_custom_fields=Y as part of your URL. lists-na_call_url No Agent Call URL This web URL address is not seen by the agent, but if it is populated it is called every time a call that is not handled by an agent is hung up or transferred. Uses the same variables as the web form fields and scripts. --A--dispo--B-- can be used to retrieve the system-defined disposition for the call. This URL can NOT be a relative path. Default is blank. Custom Fields are not available with this feature. If you put ALT into this field and submit this form, you will be able to go to a separate page where you can define multiple URLs for this action as well as specific statuses that will trigger them. +lists-apinewlead_url API New Lead URL If this is set to a valid URL, this setting will override the System Setting of the same name and send a URL request every time a new lead is inserted through the -add_lead- non-agent API function for leads in this list. If this is set to ---DISABLED--- then it will override the system setting and send no URL request for new API leads in this list. Default is blank for deferring to the system setting. lists-auto_alt_threshold Auto Alt Threshold Override If Auto Alt-Number Dialing is enabled, and not set to MULTI_LEAD, then this setting will specify the number of call attempts to the lead after which the Auto Alt dialing will no longer place alternate number calls for a specific lead, if the lead is called after this number of attempts then only the main phone number will be called. This option overrides the campaign setting for this feature. Default is -1 for the override being disabled. lists-dial_prefix Dial Prefix Override This setting will override the campaign Dial Prefix, the campaign Manual Dial Prefix and API dial prefix for calls placed in that campaign to leads within this list. Default is -blank- for disabled. lists-xferconf_a_dtmf Xfer-Conf Number Override These five fields allow for you to override the Transfer Conference number presets when the lead is from this list. Default is blank. @@ -1151,6 +1152,7 @@ settings-active_voicemail_server Active Voicemail Server In multi-server sy settings-allow_voicemail_greeting Allow Voicemail Greeting Chooser If this setting is enabled it will allow you to choose an audio file from the audio store to be played as the voicemail greeting to a specific voicemail box. Default is 0 for disabled. settings-outbound_autodial_active Outbound Auto-Dial Active This option allows you to enable or disable outbound auto-dialing within the system, setting this field to 0 will remove the LISTS and FILTERS sections and many fields from the Campaign Modification screens. Manual entry dialing will still be allowable from within the agent screen, but no list dialing will be possible. Default is 1 for active. settings-hopper_hold_inserts Lead Hopper Hold Inserts Allowed If enabled, this setting will allow campaigns to be set to insert leads into the hopper as a RHOLD status so that they can be activated by a separate process. The -2- option will also allow the AUTONEXT campaign setting. Default is 0 for disabled. +settings-apinewlead_url API New Lead URL If this is set to a valid URL, this setting will send a URL request every time a new lead is inserted through the -add_lead- non-agent API function. There is also a corresponding -List Override- setting for this option. Default is blank for disabled. settings-allow_shared_dial Shared Agent Campaign Dialing This option will allow you to set SHARED campaign Dial Methods in order to share agents across multiple outbound campaigns. For more details on how to set this up properly, read the AGENT_MULTI-CAMPAIGN_DIALING.txt document. Default is 0 for disabled. settings-agent_search_method Agent Search Method Override This option will allow you to override the agent search method that is defined in the dialplan on your dialers on a per in-group and-or per campaign basis. Setting this to -1- will enable the override for both in-groups and campaigns. -2- will enable only for in-groups. -3- will enable only for campaigns. Default is 0 for disabled. WARNING, we do not recommend enabling this setting, it can lead to greatly increased dropped calls if improperly used. settings-ofcom_uk_drop_calc UK OFCOM Drop Calculation This option allows you to enable the new UK OFCOM Drop calculation formula for individual campaigns. As of December 2015, OFCOM in the UK changed their method for calculating the drop,or abandon, percentage for an outbound dialing campaign. The new formula includes an estimate of the number of drops that were answering machines. They do this by using the agent-answered percentage of answering machines and subtracting that percentage from the number of drops. Then that new drop number is divided by the total agent-answered human-answered calls PLUS the number of drops. This differs in several ways from the way it had been done, as well as the way the drop percentage has been calculated in the USA and Canada. This new UK drop calculation method can be activated as a system setting AND a campaign option. Both must be enabled for the campaign to use the new method. In order for agent-statused answering machines to be calculated properly, we have added an answering machine status flag that is used to gather those statuses. Default is 0 for inactive. diff --git a/www/vicidial/non_agent_api.php b/www/vicidial/non_agent_api.php index 0998a96f..ba735d02 100644 --- a/www/vicidial/non_agent_api.php +++ b/www/vicidial/non_agent_api.php @@ -223,10 +223,11 @@ # 250105-1001 - Added enhanced_agent_monitoring option compatibility # 250130-1130 - Changed vicidial_daily_rt_monitor_log to vicidial_daily_rt_monitorING_log to match SQL file # 250516-1047 - Changed ksort to uksort so array sorting by key is alphabetic, case-INsensitive +# 250620-1007 - Added apinewlead_url requests for add_lead when new leads are inserted # -$version = '2.14-200'; -$build = '250516-1047'; +$version = '2.14-201'; +$build = '250620-1007'; $php_script='non_agent_api.php'; $api_url_log = 0; $camp_lead_order_random=1; @@ -16150,6 +16151,7 @@ if ($function == 'add_lead') } ### BEGIN custom fields insert section ### + $FORMcustom_field_names=''; if ($custom_fields == 'Y') { if ($custom_fields_enabled > 0) @@ -16219,6 +16221,7 @@ if ($function == 'add_lead') {$A_field_valueSQL[$o] = $A_field_value[$o];} $CFinsert_SQL .= "$A_field_label[$o]=\"$A_field_valueSQL[$o]\","; + $FORMcustom_field_names .= "$A_field_label[$o]|"; } } $o++; @@ -16416,6 +16419,273 @@ if ($function == 'add_lead') } } ### END scheduled callback section ### + + ### BEGIN apinewlead section ### + $apinewlead_url=''; + $apinewlead_url_LIST=''; + $apinewlead_url_STSTEM=''; + $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_STSTEM = $rowx[0]; + } + $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_LIST = $rowx[0]; + } + if ( (strlen($apinewlead_url_STSTEM) > 0) and (strlen($apinewlead_url_LIST) < 1) ) + {$apinewlead_url = $apinewlead_url_STSTEM;} + if ( (strlen($apinewlead_url_LIST) > 0) and ($apinewlead_url_LIST != '---DISABLED---') ) + {$apinewlead_url = $apinewlead_url_LIST;} + + # request apinewlead_url URL + if (strlen($apinewlead_url) > 10) + { + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner,entry_list_id FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysqli_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $entry_date = urlencode(trim($row[1])); + $status = urlencode(trim($row[3])); + $tsr = urlencode(trim($row[4])); + $vendor_id = urlencode(trim($row[5])); + $vendor_lead_code = urlencode(trim($row[5])); + $source_id = urlencode(trim($row[6])); + $list_id = urlencode(trim($row[7])); + $gmt_offset_now = urlencode(trim($row[8])); + $phone_code = urlencode(trim($row[10])); + $phone_number = urlencode(trim($row[11])); + $title = urlencode(trim($row[12])); + $first_name = urlencode(trim($row[13])); + $middle_initial = urlencode(trim($row[14])); + $last_name = urlencode(trim($row[15])); + $address1 = urlencode(trim($row[16])); + $address2 = urlencode(trim($row[17])); + $address3 = urlencode(trim($row[18])); + $city = urlencode(trim($row[19])); + $state = urlencode(trim($row[20])); + $province = urlencode(trim($row[21])); + $postal_code = urlencode(trim($row[22])); + $country_code = urlencode(trim($row[23])); + $gender = urlencode(trim($row[24])); + $date_of_birth = urlencode(trim($row[25])); + $alt_phone = urlencode(trim($row[26])); + $email = urlencode(trim($row[27])); + $security_phrase = urlencode(trim($row[28])); + $comments = urlencode(trim($row[29])); + $called_count = urlencode(trim($row[30])); + $call_date = urlencode(trim($row[31])); + $rank = urlencode(trim($row[32])); + $owner = urlencode(trim($row[33])); + $entry_list_id = urlencode(trim($row[34])); + } + + if (preg_match('/list_name--B--|list_description--B--|campaign--B--/i',$apinewlead_url)) + { + $stmt = "SELECT list_name,list_description,campaign_id from vicidial_lists where list_id='$list_id' limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $VL_ln_ct = mysqli_num_rows($rslt); + if ($VL_ln_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $list_name = urlencode(trim($row[0])); + $list_description = urlencode(trim($row[1])); + $list_campaign = urlencode(trim($row[2])); + } + } + + $apinewlead_url = preg_replace('/^VAR/','',$apinewlead_url); + $apinewlead_url = preg_replace('/--A--lead_id--B--/i',"$lead_id",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--vendor_id--B--/i',"$vendor_id",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--vendor_lead_code--B--/i',"$vendor_lead_code",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--list_id--B--/i',"$list_id",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--list_name--B--/i',"$list_name",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--list_description--B--/i',"$list_description",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--gmt_offset_now--B--/i',"$gmt_offset_now",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--phone_code--B--/i',"$phone_code",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--phone_number--B--/i',"$phone_number",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--title--B--/i',"$title",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--first_name--B--/i',"$first_name",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--middle_initial--B--/i',"$middle_initial",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--last_name--B--/i',"$last_name",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--address1--B--/i',"$address1",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--address2--B--/i',"$address2",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--address3--B--/i',"$address3",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--city--B--/i',"$city",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--state--B--/i',"$state",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--province--B--/i',"$province",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--postal_code--B--/i',"$postal_code",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--country_code--B--/i',"$country_code",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--gender--B--/i',"$gender",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--date_of_birth--B--/i',"$date_of_birth",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--alt_phone--B--/i',"$alt_phone",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--email--B--/i',"$email",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--security_phrase--B--/i',"$security_phrase",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--comments--B--/i',"$comments",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--user--B--/i',"$tsr",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--campaign--B--/i',"$list_campaign",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--SQLdate--B--/i',urlencode(trim($SQLdate)),$apinewlead_url); + $apinewlead_url = preg_replace('/--A--epoch--B--/i',"$epoch",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--phone--B--/i',"$phone_number",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--source_id--B--/i',"$source_id",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--status--B--/i',"$status",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--rank--B--/i',"$rank",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--owner--B--/i',"$owner",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--entry_list_id--B--/i',"$entry_list_id",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--entry_date--B--/i',"$entry_date",$apinewlead_url); + $apinewlead_url = preg_replace('/--A--called_count--B--/i',"$called_count",$apinewlead_url); + + if ($custom_insert_count > 0) + { + $custom_field_names = preg_replace("/^\||\|$/",'',$FORMcustom_field_names); + $custom_field_names = preg_replace("/\|.*_DUPLICATE_.*\|/",'|',$custom_field_names); + $custom_field_names = preg_replace("/\|/",",",$custom_field_names); + $custom_field_names_ARY = explode(',',$custom_field_names); + $custom_field_names_ct = count($custom_field_names_ARY); + $custom_field_names_SQL = $custom_field_names; + + if (preg_match("/cf_encrypt/",$active_modules)) + { + $enc_fields=0; + $stmt = "SELECT count(*) from vicidial_lists_fields where field_encrypt='Y' and list_id='$entry_list_id';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $enc_field_ct = mysqli_num_rows($rslt); + if ($enc_field_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $enc_fields = $row[0]; + } + if ($enc_fields > 0) + { + $stmt = "SELECT field_label from vicidial_lists_fields where field_encrypt='Y' and list_id='$entry_list_id';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $enc_field_ct = mysqli_num_rows($rslt); + $r=0; + while ($enc_field_ct > $r) + { + $row=mysqli_fetch_row($rslt); + $encrypt_list .= "$row[0],"; + $r++; + } + $encrypt_list = ",$encrypt_list"; + } + } + + ##### BEGIN grab the data from custom table for the lead_id + if ($entry_list_id > 0) + { + $stmt="SELECT $custom_field_names_SQL FROM custom_$entry_list_id where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00753',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysqli_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $o=0; + while ($custom_field_names_ct > $o) + { + $field_name_id = $custom_field_names_ARY[$o]; + $field_name_tag = "--A--" . $field_name_id . "--B--"; + if ($enc_fields > 0) + { + $field_enc=''; $field_enc_all=''; + if ($DB) {echo "|$column_list|$encrypt_list|\n";} + if ( (preg_match("/,$field_name_id,/",$encrypt_list)) and (strlen($row[$o]) > 0) ) + { + exec("../agc/aes.pl --decrypt --text=$row[$o]", $field_enc); + $field_enc_ct = count($field_enc); + $k=0; + while ($field_enc_ct > $k) + { + $field_enc_all .= $field_enc[$k]; + $k++; + } + $field_enc_all = preg_replace("/CRYPT: |\n|\r|\t/",'',$field_enc_all); + $row[$o] = base64_decode($field_enc_all); + } + } + $form_field_value = urlencode(trim("$row[$o]")); + + ### Check for dispo filter, run if enabled and field matches + if ( ($dispo_filter_enabled > 0) and (preg_match("/\|$field_name_id\|/",$df_fields)) ) + { + $dct=0; + while ($dispo_filters_ct > $dct) + { + $temp_df = explode(',',$dispo_filters[$dct]); + $lm=0; + + if ( (preg_match("/^$field_name_id$/i",$temp_df[0])) and ($form_field_value == $temp_df[1]) ) {$form_field_value = $temp_df[2]; $lm++;} + + if ($DB) {echo "DF-Debug 3: $dct|$lm|$temp_df[0]($field_name_id)|$temp_df[1]($form_field_value)|$temp_df[2]|\n";} + $dct++; + } + } + $apinewlead_url = preg_replace("/$field_name_tag/i","$form_field_value",$apinewlead_url); + $o++; + } + } + } + } + + ### insert a new url log entry + $stmt = "INSERT INTO vicidial_url_log SET uniqueid='$lead_id',url_date=NOW(),url_type='apinewlead',url='" . mysqli_real_escape_string($link, $apinewlead_url) . "',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"); + + ### send dispo_call_url ### + if ($DB > 0) {echo "$apinewlead_url
\n";} + + $SCUfile = file("$apinewlead_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]
\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); + } + ### END apinewlead section ### } else {