From b0fe8994e4bfc4cc63da61d9c7c09200771e5044 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 17 Mar 2022 09:32:45 +0100 Subject: [PATCH 1/4] NEW add hook selectProductsListWhere in select_produits_list function --- htdocs/core/class/html.form.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f8d87b5dd5b..c89851fe1b7 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2607,6 +2607,10 @@ class Form } elseif (empty($conf->service->enabled)) { // when service module is disabled, show products only $sql .= " AND p.fk_product_type = 0"; } + // Add where from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('selectProductsListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; // Add criteria on ref/label if ($filterkey != '') { $sql .= ' AND ('; From e8b5fa45f2c56e94fb98a8ed8697361d5bc43086 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 17 Mar 2022 09:55:26 +0100 Subject: [PATCH 2/4] FIX missing global $hookmanager --- htdocs/core/class/html.form.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c89851fe1b7..9a6ae3661dc 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2462,6 +2462,7 @@ class Form { // phpcs:enable global $langs, $conf; + global $hookmanager; $out = ''; $outarray = array(); From dbd0dd7e9710ef67a3d84e2ea964569c62413727 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 17 Mar 2022 10:18:30 +0100 Subject: [PATCH 3/4] NEW add selectThirdpartyListWhere hook --- htdocs/core/class/html.form.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 9a6ae3661dc..ad4e355a83b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1320,6 +1320,7 @@ class Form { // phpcs:enable global $conf, $user, $langs; + global $hookmanager; $out = ''; $num = 0; @@ -1367,6 +1368,10 @@ class Form if (!empty($excludeids)) { $sql .= " AND s.rowid NOT IN (".$this->db->sanitize(join(',', $excludeids)).")"; } + // Add where from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('selectThirdpartyListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; // Add criteria if ($filterkey && $filterkey != '') { $sql .= " AND ("; @@ -3185,6 +3190,7 @@ class Form { // phpcs:enable global $langs, $conf, $user; + global $hookmanager; $out = ''; $outarray = array(); @@ -3234,6 +3240,10 @@ class Form if (!empty($filtre)) { $sql .= " ".$filtre; } + // Add where from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('selectSuppliersProductsListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; // Add criteria on ref/label if ($filterkey != '') { $sql .= ' AND ('; From a73b92c8712a0c80d01e18e3a5f868aebf0f2898 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 17 Mar 2022 11:08:09 +0100 Subject: [PATCH 4/4] NEW add selectContactListWhere hook --- htdocs/core/class/html.form.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ad4e355a83b..ea6d145641a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1684,6 +1684,10 @@ class Form if (!empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) { $sql .= " AND sp.statut <> 0"; } + // Add where from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('selectContactListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; $sql .= " ORDER BY sp.lastname ASC"; dol_syslog(get_class($this)."::selectcontacts", LOG_DEBUG);