diff --git a/www/vicidial/AST_agent_time_detail.php b/www/vicidial/AST_agent_time_detail.php index 4b635912..a2bcb7a6 100644 --- a/www/vicidial/AST_agent_time_detail.php +++ b/www/vicidial/AST_agent_time_detail.php @@ -25,6 +25,7 @@ # 120224-0910 - Added HTML display option with bar graphs # 121130-0957 - Fix for user group permissions issue #588 # 130414-0137 - Added report logging +# 220414-2111 - Added counts on parked(hold) calls # $startMS = microtime(); @@ -49,6 +50,8 @@ if (isset($_GET["stage"])) {$stage=$_GET["stage"];} elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} if (isset($_GET["file_download"])) {$file_download=$_GET["file_download"];} elseif (isset($_POST["file_download"])) {$file_download=$_POST["file_download"];} +if (isset($_GET["show_parks"])) {$show_parks=$_GET["show_parks"];} + elseif (isset($_POST["show_parks"])) {$show_parks=$_POST["show_parks"];} if (isset($_GET["DB"])) {$DB=$_GET["DB"];} elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} if (isset($_GET["submit"])) {$submit=$_GET["submit"];} @@ -252,10 +255,11 @@ while($i < $group_ct) $i++; } if ( (ereg("--ALL--",$group_string) ) or ($group_ct < 1) ) - {$group_SQL = "";} + {$group_SQL = ""; $park_log_SQL = "";} else { $group_SQL = eregi_replace(",$",'',$group_SQL); + $park_log_SQL = "and channel_group in ($group_SQL)"; $group_SQL = "and campaign_id IN($group_SQL)"; } @@ -417,8 +421,12 @@ else $max_pause=1; $max_dead=1; $max_customer=1; - $GRAPH=""; - $GRAPH2=""; + $GRAPH="
CALLSTIME CLOCKAGENT TIMEWAITWAIT %TALKTALKTIME%DISPODISPOTIME%PAUSEPAUSETIME%DEADDEADTIME%CUSTOMER
"; + $GRAPH2=""; + if ($show_parks) { + $GRAPH2.=""; + } + $GRAPH2.=""; $graph_header="
CALLSTIME CLOCKAGENT TIMEPARKSPARKTIMEAVGPARKPARKS/CALLWAITWAIT %TALKTALKTIME%DISPODISPOTIME%PAUSEPAUSETIME%DEADDEADTIME%CUSTOMER
"; $CALLS_graph=$graph_header.""; $TIMECLOCK_graph=$graph_header.""; @@ -434,6 +442,10 @@ else $DEAD_graph=$graph_header.""; $DEADPCT_graph=$graph_header.""; $CUSTOMER_graph=$graph_header.""; + $PARKS_graph=$graph_header.""; + $PARKTIME_graph=$graph_header.""; + $AVGPARK_graph=$graph_header.""; + $PARKSCALL_graph=$graph_header.""; while ($i < $users_to_print) { @@ -473,9 +485,27 @@ else $PCusersARY=$MT; $PCuser_namesARY=$MT; $user_count=0; + + if ($show_parks) { + $park_HEADER=" PARKS | PARK TIME | AVG PARK | PARKS/CALL |"; + $park_HEADER_DIV="+----------+------------+------------+------------"; + $park_HEADER_CSV=",PARKS,PARK TIME,AVG PARK,PARKS/CALL"; + } + + # Displays park info - need to run regardless so HTML view will populate + $park_array=array(); + $park_stmt="select user, count(*), sum(parked_sec) From park_log where parked_time <= '$query_date_END' and parked_time >= '$query_date_BEGIN' $park_log_SQL"; + if ($DB) {$ASCII_text.= "$park_stmt\n";} + $park_rslt=mysql_query($park_stmt, $link); + while ($park_row=mysql_fetch_row($park_rslt)) { + $park_array[$park_row[0]][0]=$park_row[1]; + $park_array[$park_row[0]][1]=$park_row[2]; + } + $stmt="select $userSQL,sum(pause_sec),sub_status from vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and pause_sec > 0 and pause_sec < 65000 $group_SQL $user_group_SQL group by user,sub_status order by user,sub_status desc limit 10000000;"; $rslt=mysql_query($stmt, $link); - if ($DB) {echo "$stmt\n";} + + if ($DB) {$ASCII_text.= "$stmt\n";} $subs_to_print = mysql_num_rows($rslt); $i=0; while ($i < $subs_to_print) @@ -513,7 +543,7 @@ else ##### BEGIN Gather all agent time records and parse through them in PHP to save on DB load $stmt="select $userSQL,wait_sec,talk_sec,dispo_sec,pause_sec,lead_id,status,dead_sec from vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' $group_SQL $user_group_SQL limit 10000000;"; $rslt=mysql_query($stmt, $link); - if ($DB) {echo "$stmt\n";} + if ($DB) {$ASCII_text.= "$stmt\n";} $rows_to_print = mysql_num_rows($rslt); $i=0; $j=0; @@ -600,15 +630,15 @@ else if ($file_download < 1) { $ASCII_text.="AGENT TIME BREAKDOWN:\n"; - $ASCII_text.="+-----------------+----------+----------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n"; - $ASCII_text.="| USER NAME | ID | CALLS | TIME CLOCK | AGENT TIME | WAIT | WAIT % | TALK | TALK TIME %| DISPO | DISPOTIME %| PAUSE | PAUSETIME %| DEAD | DEAD TIME %| CUSTOMER | |$sub_statusesHTML\n"; - $ASCII_text.="+-----------------+----------+----------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n"; + $ASCII_text.="+-----------------+----------+----------+------------+------------$park_HEADER_DIV+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n"; + $ASCII_text.="| USER NAME | ID | CALLS | TIME CLOCK | AGENT TIME |$park_HEADER WAIT | WAIT % | TALK | TALK TIME %| DISPO | DISPOTIME %| PAUSE | PAUSETIME %| DEAD | DEAD TIME %| CUSTOMER | |$sub_statusesHTML\n"; + $ASCII_text.="+-----------------+----------+----------+------------+------------$park_HEADER_DIV+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n"; } else { - $file_output .= "USER,ID,CALLS,TIME CLOCK,AGENT TIME,WAIT,WAIT %,TALK,TALK TIME %,DISPO,DISPO TIME %,PAUSE,PAUSE TIME %,DEAD,DEAD TIME %,CUSTOMER$sub_statusesFILE\n"; + $file_output .= "USER,ID,CALLS,TIME CLOCK,AGENT TIME$park_HEADER_CSV,WAIT,WAIT %,TALK,TALK TIME %,DISPO,DISPO TIME %,PAUSE,PAUSE TIME %,DEAD,DEAD TIME %,CUSTOMER$sub_statusesFILE\n"; } ##### END print the output to screen or put into file output variable @@ -803,6 +833,7 @@ else } ### END loop through each status ### + $Swaitpct[$m]= sprintf("%9s", $Swaitpct[$m])."%"; $Stalkpct[$m]= sprintf("%9s", $Stalkpct[$m])."%"; $Sdispopct[$m]= sprintf("%9s", $Sdispopct[$m])."%"; @@ -817,6 +848,37 @@ else $Scalls[$m]= sprintf("%8s", $Scalls[$m]); $Stime[$m]= sprintf("%10s", $Stime[$m]); + # PARK INFO + if ($show_parks) { + $user_holds=$park_array[$Suser[$m]][0]+0; + $total_hold_time=$park_array[$Suser[$m]][1]+0; + $TOTuser_holds+=$park_array[$Suser[$m]][0]; + $TOTtotal_hold_time+=$park_array[$Suser[$m]][1]; + + $avg_hold_time=round($total_hold_time/$user_holds); + $user_hpc=sprintf("%.2f", ($user_holds/$Scalls[$m])); + + $total_hold_time=sec_convert($total_hold_time,$TIME_agenttimedetail); + $avg_hold_time=sec_convert($avg_hold_time,$TIME_agenttimedetail); + + $user_holds= sprintf("%8s", $user_holds); + $total_hold_time= sprintf("%10s", $total_hold_time); + $avg_hold_time= sprintf("%10s", $avg_hold_time); + $user_hpc= sprintf("%10s", $user_hpc); + $park_AGENT_INFO=" $user_holds | $total_hold_time | $avg_hold_time | $user_hpc |"; + $park_AGENT_INFO_CSV="$user_holds,$total_hold_time,$avg_hold_time,$user_hpc,"; + } + + if (trim($user_holds)>$max_user_holds) {$max_user_holds=trim($user_holds);} + if (trim($park_array[$Suser[$m]][1]+0)>$max_total_hold_time) {$max_total_hold_time=trim($park_array[$Suser[$m]][1]+0);} + if (trim(round(($park_array[$Suser[$m]][1]+0)/$user_holds))>$max_avg_hold_time) {$max_avg_hold_time=trim(round(($park_array[$Suser[$m]][1]+0)/$user_holds));} + if (trim($user_hpc)>$max_user_hpc) {$max_user_hpc=trim($user_hpc);} + $graph_stats[$m][15]=trim($user_holds); + $graph_stats[$m][16]=trim($park_array[$Suser[$m]][1]+0); + $graph_stats[$m][17]=trim(round(($park_array[$Suser[$m]][1]+0)/$user_holds)); + $graph_stats[$m][18]=trim($user_hpc); + + if ($non_latin < 1) { $Sname[$m]= sprintf("%-15s", $Sname[$m]); @@ -835,7 +897,7 @@ else if ($file_download < 1) { - $Toutput = "| $Sname[$m] | $Suser[$m] | $Scalls[$m] | $StimeTC[$m]$TCuserAUTOLOGOUT| $Stime[$m] | $Swait[$m] | $Swaitpct[$m] | $Stalk[$m] | $Stalkpct[$m] | $Sdispo[$m] | $Sdispopct[$m] | $Spause[$m] | $Spausepct[$m] | $Sdead[$m] | $Sdeadpct[$m] | $Scustomer[$m] | |$SstatusesHTML\n"; + $Toutput = "| $Sname[$m] | $Suser[$m] | $Scalls[$m] | $StimeTC[$m]$TCuserAUTOLOGOUT| $Stime[$m] |$park_AGENT_INFO $Swait[$m] | $Swaitpct[$m] | $Stalk[$m] | $Stalkpct[$m] | $Sdispo[$m] | $Sdispopct[$m] | $Spause[$m] | $Spausepct[$m] | $Sdead[$m] | $Sdeadpct[$m] | $Scustomer[$m] | |$SstatusesHTML\n"; $graph_stats[$m][0]=trim("$Suser[$m] - $Sname[$m]"); #CALLS | TIME CLOCK | AGENT TIME | WAIT | TALK | DISPO | PAUSE | DEAD | CUSTOMER | | LOGIN | TRAIN | TOILET | PRECAL | BREAK | | LUNCH | LAGGED } @@ -853,7 +915,12 @@ else if (strlen($RAWdead)<1) {$RAWdead='0';} if (strlen($RAWdeadpct)<0) {$RAWdeadpct='0.0%';} if (strlen($RAWcustomer)<1) {$RAWcustomer='0';} - $fileToutput = "$RAWname,$RAWuser,$RAWcalls,$RAWtimeTC,$RAWtime,$RAWwait,$RAWwaitpct %,$RAWtalk,$RAWtalkpct %,$RAWdispo,$RAWdispopct %,$RAWpause,$RAWpausepct %,$RAWdead,$RAWdeadpct %,$RAWcustomer$SstatusesFILE\n"; + $user_holds=trim($user_holds); + $total_hold_time=trim($total_hold_time); + $avg_hold_time=trim($avg_hold_time); + $user_hpc=trim($user_hpc); + + $fileToutput = "$RAWname,$RAWuser,$RAWcalls,$RAWtimeTC,$RAWtime,$park_AGENT_INFO_CSV$RAWwait,$RAWwaitpct %,$RAWtalk,$RAWtalkpct %,$RAWdispo,$RAWdispopct %,$RAWpause,$RAWpausepct %,$RAWdead,$RAWdeadpct %,$RAWcustomer$SstatusesFILE\n"; } $TOPsorted_output[$m] = $Toutput; @@ -998,6 +1065,19 @@ else $TOTALtime = sec_convert($TOTALtime,$TIME_agenttimedetail); $TOTtimeTC = sec_convert($TOTtimeTC,$TIME_agenttimedetail); + if ($show_parks) { + $TOTavg_hold_time=round($TOTtotal_hold_time/$TOTuser_holds); + $TOTuser_hpc=sprintf("%.2f", ($TOTuser_holds/$TOTcalls)); + $TOTtotal_hold_time=sec_convert($TOTtotal_hold_time,$TIME_agenttimedetail); + $TOTavg_hold_time=sec_convert($TOTavg_hold_time,$TIME_agenttimedetail); + $hTOTuser_holds= sprintf("%8s", $TOTuser_holds); + $hTOTtotal_hold_time= sprintf("%10s", $TOTtotal_hold_time); + $hTOTavg_hold_time= sprintf("%10s", $TOTavg_hold_time); + $hTOTuser_hpc= sprintf("%10s", $TOTuser_hpc); + $park_TOTALS=" $hTOTuser_holds | $hTOTtotal_hold_time | $hTOTavg_hold_time | $hTOTuser_hpc |"; + $park_TOTALS_CSV="$TOTuser_holds,$TOTtotal_hold_time,$TOTavg_hold_time,$TOTuser_hpc,"; + } + $hTOTwaitpct = sprintf("%10s", $TOTwaitpct)."%"; $hTOTtalkpct = sprintf("%10s", $TOTtalkpct)."%"; $hTOTdispopct = sprintf("%10s", $TOTdispopct)."%"; @@ -1018,9 +1098,9 @@ else if ($file_download < 1) { - $ASCII_text.="+-----------------+----------+----------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n"; - $ASCII_text.="| TOTALS AGENTS:$hTOT_AGENTS | $hTOTcalls |$hTOTtimeTC |$hTOTALtime |$hTOTwait |$hTOTwaitpct |$hTOTtalk |$hTOTtalkpct |$hTOTdispo |$hTOTdispopct |$hTOTpause |$hTOTpausepct |$hTOTdead |$hTOTdeadpct |$hTOTcustomer | |$SUMstatusesHTML\n"; - $ASCII_text.="+-----------------+----------+----------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n"; + $ASCII_text.="+-----------------+----------+----------+------------+------------$park_HEADER_DIV+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n"; + $ASCII_text.="| TOTALS AGENTS:$hTOT_AGENTS | $hTOTcalls |$hTOTtimeTC |$hTOTALtime |$park_TOTALS$hTOTwait |$hTOTwaitpct |$hTOTtalk |$hTOTtalkpct |$hTOTdispo |$hTOTdispopct |$hTOTpause |$hTOTpausepct |$hTOTdead |$hTOTdeadpct |$hTOTcustomer | |$SUMstatusesHTML\n"; + $ASCII_text.="+-----------------+----------+----------+------------+------------$park_HEADER_DIV+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n"; if ($AUTOLOGOUTflag > 0) {echo " * denotes AUTOLOGOUT from timeclock\n";} $ASCII_text.="\n\n"; @@ -1034,20 +1114,24 @@ else for ($d=0; $d"; - $TIMECLOCK_graph.=" "; - $AGENTTIME_graph.=" "; - $WAIT_graph.=" "; - $TALK_graph.=" "; - $DISPO_graph.=" "; - $PAUSE_graph.=" "; - $DEAD_graph.=" "; - $CUSTOMER_graph.=" "; - $TALKPCT_graph.=" "; - $DISPOPCT_graph.=" "; - $PAUSEPCT_graph.=" "; - $DEADPCT_graph.=" "; - $WAITPCT_graph.=" "; + $CALLS_graph.=" "; + $TIMECLOCK_graph.=" "; + $AGENTTIME_graph.=" "; + $WAIT_graph.=" "; + $TALK_graph.=" "; + $DISPO_graph.=" "; + $PAUSE_graph.=" "; + $DEAD_graph.=" "; + $CUSTOMER_graph.=" "; + $TALKPCT_graph.=" "; + $DISPOPCT_graph.=" "; + $PAUSEPCT_graph.=" "; + $DEADPCT_graph.=" "; + $WAITPCT_graph.=" "; + $PARKS_graph.=" "; + $PARKTIME_graph.=" "; + $AVGPARK_graph.=" "; + $PARKSCALL_graph.=" "; for ($e=0; $e\n"; - $$varname.=" "; + $$varname.=" "; } } $CALLS_graph.="
AGENT TIME BREAKDOWN
STATUSCALLS
TIME CLOCK
DEAD
DEAD TIME %
CUSTOMER
PARKS
PARKTIME
AVGPARK
PARKSCALL
".$graph_stats[$d][1]."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][2], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][3], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][4], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][5], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][6], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][7], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][8], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][9], 'HF')."
".$graph_stats[$d][0]."".$graph_stats[$d][10]." %
".$graph_stats[$d][0]."".$graph_stats[$d][11]." %
".$graph_stats[$d][0]."".$graph_stats[$d][12]." %
".$graph_stats[$d][0]."".$graph_stats[$d][13]." %
".$graph_stats[$d][0]."".$graph_stats[$d][14]." %
".$graph_stats[$d][0]."".$graph_stats[$d][1]."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][2], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][3], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][4], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][5], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][6], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][7], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][8], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][9], 'HF')."
".$graph_stats[$d][0]."".$graph_stats[$d][10]." %
".$graph_stats[$d][0]."".$graph_stats[$d][11]." %
".$graph_stats[$d][0]."".$graph_stats[$d][12]." %
".$graph_stats[$d][0]."".$graph_stats[$d][13]." %
".$graph_stats[$d][0]."".$graph_stats[$d][14]." %
".$graph_stats[$d][0]."".$graph_stats[$d][15]."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][16],'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][17],'HF')."
".$graph_stats[$d][0]."".$graph_stats[$d][18]."
".$graph_stats[$d][0]."".sec_convert($graph_stats_sub[$d][$e], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats_sub[$d][$e], 'HF')."
TOTAL:".trim($hTOTcalls)."
"; @@ -1072,6 +1156,11 @@ else $DISPOPCT_graph.="AVERAGE:".trim($hTOTdispopct).""; $PAUSEPCT_graph.="AVERAGE:".trim($hTOTpausepct).""; $DEADPCT_graph.="AVERAGE:".trim($hTOTdeadpct).""; + $PARKS_graph.="TOTAL:".trim($hTOTuser_holds).""; + $PARKTIME_graph.="TOTAL:".trim($hTOTtotal_hold_time).""; + $AVGPARK_graph.="AVERAGE:".trim($hTOTavg_hold_time).""; + $PARKSCALL_graph.="AVERAGE:".trim($hTOTuser_hpc).""; + for ($e=0; $e
 


"; + $GRAPH3="
 


"; # echo $GRAPH.$GRAPH2.$GRAPH3.$max; } else { - $file_output .= "TOTALS,$TOT_AGENTS,$TOTcalls,$TOTtimeTC,$TOTALtime,$TOTwait,$TOTwaitpct %,$TOTtalk,$TOTtalkpct %,$TOTdispo,$TOTpause,$TOTdead,$TOTcustomer$SUMstatusesFILE\n"; + $file_output .= "TOTALS,$TOT_AGENTS,$TOTcalls,$TOTtimeTC,$TOTALtime,$park_TOTALS_CSV$TOTwait,$TOTwaitpct %,$TOTtalk,$TOTtalkpct %,$TOTdispo,$TOTpause,$TOTdead,$TOTcustomer$SUMstatusesFILE\n"; } } @@ -1266,7 +1359,8 @@ echo "\n"; echo "\n"; echo "\n"; echo "\n"; -echo "

\n"; +echo "
\n"; +echo "Show parks-holds
"; echo "Display as:
"; echo "