FIX Removed error when no error on accounting setup page

This commit is contained in:
Laurent Destailleur 2018-04-07 22:27:42 +02:00
parent 304adff973
commit aad99bdcc0

View File

@ -27,9 +27,8 @@
* \ingroup Advanced accountancy * \ingroup Advanced accountancy
* \brief Setup page to configure accounting expert module * \brief Setup page to configure accounting expert module
*/ */
require '../../main.inc.php';
// Class require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
@ -65,39 +64,23 @@ $accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' :
if ($action == 'update') { if ($action == 'update') {
$error = 0; $error = 0;
$accounting_modes = array ( if (! $error)
'RECETTES-DEPENSES', {
'CREANCES-DETTES'
);
$accounting_mode = GETPOST('accounting_mode', 'alpha');
if (in_array($accounting_mode, $accounting_modes)) {
if (! dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
} else {
$error ++;
}
if ($error) {
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)) {
$error ++; $error++;
}
}
if ($error) {
setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
if (! $error) { if (! $error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }