diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php
index 4b15f04faa0..af2a2218410 100644
--- a/htdocs/fourn/commande/dispatch.php
+++ b/htdocs/fourn/commande/dispatch.php
@@ -491,11 +491,35 @@ if ($id > 0 || ! empty($ref)) {
$sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, SUM(l.qty) as qty,";
$sql .= " p.ref, p.label, p.tobatch, p.fk_default_warehouse";
+
+ // Enable hooks to alter the SQL query (SELECT)
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks(
+ 'printFieldListSelect',
+ $parameters,
+ $object,
+ $action
+ );
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ $sql .= $hookmanager->resPrint;
+
$sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseurdet as l";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON l.fk_product=p.rowid";
$sql .= " WHERE l.fk_commande = " . $object->id;
if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
$sql .= " AND l.product_type = 0";
+
+ // Enable hooks to alter the SQL query (WHERE)
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks(
+ 'printFieldListWhere',
+ $parameters,
+ $object,
+ $action
+ );
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ $sql .= $hookmanager->resPrint;
+
$sql .= " GROUP BY p.ref, p.label, p.tobatch, l.rowid, l.fk_product, l.subprice, l.remise_percent, p.fk_default_warehouse"; // Calculation of amount dispatched is done per fk_product so we must group by fk_product
$sql .= " ORDER BY p.ref, p.label";
@@ -526,6 +550,18 @@ if ($id > 0 || ! empty($ref)) {
print '
' . $langs->trans("QtyToDispatchShort") . ' | ';
print ' | ';
print '' . $langs->trans("Warehouse") . ' | ';
+
+ // Enable hooks to append additional columns
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks(
+ 'printFieldListTitle',
+ $parameters,
+ $object,
+ $action
+ );
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ print $hookmanager->resPrint;
+
print "\n";
}
@@ -608,6 +644,23 @@ if ($id > 0 || ! empty($ref)) {
//print img_picto($langs->trans('AddDispatchBatchLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');
print ''; // Dispatch column
print ' | '; // Warehouse column
+
+ // Enable hooks to append additional columns
+ $parameters = array(
+ 'is_information_row' => true, // allows hook to distinguish between the
+ // rows with information and the rows with
+ // dispatch form input
+ 'objp' => $objp
+ );
+ $reshook = $hookmanager->executeHooks(
+ 'printFieldListValue',
+ $parameters,
+ $object,
+ $action
+ );
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ print $hookmanager->resPrint;
+
print '';
print '';
@@ -648,6 +701,23 @@ if ($id > 0 || ! empty($ref)) {
//print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');
print ''; // Dispatch column
print ' | '; // Warehouse column
+
+ // Enable hooks to append additional columns
+ $parameters = array(
+ 'is_information_row' => true, // allows hook to distinguish between the
+ // rows with information and the rows with
+ // dispatch form input
+ 'objp' => $objp
+ );
+ $reshook = $hookmanager->executeHooks(
+ 'printFieldListValue',
+ $parameters,
+ $object,
+ $action
+ );
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ print $hookmanager->resPrint;
+
print '
';
print '';
@@ -699,6 +769,19 @@ if ($id > 0 || ! empty($ref)) {
}
print "\n";
+ // Enable hooks to append additional columns
+ $parameters = array(
+ 'is_information_row' => false // this is a dispatch form row
+ );
+ $reshook = $hookmanager->executeHooks(
+ 'printFieldListValue',
+ $parameters,
+ $object,
+ $action
+ );
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ print $hookmanager->resPrint;
+
print "
\n";
}
}
diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php
index 90ff76231d1..acfeb87fca9 100644
--- a/htdocs/fourn/product/list.php
+++ b/htdocs/fourn/product/list.php
@@ -142,6 +142,7 @@ $reshook = $hookmanager->executeHooks(
$object,
$action
);
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
$sql .= $hookmanager->resPrint;
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
@@ -180,6 +181,7 @@ $reshook = $hookmanager->executeHooks(
'printFieldListWhere',
$parameters
);
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
$sql .= $hookmanager->resPrint;
$sql .= $db->order($sortfield,$sortorder);
@@ -275,7 +277,8 @@ if ($resql)
$object,
$action
);
- if (!empty($reshook)) print $hookmanager->resPrint;
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ print $hookmanager->resPrint;
print '';
$searchpicto=$form->showFilterButtons();
@@ -301,7 +304,8 @@ if ($resql)
$object,
$action
);
- if (!empty($reshook)) print $hookmanager->resPrint;
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ print $hookmanager->resPrint;
print_liste_field_titre('',$_SERVER["PHP_SELF"]);
print "\n";
@@ -345,7 +349,8 @@ if ($resql)
$objp,
$action
);
- if (!empty($reshook)) print $hookmanager->resPrint;
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ print $hookmanager->resPrint;
print ' | | ';