Uniformize code

This commit is contained in:
Juanjo Menent 2011-09-02 12:51:12 +00:00
parent 34bb48b54d
commit 488a1ab3c3
2 changed files with 7 additions and 19 deletions

View File

@ -40,11 +40,9 @@ $action = GETPOST("action");
if ($action == "set") if ($action == "set")
{ {
$db->begin();
for ($i = 0 ; $i < 2 ; $i++) for ($i = 0 ; $i < 2 ; $i++)
{ {
$res = dolibarr_set_const($db, $_POST["nom$i"], $_POST["value$i"],'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, $_POST["nom$i"], $_POST["value$i"],'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
} }
$id=$_POST["PRELEVEMENT_ID_BANKACCOUNT"]; $id=$_POST["PRELEVEMENT_ID_BANKACCOUNT"];
@ -53,32 +51,23 @@ if ($action == "set")
if($account->fetch($id)>0) if($account->fetch($id)>0)
{ {
$res = dolibarr_set_const($db, "PRELEVEMENT_ID_BANKACCOUNT", $id,'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, "PRELEVEMENT_ID_BANKACCOUNT", $id,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
$res = dolibarr_set_const($db, "PRELEVEMENT_CODE_BANQUE", $account->code_banque,'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, "PRELEVEMENT_CODE_BANQUE", $account->code_banque,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
$res = dolibarr_set_const($db, "PRELEVEMENT_CODE_GUICHET", $account->code_guichet,'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, "PRELEVEMENT_CODE_GUICHET", $account->code_guichet,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
$res = dolibarr_set_const($db, "PRELEVEMENT_NUMERO_COMPTE", $account->number,'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, "PRELEVEMENT_NUMERO_COMPTE", $account->number,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
$res = dolibarr_set_const($db, "PRELEVEMENT_NUMBER_KEY", $account->cle_rib,'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, "PRELEVEMENT_NUMBER_KEY", $account->cle_rib,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
$res = dolibarr_set_const($db, "PRELEVEMENT_IBAN", $account->iban,'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, "PRELEVEMENT_IBAN", $account->iban,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
$res = dolibarr_set_const($db, "PRELEVEMENT_BIC", $account->bic,'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, "PRELEVEMENT_BIC", $account->bic,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
$res = dolibarr_set_const($db, "PRELEVEMENT_RAISON_SOCIALE", $account->proprio,'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, "PRELEVEMENT_RAISON_SOCIALE", $account->proprio,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
} }
else $error++;
if (! $res > 0) $error++;
if (! $error) if (! $error)
{ {
$db->commit();
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>"; $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
} }
else else
{ {
$db->rollback();
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>"; $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
} }
} }

View File

@ -78,7 +78,7 @@ if ($action == 'setbankorder')
* view * view
*/ */
llxHeader("",$langs->trans("BankSetupModule")); llxHeader("","");
$html=new Form($db); $html=new Form($db);
@ -144,8 +144,7 @@ $bankorder[1][2]='BankCode DeskCode BankAccountNumberKey AccountNumber';
$var = true; $var = true;
$i=0; $i=0;
$nbofbank=count($bankorder); while ($i < sizeof($bankorder))
while ($i < $nbofbank)
{ {
$var = !$var; $var = !$var;
@ -175,11 +174,11 @@ while ($i < $nbofbank)
print '</a></td>'; print '</a></td>';
} }
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</tr>'."\n"; print "</tr>\n";
$i++; $i++;
} }
print '</table>'."\n"; print "</table>\n";
dol_htmloutput_mesg($mesg); dol_htmloutput_mesg($mesg);