Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3983 [RiskGraph] add: add position to order charts #3985

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion class/accident.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -446,6 +446,7 @@ public function load_dashboard(): array
]
];


evarisk-micka marked this conversation as resolved.
Show resolved Hide resolved
$array['graphs'] = [$arrayNbAccidents, $arrayNbAccidentsLast3Years];

return $array;
Expand All @@ -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)) {
Expand Down Expand Up @@ -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' => [
Expand Down Expand Up @@ -544,6 +548,7 @@ public function getNbAccidentsLast3years(): array
$array['type'] = 'bar';
$array['showlegend'] = 1;
$array['dataset'] = 3;
$array['position'] = 50;

$array['labels'] = [
'pastlastyear' => [
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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)) {
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions class/digiriskdolibarrdashboard.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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')) : [];
}
}

Expand Down
8 changes: 5 additions & 3 deletions class/digiriskelement.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);

Expand Down Expand Up @@ -597,7 +598,7 @@ public function getRisksByDigiriskElement(string $riskType = 'risk'): array
}
}
}

return $array;
}

Expand All @@ -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);
Expand All @@ -639,7 +641,7 @@ public function getDigiriskElementListsByDepth(): array
];
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Un tab en trop au lieu d'un espace vide, pareil au dessus

if (!empty($digiriskElements)) {
foreach ($digiriskElements as $digiriskElement) {
if ($digiriskElement['depth'] <= getDolGlobalInt('DIGIRISKDOLIBARR_DIGIRISKELEMENT_DEPTH_GRAPH') && $digiriskElement['object']->element_type == 'groupment') {
Expand Down
6 changes: 5 additions & 1 deletion class/evaluator.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
11 changes: 7 additions & 4 deletions class/riskanalysis/risk.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si l'ordre est géré par la position, plus besoin de changer l'ordre dans l'array ?

$array['lists'] = [$getRiskListsByDangerCategories];

return $array;
Expand Down Expand Up @@ -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']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pas besoin

$array['data'] = $riskAssessment->getRiskAssessmentCategoriesNumber($riskAssessmentList);

return $array;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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'
Expand Down
3 changes: 3 additions & 0 deletions class/ticketdashboard.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down