diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index 74ba5a9d4c9..2afa630860b 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -76,7 +76,7 @@ class box_clients extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $conf; + global $user, $langs, $hookmanager; $langs->load("boxes"); $this->max = $max; @@ -100,9 +100,15 @@ class box_clients extends ModeleBoxes if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } - if ($user->socid) { - $sql .= " AND s.rowid = ".((int) $user->socid); + // Add where from hooks + $parameters = array('socid' => $user->socid, 'boxcode' => $this->boxcode); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $thirdpartystatic); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + if ($user->socid > 0) { + $sql .= " AND s.rowid = ".((int) $user->socid); + } } + $sql .= $hookmanager->resPrint; $sql .= " ORDER BY s.tms DESC"; $sql .= $this->db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 0d774faf569..f9938a02aa1 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -74,11 +74,15 @@ class box_contacts extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $conf; + global $user, $langs, $conf, $hookmanager; + $langs->load("boxes"); $this->max = $max; + $contactstatic = new Contact($this->db); + $societestatic = new Societe($this->db); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedContacts", $max)); if ($user->rights->societe->lire && $user->rights->societe->contact->lire) { @@ -110,9 +114,15 @@ class box_contacts extends ModeleBoxes if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } - if ($user->socid) { - $sql .= " AND sp.fk_soc = ".((int) $user->socid); + // Add where from hooks + $parameters = array('socid' => $user->socid, 'boxcode' => $this->boxcode); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $contactstatic); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + if ($user->socid > 0) { + $sql .= " AND sp.fk_soc = ".((int) $user->socid); + } } + $sql .= $hookmanager->resPrint; $sql .= " ORDER BY sp.tms DESC"; $sql .= $this->db->plimit($max, 0); @@ -120,9 +130,6 @@ class box_contacts extends ModeleBoxes if ($result) { $num = $this->db->num_rows($result); - $contactstatic = new Contact($this->db); - $societestatic = new Societe($this->db); - $line = 0; while ($line < $num) { $objp = $this->db->fetch_object($result); diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index 4f297135b26..3cb1f570a30 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -71,7 +71,7 @@ class box_fournisseurs extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs; + global $conf, $user, $langs, $hookmanager; $langs->load("boxes"); $this->max = $max; @@ -95,9 +95,15 @@ class box_fournisseurs extends ModeleBoxes if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } - if ($user->socid) { - $sql .= " AND s.rowid = ".((int) $user->socid); + // Add where from hooks + $parameters = array('socid' => $user->socid, 'boxcode' => $this->boxcode); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $thirdpartystatic); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + if ($user->socid > 0) { + $sql .= " AND s.rowid = ".((int) $user->socid); + } } + $sql .= $hookmanager->resPrint; $sql .= " ORDER BY s.tms DESC "; $sql .= $this->db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 9a0c76503d0..8ea14ebc8d5 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -103,8 +103,8 @@ class box_produits extends ModeleBoxes } // Add where from hooks if (is_object($hookmanager)) { - $parameters = array('boxproductlist'=>1); - $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('boxproductlist' => 1, 'boxcode' => $this->boxcode); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $productstatic); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; } $sql .= $this->db->order('p.datec', 'DESC'); diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index e074cb76198..72b1957b287 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -103,8 +103,8 @@ class box_produits_alerte_stock extends ModeleBoxes } // Add where from hooks if (is_object($hookmanager)) { - $parameters = array('boxproductalertstocklist'=>1); - $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('boxproductalertstocklist' => 1, 'boxcode' => $this->boxcode); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $productstatic); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; } $sql .= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.barcode, p.seuil_stock_alerte, p.entity,"; diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index a46713a3206..3bf69f91fe0 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -78,7 +78,7 @@ class box_prospect extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $conf; + global $user, $langs, $hookmanager; $this->max = $max; @@ -101,9 +101,15 @@ class box_prospect extends ModeleBoxes if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } - if ($user->socid) { - $sql .= " AND s.rowid = ".((int) $user->socid); + // Add where from hooks + $parameters = array('socid' => $user->socid, 'boxcode' => $this->boxcode); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $thirdpartystatic); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + if ($user->socid > 0) { + $sql .= " AND s.rowid = ".((int) $user->socid); + } } + $sql .= $hookmanager->resPrint; $sql .= " ORDER BY s.tms DESC"; $sql .= $this->db->plimit($max, 0);