From c3f8e0e3978921bb1e1448b526e19ed92bff266f Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Thu, 18 Mar 2021 16:21:54 +0100 Subject: [PATCH 1/4] invoice list - add new standard hook --- htdocs/compta/facture/list.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 9b3dce589fb..3722cb3a98a 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -493,6 +493,10 @@ if ($search_user > 0) { $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } +// Add table from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $sql .= ' WHERE f.fk_soc = s.rowid'; $sql .= ' AND f.entity IN ('.getEntity('invoice').')'; @@ -865,6 +869,10 @@ if ($resql) { // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + // Add $param from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook + $param .= $hookmanager->resPrint; $arrayofmassactions = array( 'validate'=>$langs->trans("Validate"), From 06bc9996148450ef8c4daef0809cfa05be626fff Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Thu, 18 Mar 2021 16:51:02 +0100 Subject: [PATCH 2/4] Add group by and having hooks on invoice list --- htdocs/compta/facture/list.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 3722cb3a98a..81225b289bf 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -697,6 +697,16 @@ if (!$sall) { $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 .= ' ORDER BY '; $listfield = explode(',', $sortfield); $listorder = explode(',', $sortorder); From ada5d728b5d3bcdd18f8aa70bf2427003cfe46eb Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Thu, 18 Mar 2021 17:00:57 +0100 Subject: [PATCH 3/4] invoice list - ajust hooks --- htdocs/compta/facture/list.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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); From 5b72193f0d381aaa33ff8bfcb2661b734de39d36 Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Thu, 18 Mar 2021 17:06:49 +0100 Subject: [PATCH 4/4] invoice list - ajust hooks --- htdocs/compta/facture/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 63e3fa1e2c2..31365b33b58 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -704,7 +704,7 @@ if (!$sall) { // Add HAVING from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= !empty($hookmanager->resPrint) ? (' HAVING 1=1 AND ' . $hookmanager->resPrint) : ''; +$sql .= !empty($hookmanager->resPrint) ? (' HAVING 1=1 ' . $hookmanager->resPrint) : ''; $sql .= ' ORDER BY '; $listfield = explode(',', $sortfield);