From 3772cc57c91ec83786b9a8bc0edfb9e5d29aaa3f Mon Sep 17 00:00:00 2001 From: ATM-NicolasV <92087862+ATM-NicolasV@users.noreply.github.com> Date: Tue, 11 Aug 2026 19:45:25 +0200 Subject: [PATCH] NEW Add hooks to let modules add columns to the project overview lists (#39459) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The element lists of the project overview (projet/element.php) cannot be extended with an extra column. The only hook available, printOverviewDetail, replaces the whole block of an element type, which forces a module to duplicate around 760 lines of core rendering — including the link/unlink actions and their permission checks — just to display one more column. Add three output hooks, consistent with the printOverview* family already used in this file: - printOverviewDetailTitle, in the header row before the amount columns - printOverviewDetailValue, in each element row at the same position, receiving the current element and qualifiedfortotal so a module can keep its own totals consistent with the amount totals of the list - printOverviewDetailTotal, in the total row before the amount totals All three are placed at the same relative position, so a module adding N cells in each keeps every row aligned. No behaviour change when no module implements them, and no existing hook name is reused, so context-blind implementations of the generic printFieldList* hooks cannot inject unexpected columns here. Co-authored-by: Claude Opus 5 (1M context) --- htdocs/projet/element.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index d3c0fe7ca0c..25d76ce5911 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -1410,6 +1410,13 @@ foreach ($listofreferent as $key => $value) { print ''; } + // Additional columns from hooks + $parameters = array('key' => $key, 'value' => $value, 'tablename' => $tablename); + $reshook = $hookmanager->executeHooks('printOverviewDetailTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + print $hookmanager->resPrint; // Amount HT //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print ''.$langs->trans("AmountHT").''; @@ -1751,6 +1758,13 @@ foreach ($listofreferent as $key => $value) { print ''; } + // Additional columns from hooks + $parameters = array('key' => $key, 'value' => $value, 'tablename' => $tablename, 'element' => $element, 'i' => $i, 'qualifiedfortotal' => $qualifiedfortotal); + $reshook = $hookmanager->executeHooks('printOverviewDetailValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + print $hookmanager->resPrint; // Amount without tax $warning = ''; @@ -1977,6 +1991,13 @@ foreach ($listofreferent as $key => $value) { if ($tablename == 'fichinter') { print ''.convertSecondToTime($total_duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).''; } + // Additional total columns from hooks + $parameters = array('key' => $key, 'value' => $value, 'tablename' => $tablename, 'nbelement' => $i); + $reshook = $hookmanager->executeHooks('printOverviewDetailTotal', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + print $hookmanager->resPrint; print ''; if (empty($value['disableamount'])) { if ($key == 'loan') {