Merge pull request #13825 from bb2a/Add-option-in-stock-for-affect-warehouse-
NEW Add option to define a default warehouse at user level
This commit is contained in:
commit
cf924e11e9
@ -28,6 +28,7 @@
|
||||
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"));
|
||||
@ -65,6 +66,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
|
||||
*/
|
||||
@ -79,6 +90,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 = '';
|
||||
@ -393,6 +406,68 @@ if ($virtualdiffersfromphysical)
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="warehouse">';
|
||||
|
||||
$rowspan = 4;
|
||||
|
||||
print '<table class="noborder centpercent">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print "<td>".$langs->trans("RuleForWarehouse")."</td>\n";
|
||||
print '<td class="right">'.$langs->trans("Status").'</td>'."\n";
|
||||
print '<td width="80"> </td></tr>'."\n";
|
||||
print '</tr>'."\n";
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("WarehouseAskWarehouseDuringOrder").'</td>';
|
||||
print '<td class="right">';
|
||||
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 "</td>";
|
||||
print '<td rowspan="'.$rowspan.'" class="nohover right">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("UserDefaultWarehouse").'</td>';
|
||||
print '<td class="right">';
|
||||
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 "</td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("MainDefaultWarehouse").'</td>';
|
||||
print '<td class="right">';
|
||||
print $formproduct->selectWarehouses($conf->global->MAIN_DEFAULT_WAREHOUSE, 'default_warehouse', '', 1);
|
||||
print "</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$form->textwithpicto($langs->trans("MainDefaultWarehouseUser"), $langs->trans("MainDefaultWarehouseUserDesc")).'</td>';
|
||||
print '<td class="right">';
|
||||
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 "</td>\n";
|
||||
print "</tr>\n";
|
||||
print '</table>';
|
||||
print '<br>';
|
||||
print '</form>';
|
||||
|
||||
print '<table class="noborder centpercent">';
|
||||
|
||||
@ -438,6 +513,7 @@ if ($conf->use_javascript_ajax) {
|
||||
}
|
||||
print "</td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("AlwaysShowFullArbo").'</td>';
|
||||
print '<td class="right">';
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -248,8 +248,12 @@ class FormProduct
|
||||
}
|
||||
|
||||
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 .= '<select class="flat'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled' : '').' id="'.$htmlname.'" name="'.($htmlname.($disabled ? '_disabled' : '')).'">';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user