diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 3733973bb2a..cbd7e46fd05 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -73,6 +73,11 @@ if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL' if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER','alpha'),'chaine',0,'',$conf->entity); } +if($action == 'USE_VIRTUAL_STOCK') { + $db->begin(); + $res = dolibarr_set_const($db, "USE_VIRTUAL_STOCK", GETPOST('USE_VIRTUAL_STOCK','alpha'),'chaine',0,'',$conf->entity); +} + if($action) { if (! $res > 0) $error++; @@ -89,6 +94,7 @@ if($action) } } + /* * View */ @@ -136,6 +142,19 @@ print '' print ''; print "\n"; print "\n"; + +print ""; +print ''.$langs->trans("UseVirtualStock").''; +print ''; +print "
"; +print ''; +print ""; +print $form->selectyesno("USE_VIRTUAL_STOCK",$conf->global->USE_VIRTUAL_STOCK,1); +print ''; +print '
'; +print "\n"; +print "\n"; + print '
'; print ''; print '
'; diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 140c0807be1..d36fe6d9121 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -64,7 +64,6 @@ StockLimitShort=Limit StockLimit=Stock limit for alerts PhysicalStock=Physical stock RealStock=Real Stock -TheoreticalStock=Therocial stock VirtualStock=Virtual stock MininumStock=Minimum stock StockUp=Stock up @@ -93,3 +92,4 @@ DesiredStock=Desired stock StockToBuy=Stock to buy Replenishment=Replenishment ReplenishmentOrders=Replenishment orders +UseVirtualStock=Use virtual stock instead of physical stock diff --git a/htdocs/langs/fr_FR/stocks.lang b/htdocs/langs/fr_FR/stocks.lang index c9f8621d14d..e7859b0fd52 100644 --- a/htdocs/langs/fr_FR/stocks.lang +++ b/htdocs/langs/fr_FR/stocks.lang @@ -64,7 +64,6 @@ StockLimitShort=Seuil StockLimit=Seuil d'alerte de stock PhysicalStock=Stock physique RealStock=Stock réel -TheoreticalStock=Stock théorique VirtualStock=Stock théorique MininumStock=Stock minimum StockUp=Stock maximum @@ -93,3 +92,4 @@ DesiredStock=Stock désiré StockToBuy=Stock à acheter Replenishment=Réapprovisionnement ReplenishmentOrders=Commandes de réapprovisionnement +UseVirtualStock=Utiliser le stock théorique à la place du stock physique diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index a07120bc1a6..182de040300 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -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 ' '; @@ -366,12 +371,24 @@ if ($resql) print ''.$objp->desiredstock.''; print ''; 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 ''; //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 ''.$stocktobuy.''; print '';