Fix several problem with hook printFieldListWhere
This commit is contained in:
parent
bec6ad9fb3
commit
02781b41ca
@ -53,7 +53,7 @@ class box_produits extends ModeleBoxes
|
|||||||
*/
|
*/
|
||||||
function loadBox($max=5)
|
function loadBox($max=5)
|
||||||
{
|
{
|
||||||
global $user, $langs, $db, $conf;
|
global $user, $langs, $db, $conf, $hookmanager;
|
||||||
|
|
||||||
$this->max=$max;
|
$this->max=$max;
|
||||||
|
|
||||||
@ -69,6 +69,13 @@ class box_produits extends ModeleBoxes
|
|||||||
$sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element, 1).')';
|
$sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element, 1).')';
|
||||||
if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0';
|
if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0';
|
||||||
if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1';
|
if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1';
|
||||||
|
// Add where from hooks
|
||||||
|
if (is_object($hookmanager))
|
||||||
|
{
|
||||||
|
$parameters=array();
|
||||||
|
$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
$sql.=$hookmanager->resPrint;
|
||||||
|
}
|
||||||
$sql.= $db->order('p.datec', 'DESC');
|
$sql.= $db->order('p.datec', 'DESC');
|
||||||
$sql.= $db->plimit($max, 0);
|
$sql.= $db->plimit($max, 0);
|
||||||
|
|
||||||
|
|||||||
@ -55,7 +55,7 @@ class box_produits_alerte_stock extends ModeleBoxes
|
|||||||
*/
|
*/
|
||||||
function loadBox($max=5)
|
function loadBox($max=5)
|
||||||
{
|
{
|
||||||
global $user, $langs, $db, $conf;
|
global $user, $langs, $db, $conf, $hookmanager;
|
||||||
|
|
||||||
$this->max=$max;
|
$this->max=$max;
|
||||||
|
|
||||||
@ -74,7 +74,14 @@ class box_produits_alerte_stock extends ModeleBoxes
|
|||||||
$sql.= " AND p.tosell = 1 AND p.seuil_stock_alerte > 0";
|
$sql.= " AND p.tosell = 1 AND p.seuil_stock_alerte > 0";
|
||||||
if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0';
|
if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0';
|
||||||
if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1';
|
if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1';
|
||||||
$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.seuil_stock_alerte, p.entity";
|
// Add where from hooks
|
||||||
|
if (is_object($hookmanager))
|
||||||
|
{
|
||||||
|
$parameters=array();
|
||||||
|
$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // 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.seuil_stock_alerte, p.entity";
|
||||||
$sql.= " HAVING SUM(".$db->ifsql("s.reel IS NULL","0","s.reel").") < p.seuil_stock_alerte";
|
$sql.= " HAVING SUM(".$db->ifsql("s.reel IS NULL","0","s.reel").") < p.seuil_stock_alerte";
|
||||||
$sql.= $db->order('p.seuil_stock_alerte', 'DESC');
|
$sql.= $db->order('p.seuil_stock_alerte', 'DESC');
|
||||||
$sql.= $db->plimit($max, 0);
|
$sql.= $db->plimit($max, 0);
|
||||||
|
|||||||
@ -4017,7 +4017,7 @@ class Product extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function load_state_board()
|
function load_state_board()
|
||||||
{
|
{
|
||||||
global $conf, $user;
|
global $conf, $user, $hookmanager;
|
||||||
|
|
||||||
$this->nb=array();
|
$this->nb=array();
|
||||||
|
|
||||||
@ -4025,6 +4025,13 @@ class Product extends CommonObject
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
|
||||||
$sql.= ' WHERE p.entity IN ('.getEntity($this->element, 1).')';
|
$sql.= ' WHERE p.entity IN ('.getEntity($this->element, 1).')';
|
||||||
$sql.= " AND p.fk_product_type <> 1";
|
$sql.= " AND p.fk_product_type <> 1";
|
||||||
|
// Add where from hooks
|
||||||
|
if (is_object($hookmanager))
|
||||||
|
{
|
||||||
|
$parameters=array();
|
||||||
|
$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
$sql.=$hookmanager->resPrint;
|
||||||
|
}
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
|
|||||||
@ -56,7 +56,7 @@ class Service extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function load_state_board()
|
function load_state_board()
|
||||||
{
|
{
|
||||||
global $conf, $user;
|
global $conf, $user, $hookmanager;
|
||||||
|
|
||||||
$this->nb=array();
|
$this->nb=array();
|
||||||
|
|
||||||
@ -64,6 +64,13 @@ class Service extends CommonObject
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
|
||||||
$sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')';
|
$sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')';
|
||||||
$sql.= " AND p.fk_product_type = 1";
|
$sql.= " AND p.fk_product_type = 1";
|
||||||
|
// Add where from hooks
|
||||||
|
if (is_object($hookmanager))
|
||||||
|
{
|
||||||
|
$parameters=array();
|
||||||
|
$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
$sql.=$hookmanager->resPrint;
|
||||||
|
}
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user