ok, well if anyone else has an idea, feel free to jump in....
meanwhile, if it were me i'd find a way to display the values and see where they don't look right, like maybe....
PHP Code:
function getResponseTime()
{
global $db, $vbulletin, $hour, $minute;
$result = $db->query_read("SELECT * FROM `" . TABLE_PREFIX . "pl9_support_tickets` ORDER BY tid DESC LIMIT 30");
$ticket_num = $db->num_rows($result);
if($ticket_num > 0)
{
$i = 0;
$seconds = 0;
while ($res = $db->fetch_array($result)){
$query = $db->query_first("SELECT radded FROM `" . TABLE_PREFIX . "pl9_support_replies` WHERE ticket='". $res['tid'] ."' ORDER BY radded ASC LIMIT 1");
$query_num = $db->num_rows($query);
$rep = $query['radded'];
$tick = $res['tadded'];
$seconds += ($rep - $tick);
$i++;
$debug_tickets .= "tid=".$res['tid']." tadded=".$res['tadded']." radded=".$query['radded']." seconds=".$seconds." i=".$i."<BR>";
}
if($i>0)
{
$avg = $seconds / $i;
}
} else {
$avg = 0;
}
$hour = floor($avg/3600);
$resttime = $avg - ($hour*3600);
$minute = floor($resttime/60);
return;
}
Then put $debug_tickets in the template somewhere.