From b0a1d8058fb0c8a49323028ea945330cd558b79d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 12 Feb 2023 23:28:14 +0100 Subject: [PATCH] clean code --- htdocs/compta/bank/class/account.class.php | 43 ++++++++-------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 7032f9c40e2..4ccdf93cb58 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1417,6 +1417,7 @@ class Account extends CommonObject $datas = []; + $nofetch = empty($params['nofetch']) ? false : true; $pictos = img_picto('', $this->picto).' '.$langs->trans("BankAccount").''; if (isset($this->status)) { $pictos .= ' '.$this->getLibStatut(5); @@ -1434,6 +1435,12 @@ class Account extends CommonObject $datas['accountaccounting'] = '
'.$langs->trans('AccountAccounting').': '.length_accountg($this->account_number); $datas['accountancyjournal'] = '
'.$langs->trans('AccountancyJournal').': '.$this->accountancy_journal; } + // show categories for this record only in ajax to not overload lists + if (isModEnabled('categorie') && !$nofetch) { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $form = new Form($this->db); + $datas['categories'] = '
' . $form->showCategories($this->id, Categorie::TYPE_ACCOUNT, 1); + } return $datas; } @@ -1454,38 +1461,20 @@ class Account extends CommonObject include_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; $result = ''; - $label = img_picto('', $this->picto).' '.$langs->trans("BankAccount").''; - if (isset($this->status)) { - $label .= ' '.$this->getLibStatut(5); - } - $label .= '
'.$langs->trans('Label').': '.$this->label; - $label .= '
'.$langs->trans('AccountNumber').': '.$this->number; - $label .= '
'.$langs->trans('IBAN').': '.getIbanHumanReadable($this); - $label .= '
'.$langs->trans('BIC').': '.$this->bic; - $label .= '
'.$langs->trans("AccountCurrency").': '.$this->currency_code; - - if (empty($user->rights->banque->lire) || !empty($user->socid)) { - $option = 'nolink'; - } - - if (isModEnabled('accounting')) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $langs->load("accountancy"); - $label .= '
'.$langs->trans('AccountAccounting').': '.length_accountg($this->account_number); - $label .= '
'.$langs->trans('AccountancyJournal').': '.$this->accountancy_journal; - } $classfortooltip = 'classfortooltip'; $dataparams = ''; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + 'nofetch' => 1, + ]; if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - $params = [ - 'id' => $this->id, - 'objecttype' => $this->element, - 'option' => $option, - ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); } + $label = implode($this->getTooltipContentArray($params)); + $linkclose = '"'.$dataparams.' title="'.dol_escape_htmltag($label, 1).'" class="'.$classfortooltip.'">'; $url = DOL_URL_ROOT.'/compta/bank/card.php?id='.$this->id; @@ -1871,7 +1860,7 @@ class Account extends CommonObject /** * Class to manage bank transaction lines */ -class AccountLine extends CommonObject +class AccountLine extends CommonObjectLine { /** * @var string Error code (or message)