From 4c74dd27340d887d73e2037b10eb9725761671ba Mon Sep 17 00:00:00 2001 From: mattf Date: Thu, 20 Oct 2016 15:10:28 +0000 Subject: [PATCH] Added lookup_state option to non-agent API add_lead function, added 10-digit validation if usacan_areacode_check enabled git-svn-id: svn://192.168.202.10@2598 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/docs/NON-AGENT_API.txt | 6 +++-- agc_2-X/trunk/www/vicidial/non_agent_api.php | 24 +++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/agc_2-X/trunk/docs/NON-AGENT_API.txt b/agc_2-X/trunk/docs/NON-AGENT_API.txt index b28031ab..6adba0e3 100644 --- a/agc_2-X/trunk/docs/NON-AGENT_API.txt +++ b/agc_2-X/trunk/docs/NON-AGENT_API.txt @@ -1,4 +1,4 @@ -NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2016-07-09 +NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2016-10-20 This document describes the functions of an API(Application Programming Interface) for all functions NOT directly relating to the VICIDIAL Agent screen. @@ -114,6 +114,7 @@ Changes: 151226-0954 - Added session_id(conf_exten) field to output of agent_status, and added logged_in_agents function 160603-1041 - Added update_campaign function 160709-2219 - Added lead_field_info function +161020-1042 - Added lookup_state option to add_lead, added 10-digit validation if usacan_areacode_check enabled API Functions use the 'function' variable @@ -590,7 +591,7 @@ duplicate_check - Check for duplicate records in the system, can select more tha DUPNAMEPHONECAMP - check for duplicate first_name, last_name and phone_number in all lists for this list's campaign DUPNAMEPHONESYS - check for duplicate first_name, last_name and phone_number in entire system usacan_prefix_check - Y or N, default is N. Check for a valid 4th digit for USA and Canada phone numbers (cannot be 0 or 1) -usacan_areacode_check - Y or N, default is N. Check for a valid areacode for USA and Canada phone numbers +usacan_areacode_check - Y or N, default is N. Check for a valid areacode for USA and Canada phone numbers(also checks for 10-digit length) nanpa_ac_prefix_check - Y or N, default is N. Check for a valid NANPA areacode and prefix, if optional NANPA data is on the system custom_fields - Y or N, default is N. Defines whether the API will accept custom field data when inserting leads into the vicidial_list table For custom fields to be inserted, just add the field label as a variable to the URL string @@ -605,6 +606,7 @@ callback_datetime - YYYY-MM-DD+HH:MM:SS, date and time of scheduled callback. RE callback_type - USERONLY or ANYONE, default is ANYONE callback_user - User ID the USERONLY callback is assigned to callback_comments - Optional comments to appear when the callback is called back +lookup_state - Y or N, default is N. Looks up state field from areacode list. Only works if the 'state' field is not populated. (for fields with spaces in the values, you can replace the space with a plus + sign[address, city, first_name, etc...]) OPTIONAL FIELDS- diff --git a/agc_2-X/trunk/www/vicidial/non_agent_api.php b/agc_2-X/trunk/www/vicidial/non_agent_api.php index b6de8b8d..e95765b3 100644 --- a/agc_2-X/trunk/www/vicidial/non_agent_api.php +++ b/agc_2-X/trunk/www/vicidial/non_agent_api.php @@ -109,10 +109,11 @@ # 160603-1041 - Added update_campaign function # 160709-2233 - Added lead_field_info function # 160824-0802 - Fixed issue with allowed lists feature +# 161020-1042 - Added lookup_state option to add_lead, added 10-digit validation if usacan_areacode_check enabled # -$version = '2.12-85'; -$build = '160824-0802'; +$version = '2.12-86'; +$build = '161020-1042'; $api_url_log = 0; $startMS = microtime(); @@ -405,6 +406,8 @@ if (isset($_GET["dial_timeout"])) {$dial_timeout=$_GET["dial_timeout"];} elseif (isset($_POST["dial_timeout"])) {$dial_timeout=$_POST["dial_timeout"];} if (isset($_GET["field_name"])) {$field_name=$_GET["field_name"];} elseif (isset($_POST["field_name"])) {$field_name=$_POST["field_name"];} +if (isset($_GET["lookup_state"])) {$lookup_state=$_GET["lookup_state"];} + elseif (isset($_POST["lookup_state"])) {$lookup_state=$_POST["lookup_state"];} header ("Content-type: text/html; charset=utf-8"); @@ -584,6 +587,7 @@ if ($non_latin < 1) $dial_method = preg_replace('/[^-_0-9a-zA-Z]/','',$dial_method); $dial_timeout = preg_replace('/[^0-9]/','',$dial_timeout); $field_name = preg_replace('/[^-_0-9a-zA-Z]/','',$field_name); + $lookup_state = preg_replace('/[^A-Z]/','',$lookup_state); } else { @@ -6565,7 +6569,7 @@ if ($function == 'add_lead') $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $valid_number=$row[0]; - if ($valid_number < 1) + if ( ($valid_number < 1) || (strlen($phone_number)>10) || (strlen($phone_number)<10) ) { $result_reason = "add_lead INVALID PHONE NUMBER AREACODE"; } @@ -6594,6 +6598,20 @@ if ($function == 'add_lead') } else { + ### state lookup if enabled + if ( ($lookup_state == 'Y') and (strlen($state) < 1) ) + { + $phone_areacode = substr($phone_number, 0, 3); + $stmt="SELECT state from vicidial_phone_codes where country_code='$phone_code' and areacode='$phone_areacode';"; + $rslt=mysql_to_mysqli($stmt, $link); + $vpc_recs = mysqli_num_rows($rslt); + if ($vpc_recs > 0) + { + $row=mysqli_fetch_row($rslt); + $state = $row[0]; + } + } + ### START checking for DNC if defined ### if ( ($dnc_check == 'Y') or ($dnc_check == 'AREACODE') ) {