NEW Add Hook for adapting virtual stock in replenish screen (#37290)
* Add Hook for adapting virtual stock in replenish screen Currently it is only possible to hook in the loadvirtualstock hook to adapt the virtual stock by external modules. The newer version of the replenish screen doesn't use this hook anymore (by loading stock from product object) as it now uses faster sql queries. Therefore the external module cannot adapt this area and there is an missmatch of the view in replenish.php and the stock tab of the product. * fix phan warning
This commit is contained in:
parent
0b34a66fe6
commit
00a64df8e4
1 changed files with 10 additions and 3 deletions
|
|
@ -517,16 +517,23 @@ if ($usevirtualstock) {
|
|||
$sqlProductionToProduce = '0';
|
||||
}
|
||||
|
||||
$parameters = array();
|
||||
$sqlHookVirtualStock = "0";
|
||||
$reshook = $hookmanager->executeHooks('printFieldListHavingVirtualStock', $parameters); // Note that $action and $object may have been modified by hook
|
||||
if (!empty($hookmanager->resPrint)) {
|
||||
$sqlHookVirtualStock = $hookmanager->resPrint;
|
||||
}
|
||||
|
||||
$sql .= ' HAVING (';
|
||||
$sql .= " (" . $sqldesiredtock . " >= 0 AND (" . $sqldesiredtock . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ')';
|
||||
$sql .= " - (" . $sqlCommandesCli . " - " . $sqlExpeditionsCli . ") + (" . $sqlCommandesFourn . " - " . $sqlReceptionFourn . ") + (" . $sqlProductionToProduce . " - " . $sqlProductionToConsume . ")))";
|
||||
$sql .= " - (" . $sqlCommandesCli . " - " . $sqlExpeditionsCli . ") + (" . $sqlCommandesFourn . " - " . $sqlReceptionFourn . ") + (" . $sqlProductionToProduce . " - " . $sqlProductionToConsume . ") + ".$sqlHookVirtualStock."))";
|
||||
$sql .= ' OR';
|
||||
if ($includeproductswithoutdesiredqty == 'on') {
|
||||
$sql .= " ((" . $sqlalertstock . " >= 0 OR " . $sqlalertstock . " IS NULL) AND (" . $db->ifsql($sqlalertstock . " IS NULL", "0", $sqlalertstock) . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ")";
|
||||
} else {
|
||||
$sql .= " (" . $sqlalertstock . " >= 0 AND (" . $sqlalertstock . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ')';
|
||||
}
|
||||
$sql .= " - (" . $sqlCommandesCli . " - " . $sqlExpeditionsCli . ") + (" . $sqlCommandesFourn . " - " . $sqlReceptionFourn . ") + (" . $sqlProductionToProduce . " - " . $sqlProductionToConsume . ")))";
|
||||
$sql .= " - (" . $sqlCommandesCli . " - " . $sqlExpeditionsCli . ") + (" . $sqlCommandesFourn . " - " . $sqlReceptionFourn . ") + (" . $sqlProductionToProduce . " - " . $sqlProductionToConsume . ") + ".$sqlHookVirtualStock."))";
|
||||
$sql .= ")";
|
||||
if (getDolGlobalString('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE') && $fk_entrepot > 0) {
|
||||
$sql .= " AND (";
|
||||
|
|
@ -540,7 +547,7 @@ if ($usevirtualstock) {
|
|||
} else {
|
||||
$sql .= $sqlalertstock . " >= 0 AND (" . $sqlalertstock . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ")";
|
||||
}
|
||||
$sql .= " - (" . $sqlCommandesCli . " - " . $sqlExpeditionsCli . ") + (" . $sqlCommandesFourn . " - " . $sqlReceptionFourn . ") + (" . $sqlProductionToProduce . " - " . $sqlProductionToConsume . "))";
|
||||
$sql .= " - (" . $sqlCommandesCli . " - " . $sqlExpeditionsCli . ") + (" . $sqlCommandesFourn . " - " . $sqlReceptionFourn . ") + (" . $sqlProductionToProduce . " - " . $sqlProductionToConsume . ") + ".$sqlHookVirtualStock.")";
|
||||
$sql .= ")";
|
||||
$alertchecked = 'checked';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue