mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Clean code
This commit is contained in:
parent
cf924e11e9
commit
f8b92e507c
|
|
@ -42,6 +42,7 @@ $action = GETPOST('action', 'alpha');
|
|||
/*
|
||||
* Action
|
||||
*/
|
||||
|
||||
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
|
||||
{
|
||||
$code = $reg[1];
|
||||
|
|
@ -76,6 +77,7 @@ if ($action == 'warehouse')
|
|||
if (!$res > 0) $error++;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
|
@ -108,6 +110,11 @@ print info_admin($langs->trans("IfYouUsePointOfSaleCheckModule"));
|
|||
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">';
|
||||
|
||||
// Title rule for stock decrease
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
|
|
@ -295,14 +302,6 @@ if (!empty($conf->reception->enabled))
|
|||
$found++;
|
||||
}
|
||||
|
||||
/*if (! $found)
|
||||
{
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td colspan="2">'.$langs->trans("NoModuleToManageStockIncrease").'</td>';
|
||||
print "</tr>\n";
|
||||
}*/
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<br>';
|
||||
|
|
@ -403,72 +402,10 @@ if ($virtualdiffersfromphysical)
|
|||
print "</td>\n";
|
||||
print "</tr>\n";
|
||||
print '</table>';
|
||||
|
||||
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">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
|
|
@ -477,17 +414,52 @@ print '<td class="right">'.$langs->trans("Status").'</td>'."\n";
|
|||
print '</tr>'."\n";
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("UserWarehouseAutoCreate").'</td>';
|
||||
print '<td>'.$langs->trans("MainDefaultWarehouse").'</td>';
|
||||
print '<td class="right">';
|
||||
print $formproduct->selectWarehouses($conf->global->MAIN_DEFAULT_WAREHOUSE, 'default_warehouse', '', 1, 0, 0, '', 0, 0, array(), 'left reposition');
|
||||
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('STOCK_USERSTOCK_AUTOCREATE');
|
||||
print ajax_constantonoff('MAIN_DEFAULT_WAREHOUSE_USER', array(), null, 0, 0, 1);
|
||||
} else {
|
||||
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
|
||||
print $form->selectarray("STOCK_USERSTOCK_AUTOCREATE", $arrval, $conf->global->STOCK_USERSTOCK_AUTOCREATE);
|
||||
$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";
|
||||
|
||||
if (! empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("UserWarehouseAutoCreate").'</td>';
|
||||
print '<td class="right">';
|
||||
if ($conf->use_javascript_ajax) {
|
||||
print ajax_constantonoff('STOCK_USERSTOCK_AUTOCREATE');
|
||||
} else {
|
||||
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
|
||||
print $form->selectarray("STOCK_USERSTOCK_AUTOCREATE", $arrval, $conf->global->STOCK_USERSTOCK_AUTOCREATE);
|
||||
}
|
||||
print "</td>\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>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>';
|
||||
print $form->textwithpicto($langs->trans("StockSupportServices"), $langs->trans("StockSupportServicesDesc"));
|
||||
|
|
@ -527,6 +499,8 @@ print "</td>\n";
|
|||
print "</tr>\n";
|
||||
print '</table>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
/*
|
||||
print '<br>';
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
|
||||
|
|
|
|||
|
|
@ -57,10 +57,10 @@ 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
|
||||
WarehouseAskWarehouseDuringOrder=Set a warehouse on Sale orders
|
||||
UserDefaultWarehouse=Set a warehouse on Users
|
||||
DefaultWarehouseActive=Default warehouse active
|
||||
MainDefaultWarehouse=Warehouse default
|
||||
MainDefaultWarehouse=Default warehouse
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1225,7 +1225,7 @@ if ($action == 'create' || $action == 'adduserldap')
|
|||
// TODO Move this into tab RH (HierarchicalResponsible must be on both tab)
|
||||
|
||||
// Default warehouse
|
||||
if (!empty($conf->stock->enabled) && !empty($conf->global->USER_DEFAULT_WAREHOUSE)) // TODO What is goal of this. How it is used ?
|
||||
if (!empty($conf->stock->enabled) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER))
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("DefaultWarehouse").'</td><td>';
|
||||
print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1);
|
||||
|
|
@ -1597,7 +1597,7 @@ if ($action == 'create' || $action == 'adduserldap')
|
|||
print "</tr>\n";
|
||||
|
||||
// Default warehouse
|
||||
if (!empty($conf->stock->enabled) && !empty($conf->global->USER_DEFAULT_WAREHOUSE)) // TODO What is goal of this. How it is used ?
|
||||
if (!empty($conf->stock->enabled) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
|
||||
$warehousestatic = new Entrepot($db);
|
||||
|
|
@ -2591,7 +2591,7 @@ if ($action == 'create' || $action == 'adduserldap')
|
|||
// TODO Move this into tab RH (HierarchicalResponsible must be on both tab)
|
||||
|
||||
// Default warehouse
|
||||
if (!empty($conf->stock->enabled) && !empty($conf->global->USER_DEFAULT_WAREHOUSE)) // TODO What is goal of this. How it is used ?
|
||||
if (!empty($conf->stock->enabled) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER))
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("DefaultWarehouse").'</td><td>';
|
||||
print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1);
|
||||
|
|
|
|||
|
|
@ -1174,15 +1174,7 @@ class User extends CommonObject
|
|||
return -5;
|
||||
}
|
||||
|
||||
// Update minor fields
|
||||
$result = $this->update($user, 1, 1);
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -4;
|
||||
}
|
||||
|
||||
if (!empty($conf->global->STOCK_USERSTOCK_AUTOCREATE))
|
||||
if (! empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER) && !empty($conf->global->STOCK_USERSTOCK_AUTOCREATE))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
|
||||
$langs->load("stocks");
|
||||
|
|
@ -1192,7 +1184,17 @@ class User extends CommonObject
|
|||
$entrepot->description = $langs->trans("ThisWarehouseIsPersonalStock", $this->getFullName($langs));
|
||||
$entrepot->statut = 1;
|
||||
$entrepot->country_id = $mysoc->country_id;
|
||||
$entrepot->create($user);
|
||||
$warehouseid = $entrepot->create($user);
|
||||
|
||||
$this->fk_warehouse = $warehouseid;
|
||||
}
|
||||
|
||||
// Update minor fields
|
||||
$result = $this->update($user, 1, 1);
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -4;
|
||||
}
|
||||
|
||||
if (!$notrigger)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user