Merge pull request #24150 from OPEN-DSI/develop_new_hook_loadlotstock
NEW - Add hook in loadLotStock() in html.formproduct.class.php file
This commit is contained in:
commit
173cdc4c4c
@ -865,6 +865,28 @@ class FormProduct
|
||||
// clear cache
|
||||
$this->cache_lot = array();
|
||||
$productIdList = implode(',', $productIdArray);
|
||||
|
||||
$batch_count = 0;
|
||||
global $hookmanager;
|
||||
if (empty($hookmanager)) {
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
|
||||
$hookmanager = new HookManager($this->db);
|
||||
}
|
||||
$hookmanager->initHooks(array('productdao'));
|
||||
$parameters = array('productIdList' => $productIdList);
|
||||
$reshook = $hookmanager->executeHooks('loadLotStock', $parameters, $this);
|
||||
if ($reshook < 0) {
|
||||
$this->error = $hookmanager->error;
|
||||
return -1;
|
||||
}
|
||||
if (!empty($hookmanager->resArray['batch_list']) && is_array($hookmanager->resArray['batch_list'])) {
|
||||
$this->cache_lot = $hookmanager->resArray['batch_list'];
|
||||
$batch_count = (int) $hookmanager->resArray['batch_count'];
|
||||
}
|
||||
if ($reshook > 0) {
|
||||
return $batch_count;
|
||||
}
|
||||
|
||||
$sql = "SELECT pb.batch, pb.rowid, ps.fk_entrepot, pb.qty, e.ref as label, ps.fk_product";
|
||||
$sql .= " FROM ".$this->db->prefix()."product_batch as pb";
|
||||
$sql .= " LEFT JOIN ".$this->db->prefix()."product_stock as ps on ps.rowid = pb.fk_product_stock";
|
||||
@ -889,7 +911,7 @@ class FormProduct
|
||||
$i++;
|
||||
}
|
||||
|
||||
return $num;
|
||||
return $batch_count + $num;
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
return -1;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user