Merge pull request #20379 from hregis/new_add_kooks_in_thirdparty_index

NEW add hooks in thirdparty index page
This commit is contained in:
Laurent Destailleur 2022-03-16 20:14:42 +01:00 committed by GitHub
commit 89aab0e9d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);