diff --git a/htdocs/admin/compta.php b/htdocs/admin/compta.php index b763b8c2c87..91363cff292 100644 --- a/htdocs/admin/compta.php +++ b/htdocs/admin/compta.php @@ -2,6 +2,7 @@ /* Copyright (C) 2004 Rodolphe Quiedeville * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,46 +33,65 @@ $langs->load('compta'); if (!$user->admin) accessforbidden(); - -llxHeader(); - +$action = GETPOST("action"); $compta_mode = defined('COMPTA_MODE')?COMPTA_MODE:'RECETTES-DEPENSES'; -if ($_POST['action'] == 'setcomptamode') +if ($action == 'setcomptamode') { - $compta_mode = $_POST['compta_mode']; - if (! dolibarr_set_const($db, 'COMPTA_MODE', $compta_mode,'chaine',0,'',$conf->entity)) { print $db->error(); } - // Note: This setup differs from TAX_MODE. - // TAX_MODE is used for VAT exigibility only. + $compta_mode = GETPOST("compta_mode"); + + $res = dolibarr_set_const($db, 'COMPTA_MODE', $compta_mode,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + $mesg = "".$langs->trans("SetupSaved").""; + } + else + { + $mesg = "".$langs->trans("Error").""; + } + +} + +if ($action == 'update' || $action == 'add') +{ + $constname = GETPOST("constname"); + $constvalue = GETPOST("constvalue"); + $consttype = GETPOST("consttype"); + $constnote = GETPOST("constnote"); + + $res = dolibarr_set_const($db, $constname, $constvalue, $consttype, 0, $constnote ,$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + $mesg = "".$langs->trans("SetupSaved").""; + } + else + { + $mesg = "".$langs->trans("Error").""; + } } -$form = new Form($db); -$typeconst=array('yesno','texte','chaine'); - - -if ($_POST['action'] == 'update' || $_POST['action'] == 'add') -{ - if (! dolibarr_set_const($db, $_POST['constname'], $_POST['constvalue'], $_POST['consttype'], 0, isset($_POST['constnote']) ? $_POST['constnote'] : '',$conf->entity)); - { - print $db->error(); - } -} - - -if ($_GET['action'] == 'delete') +/*if ($action == 'delete') { if (! dolibarr_del_const($db, $_GET['constname'],$conf->entity)); { print $db->error(); } -} +}*/ /* * Affichage page */ +llxHeader(); + $html=new Form($db); $linkback=''.$langs->trans("BackToModuleList").''; @@ -181,9 +201,9 @@ if ($num) print "\n"; } +dol_htmloutput_mesg($mesg); $db->close(); - llxFooter(); ?>