diff --git a/class/control.class.php b/class/control.class.php index 6ccd52d5..8a6287b4 100644 --- a/class/control.class.php +++ b/class/control.class.php @@ -762,13 +762,32 @@ public function initAsSpecimen() */ public function load_dashboard(): array { - $getNbControlsTagsByVerdict = $this->getNbControlsTagsByVerdict(); - $getNbControlsByVerdict = $this->getNbControlsByVerdict(); - $getNbControlsByMonth = $this->getNbControlsByMonth(); - $getControlListsByNextControl = $this->getControlListsByNextControl(); + global $user, $langs; - $array['graphs'] = [$getNbControlsTagsByVerdict, $getNbControlsByVerdict, $getNbControlsByMonth]; - $array['lists'] = [$getControlListsByNextControl]; + $confName = strtoupper($this->module) . '_DASHBOARD_CONFIG'; + $dashboardConfig = json_decode($user->conf->$confName); + $array = ['graphs' => [], 'lists' => [], 'disabledGraphs' => []]; + + if (empty($dashboardConfig->graphs->ControlsTagsRepartition->hide)) { + $array['graphs'][] = $this->getNbControlsTagsByVerdict(); + } else { + $array['disabledGraphs']['ControlsTagsRepartition'] = $langs->transnoentities('ControlsTagsRepartition'); + } + if (empty($dashboardConfig->graphs->ControlsRepartition->hide)) { + $array['graphs'][] = $this->getNbControlsByVerdict(); + } else { + $array['disabledGraphs']['ControlsRepartition'] = $langs->transnoentities('ControlsRepartition'); + } + if (empty($dashboardConfig->graphs->ControlsByFiscalYear->hide)) { + $array['graphs'][] = $this->getNbControlsByMonth(); + } else { + $array['disabledGraphs']['ControlsByFiscalYear'] = $langs->transnoentities('ControlsByFiscalYear'); + } + if (empty($dashboardConfig->graphs->ControlListsByNextControl->hide)) { + $array['lists'][] = $this->getControlListsByNextControl(); + } else { + $array['disabledGraphs']['ControlListsByNextControl'] = $langs->transnoentities('ControlListsByNextControl'); + } return $array; } @@ -785,6 +804,7 @@ public function getNbControlsByVerdict(): array // Graph Title parameters. $array['title'] = $langs->transnoentities('ControlsRepartition'); + $array['name'] = 'ControlsRepartition'; $array['picto'] = $this->picto; // Graph parameters. @@ -842,6 +862,7 @@ public function getNbControlsTagsByVerdict(): array // Graph Title parameters. $array['title'] = $langs->transnoentities('ControlsTagsRepartition'); + $array['name'] = 'ControlsTagsRepartition'; $array['picto'] = $this->picto; // Graph parameters. @@ -902,6 +923,7 @@ public function getNbControlsByMonth(): array // Graph Title parameters. $array['title'] = $langs->transnoentities('ControlsByFiscalYear'); + $array['name'] = 'ControlsByFiscalYear'; $array['picto'] = $this->picto; // Graph parameters. @@ -957,6 +979,7 @@ public function getControlListsByNextControl(): array // Graph Title parameters. $array['title'] = $langs->transnoentities('ControlListsByNextControl'); + $array['name'] = 'ControlListsByNextControl'; $array['picto'] = $this->picto; // Graph parameters. diff --git a/class/survey.class.php b/class/survey.class.php index 406acd29..3be9e225 100644 --- a/class/survey.class.php +++ b/class/survey.class.php @@ -500,9 +500,17 @@ public function initAsSpecimen() */ public function load_dashboard(): array { - $getNbSurveysByMonth = $this->getNbSurveysByMonth(); + global $user, $langs; - $array['graphs'] = [$getNbSurveysByMonth]; + $confName = strtoupper($this->module) . '_DASHBOARD_CONFIG'; + $dashboardConfig = json_decode($user->conf->$confName); + $array = ['graphs' => [], 'disabledGraphs' => []]; + + if (empty($dashboardConfig->graphs->SurveysByFiscalYear->hide)) { + $array['graphs'][] = $this->getNbSurveysByMonth(); + } else { + $array['disabledGraphs']['SurveysByFiscalYear'] = $langs->transnoentities('SurveysByFiscalYear'); + } return $array; } @@ -523,6 +531,7 @@ public function getNbSurveysByMonth(): array // Graph Title parameters $array['title'] = $langs->transnoentities('SurveysByFiscalYear'); + $array['name'] = 'SurveysByFiscalYear'; $array['picto'] = $this->picto; // Graph parameters