diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index 422ec5c8552..d3960ee784b 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -101,12 +101,18 @@ $sql .= ' WHERE s.entity IN ('.getEntity('societe').')'; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } -if ($socid > 0) { - $sql .= " AND s.rowid = ".((int) $socid); -} if (empty($user->rights->fournisseur->lire)) { $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible } +// Add where from hooks +$parameters = array('socid' => $socid); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +if (empty($reshook)) { + if ($socid > 0) { + $sql .= " AND s.rowid = ".((int) $socid); + } +} +$sql .= $hookmanager->resPrint; //print $sql; $result = $db->query($sql); if ($result) { @@ -284,12 +290,18 @@ $sql .= ' WHERE s.entity IN ('.getEntity('societe').')'; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } -if ($socid) { - $sql .= " AND s.rowid = ".((int) $socid); -} if (empty($user->rights->fournisseur->lire)) { $sql .= " AND (s.fournisseur != 1 OR s.client != 0)"; } +// Add where from hooks +$parameters = array('socid' => $socid); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +if (empty($reshook)) { + if ($socid > 0) { + $sql .= " AND s.rowid = ".((int) $socid); + } +} +$sql .= $hookmanager->resPrint; $sql .= $db->order("s.tms", "DESC"); $sql .= $db->plimit($max, 0);