Merge pull request #4738 from marcosgdf/account-libstatut
Refactored Account::libStatut and added object typehinting to some functions of Account class
This commit is contained in:
commit
21bf8824b9
@ -365,7 +365,7 @@ class Account extends CommonObject
|
||||
* @param string $banque Bank of cheque writer
|
||||
* @return int Rowid of added entry, <0 if KO
|
||||
*/
|
||||
function addline($date, $oper, $label, $amount, $num_chq, $categorie, $user, $emetteur='',$banque='')
|
||||
function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='')
|
||||
{
|
||||
// Deprecatîon warning
|
||||
if (is_numeric($oper)) {
|
||||
@ -480,7 +480,7 @@ class Account extends CommonObject
|
||||
* @param User $user Object user making creation
|
||||
* @return int < 0 if KO, > 0 if OK
|
||||
*/
|
||||
function create($user='')
|
||||
function create(User $user = null)
|
||||
{
|
||||
global $langs,$conf, $hookmanager;
|
||||
|
||||
@ -640,7 +640,7 @@ class Account extends CommonObject
|
||||
* @param User $user Object user making action
|
||||
* @return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function update($user='')
|
||||
function update(User $user = null)
|
||||
{
|
||||
global $langs,$conf, $hookmanager;
|
||||
|
||||
@ -738,7 +738,7 @@ class Account extends CommonObject
|
||||
* @param User $user Object user making update
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function update_bban($user='')
|
||||
function update_bban(User $user = null)
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
@ -896,7 +896,7 @@ class Account extends CommonObject
|
||||
* @param User $user User deleting
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function delete($user='')
|
||||
function delete(User $user = null)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -946,42 +946,32 @@ class Account extends CommonObject
|
||||
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
|
||||
* @return string Libelle du statut
|
||||
*/
|
||||
function LibStatut($statut,$mode=0)
|
||||
{
|
||||
global $langs;
|
||||
$langs->load('banks');
|
||||
public function LibStatut($statut, $mode = 0)
|
||||
{
|
||||
global $langs;
|
||||
$langs->load('banks');
|
||||
|
||||
if ($mode == 0)
|
||||
{
|
||||
if ($statut==0) return $langs->trans("StatusAccountOpened");
|
||||
if ($statut==1) return $langs->trans("StatusAccountClosed");
|
||||
}
|
||||
if ($mode == 1)
|
||||
{
|
||||
if ($statut==0) return $langs->trans("StatusAccountOpened");
|
||||
if ($statut==1) return $langs->trans("StatusAccountClosed");
|
||||
}
|
||||
if ($mode == 2)
|
||||
{
|
||||
if ($statut==0) return img_picto($langs->trans("StatusAccountOpened"),'statut4').' '.$langs->trans("StatusAccountOpened");
|
||||
if ($statut==1) return img_picto($langs->trans("StatusAccountClosed"),'statut5').' '.$langs->trans("StatusAccountClosed");
|
||||
}
|
||||
if ($mode == 3)
|
||||
{
|
||||
if ($statut==0) return img_picto($langs->trans("StatusAccountOpened"),'statut4');
|
||||
if ($statut==1) return img_picto($langs->trans("StatusAccountClosed"),'statut5');
|
||||
}
|
||||
if ($mode == 4)
|
||||
{
|
||||
if ($statut==0) return img_picto($langs->trans("StatusAccountOpened"),'statut4').' '.$langs->trans("StatusAccountOpened");
|
||||
if ($statut==1) return img_picto($langs->trans("StatusAccountClosed"),'statut5').' '.$langs->trans("StatusAccountClosed");
|
||||
}
|
||||
if ($mode == 5)
|
||||
{
|
||||
if ($statut==0) return $langs->trans("StatusAccountOpened").' '.img_picto($langs->trans("StatusAccountOpened"),'statut4');
|
||||
if ($statut==1) return $langs->trans("StatusAccountClosed").' '.img_picto($langs->trans("StatusAccountClosed"),'statut5');
|
||||
}
|
||||
}
|
||||
if ($statut == self::STATUS_OPEN) {
|
||||
$label = $langs->trans("StatusAccountOpened");
|
||||
$picto = img_picto($label, 'statut4');
|
||||
} else {
|
||||
$label = $langs->trans("StatusAccountClosed");
|
||||
$picto = img_picto($label, 'statut5');
|
||||
}
|
||||
|
||||
if ($mode == 2) {
|
||||
return $picto.' '.$label;
|
||||
} elseif ($mode == 3) {
|
||||
return $picto;
|
||||
} elseif ($mode == 4) {
|
||||
return $picto.' '.$label;
|
||||
} elseif ($mode == 5) {
|
||||
return $label.' '.$picto;
|
||||
}
|
||||
|
||||
//There is no short mode for this label
|
||||
return $label;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -1052,7 +1042,7 @@ class Account extends CommonObject
|
||||
* @param int $filteraccountid To get info for a particular account id
|
||||
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
|
||||
*/
|
||||
function load_board($user,$filteraccountid=0)
|
||||
function load_board(User $user, $filteraccountid = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
@ -1332,7 +1322,7 @@ class AccountLine extends CommonObject
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
function __construct($db)
|
||||
function __construct(DoliDB $db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
@ -1419,7 +1409,7 @@ class AccountLine extends CommonObject
|
||||
* @param User $user User object that delete
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function delete($user=null)
|
||||
function delete(User $user = null)
|
||||
{
|
||||
$nbko=0;
|
||||
|
||||
@ -1468,7 +1458,7 @@ class AccountLine extends CommonObject
|
||||
* @param User $user User object that delete
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function delete_urls($user=null)
|
||||
function delete_urls(User $user = null)
|
||||
{
|
||||
$nbko=0;
|
||||
|
||||
@ -1506,7 +1496,7 @@ class AccountLine extends CommonObject
|
||||
* @param int $notrigger 0=Disable all triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function update($user,$notrigger=0)
|
||||
function update(User $user, $notrigger = 0)
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
@ -1539,7 +1529,7 @@ class AccountLine extends CommonObject
|
||||
* @param int $cat Category id
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function update_conciliation($user,$cat)
|
||||
function update_conciliation(User $user, $cat)
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user