From 629028a435b2273812be05d686abee6be4fcd476 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 16 Mar 2022 16:27:25 +0100 Subject: [PATCH 1/2] NEW add hooks in thirdparty index page --- htdocs/societe/index.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index 422ec5c8552..49d45b682c5 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('printFieldListWhereForStatisticArea', $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('printFieldListWhereForLatestModified', $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); From 7437be35789e820e8e097ee8456ca979cf1e7d8a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 16 Mar 2022 19:22:48 +0100 Subject: [PATCH 2/2] FIX wrong hooks name --- htdocs/societe/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index 49d45b682c5..d3960ee784b 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -106,7 +106,7 @@ if (empty($user->rights->fournisseur->lire)) { } // Add where from hooks $parameters = array('socid' => $socid); -$reshook = $hookmanager->executeHooks('printFieldListWhereForStatisticArea', $parameters); // Note that $action and $object may have been modified by hook +$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); @@ -295,7 +295,7 @@ if (empty($user->rights->fournisseur->lire)) { } // Add where from hooks $parameters = array('socid' => $socid); -$reshook = $hookmanager->executeHooks('printFieldListWhereForLatestModified', $parameters); // Note that $action and $object may have been modified by hook +$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);