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

#3682 [LegalDisplay] add: graph on legal display #3689

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 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
34 changes: 17 additions & 17 deletions admin/socialconf.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2021-2023 EVARISK <[email protected]>
/* Copyright (C) 2021-2024 EVARISK <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -44,7 +44,7 @@
require_once __DIR__ . '/../class/digiriskresources.class.php';

// Translations
saturne_load_langs(["admin", "companies"]);
saturne_load_langs(['admin', 'companies']);

// Parameters
$action = GETPOST('action', 'aZ09');
Expand All @@ -65,12 +65,12 @@
* Actions
*/

$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
$parameters = [];
$resHook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
if ($resHook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');

if (empty($reshook)) {
if (($action == 'update' && ! GETPOST("cancel", 'alpha')) || ($action == 'updateedit')) {
if (empty($resHook)) {
if (($action == 'update' && ! GETPOST('cancel', 'alpha')) || ($action == 'updateedit')) {
$electionDateCSE = GETPOST('ElectionDateCSE', 'none');
$electionDateCSE = explode('/', $electionDateCSE);
$electionDateCSE = $electionDateCSE[2] . '-' . $electionDateCSE[1] . '-' . $electionDateCSE[0];
Expand All @@ -79,11 +79,11 @@
$electionDateDP = explode('/', $electionDateDP);
$electionDateDP = $electionDateDP[2] . '-' . $electionDateDP[1] . '-' . $electionDateDP[0];

dolibarr_set_const($db, "DIGIRISKDOLIBARR_PARTICIPATION_AGREEMENT_INFORMATION_PROCEDURE", GETPOST("modalites", 'none'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "DIGIRISKDOLIBARR_DEROGATION_SCHEDULE_PERMANENT", GETPOST("permanent", 'none'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "DIGIRISKDOLIBARR_DEROGATION_SCHEDULE_OCCASIONAL", GETPOST("occasional", 'none'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "DIGIRISKDOLIBARR_CSE_ELECTION_DATE", $electionDateCSE, 'date', 0, '', $conf->entity);
dolibarr_set_const($db, "DIGIRISKDOLIBARR_DP_ELECTION_DATE", $electionDateDP, 'date', 0, '', $conf->entity);
dolibarr_set_const($db, 'DIGIRISKDOLIBARR_PARTICIPATION_AGREEMENT_INFORMATION_PROCEDURE', GETPOST('modalites', 'none'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'DIGIRISKDOLIBARR_DEROGATION_SCHEDULE_PERMANENT', GETPOST('permanent', 'none'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'DIGIRISKDOLIBARR_DEROGATION_SCHEDULE_OCCASIONAL', GETPOST('occasional', 'none'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'DIGIRISKDOLIBARR_CSE_ELECTION_DATE', $electionDateCSE, 'date', 0, '', $conf->entity);
dolibarr_set_const($db, 'DIGIRISKDOLIBARR_DP_ELECTION_DATE', $electionDateDP, 'date', 0, '', $conf->entity);

$CSEtitulaires = ! empty(GETPOST('TitularsCSE', 'array')) ? GETPOST('TitularsCSE', 'array') : (GETPOST('TitularsCSE', 'int') > 0 ? array(GETPOST('TitularsCSE', 'int')) : array());
$CSEsuppleants = ! empty(GETPOST('AlternatesCSE', 'array')) ? GETPOST('AlternatesCSE', 'array') : (GETPOST('AlternatesCSE', 'int') > 0 ? array(GETPOST('AlternatesCSE', 'int')) : array());
Expand Down Expand Up @@ -115,13 +115,13 @@
$help_url = 'FR:Module_Digirisk#L.27onglet_Social';
$title = $langs->trans("CompanyFoundation") . ' - ' . $langs->trans("Social");

$morejs = array("/digiriskdolibarr/js/digiriskdolibarr.js");
$morecss = array("/digiriskdolibarr/css/digiriskdolibarr.css");
$morejs = array('/digiriskdolibarr/js/digiriskdolibarr.js');
$morecss = array('/digiriskdolibarr/css/digiriskdolibarr.css');

$counter = 0;

$socialResources = array("TitularsCSE", "AlternatesCSE", "TitularsDP", "AlternatesDP");
$socialConsts = array("DIGIRISKDOLIBARR_PARTICIPATION_AGREEMENT_INFORMATION_PROCEDURE", "DIGIRISKDOLIBARR_DEROGATION_SCHEDULE_PERMANENT", "DIGIRISKDOLIBARR_DEROGATION_SCHEDULE_OCCASIONAL", "DIGIRISKDOLIBARR_CSE_ELECTION_DATE", "DIGIRISKDOLIBARR_DP_ELECTION_DATE");
$socialResources = array('TitularsCSE', 'AlternatesCSE', 'HarassmentOfficerCSE', 'TitularsDP', 'AlternatesDP', 'HarassmentOfficer');
$socialConsts = array('DIGIRISKDOLIBARR_PARTICIPATION_AGREEMENT_INFORMATION_PROCEDURE', 'DIGIRISKDOLIBARR_DEROGATION_SCHEDULE_PERMANENT', 'DIGIRISKDOLIBARR_DEROGATION_SCHEDULE_OCCASIONAL', 'DIGIRISKDOLIBARR_CSE_ELECTION_DATE', 'DIGIRISKDOLIBARR_DP_ELECTION_DATE');

$maxnumber = count($socialResources) + count($socialConsts);

Expand Down Expand Up @@ -152,7 +152,7 @@
$electionDateCSE = $conf->global->DIGIRISKDOLIBARR_CSE_ELECTION_DATE;
$electionDateDP = $conf->global->DIGIRISKDOLIBARR_DP_ELECTION_DATE;

print '<span class="opacitymedium">' . $langs->trans("DigiriskMenu") . "</span><br>\n";
print '<span class="opacitymedium">' . $langs->trans('DigiriskMenu') . "</span><br>\n";
print "<br>";

print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '" name="social_form">';
Expand Down
23 changes: 16 additions & 7 deletions class/digiriskdolibarrdashboard.class.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2021-2023 EVARISK <[email protected]>
/* Copyright (C) 2021-2024 EVARISK <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -25,6 +25,8 @@
require_once __DIR__ . '/digiriskdolibarrdocuments/riskassessmentdocument.class.php';
require_once __DIR__ . '/accident.class.php';
require_once __DIR__ . '/evaluator.class.php';
require_once __DIR__ . '/digiriskdolibarrdocuments/legaldisplay.class.php';
require_once __DIR__ . '/digiriskdolibarrdocuments/informationssharing.class.php';
require_once __DIR__ . '/digiriskresources.class.php';
require_once __DIR__ . '/riskanalysis/risk.class.php';
require_once __DIR__ . '/../../saturne/class/task/saturnetask.class.php';
Expand Down Expand Up @@ -61,25 +63,32 @@ public function load_dashboard(array $moreParams = []): array
{
global $conf;

$loadRiskAssessmentDocument = array_key_exists('loadRiskAssessmentDocument', $moreParams) ? $moreParams['loadRiskAssessmentDocument'] : 1;
$loadAccident = array_key_exists('loadAccident', $moreParams) ? $moreParams['loadAccident'] : 1;
$loadEvaluator = array_key_exists('loadEvaluator', $moreParams) ? $moreParams['loadEvaluator'] : 1;
$loadDigiriskResources = array_key_exists('loadDigiriskResources', $moreParams) ? $moreParams['loadDigiriskResources'] : 1;
$loadRisk = array_key_exists('loadRisk', $moreParams) ? $moreParams['loadRisk'] : 1;
$loadTask = array_key_exists('loadTask', $moreParams) ? $moreParams['loadTask'] : 1;
$loadRiskAssessmentDocument = array_key_exists('loadRiskAssessmentDocument', $moreParams) ? $moreParams['loadRiskAssessmentDocument'] : 0;
$loadAccident = array_key_exists('loadAccident', $moreParams) ? $moreParams['loadAccident'] : 0;
$loadEvaluator = array_key_exists('loadEvaluator', $moreParams) ? $moreParams['loadEvaluator'] : 0;
$loadDigiriskResources = array_key_exists('loadDigiriskResources', $moreParams) ? $moreParams['loadDigiriskResources'] : 0;
$loadRisk = array_key_exists('loadRisk', $moreParams) ? $moreParams['loadRisk'] : 0;
$loadTask = array_key_exists('loadTask', $moreParams) ? $moreParams['loadTask'] : 0;
$loadLegalDisplay = array_key_exists('loadLegalDisplay', $moreParams) ? $moreParams['loadLegalDisplay'] : 0;
$loadInformationsSharing = array_key_exists('loadInformationsSharing', $moreParams) ? $moreParams['loadInformationsSharing'] : 0;

$riskAssessmentDocument = new RiskAssessmentDocument($this->db);
$accident = new Accident($this->db);
$evaluator = new Evaluator($this->db);
$digiriskResources = new DigiriskResources($this->db);
$risk = new Risk($this->db);
$legalDisplay = new LegalDisplay($this->db);
$digiriskTask = new SaturneTask($this->db);
$informationsSharing = new InformationsSharing($this->db);


$dashboardData['riskassessmentdocument'] = ($loadRiskAssessmentDocument) ? $riskAssessmentDocument->load_dashboard() : [];
$dashboardData['accident'] = ($loadAccident) ? $accident->load_dashboard() : [];
$dashboardData['evaluator'] = ($loadEvaluator) ? $evaluator->load_dashboard() : [];
$dashboardData['digiriskresources'] = ($loadDigiriskResources) ? $digiriskResources->load_dashboard() : [];
$dashboardData['risk'] = ($loadRisk) ? $risk->load_dashboard() : [];
$dashboardData['legaldisplay'] = ($loadLegalDisplay) ? $legalDisplay->load_dashboard() : [];
$dashboardData['informationssharing'] = ($loadInformationsSharing) ? $informationsSharing->load_dashboard() : [];
$dashboardData['task'] = ($loadTask) ? $digiriskTask->load_dashboard($conf->global->DIGIRISKDOLIBARR_DU_PROJECT) : [];

return $dashboardData;
Expand Down
Loading