|
|
|
@@ -34,10 +34,11 @@
|
|
|
|
|
# 100704-1148 - Added custom fields inserts to the add_lead function
|
|
|
|
|
# 100712-1416 - Added entry_list_id field to vicidial_list to preserve link to custom fields if any
|
|
|
|
|
# 100718-0245 - Added update_lead function to update existing leads
|
|
|
|
|
# 100723-1333 - Added no_update option to the update_lead function
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
$version = '2.4-20';
|
|
|
|
|
$build = '100718-0245';
|
|
|
|
|
$version = '2.4-21';
|
|
|
|
|
$build = '100723-1333';
|
|
|
|
|
|
|
|
|
|
require("dbconnect.php");
|
|
|
|
|
|
|
|
|
@@ -150,6 +151,8 @@ if (isset($_GET["list_id_field"])) {$list_id_field=$_GET["list_id_field"];}
|
|
|
|
|
elseif (isset($_POST["list_id_field"])) {$list_id_field=$_POST["list_id_field"];}
|
|
|
|
|
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
|
|
|
|
|
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
|
|
|
|
|
if (isset($_GET["no_update"])) {$no_update=$_GET["no_update"];}
|
|
|
|
|
elseif (isset($_POST["no_update"])) {$no_update=$_POST["no_update"];}
|
|
|
|
|
|
|
|
|
|
header ("Content-type: text/html; charset=utf-8");
|
|
|
|
|
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
|
|
|
|
@@ -238,6 +241,7 @@ if ($non_latin < 1)
|
|
|
|
|
$user_field = ereg_replace("[^-_0-9a-zA-Z]","",$user_field);
|
|
|
|
|
$list_id_field = ereg_replace("[^0-9]","",$list_id_field);
|
|
|
|
|
$lead_id = ereg_replace("[^0-9]","",$lead_id);
|
|
|
|
|
$no_update = ereg_replace("[^A-Z]","",$no_update);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@@ -1841,322 +1845,353 @@ if ($function == 'update_lead')
|
|
|
|
|
}
|
|
|
|
|
### END searching ###
|
|
|
|
|
|
|
|
|
|
if ($search_found > 0)
|
|
|
|
|
if ($no_update=='Y')
|
|
|
|
|
{
|
|
|
|
|
$VL_update_SQL='';
|
|
|
|
|
##### BEGIN update lead information in the system #####
|
|
|
|
|
if (strlen($user_field)>0) {$VL_update_SQL .= "user='$user_field',";}
|
|
|
|
|
if (strlen($list_id_field)>0) {$VL_update_SQL .= "list_id='$list_id_field',";}
|
|
|
|
|
if (strlen($status)>0) {$VL_update_SQL .= "status='$status',";}
|
|
|
|
|
if (strlen($vendor_lead_code)>0) {$VL_update_SQL .= "vendor_lead_code='$vendor_lead_code',";}
|
|
|
|
|
if (strlen($source_id)>0) {$VL_update_SQL .= "source_id='$source_id',";}
|
|
|
|
|
if (strlen($gmt_offset_now)>0) {$VL_update_SQL .= "gmt_offset_now='$gmt_offset_now',";}
|
|
|
|
|
if (strlen($title)>0) {$VL_update_SQL .= "title='$title',";}
|
|
|
|
|
if (strlen($first_name)>0) {$VL_update_SQL .= "first_name='$first_name',";}
|
|
|
|
|
if (strlen($middle_initial)>0) {$VL_update_SQL .= "middle_initial='$middle_initial',";}
|
|
|
|
|
if (strlen($last_name)>0) {$VL_update_SQL .= "last_name='$last_name',";}
|
|
|
|
|
if (strlen($address1)>0) {$VL_update_SQL .= "address1='$address1',";}
|
|
|
|
|
if (strlen($address2)>0) {$VL_update_SQL .= "address2='$address2',";}
|
|
|
|
|
if (strlen($address3)>0) {$VL_update_SQL .= "address3='$address3',";}
|
|
|
|
|
if (strlen($city)>0) {$VL_update_SQL .= "city='$city',";}
|
|
|
|
|
if (strlen($state)>0) {$VL_update_SQL .= "state='$state',";}
|
|
|
|
|
if (strlen($province)>0) {$VL_update_SQL .= "province='$province',";}
|
|
|
|
|
if (strlen($postal_code)>0) {$VL_update_SQL .= "postal_code='$postal_code',";}
|
|
|
|
|
if (strlen($country_code)>0) {$VL_update_SQL .= "country_code='$country_code',";}
|
|
|
|
|
if (strlen($gender)>0) {$VL_update_SQL .= "gender='$gender',";}
|
|
|
|
|
if (strlen($date_of_birth)>0) {$VL_update_SQL .= "date_of_birth='$date_of_birth',";}
|
|
|
|
|
if (strlen($alt_phone)>0) {$VL_update_SQL .= "alt_phone='$alt_phone',";}
|
|
|
|
|
if (strlen($email)>0) {$VL_update_SQL .= "email='$email',";}
|
|
|
|
|
if (strlen($security_phrase)>0) {$VL_update_SQL .= "security_phrase='$security_phrase',";}
|
|
|
|
|
if (strlen($comments)>0) {$VL_update_SQL .= "comments='$comments',";}
|
|
|
|
|
if (strlen($rank)>0) {$VL_update_SQL .= "rank='$rank',";}
|
|
|
|
|
if (strlen($owner)>0) {$VL_update_SQL .= "owner='$owner',";}
|
|
|
|
|
$VL_update_SQL = preg_replace("/,$/","",$VL_update_SQL);
|
|
|
|
|
$VL_update_SQL = preg_replace("/'--BLANK--'/","''",$VL_update_SQL);
|
|
|
|
|
$VL_update_SQL = preg_replace("/\n/","!N",$VL_update_SQL);
|
|
|
|
|
|
|
|
|
|
$n=0;
|
|
|
|
|
while ($search_found > $n)
|
|
|
|
|
if ($search_found > 0)
|
|
|
|
|
{
|
|
|
|
|
$VLaffected_rows=0;
|
|
|
|
|
$CFaffected_rows=0;
|
|
|
|
|
if (strlen($VL_update_SQL)>6)
|
|
|
|
|
{
|
|
|
|
|
$stmt = "UPDATE vicidial_list SET $VL_update_SQL where lead_id='$search_lead_id[$n]';";
|
|
|
|
|
if ($DB>0) {echo "DEBUG: update_lead query - $stmt\n";}
|
|
|
|
|
$rslt=mysql_query($stmt, $link);
|
|
|
|
|
$VLaffected_rows = mysql_affected_rows($link);
|
|
|
|
|
|
|
|
|
|
$result = 'SUCCESS';
|
|
|
|
|
$result_reason = "update_lead LEAD HAS BEEN UPDATED";
|
|
|
|
|
echo "$result: $result_reason - $user|$search_lead_id[$n]\n";
|
|
|
|
|
$data = "$phone_number|$list_id|$lead_id|$gmt_offset";
|
|
|
|
|
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
|
|
|
|
}
|
|
|
|
|
##### BEGIN custom fields update query build #####
|
|
|
|
|
if ($custom_fields=='Y')
|
|
|
|
|
{
|
|
|
|
|
$lead_custom_list = $search_lead_list[$n];
|
|
|
|
|
if ($search_entry_list[$n] > 99) {$lead_custom_list = $search_entry_list[$n];}
|
|
|
|
|
$update_sent=0;
|
|
|
|
|
$CFoutput='';
|
|
|
|
|
$stmt="SHOW TABLES LIKE \"custom_$lead_custom_list\";";
|
|
|
|
|
if ($DB>0) {echo "$stmt";}
|
|
|
|
|
$rslt=mysql_query($stmt, $link);
|
|
|
|
|
$tablecount_to_print = mysql_num_rows($rslt);
|
|
|
|
|
if ($tablecount_to_print > 0)
|
|
|
|
|
{
|
|
|
|
|
$update_SQL='';
|
|
|
|
|
$VL_update_SQL='';
|
|
|
|
|
$stmt="SELECT field_id,field_label,field_name,field_description,field_rank,field_help,field_type,field_options,field_size,field_max,field_default,field_cost,field_required,multi_position,name_position,field_order from vicidial_lists_fields where list_id='$lead_custom_list' order by field_rank,field_order,field_label;";
|
|
|
|
|
$rslt=mysql_query($stmt, $link);
|
|
|
|
|
$fields_to_print = mysql_num_rows($rslt);
|
|
|
|
|
$fields_list='';
|
|
|
|
|
$o=0;
|
|
|
|
|
while ($fields_to_print > $o)
|
|
|
|
|
{
|
|
|
|
|
$new_field_value='';
|
|
|
|
|
$form_field_value='';
|
|
|
|
|
$rowx=mysql_fetch_row($rslt);
|
|
|
|
|
$A_field_id[$o] = $rowx[0];
|
|
|
|
|
$A_field_label[$o] = $rowx[1];
|
|
|
|
|
$A_field_name[$o] = $rowx[2];
|
|
|
|
|
$A_field_type[$o] = $rowx[6];
|
|
|
|
|
$A_field_size[$o] = $rowx[8];
|
|
|
|
|
$A_field_max[$o] = $rowx[9];
|
|
|
|
|
$A_field_required[$o] = $rowx[12];
|
|
|
|
|
$A_field_value[$o] = '';
|
|
|
|
|
$field_name_id = $A_field_label[$o];
|
|
|
|
|
|
|
|
|
|
if (isset($_GET["$field_name_id"])) {$form_field_value=$_GET["$field_name_id"];}
|
|
|
|
|
elseif (isset($_POST["$field_name_id"])) {$form_field_value=$_POST["$field_name_id"];}
|
|
|
|
|
|
|
|
|
|
$A_field_value[$o] = $form_field_value;
|
|
|
|
|
|
|
|
|
|
if ( ($A_field_type[$o]=='DISPLAY') or ($A_field_type[$o]=='SCRIPT') )
|
|
|
|
|
{
|
|
|
|
|
$A_field_value[$o]='----IGNORE----';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!preg_match("/\|$A_field_label[$o]\|/",$vicidial_list_fields))
|
|
|
|
|
{
|
|
|
|
|
$update_SQL .= "$A_field_label[$o]='$A_field_value[$o]',";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$o++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$custom_update_count=0;
|
|
|
|
|
if (strlen($update_SQL)>3)
|
|
|
|
|
{
|
|
|
|
|
$custom_record_lead_count=0;
|
|
|
|
|
$stmt="SELECT count(*) from custom_$lead_custom_list where lead_id='$search_lead_id[$n]';";
|
|
|
|
|
if ($DB>0) {echo "$stmt";}
|
|
|
|
|
$rslt=mysql_query($stmt, $link);
|
|
|
|
|
$fieldleadcount_to_print = mysql_num_rows($rslt);
|
|
|
|
|
if ($fieldleadcount_to_print > 0)
|
|
|
|
|
{
|
|
|
|
|
$rowx=mysql_fetch_row($rslt);
|
|
|
|
|
$custom_record_lead_count = $rowx[0];
|
|
|
|
|
}
|
|
|
|
|
$update_SQL = preg_replace("/,$/","",$update_SQL);
|
|
|
|
|
$custom_table_update_SQL = "INSERT INTO custom_$lead_custom_list SET lead_id='$search_lead_id[$n]',$update_SQL;";
|
|
|
|
|
if ($custom_record_lead_count > 0)
|
|
|
|
|
{$custom_table_update_SQL = "UPDATE custom_$lead_custom_list SET $update_SQL where lead_id='$search_lead_id[$n]';";}
|
|
|
|
|
|
|
|
|
|
$rslt=mysql_query($custom_table_update_SQL, $link);
|
|
|
|
|
$custom_update_count = mysql_affected_rows($link);
|
|
|
|
|
if ($DB) {echo "$custom_update_count|$custom_table_update_SQL\n";}
|
|
|
|
|
if (!$rslt) {die('Could not execute: ' . mysql_error());}
|
|
|
|
|
|
|
|
|
|
$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";
|
|
|
|
|
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
|
|
|
|
|
|
|
|
|
$update_sent++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($custom_update_count > 0)
|
|
|
|
|
{
|
|
|
|
|
$list_table_update_SQL = "UPDATE vicidial_list SET entry_list_id='$lead_custom_list' where lead_id='$search_lead_id[$n]';";
|
|
|
|
|
$rslt=mysql_query($list_table_update_SQL, $link);
|
|
|
|
|
$list_update_count = mysql_affected_rows($link);
|
|
|
|
|
if ($DB) {echo "$list_update_count|$list_table_update_SQL\n";}
|
|
|
|
|
if (!$rslt) {die('Could not execute: ' . mysql_error());}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$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";
|
|
|
|
|
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
##### END custom fields update query build #####
|
|
|
|
|
|
|
|
|
|
$n++;
|
|
|
|
|
$result = 'NOTICE';
|
|
|
|
|
$result_reason = "update_lead LEADS FOUND IN THE SYSTEM";
|
|
|
|
|
$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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
##### END update lead information in the system #####
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$result = 'NOTICE';
|
|
|
|
|
$result_reason = "update_lead NO MATCHES FOUND IN THE SYSTEM";
|
|
|
|
|
$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;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$result = 'ERROR';
|
|
|
|
|
if ($insert_if_not_found=='Y')
|
|
|
|
|
{$result = 'NOTICE';}
|
|
|
|
|
$result_reason = "update_lead NO MATCHES FOUND IN THE SYSTEM";
|
|
|
|
|
$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);
|
|
|
|
|
if ($insert_if_not_found!='Y')
|
|
|
|
|
{exit;}
|
|
|
|
|
else
|
|
|
|
|
if ($search_found > 0)
|
|
|
|
|
{
|
|
|
|
|
if (strlen($list_id_field)>0) {$list_id=$list_id_field;}
|
|
|
|
|
##### BEGIN insert not-found lead into the system #####
|
|
|
|
|
if ( (strlen($phone_number)<6) or (strlen($phone_number)>18) or (strlen($phone_code)<1) or (strlen($list_id)<3) )
|
|
|
|
|
{
|
|
|
|
|
$result = 'ERROR';
|
|
|
|
|
$result_reason = "update_lead INVALID DATA FOR LEAD INSERTION";
|
|
|
|
|
$data = "$phone_number|$phone_code|$list_id|$insert_if_not_found";
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
### get current gmt_offset of the phone_number
|
|
|
|
|
$gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code);
|
|
|
|
|
$VL_update_SQL='';
|
|
|
|
|
##### BEGIN update lead information in the system #####
|
|
|
|
|
if (strlen($user_field)>0) {$VL_update_SQL .= "user='$user_field',";}
|
|
|
|
|
if (strlen($list_id_field)>0) {$VL_update_SQL .= "list_id='$list_id_field',";}
|
|
|
|
|
if (strlen($status)>0) {$VL_update_SQL .= "status='$status',";}
|
|
|
|
|
if (strlen($vendor_lead_code)>0) {$VL_update_SQL .= "vendor_lead_code='$vendor_lead_code',";}
|
|
|
|
|
if (strlen($source_id)>0) {$VL_update_SQL .= "source_id='$source_id',";}
|
|
|
|
|
if (strlen($gmt_offset_now)>0) {$VL_update_SQL .= "gmt_offset_now='$gmt_offset_now',";}
|
|
|
|
|
if (strlen($title)>0) {$VL_update_SQL .= "title='$title',";}
|
|
|
|
|
if (strlen($first_name)>0) {$VL_update_SQL .= "first_name='$first_name',";}
|
|
|
|
|
if (strlen($middle_initial)>0) {$VL_update_SQL .= "middle_initial='$middle_initial',";}
|
|
|
|
|
if (strlen($last_name)>0) {$VL_update_SQL .= "last_name='$last_name',";}
|
|
|
|
|
if (strlen($address1)>0) {$VL_update_SQL .= "address1='$address1',";}
|
|
|
|
|
if (strlen($address2)>0) {$VL_update_SQL .= "address2='$address2',";}
|
|
|
|
|
if (strlen($address3)>0) {$VL_update_SQL .= "address3='$address3',";}
|
|
|
|
|
if (strlen($city)>0) {$VL_update_SQL .= "city='$city',";}
|
|
|
|
|
if (strlen($state)>0) {$VL_update_SQL .= "state='$state',";}
|
|
|
|
|
if (strlen($province)>0) {$VL_update_SQL .= "province='$province',";}
|
|
|
|
|
if (strlen($postal_code)>0) {$VL_update_SQL .= "postal_code='$postal_code',";}
|
|
|
|
|
if (strlen($country_code)>0) {$VL_update_SQL .= "country_code='$country_code',";}
|
|
|
|
|
if (strlen($gender)>0) {$VL_update_SQL .= "gender='$gender',";}
|
|
|
|
|
if (strlen($date_of_birth)>0) {$VL_update_SQL .= "date_of_birth='$date_of_birth',";}
|
|
|
|
|
if (strlen($alt_phone)>0) {$VL_update_SQL .= "alt_phone='$alt_phone',";}
|
|
|
|
|
if (strlen($email)>0) {$VL_update_SQL .= "email='$email',";}
|
|
|
|
|
if (strlen($security_phrase)>0) {$VL_update_SQL .= "security_phrase='$security_phrase',";}
|
|
|
|
|
if (strlen($comments)>0) {$VL_update_SQL .= "comments='$comments',";}
|
|
|
|
|
if (strlen($rank)>0) {$VL_update_SQL .= "rank='$rank',";}
|
|
|
|
|
if (strlen($owner)>0) {$VL_update_SQL .= "owner='$owner',";}
|
|
|
|
|
$VL_update_SQL = preg_replace("/,$/","",$VL_update_SQL);
|
|
|
|
|
$VL_update_SQL = preg_replace("/'--BLANK--'/","''",$VL_update_SQL);
|
|
|
|
|
$VL_update_SQL = preg_replace("/\n/","!N",$VL_update_SQL);
|
|
|
|
|
|
|
|
|
|
if (strlen($status)<1)
|
|
|
|
|
{$status='NEW';}
|
|
|
|
|
### insert a new lead in the system with this phone number
|
|
|
|
|
$stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='$status',user='$user',vendor_lead_code='$vendor_lead_code',source_id='$source_id',gmt_offset_now='$gmt_offset',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',entry_list_id='0';";
|
|
|
|
|
if ($DB>0) {echo "DEBUG: update_lead query - $stmt\n";}
|
|
|
|
|
$rslt=mysql_query($stmt, $link);
|
|
|
|
|
$affected_rows = mysql_affected_rows($link);
|
|
|
|
|
if ($affected_rows > 0)
|
|
|
|
|
$n=0;
|
|
|
|
|
while ($search_found > $n)
|
|
|
|
|
{
|
|
|
|
|
$VLaffected_rows=0;
|
|
|
|
|
$CFaffected_rows=0;
|
|
|
|
|
if (strlen($VL_update_SQL)>6)
|
|
|
|
|
{
|
|
|
|
|
$lead_id = mysql_insert_id($link);
|
|
|
|
|
$stmt = "UPDATE vicidial_list SET $VL_update_SQL where lead_id='$search_lead_id[$n]';";
|
|
|
|
|
if ($DB>0) {echo "DEBUG: update_lead query - $stmt\n";}
|
|
|
|
|
$rslt=mysql_query($stmt, $link);
|
|
|
|
|
$VLaffected_rows = mysql_affected_rows($link);
|
|
|
|
|
|
|
|
|
|
$result = 'SUCCESS';
|
|
|
|
|
$result_reason = "update_lead LEAD HAS BEEN ADDED";
|
|
|
|
|
echo "$result: $result_reason - $phone_number|$list_id|$lead_id|$gmt_offset|$user\n";
|
|
|
|
|
$result_reason = "update_lead LEAD HAS BEEN UPDATED";
|
|
|
|
|
echo "$result: $result_reason - $user|$search_lead_id[$n]\n";
|
|
|
|
|
$data = "$phone_number|$list_id|$lead_id|$gmt_offset";
|
|
|
|
|
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
|
|
|
|
|
|
|
|
|
if (strlen($multi_alt_phones) > 5)
|
|
|
|
|
}
|
|
|
|
|
##### BEGIN custom fields update query build #####
|
|
|
|
|
if ($custom_fields=='Y')
|
|
|
|
|
{
|
|
|
|
|
$lead_custom_list = $search_lead_list[$n];
|
|
|
|
|
if ($search_entry_list[$n] > 99) {$lead_custom_list = $search_entry_list[$n];}
|
|
|
|
|
$update_sent=0;
|
|
|
|
|
$CFoutput='';
|
|
|
|
|
$stmt="SHOW TABLES LIKE \"custom_$lead_custom_list\";";
|
|
|
|
|
if ($DB>0) {echo "$stmt";}
|
|
|
|
|
$rslt=mysql_query($stmt, $link);
|
|
|
|
|
$tablecount_to_print = mysql_num_rows($rslt);
|
|
|
|
|
if ($tablecount_to_print > 0)
|
|
|
|
|
{
|
|
|
|
|
$map=$MT; $ALTm_phone_code=$MT; $ALTm_phone_number=$MT; $ALTm_phone_note=$MT;
|
|
|
|
|
$map = explode('!', $multi_alt_phones);
|
|
|
|
|
$map_count = count($map);
|
|
|
|
|
if ($DB>0) {echo "DEBUG: update_lead multi-al-entry - $a|$map_count|$multi_alt_phones\n";}
|
|
|
|
|
$g++;
|
|
|
|
|
$r=0; $s=0; $inserted_alt_phones=0;
|
|
|
|
|
while ($r < $map_count)
|
|
|
|
|
$update_SQL='';
|
|
|
|
|
$VL_update_SQL='';
|
|
|
|
|
$stmt="SELECT field_id,field_label,field_name,field_description,field_rank,field_help,field_type,field_options,field_size,field_max,field_default,field_cost,field_required,multi_position,name_position,field_order from vicidial_lists_fields where list_id='$lead_custom_list' order by field_rank,field_order,field_label;";
|
|
|
|
|
$rslt=mysql_query($stmt, $link);
|
|
|
|
|
$fields_to_print = mysql_num_rows($rslt);
|
|
|
|
|
$fields_list='';
|
|
|
|
|
$o=0;
|
|
|
|
|
while ($fields_to_print > $o)
|
|
|
|
|
{
|
|
|
|
|
$s++;
|
|
|
|
|
$ncn=$MT;
|
|
|
|
|
$ncn = explode('_', $map[$r]);
|
|
|
|
|
print "$ncn[0]|$ncn[1]|$ncn[2]";
|
|
|
|
|
$new_field_value='';
|
|
|
|
|
$form_field_value='';
|
|
|
|
|
$rowx=mysql_fetch_row($rslt);
|
|
|
|
|
$A_field_id[$o] = $rowx[0];
|
|
|
|
|
$A_field_label[$o] = $rowx[1];
|
|
|
|
|
$A_field_name[$o] = $rowx[2];
|
|
|
|
|
$A_field_type[$o] = $rowx[6];
|
|
|
|
|
$A_field_size[$o] = $rowx[8];
|
|
|
|
|
$A_field_max[$o] = $rowx[9];
|
|
|
|
|
$A_field_required[$o] = $rowx[12];
|
|
|
|
|
$A_field_value[$o] = '';
|
|
|
|
|
$field_name_id = $A_field_label[$o];
|
|
|
|
|
|
|
|
|
|
if (strlen($forcephonecode) > 0)
|
|
|
|
|
{$ALTm_phone_code[$r] = $forcephonecode;}
|
|
|
|
|
if (isset($_GET["$field_name_id"])) {$form_field_value=$_GET["$field_name_id"];}
|
|
|
|
|
elseif (isset($_POST["$field_name_id"])) {$form_field_value=$_POST["$field_name_id"];}
|
|
|
|
|
|
|
|
|
|
$A_field_value[$o] = $form_field_value;
|
|
|
|
|
|
|
|
|
|
if ( ($A_field_type[$o]=='DISPLAY') or ($A_field_type[$o]=='SCRIPT') )
|
|
|
|
|
{
|
|
|
|
|
$A_field_value[$o]='----IGNORE----';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{$ALTm_phone_code[$r] = $ncn[1];}
|
|
|
|
|
if (strlen($ALTm_phone_code[$r]) < 1)
|
|
|
|
|
{$ALTm_phone_code[$r]='1';}
|
|
|
|
|
$ALTm_phone_number[$r] = $ncn[0];
|
|
|
|
|
$ALTm_phone_note[$r] = $ncn[2];
|
|
|
|
|
$stmt = "INSERT INTO vicidial_list_alt_phones (lead_id,phone_code,phone_number,alt_phone_note,alt_phone_count) values('$lead_id','$ALTm_phone_code[$r]','$ALTm_phone_number[$r]','$ALTm_phone_note[$r]','$s');";
|
|
|
|
|
if ($DB>0) {echo "DEBUG: update_lead query - $stmt\n";}
|
|
|
|
|
$rslt=mysql_query($stmt, $link);
|
|
|
|
|
$Zaffected_rows = mysql_affected_rows($link);
|
|
|
|
|
$inserted_alt_phones = ($inserted_alt_phones + $Zaffected_rows);
|
|
|
|
|
$r++;
|
|
|
|
|
{
|
|
|
|
|
if (!preg_match("/\|$A_field_label[$o]\|/",$vicidial_list_fields))
|
|
|
|
|
{
|
|
|
|
|
$update_SQL .= "$A_field_label[$o]='$A_field_value[$o]',";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$o++;
|
|
|
|
|
}
|
|
|
|
|
$result = 'NOTICE';
|
|
|
|
|
$result_reason = "update_lead MULTI-ALT-PHONE NUMBERS LOADED";
|
|
|
|
|
echo "$result: $result_reason - $inserted_alt_phones|$lead_id|$user\n";
|
|
|
|
|
$data = "$inserted_alt_phones|$lead_id";
|
|
|
|
|
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### BEGIN custom fields insert section ###
|
|
|
|
|
if ($custom_fields == 'Y')
|
|
|
|
|
{
|
|
|
|
|
if ($custom_fields_enabled > 0)
|
|
|
|
|
$custom_update_count=0;
|
|
|
|
|
if (strlen($update_SQL)>3)
|
|
|
|
|
{
|
|
|
|
|
$stmt="SHOW TABLES LIKE \"custom_$list_id\";";
|
|
|
|
|
$custom_record_lead_count=0;
|
|
|
|
|
$stmt="SELECT count(*) from custom_$lead_custom_list where lead_id='$search_lead_id[$n]';";
|
|
|
|
|
if ($DB>0) {echo "$stmt";}
|
|
|
|
|
$rslt=mysql_query($stmt, $link);
|
|
|
|
|
$tablecount_to_print = mysql_num_rows($rslt);
|
|
|
|
|
if ($tablecount_to_print > 0)
|
|
|
|
|
$fieldleadcount_to_print = mysql_num_rows($rslt);
|
|
|
|
|
if ($fieldleadcount_to_print > 0)
|
|
|
|
|
{
|
|
|
|
|
$CFinsert_SQL='';
|
|
|
|
|
$stmt="SELECT field_id,field_label,field_name,field_description,field_rank,field_help,field_type,field_options,field_size,field_max,field_default,field_cost,field_required,multi_position,name_position,field_order from vicidial_lists_fields where list_id='$list_id' order by field_rank,field_order,field_label;";
|
|
|
|
|
$rowx=mysql_fetch_row($rslt);
|
|
|
|
|
$custom_record_lead_count = $rowx[0];
|
|
|
|
|
}
|
|
|
|
|
$update_SQL = preg_replace("/,$/","",$update_SQL);
|
|
|
|
|
$custom_table_update_SQL = "INSERT INTO custom_$lead_custom_list SET lead_id='$search_lead_id[$n]',$update_SQL;";
|
|
|
|
|
if ($custom_record_lead_count > 0)
|
|
|
|
|
{$custom_table_update_SQL = "UPDATE custom_$lead_custom_list SET $update_SQL where lead_id='$search_lead_id[$n]';";}
|
|
|
|
|
|
|
|
|
|
$rslt=mysql_query($custom_table_update_SQL, $link);
|
|
|
|
|
$custom_update_count = mysql_affected_rows($link);
|
|
|
|
|
if ($DB) {echo "$custom_update_count|$custom_table_update_SQL\n";}
|
|
|
|
|
if (!$rslt) {die('Could not execute: ' . mysql_error());}
|
|
|
|
|
|
|
|
|
|
$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";
|
|
|
|
|
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
|
|
|
|
|
|
|
|
|
$update_sent++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($custom_update_count > 0)
|
|
|
|
|
{
|
|
|
|
|
$list_table_update_SQL = "UPDATE vicidial_list SET entry_list_id='$lead_custom_list' where lead_id='$search_lead_id[$n]';";
|
|
|
|
|
$rslt=mysql_query($list_table_update_SQL, $link);
|
|
|
|
|
$list_update_count = mysql_affected_rows($link);
|
|
|
|
|
if ($DB) {echo "$list_update_count|$list_table_update_SQL\n";}
|
|
|
|
|
if (!$rslt) {die('Could not execute: ' . mysql_error());}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$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";
|
|
|
|
|
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
##### END custom fields update query build #####
|
|
|
|
|
|
|
|
|
|
$n++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
##### END update lead information in the system #####
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$result = 'ERROR';
|
|
|
|
|
if ($insert_if_not_found=='Y')
|
|
|
|
|
{$result = 'NOTICE';}
|
|
|
|
|
$result_reason = "update_lead NO MATCHES FOUND IN THE SYSTEM";
|
|
|
|
|
$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);
|
|
|
|
|
if ($insert_if_not_found!='Y')
|
|
|
|
|
{exit;}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (strlen($list_id_field)>0) {$list_id=$list_id_field;}
|
|
|
|
|
##### BEGIN insert not-found lead into the system #####
|
|
|
|
|
if ( (strlen($phone_number)<6) or (strlen($phone_number)>18) or (strlen($phone_code)<1) or (strlen($list_id)<3) )
|
|
|
|
|
{
|
|
|
|
|
$result = 'ERROR';
|
|
|
|
|
$result_reason = "update_lead INVALID DATA FOR LEAD INSERTION";
|
|
|
|
|
$data = "$phone_number|$phone_code|$list_id|$insert_if_not_found";
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
### get current gmt_offset of the phone_number
|
|
|
|
|
$gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code);
|
|
|
|
|
|
|
|
|
|
if (strlen($status)<1)
|
|
|
|
|
{$status='NEW';}
|
|
|
|
|
### insert a new lead in the system with this phone number
|
|
|
|
|
$stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='$status',user='$user',vendor_lead_code='$vendor_lead_code',source_id='$source_id',gmt_offset_now='$gmt_offset',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',entry_list_id='0';";
|
|
|
|
|
if ($DB>0) {echo "DEBUG: update_lead query - $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 = "update_lead LEAD HAS BEEN ADDED";
|
|
|
|
|
echo "$result: $result_reason - $phone_number|$list_id|$lead_id|$gmt_offset|$user\n";
|
|
|
|
|
$data = "$phone_number|$list_id|$lead_id|$gmt_offset";
|
|
|
|
|
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
|
|
|
|
|
|
|
|
|
if (strlen($multi_alt_phones) > 5)
|
|
|
|
|
{
|
|
|
|
|
$map=$MT; $ALTm_phone_code=$MT; $ALTm_phone_number=$MT; $ALTm_phone_note=$MT;
|
|
|
|
|
$map = explode('!', $multi_alt_phones);
|
|
|
|
|
$map_count = count($map);
|
|
|
|
|
if ($DB>0) {echo "DEBUG: update_lead multi-al-entry - $a|$map_count|$multi_alt_phones\n";}
|
|
|
|
|
$g++;
|
|
|
|
|
$r=0; $s=0; $inserted_alt_phones=0;
|
|
|
|
|
while ($r < $map_count)
|
|
|
|
|
{
|
|
|
|
|
$s++;
|
|
|
|
|
$ncn=$MT;
|
|
|
|
|
$ncn = explode('_', $map[$r]);
|
|
|
|
|
print "$ncn[0]|$ncn[1]|$ncn[2]";
|
|
|
|
|
|
|
|
|
|
if (strlen($forcephonecode) > 0)
|
|
|
|
|
{$ALTm_phone_code[$r] = $forcephonecode;}
|
|
|
|
|
else
|
|
|
|
|
{$ALTm_phone_code[$r] = $ncn[1];}
|
|
|
|
|
if (strlen($ALTm_phone_code[$r]) < 1)
|
|
|
|
|
{$ALTm_phone_code[$r]='1';}
|
|
|
|
|
$ALTm_phone_number[$r] = $ncn[0];
|
|
|
|
|
$ALTm_phone_note[$r] = $ncn[2];
|
|
|
|
|
$stmt = "INSERT INTO vicidial_list_alt_phones (lead_id,phone_code,phone_number,alt_phone_note,alt_phone_count) values('$lead_id','$ALTm_phone_code[$r]','$ALTm_phone_number[$r]','$ALTm_phone_note[$r]','$s');";
|
|
|
|
|
if ($DB>0) {echo "DEBUG: update_lead query - $stmt\n";}
|
|
|
|
|
$rslt=mysql_query($stmt, $link);
|
|
|
|
|
$fields_to_print = mysql_num_rows($rslt);
|
|
|
|
|
$fields_list='';
|
|
|
|
|
$o=0;
|
|
|
|
|
while ($fields_to_print > $o)
|
|
|
|
|
$Zaffected_rows = mysql_affected_rows($link);
|
|
|
|
|
$inserted_alt_phones = ($inserted_alt_phones + $Zaffected_rows);
|
|
|
|
|
$r++;
|
|
|
|
|
}
|
|
|
|
|
$result = 'NOTICE';
|
|
|
|
|
$result_reason = "update_lead MULTI-ALT-PHONE NUMBERS LOADED";
|
|
|
|
|
echo "$result: $result_reason - $inserted_alt_phones|$lead_id|$user\n";
|
|
|
|
|
$data = "$inserted_alt_phones|$lead_id";
|
|
|
|
|
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### BEGIN custom fields insert section ###
|
|
|
|
|
if ($custom_fields == 'Y')
|
|
|
|
|
{
|
|
|
|
|
if ($custom_fields_enabled > 0)
|
|
|
|
|
{
|
|
|
|
|
$stmt="SHOW TABLES LIKE \"custom_$list_id\";";
|
|
|
|
|
if ($DB>0) {echo "$stmt";}
|
|
|
|
|
$rslt=mysql_query($stmt, $link);
|
|
|
|
|
$tablecount_to_print = mysql_num_rows($rslt);
|
|
|
|
|
if ($tablecount_to_print > 0)
|
|
|
|
|
{
|
|
|
|
|
$new_field_value='';
|
|
|
|
|
$form_field_value='';
|
|
|
|
|
$rowx=mysql_fetch_row($rslt);
|
|
|
|
|
$A_field_id[$o] = $rowx[0];
|
|
|
|
|
$A_field_label[$o] = $rowx[1];
|
|
|
|
|
$A_field_name[$o] = $rowx[2];
|
|
|
|
|
$A_field_type[$o] = $rowx[6];
|
|
|
|
|
$A_field_size[$o] = $rowx[8];
|
|
|
|
|
$A_field_max[$o] = $rowx[9];
|
|
|
|
|
$A_field_required[$o] = $rowx[12];
|
|
|
|
|
$A_field_value[$o] = '';
|
|
|
|
|
$field_name_id = $A_field_label[$o];
|
|
|
|
|
|
|
|
|
|
if (isset($_GET["$field_name_id"])) {$form_field_value=$_GET["$field_name_id"];}
|
|
|
|
|
elseif (isset($_POST["$field_name_id"])) {$form_field_value=$_POST["$field_name_id"];}
|
|
|
|
|
|
|
|
|
|
$A_field_value[$o] = $form_field_value;
|
|
|
|
|
|
|
|
|
|
if ( ($A_field_type[$o]=='DISPLAY') or ($A_field_type[$o]=='SCRIPT') )
|
|
|
|
|
$CFinsert_SQL='';
|
|
|
|
|
$stmt="SELECT field_id,field_label,field_name,field_description,field_rank,field_help,field_type,field_options,field_size,field_max,field_default,field_cost,field_required,multi_position,name_position,field_order from vicidial_lists_fields where list_id='$list_id' order by field_rank,field_order,field_label;";
|
|
|
|
|
$rslt=mysql_query($stmt, $link);
|
|
|
|
|
$fields_to_print = mysql_num_rows($rslt);
|
|
|
|
|
$fields_list='';
|
|
|
|
|
$o=0;
|
|
|
|
|
while ($fields_to_print > $o)
|
|
|
|
|
{
|
|
|
|
|
$A_field_value[$o]='----IGNORE----';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!preg_match("/\|$A_field_label[$o]\|/",$vicidial_list_fields))
|
|
|
|
|
$new_field_value='';
|
|
|
|
|
$form_field_value='';
|
|
|
|
|
$rowx=mysql_fetch_row($rslt);
|
|
|
|
|
$A_field_id[$o] = $rowx[0];
|
|
|
|
|
$A_field_label[$o] = $rowx[1];
|
|
|
|
|
$A_field_name[$o] = $rowx[2];
|
|
|
|
|
$A_field_type[$o] = $rowx[6];
|
|
|
|
|
$A_field_size[$o] = $rowx[8];
|
|
|
|
|
$A_field_max[$o] = $rowx[9];
|
|
|
|
|
$A_field_required[$o] = $rowx[12];
|
|
|
|
|
$A_field_value[$o] = '';
|
|
|
|
|
$field_name_id = $A_field_label[$o];
|
|
|
|
|
|
|
|
|
|
if (isset($_GET["$field_name_id"])) {$form_field_value=$_GET["$field_name_id"];}
|
|
|
|
|
elseif (isset($_POST["$field_name_id"])) {$form_field_value=$_POST["$field_name_id"];}
|
|
|
|
|
|
|
|
|
|
$A_field_value[$o] = $form_field_value;
|
|
|
|
|
|
|
|
|
|
if ( ($A_field_type[$o]=='DISPLAY') or ($A_field_type[$o]=='SCRIPT') )
|
|
|
|
|
{
|
|
|
|
|
$CFinsert_SQL .= "$A_field_label[$o]='$A_field_value[$o]',";
|
|
|
|
|
$A_field_value[$o]='----IGNORE----';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!preg_match("/\|$A_field_label[$o]\|/",$vicidial_list_fields))
|
|
|
|
|
{
|
|
|
|
|
$CFinsert_SQL .= "$A_field_label[$o]='$A_field_value[$o]',";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$o++;
|
|
|
|
|
}
|
|
|
|
|
$o++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strlen($CFinsert_SQL)>3)
|
|
|
|
|
{
|
|
|
|
|
$CFinsert_SQL = preg_replace("/,$/","",$CFinsert_SQL);
|
|
|
|
|
$custom_table_update_SQL = "INSERT INTO custom_$list_id SET lead_id='$lead_id',$CFinsert_SQL;";
|
|
|
|
|
$rslt=mysql_query($custom_table_update_SQL, $link);
|
|
|
|
|
$custom_insert_count = mysql_affected_rows($link);
|
|
|
|
|
if ($custom_insert_count > 0)
|
|
|
|
|
if (strlen($CFinsert_SQL)>3)
|
|
|
|
|
{
|
|
|
|
|
# Update vicidial_list entry to put list_id as entry_list_id
|
|
|
|
|
$vl_table_entry_update_SQL = "UPDATE vicidial_list SET entry_list_id='$list_id' where lead_id='$lead_id';";
|
|
|
|
|
$rslt=mysql_query($vl_table_entry_update_SQL, $link);
|
|
|
|
|
$vl_table_entry_update_count = mysql_affected_rows($link);
|
|
|
|
|
$CFinsert_SQL = preg_replace("/,$/","",$CFinsert_SQL);
|
|
|
|
|
$custom_table_update_SQL = "INSERT INTO custom_$list_id SET lead_id='$lead_id',$CFinsert_SQL;";
|
|
|
|
|
$rslt=mysql_query($custom_table_update_SQL, $link);
|
|
|
|
|
$custom_insert_count = mysql_affected_rows($link);
|
|
|
|
|
if ($custom_insert_count > 0)
|
|
|
|
|
{
|
|
|
|
|
# Update vicidial_list entry to put list_id as entry_list_id
|
|
|
|
|
$vl_table_entry_update_SQL = "UPDATE vicidial_list SET entry_list_id='$list_id' where lead_id='$lead_id';";
|
|
|
|
|
$rslt=mysql_query($vl_table_entry_update_SQL, $link);
|
|
|
|
|
$vl_table_entry_update_count = mysql_affected_rows($link);
|
|
|
|
|
|
|
|
|
|
$result = 'NOTICE';
|
|
|
|
|
$result_reason = "update_lead CUSTOM FIELDS VALUES ADDED";
|
|
|
|
|
echo "$result: $result_reason - $phone_number|$lead_id|$list_id|$vl_table_entry_update_count\n";
|
|
|
|
|
$data = "$phone_number|$lead_id|$list_id";
|
|
|
|
|
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
|
|
|
|
$result = 'NOTICE';
|
|
|
|
|
$result_reason = "update_lead CUSTOM FIELDS VALUES ADDED";
|
|
|
|
|
echo "$result: $result_reason - $phone_number|$lead_id|$list_id|$vl_table_entry_update_count\n";
|
|
|
|
|
$data = "$phone_number|$lead_id|$list_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 CUSTOM FIELDS NOT ADDED, NO FIELDS DEFINED";
|
|
|
|
|
echo "$result: $result_reason - $phone_number|$lead_id|$list_id\n";
|
|
|
|
|
$data = "$phone_number|$lead_id|$list_id";
|
|
|
|
|
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@@ -2170,7 +2205,7 @@ if ($function == 'update_lead')
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$result = 'NOTICE';
|
|
|
|
|
$result_reason = "update_lead CUSTOM FIELDS NOT ADDED, NO FIELDS DEFINED";
|
|
|
|
|
$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";
|
|
|
|
|
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
|
|
|
@@ -2179,25 +2214,17 @@ if ($function == 'update_lead')
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$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";
|
|
|
|
|
$result_reason = "update_lead CUSTOM FIELDS NOT ADDED, CUSTOM FIELDS DISABLED";
|
|
|
|
|
echo "$result: $result_reason - $phone_number|$lead_id|$custom_fields|$custom_fields_enabled\n";
|
|
|
|
|
$data = "$phone_number|$lead_id|$custom_fields|$custom_fields_enabled";
|
|
|
|
|
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$result = 'NOTICE';
|
|
|
|
|
$result_reason = "update_lead CUSTOM FIELDS NOT ADDED, CUSTOM FIELDS DISABLED";
|
|
|
|
|
echo "$result: $result_reason - $phone_number|$lead_id|$custom_fields|$custom_fields_enabled\n";
|
|
|
|
|
$data = "$phone_number|$lead_id|$custom_fields|$custom_fields_enabled";
|
|
|
|
|
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
|
|
|
|
}
|
|
|
|
|
### END custom fields insert section ###
|
|
|
|
|
}
|
|
|
|
|
### END custom fields insert section ###
|
|
|
|
|
}
|
|
|
|
|
##### END insert not-found lead into the system #####
|
|
|
|
|
}
|
|
|
|
|
##### END insert not-found lead into the system #####
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|