|
@@ -1995,83 +1995,79 @@ if ($resql) {
|
|
|
print '<td class="center">';
|
|
|
if (!empty($show_shippable_command) && !empty($conf->stock->enabled)) {
|
|
|
if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) {
|
|
|
- $generic_commande->getLinesArray(); // Load array ->lines
|
|
|
$generic_commande->loadExpeditions(); // Load array ->expeditions
|
|
|
|
|
|
- $numlines = count($generic_commande->lines); // Loop on each line of order
|
|
|
- for ($lig = 0; $lig < $numlines; $lig++) {
|
|
|
- if (isset($generic_commande->expeditions[$generic_commande->lines[$lig]->id])) {
|
|
|
- $reliquat = $generic_commande->lines[$lig]->qty - $generic_commande->expeditions[$generic_commande->lines[$lig]->id];
|
|
|
+ if (isset($generic_commande->expeditions[$obj->rowid])) {
|
|
|
+ $reliquat = $obj->qty - $generic_commande->expeditions[$obj->rowid];
|
|
|
+ } else {
|
|
|
+ $reliquat = $obj->qty;
|
|
|
+ }
|
|
|
+ if ($obj->product_type == 0 && $obj->fk_product > 0) { // If line is a product and not a service
|
|
|
+ $nbprod++; // order contains real products
|
|
|
+ $generic_product->id = $obj->fk_product;
|
|
|
+
|
|
|
+ // Get local and virtual stock and store it into cache
|
|
|
+ if (empty($productstat_cache[$obj->fk_product])) {
|
|
|
+ $generic_product->load_stock('nobatch'); // ->load_virtual_stock() is already included into load_stock()
|
|
|
+ $productstat_cache[$obj->fk_product]['stock_reel'] = $generic_product->stock_reel;
|
|
|
+ $productstat_cachevirtual[$obj->fk_product]['stock_reel'] = $generic_product->stock_theorique;
|
|
|
} else {
|
|
|
- $reliquat = $generic_commande->lines[$lig]->qty;
|
|
|
+ $generic_product->stock_reel = $productstat_cache[$obj->fk_product]['stock_reel'];
|
|
|
+ $generic_product->stock_theorique = $productstat_cachevirtual[$obj->fk_product]['stock_reel'] = $generic_product->stock_theorique;
|
|
|
}
|
|
|
- if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) { // If line is a product and not a service
|
|
|
- $nbprod++; // order contains real products
|
|
|
- $generic_product->id = $generic_commande->lines[$lig]->fk_product;
|
|
|
-
|
|
|
- // Get local and virtual stock and store it into cache
|
|
|
- if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) {
|
|
|
- $generic_product->load_stock('nobatch'); // ->load_virtual_stock() is already included into load_stock()
|
|
|
- $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_reel;
|
|
|
- $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique;
|
|
|
- } else {
|
|
|
- $generic_product->stock_reel = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'];
|
|
|
- $generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique;
|
|
|
- }
|
|
|
|
|
|
- if ($reliquat > $generic_product->stock_reel) {
|
|
|
- $notshippable++;
|
|
|
- }
|
|
|
- if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) { // Default code. Default should be this case.
|
|
|
- $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->product_ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20);
|
|
|
- $text_info .= ' - '.$langs->trans("Stock").': <span class="'.($generic_product->stock_reel > 0 ? 'ok' : 'error').'">'.$generic_product->stock_reel.'</span>';
|
|
|
- $text_info .= ' - '.$langs->trans("VirtualStock").': <span class="'.($generic_product->stock_theorique > 0 ? 'ok' : 'error').'">'.$generic_product->stock_theorique.'</span>';
|
|
|
- $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' <span class="opacitymedium">('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')</span>' : '');
|
|
|
- $text_info .= '<br>';
|
|
|
- } else { // BUGGED CODE.
|
|
|
- // DOES NOT TAKE INTO ACCOUNT MANUFACTURING. THIS CODE SHOULD BE USELESS. PREVIOUS CODE SEEMS COMPLETE.
|
|
|
- // COUNT STOCK WHEN WE SHOULD ALREADY HAVE VALUE
|
|
|
- // Detailed virtual stock, looks bugged, uncomplete and need heavy load.
|
|
|
- // stock order and stock order_supplier
|
|
|
- $stock_order = 0;
|
|
|
- $stock_order_supplier = 0;
|
|
|
- if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { // What about other options ?
|
|
|
- if (!empty($conf->commande->enabled)) {
|
|
|
- if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'])) {
|
|
|
- $generic_product->load_stats_commande(0, '1,2');
|
|
|
- $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty'];
|
|
|
- } else {
|
|
|
- $generic_product->stats_commande['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'];
|
|
|
- }
|
|
|
- $stock_order = $generic_product->stats_commande['qty'];
|
|
|
- }
|
|
|
- if (isModEnabled('supplier_order')) {
|
|
|
- if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'])) {
|
|
|
- $generic_product->load_stats_commande_fournisseur(0, '3');
|
|
|
- $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty'];
|
|
|
- } else {
|
|
|
- $generic_product->stats_commande_fournisseur['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'];
|
|
|
- }
|
|
|
- $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty'];
|
|
|
+ if ($reliquat > $generic_product->stock_reel) {
|
|
|
+ $notshippable++;
|
|
|
+ }
|
|
|
+ if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) { // Default code. Default should be this case.
|
|
|
+ $text_info .= $reliquat.' x '.$obj->product_ref.' '.dol_trunc($obj->product_label, 20);
|
|
|
+ $text_info .= ' - '.$langs->trans("Stock").': <span class="'.($generic_product->stock_reel > 0 ? 'ok' : 'error').'">'.$generic_product->stock_reel.'</span>';
|
|
|
+ $text_info .= ' - '.$langs->trans("VirtualStock").': <span class="'.($generic_product->stock_theorique > 0 ? 'ok' : 'error').'">'.$generic_product->stock_theorique.'</span>';
|
|
|
+ $text_info .= ($reliquat != $obj->qty ? ' <span class="opacitymedium">('.$langs->trans("QtyInOtherShipments").' '.($obj->qty - $reliquat).')</span>' : '');
|
|
|
+ $text_info .= '<br>';
|
|
|
+ } else { // BUGGED CODE.
|
|
|
+ // DOES NOT TAKE INTO ACCOUNT MANUFACTURING. THIS CODE SHOULD BE USELESS. PREVIOUS CODE SEEMS COMPLETE.
|
|
|
+ // COUNT STOCK WHEN WE SHOULD ALREADY HAVE VALUE
|
|
|
+ // Detailed virtual stock, looks bugged, uncomplete and need heavy load.
|
|
|
+ // stock order and stock order_supplier
|
|
|
+ $stock_order = 0;
|
|
|
+ $stock_order_supplier = 0;
|
|
|
+ if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { // What about other options ?
|
|
|
+ if (!empty($conf->commande->enabled)) {
|
|
|
+ if (empty($productstat_cache[$obj->fk_product]['stats_order_customer'])) {
|
|
|
+ $generic_product->load_stats_commande(0, '1,2');
|
|
|
+ $productstat_cache[$obj->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty'];
|
|
|
+ } else {
|
|
|
+ $generic_product->stats_commande['qty'] = $productstat_cache[$obj->fk_product]['stats_order_customer'];
|
|
|
}
|
|
|
- }
|
|
|
- $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20);
|
|
|
- $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order;
|
|
|
- if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) {
|
|
|
- $warning++;
|
|
|
- $text_warning .= '<span class="warning">'.$langs->trans('Available').' : '.$text_stock_reel.'</span>';
|
|
|
- }
|
|
|
- if ($reliquat > $generic_product->stock_reel) {
|
|
|
- $text_info .= '<span class="warning">'.$langs->trans('Available').' : '.$text_stock_reel.'</span>';
|
|
|
- } else {
|
|
|
- $text_info .= '<span class="ok">'.$langs->trans('Available').' : '.$text_stock_reel.'</span>';
|
|
|
+ $stock_order = $generic_product->stats_commande['qty'];
|
|
|
}
|
|
|
if (isModEnabled('supplier_order')) {
|
|
|
- $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier;
|
|
|
+ if (empty($productstat_cache[$obj->fk_product]['stats_order_supplier'])) {
|
|
|
+ $generic_product->load_stats_commande_fournisseur(0, '3');
|
|
|
+ $productstat_cache[$obj->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty'];
|
|
|
+ } else {
|
|
|
+ $generic_product->stats_commande_fournisseur['qty'] = $productstat_cache[$obj->fk_product]['stats_order_supplier'];
|
|
|
+ }
|
|
|
+ $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty'];
|
|
|
}
|
|
|
- $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' <span class="opacitymedium">('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')</span>' : '');
|
|
|
- $text_info .= '<br>';
|
|
|
}
|
|
|
+ $text_info .= $reliquat.' x '.$obj->product_ref.' '.dol_trunc($obj->product_label, 20);
|
|
|
+ $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order;
|
|
|
+ if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $obj->qty)) {
|
|
|
+ $warning++;
|
|
|
+ $text_warning .= '<span class="warning">'.$langs->trans('Available').' : '.$text_stock_reel.'</span>';
|
|
|
+ }
|
|
|
+ if ($reliquat > $generic_product->stock_reel) {
|
|
|
+ $text_info .= '<span class="warning">'.$langs->trans('Available').' : '.$text_stock_reel.'</span>';
|
|
|
+ } else {
|
|
|
+ $text_info .= '<span class="ok">'.$langs->trans('Available').' : '.$text_stock_reel.'</span>';
|
|
|
+ }
|
|
|
+ if (isModEnabled('supplier_order')) {
|
|
|
+ $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier;
|
|
|
+ }
|
|
|
+ $text_info .= ($reliquat != $obj->qty ? ' <span class="opacitymedium">('.$langs->trans("QtyInOtherShipments").' '.($obj->qty - $reliquat).')</span>' : '');
|
|
|
+ $text_info .= '<br>';
|
|
|
}
|
|
|
}
|
|
|
if ($notshippable == 0) {
|