diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index b11b792979d..5b43a9b120a 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -1,5 +1,6 @@ + * Copyright (C) 2008 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -51,46 +52,38 @@ elseif ($_POST["action"] == 'stock_userstock_autocreate') Header("Location: stock.php"); exit; } -elseif ($_POST["action"] == 'stock_bill') +// Mode of stock changement +elseif ( $_POST["action"] == 'stock_bill' + || $_POST["action"] == 'stock_validateorder' + || $_POST["action"] == 'stock_shipment') { - dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", $_POST["stock_bill"]); - //Si activ�e on d�sactive la d�cr�mentation du stock � la validation de commande et/ou � l'exp�dition - if ($_POST["stock_bill"] == 1) - { - if ($conf->commande->enabled) dolibarr_set_const($db, "STOCK_CALCULATE_ON_VALIDATE_ORDER", 0); - if ($conf->expedition->enabled) dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", 0); - } - Header("Location: stock.php"); - exit; -} -elseif ($_POST["action"] == 'stock_validateorder') -{ - dolibarr_set_const($db, "STOCK_CALCULATE_ON_VALIDATE_ORDER", $_POST["stock_validateorder"]); - //Si activ�e on d�sactive la d�cr�mentation du stock � la facturation et/ou � l'exp�dition - if ($_POST["stock_validateorder"] == 1) - { - if ($conf->facture->enabled) dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", 0); - if ($conf->expedition->enabled) dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", 0); - } - Header("Location: stock.php"); - exit; -} -elseif ($_POST["action"] == 'stock_shipment') -{ - dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", $_POST["stock_shipment"]); - //Si activ�e on d�sactive la d�cr�mentation du stock � la facturation et/ou � la validation de commande - if ($_POST["stock_shipment"] == 1) - { - if ($conf->facture->enabled) dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", 0); - if ($conf->commande->enabled) dolibarr_set_const($db, "STOCK_CALCULATE_ON_VALIDATE_ORDER", 0); - } - Header("Location: stock.php"); - exit; -} + $count=0; + $db->begin(); + $count+=dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", ''); + $count+=dolibarr_set_const($db, "STOCK_CALCULATE_ON_VALIDATE_ORDER", ''); + $count+=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", ''); + if ($_POST["action"] == 'stock_bill') $count+=dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", $_POST["stock_bill"]); + if ($_POST["action"] == 'stock_validateorder') $count+=dolibarr_set_const($db, "STOCK_CALCULATE_ON_VALIDATE_ORDER", $_POST["stock_validateorder"]); + if ($_POST["action"] == 'stock_shipment') $count+=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", $_POST["stock_shipment"]); + if ($count == 4) + { + $db->commit(); + Header("Location: stock.php"); + exit; + } + else + { + $db->rollback(); + dolibarr_print_error("Error in some requests", LOG_ERR); + } +} + + /* - * Affiche page + * View */ + llxHeader('',$langs->trans("StockSetup")); $linkback=''.$langs->trans("BackToModuleList").''; @@ -100,10 +93,11 @@ print '
'; $html=new Form($db); $var=true; print ''; + print ''; print " \n"; print " \n"; -print " \n"; +print ''."\n"; /* * Formulaire parametres divers @@ -138,6 +132,13 @@ if ($conf->global->STOCK_USERSTOCK == 1) print "\n"; } + +print ''; +print " \n"; +print " \n"; +print ''."\n"; +$var=true; + if ($conf->facture->enabled) { $var=!$var; diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 42c43c9dc46..8ed95ecb3c1 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -38,6 +38,7 @@ EnhancedValueOfWarehouses=Warehouses value UserWarehouseAutoCreate=Create a stock automatically when creating a user QtyDispatched=Quantity dispatched OrderDispatch=Order dispatching +RuleForStockManagement=Rule for stock management DeStockReStockOnBill=Decrease/increase real stocks on invoices/credit notes (warning, in this version, it's only in warehous number 1 that stock is modified) DeStockReStockOnValidateOrder=Decrease/increase real stocks on orders notes DeStockReStockOnShipment=Decrease/increase real stocks on shipment diff --git a/htdocs/langs/fr_FR/stocks.lang b/htdocs/langs/fr_FR/stocks.lang index bf5a73c6839..a8444c285d2 100644 --- a/htdocs/langs/fr_FR/stocks.lang +++ b/htdocs/langs/fr_FR/stocks.lang @@ -38,9 +38,10 @@ EnhancedValueOfWarehouses=Valorisation des stocks UserWarehouseAutoCreate=Créer un stock automatiquement à la création d'un utilisateur QtyDispatched=Quantité ventilée OrderDispatch=Ventilation commande -DeStockReStockOnBill=Décrémente/Incrémente les stocks réels sur les factures/avoirs (attention, dans cette version, c'est toujours dans le premier entrepot numero 1 que se fait l'ajustement) -DeStockReStockOnValidateOrder=Décrémente/Incrémente les stocks réels sur les commandes -DeStockReStockOnShipment=Décrémente/Incrémente les stocks réels sur les expéditions +RuleForStockManagement=Règle de gestion de stock +DeStockReStockOnBill=Décrémente/Incrémente les stocks physiques sur les factures/avoirs (attention, dans cette version, c'est toujours dans le premier entrepot numero 1 que se fait l'ajustement) +DeStockReStockOnValidateOrder=Décrémente/Incrémente les stocks physiques sur les commandes +DeStockReStockOnShipment=Décrémente/Incrémente les stocks physiques sur les expéditions StockDiffPhysicTeoric=Raison écart stock physique-théorique StockLimitShort=Seuil StockLimit=Seuil alerte stock diff --git a/htdocs/lib/admin.lib.php b/htdocs/lib/admin.lib.php index 0c65a853f6b..75e4176b8c0 100644 --- a/htdocs/lib/admin.lib.php +++ b/htdocs/lib/admin.lib.php @@ -302,7 +302,7 @@ function dolibarr_get_const($db, $name) \param type Type de constante (chaine par défaut) \param visible La constante est elle visible (0 par défaut) \param note Explication de la constante - \return int <0 si ko, >0 si ok + \return int -1 if KO, 1 if OK */ function dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='') {
".$langs->trans("Parameters")."".$langs->trans("Value")."
".$langs->trans("RuleForStockManagement")."".$langs->trans("Value")."