From 06234e8ef20b6ff11516098f7d8368efbba52384 Mon Sep 17 00:00:00 2001 From: mattf Date: Mon, 2 Jun 2025 02:26:29 +0000 Subject: [PATCH] Fix for fronter/closer start/dispo URL variables git-svn-id: svn://192.168.202.10@3925 3d104415-ff17-0410-8863-d5cf3c621b8a --- bin/AST_send_URL.pl | 53 ++++++++++++++++++++++--- www/agc/vdc_db_query.php | 86 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 127 insertions(+), 12 deletions(-) diff --git a/bin/AST_send_URL.pl b/bin/AST_send_URL.pl index 247be6dc..7b7b7386 100644 --- a/bin/AST_send_URL.pl +++ b/bin/AST_send_URL.pl @@ -8,7 +8,7 @@ # This script is also used for the Add-Lead-URL feature in In-groups and for # QM socket-send as well as from call menus using a settings container. # -# Copyright (C) 2024 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2025 Matt Florell LICENSE: AGPLv2 # # CHANGES # 100622-0929 - First Build @@ -33,9 +33,10 @@ # 230531-1139 - Added option to send any URL as POST if "POST" is at the end of the $function var # 230605-0836 - Added SC_CALL_URL option to add post headers # 230516-2150 - Added ALT start_call_url code and --version flag +# 250601-0857 - Added fronter/closer variables to start_call_url # -$build = '230516-2150'; +$build = '250601-0857'; $|++; use Getopt::Long; @@ -1001,6 +1002,8 @@ if (length($lead_id) > 0) elsif ($function =~ /SC_CALL_URL/) { + $fronter = $user; + $closer=''; $talk_sec=0; $dead_sec=0; $dispo_epoch=time(); $now_epoch=time(); ##### BEGIN Settings Container Call URL function ##### $stmtA = "SELECT user,status,talk_sec,dead_sec,dispo_epoch from vicidial_agent_log where lead_id='$lead_id' order by agent_log_id desc limit 1;"; @@ -1111,9 +1114,9 @@ if (length($lead_id) > 0) $sthA->finish(); } - if ($sc_call_url =~ /--A--closecallid--B--/) + if ( ($sc_call_url =~ /--A--closecallid--B--/) || ($sc_call_url =~ /--A--fronter--B--|--A--closer--B--/) ) { - $stmtA = "SELECT closecallid FROM vicidial_closer_log where uniqueid='$uniqueid' order by closecallid limit 1;"; + $stmtA = "SELECT closecallid,xfercallid FROM vicidial_closer_log where uniqueid='$uniqueid' order by closecallid limit 1;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -1121,8 +1124,24 @@ if (length($lead_id) > 0) { @aryA = $sthA->fetchrow_array; $VAR_closecallid = $aryA[0]; + $VAR_xfercallid = $aryA[1]; } $sthA->finish(); + + if ( ($sc_call_url =~ /--A--fronter--B--|--A--closer--B--/) && ($VAR_xfercallid > 0) && (length($VAR_xfercallid) > 0) ) + { + $stmtA = "SELECT user from vicidial_xfer_log where xfercallid='$VAR_xfercallid' limit 1;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $fronter = $aryA[0]; + $closer = $user; + } + $sthA->finish(); + } } if ( (length($VAR_list_id) > 1) && ( ( (length($list_name) < 1) && ($sc_call_url =~ /--A--list_name--B--/) ) || ( (length($list_description) < 1) && ($sc_call_url =~ /--A--list_description--B--/) ) ) ) @@ -1208,6 +1227,8 @@ if (length($lead_id) > 0) $sc_call_url =~ s/--A--talk_time--B--/$talk_time/gi; $sc_call_url =~ s/--A--talk_time_min--B--/$talk_time_min/gi; $sc_call_url =~ s/--A--SQLdate--B--/$now_date/gi; + $sc_call_url =~ s/--A--fronter--B--/$fronter/gi; + $sc_call_url =~ s/--A--closer--B--/$closer/gi; if ($function !~ /POST$/) {$sc_call_url =~ s/ /+/gi;} $sc_call_url =~ s/&/\\&/gi; $parse_url = $sc_call_url; @@ -1218,6 +1239,8 @@ if (length($lead_id) > 0) else { ##### BEGIN Start Call URL function ##### + $fronter = $user; + $closer=''; $stmtA = "SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,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,phone_code FROM vicidial_list where lead_id='$lead_id';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1345,9 +1368,9 @@ if (length($lead_id) > 0) $sthA->finish(); } - if ($scALT_url_address[$scALT] =~ /--A--closecallid--B--/) + if ( ($scALT_url_address[$scALT] =~ /--A--closecallid--B--/) || ($scALT_url_address[$scALT] =~ /--A--fronter--B--|--A--closer--B--/) ) { - $stmtA = "SELECT closecallid FROM vicidial_closer_log where uniqueid='$uniqueid' order by closecallid limit 1;"; + $stmtA = "SELECT closecallid,xfercallid FROM vicidial_closer_log where uniqueid='$uniqueid' order by closecallid limit 1;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -1355,8 +1378,24 @@ if (length($lead_id) > 0) { @aryA = $sthA->fetchrow_array; $VAR_closecallid = $aryA[0]; + $VAR_xfercallid = $aryA[1]; } $sthA->finish(); + + if ( ($scALT_url_address[$scALT] =~ /--A--fronter--B--|--A--closer--B--/) && ($VAR_xfercallid > 0) && (length($VAR_xfercallid) > 0) ) + { + $stmtA = "SELECT user from vicidial_xfer_log where xfercallid='$VAR_xfercallid' limit 1;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $fronter = $aryA[0]; + $closer = $user; + } + $sthA->finish(); + } } if ( (length($VAR_list_id) > 1) && ( ( (length($list_name) < 1) && ($scALT_url_address[$scALT] =~ /--A--list_name--B--/) ) || ( (length($list_description) < 1) && ($scALT_url_address[$scALT] =~ /--A--list_description--B--/) ) ) ) @@ -1438,6 +1477,8 @@ if (length($lead_id) > 0) $scALT_url_address[$scALT] =~ s/--A--group--B--/$VAR_campaign_id/gi; $scALT_url_address[$scALT] =~ s/--A--function--B--/$function/gi; $scALT_url_address[$scALT] =~ s/--A--SQLdate--B--/$now_date/gi; + $scALT_url_address[$scALT] =~ s/--A--fronter--B--/$fronter/gi; + $scALT_url_address[$scALT] =~ s/--A--closer--B--/$closer/gi; $scALT_url_address[$scALT] =~ s/ /+/gi; $scALT_url_address[$scALT] =~ s/&/\\&/gi; $parse_url = $scALT_url_address[$scALT]; diff --git a/www/agc/vdc_db_query.php b/www/agc/vdc_db_query.php index ad042d9d..a1ace867 100644 --- a/www/agc/vdc_db_query.php +++ b/www/agc/vdc_db_query.php @@ -558,10 +558,11 @@ # 250224-1642 - Fix for drop_lockout_time issue with NULL last_local_call_time DROP leads # 250311-1420 - Fix for start_call_url on inbound calls where blank and campaign set to ALT # 250326-1937 - Fix for missing vicidial_inbound_group_agents entries +# 250601-0843 - Fix for fronter/closer start/dispo URL variables # -$version = '2.14-451'; -$build = '250326-1937'; +$version = '2.14-452'; +$build = '250601-0843'; $php_script = 'vdc_db_query.php'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=913; @@ -1321,6 +1322,8 @@ else $calls_waiting_vl_twoLABEL = preg_replace('/[^-, _0-9\p{L}]/u','',$calls_waiting_vl_twoLABEL); } +$fronter=''; +$closer=''; if (strlen($SSagent_debug_logging) > 1) { @@ -2361,6 +2364,11 @@ if ($ACTION == 'manDiaLnextCaLL') $CCIDtype=''; $channel_live=1; $MDF_search_flag='MAIN'; + $INxfercallid=''; + $INclosecallid=''; + # outbound call, assign fronter to user and closer blank + $fronter=$user; + $closer=''; $lead_id = preg_replace("/[^0-9]/","",$lead_id); if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) ) { @@ -6364,6 +6372,9 @@ if ($ACTION == 'manDiaLonly') $CCIDtype=''; $channel_live=1; $MDF_search_flag='MAIN'; + # outbound call, assign fronter to user and closer blank + $fronter=$user; + $closer=''; if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) || (strlen($phone_number)<1) || (strlen($lead_id)<1) ) { $channel_live=0; @@ -10001,6 +10012,9 @@ if ($ACTION == 'VDADcheckINCOMING') $INclosecallid=''; $INxfercallid=''; $rct = 'Q'; + # default to $fronter=$user, closer blank + $fronter = $user; + $closer=''; if ( (strlen($campaign)<1) || (strlen($server_ip)<1) ) { @@ -10525,6 +10539,9 @@ if ($ACTION == 'VDADcheckINCOMING') $alt_phone_count = $row[4]; } } + # outbound call, assign fronter to user and closer blank + $fronter=$user; + $closer=''; } else { @@ -10536,6 +10553,7 @@ if ($ACTION == 'VDADcheckINCOMING') if (strlen($closecallid)<1) { + $INxfercallid=''; $stmt = "SELECT closecallid,xfercallid from vicidial_closer_log where lead_id='$lead_id' and user='$user' and list_id='$list_id' order by closecallid desc limit 1;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); @@ -10547,6 +10565,21 @@ if ($ACTION == 'VDADcheckINCOMING') $INclosecallid = $row[0]; $INxfercallid = $row[1]; } + if ( (strlen($INxfercallid) > 0) and ($INxfercallid > 0) ) + { + # check for fronter in vicidial_xfer_log + $stmt = "SELECT user from vicidial_xfer_log where xfercallid='$INxfercallid' limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + $VDCL_vxl_ct = mysqli_num_rows($rslt); + if ($VDCL_vxl_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $fronter = $row[0]; + $closer = $user; + } + } } $stmt = "SELECT count(*) from vicidial_log where lead_id='$lead_id' and uniqueid='$uniqueid';"; @@ -10999,7 +11032,8 @@ if ($ACTION == 'VDADcheckINCOMING') if ( (strlen($VDCL_group_web)>5) or (strlen($VDCL_group_name)>0) ) {echo "$VDCL_group_web|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|$VDCL_default_xfer_group|$VDCL_ingroup_recording_override|$VDCL_ingroup_rec_filename|$VDCL_default_group_alias|$VDCL_caller_id_number|$VDCL_group_web_vars|$VDCL_group_web_two|$VDCL_timer_action|$VDCL_timer_action_message|$VDCL_timer_action_seconds|$VDCL_xferconf_c_number|$VDCL_xferconf_d_number|$VDCL_xferconf_e_number|$VDCL_uniqueid_status_display|$custom_call_id|$VDCL_uniqueid_status_prefix|$VDCL_timer_action_destination|$DID_id|$DID_extension|$DID_pattern|$DID_description|$INclosecallid|$INxfercallid|$VDCL_group_web_three|$VDCL_ingroup_script_color|$VDCL_inbound_survey|$VDCL_survey_participate|$VDCL_ingroup_script_two|$VDCL_ingroup_script_color_two|$VDCL_browser_alert_sound|$VDCL_browser_alert_volume|\n";} else {echo "X|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|$VDCL_default_xfer_group|$VDCL_ingroup_recording_override|$VDCL_ingroup_rec_filename|$VDCL_default_group_alias|$VDCL_caller_id_number|$VDCL_group_web_vars|$VDCL_group_web_two|$VDCL_timer_action|$VDCL_timer_action_message|$VDCL_timer_action_seconds|$VDCL_xferconf_c_number|$VDCL_xferconf_d_number|$VDCL_xferconf_e_number|$VDCL_uniqueid_status_display|$custom_call_id|$VDCL_uniqueid_status_prefix|$VDCL_timer_action_destination|$DID_id|$DID_extension|$DID_pattern|$DID_description|$INclosecallid|$INxfercallid|$VDCL_group_web_three|$VDCL_ingroup_script_color|$VDCL_inbound_survey|$VDCL_survey_participate|$VDCL_ingroup_script_two|$VDCL_ingroup_script_color_two|$VDCL_browser_alert_sound|$VDCL_browser_alert_volume|\n";} - $stmt = "SELECT full_name from vicidial_users where user='$tsr';"; + if (strlen($fronter) < 2) {$fronter = $tsr;} + $stmt = "SELECT full_name from vicidial_users where user='$fronter';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00122',$user,$server_ip,$session_name,$one_mysql_log);} @@ -11748,6 +11782,9 @@ if ($ACTION == 'VDADcheckINCOMINGother') $queue_seconds=0; if (!is_array($inbound_email_groups)) {$inbound_email_groups=array();} if (!is_array($inbound_chat_groups)) {$inbound_chat_groups=array();} + # default to $fronter=$user, closer blank + $fronter = $user; + $closer=''; $email_group_ct=count($inbound_email_groups); # This should always be greater than zero for the script to reach this point, but just in case... for ($i=0; $i<$email_group_ct; $i++) @@ -11996,6 +12033,7 @@ if ($ACTION == 'VDADcheckINCOMINGother') ### if a transfer, update the transfer record with the user if ($xferred_email==1) { + $closer=$user; $stmt = "UPDATE vicidial_xfer_log set closer='$user' where xfercallid='$xfercallid';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); @@ -12295,6 +12333,21 @@ if ($ACTION == 'VDADcheckINCOMINGother') $INclosecallid = $row[0]; $INxfercallid = $row[1]; } + if ( (strlen($INxfercallid) > 0) and ($INxfercallid > 0) ) + { + # check for fronter in vicidial_xfer_log + $stmt = "SELECT user from vicidial_xfer_log where xfercallid='$INxfercallid' limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + $VDCL_vxl_ct = mysqli_num_rows($rslt); + if ($VDCL_vxl_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $fronter = $row[0]; + $closer = $user; + } + } } $stmt = "SELECT count(*) from vicidial_log where lead_id='$lead_id' and uniqueid='$uniqueid';"; @@ -13277,6 +13330,9 @@ if ($ACTION == 'LeaDSearcHSelecTUpdatE') $alt_phone_count=''; $INclosecallid=''; $INxfercallid=''; + # default to $fronter=$user, closer blank + $fronter = $user; + $closer=''; if ( (strlen($campaign)<1) || (strlen($server_ip)<1) || ($lead_id<0) ) { @@ -13594,6 +13650,7 @@ if ($ACTION == 'LeaDSearcHSelecTUpdatE') if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00452',$user,$server_ip,$session_name,$one_mysql_log);} + $closer=$user; $script_recording_delay=0; ##### find if script contains recording fields @@ -13940,7 +13997,6 @@ if ($ACTION == 'LeaDSearcHSelecTUpdatE') } else {echo '|' . $tsr . "\n";} - ##### find if script contains recording fields $stmt="SELECT count(*) FROM vicidial_lists WHERE list_id='$list_id' and agent_script_override!='' and agent_script_override IS NOT NULL and agent_script_override!='NONE';"; $rslt=mysql_to_mysqli($stmt, $link); @@ -14164,6 +14220,9 @@ if ($ACTION == 'updateDISPO') { $MT[0]=''; $row=''; $rowx=''; + # default to $fronter=$user, closer blank + $fronter = $user; + $closer=''; $MAN_vl_insert=0; if ( (strlen($dispo_choice)<1) || (strlen($lead_id)<1) ) { @@ -15947,7 +16006,7 @@ if ($ACTION == 'updateDISPO') } } - if ((preg_match('/callid--B--/i',$dispo_call_urlARY[$j])) or (preg_match('/group--B--|--A--term_reason--B--/i',$dispo_call_urlARY[$j]))) + if ( (preg_match('/callid--B--/i',$dispo_call_urlARY[$j])) or (preg_match('/group--B--|--A--term_reason--B--/i',$dispo_call_urlARY[$j])) or (preg_match('/fronter--B--|closer--B--/i',$dispo_call_urlARY[$j])) ) { $INclosecallid=''; $INxfercallid=''; @@ -15965,6 +16024,21 @@ if ($ACTION == 'updateDISPO') $INxfercallid = $row[2]; $term_reason = $row[3]; } + if ( (strlen($INxfercallid) > 0) and ($INxfercallid > 0) and (preg_match('/fronter--B--|closer--B--/i',$dispo_call_urlARY[$j])) ) + { + # check for fronter in vicidial_xfer_log + $stmt = "SELECT user from vicidial_xfer_log where xfercallid='$INxfercallid' limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + $VDCL_vxl_ct = mysqli_num_rows($rslt); + if ($VDCL_vxl_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $fronter = $row[0]; + $closer = $user; + } + } } ##### grab the data from vicidial_list for the lead_id @@ -16204,7 +16278,7 @@ if ($ACTION == 'updateDISPO') $dispo_call_urlARY[$j] = preg_replace('/--A--original_phone_login--B--/i',"$original_phone_login",$dispo_call_urlARY[$j]); $dispo_call_urlARY[$j] = preg_replace('/--A--phone_pass--B--/i',"$phone_pass",$dispo_call_urlARY[$j]); $dispo_call_urlARY[$j] = preg_replace('/--A--fronter--B--/i',"$fronter",$dispo_call_urlARY[$j]); - $dispo_call_urlARY[$j] = preg_replace('/--A--closer--B--/i',"$user",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--closer--B--/i',"$closer",$dispo_call_urlARY[$j]); $dispo_call_urlARY[$j] = preg_replace('/--A--group--B--/i',"$VDADchannel_group",$dispo_call_urlARY[$j]); $dispo_call_urlARY[$j] = preg_replace('/--A--channel_group--B--/i',"$VDADchannel_group",$dispo_call_urlARY[$j]); $dispo_call_urlARY[$j] = preg_replace('/--A--SQLdate--B--/i',urlencode(trim($SQLdate)),$dispo_call_urlARY[$j]);