Uniformize code

This commit is contained in:
Juanjo Menent 2011-08-28 09:52:46 +00:00
parent aacad07511
commit 8e75a21df9

View File

@ -68,14 +68,17 @@ if ($action == 'setcodecompta')
if ($action == 'COMPANY_USE_SEARCH_TO_SELECT') if ($action == 'COMPANY_USE_SEARCH_TO_SELECT')
{ {
if (dolibarr_set_const($db, "COMPANY_USE_SEARCH_TO_SELECT", $_POST["activate_COMPANY_USE_SEARCH_TO_SELECT"],'chaine',0,'',$conf->entity)) $res = dolibarr_set_const($db, "COMPANY_USE_SEARCH_TO_SELECT", $_POST["activate_COMPANY_USE_SEARCH_TO_SELECT"],'chaine',0,'',$conf->entity);
{ if (! $res > 0) $error++;
Header("Location: ".$_SERVER["PHP_SELF"]); if (! $error)
exit; {
} $db->commit();
else $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
{ }
dol_print_error($db); else
{
$db->rollback();
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
} }
} }
@ -83,16 +86,29 @@ if ($action == 'COMPANY_USE_SEARCH_TO_SELECT')
if ($action == 'setModuleOptions') if ($action == 'setModuleOptions')
{ {
$post_size=count($_POST); $post_size=count($_POST);
$db->begin();
for($i=0;$i < $post_size;$i++) for($i=0;$i < $post_size;$i++)
{ {
if (array_key_exists('param'.$i,$_POST)) if (array_key_exists('param'.$i,$_POST))
{ {
$param=$_POST["param".$i]; $param=$_POST["param".$i];
$value=$_POST["value".$i]; $value=$_POST["value".$i];
if ($param) dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
} }
} }
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>"; if (! $error)
{
$db->commit();
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$db->rollback();
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
} }
// Activate a document generator module // Activate a document generator module