added an option to use virtual stock instead of physical stock

This commit is contained in:
Cédric Salvador 2013-06-10 15:42:58 +02:00
parent d4aa2a0f79
commit 52cfecd0af
2 changed files with 35 additions and 5 deletions

View File

@ -142,6 +142,19 @@ print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'
print '</form>';
print "</td>\n";
print "</tr>\n";
print "<tr ".$bc[$var].">";
print '<td width="60%">'.$langs->trans("UseVirtualStock").'</td>';
print '<td width="160" align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"USE_VIRTUAL_STOCK\">";
print $form->selectyesno("USE_VIRTUAL_STOCK",$conf->global->USE_VIRTUAL_STOCK,1);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print "</td>\n";
print "</tr>\n";
print '<br>';
print '</table>';
print '<br>';

View File

@ -287,7 +287,12 @@ if ($resql)
print_liste_field_titre($langs->trans("Label"),"replenish.php", "p.label",$param,"","",$sortfield,$sortorder);
if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre($langs->trans("Duration"),"replenish.php", "p.duration",$param,"",'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DesiredStock"),"replenish.php", "p.desiredstock",$param,"",'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("PhysicalStock"),"replenish.php", "stock_physique",$param,"",'align="right"',$sortfield,$sortorder);
if($conf->global->USE_VIRTUAL_STOCK) {
print_liste_field_titre($langs->trans("VirtualStock"),"replenish.php", "",$param,"",'align="right"',$sortfield,$sortorder);
}
else {
print_liste_field_titre($langs->trans("PhysicalStock"),"replenish.php", "stock_physique",$param,"",'align="right"',$sortfield,$sortorder);
}
print_liste_field_titre($langs->trans("StockToBuy"),"replenish.php", "",$param,"",'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Supplier"),"replenish.php", "",$param,"",'align="right"',$sortfield,$sortorder);
print '<td>&nbsp;</td>';
@ -366,12 +371,24 @@ if ($resql)
print '<td align="right">'.$objp->desiredstock.'</td>';
print '<td align="right">';
if(!$objp->stock_physique) $objp->stock_physique = 0;
if ($objp->seuil_stock_alerte && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' ';
print $objp->stock_physique;
if($conf->global->USE_VIRTUAL_STOCK){
$product_static->fetch($product_static->id);
$result=$product_static->load_stats_commande(0,'1,2');
if ($result < 0) dol_print_error($db,$product_static->error);
$stock_commande_client = $product_static->stats_commande['qty'];
$result=$product_static->load_stats_commande_fournisseur(0,'3');
if ($result < 0) dol_print_error($db,$product_static->error);
$stock_commande_fournisseur = $product_static->stats_commande_fournisseur['qty'];
$stock = $objp->stock_physique - $stock_commande_client + $stock_commande_fournisseur;
}
else{
$stock = $objp->stock_physique;
}
if ($objp->seuil_stock_alerte && ($stock < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' ';
print $stock;
print '</td>';
//depending on conf, use either physical stock or
//theoretical stock to compute the stock to buy value
($conf->global->use_theoretical_stock? $stock = $objp->stock_théorique : $stock = $objp->stock_physique);
//virtual stock to compute the stock to buy value
$stocktobuy = $objp->desiredstock - $stock;
print '<td align="right">'.$stocktobuy.'</td>';
print '<input type="hidden" name="tobuy'.$i.'" value="'.$stocktobuy.'" >';