From 3f59ab45f67c33fec663338bea78908d099c834c Mon Sep 17 00:00:00 2001 From: mattf Date: Tue, 31 Mar 2020 18:56:11 +0000 Subject: [PATCH] Added the "list_custom_fields" Non-Agent API function, to show all list custom data fields in a list/all-lists. More translations fixes git-svn-id: svn://192.168.202.10@3206 3d104415-ff17-0410-8863-d5cf3c621b8a --- UPGRADE | 3 + docs/NON-AGENT_API.txt | 40 +++++- www/agc/functions.php | 5 +- www/agc/vdc_db_query.php | 4 +- www/agc/vicidial.php | 5 +- www/vicidial/admin.php | 43 +++--- www/vicidial/functions.php | 3 + www/vicidial/non_agent_api.php | 241 ++++++++++++++++++++++++++++++++- 8 files changed, 309 insertions(+), 35 deletions(-) diff --git a/UPGRADE b/UPGRADE index ce629a85..e15af432 100644 --- a/UPGRADE +++ b/UPGRADE @@ -485,6 +485,9 @@ OTHER CHANGES: 135. Added AMD Agent Route Options as a campaign option allowing you to set the specific AMD responses for calls that should be routed to agents +136. Added the "list_custom_fields" Non-Agent API function, to show all list + custom data fields in a list/all-lists. + diff --git a/docs/NON-AGENT_API.txt b/docs/NON-AGENT_API.txt index 76654967..e4edf9a9 100644 --- a/docs/NON-AGENT_API.txt +++ b/docs/NON-AGENT_API.txt @@ -1,4 +1,4 @@ -NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2019-11-14 +NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2020-03-31 This document describes the functions of an API(Application Programming Interface) for all functions NOT directly relating to the VICIDIAL Agent screen. @@ -32,6 +32,7 @@ update_phone_alias - updates or deletes an existing phone alias record in the sy add_list - adds a list to the system update_list - updates list settings in the system, reset leads in list, delete list list_info - summary information about a list +list_custom_fields - shows the custom fields that are in a list, or all lists add_group_alias - adds group alias to the system user_group_status - real-time status of one or more user groups in_group_status - real-time status of one or more in groups @@ -152,6 +153,7 @@ Changes: 191107-1143 - Added list_info function 191113-1758 - Added add_dnc_phone and add_fpg_phone functions 191114-1637 - Added remove_from_hopper option to update_lead function +200331-1207 - Added list_custom_fields function API Functions use the 'function' variable @@ -1595,6 +1597,42 @@ list_id|list_name|campaign_id|active|list_changedate|list_lastcalldate|expiratio + +-------------------------------------------------------------------------------- +list_custom_fields - shows the custom data fields that are in a list, or all lists + +NOTE: api user for this function must have user_level set to 8 or higher and "modify lists" enabled +NOTE: this output will not include display-only fields in the FORM, only the non-default custom data fields, + any DISPLAY, SCRIPT and SWITCH form elements will be ignored + +REQUIRED FIELDS- +list_id - must be all numbers, 2-14 digits, OR use "---ALL---" for all lists +source - description of what originated the API call (maximum 20 characters) + +SETTINGS FIELDS- (optional) +stage - the format of the exported data: csv, tab, pipe(default) +header - include a header(YES) or not(NO). This is optional, default is not to include a header +custom_order - the order to put the custom fields into: table_order, alpha_up, alpha_down (default is 'table_order') + +Example URL strings for API calls: +http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=list_custom_fields&list_id=1101&header=YES + +Example responses: +ERROR: list_custom_fields CUSTOM LIST FIELDS ARE NOT ENABLED ON THIS SYSTEM - 6666 +ERROR: list_custom_fields USER DOES NOT HAVE PERMISSION TO MODIFY LISTS - 6666 +ERROR: list_custom_fields YOU MUST USE ALL REQUIRED FIELDS - 6666|1 +ERROR: list_custom_fields NOT AN ALLOWED LIST ID - 98762 +ERROR: list_custom_fields LIST DOES NOT EXIST - 98762 + +A SUCCESS response will not show "SUCCESS", but instead will just print the results in the following formats: + +list_id|list_name|campaign_id|active|list_changedate|list_lastcalldate|custom_fields_list_space_delimited +1101|performance list|TESTCAMP|Y|2019-09-02 08:52:50|2019-11-07 10:12:12|fav_color fav_food res_city res_state res_zip + + + + + -------------------------------------------------------------------------------- check_phone_number - allows you to check if a phone number is valid and dialable diff --git a/www/agc/functions.php b/www/agc/functions.php index 9e455a14..bd81af9f 100644 --- a/www/agc/functions.php +++ b/www/agc/functions.php @@ -2497,6 +2497,9 @@ function _QXZ($English_text, $sprintf=0, $align="l", $v_one='', $v_two='', $v_th { if ( (strlen($VUselected_language) > 0) and ($VUselected_language != 'default English') ) { + if ($English_text=="Y" && !preg_match('/english/i', $VUselected_language)) {$English_text="YES";} + if ($English_text=="N" && !preg_match('/english/i', $VUselected_language)) {$English_text="NO";} + if ($SSlanguage_method == 'MYSQL') { $stmt="SELECT translated_text from vicidial_language_phrases where english_text='$English_text' and language_id='$VUselected_language';"; @@ -2545,4 +2548,4 @@ function _QXZ($English_text, $sprintf=0, $align="l", $v_one='', $v_two='', $v_th return $English_text; } -?> \ No newline at end of file +?> diff --git a/www/agc/vdc_db_query.php b/www/agc/vdc_db_query.php index dc821239..8271ccb3 100644 --- a/www/agc/vdc_db_query.php +++ b/www/agc/vdc_db_query.php @@ -16637,8 +16637,8 @@ if ($ACTION == 'CALLLOGview') $ALLlead_id[$g] = $row[7]; $ALLhangup_reason[$g] = $row[8]; $ALLalt_dial[$g] = $row[9]; - $ALLin_out[$g] = "OUT-AUTO"; - if ($row[10] == 'MANUAL') {$ALLin_out[$g] = "OUT-MANUAL";} + $ALLin_out[$g] = _QXZ("OUT-AUTO"); + if ($row[10] == 'MANUAL') {$ALLin_out[$g] = _QXZ("OUT-MANUAL");} $stmtA="SELECT first_name,last_name FROM vicidial_list WHERE lead_id='$ALLlead_id[$g]';"; $rsltA=mysql_to_mysqli($stmtA, $link); diff --git a/www/agc/vicidial.php b/www/agc/vicidial.php index d5c9b23e..9eb08ea4 100644 --- a/www/agc/vicidial.php +++ b/www/agc/vicidial.php @@ -4094,9 +4094,8 @@ $cb_display_days=999; if ($callback_display_days > 0) {$cb_display_days=$callback_display_days;} -$Cmonths = Array('0','January','February','March','April','May','June', - 'July','August','September','October','November','December'); -$Cdays = Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); +$Cmonths = Array('0',_QXZ('January'),_QXZ('February'),_QXZ('March'),_QXZ('April'),_QXZ('May'),_QXZ('June'),_QXZ('July'),_QXZ('August'),_QXZ('September'),_QXZ('October'),_QXZ('November'),_QXZ('December')); +$Cdays = Array(_QXZ('Sun'),_QXZ('Mon'),_QXZ('Tue'),_QXZ('Wed'),_QXZ('Thu'),_QXZ('Fri'),_QXZ('Sat')); $CCAL_OUT = ''; diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index 44ab98a3..40a50119 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -128,7 +128,7 @@ $UGreports = 'ALL REPORTS, NONE, Real-Time Main Report, Real-Time Campaign Summa $Vtables = 'NONE,log_noanswer,did_agent_log,contact_information'; -$APIfunctions = 'ALL_FUNCTIONS add_group_alias add_lead add_list add_phone add_phone_alias add_user agent_ingroup_info agent_stats_export agent_status audio_playback blind_monitor call_agent callid_info change_ingroups check_phone_number did_log_export external_add_lead external_dial external_hangup external_pause external_status in_group_status logout moh_list park_call pause_code preview_dial_action ra_call_control recording recording_lookup send_dtmf server_refresh set_timer_action sounds_list st_get_agent_active_lead st_login_log transfer_conference update_fields update_lead update_list list_info update_log_entry update_phone update_phone_alias update_user user_group_status vm_list webphone_url webserver logged_in_agents update_campaign update_did lead_field_info phone_number_log switch_lead ccc_lead_info lead_status_search call_status_stats calls_in_queue_count force_fronter_leave_3way force_fronter_audio_stop update_cid_group_entry add_dnc_phone add_fpg_phone'; +$APIfunctions = 'ALL_FUNCTIONS add_group_alias add_lead add_list add_phone add_phone_alias add_user agent_ingroup_info agent_stats_export agent_status audio_playback blind_monitor call_agent callid_info change_ingroups check_phone_number did_log_export external_add_lead external_dial external_hangup external_pause external_status in_group_status logout moh_list park_call pause_code preview_dial_action ra_call_control recording recording_lookup send_dtmf server_refresh set_timer_action sounds_list st_get_agent_active_lead st_login_log transfer_conference update_fields update_lead update_list list_info list_custom_fields update_log_entry update_phone update_phone_alias update_user user_group_status vm_list webphone_url webserver logged_in_agents update_campaign update_did lead_field_info phone_number_log switch_lead ccc_lead_info lead_status_search call_status_stats calls_in_queue_count force_fronter_leave_3way force_fronter_audio_stop update_cid_group_entry add_dnc_phone add_fpg_phone'; ### BEGIN housecleaning of old static report files, if not done before ### @@ -4628,12 +4628,13 @@ else # 200315-1126 - Added a SKIP option for the CID Group auto-rotate feature # 200318-1330 - Added a default bgcolor to the servers table on the Reports page, Issue #1203 # 200327-1715 - Translation fixes +# 200331-1148 - Added list_custom_fields API function, and more translation fixes # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 9 to access this page the first time -$admin_version = '2.14-742a'; -$build = '200327-1715'; +$admin_version = '2.14-743a'; +$build = '200331-1148'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -24370,7 +24371,7 @@ if ($ADD==31) } else { - echo ""._QXZ("AM Message Wildcards").": $NWB#campaigns-am_message_wildcards$NWE\n"; + echo ""._QXZ("AM Message Wildcards").": $NWB#campaigns-am_message_wildcards$NWE\n"; } if ($SSoutbound_autodial_active > 0) @@ -25440,16 +25441,16 @@ if ($ADD==31) echo "\n"; echo "\n"; echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; echo "\n"; echo "\n"; @@ -26286,24 +26287,24 @@ if ($ADD==34) echo ""._QXZ("Campaign Login Date").": $campaign_logindate   $NWB#campaigns-campaign_logindate$NWE\n"; echo ""._QXZ("Active").": $NWB#campaigns-active$NWE\n"; - echo ""._QXZ("Admin User Group").": $user_group $NWB#campaigns-user_group$NWE\n"; + echo ""._QXZ("Admin User Group").": "._QXZ("$user_group")." $NWB#campaigns-user_group$NWE\n"; echo ""._QXZ("Park Music-on-Hold").": $row[10] $NWB#campaigns-park_ext$NWE\n"; echo ""._QXZ("Web Form").": $row[11]$NWB#campaigns-web_form_address$NWE"; if ($SSenable_first_webform < 1) {echo " "._QXZ("DISABLED")."";} echo "\n"; - echo ""._QXZ("Allow Closers").": $row[12] $NWB#campaigns-allow_closers$NWE\n"; - echo ""._QXZ("Default Transfer Group").": $default_xfer_group $NWB#campaigns-default_xfer_group$NWE\n"; + echo ""._QXZ("Allow Closers").": "._QXZ("$row[12]")." $NWB#campaigns-allow_closers$NWE\n"; + echo ""._QXZ("Default Transfer Group").": "._QXZ("$default_xfer_group")." $NWB#campaigns-default_xfer_group$NWE\n"; if ($SSallow_emails > 0) { - echo ""._QXZ("Allow Emails").": $allow_emails $NWB#campaigns-allow_emails$NWE\n"; + echo ""._QXZ("Allow Emails").": "._QXZ("$allow_emails")." $NWB#campaigns-allow_emails$NWE\n"; } if ($SSallow_chats > 0) { - echo ""._QXZ("Allow Chats").": $allow_chats $NWB#campaigns-allow_chats$NWE\n"; + echo ""._QXZ("Allow Chats").": "._QXZ("$allow_chats")." $NWB#campaigns-allow_chats$NWE\n"; } if ($SSoutbound_autodial_active > 0) { - echo ""._QXZ("Allow Inbound and Blended").": $campaign_allow_inbound $NWB#campaigns-campaign_allow_inbound$NWE\n"; + echo ""._QXZ("Allow Inbound and Blended").": "._QXZ("$campaign_allow_inbound")." $NWB#campaigns-campaign_allow_inbound$NWE\n"; $o=0; while ($Ds_to_print > $o) @@ -26639,7 +26640,7 @@ if ($ADD==34) {echo " $row[8]";} else {echo " $row[8]";} - echo " $row[4]"; + echo " "._QXZ("$row[4]").""; echo ""; if (preg_match('/Y/',$row[4])) diff --git a/www/vicidial/functions.php b/www/vicidial/functions.php index 7904dbdd..e28db831 100644 --- a/www/vicidial/functions.php +++ b/www/vicidial/functions.php @@ -1365,6 +1365,9 @@ function _QXZ($English_text, $sprintf=0, $align="l", $v_one='', $v_two='', $v_th { if ( (strlen($VUselected_language) > 0) and ($VUselected_language != 'default English') ) { + if ($English_text=="Y" && !preg_match('/english/i', $VUselected_language)) {$English_text="YES";} + if ($English_text=="N" && !preg_match('/english/i', $VUselected_language)) {$English_text="NO";} + if ($SSlanguage_method == 'MYSQL') { $stmt="SELECT translated_text from vicidial_language_phrases where english_text='$English_text' and language_id='$VUselected_language';"; diff --git a/www/vicidial/non_agent_api.php b/www/vicidial/non_agent_api.php index fedecd90..fa09a695 100644 --- a/www/vicidial/non_agent_api.php +++ b/www/vicidial/non_agent_api.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2020 Matt Florell LICENSE: AGPLv2 # # This script is designed as an API(Application Programming Interface) to allow # other programs to interact with all non-agent-screen VICIDIAL functions @@ -142,10 +142,11 @@ # 191107-1143 - Added list_info function # 191113-1758 - Added add_dnc_phone and add_fpg_phone functions # 191114-1637 - Added remove_from_hopper option to update_lead function +# 200331-1207 - Added list_custom_fields function # -$version = '2.14-119'; -$build = '191114-1637'; +$version = '2.14-120'; +$build = '200331-1207'; $api_url_log = 0; $startMS = microtime(); @@ -518,6 +519,12 @@ if (isset($_GET["leads_counts"])) {$leads_counts=$_GET["leads_counts"];} elseif (isset($_POST["leads_counts"])) {$leads_counts=$_POST["leads_counts"];} if (isset($_GET["remove_from_hopper"])) {$remove_from_hopper=$_GET["remove_from_hopper"];} elseif (isset($_POST["remove_from_hopper"])) {$remove_from_hopper=$_POST["remove_from_hopper"];} +if (isset($_GET["dedupe_statuses"])) {$dedupe_statuses=$_GET["dedupe_statuses"];} + elseif (isset($_POST["dedupe_statuses"])) {$dedupe_statuses=$_POST["dedupe_statuses"];} +if (isset($_GET["status_mismatch_action"])) {$status_mismatch_action=$_GET["status_mismatch_action"];} + elseif (isset($_POST["status_mismatch_action"])) {$status_mismatch_action=$_POST["status_mismatch_action"];} +if (isset($_GET["custom_order"])) {$custom_order=$_GET["custom_order"];} + elseif (isset($_POST["custom_order"])) {$custom_order=$_POST["custom_order"];} header ("Content-type: text/html; charset=utf-8"); @@ -566,7 +573,7 @@ if ($non_latin < 1) $pass=preg_replace('/[^-_0-9a-zA-Z]/','',$pass); $function = preg_replace('/[^-\_0-9a-zA-Z]/', '',$function); $format = preg_replace('/[^0-9a-zA-Z]/','',$format); - $list_id = preg_replace('/[^0-9]/','',$list_id); + $list_id = preg_replace('/[^-_0-9a-zA-Z]/','',$list_id); $entry_list_id = preg_replace('/[^0-9]/','',$entry_list_id); $phone_code = preg_replace('/[^0-9]/','',$phone_code); $update_phone_number=preg_replace('/[^A-Z]/','',$update_phone_number); @@ -744,6 +751,7 @@ if ($non_latin < 1) $leads_counts = preg_replace('/[^-_0-9a-zA-Z]/','',$leads_counts); $remove_from_hopper=preg_replace('/[^0-9a-zA-Z]/','',$remove_from_hopper); $list_description=preg_replace('/[^- \+\.\:\/\@\?\&\_0-9a-zA-Z]/','',$list_description); + $custom_order = preg_replace('/[^-_0-9a-zA-Z]/','',$custom_order); } else { @@ -919,7 +927,7 @@ $api_list_restrict = $row[0]; $api_allowed_functions = $row[1]; $LOGuser_group = $row[2]; $VUselected_language = $row[3]; -if ( ($api_list_restrict > 0) and ( ($function == 'add_lead') or ($function == 'update_lead') or ($function == 'update_list') ) ) +if ( ($api_list_restrict > 0) and ( ($function == 'add_lead') or ($function == 'update_lead') or ($function == 'update_list') or ($function == 'list_info') or ($function == 'list_custom_fields') ) ) { $stmt="SELECT allowed_campaigns from vicidial_user_groups where user_group='$LOGuser_group';"; if ($DB>0) {echo "|$stmt|\n";} @@ -944,13 +952,16 @@ if ( ($api_list_restrict > 0) and ( ($function == 'add_lead') or ($function == ' $lists_to_print = mysqli_num_rows($rslt); $i=0; $allowed_lists=' '; + $allowed_listsSQL=''; while ($i < $lists_to_print) { $row=mysqli_fetch_row($rslt); - $allowed_lists .= "$row[0] "; + $allowed_lists .= "$row[0] "; + $allowed_listsSQL .= "'$row[0]',"; $i++; } - if ($DB>0) {echo "Allowed lists:|$allowed_lists|\n";} + $allowed_listsSQL = preg_replace("/,$/",'',$allowed_listsSQL); + if ($DB>0) {echo "Allowed lists:|$allowed_lists|$allowed_listsSQL|\n";} } else { @@ -4959,6 +4970,222 @@ if ($function == 'list_info') +################################################################################ +### list_custom_fields - shows the custom fields that are in a list, or all lists +################################################################################ +if ($function == 'list_custom_fields') + { + if(strlen($source)<2) + { + $result = 'ERROR'; + $result_reason = "Invalid Source"; + echo "$result: $result_reason - $source\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + echo "ERROR: Invalid Source: |$source|\n"; + exit; + } + else + { + if ( (!preg_match("/ $function /",$api_allowed_functions)) and (!preg_match("/ALL_FUNCTIONS/",$api_allowed_functions)) ) + { + $result = 'ERROR'; + $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; + echo "$result: $result_reason: |$user|$function|\n"; + $data = "$allowed_user"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + if ($custom_fields_enabled < 1) + { + $result = 'ERROR'; + $result_reason = "CUSTOM LIST FIELDS ARE NOT ENABLED ON THIS SYSTEM"; + echo "$result: $result_reason: |$user|$function|\n"; + $data = "$allowed_user"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + $stmt="SELECT count(*) from vicidial_users where user='$user' and vdc_agent_api_access='1' and modify_lists='1' and user_level >= 8 and active='Y';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $allowed_user=$row[0]; + if ($allowed_user < 1) + { + $result = 'ERROR'; + $result_reason = "list_custom_fields USER DOES NOT HAVE PERMISSION TO MODIFY LISTS"; + $data = "$allowed_user"; + 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 + { + if ( (strlen($list_id)<2) or (strlen($list_id)>14) ) + { + $result = 'ERROR'; + $result_reason = "list_custom_fields YOU MUST USE ALL REQUIRED FIELDS"; + $data = "$list_id|$list_name|$campaign_id"; + 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 + { + if ($api_list_restrict > 0) + { + if ( (!preg_match("/ $list_id /",$allowed_lists)) and ($list_id != '---ALL---') ) + { + $result = 'ERROR'; + $result_reason = "list_custom_fields NOT AN ALLOWED LIST ID"; + $data = "$list_id"; + echo "$result: $result_reason - $data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + } + $stmt="SELECT allowed_campaigns,admin_viewable_groups from vicidial_user_groups where user_group='$LOGuser_group';"; + if ($DB>0) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $LOGallowed_campaigns = $row[0]; + $LOGadmin_viewable_groups = $row[1]; + + $LOGallowed_campaignsSQL=''; + $whereLOGallowed_campaignsSQL=''; + if ( (!preg_match('/\-ALL/i', $LOGallowed_campaigns)) ) + { + $rawLOGallowed_campaignsSQL = preg_replace("/ -/",'',$LOGallowed_campaigns); + $rawLOGallowed_campaignsSQL = preg_replace("/ /","','",$rawLOGallowed_campaignsSQL); + $LOGallowed_campaignsSQL = "and campaign_id IN('$rawLOGallowed_campaignsSQL')"; + $whereLOGallowed_campaignsSQL = "where campaign_id IN('$rawLOGallowed_campaignsSQL')"; + } + + if ($list_id == '---ALL---') + {$list_exists=1;} + else + { + $stmt="SELECT count(*) from vicidial_lists where list_id='$list_id' $LOGallowed_campaignsSQL;"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $list_exists=$row[0]; + } + if ($list_exists < 1) + { + $result = 'ERROR'; + $result_reason = "list_custom_fields LIST DOES NOT EXIST"; + $data = "$list_id"; + 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 + { + $listSQL = "list_id='$list_id'"; + if ($list_id == '---ALL---') + { + if (strlen($allowed_listsSQL) > 3) + {$listSQL = "list_id IN($allowed_listsSQL)";} + else + {$listSQL = "list_id > 0";} + } + $stmt="SELECT list_name,campaign_id,active,list_changedate,list_lastcalldate,expiration_date,resets_today,list_id from vicidial_lists where $listSQL $LOGallowed_campaignsSQL order by list_id;"; + if ($DB>0) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $lists_to_print = mysqli_num_rows($rslt); + $lp=0; + while ($lp < $lists_to_print) + { + $row=mysqli_fetch_row($rslt); + $OUTlist_name[$lp] = $row[0]; + $OUTcampaign_id[$lp] = $row[1]; + $OUTactive[$lp] = $row[2]; + $OUTlist_changedate[$lp] = $row[3]; + $OUTlist_lastcalldate[$lp] = $row[4]; + $OUTexpiration_date[$lp] = $row[5]; + $OUTresets_today[$lp] = $row[6]; + $OUTlist_id[$lp] = $row[7]; + $lp++; + } + + $output=''; + $DLset=0; + if ($stage == 'csv') + {$DL = ','; $DLset++;} + if ($stage == 'tab') + {$DL = "\t"; $DLset++;} + if ($stage == 'pipe') + {$DL = '|'; $DLset++;} + if ($DLset < 1) + {$DL='|';} + if ($header == 'YES') + {$output .= 'list_id' . $DL . 'list_name' . $DL . 'campaign_id' . $DL . 'active' . $DL . 'list_changedate' . $DL . 'list_lastcalldate' . $DL . 'custom_fields_list_space_delimited' . "\n";} + + $lp=0; + while ($lp < $lists_to_print) + { + $stmt="SHOW TABLES LIKE \"custom_$OUTlist_id[$lp]\";"; + if ($DB>0) {echo "$stmt";} + $rslt=mysql_to_mysqli($stmt, $link); + $tablecount_to_print = mysqli_num_rows($rslt); + $cf=0; $af=0; + $CFtable_order=''; + if ($tablecount_to_print > 0) + { + $stmtA = "describe custom_$OUTlist_id[$lp];"; + $rslt=mysql_to_mysqli($stmtA, $link); + if ($DB) {echo "$stmtA\n";} + $columns_ct = mysqli_num_rows($rslt); + while ($columns_ct > $cf) + { + $row=mysqli_fetch_row($rslt); + $column[$cf] = $row[0]; + if ( ($row[0] != 'lead_id') and (strlen($row[0]) > 0) ) + { + $field_list[$af] = $row[0]; + if ($af > 0) + {$CFtable_order .= " $field_list[$af]";} + else + {$CFtable_order .= "$field_list[$af]";} + $af++; + } + $cf++; + } + } + $leads_fields_output = $CFtable_order; + if ($custom_order == 'alpha_up') + { + sort($field_list); + $leads_fields_output = implode(" ",$field_list); + } + if ($custom_order == 'alpha_down') + { + rsort($field_list); + $leads_fields_output = implode(" ",$field_list); + } + + $output .= "$OUTlist_id[$lp]" . $DL . "$OUTlist_name[$lp]" . $DL . "$OUTcampaign_id[$lp]" . $DL . "$OUTactive[$lp]" . $DL . "$OUTlist_changedate[$lp]" . $DL . "$OUTlist_lastcalldate[$lp]" . $DL . $leads_fields_output . "\n"; + + $lp++; + } + + $result = 'SUCCESS'; + $result_reason = "list_custom_fields LIST CUSTOM FIELDS INFORMATION SENT"; + $data = "$list_id"; + echo $output; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + } + } + } + } +################################################################################ +### END list_custom_fields +################################################################################ + + + + + ################################################################################ ### add_list - adds list to the vicidial_lists table ################################################################################