* Copyright (C) 2008-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2012-2013 Juanjo Menent * Copyright (C) 2013-2018 Philippe Grand * Copyright (C) 2013 Florian Henry * * 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 * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/admin/stock.php * \ingroup stock * \brief Page d'administration/configuration du module gestion de stock */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "stocks")); // Securit check if (!$user->admin) accessforbidden(); $action = GETPOST('action','alpha'); /* * Actions */ if($action) { $db->begin(); if ($action == 'STOCK_SUPPORTS_SERVICES') { $res = dolibarr_set_const($db, "STOCK_SUPPORTS_SERVICES", GETPOST('STOCK_SUPPORTS_SERVICES','alpha'),'chaine',0,'',$conf->entity); } if ($action == 'STOCK_USERSTOCK_AUTOCREATE') { $res = dolibarr_set_const($db, "STOCK_USERSTOCK_AUTOCREATE", GETPOST('STOCK_USERSTOCK_AUTOCREATE','alpha'),'chaine',0,'',$conf->entity); } if ($action == 'STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE') { $res = dolibarr_set_const($db, "STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE", GETPOST('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE','alpha'),'chaine',0,'',$conf->entity); } if ($action == 'STOCK_ALLOW_NEGATIVE_TRANSFER') { $res = dolibarr_set_const($db, "STOCK_ALLOW_NEGATIVE_TRANSFER", GETPOST('STOCK_ALLOW_NEGATIVE_TRANSFER','alpha'),'chaine',0,'',$conf->entity); } // Mode of stock decrease if ($action == 'STOCK_CALCULATE_ON_BILL' || $action == 'STOCK_CALCULATE_ON_VALIDATE_ORDER' || $action == 'STOCK_CALCULATE_ON_SHIPMENT' || $action == 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE') { $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", '','chaine',0,'',$conf->entity); $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_VALIDATE_ORDER", '','chaine',0,'',$conf->entity); $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", '','chaine',0,'',$conf->entity); $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT_CLOSE", '','chaine',0,'',$conf->entity); if ($action == 'STOCK_CALCULATE_ON_BILL') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", GETPOST('STOCK_CALCULATE_ON_BILL','alpha'),'chaine',0,'',$conf->entity); if ($action == 'STOCK_CALCULATE_ON_VALIDATE_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_VALIDATE_ORDER", GETPOST('STOCK_CALCULATE_ON_VALIDATE_ORDER','alpha'),'chaine',0,'',$conf->entity); if ($action == 'STOCK_CALCULATE_ON_SHIPMENT') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", GETPOST('STOCK_CALCULATE_ON_SHIPMENT','alpha'),'chaine',0,'',$conf->entity); if ($action == 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT_CLOSE", GETPOST('STOCK_CALCULATE_ON_SHIPMENT_CLOSE','alpha'),'chaine',0,'',$conf->entity); } // Mode of stock increase if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL' || $action == 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER' || $action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER') { //Use variable cause empty(GETPOST()) do not work with php version < 5.4 $valdispatch=GETPOST('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER','alpha'); $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_BILL", '','chaine',0,'',$conf->entity); $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", '','chaine',0,'',$conf->entity); $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", '','chaine',0,'',$conf->entity); if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_BILL", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_BILL','alpha'),'chaine',0,'',$conf->entity); if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER','alpha'),'chaine',0,'',$conf->entity); if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $valdispatch,'chaine',0,'',$conf->entity); if (empty($valdispatch)) { $res=dolibarr_set_const($db, "SUPPLIER_ORDER_USE_DISPATCH_STATUS", '','chaine',0,'',$conf->entity); } } if($action == 'SUPPLIER_ORDER_USE_DISPATCH_STATUS') { $res = dolibarr_set_const($db, "SUPPLIER_ORDER_USE_DISPATCH_STATUS", GETPOST('SUPPLIER_ORDER_USE_DISPATCH_STATUS','alpha'),'chaine',0,'',$conf->entity); } if($action == 'STOCK_USE_VIRTUAL_STOCK') { $res = dolibarr_set_const($db, "STOCK_USE_VIRTUAL_STOCK", GETPOST('STOCK_USE_VIRTUAL_STOCK','alpha'),'chaine',0,'',$conf->entity); } if($action == 'STOCK_MUST_BE_ENOUGH_FOR_INVOICE') { $res = dolibarr_set_const($db, "STOCK_MUST_BE_ENOUGH_FOR_INVOICE", GETPOST('STOCK_MUST_BE_ENOUGH_FOR_INVOICE','alpha'),'chaine',0,'',$conf->entity); } if($action == 'STOCK_MUST_BE_ENOUGH_FOR_ORDER') { $res = dolibarr_set_const($db, "STOCK_MUST_BE_ENOUGH_FOR_ORDER", GETPOST('STOCK_MUST_BE_ENOUGH_FOR_ORDER','alpha'),'chaine',0,'',$conf->entity); } if($action == 'STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT') { $res = dolibarr_set_const($db, "STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT", GETPOST('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT','alpha'),'chaine',0,'',$conf->entity); } if($action == 'INDEPENDANT_SUBPRODUCT_STOCK') { $res = dolibarr_set_const($db, "INDEPENDANT_SUBPRODUCT_STOCK", GETPOST('INDEPENDANT_SUBPRODUCT_STOCK','alpha'),'chaine',0,'',$conf->entity); } if (! $res > 0) $error++; if (! $error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { $db->rollback(); setEventMessages($langs->trans("Error"), null, 'errors'); } } /* * View */ llxHeader('',$langs->trans("StockSetup")); $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("StockSetup"),$linkback,'title_setup'); $form=new Form($db); $disabled=''; if (! empty($conf->productbatch->enabled)) { $langs->load("productbatch"); $disabled=' disabled'; print info_admin($langs->trans("WhenProductBatchModuleOnOptionAreForced")); } //if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) //{ print info_admin($langs->trans("IfYouUsePointOfSaleCheckModule")); print '
'; //} // Title rule for stock decrease print ''; print ''; print " \n"; print " \n"; print ''."\n"; $found=0; print ''; print ''; print '\n\n"; $found++; print ''; print ''; print '\n\n"; $found++; //if (! empty($conf->expedition->enabled)) //{ print ''; print ''; print '\n\n"; $found++; print ''; print ''; print '\n\n"; $found++; /*if (! $found) { print ''; print ''; print "\n"; }*/ print '
".$langs->trans("RuleForStockManagementDecrease")." 
'.$langs->trans("DeStockOnBill").''; if (! empty($conf->facture->enabled)) { print "
"; print ''; print ""; print $form->selectyesno("STOCK_CALCULATE_ON_BILL",$conf->global->STOCK_CALCULATE_ON_BILL,1,$disabled); print ''; print "
\n"; } else { print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module30Name")); } print "
'.$langs->trans("DeStockOnValidateOrder").''; if (! empty($conf->commande->enabled)) { print "
"; print ''; print ""; print $form->selectyesno("STOCK_CALCULATE_ON_VALIDATE_ORDER",$conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER,1,$disabled); print ''; print "
\n"; } else { print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module25Name")); } print "
'.$langs->trans("DeStockOnShipment").''; if (! empty($conf->expedition->enabled)) { print "
"; print ''; print ""; print $form->selectyesno("STOCK_CALCULATE_ON_SHIPMENT",$conf->global->STOCK_CALCULATE_ON_SHIPMENT,1,$disabled); print ''; print "
\n"; } else { print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")); } print "
'.$langs->trans("DeStockOnShipmentOnClosing").''; if (! empty($conf->expedition->enabled)) { print "
"; print ''; print ""; print $form->selectyesno("STOCK_CALCULATE_ON_SHIPMENT_CLOSE",$conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE,1,$disabled); print ''; print "
\n"; } else { print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")); } print "
'.$langs->trans("NoModuleToManageStockDecrease").'
'; print '
'; // Title rule for stock increase print ''; print ''; print " \n"; print " \n"; print ''."\n"; $found=0; print ''; print ''; print '\n\n"; $found++; print ''; print ''; print '\n\n"; $found++; print ''; print ''; print '\n\n"; $found++; /*if (! $found) { print ''; print ''; print "\n"; }*/ print '
".$langs->trans("RuleForStockManagementIncrease")." 
'.$langs->trans("ReStockOnBill").''; if (! empty($conf->fournisseur->enabled)) { print "
"; print ''; print ""; print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_BILL",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL,1,$disabled); print ''; print "
\n"; } else { print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")); } print "
'.$langs->trans("ReStockOnValidateOrder").''; if (! empty($conf->fournisseur->enabled)) { print "
"; print ''; print ""; print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER,1,$disabled); print ''; print "
\n"; } else { print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")); } print "
'.$langs->trans("ReStockOnDispatchOrder").''; if (! empty($conf->fournisseur->enabled)) { print "
"; print ''; print ""; print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER,1,$disabled); print ''; print "
\n"; } else { print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")); } print "
'.$langs->trans("NoModuleToManageStockIncrease").'
'; print '
'; print ''; print ''; print " \n"; print " \n"; print ''."\n"; print ''; print ''; print '\n"; print "\n"; // Option to force stock to be enough before adding a line into document if($conf->invoice->enabled) { print ''; print ''; print '\n"; print "\n"; } if($conf->order->enabled) { print ''; print ''; print '\n"; print "\n"; } if($conf->expedition->enabled) { print ''; print ''; print '\n"; print "\n"; } print '
".$langs->trans("RuleForStockAvailability")." 
'.$langs->trans("WarehouseAllowNegativeTransfer").''; print "
"; print ''; print ""; print $form->selectyesno("STOCK_ALLOW_NEGATIVE_TRANSFER",$conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER,1); print ''; print '
'; print "
'.$langs->trans("StockMustBeEnoughForInvoice").''; print "
"; print ''; print ""; print $form->selectyesno("STOCK_MUST_BE_ENOUGH_FOR_INVOICE",$conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE,1); print ''; print '
'; print "
'.$langs->trans("StockMustBeEnoughForOrder").''; print "
"; print ''; print ""; print $form->selectyesno("STOCK_MUST_BE_ENOUGH_FOR_ORDER",$conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER,1); print ''; print '
'; print "
'.$langs->trans("StockMustBeEnoughForShipment").''; print "
"; print ''; print ""; print $form->selectyesno("STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT",$conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT,1); print ''; print '
'; print "
'; print '
'; $virtualdiffersfromphysical=0; if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) ) $virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs. if ($virtualdiffersfromphysical) { print ''; print ''; print " \n"; print " \n"; print ''."\n"; print ''; print ''; print '\n"; print "\n"; print '
".$langs->trans("RuleForStockReplenishment")." ".img_help('help',$langs->trans("VirtualDiffersFromPhysical"))." 
'.$langs->trans("UseVirtualStockByDefault").''; print "
"; print ''; print ""; print $form->selectyesno("STOCK_USE_VIRTUAL_STOCK",$conf->global->STOCK_USE_VIRTUAL_STOCK,1); print ''; print '
'; print "
'; print '
'; } print ''; print ''; print " \n"; print " \n"; print ''."\n"; print ''; print ''; print '\n"; print "\n"; print ''; print ''; print '\n"; print "\n"; print ''; print ''; print '\n"; print "\n"; if (! empty($conf->fournisseur->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { print ''; print ''; print '\n\n"; } print '
".$langs->trans("Other")." 
'.$langs->trans("UserWarehouseAutoCreate").''; print "
"; print ''; print ""; print $form->selectyesno("STOCK_USERSTOCK_AUTOCREATE",$conf->global->STOCK_USERSTOCK_AUTOCREATE,1); print ''; print '
'; print "
'; print $form->textwithpicto($langs->trans("StockSupportServices"), $langs->trans("StockSupportServicesDesc")); print ''; print "
"; print ''; print ""; print $form->selectyesno("STOCK_SUPPORTS_SERVICES",$conf->global->STOCK_SUPPORTS_SERVICES,1); print ''; print '
'; print "
'.$langs->trans("AllowAddLimitStockByWarehouse").''; print "
"; print ''; print ""; print $form->selectyesno("STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE",$conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE,1); print ''; print '
'; print "
'.$langs->trans("UseDispatchStatus").''; print "
"; print ''; print ""; print $form->selectyesno("SUPPLIER_ORDER_USE_DISPATCH_STATUS",$conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS,1); print ''; print "
\n"; print "
'; print '
'; if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { print ''; print ''; print ''."\n"; print ''; print ''."\n"; // Example with a yes / no select print ''; print ''; print ''; print ''; // Example with a yes / no select print ''; print ''; print ''; print ''; // Example with a yes / no select print ''; print ''; print ''; print ''; print '
'.$langs->trans("Inventory").'  
'.$langs->trans("INVENTORY_DISABLE_VIRTUAL").' '; print '
'; print ''; print ''; print $form->selectyesno("INVENTORY_DISABLE_VIRTUAL",$conf->global->INVENTORY_DISABLE_VIRTUAL,1); print ''; print '
'; print '
'.$langs->trans("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA").' '; print '
'; print ''; print ''; print $form->selectyesno("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA",$conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA,1); print ''; print '
'; print '
'.$langs->trans("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT").' '; print '
'; print ''; print ''; print $form->selectyesno("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT",$conf->global->INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT,1); print ''; print '
'; print '
'; } /* I keep the option/feature, but hidden to end users for the moment. If feature is used by module, no need to have users see it. If not used by a module, I still need to understand in which case user may need this now we can set rule on product page. if ($conf->global->PRODUIT_SOUSPRODUITS) { print ''; print ''.$langs->trans("IndependantSubProductStock").''; print ''; print "
"; print ''; print ""; print $form->selectyesno("INDEPENDANT_SUBPRODUCT_STOCK",$conf->global->INDEPENDANT_SUBPRODUCT_STOCK,1); print ''; print '
'; print "\n"; print "\n"; } */ // End of page llxFooter(); $db->close();