From dcde7773a3e788772dd4eab1208fd45c1db77fc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 2 Mar 2016 11:04:52 +0100 Subject: [PATCH] Started using Account TYPE and STATUS constants --- htdocs/compta/bank/card.php | 6 +++--- htdocs/compta/bank/class/account.class.php | 17 ++++++++++++++--- .../societe/class/companybankaccount.class.php | 4 +--- htdocs/user/class/userbankaccount.class.php | 4 +--- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index cccf16f0467..12dfe51ab59 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -302,7 +302,7 @@ if ($action == 'create') // Status print ''.$langs->trans("Status").''; print ''; - print $form->selectarray("clos",array(0=>$account->status[0],1=>$account->status[1]),(isset($_POST["clos"])?$_POST["clos"]:$account->clos)); + print $form->selectarray("clos", $account->status,(isset($_POST["clos"])?$_POST["clos"]:$account->clos)); print ''; // Country @@ -643,7 +643,7 @@ else print '
'; - if ($account->type == 0 || $account->type == 1) + if ($account->type == Account::TYPE_SAVINGS || $account->type == Account::TYPE_CURRENT) { print ''; @@ -861,7 +861,7 @@ else // Status print ''; print ''; // Country diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index a5e108a2c96..ca6ad0c37ce 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -139,7 +139,19 @@ class Account extends CommonObject public $state_code; public $state; - public $type_lib=array(); + /** + * Variable containing all account types with their respective translated label. + * Defined in __construct + * @var array + */ + public $type_lib = array(); + + /** + * Variable containing all account statuses with their respective translated label. + * Defined in __construct + * @var array + */ + public $status = array(); /** * Accountancy code @@ -205,7 +217,6 @@ class Account extends CommonObject $this->db = $db; - $this->clos = 0; $this->solde = 0; $this->type_lib = array( @@ -1230,7 +1241,7 @@ class Account extends CommonObject $this->label = 'My Bank account'; $this->bank = 'MyBank'; $this->courant = 1; - $this->clos = 0; + $this->clos = Account::STATUS_OPEN; $this->code_banque = '123'; $this->code_guichet = '456'; $this->number = 'ABC12345'; diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 3924e8a9174..f71b04b7730 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -46,16 +46,14 @@ class CompanyBankAccount extends Account * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct(DoliDB $db) { $this->db = $db; $this->socid = 0; - $this->clos = 0; $this->solde = 0; $this->error_number = 0; $this->default_rib = 0; - return 1; } diff --git a/htdocs/user/class/userbankaccount.class.php b/htdocs/user/class/userbankaccount.class.php index 30c795bbd72..a91d064c7f8 100644 --- a/htdocs/user/class/userbankaccount.class.php +++ b/htdocs/user/class/userbankaccount.class.php @@ -44,15 +44,13 @@ class UserBankAccount extends Account * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct(DoliDB $db) { $this->db = $db; $this->socid = 0; - $this->clos = 0; $this->solde = 0; $this->error_number = 0; - return 1; }
'.$langs->trans("Status").''; - print $form->selectarray("clos",array(0=>$account->status[0],1=>$account->status[1]),(isset($_POST["clos"])?$_POST["clos"]:$account->clos)); + print $form->selectarray("clos", $account->status,(isset($_POST["clos"])?$_POST["clos"]:$account->clos)); print '