diff --git a/class/accident.class.php b/class/accident.class.php index 5fe2a74d6..dcec16316 100644 --- a/class/accident.class.php +++ b/class/accident.class.php @@ -426,7 +426,7 @@ public function load_dashboard(): array //$arrayGravityIndex = $this->getGravityIndex(); $arrayGravityRate = $this->getGravityRate(); - $array['widgets'] = [ + $array['widgets'] = [ 'accident' => [ 'label' => [$langs->transnoentities('DayWithoutAccident') ?? '', $langs->transnoentities('WorkStopDays') ?? '', $langs->transnoentities('NbAccidentsByEmployees') ?? '', $langs->transnoentities('NbPresquAccidents') ?? '', $langs->transnoentities('NbAccidentInvestigations') ?? ''], 'content' => [$arrayNbDaysWithoutAccident['daywithoutaccident'] ?? 0, $arrayNbWorkstopDays['nbworkstopdays'] ?? 0, $arrayNbAccidentsByEmployees['nbaccidentsbyemployees'] ?? 0, $arrayNbPresquAccidents['nbpresquaccidents'] ?? 0, $arrayNbAccidentInvestigations['nbaccidentinvestigations'] ?? 0], @@ -446,6 +446,7 @@ public function load_dashboard(): array ] ]; + $array['graphs'] = [$arrayNbAccidents, $arrayNbAccidentsLast3Years]; return $array; @@ -458,6 +459,8 @@ public function load_dashboard(): array * @throws Exception */ public function getNbDaysWithoutAccident() { + $array['position'] = 30; + // Number days without accident $lastAccident = $this->fetchAll('DESC', 'accident_date', 1, 0 ); if (is_array($lastAccident) && !empty($lastAccident)) { @@ -489,6 +492,7 @@ public function getNbAccidents(): array $array['type'] = 'pie'; $array['showlegend'] = $conf->browser->layout == 'phone' ? 1 : 2; $array['dataset'] = 1; + $array['position'] = 40; $array['labels'] = [ 'accidents' => [ @@ -544,6 +548,7 @@ public function getNbAccidentsLast3years(): array $array['type'] = 'bar'; $array['showlegend'] = 1; $array['dataset'] = 3; + $array['position'] = 50; $array['labels'] = [ 'pastlastyear' => [ @@ -600,6 +605,8 @@ public function getNbAccidentsLast3years(): array * @throws Exception */ public function getNbWorkstopDays() { + $array['position'] = 60; + // Number workstop days $allaccidents = $this->fetchAll(); if (is_array($allaccidents) && !empty($allaccidents)) { @@ -630,6 +637,8 @@ public function getNbWorkstopDays() { public function getNbAccidentsByEmployees() { $evaluator = new Evaluator($this->db); + $array['position'] = 70; + // Number accidents by employees $arrayNbAccidents = $this->getNbAccidents(); $arrayNbEmployees = $evaluator->getNbEmployees(); @@ -657,6 +666,8 @@ public function getNbPresquAccidents() { $category = new Categorie($this->db); + $array['position'] = 80; + // Number accidents presqu'accidents $category->fetch(0, $langs->transnoentities('PresquAccident')); $alltickets = $category->getObjectsInCateg(Categorie::TYPE_TICKET); @@ -675,6 +686,8 @@ public function getNbPresquAccidents() { * @throws Exception */ public function getNbAccidentInvestigations() { + $array['position'] = 90; + // Number accident investigations $allaccidents = $this->fetchAll(); if (is_array($allaccidents) && !empty($allaccidents)) { @@ -706,6 +719,8 @@ public function getNbAccidentInvestigations() { public function getFrequencyIndex() { $evaluator = new Evaluator($this->db); + $array['position'] = 100; + // (Number accidents with DIAT by employees) x 1 000 $arrayNbAccidents = $this->getNbAccidents(); $arrayNbEmployees = $evaluator->getNbEmployees(); @@ -729,6 +744,8 @@ public function getFrequencyIndex() { * @throws Exception */ public function getFrequencyRate() { + $array['position'] = 110; + // (Number accidents with DIAT by working hours) x 1 000 000 $arrayNbAccidents = $this->getNbAccidents(); $total_workhours = getWorkedHours(); @@ -753,6 +770,8 @@ public function getFrequencyRate() { * @throws Exception */ public function getGravityRate() { + $array['position'] = 120; + // (Number workstop days by working hours) x 1 000 $arrayNbWorkstopDays = $this->getNbWorkstopDays(); $total_workhours = getWorkedHours(); diff --git a/class/digiriskdolibarrdashboard.class.php b/class/digiriskdolibarrdashboard.class.php index f399880b9..eee1d8124 100644 --- a/class/digiriskdolibarrdashboard.class.php +++ b/class/digiriskdolibarrdashboard.class.php @@ -52,12 +52,12 @@ public function load_dashboard(array $moreParams = []): array { $dashboardDatas = [ ['type' => 'RiskAssessmentDocument', 'classPath' => '/digiriskdolibarrdocuments/riskassessmentdocument.class.php'], + ['type' => 'Risk', 'classPath' => '/riskanalysis/risk.class.php'], + ['type' => 'DigiriskElement', 'classPath' => '/digiriskelement.class.php'], ['type' => 'Accident', 'classPath' => '/accident.class.php'], ['type' => 'Evaluator', 'classPath' => '/evaluator.class.php'], ['type' => 'DigiriskResources', 'classPath' => '/digiriskresources.class.php'], - ['type' => 'DigiriskElement', 'classPath' => '/digiriskelement.class.php'], ['type' => 'SaturneTask', 'classPath' => '/../../saturne/class/task/saturnetask.class.php'], - ['type' => 'Risk', 'classPath' => '/riskanalysis/risk.class.php'], ['type' => 'TicketDashboard', 'classPath' => '/ticketdashboard.class.php'] ]; foreach ($dashboardDatas as $dashboardData) { @@ -68,9 +68,9 @@ public function load_dashboard(array $moreParams = []): array $className = new TicketDashboard($this->db, $moreParams['join'], $moreParams['where']); } if ($dashboardData['type'] != 'SaturneTask') { - $array[$dashboardData['type']] = array_key_exists('Load' . $dashboardData['type'], $moreParams) ? $className->load_dashboard() : []; + $array[dol_strtolower($dashboardData['type'])] = array_key_exists('Load' . $dashboardData['type'], $moreParams) ? $className->load_dashboard() : []; } else { - $array[$dashboardData['type']] = array_key_exists('Load' . $dashboardData['type'], $moreParams) ? $className->load_dashboard(getDolGlobalInt('DIGIRISKDOLIBARR_DU_PROJECT')) : []; + $array[dol_strtolower($dashboardData['type'])] = array_key_exists('Load' . $dashboardData['type'], $moreParams) ? $className->load_dashboard(getDolGlobalInt('DIGIRISKDOLIBARR_DU_PROJECT')) : []; } } diff --git a/class/digiriskelement.class.php b/class/digiriskelement.class.php index d653a6145..e7c6555b6 100644 --- a/class/digiriskelement.class.php +++ b/class/digiriskelement.class.php @@ -542,7 +542,7 @@ public function load_dashboard(): array $getDigiriskElementListsByDepth = $this->getDigiriskElementListsByDepth(); $getRisksByDigiriskElement = $this->getRisksByDigiriskElement(); - $array['graphs'] = [$getDigiriskElementListsByDepth, $getRisksByDigiriskElement]; + $array['graphs'] = [$getRisksByDigiriskElement, $getDigiriskElementListsByDepth]; return $array; } @@ -569,6 +569,7 @@ public function getRisksByDigiriskElement(string $riskType = 'risk'): array $array['type'] = 'pie'; $array['showlegend'] = $conf->browser->layout == 'phone' ? 1 : 2; $array['dataset'] = 1; + $array['position'] = 1; $digiriskElements = $this->fetchDigiriskElementFlat(GETPOSTISSET('id') ? GETPOST('id') : 0); @@ -597,7 +598,7 @@ public function getRisksByDigiriskElement(string $riskType = 'risk'): array } } } - + return $array; } @@ -621,6 +622,7 @@ public function getDigiriskElementListsByDepth(): array $array['type'] = 'pie'; $array['showlegend'] = $conf->browser->layout == 'phone' ? 1 : 2; $array['dataset'] = 1; + $array['position'] = 20; $children = []; $digiriskElements = $this->fetchDigiriskElementFlat(GETPOSTISSET('id') ? GETPOST('id') : 0); @@ -639,7 +641,7 @@ public function getDigiriskElementListsByDepth(): array ]; } } - + if (!empty($digiriskElements)) { foreach ($digiriskElements as $digiriskElement) { if ($digiriskElement['depth'] <= getDolGlobalInt('DIGIRISKDOLIBARR_DIGIRISKELEMENT_DEPTH_GRAPH') && $digiriskElement['object']->element_type == 'groupment') { diff --git a/class/evaluator.class.php b/class/evaluator.class.php index 949f358af..61ca55b49 100644 --- a/class/evaluator.class.php +++ b/class/evaluator.class.php @@ -160,7 +160,9 @@ public function load_dashboard(): array * @throws Exception */ public function getNbEmployeesInvolved() { - // Number employees involved + $array['position'] = 130; + + // Number employees involved $allevaluators = $this->fetchAll('','', 0, 0, array(), 'AND', 'fk_user'); if (is_array($allevaluators) && !empty($allevaluators)) { $array['nbemployeesinvolved'] = count($allevaluators); @@ -179,6 +181,8 @@ public function getNbEmployeesInvolved() { public function getNbEmployees() { global $conf; + $array['position'] = 140; + // Number employees if ($conf->global->DIGIRISKDOLIBARR_NB_EMPLOYEES > 0 && $conf->global->DIGIRISKDOLIBARR_MANUAL_INPUT_NB_EMPLOYEES) { $array['nbemployees'] = $conf->global->DIGIRISKDOLIBARR_NB_EMPLOYEES; diff --git a/class/riskanalysis/risk.class.php b/class/riskanalysis/risk.class.php index f00ac2c11..802facabc 100644 --- a/class/riskanalysis/risk.class.php +++ b/class/riskanalysis/risk.class.php @@ -573,8 +573,8 @@ public function load_dashboard(): array $getRisksByDangerCategoriesAndCriticality = $this->getRisksByDangerCategoriesAndCriticality($dangerCategories); $getRisksByDangerCategories = $this->getRisksByDangerCategories($dangerCategories); $getRiskListsByDangerCategories = $this->getRiskListsByDangerCategories($dangerCategories); - - $array['graphs'] = [$getRisksByCotation, $getRisksByDangerCategoriesAndCriticality, $getRisksByDangerCategories]; + + $array['graphs'] = [$getRisksByDangerCategoriesAndCriticality, $getRisksByCotation , $getRisksByDangerCategories]; $array['lists'] = [$getRiskListsByDangerCategories]; return $array; @@ -603,8 +603,9 @@ public function getRisksByCotation(): array $array['showlegend'] = $conf->browser->layout == 'phone' ? 1 : 2; $array['dataset'] = 1; $array['labels'] = $this->cotations; + $array['position'] = 2; - $riskAssessmentList = $riskAssessment->fetchAll('', '', 0, 0, ['customsql' => 'status = 1']); + $riskAssessmentList = $riskAssessment->fetchAll('', '', 0, 0, ['customsql' => 'status > 0']); $array['data'] = $riskAssessment->getRiskAssessmentCategoriesNumber($riskAssessmentList); return $array; @@ -635,6 +636,7 @@ public function getRisksByDangerCategoriesAndCriticality(array $dangerCategories $array['dataset'] = 4; $array['moreCSS'] = 'grid-2'; $array['labels'] = $this->cotations; + $array['position'] = 0; $join = ' LEFT JOIN ' . MAIN_DB_PREFIX . $this->table_element . ' as r ON r.rowid = t.fk_risk'; foreach ($dangerCategories as $dangerCategory) { @@ -674,8 +676,9 @@ public function getRisksByDangerCategories(array $dangerCategories, string $type $array['showlegend'] = 1; $array['dataset'] = 2; $array['moreCSS'] = 'grid-2'; + $array['position'] = 10; - $array['labels'] = [ + $array['labels'] = [ 0 => [ 'label' => $langs->transnoentities('NumberOfRisks'), 'color' => '#A1467E' diff --git a/class/ticketdashboard.class.php b/class/ticketdashboard.class.php index e16723195..b8d2bca62 100644 --- a/class/ticketdashboard.class.php +++ b/class/ticketdashboard.class.php @@ -304,6 +304,7 @@ public function getTicketsByMonth(): array $array['showlegend'] = 1; $array['dataset'] = 2; $array['moreCSS'] = 'grid-2'; + $array['position'] = 160; $dateStart = dol_mktime(0, 0, 0, GETPOST('dateStartmonth', 'int'), GETPOST('dateStartday', 'int'), GETPOST('dateStartyear', 'int')); $dateEnd = dol_mktime(23, 59, 59, GETPOST('dateEndmonth', 'int'), GETPOST('dateEndday', 'int'), GETPOST('dateEndyear', 'int')); @@ -361,6 +362,7 @@ public function getTicketsByMainTagAndByDigiriskElement($mainCategories): array $array['showlegend'] = 1; $array['dataset'] = 2; $array['moreCSS'] = 'grid-2'; + $array['position'] = 170; $digiriskElement = new DigiriskElement($this->db); @@ -407,6 +409,7 @@ public function getTicketsByMainSubTagAndByDigiriskElement($mainCategories): arr $array['showlegend'] = 1; $array['dataset'] = 2; $array['moreCSS'] = 'grid-2'; + $array['position'] = 180; $category = new Categorie($this->db); $digiriskElement = new DigiriskElement($this->db);