NEW Add hooks to let modules add columns to the project overview lists (#39459)

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) <noreply@anthropic.com>
This commit is contained in:
ATM-NicolasV 2026-08-11 19:45:25 +02:00 committed by GitHub
parent 7858059c63
commit 3772cc57c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1410,6 +1410,13 @@ foreach ($listofreferent as $key => $value) {
print '</td>';
}
// 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 '<td class="right" width="120">'.$langs->trans("AmountHT").'</td>';
@ -1751,6 +1758,13 @@ foreach ($listofreferent as $key => $value) {
print '</td>';
}
// 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 '<td class="left">'.convertSecondToTime($total_duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).'</td>';
}
// 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 '<td class="right">';
if (empty($value['disableamount'])) {
if ($key == 'loan') {