From 85e206a8aea5a8c4def75d2837a4820ecce6982e Mon Sep 17 00:00:00 2001 From: mattf Date: Sat, 30 Apr 2011 15:30:37 +0000 Subject: [PATCH] Added ability to use external_dial Agent API function with a defined lead_id and optional alt_dial setting git-svn-id: svn://192.168.202.10@1647 3d104415-ff17-0410-8863-d5cf3c621b8a --- UPGRADE | 2 ++ docs/AGENT_API.txt | 8 +++++- www/agc/api.php | 60 ++++++++++++++++++++++++++++++++++++++------ www/agc/vicidial.php | 7 ++++-- 4 files changed, 67 insertions(+), 10 deletions(-) diff --git a/UPGRADE b/UPGRADE index c91fa13b..7e72c7af 100644 --- a/UPGRADE +++ b/UPGRADE @@ -543,6 +543,8 @@ OTHER CHANGES: Works across web/api/cli lead loading methods. There is also an option in the time zone updating script to use this method. +123. Added ability to use external_dial Agent API function with a defined + lead_id and optional alt_dial setting diff --git a/docs/AGENT_API.txt b/docs/AGENT_API.txt index cc263b9e..48a4b127 100644 --- a/docs/AGENT_API.txt +++ b/docs/AGENT_API.txt @@ -149,6 +149,8 @@ Places a manual dial phone call on the agent screen, you can define whether to s VALUES: value - Any valid phone number (7275551212) +lead_id - + Any valid lead_id from the system(either value or lead_id are required) if both are defined, lead_id will override value phone_code - Any valid phone country code (1 for USA/Canada, 44 for UK, etc...) search - @@ -170,6 +172,8 @@ vtiger_callback - OPTIONAL, YES or NO, will lookup the phone number and Vtiger account ID from the provided Event ID alt_user - OPTIONAL, instead of agent_user, this is to lookup the agent_user using the vicidial_users.custom_three field +alt_dial - + OPTIONAL, if using lead_id you can set this flag to dial the ALT number or the ADDR3 number EXAMPLE URLS: http://server/agc/api.php?source=test&user=6666&pass=1234&agent_user=1000&function=external_dial&value=7275551212&phone_code=1&search=YES&preview=NO&focus=YES @@ -184,7 +188,9 @@ ERROR: caller_id_number from group_alias is not valid - 6666|TESTING|123 ERROR: group_alias is not valid - 6666|TESTING ERROR: vtiger callback activity does not exist in vtiger system - 12345 ERROR: phone_number is already in this agents manual dial queue - 6666|7275551211 -SUCCESS: external_dial function set - 7275551212|6666|1|YES|NO|YES|123456|1232020456|9|TESTING|7275551211 +ERROR: lead_id is not valid - 6666|1234567 +ERROR: phone number is not valid - 6666||1234567| +SUCCESS: external_dial function set - 7275551212|6666|1|YES|NO|YES|123456|1232020456|9|TESTING|7275551211| diff --git a/www/agc/api.php b/www/agc/api.php index d8068d3c..afaa9eaf 100644 --- a/www/agc/api.php +++ b/www/agc/api.php @@ -31,6 +31,7 @@ # - $status # - $close_window_link # - $language +# - $alt_dial - ('','MAIN','ALT','ADDR3') # CHANGELOG: # 80703-2225 - First build of script @@ -52,10 +53,11 @@ # 101123-1050 - Added manual dial queue features to external_dial function # 110224-1711 - Added compatibility with QM phone environment logging # 110409-0821 - Added run_time logging of API functions +# 110430-0953 - Added option to external_dial by lead_id with alt_dial option # -$version = '2.4-19'; -$build = '110409-0821'; +$version = '2.4-20'; +$build = '110430-0953'; $startMS = microtime(); @@ -168,6 +170,8 @@ if (isset($_GET["dial_override"])) {$dial_override=$_GET["dial_override"];} elseif (isset($_POST["dial_override"])) {$dial_override=$_POST["dial_override"];} if (isset($_GET["consultative"])) {$consultative=$_GET["consultative"];} elseif (isset($_POST["consultative"])) {$consultative=$_POST["consultative"];} +if (isset($_GET["alt_dial"])) {$alt_dial=$_GET["alt_dial"];} + elseif (isset($_POST["alt_dial"])) {$alt_dial=$_POST["alt_dial"];} if (isset($_GET["DB"])) {$DB=$_GET["DB"];} elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} @@ -212,6 +216,7 @@ if ($non_latin < 1) $source = ereg_replace("[^0-9a-zA-Z]","",$source); $format = ereg_replace("[^0-9a-zA-Z]","",$format); $vtiger_callback = ereg_replace("[^A-Z]","",$vtiger_callback); + $alt_dial = ereg_replace("[^0-9A-Z]","",$alt_dial); $blended = ereg_replace("[^A-Z]","",$blended); $ingroup_choices = ereg_replace("[^ -\_0-9a-zA-Z]","",$ingroup_choices); $set_as_default = ereg_replace("[^A-Z]","",$set_as_default); @@ -585,11 +590,11 @@ if ($function == 'external_dial') { $value = ereg_replace("[^0-9]","",$value); - if ( (strlen($value)<2) or ( (strlen($agent_user)<2) and (strlen($alt_user)<2) ) or (strlen($search)<2) or (strlen($preview)<2) or (strlen($focus)<2) ) + if ( ( (strlen($value)<2) and (strlen($lead_id)<1) ) or ( (strlen($agent_user)<2) and (strlen($alt_user)<2) ) or (strlen($search)<2) or (strlen($preview)<2) or (strlen($focus)<2) ) { $result = 'ERROR'; $result_reason = "external_dial not valid"; - $data = "$phone_code|$search|$preview|$focus"; + $data = "$phone_code|$search|$preview|$focus|$lead_id"; echo "$result: $result_reason - $value|$data|$agent_user|$alt_user\n"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } @@ -787,11 +792,52 @@ if ($function == 'external_dial') } ####### End Vtiger CallBack Launching ####### + ### If lead_id is populated, check for it and adjust variables accordingly + if (strlen($lead_id) > 0) + { + $value=''; + $phone_code=''; + if ($alt_dial=='ALT') + {$stmtPF = "select alt_phone,phone_code from vicidial_list where lead_id='$lead_id';";} + if ($alt_dial=='ADDR3') + {$stmtPF = "select address3,phone_code from vicidial_list where lead_id='$lead_id';";} + if (strlen($stmtPF)<20) + {$stmtPF = "select phone_number,phone_code from vicidial_list where lead_id='$lead_id';";} + if ($DB) {echo "$stmtPF\n";} + $rslt=mysql_query($stmtPF, $link); + $VL_lead_id_ct = mysql_num_rows($rslt); + if ($VL_lead_id_ct > 0) + { + $row=mysql_fetch_row($rslt); + $value = $row[0]; + $phone_code = $row[1]; + $value = ereg_replace("[^0-9]","",$value); + if (strlen($value)<2) + { + $result = 'ERROR'; + $result_reason = "phone number is not valid"; + $data = "$value|$lead_id|$alt_dial"; + 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; + } + } + else + { + $result = 'ERROR'; + $result_reason = "lead_id is not valid"; + $data = "$lead_id"; + 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; + } + } + $success=0; ### If no errors, run the update to place the call ### if ($api_manual_dial=='STANDARD') { - $stmt="UPDATE vicidial_live_agents set external_dial='$value!$phone_code!$search!$preview!$focus!$vendor_id!$epoch!$dial_prefix!$group_alias!$caller_id_number!$vtiger_callback_id' where user='$agent_user';"; + $stmt="UPDATE vicidial_live_agents set external_dial='$value!$phone_code!$search!$preview!$focus!$vendor_id!$epoch!$dial_prefix!$group_alias!$caller_id_number!$vtiger_callback_id!$lead_id!$alt_dial' where user='$agent_user';"; $success=1; } else @@ -802,7 +848,7 @@ if ($function == 'external_dial') $row=mysql_fetch_row($rslt); if ($row[0] < 1) { - $stmt="INSERT INTO vicidial_manual_dial_queue set user='$agent_user',phone_number='$value',entry_time=NOW(),status='READY',external_dial='$value!$phone_code!$search!$preview!$focus!$vendor_id!$epoch!$dial_prefix!$group_alias!$caller_id_number!$vtiger_callback_id';"; + $stmt="INSERT INTO vicidial_manual_dial_queue set user='$agent_user',phone_number='$value',entry_time=NOW(),status='READY',external_dial='$value!$phone_code!$search!$preview!$focus!$vendor_id!$epoch!$dial_prefix!$group_alias!$caller_id_number!$vtiger_callback_id!$lead_id!$alt_dial';"; $success=1; } else @@ -819,7 +865,7 @@ if ($function == 'external_dial') $rslt=mysql_query($stmt, $link); $result = 'SUCCESS'; $result_reason = "external_dial function set"; - $data = "$phone_code|$search|$preview|$focus|$vendor_id|$epoch|$dial_prefix|$group_alias|$caller_id_number"; + $data = "$phone_code|$search|$preview|$focus|$vendor_id|$epoch|$dial_prefix|$group_alias|$caller_id_number|$alt_dial"; echo "$result: $result_reason - $value|$agent_user|$data\n"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } diff --git a/www/agc/vicidial.php b/www/agc/vicidial.php index aae51e68..d17f375e 100644 --- a/www/agc/vicidial.php +++ b/www/agc/vicidial.php @@ -346,10 +346,11 @@ # 110413-1244 - Added ALT dialing from scheduled callback list, and other formatting changes # 110420-1211 - Added web_vars variable # 110428-1549 - Added use of manual_dial_cid setting +# 110430-1126 - Added ability to use external_dial API function with lead_id and alt_dial options # -$version = '2.4-323c'; -$build = '110428-1549'; +$version = '2.4-324c'; +$build = '110430-1126'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=72; $one_mysql_log=0; @@ -4230,6 +4231,8 @@ function set_length(SLnumber,SLlength_goal,SLdirection) active_group_alias = APIDiaL_array_detail[8]; cid_choice = APIDiaL_array_detail[9]; vtiger_callback_id = APIDiaL_array_detail[10]; + document.vicidial_form.MDLeadID.value = APIDiaL_array_detail[11]; + document.vicidial_form.MDType.value = APIDiaL_array_detail[12]; // alert(APIDiaL_array_detail[1] + "-----" + APIDiaL + "-----" + document.vicidial_form.MDDiaLCodE.value + "-----" + document.vicidial_form.phone_code.value);