diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 81225b289bf..63e3fa1e2c2 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -693,19 +693,18 @@ if (!$sall) { $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : ''); } } + // Add GroupBy from hooks + $parameters = array('all' => $all, 'fieldstosearchall' => $fieldstosearchall); + $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; } else { $sql .= natural_search(array_keys($fieldstosearchall), $sall); } -// Add GroupBy from hooks -$parameters = array('all' => $all, 'fieldstosearchall' => $fieldstosearchall); -$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; - // Add HAVING from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; +$sql .= !empty($hookmanager->resPrint) ? (' HAVING 1=1 AND ' . $hookmanager->resPrint) : ''; $sql .= ' ORDER BY '; $listfield = explode(',', $sortfield);