Fix missing printFieldListWhere hook

This commit is contained in:
Laurent Destailleur 2017-06-09 09:45:22 +02:00
parent d326f161ef
commit d6ba16d357
2 changed files with 34 additions and 23 deletions

View File

@ -42,6 +42,9 @@ else $result=restrictedArea($user,'produit|service');
$langs->load("products"); $langs->load("products");
$langs->load("stocks"); $langs->load("stocks");
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
$hookmanager->initHooks(array('productindex'));
$product_static = new Product($db); $product_static = new Product($db);
@ -117,6 +120,10 @@ $sql = "SELECT COUNT(p.rowid) as total, p.fk_product_type, p.tosell, p.tobuy";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p";
$sql.= ' WHERE p.entity IN ('.getEntity($product_static->element, 1).')'; $sql.= ' WHERE p.entity IN ('.getEntity($product_static->element, 1).')';
$sql.= " GROUP BY p.fk_product_type, p.tosell, p.tobuy"; $sql.= " GROUP BY p.fk_product_type, p.tosell, p.tobuy";
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$result = $db->query($sql); $result = $db->query($sql);
while ($objp = $db->fetch_object($result)) while ($objp = $db->fetch_object($result))
{ {
@ -246,6 +253,10 @@ $sql.= " p.tms as datem";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p";
$sql.= " WHERE p.entity IN (".getEntity($product_static->element, 1).")"; $sql.= " WHERE p.entity IN (".getEntity($product_static->element, 1).")";
if ($type != '') $sql.= " AND p.fk_product_type = ".$type; if ($type != '') $sql.= " AND p.fk_product_type = ".$type;
// Add where from hooks
$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.tms","DESC"); $sql.= $db->order("p.tms","DESC");
$sql.= $db->plimit($max,0); $sql.= $db->plimit($max,0);

View File

@ -78,7 +78,7 @@ $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'productser
if ((string) $type == '1') { $contextpage='servicelist'; if ($search_type=='') $search_type='1'; } if ((string) $type == '1') { $contextpage='servicelist'; if ($search_type=='') $search_type='1'; }
if ((string) $type == '0') { $contextpage='productlist'; if ($search_type=='') $search_type='0'; } if ((string) $type == '0') { $contextpage='productlist'; if ($search_type=='') $search_type='0'; }
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
$hookmanager->initHooks(array($contextpage)); $hookmanager->initHooks(array($contextpage));
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$form=new Form($db); $form=new Form($db);