Merge pull request #11512 from atm-florianm/9.0_FIX_missing-hooks-in-supplier-product-list-and-supplier-product-dispatch

9.0 fix missing hooks in supplier product list and supplier product dispatch
This commit is contained in:
Laurent Destailleur 2019-07-16 13:27:53 +03:00 committed by GitHub
commit 617d10bf2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 144 additions and 1 deletions

View File

@ -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 '<td align="right">' . $langs->trans("QtyToDispatchShort") . '</td>';
print '<td width="32"></td>';
print '<td align="right">' . $langs->trans("Warehouse") . '</td>';
// 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 "</tr>\n";
}
@ -608,6 +644,23 @@ if ($id > 0 || ! empty($ref)) {
//print img_picto($langs->trans('AddDispatchBatchLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');
print '</td>'; // Dispatch column
print '<td></td>'; // 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 '</tr>';
print '<tr class="oddeven" name="' . $type . $suffix . '">';
@ -648,6 +701,23 @@ if ($id > 0 || ! empty($ref)) {
//print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');
print '</td>'; // Dispatch column
print '<td></td>'; // 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 '</tr>';
print '<tr class="oddeven" name="' . $type . $suffix . '">';
@ -699,6 +769,19 @@ if ($id > 0 || ! empty($ref)) {
}
print "</td>\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 "</tr>\n";
}
}

View File

@ -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 '<td></td>';
print '<td></td>';
print '<td></td>';
// 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 '<td class="liste_titre" align="right">';
$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 "</tr>\n";
@ -292,6 +341,17 @@ if ($resql)
print '<td align="right">'.(isset($objp->unitprice) ? price($objp->unitprice) : '').'</td>';
// 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 '<td align="right"></td>';
print "</tr>\n";