Fix param lost when saving setup

This commit is contained in:
Laurent Destailleur 2016-11-04 16:32:28 +01:00
parent e59c2bb61c
commit 614f3d8286

View File

@ -50,8 +50,6 @@ $action = GETPOST('action', 'alpha');
// Parameters ACCOUNTING_* and others // Parameters ACCOUNTING_* and others
$list = array ( $list = array (
//'ACCOUNTING_LIMIT_LIST_VENTILATION', Useless, we can change value dynamically, so we use default global setup
'ACCOUNTING_MANAGE_ZERO',
'ACCOUNTING_LENGTH_GACCOUNT', 'ACCOUNTING_LENGTH_GACCOUNT',
'ACCOUNTING_LENGTH_AACCOUNT' , 'ACCOUNTING_LENGTH_AACCOUNT' ,
'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc
@ -85,13 +83,11 @@ if ($action == 'update') {
$error ++; $error ++;
} }
if (! $error) { if ($error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
foreach ( $list as $constname ) { foreach ($list as $constname) {
$constvalue = GETPOST($constname, 'alpha'); $constvalue = GETPOST($constname, 'alpha');
if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
@ -259,41 +255,37 @@ if (! empty($user->admin))
print '</a></td>'; print '</a></td>';
} }
print '</tr>'; print '</tr>';
$var = ! $var;
print "<tr " . $bc[$var] . ">";
print '<td>' . $langs->trans("ACCOUNTING_MANAGE_ZERO") . '</td>';
if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setmanagezero&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setmanagezero&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
} }
// Param a user $user->rights->accountancy->chartofaccount can access // Param a user $user->rights->accountancy->chartofaccount can access
foreach ( $list as $key ) { foreach ($list as $key)
{
$var = ! $var; $var = ! $var;
if ($key != 'ACCOUNTING_MANAGE_ZERO') print '<tr ' . $bc[$var] . ' class="value">';
{ // Param
print '<tr ' . $bc[$var] . ' class="value">'; $label = $langs->trans($key);
// Param print '<td>'.$label.'</td>';
$label = $langs->trans($key); // Value
print '<td>'.$label.'</td>'; print '<td align="right">';
// Value print '<input type="text" size="20" id="' . $key . '" name="' . $key . '" value="' . $conf->global->$key . '">';
print '<td align="right">'; print '</td>';
print '<input type="text" size="20" id="' . $key . '" name="' . $key . '" value="' . $conf->global->$key . '">'; print '</tr>';
print '</td>';
print '</tr>';
}
if ($key == 'ACCOUNTING_MANAGE_ZERO')
{
$var = ! $var;
print "<tr " . $bc[$var] . ">";
print '<td>' . $langs->trans("ACCOUNTING_MANAGE_ZERO") . '</td>';
if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
print '<td align="right""><a href="' . $_SERVER['PHP_SELF'] . '?action=setmanagezero&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setmanagezero&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
}
} }
@ -302,10 +294,6 @@ print '</table>';
dol_fiche_end(); dol_fiche_end();
print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>'; print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';