NEW shipment with warhouse in cache

This commit is contained in:
VESSILLER 2025-02-07 17:15:46 +01:00
parent c316d1e5f3
commit 846e3aa712

View File

@ -2409,6 +2409,7 @@ if ($action == 'create') {
print '<tbody>';
// Loop on each product to send/sent
$conf->cache['warehouse'] = array();
for ($i = 0; $i < $num_prod; $i++) {
$parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => !empty($editColspan) ? $editColspan : 0, 'outputlangs' => $outputlangs);
$reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action);
@ -2629,16 +2630,28 @@ if ($action == 'create') {
if ($lines[$i]->product_type == Product::TYPE_SERVICE && getDolGlobalString('SHIPMENT_SUPPORTS_SERVICES')) {
print '<span class="opacitymedium">('.$langs->trans("Service").')</span>';
} elseif ($lines[$i]->entrepot_id > 0) {
$entrepot = new Entrepot($db);
$entrepot->fetch($lines[$i]->entrepot_id);
print $entrepot->getNomUrl(1);
$warehouse_id = $lines[$i]->entrepot_id;
if (!isset($conf->cache['warehouse'][$warehouse_id])) {
$warehouse = new Entrepot($db);
$warehouse->fetch($warehouse_id);
$conf->cache['warehouse'][$warehouse_id] = $warehouse;
} else {
$warehouse = $conf->cache['warehouse'][$warehouse_id];
}
print $warehouse->getNomUrl(1);
} elseif (count($lines[$i]->details_entrepot) > 1) {
$detail = '';
foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
if ($detail_entrepot->entrepot_id > 0) {
$entrepot = new Entrepot($db);
$entrepot->fetch($detail_entrepot->entrepot_id);
$detail .= $langs->trans("DetailWarehouseFormat", $entrepot->label, $detail_entrepot->qty_shipped).'<br>';
$warehouse_id = $detail_entrepot->entrepot_id;
if ($warehouse_id > 0) {
if (!isset($conf->cache['warehouse'][$warehouse_id])) {
$warehouse = new Entrepot($db);
$warehouse->fetch($warehouse_id);
$conf->cache['warehouse'][$warehouse_id] = $warehouse;
} else {
$warehouse = $conf->cache['warehouse'][$warehouse_id];
}
$detail .= $langs->trans("DetailWarehouseFormat", $warehouse->label, $detail_entrepot->qty_shipped).'<br>';
}
}
print $form->textwithtooltip(img_picto('', 'object_stock').' '.$langs->trans("DetailWarehouseNumber"), $detail);