From 3684b57153df920daa85752a6d3ff3fa58e21bd1 Mon Sep 17 00:00:00 2001 From: evarisk-kilyan Date: Thu, 17 Oct 2024 17:02:59 +0200 Subject: [PATCH] #322 [Dashboard] add: name on graph --- class/easycrmdashboard.class.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/class/easycrmdashboard.class.php b/class/easycrmdashboard.class.php index a0cfddc..bbd1718 100644 --- a/class/easycrmdashboard.class.php +++ b/class/easycrmdashboard.class.php @@ -49,10 +49,22 @@ public function __construct(DoliDB $db) */ public function load_dashboard(): array { - $statusCommRepartition = self::getDataFromExtrafieldsAndDictionary('PropalStatusCommRepartition', 'c_commercial_status'); - $refusalReasonRepartition = self::getDataFromExtrafieldsAndDictionary('PropalRefusalReasonRepartition', 'c_refusal_reason', 'commrefusal'); - - $array['propal']['graphs'] = [$statusCommRepartition, $refusalReasonRepartition]; + global $user, $langs; + + $confName = 'EASYCRM_DASHBOARD_CONFIG'; + $dashboardConfig = json_decode($user->conf->$confName); + $array = ['propal' => ['graphs' => [], 'disabledGraphs' => []]]; + + if (empty($dashboardConfig->graphs->PropalStatusCommRepartition->hide)) { + $array['propal']['graphs'][] = self::getDataFromExtrafieldsAndDictionary('PropalStatusCommRepartition', 'c_commercial_status'); + } else { + $array['propal']['disabledGraphs']['PropalStatusCommRepartition'] = $langs->transnoentities('PropalStatusCommRepartition'); + } + if (empty($dashboardConfig->graphs->PropalRefusalReasonRepartition->hide)) { + $array['propal']['graphs'][] = self::getDataFromExtrafieldsAndDictionary('PropalRefusalReasonRepartition', 'c_refusal_reason', 'commrefusal'); + } else { + $array['propal']['disabledGraphs']['PropalRefusalReasonRepartition'] = $langs->transnoentities('PropalRefusalReasonRepartition'); + } return $array; } @@ -77,6 +89,7 @@ public function getDataFromExtrafieldsAndDictionary(string $title, string $dicti // Graph Title parameters. $array['title'] = $langs->transnoentities($title); + $array['name'] = $title; $array['picto'] = $class; // Graph parameters.