Added agent_status function to the non-agent API

git-svn-id: svn://192.168.202.10@1953 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2013-04-05 21:11:09 +00:00
parent 6cce4c6fc1
commit 8c644f19ba
3 changed files with 194 additions and 3 deletions
+2
View File
@@ -230,6 +230,8 @@ OTHER CHANGES:
39. Added user_group as a script, form, webform, start_call_url and
dispo_call_url variable.
40. Added agent_status function to the non-agent API
+35 -1
View File
@@ -1,4 +1,4 @@
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2013-03-28
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2013-04-05
This document describes the functions of an API(Application Programming
Interface) for all functions NOT directly relating to the VICIDIAL Agent screen.
@@ -33,6 +33,7 @@ update_list - updates list settings in the system, reset leads in list, delete l
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
agent_status - real-time status of one user
New scripts:
@@ -79,6 +80,7 @@ Changes:
121116-1938 - Added state call time restrictions to add_lead hopper insert function
121125-2210 - Added Other Campaign DNC option and list expiration date option
130328-0949 - Added update_phone_number option to update_lead function
130405-1538 - Added agent_status function
@@ -394,6 +396,38 @@ SALESLINE SUPPORT,31,0,75,54,0,20,1
--------------------------------------------------------------------------------
agent_status - real-time status of one agent user
NOTE: api user for this function must have user_level set to 7 or higher and "view reports" enabled
REQUIRED FIELDS-
source - description of what originated the API call (maximum 20 characters)
agent_user - 2-20 characters, use only for one agent status
SETTINGS FIELDS-
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
NOTES-
There is a hard limit of 10000000 records analyzed
Example URL strings for API calls:
http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=agent_status&agent_user=1234&stage=csv&header=YES
Example responses:
ERROR: agent_status USER DOES NOT HAVE PERMISSION TO GET AGENT INFO - 6666|0
ERROR: agent_status INVALID SEARCH PARAMETERS - 6666||
ERROR: agent_status AGENT NOT FOUND - 6666||
ERROR: agent_status AGENT NOT LOGGED IN - 6666||
A SUCCESS response will not show "SUCCESS", but instead will just print the results in the following format:
status,call_id,lead_id,campaign_id,calls_today,full_name,user_group,user_level
INCALL,M4050908070000012345,12345,TESTCAMP,12,Test Agent,AGENTS,3
--------------------------------------------------------------------------------
update_log_entry - updates the status of a vicidial_log or vicidial_closer_log entry
+157 -2
View File
@@ -72,10 +72,11 @@
# 121116-1938 - Added state call time restrictions to add_lead hopper insert function
# 121125-2210 - Added Other Campaign DNC option and list expiration date option
# 130328-0949 - Added update_phone_number option to update_lead function, issue #653
# 130405-1539 - Added agent_status function
#
$version = '2.6-50';
$build = '130328-0949';
$version = '2.6-51';
$build = '130405-1539';
$api_url_log = 0;
$startMS = microtime();
@@ -4240,6 +4241,160 @@ if ($function == 'in_group_status')
################################################################################
### agent_status - exports agent user real-time stats
################################################################################
if ($function == 'agent_status')
{
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
{
$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and vdc_agent_api_access='1' and view_reports='1' and user_level > 6 and active='Y';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$allowed_user=$row[0];
if ($allowed_user < 1)
{
$result = 'ERROR';
$result_reason = "agent_status USER DOES NOT HAVE PERMISSION TO GET AGENT 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
{
$agent_search_SQL='';
$search_ready=0;
require_once("functions.php");
if ( (strlen($agent_user)>0) and (strlen($agent_user)<100) )
{
$agent_search_SQL .= "where user='$agent_user'";
$search_ready++;
}
if ($search_ready < 1)
{
$result = 'ERROR';
$result_reason = "agent_status INVALID SEARCH PARAMETERS";
$data = "$user|$agent_user";
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 user_group from vicidial_users where user='$user' and pass='$pass' and user_level > 6 and view_reports='1' and active='Y';";
if ($DB) {$MAIN.="|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGuser_group = $row[0];
$stmt="SELECT admin_viewable_groups from vicidial_user_groups where user_group='$LOGuser_group';";
if ($DB) {$MAIN.="|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGadmin_viewable_groups = $row[0];
$LOGadmin_viewable_groupsSQL='';
$whereLOGadmin_viewable_groupsSQL='';
if ( (!eregi("--ALL--",$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) )
{
$rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups);
$rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL);
$LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')";
$whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')";
}
$k=0;
$output='';
$DLset=0;
if ($stage == 'csv')
{$DL = ','; $DLset++;}
if ($stage == 'tab')
{$DL = "\t"; $DLset++;}
if ($stage == 'pipe')
{$DL = '|'; $DLset++;}
if ($DLset < 1)
{$DL='|'; $stage='pipe';}
if (strlen($time_format) < 1)
{$time_format = 'HF';}
if ($header == 'YES')
{$output .= 'status' . $DL . 'callerid' . $DL . 'lead_id' . $DL . 'campaign_id' . $DL . 'calls_today' . $DL . 'full_name' . $DL . 'user_group' . $DL . 'user_level' . "\n";}
$stmt="select full_name,user_group,user_level from vicidial_users $agent_search_SQL $LOGadmin_viewable_groupsSQL;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$user_to_list = mysql_num_rows($rslt);
if ($user_to_list > 0)
{
$row=mysql_fetch_row($rslt);
$full_name = $row[0];
$user_group = $row[1];
$user_level = $row[2];
$stmt="select status,callerid,lead_id,campaign_id,calls_today from vicidial_live_agents $agent_search_SQL;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$agent_to_list = mysql_num_rows($rslt);
if ($agent_to_list > 0)
{
$row=mysql_fetch_row($rslt);
$status = $row[0];
$callerid = $row[1];
$lead_id = $row[2];
$campaign_id = $row[3];
$calls_today = $row[4];
$output .= "$status$DL$callerid$DL$lead_id$DL$campaign_id$DL$calls_today$DL$full_name$DL$user_group$DL$user_level\n";
echo "$output";
$result = 'SUCCESS';
$data = "$user|$agent_user|$stage";
$result_reason = "agent_status $output";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
}
else
{
$result = 'ERROR';
$result_reason = "agent_status AGENT NOT LOGGED IN";
$data = "$user|$agent_user";
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 = "agent_status AGENT NOT FOUND";
$data = "$user|$agent_user";
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;
}
################################################################################
### END agent_status
################################################################################
################################################################################
### update_log_entry - updates the status of a log entry
################################################################################