diff --git a/docs/AGENT_API.txt b/docs/AGENT_API.txt index 8f0b5fc7..ce29bc17 100644 --- a/docs/AGENT_API.txt +++ b/docs/AGENT_API.txt @@ -1,4 +1,4 @@ -AGENT API DOCUMENT Started: 2008-07-03 Updated: 2024-04-25 +AGENT API DOCUMENT Started: 2008-07-03 Updated: 2024-04-27 This document describes the functions of an API(Application Programming Interface) for the VICIDIAL Agent screen. This functionality will be rather limited at first @@ -718,7 +718,9 @@ VALUES: multi_dial_phones - OPTIONAL, for use only with "Agent 3-way Press-1 Calls", contains up to 10 phone numbers separated by commas: "2125551212,4075551212,3125551212" (duplicates will be removed) md_check - - OPTIONAL, for use only with 'multi_dial_phones' option above, if this is set to 'YES' it will check for still-active previous 3-way calls and show an error if any are found + OPTIONAL, for use only with 'multi_dial_phones' option above, if this is set to 'YES' it will check for still-active previous 3-way press-1 calls and show an error if any are found + tw_check - + OPTIONAL, for use only with the dialing 3-way call options above, if this is set to 'YES' it will check for still-active previous 3-way calls and show an error if any are found EXAMPLE URLS: http://server/agc/api.php?source=test&user=6666&pass=1234&agent_user=1000&function=transfer_conference&value=HANGUP_XFER @@ -746,6 +748,7 @@ ERROR: caller_id_number from group_alias is not valid - 6666|TESTING|123 ERROR: group_alias is not valid - 6666|TESTING ERROR: cid_choice is not valid - 6666|TESTING ERROR: agent_user has previous active 3-way calls - 6666|1|0|YES +ERROR: agent_user has current active 3-way call - 6666|1|0|YES SUCCESS: transfer_conference function set - LOCAL_CLOSER|SALESLINE||YES|6666|M2141842580000000044| diff --git a/www/agc/api.php b/www/agc/api.php index 4d41177a..018d232e 100644 --- a/www/agc/api.php +++ b/www/agc/api.php @@ -114,10 +114,11 @@ # 231222-2105 - Added multi_dial_phones option to the transfer_conference function # 240219-1500 - Added daily_limit setting to change_ingroups function # 240425-1901 - Added md_check option for transfer_conference function +# 240427-0809 - Added tw_check option for transfer_conference function # -$version = '2.14-79'; -$build = '240425-1901'; +$version = '2.14-80'; +$build = '240427-0809'; $php_script = 'api.php'; $startMS = microtime(); @@ -295,6 +296,8 @@ if (isset($_GET["multi_dial_phones"])) {$multi_dial_phones=$_GET["multi_dial_p elseif (isset($_POST["multi_dial_phones"])) {$multi_dial_phones=$_POST["multi_dial_phones"];} if (isset($_GET["md_check"])) {$md_check=$_GET["md_check"];} elseif (isset($_POST["md_check"])) {$md_check=$_POST["md_check"];} +if (isset($_GET["tw_check"])) {$tw_check=$_GET["tw_check"];} + elseif (isset($_POST["tw_check"])) {$tw_check=$_POST["tw_check"];} $DB=preg_replace("/[^0-9a-zA-Z]/","",$DB); @@ -358,6 +361,7 @@ $campaign_dnc_check=preg_replace("/[^-_0-9a-zA-Z]/","",$campaign_dnc_check); $notification_date = preg_replace('/[^- \:0-9]/','',$notification_date); $multi_dial_phones = preg_replace('/[^\,0-9]/','',$multi_dial_phones); $md_check = preg_replace("/[^0-9a-zA-Z]/","",$md_check); +$tw_check = preg_replace("/[^0-9a-zA-Z]/","",$tw_check); if ($non_latin < 1) { @@ -4030,12 +4034,15 @@ if ($function == 'transfer_conference') $row=mysqli_fetch_row($rslt); if ($row[0] > 0) { - $stmt = "select lead_id,callerid from vicidial_live_agents where user='$agent_user';"; + $stmt = "select lead_id,callerid,server_ip,conf_exten,status from vicidial_live_agents where user='$agent_user';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); - $lead_id = $row[0]; - $callerid = $row[1]; + $lead_id = $row[0]; + $callerid = $row[1]; + $AGENTserver_ip = $row[2]; + $AGENTconf_exten = $row[3]; + $AGENTstatus = $row[4]; if ( ($lead_id > 0) and (strlen($callerid)>15) ) { ### START In-group transfer or bridge ### @@ -4224,6 +4231,7 @@ if ($function == 'transfer_conference') $multi_dial_phones_STRING=''; if (strlen($multi_dial_phones) > 4) { + ### START 3-way press-1 multi-dial calls processing ### $multi_dial_phonesARY=array(); $multi_dial_phones_ct=0; if (preg_match("/,/",$multi_dial_phones)) @@ -4256,8 +4264,9 @@ if ($function == 'transfer_conference') $md_check_ct=0; if (preg_match("/YES/i",$md_check)) { + $half_hour_ago = date("Y-m-d H:i:s", mktime(date("H"),date("i")-30,date("s"),date("m"),date("d"),date("Y"))); # check for still-active previous 3-way calls from this agent and send error if any are found - $stmt = "select count(*) from vicidial_3way_press_live where user='$agent_user' and status NOT IN('HUNGUP','DEFEATED','TRANSFER','TOOSLOW','DECLINED');"; + $stmt = "select count(*) from vicidial_3way_press_live where user='$agent_user' and status NOT IN('HUNGUP','DEFEATED','TRANSFER','TOOSLOW','DECLINED') and call_date > \"$half_hour_ago\";"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); $VDTW_live_ct = mysqli_num_rows($rslt); @@ -4285,8 +4294,45 @@ if ($function == 'transfer_conference') } } $multi_dial_phones_OUTPUT = "|Multi-phones: $vp $mp $affected_rowsVP"; + ### END 3-way press-1 multi-dial calls processing ### } + ### START Check for already active 3-way calls in agent session, if enabled ### + if (preg_match("/YES/i",$tw_check)) + { + $conf_engine=''; + $conf_table = 'vicidial_conferences'; + $tw_check_ct=0; + + $stmt = "SELECT conf_engine from servers where server_ip='$AGENTserver_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $conf_engine = $row[0]; + if (preg_match("/CONFBRIDGE/i",$conf_engine)) {$conf_table = 'vicidial_confbridges';} + + # check for active 3-way call from this agent and send error if any are found + $stmt = "SELECT count(*) from live_sip_channels where server_ip='$AGENTserver_ip' and channel_group LIKE \"DC%W\" and extension='$AGENTconf_exten';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $TW_live_ct = mysqli_num_rows($rslt); + if ($TW_live_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $tw_check_ct = $row[0]; + } + if ($tw_check_ct > 0) + { + $result = _QXZ("ERROR"); + $result_reason = _QXZ("agent_user has current active 3-way call"); + $data = "$tw_check_ct|0|$tw_check"; + echo "$result: $result_reason - $agent_user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + } + ### END Check for already active 3-way calls in agent session, if enabled ### + $stmt="UPDATE vicidial_live_agents set external_transferconf='$external_transferconf' where user='$agent_user';"; if ($format=='debug') {echo "\n";} if ($DB) {echo "$stmt\n";}