Show duration of jobs
This commit is contained in:
parent
67efae20f4
commit
05cc5b6398
@ -165,6 +165,7 @@ function convertTime2Seconds($iHours=0, $iMinutes=0, $iSeconds=0)
|
||||
* @param string $format Output format ('all': total delay days hour:min like "2 days 12:30",
|
||||
* - 'allwithouthour': total delay days without hour part like "2 days",
|
||||
* - 'allhourmin': total delay with format hours:min like "60:30",
|
||||
* - 'allhourminsec': total delay with format hours:min:sec like "60:30:10",
|
||||
* - 'allhour': total delay hours without min/sec like "60:30",
|
||||
* - 'fullhour': total delay hour decimal like "60.5" for 60:30,
|
||||
* - 'hour': only hours part "12",
|
||||
@ -185,7 +186,7 @@ function convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengt
|
||||
if (empty($lengthOfDay)) $lengthOfDay = 86400; // 1 day = 24 hours
|
||||
if (empty($lengthOfWeek)) $lengthOfWeek = 7; // 1 week = 7 days
|
||||
|
||||
if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin')
|
||||
if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin' || $format == 'allhourminsec')
|
||||
{
|
||||
if ((int) $iSecond === 0) return '0'; // This is to avoid having 0 return a 12:00 AM for en_US
|
||||
|
||||
@ -232,11 +233,15 @@ function convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengt
|
||||
$sTime.= dol_print_date($iSecond,'hourduration',true);
|
||||
}
|
||||
}
|
||||
if ($format == 'allhourmin')
|
||||
elseif ($format == 'allhourminsec')
|
||||
{
|
||||
return sprintf("%02d",($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))).':'.sprintf("%02d",((int) floor(($iSecond % 3600)/60))).':'.sprintf("%02d",((int) ($iSecond % 60)));
|
||||
}
|
||||
elseif ($format == 'allhourmin')
|
||||
{
|
||||
return sprintf("%02d",($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))).':'.sprintf("%02d",((int) floor(($iSecond % 3600)/60)));
|
||||
}
|
||||
if ($format == 'allhour')
|
||||
elseif ($format == 'allhour')
|
||||
{
|
||||
return sprintf("%02d",($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600)));
|
||||
}
|
||||
|
||||
@ -409,7 +409,7 @@ print_liste_field_titre("CronDtEnd",$_SERVER["PHP_SELF"],"t.dateend","",$param,'
|
||||
print_liste_field_titre("CronMaxRun",$_SERVER["PHP_SELF"],"t.maxrun","",$param,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("CronNbRun",$_SERVER["PHP_SELF"],"t.nbrun","",$param,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("CronDtLastLaunch",$_SERVER["PHP_SELF"],"t.datelastrun","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("CronDtLastResult",$_SERVER["PHP_SELF"],"t.datelastresult","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("Duration",$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("CronLastResult",$_SERVER["PHP_SELF"],"t.lastresult","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("CronLastOutput",$_SERVER["PHP_SELF"],"t.lastoutput","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre("CronDtNextLaunch",$_SERVER["PHP_SELF"],"t.datenextrun","",$param,'align="center"',$sortfield,$sortorder);
|
||||
@ -438,6 +438,9 @@ if ($num > 0)
|
||||
$object->priority = $obj->priority;
|
||||
$object->processing = $obj->processing;
|
||||
|
||||
$datelastrun = $db->jdate($obj->datelastrun);
|
||||
$datelastresult = $db->jdate($obj->datelastresult);
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Ref
|
||||
@ -510,12 +513,15 @@ if ($num > 0)
|
||||
|
||||
// Date start last run
|
||||
print '<td class="center">';
|
||||
if (!empty($obj->datelastrun)) {print dol_print_date($db->jdate($obj->datelastrun),'dayhoursec');}
|
||||
if (!empty($datelastrun)) {print dol_print_date($datelastrun,'dayhoursec');}
|
||||
print '</td>';
|
||||
|
||||
// Date end last run
|
||||
// Duration
|
||||
print '<td class="center">';
|
||||
if (!empty($obj->datelastresult)) {print dol_print_date($db->jdate($obj->datelastresult),'dayhoursec');}
|
||||
if (!empty($datelastresult) && ($datelastresult >= $datelastrun)) {
|
||||
print convertSecondToTime(max($datelastresult - $datelastrun, 1), 'allhourminsec');
|
||||
//print '<br>'.($datelastresult - $datelastrun).' '.$langs->trans("seconds");
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Return code of last run
|
||||
|
||||
Loading…
Reference in New Issue
Block a user