From f9ed6ff4f3b1630c5a4a38f5199e5e8c4b24a0a6 Mon Sep 17 00:00:00 2001 From: Oarces DEV Date: Thu, 13 Apr 2023 16:54:26 +0200 Subject: [PATCH 1/3] Update card.php This code generates two rows of a table to display the total duration of an employee, one in time format (DD HH:MM) and the other in hour format (HH). The first row (original code) displays the title "TotalDurationTime" using the "trans" method of the $langs object to translate the string. The total time is converted to HH:MM:SS format using the "convertSecondToTime" function, which takes into account the daily work time duration specified in the global variable $conf->global->MAIN_DURATION_OF_WORKDAY. The second row displays the title "TotalDurationHour" using the "trans" method of the $langs object to translate the string. The total duration is converted to hours using the "convertDurationtoHour" function, specifying "s" as the time unit (seconds). --- htdocs/fichinter/card.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index a4244195bfa..23ef7371ec0 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -9,6 +9,7 @@ * Copyright (C) 2015-2016 Abbes Bahfir * Copyright (C) 2018-2022 Philippe Grand * Copyright (C) 2020 Frédéric France + * Copyright (C) 2023 Benjamin Grembi * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1275,10 +1276,14 @@ if ($action == 'create') { print ''; if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) { - // Duration - print ''; + // Duration in time + print ''; print ''; print ''; + // Duration in hour format + print ''; + print ''; + print ''; } print "
'.$langs->trans("TotalDuration").'
'.$langs->trans("TotalDurationTime").''.convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).'
'.$langs->trans("TotalDurationHour").''.convertDurationtoHour($object->duration, "s").' '.$langs->trans("h").'
"; From 8776c6dcd95db3d973c5f5632f8432474be246aa Mon Sep 17 00:00:00 2001 From: Oarces DEV Date: Wed, 19 Apr 2023 00:57:32 +0200 Subject: [PATCH 2/3] Update card.php --- htdocs/fichinter/card.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 23ef7371ec0..fa983a24514 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1277,12 +1277,8 @@ if ($action == 'create') { if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) { // Duration in time - print ''.$langs->trans("TotalDurationTime").''; - print ''.convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).''; - print ''; - // Duration in hour format - print ''.$langs->trans("TotalDurationHour").''; - print ''.convertDurationtoHour($object->duration, "s").' '.$langs->trans("h").''; + print ''.$langs->trans("TotalDuration").''; + print ''.convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).' ('.convertDurationtoHour($object->duration, "s").' '.$langs->trans("h").')'; print ''; } From 4a3407aa8279013b780d4f7e3adaf1a54dfbc7a7 Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Mon, 1 May 2023 16:00:58 +0200 Subject: [PATCH 3/3] FIX #24653 modulebuilder: replace /myobject/ in includes The templates view, like myobject_card.php are including the following files: dol_include_once('/mymodule/class/myobject.class.php'); dol_include_once('/mymodule/lib/mymodule_myobject.lib.php'); The mymodule value was replaced correctly, but the myobject value wasn't, leading to another classfile beind included when, for instance, creating new `myobject` objects (whatever myobject actually was, except myobject of course), and resulting in PHP errors like: Fatal error: Uncaught Error: Class "DemoObject" not found in /var/www/html/custom/demobug/demoobject_card.php:105 Stack trace: #0 {main} thrown in /var/www/html/custom/demobug/demoobject_card.php on line 105 Fixes #24653 --- htdocs/modulebuilder/index.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index d5a7a7079b2..20a78a21ab9 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1,6 +1,7 @@ * Copyright (C) 2018-2019 Nicolas ZABOURI + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1334,6 +1335,11 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { setEventMessages($langs->trans("FileAlreadyExists", $destfile), null, 'warnings'); } } + $arrayreplacement = array( + '/myobject\.class\.php/' => strtolower($objectname).'.class.php', + '/myobject\.lib\.php/' => strtolower($objectname).'.lib.php', + ); + dolReplaceInFile($destdir.'/'.$destfile, $arrayreplacement, '', 0, 0, 1); } }