Uniformize code

This commit is contained in:
Juanjo Menent 2011-09-02 12:51:12 +00:00
parent b81579a2ef
commit 5f2daf5867
2 changed files with 46 additions and 22 deletions

View File

@ -31,18 +31,18 @@ require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php");
$langs->load("admin"); $langs->load("admin");
$langs->load("withdrawals"); $langs->load("withdrawals");
$langs->load("bills");
$langs->load("other");
// Security check // Security check
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
if ($_GET["action"] == "set") $action = GETPOST("action");
if ($action == "set")
{ {
for ($i = 0 ; $i < 2 ; $i++) for ($i = 0 ; $i < 2 ; $i++)
{ {
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);
} }
$id=$_POST["PRELEVEMENT_ID_BANKACCOUNT"]; $id=$_POST["PRELEVEMENT_ID_BANKACCOUNT"];
@ -50,21 +50,29 @@ if ($_GET["action"] == "set")
if($account->fetch($id)>0) if($account->fetch($id)>0)
{ {
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);
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);
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);
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);
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);
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);
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);
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);
} }
Header("Location: prelevement.php"); if (! $res > 0) $error++;
exit;
if (! $error)
{
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
} }
if ($_GET["action"] == "addnotif") if ($action == "addnotif")
{ {
$bon = new BonPrelevement($db); $bon = new BonPrelevement($db);
$bon->AddNotification($db,$_POST["user"],$_POST["action"]); $bon->AddNotification($db,$_POST["user"],$_POST["action"]);
@ -73,7 +81,7 @@ if ($_GET["action"] == "addnotif")
exit; exit;
} }
if ($_GET["action"] == "deletenotif") if ($action == "deletenotif")
{ {
$bon = new BonPrelevement($db); $bon = new BonPrelevement($db);
$bon->DeleteNotificationById($_GET["notif"]); $bon->DeleteNotificationById($_GET["notif"]);
@ -242,6 +250,8 @@ if ($resql)
print '</table>'; print '</table>';
print '</form>'; print '</form>';
dol_htmloutput_mesg($mesg);
$db->close(); $db->close();
llxFooter(); llxFooter();

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -36,20 +36,32 @@ $langs->load("banks");
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
$typeconst=array('yesno','texte','chaine'); $action = GETPOST("action");
/* /*
* Actions * Actions
*/ */
if ($_POST["action"] == 'set_BANK_CHEQUERECEIPT_FREE_TEXT') if ($action == 'set_BANK_CHEQUERECEIPT_FREE_TEXT')
{ {
dolibarr_set_const($db, "BANK_CHEQUERECEIPT_FREE_TEXT",$_POST["BANK_CHEQUERECEIPT_FREE_TEXT"],'chaine',0,'',$conf->entity); $free = GETPOST("BANK_CHEQUERECEIPT_FREE_TEXT");
$res = dolibarr_set_const($db, "BANK_CHEQUERECEIPT_FREE_TEXT",$free,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
} }
//Order display of bank account //Order display of bank account
if ($_GET["action"] == 'setbankorder') if ($action == 'setbankorder')
{ {
if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION",$_GET["value"],'chaine',0,'',$conf->entity) > 0) if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION",$_GET["value"],'chaine',0,'',$conf->entity) > 0)
{ {
@ -168,6 +180,8 @@ while ($i < sizeof($bankorder))
print "</table>\n"; print "</table>\n";
dol_htmloutput_mesg($mesg);
$db->close(); $db->close();
llxFooter(); llxFooter();