Skip to content

Commit

Permalink
Uniformize code
Browse files Browse the repository at this point in the history
  • Loading branch information
Juanjo Menent committed Sep 2, 2011
1 parent b81579a commit 5f2daf5
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 22 deletions.
42 changes: 26 additions & 16 deletions htdocs/admin/prelevement.php
Expand Up @@ -31,40 +31,48 @@

$langs->load("admin");
$langs->load("withdrawals");
$langs->load("bills");
$langs->load("other");

// Security check
if (!$user->admin)
accessforbidden();

if ($_GET["action"] == "set")
$action = GETPOST("action");

if ($action == "set")
{
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"];
$account = new Account($db, $id);

if($account->fetch($id)>0)
{
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);
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);
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);
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_ID_BANKACCOUNT", $id,'chaine',0,'',$conf->entity);
$res = dolibarr_set_const($db, "PRELEVEMENT_CODE_BANQUE", $account->code_banque,'chaine',0,'',$conf->entity);
$res = dolibarr_set_const($db, "PRELEVEMENT_CODE_GUICHET", $account->code_guichet,'chaine',0,'',$conf->entity);
$res = dolibarr_set_const($db, "PRELEVEMENT_NUMERO_COMPTE", $account->number,'chaine',0,'',$conf->entity);
$res = dolibarr_set_const($db, "PRELEVEMENT_NUMBER_KEY", $account->cle_rib,'chaine',0,'',$conf->entity);
$res = dolibarr_set_const($db, "PRELEVEMENT_IBAN", $account->iban,'chaine',0,'',$conf->entity);
$res = dolibarr_set_const($db, "PRELEVEMENT_BIC", $account->bic,'chaine',0,'',$conf->entity);
$res = dolibarr_set_const($db, "PRELEVEMENT_RAISON_SOCIALE", $account->proprio,'chaine',0,'',$conf->entity);
}

Header("Location: prelevement.php");
exit;
if (! $res > 0) $error++;

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->AddNotification($db,$_POST["user"],$_POST["action"]);
Expand All @@ -73,7 +81,7 @@
exit;
}

if ($_GET["action"] == "deletenotif")
if ($action == "deletenotif")
{
$bon = new BonPrelevement($db);
$bon->DeleteNotificationById($_GET["notif"]);
Expand Down Expand Up @@ -242,6 +250,8 @@
print '</table>';
print '</form>';

dol_htmloutput_mesg($mesg);

$db->close();

llxFooter();
Expand Down
26 changes: 20 additions & 6 deletions htdocs/compta/bank/admin/bank.php
@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
/* Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
*
* 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
Expand Down Expand Up @@ -36,20 +36,32 @@
if (!$user->admin)
accessforbidden();

$typeconst=array('yesno','texte','chaine');
$action = GETPOST("action");


/*
* 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
if ($_GET["action"] == 'setbankorder')
if ($action == 'setbankorder')
{
if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION",$_GET["value"],'chaine',0,'',$conf->entity) > 0)
{
Expand Down Expand Up @@ -168,6 +180,8 @@

print "</table>\n";

dol_htmloutput_mesg($mesg);

$db->close();

llxFooter();
Expand Down

0 comments on commit 5f2daf5

Please sign in to comment.