diff --git a/agc_2-X/trunk/docs/NON-AGENT_API.txt b/agc_2-X/trunk/docs/NON-AGENT_API.txt index 947265a5..8af9455d 100644 --- a/agc_2-X/trunk/docs/NON-AGENT_API.txt +++ b/agc_2-X/trunk/docs/NON-AGENT_API.txt @@ -64,6 +64,7 @@ campaigns_list - displays information about all campaigns in the system hopper_list - displays information about leads in the hopper for a campaign update_alt_url - updates/adds/displays alternate dispo call url entries for a campaign update_presets - updates/adds/displays/deletes campaign preset entries +lead_dearchive - moves a lead from the archive to active leads table New scripts: @@ -210,6 +211,7 @@ Changes: 230614-0828 - Added container_list function 230721-1753 - Added insert for daily RT monitoring 231109-0933 - Added archived_lead option to multiple functions +231109-2022 - Added lead_dearchive function API Functions use the 'function' variable @@ -962,6 +964,30 @@ lead_id|callback_type|recipient|callback_status|lead_status|callback_date|entry_ +-------------------------------------------------------------------------------- +lead_dearchive - moves a lead from the archive to active leads table + +NOTE: api user for this function must have user_level set to 8 or higher and "modify leads" enabled + +REQUIRED FIELDS- +source - description of what originated the API call (maximum 20 characters) +lead_id - 16-40 characters + +Example URL strings for API calls: +http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=lead_dearchive&lead_id=274071 + +Example responses: +ERROR: lead_dearchive USER DOES NOT HAVE PERMISSION TO MODIFY LEAD INFO - 6666|0 +ERROR: lead_dearchive INVALID SEARCH PARAMETERS - 6666|| +ERROR: lead_dearchive LEAD INSERT FAILED - 6666|| +ERROR: lead_dearchive NON-ARCHIVED LEAD FOUND - 6666|| +ERROR: lead_dearchive ARCHIVED LEAD NOT FOUND - 6666|| +SUCCESS: lead_dearchive LEAD DE-ARCHIVED - 6666|274071|1|1 + + + + + -------------------------------------------------------------------------------- update_log_entry - updates the status of a vicidial_log or vicidial_closer_log entry diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index 862e3f7f..998ffb71 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -131,7 +131,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 copy_user did_log_export external_add_lead external_dial external_hangup external_pause external_status in_group_status logout moh_list ingroup_list campaigns_list callmenu_list hopper_list call_dispo_report agent_campaigns 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 batch_update_lead update_list list_info list_custom_fields update_log_entry update_phone update_phone_alias update_user user_group_status vm_list vm_message webphone_url webserver logged_in_agents update_campaign update_alt_url update_presets add_did update_did lead_field_info lead_all_info lead_callback_info phone_number_log switch_lead ccc_lead_info lead_status_search lead_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 send_notification'; +$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 copy_user did_log_export external_add_lead external_dial external_hangup external_pause external_status in_group_status logout moh_list ingroup_list campaigns_list callmenu_list hopper_list call_dispo_report agent_campaigns 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 batch_update_lead update_list list_info list_custom_fields update_log_entry update_phone update_phone_alias update_user user_group_status vm_list vm_message webphone_url webserver logged_in_agents update_campaign update_alt_url update_presets add_did update_did lead_field_info lead_all_info lead_callback_info phone_number_log switch_lead ccc_lead_info lead_status_search lead_search lead_dearchive 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 send_notification'; $browser_alert_sounds_list = 'bark_dog,beep_double,beep_five,beep_up,bell_double,bell_school,bird,blaster1,blaster2,buzz1,buzz2,cash_register,chat_alert,click_single,click_double,click_quiet,close_encounter,confirmation,ding,droplet,droplet_double,elephant,email_alert,hold_tone,horn_bike,horn_car,horn_car_triple,horn_clown,horn_double,horn_train,meow_cat,scream_wilhelm,silence_quick,siren,slide_down,slide_up,swish,teleport1,teleport2,ticking_two,ticking_four,ticking_six,whip,whistle_up,whistle_two,whistle_three,whoosh,xylophone1,xylophone2,xylophone3,xylophone4,20Hz_tone'; @@ -6107,12 +6107,13 @@ if ($SSscript_remove_js > 0) # 230926-0849 - Added camp_lead_order_random options.php setting # 230927-0857 - Added agent_search_ingroup_list campaign and agent_search_list ingroup options # 231109-0904 - Added two_factor_auth_agent_hours system setting +# 231109-2027 - Added lead_dearchive API function # # 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-898a'; -$build = '231109-0904'; +$admin_version = '2.14-899a'; +$build = '231109-2027'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); diff --git a/agc_2-X/trunk/www/vicidial/non_agent_api.php b/agc_2-X/trunk/www/vicidial/non_agent_api.php index 71cc8651..a7771beb 100644 --- a/agc_2-X/trunk/www/vicidial/non_agent_api.php +++ b/agc_2-X/trunk/www/vicidial/non_agent_api.php @@ -204,10 +204,11 @@ # 230614-0828 - Added container_list function # 230721-1753 - Added insert for daily RT monitoring # 231109-0933 - Added archived_lead option to multiple functions +# 231109-2022 - Added lead_dearchive function # -$version = '2.14-181'; -$build = '231109-0933'; +$version = '2.14-182'; +$build = '231109-2022'; $php_script='non_agent_api.php'; $api_url_log = 0; @@ -12807,6 +12808,179 @@ if ($function == 'lead_callback_info') +################################################################################ +### lead_dearchive - moves a lead from the archive to active leads table +################################################################################ +if ($function == 'lead_dearchive') + { + 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; + } + $stmt="SELECT count(*) from vicidial_users where user='$user' and vdc_agent_api_access='1' and modify_leads='1' and user_level > 7 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 = "lead_dearchive USER DOES NOT HAVE PERMISSION TO MODIFY LEAD INFO"; + echo "$result: $result_reason: |$user|$allowed_user|\n"; + $data = "$allowed_user"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + { + $lead_search_SQL=''; + $search_ready=0; + + if ( (strlen($lead_id)>0) and (strlen($lead_id)<12) ) + { + $lead_search_SQL .= "where lead_id='$lead_id'"; + $search_ready++; + } + if ($search_ready < 1) + { + $result = 'ERROR'; + $result_reason = "lead_dearchive INVALID SEARCH PARAMETERS"; + $data = "$user|$lead_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; + } + else + { + $stmt="SELECT allowed_campaigns from vicidial_user_groups where user_group='$LOGuser_group';"; + if ($DB) {$MAIN.="|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $LOGallowed_campaigns = $row[0]; + + $LOGallowed_campaignsSQL=''; + $whereLOGallowed_campaignsSQL=''; + $allowed_listsSQL=''; + 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')"; + + $stmt="SELECT list_id from vicidial_lists $whereLOGallowed_campaignsSQL order by list_id;"; + if ($DB>0) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $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_listsSQL .= "'$row[0]',"; + $i++; + } + $allowed_listsSQL = preg_replace("/,$/",'',$allowed_listsSQL); + if ($DB>0) {echo "Allowed lists:|$allowed_lists|$allowed_listsSQL|\n";} + if (strlen($allowed_listsSQL) > 3) + {$allowed_listsSQL = "and list_id IN($allowed_listsSQL)";} + } + + $stmt="SELECT list_id,entry_list_id from vicidial_list_archive $lead_search_SQL $allowed_listsSQL limit 1;"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $lead_archive_exists = mysqli_num_rows($rslt); + + if ($lead_archive_exists > 0) + { + $row=mysqli_fetch_row($rslt); + $lead_list_id = $row[0]; + $lead_entry_list_id = $row[1]; + + $stmt="SELECT list_id,entry_list_id from vicidial_list $lead_search_SQL limit 1"; + if ($DB) {$MAIN.="|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $lead_exists = mysqli_num_rows($rslt); + + if ($lead_exists < 1) + { + # Insert archived lead back into vicidial_list + $vl_table_insert_SQL = "INSERT INTO vicidial_list SELECT * from vicidial_list_archive where lead_id='$lead_id';"; + $rslt=mysql_to_mysqli($vl_table_insert_SQL, $link); + $vl_table_insert_count = mysqli_affected_rows($link); + + if ($vl_table_insert_count > 0) + { + # Delete archived lead from vicidial_list_archive + $vla_table_delete_SQL = "DELETE FROM vicidial_list_archive where lead_id='$lead_id';"; + $rslt=mysql_to_mysqli($vla_table_delete_SQL, $link); + $vla_table_delete_count = mysqli_affected_rows($link); + + $result = 'SUCCESS'; + $data = "$user|$lead_id|$vl_table_insert_count|$vla_table_delete_count"; + $result_reason = "lead_dearchive LEAD DE-ARCHIVED"; + echo "$result: $result_reason: $data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + else + { + $result = 'ERROR'; + $result_reason = "lead_dearchive LEAD INSERT FAILED"; + $data = "$user|$lead_id|$lead_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; + } + } + else + { + $result = 'ERROR'; + $result_reason = "lead_dearchive NON-ARCHIVED LEAD FOUND"; + $data = "$user|$lead_id|$lead_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; + } + } + else + { + $result = 'ERROR'; + $result_reason = "lead_dearchive ARCHIVED LEAD NOT FOUND"; + $data = "$user|$lead_id|$stage|$search_location"; + echo "$result: $result_reason: $data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + } + } + } + exit; + } +################################################################################ +### lead_dearchive - moves a lead from the archive to active leads table +################################################################################ + + + + + ################################################################################ ### lead_field_info - pulls the value of one field of a lead ################################################################################