diff --git a/UPGRADE b/UPGRADE index b0bb8fa2..ac5c77b3 100644 --- a/UPGRADE +++ b/UPGRADE @@ -182,7 +182,8 @@ OTHER CHANGES: to the agent. Also, the Calls Export Report and the List Download feature include the custom fields values for the leads exported. There is currently no way to import data through the lead loader into custom - fields. + fields, but you can import custom field data when using the non-agent + API add_lead function(see the NON-AGENT_API.txt doc for more info). diff --git a/docs/NON-AGENT_API.txt b/docs/NON-AGENT_API.txt index bc8abeea..f1da646a 100644 --- a/docs/NON-AGENT_API.txt +++ b/docs/NON-AGENT_API.txt @@ -5,7 +5,7 @@ Interface) for all functions NOT directly relating to the VICIDIAL Agent screen. This functionality will be rather limited at first and will be built upon as critical functions are identified and programmed into it. -There is also a new agent API script, for more information on that, please read +There is also an agent API script, for more information on that, please read the AGENT_API.txt document. @@ -35,6 +35,8 @@ Changes: 90916-2342 - Added vm_list voicemail list 91203-1140 - Added agent_ingroup_info feature 91216-0331 - Added duplication check features to add_lead function +100118-0543 - Added new Australian and New Zealand DST schemes (FSO-FSA and LSS-FSA) +100704-1148 - Added custom fields inserts to the add_lead function @@ -213,6 +215,9 @@ duplicate_check - Check for duplicate records in the system, can select more tha DUPTITLEALTPHONELIST - check for duplicate title and alt_phone in same list DUPTITLEALTPHONECAMP - check for duplicate title and alt_phone in all lists for this list's campaign DUPTITLEALTPHONESYS - check for duplicate title and alt_phone in entire 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 + For example, if the field_label is "favorite_color" you would add "&favorite_color=blue" (for fields with spaces in the values, you can replace the space with a plus + sign[address, city, first_name, etc...]) OPTIONAL FIELDS- @@ -242,6 +247,7 @@ rank - 1-5 digits owner - 1-20 characters (user ID, Territory or user group) + Multi-ALT-Phones format: 7275551212_1_work!7275551213_1_sister+house!1234567890_1_neighbor @@ -260,12 +266,18 @@ 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=add_lead&phone_number=7275551212&phone_code=1&list_id=999&dnc_check=N&first_name=Bob&last_name=Wilson&duplicate_check=DUPLIST-DUPTITLEALTPHONELIST +http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=add_lead&phone_number=7275551212&phone_code=1&list_id=999&custom_fields=Y&favorite_color=blue + Example responses: SUCCESS: add_lead LEAD HAS BEEN ADDED - 7275551111|6666|999|193715|-4 NOTICE: add_lead ADDED TO HOPPER - 7275551111|6666|193715|1677922 SUCCESS: add_lead LEAD HAS BEEN ADDED - 7275551111|6666|999|193716|-4 +NOTICE: add_lead CUSTOM FIELDS VALUES ADDED - 7275551111|1234|101 +NOTICE: add_lead CUSTOM FIELDS NOT ADDED, CUSTOM FIELDS DISABLED - 7275551111|Y|0 +NOTICE: add_lead CUSTOM FIELDS NOT ADDED, NO CUSTOM FIELDS DEFINED FOR THIS LIST - 7275551111|1234|101 +NOTICE: add_lead CUSTOM FIELDS NOT ADDED, NO FIELDS DEFINED - 7275551111|1234|101 NOTICE: add_lead MULTI-ALT-PHONE NUMBERS LOADED - 3|6666|193716 NOTICE: add_lead NOT ADDED TO HOPPER, OUTSIDE OF LOCAL TIME - 7275551111|6666|193716|-4|0 diff --git a/www/vicidial/non_agent_api.php b/www/vicidial/non_agent_api.php index faecfc20..61e2198a 100644 --- a/www/vicidial/non_agent_api.php +++ b/www/vicidial/non_agent_api.php @@ -31,10 +31,11 @@ # 91203-1140 - Added agent_ingroup_info feature # 91216-0331 - Added duplication check features to add_lead function # 100118-0543 - Added new Australian and New Zealand DST schemes (FSO-FSA and LSS-FSA) +# 100704-1148 - Added custom fields inserts to the add_lead function # -$version = '2.2.0-17'; -$build = '100118-0543'; +$version = '2.4-18'; +$build = '100704-1148'; require("dbconnect.php"); @@ -129,6 +130,8 @@ if (isset($_GET["agent_user"])) {$agent_user=$_GET["agent_user"];} elseif (isset($_POST["agent_user"])) {$agent_user=$_POST["agent_user"];} if (isset($_GET["duplicate_check"])) {$duplicate_check=$_GET["duplicate_check"];} elseif (isset($_POST["duplicate_check"])) {$duplicate_check=$_POST["duplicate_check"];} +if (isset($_GET["custom_fields"])) {$custom_fields=$_GET["custom_fields"];} + elseif (isset($_POST["custom_fields"])) {$custom_fields=$_POST["custom_fields"];} header ("Content-type: text/html; charset=utf-8"); header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 @@ -136,13 +139,14 @@ header ("Pragma: no-cache"); // HTTP/1.0 ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### -$stmt = "SELECT use_non_latin FROM system_settings;"; +$stmt = "SELECT use_non_latin,custom_fields_enabled FROM system_settings;"; $rslt=mysql_query($stmt, $link); $qm_conf_ct = mysql_num_rows($rslt); if ($qm_conf_ct > 0) { $row=mysql_fetch_row($rslt); - $non_latin = $row[0]; + $non_latin = $row[0]; + $custom_fields_enabled = $row[1]; } ##### END SETTINGS LOOKUP ##### ########################################### @@ -208,6 +212,7 @@ if ($non_latin < 1) $rank = ereg_replace("[^0-9]","",$rank); $owner = ereg_replace("[^-_0-9a-zA-Z]","",$owner); $duplicate_check = ereg_replace("[^-_0-9a-zA-Z]","",$duplicate_check); + $custom_fields = ereg_replace("[^0-9a-zA-Z]","",$custom_fields); } else { @@ -233,6 +238,7 @@ $postalgmt=''; $api_script = 'non-agent'; $api_logging = 1; +$vicidial_list_fields = '|lead_id|vendor_lead_code|source_id|list_id|gmt_offset_now|called_since_last_reset|phone_code|phone_number|title|first_name|middle_initial|last_name|address1|address2|address3|city|state|province|postal_code|country_code|gender|date_of_birth|alt_phone|email|security_phrase|comments|called_count|last_local_call_time|rank|owner|'; $secX = date("U"); $hour = date("H"); @@ -1470,6 +1476,109 @@ if ($function == 'add_lead') 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) + { + $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) + { + $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)) + { + $CFinsert_SQL .= "$A_field_label[$o]='$A_field_value[$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) + { + $result = 'NOTICE'; + $result_reason = "add_lead CUSTOM FIELDS VALUES ADDED"; + 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 + { + $result = 'NOTICE'; + $result_reason = "add_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 + { + $result = 'NOTICE'; + $result_reason = "add_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 + { + $result = 'NOTICE'; + $result_reason = "add_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); + } + } + else + { + $result = 'NOTICE'; + $result_reason = "add_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 ### + if ($add_to_hopper == 'Y') { $dialable=1;