diff --git a/htdocs/product/index.php b/htdocs/product/index.php
index 74a974804ff..56508616edd 100644
--- a/htdocs/product/index.php
+++ b/htdocs/product/index.php
@@ -42,6 +42,9 @@ else $result=restrictedArea($user,'produit|service');
$langs->load("products");
$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);
@@ -80,7 +83,7 @@ print '
';
/*
* Search Area of product/service
*/
-
+
// Search contract
if ((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && ($user->rights->produit->lire || $user->rights->service->lire))
{
@@ -102,7 +105,7 @@ if (count($listofsearchfields))
print '';
$i++;
}
- print '';
+ print '';
print '';
print '
';
}
@@ -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.= ' WHERE p.entity IN ('.getEntity($product_static->element, 1).')';
$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);
while ($objp = $db->fetch_object($result))
{
@@ -246,6 +253,10 @@ $sql.= " p.tms as datem";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
$sql.= " WHERE p.entity IN (".getEntity($product_static->element, 1).")";
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->plimit($max,0);
@@ -419,7 +430,7 @@ function activitytrim($product_type)
$i = 0;
$var=true;
-
+
while ($i < $num)
{
$objp = $db->fetch_object($result);
diff --git a/htdocs/product/list.php b/htdocs/product/list.php
index 1aec109474e..043327920db 100644
--- a/htdocs/product/list.php
+++ b/htdocs/product/list.php
@@ -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 == '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));
$extrafields = new ExtraFields($db);
$form=new Form($db);
@@ -163,7 +163,7 @@ $arrayfields=array(
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
- foreach($extrafields->attribute_label as $key => $val)
+ foreach($extrafields->attribute_label as $key => $val)
{
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key]);
}
@@ -284,7 +284,7 @@ else
$typ=$extrafields->attribute_type[$tmpkey];
$mode=0;
if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric
- if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit)))
+ if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit)))
{
$sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
}
@@ -369,8 +369,8 @@ else
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
- }
-
+ }
+
print '