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 16ed559814d..acfeb87fca9 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -75,7 +75,12 @@ if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } $parameters=array(); -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +$reshook=$hookmanager->executeHooks( + 'doActions', + $parameters, + $object, + $action +); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -128,6 +133,18 @@ $massactionbutton=$form->selectMassAction('', $arrayofmassactions); $sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type, p.entity,"; $sql.= " ppf.fk_soc, ppf.ref_fourn, ppf.price as price, ppf.quantity as qty, ppf.unitprice,"; $sql.= " s.rowid as socid, s.nom as name"; + +// Add fields to SELECT from hooks +$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."product as p"; if ($catid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as ppf ON p.rowid = ppf.fk_product"; @@ -158,6 +175,15 @@ if ($fourn_id > 0) $sql .= " AND ppf.fk_soc = ".$fourn_id; } +// Add WHERE filters from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks( + 'printFieldListWhere', + $parameters +); +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +$sql .= $hookmanager->resPrint; + $sql .= $db->order($sortfield,$sortorder); // Count total nb of records without orderby and limit @@ -242,6 +268,18 @@ if ($resql) print ''; print ''; print ''; + + // add filters from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks( + 'printFieldPreListTitle', + $parameters, + $object, + $action + ); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + print $hookmanager->resPrint; + print ''; $searchpicto=$form->showFilterButtons(); print $searchpicto; @@ -257,6 +295,17 @@ if ($resql) print_liste_field_titre("BuyingPrice",$_SERVER["PHP_SELF"], "ppf.price",$param,"",'align="right"',$sortfield,$sortorder); print_liste_field_titre("QtyMin",$_SERVER["PHP_SELF"], "ppf.quantity",$param,"",'align="right"',$sortfield,$sortorder); print_liste_field_titre("UnitPrice",$_SERVER["PHP_SELF"], "ppf.unitprice",$param,"",'align="right"',$sortfield,$sortorder); + + // add header cells from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks( + 'printFieldListTitle', + $parameters, + $object, + $action + ); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + print $hookmanager->resPrint; print_liste_field_titre('',$_SERVER["PHP_SELF"]); print "\n"; @@ -292,6 +341,17 @@ if ($resql) print ''.(isset($objp->unitprice) ? price($objp->unitprice) : '').''; + // add additional columns from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks( + 'printFieldListValue', + $parameters, + $objp, + $action + ); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + print $hookmanager->resPrint; + print ''; print "\n";