From 80a7b83956bc0469f971824b13d6cd778c8367e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 18 Dec 2021 23:02:31 +0100 Subject: [PATCH] Debug status of accounting account --- htdocs/accountancy/admin/card.php | 4 +- .../class/accountingaccount.class.php | 60 ++++++------------- 2 files changed, 21 insertions(+), 43 deletions(-) diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 9430bf33439..91d8257ea7f 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -417,13 +417,13 @@ if ($action == 'create') { print '
'; if (!empty($user->rights->accounting->chartofaccount)) { - print ''.$langs->trans('Modify').''; + print 'id.'">'.$langs->trans('Modify').''; } else { print ''.$langs->trans('Modify').''; } if (!empty($user->rights->accounting->chartofaccount)) { - print ''.$langs->trans('Delete').''; + print 'id.'">'.$langs->trans('Delete').''; } else { print ''.$langs->trans('Delete').''; } diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index f462ab87453..d5d04dd518c 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -153,6 +153,11 @@ class AccountingAccount extends CommonObject */ private $accountingaccount_codetotid_cache = array(); + + const STATUS_ENABLED = 1; + const STATUS_DISABLED = 0; + + /** * Constructor * @@ -691,49 +696,22 @@ class AccountingAccount extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - global $langs; - $langs->loadLangs(array("users")); - - if ($mode == 0) { - if ($status == 1) { - return $langs->trans('Enabled'); - } elseif ($status == 0) { - return $langs->trans('Disabled'); - } - } elseif ($mode == 1) { - if ($status == 1) { - return $langs->trans('Enabled'); - } elseif ($status == 0) { - return $langs->trans('Disabled'); - } - } elseif ($mode == 2) { - if ($status == 1) { - return img_picto($langs->trans('Enabled'), 'statut4') . ' ' . $langs->trans('Enabled'); - } elseif ($status == 0) { - return img_picto($langs->trans('Disabled'), 'statut5') . ' ' . $langs->trans('Disabled'); - } - } elseif ($mode == 3) { - if ($status == 1) { - return img_picto($langs->trans('Enabled'), 'statut4'); - } elseif ($status == 0) { - return img_picto($langs->trans('Disabled'), 'statut5'); - } - } elseif ($mode == 4) { - if ($status == 1) { - return img_picto($langs->trans('Enabled'), 'statut4') . ' ' . $langs->trans('Enabled'); - } elseif ($status == 0) { - return img_picto($langs->trans('Disabled'), 'statut5') . ' ' . $langs->trans('Disabled'); - } - } elseif ($mode == 5) { - if ($status == 1) { - return $langs->trans('Enabled') . ' ' . img_picto($langs->trans('Enabled'), 'statut4'); - } elseif ($status == 0) { - return $langs->trans('Disabled') . ' ' . img_picto($langs->trans('Disabled'), 'statut5'); - } + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { + global $langs; + $langs->load("users"); + $this->labelStatus[self::STATUS_ENABLED] = $langs->transnoentitiesnoconv('Enabled'); + $this->labelStatus[self::STATUS_DISABLED] = $langs->transnoentitiesnoconv('Disabled'); + $this->labelStatusShort[self::STATUS_ENABLED] = $langs->transnoentitiesnoconv('Enabled'); + $this->labelStatusShort[self::STATUS_DISABLED] = $langs->transnoentitiesnoconv('Disabled'); } - } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + $statusType = 'status4'; + if ($status == self::STATUS_DISABLED) { + $statusType = 'status5'; + } + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); + } /** * Return Suggest accounting accounts to bind