Better detail for time elapsed

This commit is contained in:
Laurent Destailleur
2018-07-16 11:14:39 +02:00
parent 89cc048fff
commit d3cc2c81eb
3 changed files with 45 additions and 30 deletions

View File

@@ -7637,3 +7637,15 @@ function isVisibleToUserType($type_user, &$menuentry, &$listofmodulesforexternal
if (! $menuentry['perms']) return 2; // No permissions and user is external
return 1;
}
/**
* Round to next multiple.
*
* @param double $n Number to round up
* @param integer $x Multiple. For example 60 to round up to nearest exact minute for a date with seconds.
* @return integer Value rounded.
*/
function roundUpToNextMultiple($n, $x=5)
{
return (ceil($n)%$x === 0) ? ceil($n) : round(($n+$x/2)/$x)*$x;
}

View File

@@ -198,7 +198,8 @@ TicketMessageMailSignatureLabelAdmin=Signature of response email
TicketMessageMailSignatureHelpAdmin=This text will be inserted after the response message.
TicketMessageHelp=Only this text will be saved in the message list on ticket card.
TicketMessageSubstitutionReplacedByGenericValues=Substitutions variables are replaced by generic values.
TicketTimeToRead=Time elapsed before ticket read
TimeElapsedSince=Time elapsed since
TicketTimeToRead=Time elapsed before read
TicketContacts=Contacts ticket
TicketDocumentsLinked=Documents linked to ticket
ConfirmReOpenTicket=Confirm reopen this ticket ?

View File

@@ -82,6 +82,8 @@ $permissiontoadd = $user->rights->ticket->write;
$actionobject = new ActionsTicket($db);
$now = dol_now();
/*
* Actions
@@ -364,26 +366,23 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
// Creation date
print '<tr><td>' . $langs->trans("DateCreation") . '</td><td>';
print dol_print_date($object->datec, 'dayhour');
print ' - '.$langs->trans("TimeElapsedSince").': '.'<i>'.convertSecondToTime(roundUpToNextMultiple($now - $object->datec, 60)).'</i>';
print '</td></tr>';
// Read date
print '<tr><td>' . $langs->trans("TicketReadOn") . '</td><td>';
if (!empty($object->date_read)) {
print '<tr><td>' . $langs->trans("TicketReadOn") . '</td><td>';
print dol_print_date($object->date_read, 'dayhour');
print '</td></tr>';
print '<tr><td>' . $langs->trans("TicketTimeToRead") . '</td><td>';
print '<strong>' . convertSecondToTime($object->date_read - $object->datec) . '</strong>';
print '</td></tr>';
print dol_print_date($object->date_read, 'dayhour');
print ' - '.$langs->trans("TicketTimeToRead").': <i>'.convertSecondToTime(roundUpToNextMultiple($object->date_read - $object->datec, 60)).'</i>';
print ' - '.$langs->trans("TimeElapsedSince").': '.'<i>'.convertSecondToTime(roundUpToNextMultiple($now - $object->date_read, 60)).'</i>';
}
print '</td></tr>';
// Close date
print '<tr><td>' . $langs->trans("TicketCloseOn") . '</td><td>';
if (!empty($object->date_close)) {
print '<tr><td>' . $langs->trans("TicketCloseOn") . '</td><td>';
print dol_print_date($object->date_close, 'dayhour');
print '</td></tr>';
print dol_print_date($object->date_close, 'dayhour');
}
print '</td></tr>';
// Thirdparty
@@ -453,25 +452,28 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
print '</td>';
print '</tr>';
// Timing (Duration sum of linked fichinter
$object->fetchObjectLinked();
$num = count($object->linkedObjects);
$timing = 0;
if ($num) {
foreach ($object->linkedObjects as $objecttype => $objects) {
if ($objecttype = "fichinter") {
foreach ($objects as $fichinter) {
$timing += $fichinter->duration;
}
}
}
}
print '<tr><td valign="top">';
// Timing (Duration sum of linked fichinter)
if ($conf->fichinter->enabled)
{
$object->fetchObjectLinked();
$num = count($object->linkedObjects);
$timing = 0;
if ($num) {
foreach ($object->linkedObjects as $objecttype => $objects) {
if ($objecttype = "fichinter") {
foreach ($objects as $fichinter) {
$timing += $fichinter->duration;
}
}
}
}
print '<tr><td valign="top">';
print $form->textwithpicto($langs->trans("TicketDurationAuto"), $langs->trans("TicketDurationAutoInfos"), 1);
print '</td><td>';
print convertSecondToTime($timing, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
print '</td></tr>';
print $form->textwithpicto($langs->trans("TicketDurationAuto"), $langs->trans("TicketDurationAutoInfos"), 1);
print '</td><td>';
print convertSecondToTime($timing, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
print '</td></tr>';
}
// Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';