From c6d2a1faf3944bb315951146550f3758b38a1ec4 Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Wed, 6 May 2020 00:48:00 +0200 Subject: [PATCH 1/5] Add options Add options in module stock --- htdocs/admin/stock.php | 78 ++++++++++++++++++- htdocs/langs/en_US/stocks.lang | 7 ++ htdocs/langs/fr_FR/stocks.lang | 7 ++ .../product/class/html.formproduct.class.php | 10 ++- 4 files changed, 97 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 43e610c3052..fc5e9f98404 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -28,7 +28,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php'; - +require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + // Load translation files required by the page $langs->loadLangs(array("admin", "stocks")); @@ -69,6 +70,16 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) } } +if ($action == 'warehouse') +{ + $value = GETPOST('default_warehouse', 'alpha'); + $res = dolibarr_set_const($db, "MAIN_DEFAULT_WAREHOUSE", $value, 'chaine', 0, '', $conf->entity); + if ($value == -1 || empty($value) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)){ + $res = dolibarr_del_const($db, "MAIN_DEFAULT_WAREHOUSE", $conf->entity); + } + if (!$res > 0) $error++; +} + /* * View */ @@ -83,6 +94,8 @@ $head = stock_admin_prepare_head(); dol_fiche_head($head, 'general', $langs->trans("StockSetup"), -1, 'stock'); $form = new Form($db); +$formproduct = new FormProduct($db); + $disabled = ''; @@ -413,6 +426,68 @@ if ($virtualdiffersfromphysical) print '
'; } +print '
'; +print ''; +print ''; + +$rowspan = 4; + +print ''; + +print ''; +print "\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; + +print ''; +print ''; +print '"; +print ''; +print "\n"; + +print ''; +print ''; +print '\n"; +print "\n"; + +print ''; +print ''; +print '"; +print "\n"; + +print ''; +print ''; +print '\n"; +print "\n"; +print '
".$langs->trans("RuleForWarehouse")."'.$langs->trans("Status").' 
'.$langs->trans("WarehouseAskWarehouseDuringOrder").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $arrval, $conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER); +} +print "'; +print ''; +print '
'.$langs->trans("UserDefaultWarehouse").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('USER_DEFAULT_WAREHOUSE'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("USER_DEFAULT_WAREHOUSE", $arrval, $conf->global->USER_DEFAULT_WAREHOUSE); +} +print "
'.$langs->trans("MainDefaultWarehouse").''; +print $formproduct->selectWarehouses($conf->global->MAIN_DEFAULT_WAREHOUSE, 'default_warehouse', '', 1); +print "
'.$form->textwithpicto($langs->trans("MainDefaultWarehouseUser"), $langs->trans("MainDefaultWarehouseUserDesc")).''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_DEFAULT_WAREHOUSE_USER'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MAIN_DEFAULT_WAREHOUSE_USER", $arrval, $conf->global->MAIN_DEFAULT_WAREHOUSE_USER); +} +print "
'; +print '
'; +print '
'; print ''; @@ -458,7 +533,6 @@ if ($conf->use_javascript_ajax) { } print "\n"; print "\n"; - print '
'; /* diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 9856649b834..7c29c62b722 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -56,6 +56,13 @@ PMPValueShort=WAP EnhancedValueOfWarehouses=Warehouses value UserWarehouseAutoCreate=Create a user warehouse automatically when creating a user AllowAddLimitStockByWarehouse=Manage also value for minimum and desired stock per pairing (product-warehouse) in addition to the value for minimum and desired stock per product +RuleForWarehouse=Rule for warehouses +WarehouseAskWarehouseDuringOrder=Assign order on a warehouse +UserDefaultWarehouse=Assign a default warehouse on user +DefaultWarehouseActive=Default warehouse active +MainDefaultWarehouse=Warehouse default +MainDefaultWarehouseUser=Use user warehouse asign default +MainDefaultWarehouseUserDesc=/!\ By activating this option the gold of the creation of an article, the warehouse assigned to the user will be defined on this one. If no warehouse is defined on the user, the default warehouse is defined. IndependantSubProductStock=Product stock and subproduct stock are independent QtyDispatched=Quantity dispatched QtyDispatchedShort=Qty dispatched diff --git a/htdocs/langs/fr_FR/stocks.lang b/htdocs/langs/fr_FR/stocks.lang index b3ea9e04c13..d71c6c46397 100644 --- a/htdocs/langs/fr_FR/stocks.lang +++ b/htdocs/langs/fr_FR/stocks.lang @@ -56,6 +56,13 @@ PMPValueShort=PMP EnhancedValueOfWarehouses=Valorisation des stocks UserWarehouseAutoCreate=Créer automatiquement un stock/entrepôt propre à l'utilisateur lors de sa création AllowAddLimitStockByWarehouse=Gérez également les valeurs des stocks minimums et souhaités par paire (produit-entrepôt) en plus des valeurs de minimums et souhaités par produit +RuleForWarehouse=Régles pour entrepôts +WarehouseAskWarehouseDuringOrder=Affecter un entrepôt sur les commandes +UserDefaultWarehouse=Affecter un entrepôt par default sur les utilisateurs +DefaultWarehouseActive=Activation entrepot par default +MainDefaultWarehouse=Entrepôt par default +MainDefaultWarehouseUser=Utiliser l'entrepôt de l'utilisateur par default +MainDefaultWarehouseUserDesc=/!\ En activant cette option l'or de la création d'un article, l'entrepôt affecté à l'utilisateur sera défini sur celui-ci. Si aucun entrepôt n'est défini sur l'utilisateur, c'est l'entrepôt par défaut qui est défini. IndependantSubProductStock=Le stock du produit et le stock des sous-produits sont indépendant QtyDispatched=Quantité ventilée QtyDispatchedShort=Qté ventilée diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 0eeddd15c07..81ccdc79a4f 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -253,10 +253,14 @@ class FormProduct $comboenhancement = ajax_combobox($htmlname, $events); $out .= $comboenhancement; } - + if (strpos($htmlname, 'search_') !== 0) { - if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) $selected = $conf->global->MAIN_DEFAULT_WAREHOUSE; - if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) $selected = $user->fk_warehouse; + if (empty($user->fk_warehouse) || $user->fk_warehouse == -1){ + if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) $selected = $conf->global->MAIN_DEFAULT_WAREHOUSE; + } + else{ + if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) $selected = $user->fk_warehouse; + } } $out .= '