diff --git a/agc_2-X/trunk/docs/SIP_EVENT_LOGGING.txt b/agc_2-X/trunk/docs/SIP_EVENT_LOGGING.txt index ce4089ad..357b06bd 100644 --- a/agc_2-X/trunk/docs/SIP_EVENT_LOGGING.txt +++ b/agc_2-X/trunk/docs/SIP_EVENT_LOGGING.txt @@ -1,4 +1,4 @@ -SIP EVENT LOGGING DOC Started: 2019-05-30 Updated: 2019-06-09 +SIP EVENT LOGGING DOC Started: 2019-05-30 Updated: 2019-07-30 !!!! THIS IS AN EXPERIMENTAL FEATURE, PLEASE READ ALL IMPORTANT NOTES !!!! @@ -13,6 +13,7 @@ For phase 1 of this project, the basic framework of logging the SIP messages on For phase 2 of this project, we added some basic reporting(AST_SIP_event_report.php) which can show the summary details of every Answered call on the system with pop-up displays for all of the SIP events that happened on each call as well as a link to the modify lead page where you can also see the SIP events for every call to that lead(the SIP events are only stored for 7 days). +ADDED 2019-07-24: The new campaign "SIP Event Actions" settings will allow you to define specific actions to happen depending on what is in the SIP Event Log for each call. Initially this feature will only affect manual dial agent screen calls, for example, allowing you to automatically hang up manual dial calls that take less than one seccond from the dial event to the answer. See the "Campaign SIP Event Actions" section below for more information. @@ -82,12 +83,46 @@ Scripts modified/added: - bin/ADMIN_archive_log_tables.pl - www/vicidial/AST_SIP_event_report.php - www/vicidial/admin_modify_lead.php +- www/vicidial/admin.php +- www/agc/vicidial.php +- www/agc/vdc_db_query.php +- www/agc/conf_exten_check.php - install.pl +Campaign SIP Event Actions: + +This is designed to be a set of features that will allow for flexible configuration of different actions that are to be taken on calls based upon their SIP event logs. + +The first action of this feature to be enabled is the ability to set agent screen manual dial calls to be hung up if certain criteria are met, for example, less than 1 second from dial to answer. + + +This set of features is configured using a Settings Container of the "SIP_EVENT_ACTIONS" type, which you define in the Campaign Detail screen "SIP Event Actions" setting. + + +Example SIP_EVENT_ACTIONS Settings Container: + +; agent screen actions +AGENT_SCREEN_ACTIONS_START +invite_to_final => 0.0,1.0,hangup-dispo-message,FAS,Auto Hangup and Dispo of False Answer Call +AGENT_SCREEN_ACTIONS_FINISH + + + +Settings within agent screen actions: +1. time range start - a number with 1-6 decimal places +2. time range finish - a number with 1-6 decimal places +3. agent screen action taken - any combination of the following: 'hangup', 'dispo', 'message' separated by dashes +4. If 'dispo' is included in #3, then this is the dispo set +5. If 'message' is included in #3, then this is the message sent to the agent + + +If you include a message, it will be displayed on the agent's screen for 4 seconds then it will automatically disappear. + + @@ -96,6 +131,8 @@ Scripts modified/added: ALTER TABLE system_settings ADD sip_event_logging ENUM('0','1','2','3','4','5','6','7') default '0'; +ALTER TABLE vicidial_campaigns ADD sip_event_logging VARCHAR(40) default 'DISABLED'; + CREATE TABLE vicidial_sip_event_log ( sip_event_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL, caller_code VARCHAR(30) NOT NULL, diff --git a/agc_2-X/trunk/www/agc/conf_exten_check.php b/agc_2-X/trunk/www/agc/conf_exten_check.php index 103e3e7a..ec5dfbb1 100644 --- a/agc_2-X/trunk/www/agc/conf_exten_check.php +++ b/agc_2-X/trunk/www/agc/conf_exten_check.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2019 Matt Florell LICENSE: AGPLv2 # # This script is designed purely to send whether the meetme conference has live channels connected and which they are # This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table @@ -80,13 +80,14 @@ # 170709-1017 - Added xfer dead call checking process # 170817-0739 - Small change to xfer dead call checking process # 180602-0149 - Changed SQL query for email queue count for accuracy +# 190730-0927 - Added campaign SIP Actions processing # -$version = '2.14-54'; -$build = '170817-0739'; +$version = '2.14-55'; +$build = '190730-0927'; $php_script = 'conf_exten_check.php'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=46; +$mysql_log_count=51; $one_mysql_log=0; $DB=0; $VD_login=0; @@ -133,6 +134,12 @@ if (isset($_GET["live_call_seconds"])) {$live_call_seconds=$_GET["live_call_se elseif (isset($_POST["live_call_seconds"])) {$live_call_seconds=$_POST["live_call_seconds"];} if (isset($_GET["xferchannel"])) {$xferchannel=$_GET["xferchannel"];} elseif (isset($_POST["xferchannel"])) {$xferchannel=$_POST["xferchannel"];} +if (isset($_GET["check_for_answer"])) {$check_for_answer=$_GET["check_for_answer"];} + elseif (isset($_POST["check_for_answer"])) {$check_for_answer=$_POST["check_for_answer"];} +if (isset($_GET["MDnextCID"])) {$MDnextCID=$_GET["MDnextCID"];} + elseif (isset($_POST["MDnextCID"])) {$MDnextCID=$_POST["MDnextCID"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} if ($bcrypt == 'OFF') {$bcrypt=0;} @@ -869,7 +876,140 @@ if ($ACTION == 'refresh') } } - echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Logged-in: ' . $Alogin . '|CampCalls: ' . $RingCalls . '|Status: ' . $Astatus . '|DiaLCalls: ' . $DiaLCalls . '|APIHanguP: ' . $external_hangup . '|APIStatuS: ' . $external_status . '|APIPausE: ' . $external_pause . '|APIDiaL: ' . $external_dial . '|DEADcall: ' . $DEADcustomer . '|InGroupChange: ' . $InGroupChangeDetails . '|APIFields: ' . $external_update_fields . '|APIFieldsData: ' . $external_update_fields_data . '|APITimerAction: ' . $timer_action . '|APITimerMessage: ' . $timer_action_message . '|APITimerSeconds: ' . $timer_action_seconds . '|APIdtmf: ' . $external_dtmf . '|APItransferconf: ' . $external_transferconf . '|APIpark: ' . $external_park . '|APITimerDestination: ' . $timer_action_destination . '|APIManualDialQueue: ' . $MDQ_count . '|APIRecording: ' . $external_recording . '|APIPaUseCodE: ' . $external_pause_code . '|WaitinGChats: ' . $WaitinGChats . '|WaitinGEmails: ' . $WaitinGEmails . '|LivEAgentCommentS: ' . $live_agents_comments . '|LeadIDSwitch: ' . $external_lead_id .'|DEADxfer: '.$DEADxfer. "\n"; + //Check for call answer + $CHANanswer='0-----'; + if ( ($check_for_answer > 0) and (strlen($MDnextCID) > 18) ) + { + $dial_time = 0; + $sip_event_action_output=''; + $stmt = "SELECT invite_date,UNIX_TIMESTAMP(first_180_date),UNIX_TIMESTAMP(first_183_date),UNIX_TIMESTAMP(200_date),TIMESTAMPDIFF(MICROSECOND,invite_date,200_date) as dial,TIMESTAMPDIFF(MICROSECOND,invite_date,first_180_date) as prog,TIMESTAMPDIFF(MICROSECOND,invite_date,first_183_date) as pdd from vicidial_sip_event_recent where caller_code='$MDnextCID' LIMIT 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03047',$user,$server_ip,$session_name,$one_mysql_log);} + $VSER_ct = mysqli_num_rows($rslt); + if ($VSER_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $invite_date = $row[0]; + $first_180_date = $row[1]; + $first_183_date = $row[2]; + $sip200_date = $row[3]; + $dial_time = $row[4]; + $time_to_progress = $row[5]; + $time_to_ring = $row[6]; + if ( ($first_180_date > 0) and ($first_180_date != 'NULL') and ($first_183_date > 0) and ($first_183_date != 'NULL')) + {if ($first_180_date > $first_183_date) {$time_to_progress=$time_to_ring;}} + + if ( ($dial_time > 0) and ($dial_time != 'NULL') ) + { + if ( ($time_to_progress > 0) and ($time_to_progress != 'NULL') ) + { + if ( ($dial_time <= 0) or ($dial_time == 'NULL') ) + {$dial_time = $time_to_progress;} + $invite_to_ring = $time_to_progress; + $ring_to_final = ($dial_time - $invite_to_ring); + } + else + { + if ( ($time_to_ring > 0) and ($time_to_ring != 'NULL') ) + { + if ( ($dial_time <= 0) or ($dial_time == 'NULL') ) + {$dial_time = $time_to_ring;} + $invite_to_ring = $time_to_ring; + $ring_to_final = ($dial_time - $invite_to_ring); + } + else + { + $invite_to_ring = 0; + $ring_to_final = 0; + } + } + + if ($invite_to_ring != '0') {$invite_to_ring = ($invite_to_ring / 1000000);} + if ($ring_to_final != '0') {$ring_to_final = ($ring_to_final / 1000000);} + if ($dial_time != '0') {$dial_time = ($dial_time / 1000000);} + + # insert a record into the vicidial_log_extended_sip table for this call + $stmt = "INSERT INTO vicidial_log_extended_sip SET call_date='$invite_date', caller_code='$MDnextCID', invite_to_ring='$invite_to_ring', ring_to_final='$ring_to_final', invite_to_final='$dial_time', last_event_code='200';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03048',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rowsX = mysqli_affected_rows($link); + + # flag the vicidial_sip_event_recent record as processed + $stmt = "UPDATE vicidial_sip_event_recent set processed='Y' where caller_code='$MDnextCID' LIMIT 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03049',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rowsX = mysqli_affected_rows($link); + + + ### BEGIN check for SIP event log actions ### + $CAMPsip_event_logging='DISABLED'; + $invite_to_final=''; + $stmt = "SELECT sip_event_logging FROM vicidial_campaigns where campaign_id='$campaign';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03050',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $csel_ct = mysqli_num_rows($rslt); + if ($csel_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $CAMPsip_event_logging = $row[0]; + } + + if ( (strlen($CAMPsip_event_logging) > 0) and ($CAMPsip_event_logging != 'DISABLED') ) + { + # gather Sip event settings container + $stmt = "SELECT container_entry FROM vicidial_settings_containers where container_id='$CAMPsip_event_logging';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03051',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $SCinfo_ct = mysqli_num_rows($rslt); + if ($SCinfo_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $SAcontainer_entry = $row[0]; + $SAcontainer_entry = preg_replace("/\r|\t|\'|\"/",'',$SAcontainer_entry); + $sip_action_settings = explode("\n",$SAcontainer_entry); + $sip_action_settings_ct = count($sip_action_settings); + $sea=0; + while ($sip_action_settings_ct >= $sea) + { + if (preg_match("/^invite_to_final => /",$sip_action_settings[$sea])) + { + # invite_to_final => 0.0,1.0,hangup-dispo-message,FAS,Auto Hangup and Dispo of False Answer Call + $sip_action_settings[$sea] = preg_replace("/invite_to_final => /",'',$sip_action_settings[$sea]); + $invite_to_finalARY = explode(",",$sip_action_settings[$sea]); + $T_dial_time = floatval($dial_time); + $itf_begin = floatval($invite_to_finalARY[0]); + $itf_end = floatval($invite_to_finalARY[1]); + $itf_actions = $invite_to_finalARY[2]; + $itf_dispo = $invite_to_finalARY[3]; + $itf_message = $invite_to_finalARY[4]; + if ( ($T_dial_time >= $itf_begin) and ($T_dial_time <= $itf_end) and (strlen($itf_actions) > 4) ) + { + # $call_output = "$uniqueid\n$channel\nERROR\n" . $hangup_cause_msg . "\n
" . $sip_hangup_cause_msg; + $sip_event_action_output = "SIP ACTION-----" . $itf_actions . "-----" . $itf_dispo . "-----" . $itf_message; + } + } + $sea++; + } + } + } + ### END check for SIP event log actions ### + $CHANanswer = "1-----" . $sip_event_action_output; + + # SIP event debug logging + # $fp = fopen ("./SELdebug_log.txt", "a"); + # fwrite ($fp, "$NOW_TIME SEL-CCC-Debug 1, chan-check: $check_for_answer|$MDnextCID|$invite_date|$sip200_date|$dial_time|$time_to_progress|$time_to_ring|\n"); + # fclose($fp); + } + } + } + + + echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Logged-in: ' . $Alogin . '|CampCalls: ' . $RingCalls . '|Status: ' . $Astatus . '|DiaLCalls: ' . $DiaLCalls . '|APIHanguP: ' . $external_hangup . '|APIStatuS: ' . $external_status . '|APIPausE: ' . $external_pause . '|APIDiaL: ' . $external_dial . '|DEADcall: ' . $DEADcustomer . '|InGroupChange: ' . $InGroupChangeDetails . '|APIFields: ' . $external_update_fields . '|APIFieldsData: ' . $external_update_fields_data . '|APITimerAction: ' . $timer_action . '|APITimerMessage: ' . $timer_action_message . '|APITimerSeconds: ' . $timer_action_seconds . '|APIdtmf: ' . $external_dtmf . '|APItransferconf: ' . $external_transferconf . '|APIpark: ' . $external_park . '|APITimerDestination: ' . $timer_action_destination . '|APIManualDialQueue: ' . $MDQ_count . '|APIRecording: ' . $external_recording . '|APIPaUseCodE: ' . $external_pause_code . '|WaitinGChats: ' . $WaitinGChats . '|WaitinGEmails: ' . $WaitinGEmails . '|LivEAgentCommentS: ' . $live_agents_comments . '|LeadIDSwitch: ' . $external_lead_id .'|DEADxfer: '.$DEADxfer .'|CHANanswer: '.$CHANanswer. "\n"; if (strlen($timer_action) > 3) { diff --git a/agc_2-X/trunk/www/agc/vdc_db_query.php b/agc_2-X/trunk/www/agc/vdc_db_query.php index d3bd38e7..22952138 100644 --- a/agc_2-X/trunk/www/agc/vdc_db_query.php +++ b/agc_2-X/trunk/www/agc/vdc_db_query.php @@ -477,13 +477,14 @@ # 190627-1535 - Added new options for campaign agent_screen_time_display feature # 190709-1846 - Added Call Quota logging # 190722-1658 - Added ENABLED_EXTENDED_RANGE Agent Screen Time Display option +# 190730-0926 - Added campaign SIP Actions processing # -$version = '2.14-371'; -$build = '190722-1658'; +$version = '2.14-372'; +$build = '190730-0926'; $php_script = 'vdc_db_query.php'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=797; +$mysql_log_count=808; $one_mysql_log=0; $DB=0; $VD_login=0; @@ -6727,11 +6728,12 @@ if ($ACTION == 'manDiaLlookCaLL') if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00742',$user,$server_ip,$session_name,$one_mysql_log);} } + $sip_event_action_output=''; ##### BEGIN SIP event logging, if enabled in the system ##### if ($SSsip_event_logging > 0) { ##### insert log into vicidial_log_extended for manual VICIDiaL call - $stmt="UPDATE vicidial_sip_event_recent set processed='U' where caller_code='$MDnextCID' LIMIT 1;;"; + $stmt="UPDATE vicidial_sip_event_recent set processed='U' where caller_code='$MDnextCID' LIMIT 1;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00794',$user,$server_ip,$session_name,$one_mysql_log);} @@ -6800,13 +6802,77 @@ if ($ACTION == 'manDiaLlookCaLL') $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00797',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rowsX = mysqli_affected_rows($link); + + + ### BEGIN check for SIP event log actions ### + $CAMPsip_event_logging='DISABLED'; + $invite_to_final=''; + $stmt = "SELECT sip_event_logging FROM vicidial_campaigns where campaign_id='$campaign';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00798',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $csel_ct = mysqli_num_rows($rslt); + if ($csel_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $CAMPsip_event_logging = $row[0]; + } + + if ( (strlen($CAMPsip_event_logging) > 0) and ($CAMPsip_event_logging != 'DISABLED') ) + { + # gather Sip event settings container + $stmt = "SELECT container_entry FROM vicidial_settings_containers where container_id='$CAMPsip_event_logging';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00799',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $SCinfo_ct = mysqli_num_rows($rslt); + if ($SCinfo_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $SAcontainer_entry = $row[0]; + $SAcontainer_entry = preg_replace("/\r|\t|\'|\"/",'',$SAcontainer_entry); + $sip_action_settings = explode("\n",$SAcontainer_entry); + $sip_action_settings_ct = count($sip_action_settings); + $sea=0; + while ($sip_action_settings_ct >= $sea) + { + if (preg_match("/^invite_to_final => /",$sip_action_settings[$sea])) + { + # invite_to_final => 0.0,1.0,hangup-dispo-message,FAS,Auto Hangup and Dispo of False Answer Call + $sip_action_settings[$sea] = preg_replace("/invite_to_final => /",'',$sip_action_settings[$sea]); + $invite_to_finalARY = explode(",",$sip_action_settings[$sea]); + $T_dial_time = floatval($dial_time); + $itf_begin = floatval($invite_to_finalARY[0]); + $itf_end = floatval($invite_to_finalARY[1]); + $itf_actions = $invite_to_finalARY[2]; + $itf_dispo = $invite_to_finalARY[3]; + $itf_message = $invite_to_finalARY[4]; + if ( ($T_dial_time >= $itf_begin) and ($T_dial_time <= $itf_end) and (strlen($itf_actions) > 4) ) + { + # $call_output = "$uniqueid\n$channel\nERROR\n" . $hangup_cause_msg . "\n
" . $sip_hangup_cause_msg; + $sip_event_action_output = "SIP ACTION\n" . $itf_actions . "\n" . $itf_dispo . "\n" . $itf_message; + } + } + $sea++; + } + } + } + ### END check for SIP event log actions ### + } + else + { + # SIP event debug logging + # $fp = fopen ("./SELdebug_log.txt", "a"); + # fwrite ($fp, "$NOW_TIME SEL-Debug 0, No 200: $invite_date|$sip200_date|$dial_time|$time_to_progress|$time_to_ring|\n"); + # fclose($fp); + # $sip_event_action_output = "CALL UNANSWERED\n"; } } } } ##### END SIP event logging, if enabled in the system ##### - echo "$call_output"; + echo "$call_output$sip_event_action_output"; $stage .= " $uniqueid $channel"; } @@ -12202,9 +12268,9 @@ if ($ACTION == 'updateDISPO') ### BEGIN Call Quota Lead Renking logging ### - $fp = fopen ("./CQdebug_log.txt", "a"); - fwrite ($fp, "$NOW_TIME CQ-Debug 0: $call_quota_lead_ranking|$call_type|\n"); - fclose($fp); + # $fp = fopen ("./CQdebug_log.txt", "a"); + # fwrite ($fp, "$NOW_TIME CQ-Debug 0: $call_quota_lead_ranking|$call_type|\n"); + # fclose($fp); if ( ($call_quota_lead_ranking != 'DISABLED') and ($call_type == 'OUT') and ($SScall_quota_lead_ranking > 0) ) { $call_quota_sessions_valid=0; @@ -12213,7 +12279,7 @@ if ($ACTION == 'updateDISPO') # Gather details on the campaign's Call Quota settings container $stmt = "SELECT container_entry FROM vicidial_settings_containers where container_id='$call_quota_lead_ranking';"; $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);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00800',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $SCinfo_ct = mysqli_num_rows($rslt); if ($SCinfo_ct > 0) @@ -12281,16 +12347,16 @@ if ($ACTION == 'updateDISPO') } $cql++; } - $fp = fopen ("./CQdebug_log.txt", "a"); - fwrite ($fp, "$NOW_TIME CQ-Debug 1: $call_quota_settings_ct|$call_quota_lead_ranking|$call_quota_sessions_valid|\n"); - fclose($fp); + # $fp = fopen ("./CQdebug_log.txt", "a"); + # fwrite ($fp, "$NOW_TIME CQ-Debug 1: $call_quota_settings_ct|$call_quota_lead_ranking|$call_quota_sessions_valid|\n"); + # fclose($fp); if ($call_quota_sessions_valid > 0) { # Gather list ID and called count for this lead $stmt = "SELECT list_id,called_count,rank FROM vicidial_list where lead_id='$lead_id';"; $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);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00801',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $VLinfo_ct = mysqli_num_rows($rslt); if ($VLinfo_ct > 0) @@ -12306,7 +12372,7 @@ if ($ACTION == 'updateDISPO') # Gather the date/time this call was dialed $stmt = "SELECT call_date from vicidial_dial_log where lead_id='$lead_id' and call_date > \"$four_hours_ago\" and caller_code LIKE \"%$lead_id\" order by call_date desc limit 1;"; $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);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00802',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $VDLinfo_ct = mysqli_num_rows($rslt); if ($VDLinfo_ct > 0) @@ -12355,9 +12421,9 @@ if ($ACTION == 'updateDISPO') $session_updateSQL=",session_six_calls=(session_six_calls + 1),session_six_today_calls=(session_six_today_calls + 1)"; } - $fp = fopen ("./CQdebug_log.txt", "a"); - fwrite ($fp, "$NOW_TIME CQ-Debug 2: $VDLcall_datetime|$VDLcall_hourmin|$timeclock_end_of_day|$session_one_start|$session_one_end|$call_in_session|\n"); - fclose($fp); + # $fp = fopen ("./CQdebug_log.txt", "a"); + # fwrite ($fp, "$NOW_TIME CQ-Debug 2: $VDLcall_datetime|$VDLcall_hourmin|$timeclock_end_of_day|$session_one_start|$session_one_end|$call_in_session|\n"); + # fclose($fp); if ($call_in_session > 0) { @@ -12377,7 +12443,7 @@ if ($ACTION == 'updateDISPO') # Gather the details on existing vicidial_lead_call_quota_counts for this lead, if there is one $stmt = "SELECT first_call_date,UNIX_TIMESTAMP(first_call_date),last_call_date from vicidial_lead_call_quota_counts where lead_id='$lead_id' and list_id='$VLlist_id';"; $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);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00803',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $VLCQCinfo_ct = mysqli_num_rows($rslt); if ($VLCQCinfo_ct > 0) @@ -12412,7 +12478,7 @@ if ($ACTION == 'updateDISPO') } if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00804',$VD_login,$server_ip,$session_name,$one_mysql_log);} $VLCQCaffected_rows_update = mysqli_affected_rows($link); } else @@ -12421,7 +12487,7 @@ if ($ACTION == 'updateDISPO') $stmt="INSERT INTO vicidial_lead_call_quota_counts SET lead_id='$lead_id',list_id='$VLlist_id',first_call_date='$VDLcall_datetime',last_call_date='$VDLcall_datetime',status='$dispo_choice',called_count='$VLcalled_count',day_one_calls='1',rank='$tempVLrank',modify_date=NOW() $session_newSQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00805',$VD_login,$server_ip,$session_name,$one_mysql_log);} $VLCQCaffected_rows_update = mysqli_affected_rows($link); } @@ -12432,13 +12498,13 @@ if ($ACTION == 'updateDISPO') $stmtR="UPDATE vicidial_list SET rank='0' where lead_id='$lead_id';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmtR, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtR,'00XXX',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtR,'00806',$VD_login,$server_ip,$session_name,$one_mysql_log);} $VLCQCaffected_rows_zero_rank = mysqli_affected_rows($link); } - $fp = fopen ("./CQdebug_log.txt", "a"); - fwrite ($fp, "$NOW_TIME CQ-Debug 3: $VLCQCaffected_rows_update|$stmt|$VLCQCaffected_rows_zero_rank|$stmtR|\n"); - fclose($fp); + # $fp = fopen ("./CQdebug_log.txt", "a"); + # fwrite ($fp, "$NOW_TIME CQ-Debug 3: $VLCQCaffected_rows_update|$stmt|$VLCQCaffected_rows_zero_rank|$stmtR|\n"); + # fclose($fp); } else { @@ -18064,7 +18130,7 @@ if ($ACTION == 'AGENTtimeREPORT') $archive_cutoff=0; $stmt="SELECT event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log order by agent_log_id limit 1;"; $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);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00807',$user,$server_ip,$session_name,$one_mysql_log);} $archive_check_to_print = mysqli_num_rows($rslt); if ($format=='debug') {echo "|$archive_check_to_print|$stmt|";} if ($archive_check_to_print > 0) @@ -18160,7 +18226,7 @@ if ($ACTION == 'AGENTtimeREPORT') $temp_date = date("Y-m-d",$temp_date_epoch); $stmt="SELECT pause_epoch,wait_epoch,talk_epoch,dispo_epoch,dead_epoch,pause_sec,wait_sec,talk_sec,dispo_sec,dead_sec,sub_status,agent_log_id,campaign_id from $vicidial_agent_log where user='$user' and event_time >= '$temp_date 00:00:00' and event_time <= '$temp_date 23:59:59' order by campaign_id desc limit 10000;"; $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);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00808',$user,$server_ip,$session_name,$one_mysql_log);} $time_logs_to_print = mysqli_num_rows($rslt); if ($format=='debug') {echo "|$stage|$time_logs_to_print|$stmt|";} diff --git a/agc_2-X/trunk/www/agc/vicidial.php b/agc_2-X/trunk/www/agc/vicidial.php index de79c891..58503547 100644 --- a/agc_2-X/trunk/www/agc/vicidial.php +++ b/agc_2-X/trunk/www/agc/vicidial.php @@ -615,10 +615,11 @@ # 190617-1116 - Fix for script variable issue # 190627-2134 - Added new options for campaign agent_screen_time_display feature # 190723-1655 - Fix for script tab custom fields +# 190730-0925 - Added campaign SIP Actions processing # -$version = '2.14-584c'; -$build = '190723-1655'; +$version = '2.14-585c'; +$build = '190730-0925'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=87; $one_mysql_log=0; @@ -4746,6 +4747,10 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} var script_span_zindex=0; var dead_auto_dispo_count=0; var dead_auto_dispo_finish=0; + var SIPaction_dispo_count=0; + var SIPaction_dispo_finish=0; + var MDcheck_for_answer=0; + var CIDcheck=''; var alt_dial_dispo_count=0 var pause_max_finish=0 var cid_lock=0; @@ -4780,6 +4785,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} var pause_resume_click_epoch=0; var previous_agent_log_id=''; var alert_box_close_counter=0; + var dial_box_close_counter=0; var api_switch_lead_triggered=0; var agent_xfer_validation=''; var agent_xfer_group_selected=''; @@ -5737,7 +5743,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection) } if (xmlhttprequestcheckconf) { - checkconf_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&client=vdc&conf_exten=" + taskconfnum + "&auto_dial_level=" + auto_dial_level + "&campagentstdisp=" + campagentstdisp + "&customer_chat_id=" + document.vicidial_form.customer_chat_id.value + "&live_call_seconds=" + VD_live_call_secondS + "&xferchannel=" + document.vicidial_form.xferchannel.value + "&clicks=" + button_click_log; + checkconf_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&client=vdc&conf_exten=" + taskconfnum + "&auto_dial_level=" + auto_dial_level + "&campagentstdisp=" + campagentstdisp + "&customer_chat_id=" + document.vicidial_form.customer_chat_id.value + "&live_call_seconds=" + VD_live_call_secondS + "&xferchannel=" + document.vicidial_form.xferchannel.value + "&check_for_answer=" + MDcheck_for_answer + "&MDnextCID=" + MDnextCID + "&campaign=" + campaign + "&clicks=" + button_click_log; button_click_log=''; xmlhttprequestcheckconf.open('POST', 'conf_exten_check.php'); xmlhttprequestcheckconf.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); @@ -5888,6 +5894,8 @@ function set_length(SLnumber,SLlength_goal,SLdirection) var api_switch_lead = APILeadSwitch_array[1]; var DEADxfer_array = check_time_array[31].split("DEADxfer: "); var DEADxfer = DEADxfer_array[1]; + var CHANanswer_array = check_time_array[32].split("CHANanswer: "); + var CHANanswer_detail = CHANanswer_array[1].split("-----"); var APIdtmf_array = check_time_array[20].split("APIdtmf: "); api_dtmf = APIdtmf_array[1]; var APItransfercond_array = check_time_array[21].split("APItransferconf: "); @@ -5902,6 +5910,56 @@ function set_length(SLnumber,SLlength_goal,SLdirection) var APIpark_array = check_time_array[22].split("APIpark: "); api_parkcustomer = APIpark_array[1]; + if (CHANanswer_detail[0] > 0) + { + if (CHANanswer_detail[1] == 'SIP ACTION') + { + var MDactionOption = CHANanswer_detail[2]; + var MDactionDispo = CHANanswer_detail[3]; + var MDactionMessage = CHANanswer_detail[4]; + var regSAmessage = new RegExp("message","ig"); + var regSAdispo = new RegExp("dispo","ig"); + var regSAhangup = new RegExp("hangup","ig"); + if (MDactionOption.match(regSAmessage)) + { + button_click_log = button_click_log + "" + SQLdate + "-----SIPeventMESSAGE---" + MDactionOption + "|"; + TimerActionRun("DiaLAlerT",MDactionMessage,3); + } + if (MDactionOption.match(regSAhangup)) + { + button_click_log = button_click_log + "" + SQLdate + "-----SIPeventHANGUP---" + MDactionOption + "|"; + dialedcall_send_hangup(); + if ( (MDactionOption.match(regSAdispo)) && (MDactionDispo.length > 0) ) + { + button_click_log = button_click_log + "" + SQLdate + "-----SIPeventDISPO---" + MDactionDispo + " " + MDactionOption + "|"; + CustomerData_update('NO'); + if ( (per_call_notes == 'ENABLED') && (comments_dispo_screen != 'REPLACE_CALL_NOTES') ) + { + var test_notesDE = document.vicidial_form.call_notes.value; + if (test_notesDE.length > 0) + {document.vicidial_form.call_notes_dispo.value = document.vicidial_form.call_notes.value} + } + + SIPaction_dispo_count=4; + SIPaction_dispo_finish=1; + alt_phone_dialing=starting_alt_phone_dialing; + alt_dial_active = 0; + alt_dial_status_display = 0; + document.vicidial_form.DispoSelection.value = MDactionDispo; + document.vicidial_form.DispoSelectStop.checked=true; + dialedcall_send_hangup('NO', 'NO', MDactionDispo); + if (custom_fields_enabled > 0) + { + customsubmit_trigger=1; + } + } + } + agent_events('agent_alert', "SIP Action: " + MDactionOption + ' ' + MDactionDispo, aec); aec++; + // document.getElementById("debugbottomspan").innerHTML = "
|" + manDiaLlook_query + "|
\n" + debug_response + "
\n" + MDactionOption; + } + MDcheck_for_answer=0; + } + if ( (DEADxfer > 0) && (CheckDEADcallON < 1) && (XD_live_customer_call > 0) ) { button_click_log = button_click_log + "" + SQLdate + "-----XferHungUp---" + document.vicidial_form.xferchannel.value + "|"; @@ -8624,7 +8682,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection) if ( (script_recording_delay < 1) && (routing_initiated_recording == 'Y') && ( (LIVE_campaign_recording == 'ALLCALLS') || (LIVE_campaign_recording == 'ALLFORCE') ) ) {temp_rir='Y';} - manDiaLlook_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=manDiaLlookCaLL&conf_exten=" + session_id + "&user=" + user + "&pass=" + pass + "&MDnextCID=" + CIDcheck + "&agent_log_id=" + agent_log_id + "&lead_id=" + document.vicidial_form.lead_id.value + "&DiaL_SecondS=" + MD_ring_secondS + "&stage=" + taskCheckOR + "&routing_initiated_recording=" + temp_rir; + manDiaLlook_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=manDiaLlookCaLL&conf_exten=" + session_id + "&user=" + user + "&pass=" + pass + "&MDnextCID=" + CIDcheck + "&agent_log_id=" + agent_log_id + "&lead_id=" + document.vicidial_form.lead_id.value + "&DiaL_SecondS=" + MD_ring_secondS + "&stage=" + taskCheckOR + "&campaign=" + campaign + "&routing_initiated_recording=" + temp_rir; xmlhttp.open('POST', 'vdc_db_query.php'); xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp.send(manDiaLlook_query); @@ -8635,9 +8693,9 @@ function set_length(SLnumber,SLlength_goal,SLdirection) var MDlookResponse = null; // alert(xmlhttp.responseText); - // var debug_response = xmlhttp.responseText; - // var REGcommentsDBNL = new RegExp("\n","g"); - // debug_response = debug_response.replace(REGcommentsDBNL, "
"); + var debug_response = xmlhttp.responseText; + var REGcommentsDBNL = new RegExp("\n","g"); + debug_response = debug_response.replace(REGcommentsDBNL, "
"); // document.getElementById("debugbottomspan").innerHTML = "
|" + manDiaLlook_query + "|
\n" + debug_response; MDlookResponse = xmlhttp.responseText; @@ -8677,7 +8735,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection) var XDerrorDesc = MDlookResponse_array[3]; var XDerrorDescSIP = MDlookResponse_array[4]; var DiaLAlerTMessagE = " " + XDchannel + "\n" + XDerrorDesc + "\n" + XDerrorDescSIP; - TimerActionRun("DiaLAlerT",DiaLAlerTMessagE); + TimerActionRun("DiaLAlerT",DiaLAlerTMessagE,0); agent_events('agent_alert', "Call Rejected: " + XDerrorDesc + ' ' + XDerrorDescSIP, aec); aec++; } if ( (XDchannel.match(regMDL)) && (asterisk_version != '1.0.8') && (asterisk_version != '1.0.9') && (MD_ring_secondS < 10) ) @@ -8737,7 +8795,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection) var MDerrorDesc = MDlookResponse_array[3]; var MDerrorDescSIP = MDlookResponse_array[4]; var DiaLAlerTMessagE = " " + MDchannel + "\n" + MDerrorDesc + "\n" + MDerrorDescSIP; - TimerActionRun("DiaLAlerT",DiaLAlerTMessagE); + TimerActionRun("DiaLAlerT",DiaLAlerTMessagE,0); agent_events('agent_alert', "Call Rejected: " + MDerrorDesc + ' ' + MDerrorDescSIP, aec); aec++; } if ( (MDchannel.match(regMDL)) && (asterisk_version != '1.0.8') && (asterisk_version != '1.0.9') ) @@ -8868,6 +8926,56 @@ function set_length(SLnumber,SLlength_goal,SLdirection) custchannellive=1; agent_events('call_answered', CIDcheck, aec); aec++; + + if (MDalert == 'SIP ACTION') + { + var MDactionOption = MDlookResponse_array[3]; + var MDactionDispo = MDlookResponse_array[4]; + var MDactionMessage = MDlookResponse_array[5]; + var regSAmessage = new RegExp("message","ig"); + var regSAdispo = new RegExp("dispo","ig"); + var regSAhangup = new RegExp("hangup","ig"); + if (MDactionOption.match(regSAmessage)) + { + button_click_log = button_click_log + "" + SQLdate + "-----SIPeventMESSAGE---" + MDactionOption + "|"; + TimerActionRun("DiaLAlerT",MDactionMessage,3); + } + if (MDactionOption.match(regSAhangup)) + { + button_click_log = button_click_log + "" + SQLdate + "-----SIPeventHANGUP---" + MDactionOption + "|"; + dialedcall_send_hangup(); + if ( (MDactionOption.match(regSAdispo)) && (MDactionDispo.length > 0) ) + { + button_click_log = button_click_log + "" + SQLdate + "-----SIPeventDISPO---" + MDactionDispo + " " + MDactionOption + "|"; + CustomerData_update('NO'); + if ( (per_call_notes == 'ENABLED') && (comments_dispo_screen != 'REPLACE_CALL_NOTES') ) + { + var test_notesDE = document.vicidial_form.call_notes.value; + if (test_notesDE.length > 0) + {document.vicidial_form.call_notes_dispo.value = document.vicidial_form.call_notes.value} + } + + SIPaction_dispo_count=4; + SIPaction_dispo_finish=1; + alt_phone_dialing=starting_alt_phone_dialing; + alt_dial_active = 0; + alt_dial_status_display = 0; + document.vicidial_form.DispoSelection.value = MDactionDispo; + document.vicidial_form.DispoSelectStop.checked=true; + dialedcall_send_hangup('NO', 'NO', MDactionDispo); + if (custom_fields_enabled > 0) + { + customsubmit_trigger=1; + } + } + } + agent_events('agent_alert', "SIP Action: " + MDactionOption + ' ' + MDactionDispo, aec); aec++; + document.getElementById("debugbottomspan").innerHTML = "
|" + manDiaLlook_query + "|
\n" + debug_response + "
\n" + MDactionOption; + } + if (MDalert == 'CALL UNANSWERED') + { + MDcheck_for_answer=1; + } } } } @@ -10091,6 +10199,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection) trigger_manual_validation=0; manual_entry_dial=0; SCRIPTweb_form_vars=''; + MDcheck_for_answer=0; if (manual_dial_preview < 1) { document.vicidial_form.LeadPreview.checked=false; @@ -12780,6 +12889,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection) MDnextCID = ''; cid_lock=0; MD_dial_timed_out=0; + MDcheck_for_answer=0; // UPDATE VICIDIAL_LOG ENTRY FOR THIS CALL PROCESS DialLog("end",nodeletevdac); @@ -14024,6 +14134,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection) trigger_manual_validation=0; manual_entry_dial=0; SCRIPTweb_form_vars=''; + MDcheck_for_answer=0; if (manual_auto_next > 0) {manual_auto_next_trigger=1; manual_auto_next_count=manual_auto_next;} if (agent_display_fields.match(adfREGentry_date)) @@ -17686,7 +17797,7 @@ function phone_number_format(formatphone) { // ################################################################################ // Finish the wrapup timer early - function TimerActionRun(taskaction,taskdialalert) + function TimerActionRun(taskaction,taskdialalert,tasktimerhide) { var next_action=0; if (taskaction == 'DiaLAlerT') @@ -17694,6 +17805,9 @@ function phone_number_format(formatphone) { document.getElementById("TimerContentSpan").innerHTML = "

" + taskdialalert.replace("\n","
") + "
"; showDiv('TimerSpan'); + + if (tasktimerhide > 0) + {dial_box_close_counter = tasktimerhide;} } else { @@ -18407,7 +18521,7 @@ function phone_number_format(formatphone) { } if ( (timer_action != 'NONE') && (timer_action.length > 3) && (timer_action_seconds <= VD_live_call_secondS) && (timer_action_seconds >= 0) ) { - TimerActionRun('',''); + TimerActionRun('','',0); } if (HKdispo_display > 0) { @@ -18443,6 +18557,15 @@ function phone_number_format(formatphone) { } dead_auto_dispo_count--; } + if (SIPaction_dispo_count > 0) + { + if ( (SIPaction_dispo_count == 3) && (SIPaction_dispo_finish==1) ) + { + SIPaction_dispo_finish=0; + DispoSelect_submit('1',document.vicidial_form.DispoSelection.value); + } + SIPaction_dispo_count--; + } if (all_record == 'YES') { @@ -18597,6 +18720,12 @@ function phone_number_format(formatphone) { if (alert_box_close_counter < 1) {hideDiv('AlertBox');} } + if (dial_box_close_counter > 0) + { + dial_box_close_counter = (dial_box_close_counter - 1); + if (dial_box_close_counter < 1) + {hideDiv('TimerSpan');} + } if (left_3way_timeout > 0) {left_3way_timeout = (left_3way_timeout - 1);}