From d522b0ff44272fe2a8687d36e0598b1ea2cf91db Mon Sep 17 00:00:00 2001 From: mattf Date: Fri, 2 Apr 2010 04:56:38 +0000 Subject: [PATCH] Added external_add_lead api.php function git-svn-id: svn://192.168.202.10@1396 3d104415-ff17-0410-8863-d5cf3c621b8a --- docs/AGENT_API.txt | 61 +++++++++++++ docs/VICIDIAL_statuses.txt | 2 +- www/agc/api.php | 169 ++++++++++++++++++++++++++++++++++++- 3 files changed, 229 insertions(+), 3 deletions(-) diff --git a/docs/AGENT_API.txt b/docs/AGENT_API.txt index 2211ac44..d349745d 100644 --- a/docs/AGENT_API.txt +++ b/docs/AGENT_API.txt @@ -15,6 +15,7 @@ external_hangup - sends command to hangup the current phone call for one specifi external_status - sends command to set the disposition for one specific agent and move on to next call external_pause - sends command to pause/resume an agent now if not on a call, or pause after their next call if on call external_dial - sends command to manually dial a number on the agent's screen +external_add_lead - Adds a lead in the manual dial list of the campaign for logged-in agent change_ingroups - changes the selected in-groups for a logged-in agent update_fields - changes values for selected data fields in the agent interface set_timer_action - sets timer action for the current call the agent is on @@ -183,6 +184,66 @@ SUCCESS: external_dial function set - 7275551212|6666|1|YES|NO|YES|123456|123202 + + +-------------------------------------------------------------------------------- +external_add_lead - + +DESCRIPTION: +Adds a lead in the manual dial list of the campaign for logged-in agent. A much simplified add lead function compared to the Non-Agent API function + +VALUES: +agent_user - + REQUIRED alphanumeric string for agent user +dnc_check - + OPTIONAL - Check for number against system DNC +campaign_dnc_check - + OPTIONAL - Check for number against campaign DNC from the agent's campaign +LEAD DATA (must populate at least one) + NOTE: Only fields that are specified in the API call will be modified + address1 + address2 + address3 + alt_phone + city + comments + country_code + date_of_birth + email + first_name + gender + gmt_offset_now + last_name + middle_initial + phone_number + phone_code + postal_code + province + security_phrase + source_id + state + title + vendor_lead_code + rank + owner + +EXAMPLE URLS: +http://server/agc/api.php?source=test&user=6666&pass=1234&agent_user=1000&function=external_add_lead&phone_number=7275551212&phone_code=1&first_name=Bob&last_name=Smith=NO&dnc_check=YES + +RESPONSES: +ERROR: external_add_lead not valid - 7275551212|1|6666| +ERROR: no user found - 6666 +ERROR: lead insertion failed - 7275551212|TESTCAMP|101|6666 +ERROR: add_lead PHONE NUMBER IN DNC - 7275551212|6666 +ERROR: add_lead PHONE NUMBER IN CAMPAIGN DNC - 7275551212|TESTCAMP|6666 +ERROR: campaign manual dial list undefined - 7275551212|TESTCAMP|6666 +ERROR: agent_user is not logged in - 6666 +SUCCESS: lead added - 7275551212|TESTCAMP|101|123456|6666 + + + + + -------------------------------------------------------------------------------- change_ingroups - diff --git a/docs/VICIDIAL_statuses.txt b/docs/VICIDIAL_statuses.txt index d3ee6c91..d7659bb7 100644 --- a/docs/VICIDIAL_statuses.txt +++ b/docs/VICIDIAL_statuses.txt @@ -16,7 +16,7 @@ AB - Busy Auto - Carrier-received Busy signal DC - Disconnected Number - Agent-Defined Disconnected number ADC - Disconnected Number Auto - Carrier-received Disconnected number DEC - Declined Sale - Agent-defined status -DNC - DO NOT CALL - If defined, lead will also go int he VICIDIAL DNC list +DNC - DO NOT CALL - If defined, lead will also go in the VICIDIAL DNC list DNCL - DO NOT CALL Hopper Match - status of a lead that matches the phone number of a lead that has been placed in the VICIDIAL DNC list DNCC - DO NOT CALL Hopper Match Campaign- status of a lead that matches the phone number of a lead that has been placed in the VICIDIAL Campaign-specific DNC list for this Campaign SALE - Sale Made - Agent-defined status diff --git a/www/agc/api.php b/www/agc/api.php index c3af234b..131cd6d2 100644 --- a/www/agc/api.php +++ b/www/agc/api.php @@ -46,9 +46,11 @@ # 91228-1059 - Added update_fields function # 100315-2021 - Added ra_call_control function # 100318-0605 - Added close_window_link and language options +# 100401-2357 - Added external_add_lead function (contributed by aouyar) +# -$version = '2.2.0-13'; -$build = '100318-0605'; +$version = '2.4-14'; +$build = '100401-2357'; require("dbconnect.php"); @@ -151,6 +153,12 @@ if (isset($_GET["status"])) {$status=$_GET["status"];} elseif (isset($_POST["status"])) {$status=$_POST["status"];} if (isset($_GET["close_window_link"])) {$close_window_link=$_GET["close_window_link"];} elseif (isset($_POST["close_window_link"])) {$close_window_link=$_POST["close_window_link"];} +if (isset($_GET["dnc_check"])) {$dnc_check=$_GET["dnc_check"];} + elseif (isset($_POST["dnc_check"])) {$dnc_check=$_POST["dnc_check"];} +if (isset($_GET["campaign_dnc_check"])) {$campaign_dnc_check=$_GET["campaign_dnc_check"];} + elseif (isset($_POST["campaign_dnc_check"])) {$campaign_dnc_check=$_POST["campaign_dnc_check"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} header ("Content-type: text/html; charset=utf-8"); @@ -783,6 +791,163 @@ if ($function == 'external_dial') +################################################################################ +### BEGIN - external_add_lead - add lead in manual dial list of the campaign for logged-in agent +################################################################################ +if ($function == 'external_add_lead') + { + if ( (strlen($value) < 1) and (strlen($phone_number) > 1) ) + {$value = $phone_number;} + if ( ( (strlen($agent_user)<2) and (strlen($alt_user)<2) ) or (strlen($phone_code)<1) or (strlen($value)<2) ) + { + $result = 'ERROR'; + $result_reason = "external_add_lead not valid"; + $data = "$value|$phone_code"; + echo "$result: $result_reason - $data|$agent_user|$alt_user\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + { + if (strlen($vendor_id) > 0 ) + { + $vendor_lead_code = $vendor_id; + } + if (strlen($alt_user)>1) + { + $stmt = "select count(*) from vicidial_users where custom_three='$alt_user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + { + $stmt = "select user from vicidial_users where custom_three='$alt_user' order by user;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $agent_user = $row[0]; + } + else + { + $result = 'ERROR'; + $result_reason = "no user found"; + echo "$result: $result_reason - $alt_user\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + } + $stmt = "select count(*) from vicidial_live_agents where user='$agent_user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + { + $stmt = "select c.campaign_id,c.manual_dial_list_id from vicidial_campaigns c,vicidial_live_agents a where a.user='$agent_user' and a.campaign_id=c.campaign_id;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $nrow=mysql_num_rows($rslt); + if ($nrow > 0) + { + $list_id = $row[1]; + $campaign_id = $row[0]; + + # DNC Check + if ($dnc_check == 'YES' or $dnc_check=='Y') + { + $stmt="SELECT count(*) from vicidial_dnc where phone_number='$value';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $dnc_found=$row[0]; + } + else + { + $dnc_found=0; + } + + # Campaign DNC Check + if ($campaign_dnc_check == 'YES' or $campaign_dnc_check=='Y') + { + $stmt="SELECT count(*) from vicidial_campaign_dnc where phone_number='$value' and campaign_id='$campaign_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $camp_dnc_found=$row[0]; + } + else + { + $camp_dnc_found=0; + } + + if ($dnc_found==0 and $camp_dnc_found==0) + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$value',list_id='$list_id',status='NEW',user='$user',vendor_lead_code='$vendor_lead_code',source_id='$source_id',title='$title',first_name='$first_name',middle_initial='$middle_initial',last_name='$last_name',address1='$address1',address2='$address2',address3='$address3',city='$city',state='$state',province='$province',postal_code='$postal_code',country_code='$country_code',gender='$gender',date_of_birth='$date_of_birth',alt_phone='$alt_phone',email='$email',security_phrase='$security_phrase',comments='$comments',called_since_last_reset='N',entry_date='$ENTRYdate',last_local_call_time='$NOW_TIME',rank='$rank',owner='$owner';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + if ($affected_rows > 0) + { + $lead_id = mysql_insert_id($link); + $result = 'SUCCESS'; + $result_reason = "lead added"; + echo "$result: $result_reason - $value|$campaign_id|$list_id|$lead_id|$agent_user\n"; + $data = "$value|$list_id|$lead_id"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + else + { + $result = 'ERROR'; + $result_reason = "lead insertion failed"; + echo "$result: $result_reason - $value|$campaign_id|$list_id|$agent_user\n"; + $data = "$value|$list_id|$stmt"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + } + else + { + if ($dnc_found>0) + { + $result = 'ERROR'; + $result_reason = "add_lead PHONE NUMBER IN DNC"; + echo "$result: $result_reason - $value|$agent_user\n"; + $data = "$value"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + if ($camp_dnc_found>0) + { + $result = 'ERROR'; + $result_reason = "add_lead PHONE NUMBER IN CAMPAIGN DNC"; + echo "$result: $result_reason - $value|$campaign_id|$agent_user\n"; + $data = "$value|$campaign_id"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + } + } + else + { + $result = 'ERROR'; + $result_reason = "campaign manual dial list undefined"; + echo "$result: $result_reason - $value|$campaign_id|$agent_user\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + } + else + { + $result = 'ERROR'; + $result_reason = "agent_user is not logged in"; + echo "$result: $result_reason - $agent_user\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + } + } +################################################################################ +### END - external_add_lead +################################################################################ + + + + ################################################################################ ### BEGIN - change_ingroups - change selected in-groups for logged-in agent ################################################################################