diff --git a/agc_2-X/trunk/www/vicidial/AST_agent_time_detail.php b/agc_2-X/trunk/www/vicidial/AST_agent_time_detail.php index 56959d7f..423fac91 100644 --- a/agc_2-X/trunk/www/vicidial/AST_agent_time_detail.php +++ b/agc_2-X/trunk/www/vicidial/AST_agent_time_detail.php @@ -31,6 +31,7 @@ # 130704-0945 - Fixed issue #675 # 130829-2012 - Changed to mysqli PHP functions # 131122-0657 - Added options.php atdr_login_logout_user_link option +# 131129-1020 - Fixed division by zero bug in HTML mode # $startMS = microtime(); @@ -921,11 +922,17 @@ else 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 ($user_holds>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)); + if ($user_holds>0) { + $graph_stats[$m][17]=trim(round(($park_array[$Suser[$m]][1]+0)/$user_holds)); + } else { + $graph_stats[$m][17]=0; + } $graph_stats[$m][18]=trim($user_hpc); @@ -1109,11 +1116,23 @@ else ### END loop through each status ### ### call function to calculate and print dialable leads - $TOTwaitpct=sprintf("%01.2f", (100*$TOTwait/$TOTALtime)); - $TOTtalkpct=sprintf("%01.2f", (100*$TOTtalk/$TOTALtime)); - $TOTdispopct=sprintf("%01.2f", (100*$TOTdispo/$TOTALtime)); - $TOTpausepct=sprintf("%01.2f", (100*$TOTpause/$TOTALtime)); - $TOTdeadpct=sprintf("%01.2f", (100*$TOTdead/$TOTALtime)); + if ($TOTALtime>0) + { + $TOTwaitpct=sprintf("%01.2f", (100*$TOTwait/$TOTALtime)); + $TOTtalkpct=sprintf("%01.2f", (100*$TOTtalk/$TOTALtime)); + $TOTdispopct=sprintf("%01.2f", (100*$TOTdispo/$TOTALtime)); + $TOTpausepct=sprintf("%01.2f", (100*$TOTpause/$TOTALtime)); + $TOTdeadpct=sprintf("%01.2f", (100*$TOTdead/$TOTALtime)); + } + else + { + $TOTwaitpct=sprintf("%01.2f", 0); + $TOTtalkpct=sprintf("%01.2f", 0); + $TOTdispopct=sprintf("%01.2f", 0); + $TOTpausepct=sprintf("%01.2f", 0); + $TOTdeadpct=sprintf("%01.2f", 0); + } + $TOTwait = sec_convert($TOTwait,$TIME_agenttimedetail); $TOTtalk = sec_convert($TOTtalk,$TIME_agenttimedetail); $TOTdispo = sec_convert($TOTdispo,$TIME_agenttimedetail); @@ -1124,8 +1143,16 @@ else $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)); + if ($TOTuser_holds>0) { + $TOTavg_hold_time=round($TOTtotal_hold_time/$TOTuser_holds); + } else { + $TOTavg_hold_time=0; + } + if ($TOTcalls>0) { + $TOTuser_hpc=sprintf("%.2f", ($TOTuser_holds/$TOTcalls)); + } else { + $TOTuser_hpc=0; + } $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); @@ -1183,23 +1210,23 @@ else { $CALLS_graph.="