diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7b515fd1e46..714f155120d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -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; +} diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index 6cc31a25bfd..9f441d1c66f 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -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 ? diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 78337253b1b..cf49bda3562 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -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 '' . $langs->trans("DateCreation") . ''; print dol_print_date($object->datec, 'dayhour'); + print ' - '.$langs->trans("TimeElapsedSince").': '.''.convertSecondToTime(roundUpToNextMultiple($now - $object->datec, 60)).''; print ''; // Read date + print '' . $langs->trans("TicketReadOn") . ''; if (!empty($object->date_read)) { - print '' . $langs->trans("TicketReadOn") . ''; - print dol_print_date($object->date_read, 'dayhour'); - print ''; - - print '' . $langs->trans("TicketTimeToRead") . ''; - print '' . convertSecondToTime($object->date_read - $object->datec) . ''; - print ''; + print dol_print_date($object->date_read, 'dayhour'); + print ' - '.$langs->trans("TicketTimeToRead").': '.convertSecondToTime(roundUpToNextMultiple($object->date_read - $object->datec, 60)).''; + print ' - '.$langs->trans("TimeElapsedSince").': '.''.convertSecondToTime(roundUpToNextMultiple($now - $object->date_read, 60)).''; } + print ''; // Close date + print '' . $langs->trans("TicketCloseOn") . ''; if (!empty($object->date_close)) { - print '' . $langs->trans("TicketCloseOn") . ''; - print dol_print_date($object->date_close, 'dayhour'); - print ''; + print dol_print_date($object->date_close, 'dayhour'); } - print ''; // Thirdparty @@ -453,25 +452,28 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti print ''; print ''; - // 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 ''; + // 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 ''; - print $form->textwithpicto($langs->trans("TicketDurationAuto"), $langs->trans("TicketDurationAutoInfos"), 1); - print ''; - print convertSecondToTime($timing, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); - print ''; + print $form->textwithpicto($langs->trans("TicketDurationAuto"), $langs->trans("TicketDurationAutoInfos"), 1); + print ''; + print convertSecondToTime($timing, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); + print ''; + } // Other attributes include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';