Merge pull request #4708 from marcosgdf/account-constants
Started using Account TYPE and STATUS constants
This commit is contained in:
commit
87093c79f9
@ -489,7 +489,7 @@ if ($id > 0 || ! empty($ref))
|
||||
$form->select_date($dateop,'op',0,0,0,'transaction');
|
||||
print '</td>';
|
||||
print '<td class="nowrap">';
|
||||
$form->select_types_paiements((GETPOST('operation')?GETPOST('operation'):($object->courant == 2 ? 'LIQ' : '')),'operation','1,2',2,1);
|
||||
$form->select_types_paiements((GETPOST('operation')?GETPOST('operation'):($object->courant == Account::TYPE_CASH ? 'LIQ' : '')),'operation','1,2',2,1);
|
||||
print '</td><td>';
|
||||
print '<input name="num_chq" class="flat" type="text" size="4" value="'.GETPOST("num_chq").'"></td>';
|
||||
print '<td colspan="2">';
|
||||
|
||||
@ -302,7 +302,7 @@ if ($action == 'create')
|
||||
// Status
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
|
||||
print '<td colspan="3">';
|
||||
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 '</td></tr>';
|
||||
|
||||
// Country
|
||||
@ -643,7 +643,7 @@ else
|
||||
|
||||
print '<br>';
|
||||
|
||||
if ($account->type == 0 || $account->type == 1)
|
||||
if ($account->type == Account::TYPE_SAVINGS || $account->type == Account::TYPE_CURRENT)
|
||||
{
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
@ -861,7 +861,7 @@ else
|
||||
// Status
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
|
||||
print '<td colspan="3">';
|
||||
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 '</td></tr>';
|
||||
|
||||
// Country
|
||||
|
||||
@ -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(
|
||||
@ -231,7 +242,7 @@ class Account extends CommonObject
|
||||
global $conf;
|
||||
|
||||
if (empty($this->rappro)) return -1;
|
||||
if ($this->courant == 2 && empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) return -2;
|
||||
if ($this->courant == Account::TYPE_CASH && empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) return -2;
|
||||
if ($this->clos) return -3;
|
||||
return 1;
|
||||
}
|
||||
@ -388,7 +399,7 @@ class Account extends CommonObject
|
||||
$this->error="this->rowid not defined";
|
||||
return -2;
|
||||
}
|
||||
if ($this->courant == 2 && $oper != 'LIQ')
|
||||
if ($this->courant == Account::TYPE_CASH && $oper != 'LIQ')
|
||||
{
|
||||
$this->error="ErrorCashAccountAcceptsOnlyCashMoney";
|
||||
return -3;
|
||||
@ -1229,8 +1240,8 @@ class Account extends CommonObject
|
||||
$this->ref = 'MBA';
|
||||
$this->label = 'My Bank account';
|
||||
$this->bank = 'MyBank';
|
||||
$this->courant = 1;
|
||||
$this->clos = 0;
|
||||
$this->courant = Account::TYPE_CURRENT;
|
||||
$this->clos = Account::STATUS_OPEN;
|
||||
$this->code_banque = '123';
|
||||
$this->code_guichet = '456';
|
||||
$this->number = 'ABC12345';
|
||||
|
||||
@ -102,7 +102,7 @@ if ($user->rights->banque->modifier && $action == "update")
|
||||
$ac = new Account($db);
|
||||
$ac->fetch($id);
|
||||
|
||||
if ($ac->courant == 2 && $_POST['value'] != 'LIQ')
|
||||
if ($ac->courant == Account::TYPE_CASH && $_POST['value'] != 'LIQ')
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorCashAccountAcceptsOnlyCashMoney"), null, 'errors');
|
||||
$error++;
|
||||
|
||||
@ -93,7 +93,7 @@ if ($action == 'add')
|
||||
// By default, electronic transfert from bank to bank
|
||||
$typefrom='PRE';
|
||||
$typeto='VIR';
|
||||
if ($accountto->courant == 2 || $accountfrom->courant == 2)
|
||||
if ($accountto->courant == Account::TYPE_CASH || $accountfrom->courant == Account::TYPE_CASH)
|
||||
{
|
||||
// This is transfert of change
|
||||
$typefrom='LIQ';
|
||||
|
||||
@ -49,32 +49,11 @@ class FormBank
|
||||
* @param string $htmlname Nom champ formulaire
|
||||
* @return void
|
||||
*/
|
||||
function select_type_comptes_financiers($selected=1,$htmlname='type')
|
||||
public function select_type_comptes_financiers($selected = Account::TYPE_CURRENT, $htmlname = 'type')
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("banks");
|
||||
$account = new Account($this->db);
|
||||
|
||||
$type_available=array(0,1,2);
|
||||
|
||||
print '<select id="select'.$htmlname.'" class="flat" name="'.$htmlname.'">';
|
||||
$num = count($type_available);
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
if ($selected == $type_available[$i])
|
||||
{
|
||||
print '<option value="'.$type_available[$i].'" selected>'.$langs->trans("BankType".$type_available[$i]).'</option>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<option value="'.$type_available[$i].'">'.$langs->trans("BankType".$type_available[$i]).'</option>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
print '</select>';
|
||||
print Form::selectarray($htmlname, $account->type_lib, $selected);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ function bank_prepare_head(Account $object)
|
||||
$head[$h][2] = 'graph';
|
||||
$h++;
|
||||
|
||||
if ($object->courant != 2)
|
||||
if ($object->courant != Account::TYPE_CASH)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/compta/bank/releve.php?account=".$object->id;
|
||||
$head[$h][1] = $langs->trans("AccountStatements");
|
||||
|
||||
@ -281,7 +281,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
$newmenu->add('/compta/bank/card.php?id='.$objp->rowid,$objp->label,1,$user->rights->banque->lire);
|
||||
if ($objp->rappro && $objp->courant != 2 && empty($objp->clos)) // If not cash account and not closed and can be reconciliate
|
||||
if ($objp->rappro && $objp->courant != Account::TYPE_CASH && empty($objp->clos)) // If not cash account and not closed and can be reconciliate
|
||||
{
|
||||
$newmenu->add('/compta/bank/rappro.php?account='.$objp->rowid,$langs->trans("Conciliate"),2,$user->rights->banque->consolidate);
|
||||
}
|
||||
|
||||
@ -1342,7 +1342,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
$newmenu->add('/compta/bank/card.php?id='.$objp->rowid,$objp->label,1,$user->rights->banque->lire);
|
||||
if ($objp->rappro && $objp->courant != 2 && empty($objp->clos)) // If not cash account and not closed and can be reconciliate
|
||||
if ($objp->rappro && $objp->courant != Account::TYPE_CASH && empty($objp->clos)) // If not cash account and not closed and can be reconciliate
|
||||
{
|
||||
$newmenu->add('/compta/bank/rappro.php?account='.$objp->rowid,$langs->trans("Conciliate"),2,$user->rights->banque->consolidate);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user