NEW Provide an easier way to understand if an order can be shipped.

This commit is contained in:
Laurent Destailleur 2015-11-25 23:20:41 +01:00
parent 28c77cbb49
commit 2d8c2221d8

View File

@ -402,26 +402,51 @@ if ($resql)
print $generic_commande->getNomUrl(1,($viewstatut != 2?0:$objp->fk_statut)); print $generic_commande->getNomUrl(1,($viewstatut != 2?0:$objp->fk_statut));
print '</td>'; print '</td>';
// Shippable Icon // Show shippable Icon (create subloop, so may be slow)
if (($objp->fk_statut > 0) && ($objp->fk_statut < 3) && ! empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) { if ($conf->stock->enabled)
{
$langs->load("stocks");
if (($objp->fk_statut > 0) && ($objp->fk_statut < 3))
{
$notshippable=0; $notshippable=0;
$warning = 0; $warning = 0;
$text_info=''; $text_info='';
$nbprod=0; $nbprod=0;
for ($lig=0; $lig<(count($generic_commande->lines)); $lig++) {
if ($generic_commande->lines[$lig]->product_type==0) { $num = count($generic_commande->lines); // Loop on each line of order
for ($lig=0; $lig < $num; $lig++)
{
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 $nbprod++; // order contains real products
$generic_product->id = $generic_commande->lines[$lig]->fk_product; $generic_product->id = $generic_commande->lines[$lig]->fk_product;
if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) { if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) {
$generic_product->load_stock(); $generic_product->load_stock();
$generic_product->load_virtual_stock();
$productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_reel; $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 { } else {
$generic_product->stock_reel = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel']; $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 (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) // Default code is when this option is not set, setting it create strange result
{
$text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->ref.'&nbsp;'.dol_trunc($generic_commande->lines[$lig]->product_label, 25);
$text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel;
$text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique;
$text_info .= '<br>';
if ($generic_commande->lines[$lig]->qty > $generic_product->stock_reel)
{
$notshippable++;
}
}
else { // Detailed code, looks bugged
// stock order and stock order_supplier // stock order and stock order_supplier
$stock_order=0; $stock_order=0;
$stock_order_supplier=0; $stock_order_supplier=0;
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) // What about other options ?
{ {
if (! empty($conf->commande->enabled)) if (! empty($conf->commande->enabled))
{ {
@ -456,13 +481,14 @@ if ($resql)
} else { } else {
$text_info.='<span class="ok">'.$langs->trans('Available').'&nbsp;:&nbsp;'.$text_stock_reel.'</span>'; $text_info.='<span class="ok">'.$langs->trans('Available').'&nbsp;:&nbsp;'.$text_stock_reel.'</span>';
} }
if ($stock_order_supplier>0) { if (! empty($conf->fournisseur->enabled)) {
$text_info.= '&nbsp;'.$langs->trans('SupplierOrder').'&nbsp;:&nbsp;'.$stock_order_supplier.'<br>'; $text_info.= '&nbsp;'.$langs->trans('SupplierOrder').'&nbsp;:&nbsp;'.$stock_order_supplier.'<br>';
} else { } else {
$text_info.= '<br>'; $text_info.= '<br>';
} }
} }
} }
}
if ($notshippable==0) { if ($notshippable==0) {
$text_icon = img_picto('', 'object_sending'); $text_icon = img_picto('', 'object_sending');
$text_info = $langs->trans('Shippable').'<br>'.$text_info; $text_info = $langs->trans('Shippable').'<br>'.$text_info;
@ -470,20 +496,20 @@ if ($resql)
$text_icon = img_picto('', 'error'); $text_icon = img_picto('', 'error');
$text_info = $langs->trans('NonShippable').'<br>'.$text_info; $text_info = $langs->trans('NonShippable').'<br>'.$text_info;
} }
if ($nbprod>0) { }
print '<td>'; print '<td>';
if ($nbprod)
{
print $form->textwithtooltip('',$text_info,2,1,$text_icon,'',2); print $form->textwithtooltip('',$text_info,2,1,$text_icon,'',2);
print '</td>';
} }
if ($warning) { if ($warning) {
print '<td>';
print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders').'<br>'.$text_warning, 2, 1, img_picto('', 'error'),'',2); print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders').'<br>'.$text_warning, 2, 1, img_picto('', 'error'),'',2);
}
print '</td>'; print '</td>';
} }
}
// warning late icon // Warning late icon
print '<td style="min-width: 20px" class="nobordernopadding nowrap">'; print '<td class="nobordernopadding nowrap">';
if ($generic_commande->hasDelay()) { if ($generic_commande->hasDelay()) {
print img_picto($langs->trans("Late"), "warning"); print img_picto($langs->trans("Late"), "warning");
} }