FIX wrong multicompany filter (#34714)

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
Regis Houssin 2025-07-15 14:55:09 +02:00 committed by ldestailleur
parent b03f30c7e2
commit e5f5df3820

View file

@ -105,8 +105,7 @@ $pageprev = $page - 1;
$pagenext = $page + 1;
$search_all = GETPOST('search_all', 'alphanohtml');
$search_entity = ($user->entity > 0 ? $user->entity : GETPOSTINT('search_entity'));
$search_entity = GETPOSTINT('search_entity');
$search_ref = GETPOST("search_ref", 'alpha');
$search_label = GETPOST("search_label", 'alpha');
$search_societe = GETPOST("search_societe", 'alpha');
@ -590,11 +589,10 @@ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user AS u ON p.fk_user_creat = u.rowid';
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
if ($search_entity > 0) {
$sql .= " WHERE p.entity = ".((int) $search_entity);
} else {
$sql .= " WHERE p.entity IN (".getEntity('project', (GETPOSTINT('search_current_entity') ? 0 : 1)).')';
$sql .= " WHERE p.entity IN (".getEntity('project').')';
}
if (!$user->hasRight('projet', 'all', 'lire')) {
$sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users