From 1b6e0a9fc0f05d5f6711a014218c9da039bb3584 Mon Sep 17 00:00:00 2001 From: IC-Ilies Date: Sat, 21 May 2022 16:25:47 +0200 Subject: [PATCH 1/2] FIX#20886 : manage durations in list_print_total.tpl.php --- htdocs/core/tpl/list_print_total.tpl.php | 9 ++++++++- htdocs/fichinter/list.php | 7 ++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/list_print_total.tpl.php b/htdocs/core/tpl/list_print_total.tpl.php index 929ea2df50f..c103970a26d 100644 --- a/htdocs/core/tpl/list_print_total.tpl.php +++ b/htdocs/core/tpl/list_print_total.tpl.php @@ -13,7 +13,14 @@ if (isset($totalarray['pos'])) { while ($i < $totalarray['nbfield']) { $i++; if (!empty($totalarray['pos'][$i])) { - print ''.price(!empty($totalarray['val'][$totalarray['pos'][$i]])?$totalarray['val'][$totalarray['pos'][$i]]:0).''; + if(!empty($totalarray['type'][$i])){ + if($totalarray['type'][$i] == 'duration'){ + print ''.(!empty($totalarray['val'][$totalarray['pos'][$i]])? convertSecondToTime($totalarray['val'][$totalarray['pos'][$i]]): '00:00').''; + } + } + else { + print '' . price(!empty($totalarray['val'][$totalarray['pos'][$i]]) ? $totalarray['val'][$totalarray['pos'][$i]] : 0) . ''; + } } else { if ($i == 1) { if (is_null($limit) || $num < $limit) { diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index d710d7cd6cc..08c35e2b002 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -132,7 +132,7 @@ $arrayfields = array( 'f.fk_statut'=>array('label'=>'Status', 'checked'=>1, 'position'=>1000), 'fd.description'=>array('label'=>"DescriptionOfLine", 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0), 'fd.date'=>array('label'=>'DateOfLine', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0), - 'fd.duree'=>array('label'=>'DurationOfLine', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0), + 'fd.duree'=>array('label'=>'DurationOfLine', 'type'=> 'duration', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0), //type duration is here because in database, column 'duree' is double ); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -737,9 +737,8 @@ if ($resql) { print ''.convertSecondToTime($obj->duree, 'allhourmin').''; if (!$i) { $totalarray['nbfield']++; - } - if (!$i) { $totalarray['pos'][$totalarray['nbfield']] = 'fd.duree'; + $totalarray['type'][$totalarray['nbfield']] = $arrayfields['fd.duree']['type']; //pass the type for the list_print_total.tpl.php to manage durations } $totalarray['val']['fd.duree'] += $obj->duree; } @@ -763,6 +762,8 @@ if ($resql) { $i++; } + + // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; From f9ff16c6f3723bff44c3da61417a62cf02a9be4a Mon Sep 17 00:00:00 2001 From: IC-Ilies Date: Sat, 21 May 2022 17:33:03 +0200 Subject: [PATCH 2/2] fix psr2 --- htdocs/core/tpl/list_print_total.tpl.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/list_print_total.tpl.php b/htdocs/core/tpl/list_print_total.tpl.php index c103970a26d..09768f71ae4 100644 --- a/htdocs/core/tpl/list_print_total.tpl.php +++ b/htdocs/core/tpl/list_print_total.tpl.php @@ -13,12 +13,11 @@ if (isset($totalarray['pos'])) { while ($i < $totalarray['nbfield']) { $i++; if (!empty($totalarray['pos'][$i])) { - if(!empty($totalarray['type'][$i])){ - if($totalarray['type'][$i] == 'duration'){ + if (!empty($totalarray['type'][$i])) { + if ($totalarray['type'][$i] == 'duration') { print ''.(!empty($totalarray['val'][$totalarray['pos'][$i]])? convertSecondToTime($totalarray['val'][$totalarray['pos'][$i]]): '00:00').''; } - } - else { + } else { print '' . price(!empty($totalarray['val'][$totalarray['pos'][$i]]) ? $totalarray['val'][$totalarray['pos'][$i]] : 0) . ''; } } else {