Added Add-to-hopper options to update_lead function in the Non-Agent API
git-svn-id: svn://192.168.202.10@2768 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -163,6 +163,8 @@ OTHER CHANGES:
|
||||
35. Added Agent Push Events, allowing for HTTP Push events to be sent on agent
|
||||
screen events. See the AGENT_EVENTS.txt doc for more details.
|
||||
|
||||
36. Added Add-to-hopper options to update_lead function in the Non-Agent API
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2017-04-23
|
||||
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2017-06-01
|
||||
|
||||
This document describes the functions of an API(Application Programming
|
||||
Interface) for all functions NOT directly relating to the VICIDIAL Agent screen.
|
||||
@@ -123,6 +123,9 @@ Changes:
|
||||
170301-1649 - Added validation that sounds web dir exists to sounds_list function
|
||||
170409-1603 - Added IP List validation code
|
||||
170423-0800 - Added force_entry_list_id option for update_lead
|
||||
170508-1048 - Added blind_monitor logging
|
||||
170527-2254 - Fix for rare inbound logging issue #1017
|
||||
170601-0747 - Added add_to_hopper options to update_lead function
|
||||
|
||||
|
||||
API Functions use the 'function' variable
|
||||
@@ -787,6 +790,9 @@ 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
|
||||
update_phone_number - Y or N, Optional setting to update the phone_number field, default is N.
|
||||
add_to_hopper - Y or N, default is N
|
||||
hopper_priority - 99 to -99, the higher number the higher priority, default is 0
|
||||
hopper_local_call_time_check - Y or N, default is N. Validate the local call time and/or state call time before inserting lead in the hopper
|
||||
|
||||
EDITABLE FIELDS-
|
||||
user_field - 1-20 characters, this updates the 'user' field in the vicidial_list table
|
||||
@@ -845,6 +851,8 @@ http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&functio
|
||||
|
||||
http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=update_lead&lead_id=406757&campaign_id=TESTCAMP&callback=Y&callback_status=CALLBK&callback_datetime=NOW&callback_type=USERONLY&callback_user=1028&callback_comments=Comments+go+here+again
|
||||
|
||||
http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=update_lead&search_location=SYSTEM&search_method=PHONE_NUMBER&phone_number=9998887112&no_update=Y&add_to_hopper=Y&hopper_priority=99&hopper_local_call_time_check=Y
|
||||
|
||||
Example responses:
|
||||
SUCCESS: update_lead LEAD HAS BEEN UPDATED - 6666|193716
|
||||
NOTICE: update_lead CUSTOM FIELDS VALUES UPDATED - 7275551111|1234|101
|
||||
@@ -867,6 +875,12 @@ NOTICE: update_lead CUSTOM FIELDS ENTRY DELETED 1 - 7275551111|6666|999|193716|-
|
||||
NOTICE: update_lead LEADS FOUND IN THE SYSTEM: |6666|1010542|12345678901234|9998887112|3333444|0
|
||||
(user|lead_id|vendorleadcode|phone |list_id|entry_list_id)
|
||||
|
||||
NOTICE: update_lead ADDED TO HOPPER - 7275551111|6666|193715|1677922
|
||||
NOTICE: update_lead NOT ADDED TO HOPPER - 7275551111|6666|193715|1677922
|
||||
NOTICE: update_lead NOT ADDED TO HOPPER, OUTSIDE OF LOCAL TIME - 7275551111|193715|-5|0|6666
|
||||
NOTICE: update_lead NOT ADDED TO HOPPER, LEAD NOT FOUND - 7275551111|193715|6666
|
||||
NOTICE: update_lead NOT ADDED TO HOPPER, LEAD IS ALREADY IN THE HOPPER - 7275551111|193715|6666
|
||||
|
||||
ERROR: update_lead INVALID DATA FOR LEAD INSERTION - 6666|||
|
||||
ERROR: update_lead NO MATCHES FOUND IN THE SYSTEM - 6666|||
|
||||
ERROR: update_lead NO VALID SEARCH METHOD - 6666|SYSTEM|||
|
||||
|
||||
@@ -119,10 +119,11 @@
|
||||
# 170423-0800 - Added force_entry_list_id option for update_lead
|
||||
# 170508-1048 - Added blind_monitor logging
|
||||
# 170527-2254 - Fix for rare inbound logging issue #1017
|
||||
# 170601-0747 - Added add_to_hopper options to update_lead function
|
||||
#
|
||||
|
||||
$version = '2.14-95';
|
||||
$build = '170527-2254';
|
||||
$version = '2.14-96';
|
||||
$build = '170601-0747';
|
||||
$api_url_log = 0;
|
||||
|
||||
$startMS = microtime();
|
||||
@@ -7770,6 +7771,7 @@ if ($function == 'update_lead')
|
||||
if ($search_found > 0)
|
||||
{
|
||||
if (strlen($lead_id)<1) {$lead_id=$search_lead_id[0];}
|
||||
if (strlen($list_id)<1) {$list_id=$search_lead_list[0];}
|
||||
$result = 'NOTICE';
|
||||
$result_reason = "update_lead LEADS FOUND IN THE SYSTEM";
|
||||
$data = "$lead_id|$vendor_lead_code|$phone_number|$search_lead_list[0]|$search_entry_list[0]";
|
||||
@@ -7783,13 +7785,16 @@ if ($function == 'update_lead')
|
||||
$data = "$lead_id|$vendor_lead_code|$phone_number";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
|
||||
exit;
|
||||
}
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($search_found > 0)
|
||||
{
|
||||
if (strlen($lead_id)<1) {$lead_id=$search_lead_id[0];}
|
||||
if (strlen($list_id)<1) {$list_id=$search_lead_list[0];}
|
||||
$VL_update_SQL='';
|
||||
##### BEGIN update lead information in the system #####
|
||||
if (strlen($user_field)>0) {$VL_update_SQL .= "user=\"$user_field\",";}
|
||||
@@ -7873,7 +7878,7 @@ if ($function == 'update_lead')
|
||||
|
||||
$result = 'SUCCESS';
|
||||
echo "$result: $result_reason - $user|$search_lead_id[$n]|$VLaffected_rows\n";
|
||||
$data = "$phone_number|$list_id|$lead_id|$gmt_offset";
|
||||
$data = "$phone_number|$search_lead_list[$n]|$search_lead_id[$n]|$gmt_offset";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
##### BEGIN scheduled callback section #####
|
||||
@@ -7921,7 +7926,7 @@ if ($function == 'update_lead')
|
||||
|
||||
$result = 'NOTICE';
|
||||
$result_reason = "update_lead SCHEDULED CALLBACK UPDATED";
|
||||
$data = "$lead_id|$campaign_id|$callback_datetime|$callback_type|$callback_user|$callback_status";
|
||||
$data = "$search_lead_id[$n]|$campaign_id|$callback_datetime|$callback_type|$callback_user|$callback_status";
|
||||
echo "$result: $result_reason - $data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
@@ -7929,7 +7934,7 @@ if ($function == 'update_lead')
|
||||
{
|
||||
$result = 'NOTICE';
|
||||
$result_reason = "update_lead SCHEDULED CALLBACK NOT UPDATED, NO FIELDS SPECIFIED";
|
||||
$data = "$lead_id|$CBupdateSQL";
|
||||
$data = "$search_lead_id[$n]|$CBupdateSQL";
|
||||
echo "$result: $result_reason - $data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
@@ -7965,7 +7970,7 @@ if ($function == 'update_lead')
|
||||
{
|
||||
$result = 'NOTICE';
|
||||
$result_reason = "update_lead SCHEDULED CALLBACK NOT ADDED, USER NOT VALID";
|
||||
$data = "$lead_id|$campaign_id|$callback_user|$callback_type";
|
||||
$data = "$search_lead_id[$n]|$campaign_id|$callback_user|$callback_type";
|
||||
echo "$result: $result_reason - $data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
@@ -7982,14 +7987,14 @@ if ($function == 'update_lead')
|
||||
if (strlen($callback_status)<1)
|
||||
{$callback_status='CALLBK';}
|
||||
|
||||
$stmt="INSERT INTO vicidial_callbacks (lead_id,list_id,campaign_id,status,entry_time,callback_time,user,recipient,comments,user_group,lead_status) values('$lead_id','$list_id','$campaign_id','ACTIVE','$NOW_TIME','$callback_datetime','$callback_user','$callback_type','$callback_comments','$user_group','$callback_status');";
|
||||
$stmt="INSERT INTO vicidial_callbacks (lead_id,list_id,campaign_id,status,entry_time,callback_time,user,recipient,comments,user_group,lead_status) values('$search_lead_id[$n]','$search_lead_list[$n]','$campaign_id','ACTIVE','$NOW_TIME','$callback_datetime','$callback_user','$callback_type','$callback_comments','$user_group','$callback_status');";
|
||||
if ($DB>0) {echo "DEBUG: update_lead query - $stmt\n";}
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
$CBaffected_rows = mysqli_affected_rows($link);
|
||||
|
||||
$result = 'NOTICE';
|
||||
$result_reason = "update_lead SCHEDULED CALLBACK ADDED";
|
||||
$data = "$lead_id|$campaign_id|$callback_datetime|$callback_type|$callback_user|$callback_status";
|
||||
$data = "$search_lead_id[$n]|$campaign_id|$callback_datetime|$callback_type|$callback_user|$callback_status";
|
||||
echo "$result: $result_reason - $data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
@@ -7998,7 +8003,7 @@ if ($function == 'update_lead')
|
||||
{
|
||||
$result = 'NOTICE';
|
||||
$result_reason = "update_lead SCHEDULED CALLBACK NOT ADDED, CAMPAIGN NOT VALID";
|
||||
$data = "$lead_id|$campaign_id";
|
||||
$data = "$search_lead_id[$n]|$campaign_id";
|
||||
echo "$result: $result_reason - $data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
@@ -8051,7 +8056,7 @@ if ($function == 'update_lead')
|
||||
$result = 'NOTICE';
|
||||
$result_reason = "update_lead CUSTOM FIELDS ENTRY DELETED";
|
||||
echo "$result: $result_reason - $phone_number|$search_lead_id[$n]|$search_lead_list[$n]|$search_entry_list[$n]|$lead_custom_list|$custom_update_count\n";
|
||||
$data = "$phone_number|$lead_id|$list_id|$VCLDaffected_rows";
|
||||
$data = "$phone_number|$search_lead_id[$n]|$search_lead_list[$n]|$VCLDaffected_rows";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
}
|
||||
@@ -8146,7 +8151,7 @@ if ($function == 'update_lead')
|
||||
$result = 'NOTICE';
|
||||
$result_reason = "update_lead CUSTOM FIELDS VALUES UPDATED";
|
||||
echo "$result: $result_reason - $phone_number|$search_lead_id[$n]|$search_lead_list[$n]|$search_entry_list[$n]|$lead_custom_list|$custom_update_count\n";
|
||||
$data = "$phone_number|$lead_id|$list_id";
|
||||
$data = "$phone_number|$search_lead_id[$n]|$search_lead_list[$n]";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
|
||||
$update_sent++;
|
||||
@@ -8166,8 +8171,8 @@ if ($function == 'update_lead')
|
||||
{
|
||||
$result = 'NOTICE';
|
||||
$result_reason = "update_lead CUSTOM FIELDS NOT ADDED, NO CUSTOM FIELDS DEFINED FOR THIS LIST";
|
||||
echo "$result: $result_reason - $phone_number|$lead_id|$list_id\n";
|
||||
$data = "$phone_number|$lead_id|$list_id";
|
||||
echo "$result: $result_reason - $phone_number|$search_lead_id[$n]|$search_lead_list[$n]\n";
|
||||
$data = "$phone_number|$search_lead_id[$n]|$search_lead_list[$n]";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
}
|
||||
@@ -8416,6 +8421,99 @@ if ($function == 'update_lead')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
### BEGIN add to hopper section ###
|
||||
if ( ($add_to_hopper == 'Y') and ($search_found > 0) )
|
||||
{
|
||||
$stmt="SELECT count(*) from vicidial_hopper where lead_id='$lead_id';";
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
$row=mysqli_fetch_row($rslt);
|
||||
$hopper_lead_count = $row[0];
|
||||
|
||||
if ($hopper_lead_count < 1)
|
||||
{
|
||||
$dialable=1;
|
||||
|
||||
$stmt="SELECT vicidial_campaigns.local_call_time,vicidial_lists.local_call_time,vicidial_campaigns.campaign_id from vicidial_campaigns,vicidial_lists where list_id='$list_id' and vicidial_campaigns.campaign_id=vicidial_lists.campaign_id;";
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
$row=mysqli_fetch_row($rslt);
|
||||
$local_call_time = $row[0];
|
||||
$list_local_call_time = $row[1];
|
||||
$VD_campaign_id = $row[2];
|
||||
|
||||
if ($DB > 0) {echo "DEBUG call time: |$local_call_time|$list_local_call_time|$VD_campaign_id|";}
|
||||
if ( ($list_local_call_time!='') and (!preg_match("/^campaign$/i",$list_local_call_time)) )
|
||||
{$local_call_time = $list_local_call_time;}
|
||||
|
||||
$stmt="SELECT state,vendor_lead_code,gmt_offset_now from vicidial_list where lead_id='$lead_id';";
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
$ulhi_recs = mysqli_num_rows($rslt);
|
||||
if ($ulhi_recs > 0)
|
||||
{
|
||||
$row=mysqli_fetch_row($rslt);
|
||||
$state = $row[0];
|
||||
$vendor_lead_code = $row[1];
|
||||
$gmt_offset = $row[2];
|
||||
|
||||
if ($hopper_local_call_time_check == 'Y')
|
||||
{
|
||||
### call function to determine if lead is dialable
|
||||
$dialable = dialable_gmt($DB,$link,$local_call_time,$gmt_offset,$state);
|
||||
}
|
||||
if ($dialable < 1)
|
||||
{
|
||||
$result = 'NOTICE';
|
||||
$result_reason = "update_lead NOT ADDED TO HOPPER, OUTSIDE OF LOCAL TIME";
|
||||
echo "$result: $result_reason - $phone_number|$lead_id|$gmt_offset|$dialable|$user\n";
|
||||
$data = "$phone_number|$lead_id|$gmt_offset|$dialable|$state";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
else
|
||||
{
|
||||
### insert record into vicidial_hopper
|
||||
$stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$VD_campaign_id',status='READY',list_id='$list_id',gmt_offset_now='$gmt_offset',state='$state',user='',priority='$hopper_priority',source='P',vendor_lead_code=\"$vendor_lead_code\";";
|
||||
if ($DB>0) {echo "DEBUG: update_lead query - $stmt\n";}
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
$Haffected_rows = mysqli_affected_rows($link);
|
||||
if ($Haffected_rows > 0)
|
||||
{
|
||||
$hopper_id = mysqli_insert_id($link);
|
||||
|
||||
$result = 'NOTICE';
|
||||
$result_reason = "update_lead ADDED TO HOPPER";
|
||||
echo "$result: $result_reason - $phone_number|$lead_id|$hopper_id|$user\n";
|
||||
$data = "$phone_number|$lead_id|$hopper_id";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = 'NOTICE';
|
||||
$result_reason = "update_lead NOT ADDED TO HOPPER";
|
||||
echo "$result: $result_reason - $phone_number|$lead_id|$stmt|$user\n";
|
||||
$data = "$phone_number|$lead_id|$stmt";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = 'NOTICE';
|
||||
$result_reason = "update_lead NOT ADDED TO HOPPER, LEAD NOT FOUND";
|
||||
echo "$result: $result_reason - $phone_number|$lead_id|$user\n";
|
||||
$data = "$phone_number|$lead_id|$user";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = 'NOTICE';
|
||||
$result_reason = "update_lead NOT ADDED TO HOPPER, LEAD IS ALREADY IN THE HOPPER";
|
||||
echo "$result: $result_reason - $phone_number|$lead_id|$user\n";
|
||||
$data = "$phone_number|$lead_id|$user";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
}
|
||||
### END add to hopper section ###
|
||||
}
|
||||
}
|
||||
exit;
|
||||
|
||||
Reference in New Issue
Block a user