diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 0db01a84656..3d7bceadcf3 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -1618,7 +1618,7 @@ class Form
public function select_dolusers($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $show_every = 0, $enableonlytext = '', $morecss = '', $noactive = 0, $outputmode = 0, $multiple = false)
{
// phpcs:enable
- global $conf, $user, $langs;
+ global $conf, $user, $langs, $hookmanager;
// If no preselected user defined, we take current user
if ((is_numeric($selected) && ($selected < -2 || empty($selected))) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) $selected = $user->id;
@@ -1679,6 +1679,10 @@ class Form
if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive) $sql .= " AND u.statut <> 0";
if (!empty($morefilter)) $sql .= " ".$morefilter;
+ //Add hook to filter on user (for exemple on usergroup define in custom modules)
+ $reshook = $hookmanager->executeHooks('addSQLWhereFilterOnSelectUsers', array(), $this, $action);
+ if (!empty($reshook)) $sql .= $hookmanager->resPrint;
+
if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) // MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname
{
$sql .= " ORDER BY u.firstname ASC";
diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php
index 829a3f9c72f..b245f5f013b 100644
--- a/htdocs/core/class/html.formother.class.php
+++ b/htdocs/core/class/html.formother.class.php
@@ -424,7 +424,7 @@ class FormOther
public function select_salesrepresentatives($selected, $htmlname, $user, $showstatus = 0, $showempty = 1, $morecss = '', $norepresentative = 0)
{
// phpcs:enable
- global $conf, $langs;
+ global $conf, $langs, $hookmanager;
$langs->load('users');
@@ -440,6 +440,9 @@ class FormOther
$out.=$comboenhancement;
}
}
+
+ $reshook = $hookmanager->executeHooks('addSQLWhereFilterOnSelectSalesRep', array(), $this, $action);
+
// Select each sales and print them in a select input
$out.='