Added group_by_campaign option to agent_stats_export function of the Non-Agent API

git-svn-id: svn://192.168.202.10@3333 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2020-12-01 21:57:09 +00:00
parent 98151e20bd
commit f6dc15c410
2 changed files with 64 additions and 15 deletions
+5 -1
View File
@@ -1,4 +1,4 @@
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2020-11-13 NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2020-12-01
This document describes the functions of an API(Application Programming This document describes the functions of an API(Application Programming
Interface) for all functions NOT directly relating to the VICIDIAL Agent screen. Interface) for all functions NOT directly relating to the VICIDIAL Agent screen.
@@ -166,6 +166,7 @@ Changes:
201002-1545 - Added extension as recording_lookup option, Allowed for secure sounds_web_server setting 201002-1545 - Added extension as recording_lookup option, Allowed for secure sounds_web_server setting
201106-1654 - Added campaign_id option to agent_stats_export function 201106-1654 - Added campaign_id option to agent_stats_export function
201113-0713 - Added delete_did option to update_did function 201113-0713 - Added delete_did option to update_did function
201201-1625 - Added group_by_campaign option to agent_stats_export function
API Functions use the 'function' variable API Functions use the 'function' variable
@@ -539,6 +540,7 @@ 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 header - include a header(YES) or not(NO). This is optional, default is not to include a header
time_format - time format('H','HF','M','S') in hours, minutes or seconds: H = 1:23:45, M = 83:45, S = 5023 (default 'HF') time_format - time format('H','HF','M','S') in hours, minutes or seconds: H = 1:23:45, M = 83:45, S = 5023 (default 'HF')
* HF will force hour format even for zero seconds time "0:00:00" * HF will force hour format even for zero seconds time "0:00:00"
group_by_campaign - divide and output the agent results grouped by campaign(YES) or not(NO). This is optional, default is 'NO'
NOTES- NOTES-
There is a hard limit of 10000000 records analyzed There is a hard limit of 10000000 records analyzed
@@ -557,6 +559,8 @@ user|full_name|user_group|calls|login_time|total_talk_time|avg_talk_time|avg_wai
1029|test agent|ADMIN|1|0:01:52|0:00:16|0:00:16|0:00:18|16.7%|54|3|0:00:37|5|0:00:11|48.2%|2|0:00:32 1029|test agent|ADMIN|1|0:01:52|0:00:16|0:00:16|0:00:18|16.7%|54|3|0:00:37|5|0:00:11|48.2%|2|0:00:32
6666|Admin|ADMIN|5|0:04:11|0:01:48|0:00:22|0:00:17|83.3%|27|2|0:02:06|4|0:00:07|10.8%|2|0:00:32 6666|Admin|ADMIN|5|0:04:11|0:01:48|0:00:22|0:00:17|83.3%|27|2|0:02:06|4|0:00:07|10.8%|2|0:00:32
* if the 'group_by_campaign' option is enabled, the format above will have 'campaign_id' as the first column, and each agent's activity will be divided on separate lines by the campaigns they were logged into during the requested time period.
+59 -14
View File
@@ -156,10 +156,11 @@
# 201002-1545 - Added extension as recording lookup option, Allowed for secure sounds_web_server setting # 201002-1545 - Added extension as recording lookup option, Allowed for secure sounds_web_server setting
# 201106-1654 - Added campaign_id option to agent_stats_export function # 201106-1654 - Added campaign_id option to agent_stats_export function
# 201113-0713 - Added delete_did option to update_did function, Issue #1242 # 201113-0713 - Added delete_did option to update_did function, Issue #1242
# 201201-1625 - Added group_by_campaign option to agent_stats_export function
# #
$version = '2.14-133'; $version = '2.14-134';
$build = '201113-0713'; $build = '201201-1625';
$api_url_log = 0; $api_url_log = 0;
$startMS = microtime(); $startMS = microtime();
@@ -554,6 +555,8 @@ if (isset($_GET["on_hook_agent"])) {$on_hook_agent=$_GET["on_hook_agent"];}
elseif (isset($_POST["on_hook_agent"])) {$on_hook_agent=$_POST["on_hook_agent"];} elseif (isset($_POST["on_hook_agent"])) {$on_hook_agent=$_POST["on_hook_agent"];}
if (isset($_GET["delete_did"])) {$delete_did=$_GET["delete_did"];} if (isset($_GET["delete_did"])) {$delete_did=$_GET["delete_did"];}
elseif (isset($_POST["delete_did"])) {$delete_did=$_POST["delete_did"];} elseif (isset($_POST["delete_did"])) {$delete_did=$_POST["delete_did"];}
if (isset($_GET["group_by_campaign"])) {$group_by_campaign=$_GET["group_by_campaign"];}
elseif (isset($_POST["group_by_campaign"])) {$group_by_campaign=$_POST["group_by_campaign"];}
header ("Content-type: text/html; charset=utf-8"); header ("Content-type: text/html; charset=utf-8");
@@ -789,6 +792,7 @@ if ($non_latin < 1)
$template_id = preg_replace('/[^-_0-9a-zA-Z]/','',$template_id); $template_id = preg_replace('/[^-_0-9a-zA-Z]/','',$template_id);
$on_hook_agent = preg_replace('/[^-_0-9a-zA-Z]/','',$on_hook_agent); $on_hook_agent = preg_replace('/[^-_0-9a-zA-Z]/','',$on_hook_agent);
$delete_did = preg_replace('/[^0-9a-zA-Z]/','',$delete_did); $delete_did = preg_replace('/[^0-9a-zA-Z]/','',$delete_did);
$group_by_campaign = preg_replace('/[^0-9a-zA-Z]/','',$group_by_campaign);
} }
else else
{ {
@@ -7908,7 +7912,14 @@ if ($function == 'agent_stats_export')
} }
else else
{ {
$stmt="SELECT user,lead_id,sub_status,pause_sec,wait_sec,talk_sec,dispo_sec,dead_sec,pause_epoch from vicidial_agent_log where $search_SQL order by user,agent_log_id limit 10000000;"; if ($group_by_campaign == 'YES')
{
$stmt="SELECT user,lead_id,sub_status,pause_sec,wait_sec,talk_sec,dispo_sec,dead_sec,pause_epoch,campaign_id from vicidial_agent_log where $search_SQL order by campaign_id,user,agent_log_id limit 10000000;";
}
else
{
$stmt="SELECT user,lead_id,sub_status,pause_sec,wait_sec,talk_sec,dispo_sec,dead_sec,pause_epoch,campaign_id from vicidial_agent_log where $search_SQL order by user,agent_log_id limit 10000000;";
}
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
$rec_recs = mysqli_num_rows($rslt); $rec_recs = mysqli_num_rows($rslt);
if ($DB>0) {echo "DEBUG: agent_stats_export query - $rec_recs|$stmt\n";} if ($DB>0) {echo "DEBUG: agent_stats_export query - $rec_recs|$stmt\n";}
@@ -7937,9 +7948,19 @@ if ($function == 'agent_stats_export')
if (strlen($time_format) < 1) if (strlen($time_format) < 1)
{$time_format = 'HF';} {$time_format = 'HF';}
if ($header == 'YES') if ($header == 'YES')
{$output .= 'user' . $DL . 'full_name' . $DL . 'user_group' . $DL . 'calls' . $DL . 'login_time' . $DL . 'total_talk_time' . $DL . 'avg_talk_time' . $DL . 'avg_wait_time' . $DL . 'pct_of_queue' . $DL . 'pause_time' . $DL . 'sessions' . $DL . 'avg_session' . $DL . 'pauses' . $DL . 'avg_pause_time' . $DL . 'pause_pct' . $DL . 'pauses_per_session' . "\n";} {
if ($group_by_campaign == 'YES')
{
$output .= 'campaign_id' . $DL . 'user' . $DL . 'full_name' . $DL . 'user_group' . $DL . 'calls' . $DL . 'login_time' . $DL . 'total_talk_time' . $DL . 'avg_talk_time' . $DL . 'avg_wait_time' . $DL . 'pct_of_queue' . $DL . 'pause_time' . $DL . 'sessions' . $DL . 'avg_session' . $DL . 'pauses' . $DL . 'avg_pause_time' . $DL . 'pause_pct' . $DL . 'pauses_per_session' . "\n";
}
else
{
$output .= 'user' . $DL . 'full_name' . $DL . 'user_group' . $DL . 'calls' . $DL . 'login_time' . $DL . 'total_talk_time' . $DL . 'avg_talk_time' . $DL . 'avg_wait_time' . $DL . 'pct_of_queue' . $DL . 'pause_time' . $DL . 'sessions' . $DL . 'avg_session' . $DL . 'pauses' . $DL . 'avg_pause_time' . $DL . 'pause_pct' . $DL . 'pauses_per_session' . "\n";
}
}
$ASuser=array(); $ASuser=array();
$AScampaign=array();
$ASstart_epoch=array(); $ASstart_epoch=array();
$AScalls=array(); $AScalls=array();
$ASpauses=array(); $ASpauses=array();
@@ -7961,15 +7982,33 @@ if ($function == 'agent_stats_export')
{ {
# user,lead_id,sub_status,pause_sec,wait_sec,talk_sec,dispo_sec,dead_sec # user,lead_id,sub_status,pause_sec,wait_sec,talk_sec,dispo_sec,dead_sec
$row=mysqli_fetch_row($rslt); $row=mysqli_fetch_row($rslt);
if (!preg_match("/^$last_user$/i", $row[0])) if ($group_by_campaign == 'YES')
{ {
$uc++; $temp_camp_user="$row[9] $row[0]";
$ASuser[$uc] = $row[0]; if (!preg_match("/^$last_user$/i", $temp_camp_user))
$ASstart_epoch[$uc] = $row[8]; {
$last_user = $row[0]; $uc++;
$AScalls[$uc] = 0; $ASuser[$uc] = $row[0];
$ASpauses[$uc] = 0; $AScampaign[$uc] = $row[9];
$ASsessions[$uc] = 0; $ASstart_epoch[$uc] = $row[8];
$last_user = $temp_camp_user;
$AScalls[$uc] = 0;
$ASpauses[$uc] = 0;
$ASsessions[$uc] = 0;
}
}
else
{
if (!preg_match("/^$last_user$/i", $row[0]))
{
$uc++;
$ASuser[$uc] = $row[0];
$ASstart_epoch[$uc] = $row[8];
$last_user = $row[0];
$AScalls[$uc] = 0;
$ASpauses[$uc] = 0;
$ASsessions[$uc] = 0;
}
} }
if ($row[1] > 0) if ($row[1] > 0)
{ {
@@ -8047,8 +8086,14 @@ if ($function == 'agent_stats_export')
$avg_cust_sec = sec_convert($avg_cust_sec,$time_format); $avg_cust_sec = sec_convert($avg_cust_sec,$time_format);
$avg_wait_sec = sec_convert($avg_wait_sec,$time_format); $avg_wait_sec = sec_convert($avg_wait_sec,$time_format);
$output .= "$ASuser[$k]$DL$ASfull_name[$k]$DL$ASuser_group[$k]$DL$AScalls[$k]$DL$login_sec$DL$cust_sec$DL$avg_cust_sec$DL$avg_wait_sec$DL$pct_of_queue%$DL$ASpause_sec[$k]$DL$ASsessions[$k]$DL$avg_session_sec$DL$ASpauses[$k]$DL$avg_pause_sec$DL$pct_pause%$DL$avg_pause_session$DL$wait_sec\n"; if ($group_by_campaign == 'YES')
{
$output .= "$AScampaign[$k]$DL$ASuser[$k]$DL$ASfull_name[$k]$DL$ASuser_group[$k]$DL$AScalls[$k]$DL$login_sec$DL$cust_sec$DL$avg_cust_sec$DL$avg_wait_sec$DL$pct_of_queue%$DL$ASpause_sec[$k]$DL$ASsessions[$k]$DL$avg_session_sec$DL$ASpauses[$k]$DL$avg_pause_sec$DL$pct_pause%$DL$avg_pause_session$DL$wait_sec\n";
}
else
{
$output .= "$ASuser[$k]$DL$ASfull_name[$k]$DL$ASuser_group[$k]$DL$AScalls[$k]$DL$login_sec$DL$cust_sec$DL$avg_cust_sec$DL$avg_wait_sec$DL$pct_of_queue%$DL$ASpause_sec[$k]$DL$ASsessions[$k]$DL$avg_session_sec$DL$ASpauses[$k]$DL$avg_pause_sec$DL$pct_pause%$DL$avg_pause_session$DL$wait_sec\n";
}
$k++; $k++;
} }