diff --git a/admin/socialconf.php b/admin/socialconf.php index 23d5dc215..83ee368a1 100644 --- a/admin/socialconf.php +++ b/admin/socialconf.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2021-2024 EVARISK * * 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 @@ -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'); @@ -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]; @@ -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()); @@ -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); @@ -152,7 +152,7 @@ $electionDateCSE = $conf->global->DIGIRISKDOLIBARR_CSE_ELECTION_DATE; $electionDateDP = $conf->global->DIGIRISKDOLIBARR_DP_ELECTION_DATE; -print '' . $langs->trans("DigiriskMenu") . "
\n"; +print '' . $langs->trans('DigiriskMenu') . "
\n"; print "
"; print '
'; diff --git a/class/digiriskdolibarrdashboard.class.php b/class/digiriskdolibarrdashboard.class.php index 556559e81..5ac500caf 100644 --- a/class/digiriskdolibarrdashboard.class.php +++ b/class/digiriskdolibarrdashboard.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2021-2024 EVARISK * * 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 @@ -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'; @@ -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; diff --git a/class/digiriskdolibarrdocuments/informationssharing.class.php b/class/digiriskdolibarrdocuments/informationssharing.class.php index bfcdb6574..dee1ceefa 100644 --- a/class/digiriskdolibarrdocuments/informationssharing.class.php +++ b/class/digiriskdolibarrdocuments/informationssharing.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2021-2024 EVARISK * * 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 @@ -23,6 +23,7 @@ // Load DigiriskDolibarr libraries require_once __DIR__ . '/../digiriskdocuments.class.php'; +require_once __DIR__ . '/../digiriskresources.class.php'; /** * Class for InformationsSharing @@ -30,19 +31,24 @@ class InformationsSharing extends DigiriskDocuments { /** - * @var string Module name. + * @var string Module name */ public $module = 'digiriskdolibarr'; /** - * @var string Element type of object. + * @var string Element type of object */ public $element = 'informationssharing'; + /** + * @var string String with name of icon for informations sharing. Must be the part after the 'object_' into object_informations sharing.png + */ + public $picto = 'fa-comment-dots_fas_#d35968'; + /** - * Constructor. + * Constructor * - * @param DoliDb $db Database handler. + * @param DoliDb $db Database handler */ public function __construct(DoliDB $db) { @@ -57,7 +63,7 @@ public function __construct(DoliDB $db) */ public function InformationsSharingFillJSON() { - global $conf; + global $conf, $langs; $resources = new DigiriskResources($this->db); $digirisk_resources = $resources->fetchDigiriskResources(); @@ -68,37 +74,41 @@ public function InformationsSharingFillJSON() $labour_doctor_contact = new Contact($this->db); $result = $labour_doctor_contact->fetch($digirisk_resources['LabourDoctorContact']->id[0]); if ($result > 0) { - $json['InformationsSharing']['occupational_health_service']['id'] = $labour_doctor_contact->id; - $json['InformationsSharing']['occupational_health_service']['name'] = $labour_doctor_contact->firstname . " " . $labour_doctor_contact->lastname; - $json['InformationsSharing']['occupational_health_service']['phone'] = $labour_doctor_contact->phone_pro; + $json['InformationsSharing']['occupational_health_service']['id'] = $labour_doctor_contact->id; + $json['InformationsSharing']['occupational_health_service']['name'] = $labour_doctor_contact->firstname . " " . $labour_doctor_contact->lastname; + $json['InformationsSharing']['occupational_health_service']['phone'] = $labour_doctor_contact->phone_pro; + $json['InformationsSharing']['occupational_health_service']['fullname'] = $labour_doctor_contact->getNomUrl(1); } $labourInspectorContact = new Contact($this->db); $result = $labourInspectorContact->fetch($digirisk_resources['LabourInspectorContact']->id[0]); if ($result > 0) { - $json['InformationsSharing']['detective_work']['id'] = $labourInspectorContact->id; - $json['InformationsSharing']['detective_work']['name'] = $labourInspectorContact->firstname . " " . $labourInspectorContact->lastname; - $json['InformationsSharing']['detective_work']['phone'] = $labourInspectorContact->phone_pro; + $json['InformationsSharing']['detective_work']['id'] = $labourInspectorContact->id; + $json['InformationsSharing']['detective_work']['name'] = $labourInspectorContact->firstname . " " . $labourInspectorContact->lastname; + $json['InformationsSharing']['detective_work']['phone'] = $labourInspectorContact->phone_pro; + $json['InformationsSharing']['detective_work']['fullname'] = $labourInspectorContact->getNomUrl(1); } $harassment_officer = new User($this->db); $result = $harassment_officer->fetch($digirisk_resources['HarassmentOfficer']->id[0]); if ($result > 0) { - $json['InformationsSharing']['harassment_officer']['id'] = $harassment_officer->id; - $json['InformationsSharing']['harassment_officer']['name'] = $harassment_officer->getFullName($langs); - $json['InformationsSharing']['harassment_officer']['phone'] = $harassment_officer->office_phone; + $json['InformationsSharing']['harassment_officer']['id'] = $harassment_officer->id; + $json['InformationsSharing']['harassment_officer']['name'] = $harassment_officer->getFullName($langs); + $json['InformationsSharing']['harassment_officer']['phone'] = $harassment_officer->office_phone; + $json['InformationsSharing']['harassment_officer']['fullname'] = $harassment_officer->getNomUrl(0); } $harassment_officer_cse = new User($this->db); $result = $harassment_officer_cse->fetch($digirisk_resources['HarassmentOfficerCSE']->id[0]); if ($result > 0) { - $json['InformationsSharing']['harassment_officer_cse']['id'] = $harassment_officer_cse->id; - $json['InformationsSharing']['harassment_officer_cse']['name'] = $harassment_officer_cse->getFullName($langs); - $json['InformationsSharing']['harassment_officer_cse']['phone'] = $harassment_officer_cse->office_phone; - } + $json['InformationsSharing']['harassment_officer_cse']['id'] = $harassment_officer_cse->id; + $json['InformationsSharing']['harassment_officer_cse']['name'] = $harassment_officer_cse->getFullName($langs); + $json['InformationsSharing']['harassment_officer_cse']['phone'] = $harassment_officer_cse->office_phone; + $json['InformationsSharing']['harassment_officer_cse']['fullname'] = $harassment_officer->getNomUrl(0); + } $json['InformationsSharing']['delegues_du_personnels_date'] = (dol_strlen($conf->global->DIGIRISKDOLIBARR_DP_ELECTION_DATE) > 0 && $conf->global->DIGIRISKDOLIBARR_DP_ELECTION_DATE != '--' ? $conf->global->DIGIRISKDOLIBARR_DP_ELECTION_DATE : ''); $json['InformationsSharing']['delegues_du_personnels_titulaires'] = ''; @@ -108,8 +118,8 @@ public function InformationsSharingFillJSON() $dp_titulars = new User($this->db); $result = $dp_titulars->fetch($dp_titular); if ($result > 0) { - $json['InformationsSharing']['delegues_du_personnels_titulaires'] .= $dp_titulars->firstname . " " . $dp_titulars->lastname . '
'; - $json['InformationsSharing']['delegues_du_personnels_titulairesFullName'] .= $dp_titulars->getNomUrl(1) . '
'; + $json['InformationsSharing']['delegues_du_personnels_titulaires'] .= $dp_titulars->firstname . " " . $dp_titulars->lastname; + $json['InformationsSharing']['delegues_du_personnels_titulairesFullName'] .= $dp_titulars->getNomUrl(1); } } } @@ -121,8 +131,8 @@ public function InformationsSharingFillJSON() $dp_alternates = new User($this->db); $result = $dp_alternates->fetch($dp_alternate); if ($result > 0) { - $json['InformationsSharing']['delegues_du_personnels_suppleants'] .= $dp_alternates->firstname . " " . $dp_alternates->lastname . '
'; - $json['InformationsSharing']['delegues_du_personnels_suppleantsFullName'] .= $dp_alternates->getNomUrl(1) . '
'; + $json['InformationsSharing']['delegues_du_personnels_suppleants'] .= $dp_alternates->firstname . " " . $dp_alternates->lastname; + $json['InformationsSharing']['delegues_du_personnels_suppleantsFullName'] .= $dp_alternates->getNomUrl(1); } } } @@ -135,8 +145,8 @@ public function InformationsSharingFillJSON() $cse_titulars = new User($this->db); $result = $cse_titulars->fetch($cse_titular); if ($result > 0) { - $json['InformationsSharing']['membres_du_comite_entreprise_titulaires'] .= $cse_titulars->firstname . " " . $cse_titulars->lastname . '
'; - $json['InformationsSharing']['membres_du_comite_entreprise_titulairesFullName'] .= $cse_titulars->getNomUrl(1) . '
'; + $json['InformationsSharing']['membres_du_comite_entreprise_titulaires'] .= $cse_titulars->firstname . " " . $cse_titulars->lastname; + $json['InformationsSharing']['membres_du_comite_entreprise_titulairesFullName'] .= $cse_titulars->getNomUrl(1); } } } @@ -147,8 +157,8 @@ public function InformationsSharingFillJSON() $cse_alternates = new User($this->db); $result = $cse_alternates->fetch($cse_alternate); if ($result > 0) { - $json['InformationsSharing']['membres_du_comite_entreprise_suppleants'] .= $cse_alternates->firstname . " " . $cse_alternates->lastname . '
'; - $json['InformationsSharing']['membres_du_comite_entreprise_suppleantsFullName'] .= $cse_alternates->getNomUrl(1) . '
'; + $json['InformationsSharing']['membres_du_comite_entreprise_suppleants'] .= $cse_alternates->firstname . " " . $cse_alternates->lastname; + $json['InformationsSharing']['membres_du_comite_entreprise_suppleantsFullName'] .= $cse_alternates->getNomUrl(1); } } } @@ -160,4 +170,103 @@ public function InformationsSharingFillJSON() return -1; } } + + /** + * Load dashboard info + * + * @return array $dashboardData Return all dashboardData after load info + * @throws Exception + */ + public function load_dashboard(): array { + global $langs; + + $informationsSharing = json_decode($this->InformationsSharingFillJSON(), false, 512, JSON_UNESCAPED_UNICODE)->InformationsSharing; + $getInformationsSharingInfos = $this->getInformationsSharingInfos(); + + $dashboardData['graphs'] = [$getInformationsSharingInfos]; + $dashboardData['widgets'] = [ + 'information_sharing_widget' => [ + 'label' => [ + $langs->transnoentities('LabourDoctor') ?? '', + $langs->transnoentities('LabourInspector') ?? '', + $langs->transnoentities('HarassmentOfficer') ?? '', + $langs->transnoentities('StaffRepresentatives') ?? '', + $langs->transnoentities('ESC') ?? '', + ], + 'content' => [ + 0 => '' . $langs->transnoentities('CongigureDoctorData') . ' ', + 1 => '' . $langs->transnoentities('CongigureLabourInspectorData') . ' ', + 2 => '' . $langs->transnoentities('SocialConfiguration') . ' ', + 3 => '' . $langs->transnoentities('SocialConfiguration') . ' ', + 4 => '' . $langs->transnoentities('SocialConfiguration') . ' ', + ], + 'picto' => 'fas fa-link', + 'widgetName' => $langs->transnoentities('Society') + ] + ]; + return $dashboardData; + } + + /** + * get information sharing info + * + * @return array $array Return all graph data for dashboardData after load info + * @throws Exception + */ + public function getInformationsSharingInfos(): array { + global $langs; + + $informationsSharing = json_decode($this->InformationsSharingFillJSON(), false, 512, JSON_UNESCAPED_UNICODE)->InformationsSharing; + + $labourDoctor = [$informationsSharing->occupational_health_service->fullname, $informationsSharing->occupational_health_service->phone]; + $detectiveWork = [$informationsSharing->detective_work->fullname, $informationsSharing->detective_work->phone]; + $harassmentOfficer = [$informationsSharing->harassment_officer->fullname, $informationsSharing->harassment_officer_cse->fullname, $informationsSharing->harassment_officer->phone, $informationsSharing->harassment_officer_cse->phone]; + $deleguePersonnel = [$informationsSharing->delegues_du_personnels_titulairesFullName, $informationsSharing->delegues_du_personnels_suppleantsFullName]; + $membreComitee = [$informationsSharing->membres_du_comite_entreprise_titulairesFullName, $informationsSharing->membres_du_comite_entreprise_suppleantsFullName, $informationsSharing->membres_du_comite_entreprise_date]; + + function isGreaterThanZero($value) { + return dol_strlen($value) > 0; + } + + // Define a function to count the number of non-empty values in an array + function countNonEmptyValues($array) { + return count(array_filter($array, 'isGreaterThanZero')); + } + + $labourDoctorValue = countNonEmptyValues($labourDoctor); + $detectiveWorkValue = countNonEmptyValues($detectiveWork); + $harassmentOfficerValue = countNonEmptyValues($harassmentOfficer); + $deleguePersonnelValue = countNonEmptyValues($deleguePersonnel); + $membreComiteeValue = countNonEmptyValues($membreComitee); + + $array['title'] = $langs->transnoentities('ConfigureInformationsSharing'); + $array['picto'] = $this->picto; + + // Graph parameters + $array['width'] = '100%'; + $array['height'] = 300; + $array['type'] = 'bars'; + $array['showlegend'] = 1; + $array['dataset'] = 2; + $array['labels'] = [ + 0 => [ + 'label' => $langs->transnoentities('Values'), + 'color' => '#00CF68' + ], + 1 => [ + 'label' => $langs->transnoentities('Total'), + 'color' => '#006400' + ], + ]; + $dataArray = [ + [$langs->transnoentities('LabourDoctor'), $labourDoctorValue, count($labourDoctor)], + [$langs->transnoentities('LabourInspector'), $detectiveWorkValue, count($detectiveWork)], + [$langs->transnoentities('HarassmentOfficer'), $harassmentOfficerValue, count($harassmentOfficer)], + [$langs->transnoentities('StaffRepresentatives'), $deleguePersonnelValue, count($deleguePersonnel)], + [$langs->transnoentities('ESC'), $membreComiteeValue, count($membreComitee)] + ]; + + $array['data'] = $dataArray; + return $array; + } } diff --git a/class/digiriskdolibarrdocuments/legaldisplay.class.php b/class/digiriskdolibarrdocuments/legaldisplay.class.php index fc8bfe81a..292f67957 100644 --- a/class/digiriskdolibarrdocuments/legaldisplay.class.php +++ b/class/digiriskdolibarrdocuments/legaldisplay.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2021-2024 EVARISK * * 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 @@ -23,6 +23,7 @@ // Load DigiriskDolibarr libraries require_once __DIR__ . '/../digiriskdocuments.class.php'; +require_once __DIR__ . '/../digiriskresources.class.php'; /** * Class for LegalDisplay @@ -30,19 +31,24 @@ class LegalDisplay extends DigiriskDocuments { /** - * @var string Module name. + * @var string Module name */ public $module = 'digiriskdolibarr'; /** - * @var string Element type of object. + * @var string Element type of object */ public $element = 'legaldisplay'; + /** + * @var string String with name of icon for legaldisplay. Must be the part after the 'object_' into object_legaldisplay.png + */ + public $picto = 'fontawesome_fa-file_fas_#d35968'; + /** - * Constructor. + * Constructor * - * @param DoliDb $db Database handler. + * @param DoliDb $db Database handler */ public function __construct(DoliDB $db) { @@ -50,7 +56,7 @@ public function __construct(DoliDB $db) } /** - * Function for JSON filling before saving in database + * Function for JSON filling before saving in database for documents * * @return false|string * @throws Exception @@ -73,18 +79,26 @@ public function LegalDisplayFillJSON() { $thirdparty_openinghours = new SaturneSchedules($this->db); $thirdparty_openinghours->fetch(0, '', $morewhere); - $json['LegalDisplay']['occupational_health_service']['openinghours'] = $langs->trans('Monday') . ' : ' . $thirdparty_openinghours->monday . "\r\n" . $langs->trans('Tuesday') . ' : ' . $thirdparty_openinghours->tuesday . "\r\n" . $langs->trans('Wednesday') . ' : ' . $thirdparty_openinghours->wednesday . "\r\n" . $langs->trans('Thursday') . ' : ' . $thirdparty_openinghours->thursday . "\r\n" . $langs->trans('Friday') . ' : ' . $thirdparty_openinghours->friday . "\r\n" . $langs->trans('Saturday') . ' : ' . $thirdparty_openinghours->saturday . "\r\n" . $langs->trans('Sunday') . ' : ' . $thirdparty_openinghours->sunday; + $json['LegalDisplay']['occupational_health_service']['openinghours'] = $langs->trans('Monday') . ' : ' . $thirdparty_openinghours->monday . "\r\n" . $langs->trans('Tuesday') . ' : ' . $thirdparty_openinghours->tuesday . "\r\n" . $langs->trans('Wednesday') . ' : ' . $thirdparty_openinghours->wednesday . "\r\n" . $langs->trans('Thursday') . ' : ' . $thirdparty_openinghours->thursday . "\r\n" . $langs->trans('Friday') . ' : ' . $thirdparty_openinghours->friday . "\r\n" . $langs->trans('Saturday') . ' : ' . $thirdparty_openinghours->saturday . "\r\n" . $langs->trans('Sunday') . ' : ' . $thirdparty_openinghours->sunday; + $json['LegalDisplay']['occupational_health_service']['opening_hours_details']['monday'] = $thirdparty_openinghours->monday; + $json['LegalDisplay']['occupational_health_service']['opening_hours_details']['tuesday'] = $thirdparty_openinghours->tuesday; + $json['LegalDisplay']['occupational_health_service']['opening_hours_details']['wednesday'] = $thirdparty_openinghours->wednesday; + $json['LegalDisplay']['occupational_health_service']['opening_hours_details']['thursday'] = $thirdparty_openinghours->thursday; + $json['LegalDisplay']['occupational_health_service']['opening_hours_details']['friday'] = $thirdparty_openinghours->friday; + $json['LegalDisplay']['occupational_health_service']['opening_hours_details']['saturday'] = $thirdparty_openinghours->saturday; + $json['LegalDisplay']['occupational_health_service']['opening_hours_details']['sunday'] = $thirdparty_openinghours->sunday; } $labour_doctor_contact = new Contact($this->db); $result = $labour_doctor_contact->fetch($digirisk_resources['LabourDoctorContact']->id[0]); if ($result > 0) { - $json['LegalDisplay']['occupational_health_service']['id'] = $labour_doctor_contact->id; - $json['LegalDisplay']['occupational_health_service']['name'] = $labour_doctor_contact->firstname . " " . $labour_doctor_contact->lastname; - $json['LegalDisplay']['occupational_health_service']['address'] = preg_replace('/\s\s+/', ' ', $labour_doctor_contact->address); - $json['LegalDisplay']['occupational_health_service']['zip'] = $labour_doctor_contact->zip; - $json['LegalDisplay']['occupational_health_service']['town'] = $labour_doctor_contact->town; - $json['LegalDisplay']['occupational_health_service']['phone'] = $labour_doctor_contact->phone_pro; + $json['LegalDisplay']['occupational_health_service']['id'] = $labour_doctor_contact->id; + $json['LegalDisplay']['occupational_health_service']['name'] = $labour_doctor_contact->firstname . " " . $labour_doctor_contact->lastname; + $json['LegalDisplay']['occupational_health_service']['address'] = preg_replace('/\s\s+/', ' ', $labour_doctor_contact->address); + $json['LegalDisplay']['occupational_health_service']['zip'] = $labour_doctor_contact->zip; + $json['LegalDisplay']['occupational_health_service']['town'] = $labour_doctor_contact->town; + $json['LegalDisplay']['occupational_health_service']['phone'] = $labour_doctor_contact->phone_pro; + $json['LegalDisplay']['occupational_health_service']['fullname'] = $labour_doctor_contact->getNomUrl(1); } $labour_inspector_societe = new Societe($this->db); @@ -97,19 +111,27 @@ public function LegalDisplayFillJSON() { $thirdparty_openinghours = new SaturneSchedules($this->db); $thirdparty_openinghours->fetch(0, '', $morewhere); - $json['LegalDisplay']['detective_work']['openinghours'] = $langs->trans('Monday') . ' : ' . $thirdparty_openinghours->monday . "\r\n" . $langs->trans('Tuesday') . ' : ' . $thirdparty_openinghours->tuesday . "\r\n" . $langs->trans('Wednesday') . ' : ' . $thirdparty_openinghours->wednesday . "\r\n" . $langs->trans('Thursday') . ' : ' . $thirdparty_openinghours->thursday . "\r\n" . $langs->trans('Friday') . ' : ' . $thirdparty_openinghours->friday . "\r\n" . $langs->trans('Saturday') . ' : ' . $thirdparty_openinghours->saturday . "\r\n" . $langs->trans('Sunday') . ' : ' . $thirdparty_openinghours->sunday; + $json['LegalDisplay']['detective_work']['openinghours'] = $langs->trans('Monday') . ' : ' . $thirdparty_openinghours->monday . "\r\n" . $langs->trans('Tuesday') . ' : ' . $thirdparty_openinghours->tuesday . "\r\n" . $langs->trans('Wednesday') . ' : ' . $thirdparty_openinghours->wednesday . "\r\n" . $langs->trans('Thursday') . ' : ' . $thirdparty_openinghours->thursday . "\r\n" . $langs->trans('Friday') . ' : ' . $thirdparty_openinghours->friday . "\r\n" . $langs->trans('Saturday') . ' : ' . $thirdparty_openinghours->saturday . "\r\n" . $langs->trans('Sunday') . ' : ' . $thirdparty_openinghours->sunday; + $json['LegalDisplay']['detective_work']['opening_hours_details']['monday'] = $thirdparty_openinghours->monday; + $json['LegalDisplay']['detective_work']['opening_hours_details']['tuesday'] = $thirdparty_openinghours->tuesday; + $json['LegalDisplay']['detective_work']['opening_hours_details']['wednesday'] = $thirdparty_openinghours->wednesday; + $json['LegalDisplay']['detective_work']['opening_hours_details']['thursday'] = $thirdparty_openinghours->thursday; + $json['LegalDisplay']['detective_work']['opening_hours_details']['friday'] = $thirdparty_openinghours->friday; + $json['LegalDisplay']['detective_work']['opening_hours_details']['saturday'] = $thirdparty_openinghours->saturday; + $json['LegalDisplay']['detective_work']['opening_hours_details']['sunday'] = $thirdparty_openinghours->sunday; } $labourInspectorContact = new Contact($this->db); $result = $labourInspectorContact->fetch($digirisk_resources['LabourInspectorContact']->id[0]); if ($result > 0) { - $json['LegalDisplay']['detective_work']['id'] = $labourInspectorContact->id; - $json['LegalDisplay']['detective_work']['name'] = $labourInspectorContact->firstname . " " . $labourInspectorContact->lastname; - $json['LegalDisplay']['detective_work']['address'] = preg_replace('/\s\s+/', ' ', $labourInspectorContact->address); - $json['LegalDisplay']['detective_work']['zip'] = $labourInspectorContact->zip; - $json['LegalDisplay']['detective_work']['town'] = $labourInspectorContact->town; - $json['LegalDisplay']['detective_work']['phone'] = $labourInspectorContact->phone_pro; + $json['LegalDisplay']['detective_work']['id'] = $labourInspectorContact->id; + $json['LegalDisplay']['detective_work']['name'] = $labourInspectorContact->firstname . " " . $labourInspectorContact->lastname; + $json['LegalDisplay']['detective_work']['address'] = preg_replace('/\s\s+/', ' ', $labourInspectorContact->address); + $json['LegalDisplay']['detective_work']['zip'] = $labourInspectorContact->zip; + $json['LegalDisplay']['detective_work']['town'] = $labourInspectorContact->town; + $json['LegalDisplay']['detective_work']['phone'] = $labourInspectorContact->phone_pro; + $json['LegalDisplay']['detective_work']['fullname'] = $labourInspectorContact->getNomUrl(1); } $samu = new Societe($this->db); @@ -234,4 +256,123 @@ public function getIDCCByCode($code) { return ''; } } + + /** + * Load dashboard info + * + * @return array $dashboardData Return all dashboardData after load info + * @throws Exception + */ + public function load_dashboard(): array { + global $langs; + + $legalDisplay = json_decode($this->LegalDisplayFillJSON(), false, 512, JSON_UNESCAPED_UNICODE)->LegalDisplay; + $getLegalDisplayInfos = $this->getLegalDisplayInfos(); + + $dashboardData['graphs'] = [$getLegalDisplayInfos]; + $dashboardData['widgets'] = [ + 'legal_display_info' => [ + 'label' => [ + $langs->transnoentities('LabourDoctor') ?? '', + $langs->transnoentities('Schedules') ?? '', + $langs->transnoentities('LabourInspector') ?? '', + $langs->transnoentities('Schedules') ?? '', + $langs->transnoentities('AllEmergencies') ?? '', + $langs->transnoentities('SafetyInstructions') ?? '', + $langs->transnoentities('OpeningHours') ?? '', + $langs->transnoentities('Parameters') ?? '', + ], + 'content' => [ + 0 => '' . $langs->transnoentities('CongigureDoctorData') . ' ', + 1 => '' . $langs->transnoentities('CongigureDoctorData') . ' ', + 2 => '' . $langs->transnoentities('CongigureLabourInspectorData') . ' ', + 3 => '' . $langs->transnoentities('CongigureLabourInspectorData') . ' ', + 4 => '' . $langs->transnoentities('ConfigureSecurityAndSocialData') . ' ', + 5 => '' . $langs->transnoentities('ConfigureSecurityAndSocialData') . ' ', + 6 => '' . $langs->transnoentities('ConfigureSecurityAndSocialData') . ' ', + 7 => '' . $langs->transnoentities('ConfigureSecurityAndSocialData') . ' ', + + ], + 'picto' => 'fas fa-link', + 'widgetName' => $langs->transnoentities('Society') + ] + ]; + return $dashboardData; + } + + /** + * get legal display info + * + * @return array $array Return all graph data for dashboardData after load info + * @throws Exception + */ + public function getLegalDisplayInfos(): array + { + global $langs; + + $legalDisplay = json_decode($this->LegalDisplayFillJSON(), false, 512, JSON_UNESCAPED_UNICODE)->LegalDisplay; + + $labourDoctor = [$legalDisplay->occupational_health_service->fullname, $legalDisplay->occupational_health_service->zip, $legalDisplay->occupational_health_service->address, $legalDisplay->occupational_health_service->town, $legalDisplay->occupational_health_service->phone]; + $labourDoctorTime = [$legalDisplay->occupational_health_service->opening_hours_details->monday, $legalDisplay->occupational_health_service->opening_hours_details->tuesday, $legalDisplay->occupational_health_service->opening_hours_details->wednesday, $legalDisplay->occupational_health_service->opening_hours_details->thursday, $legalDisplay->occupational_health_service->opening_hours_details->friday, $legalDisplay->occupational_health_service->opening_hours_details->saturday, $legalDisplay->occupational_health_service->opening_hours_details->sunday]; + $detectiveWork = [$legalDisplay->detective_work->fullname, $legalDisplay->detective_work->zip, $legalDisplay->detective_work->address, $legalDisplay->detective_work->town, $legalDisplay->detective_work->phone]; + $labourDetectiveWorkTime = [$legalDisplay->detective_work->opening_hours_details->monday, $legalDisplay->detective_work->opening_hours_details->tuesday, $legalDisplay->detective_work->opening_hours_details->wednesday, $legalDisplay->detective_work->opening_hours_details->thursday, $legalDisplay->detective_work->opening_hours_details->friday, $legalDisplay->detective_work->opening_hours_details->saturday, $legalDisplay->detective_work->opening_hours_details->sunday]; + $emergencyService = [$legalDisplay->emergency_service->samu, $legalDisplay->emergency_service->pompier, $legalDisplay->emergency_service->police, $legalDisplay->emergency_service->emergency, $legalDisplay->emergency_service->right_defender, $legalDisplay->emergency_service->poison_control_center]; + $safetyRule = [$legalDisplay->emergency_service->safety_rule->responsible_for_preventing, $legalDisplay->emergency_service->safety_rule->phone, $legalDisplay->emergency_service->safety_rule->location_of_detailed_instruction]; + $workingHour = [$legalDisplay->working_hour->monday_morning, $legalDisplay->working_hour->monday_afternoon, $legalDisplay->working_hour->tuesday_morning, $legalDisplay->working_hour->tuesday_afternoon, $legalDisplay->working_hour->wednesday_morning, $legalDisplay->working_hour->wednesday_afternoon, $legalDisplay->working_hour->thursday_morning, $legalDisplay->working_hour->thursday_afternoon, $legalDisplay->working_hour->friday_morning, $legalDisplay->working_hour->friday_afternoon, $legalDisplay->working_hour->saturday_morning, $legalDisplay->working_hour->saturday_afternoon, $legalDisplay->working_hour->sunday_morning, $legalDisplay->working_hour->sunday_afternoon]; + $parameters = [$legalDisplay->derogation_schedule->permanent, $legalDisplay->derogation_schedule->occasional, $legalDisplay->DUER->how_access_to_duer, $legalDisplay->participation_agreement->information_procedures, $legalDisplay->collective_agreement->location_and_access_terms_of_the_agreement]; + + function isGreaterThanZero($value) { + return dol_strlen($value) > 0; + } + + // Define a function to count the number of non-empty values in an array + function countNonEmptyValues($array) { + return count(array_filter($array, 'isGreaterThanZero')); + } + + $labourDoctorValue = countNonEmptyValues($labourDoctor); + $labourDoctorTimeValue = countNonEmptyValues($labourDoctorTime); + $detectiveWorkValue = countNonEmptyValues($detectiveWork); + $labourDetectiveWorkTimeValue = countNonEmptyValues($labourDetectiveWorkTime); + $emergencyServiceValue = countNonEmptyValues($emergencyService); + $safetyRuleValue = countNonEmptyValues($safetyRule); + $workingHourValue = countNonEmptyValues($workingHour); + $parametersValue = countNonEmptyValues($parameters); + + // Graph Title parameters + $array['title'] = $langs->transnoentities('ConfigureLegalDisplay'); + $array['picto'] = $this->picto; + + // Graph parameters + $array['width'] = '100%'; + $array['height'] = 300; + $array['type'] = 'bars'; + $array['showlegend'] = 1; + $array['dataset'] = 2; + + //$legalDisplayGraphInfos = $this->getLegalDisplayNumber(); + $array['labels'] = [ + 0 => [ + 'label' => $langs->transnoentities('Values'), + 'color' => '#00CF68' + ], + 1 => [ + 'label' => $langs->transnoentities('Total'), + 'color' => '#006400' + ], + ]; + $dataArray = [ + [$langs->transnoentities('LabourDoctor'), $labourDoctorValue, count($labourDoctor)], + [$langs->transnoentities('Schedules'), $labourDoctorTimeValue, count($labourDoctorTime)], + [$langs->transnoentities('LabourInspector'), $detectiveWorkValue, count($detectiveWork)], + [$langs->transnoentities('Schedules'), $labourDetectiveWorkTimeValue, count($labourDetectiveWorkTime)], + [$langs->transnoentities('AllEmergencies'), $emergencyServiceValue, count($emergencyService)], + [$langs->transnoentities('SafetyInstructions'), $safetyRuleValue, count($safetyRule)], + [$langs->transnoentities('OpeningHours'), $workingHourValue, count($workingHour)], + [$langs->transnoentities('parameters'), $parametersValue, count($parameters)] + ]; + + $array['data'] = $dataArray; + return $array; + } } diff --git a/digiriskdolibarrindex.php b/digiriskdolibarrindex.php index fdc645da1..30cd15feb 100644 --- a/digiriskdolibarrindex.php +++ b/digiriskdolibarrindex.php @@ -34,4 +34,13 @@ $moreParams['specialModuleNameLowerCase'] = 'digirisk'; +$moreParams = [ + 'loadRiskAssessmentDocument' => 1, + 'loadAccident' => 1, + 'loadEvaluator' => 1, + 'loadDigiriskResources' => 1, + 'loadRisk' => 1, + 'loadTask' => 1, +]; + require_once __DIR__ . '/../saturne/core/tpl/index/index_view.tpl.php'; diff --git a/langs/fr_FR/digiriskdolibarr.lang b/langs/fr_FR/digiriskdolibarr.lang index b3d1e98a4..5930eb0b2 100644 --- a/langs/fr_FR/digiriskdolibarr.lang +++ b/langs/fr_FR/digiriskdolibarr.lang @@ -173,6 +173,7 @@ CollectiveAgreement = Conventions collectives CollectiveAgreementValue = Disponible sur le site du gouvernement :
https://www.service-public.fr/particuliers/vosdroits/F78 legaldisplay.odt = Affichage légal legaldisplay_custom.odt = Affichage légal personnalisé +DocumentCompletionRate = Taux de remplissage du document # # InformationsSharing - Diffusion d'informations @@ -210,6 +211,7 @@ PermanentDerogation = Dérogation permanente PermanentDerogationValue = Non OccasionalDerogation = Dérogation occasionnelle OccasionalDerogationValue = Oui +InformationsSharingRate = Taux de remplissage des informations # @@ -1341,6 +1343,12 @@ DataMigrationDolibarrToDolibarr = Migration des données de Dolibar # Other # +Values = Valeurs +CongigureDoctorData = Configuration du médecin du travail +CongigureLabourInspectorData = Configuration de l'inspecteur du travail +ConfigureLegalDisplay = Taux de configuration de l'affichage légal +ConfigureInformationsSharing = Taux de configuration de la diffusion d'informations + # Data - Donnée AT = au diff --git a/view/digiriskstandard/digiriskstandard_card.php b/view/digiriskstandard/digiriskstandard_card.php index bef9d95db..3dd1f900a 100644 --- a/view/digiriskstandard/digiriskstandard_card.php +++ b/view/digiriskstandard/digiriskstandard_card.php @@ -119,7 +119,11 @@ print '
'; $moreParams = [ - 'loadAccident' => 0 + 'loadRiskAssessmentDocument' => 1, + 'loadEvaluator' => 1, + 'loadDigiriskResources' => 1, + 'loadRisk' => 1, + 'loadTask' => 1, ]; $dashboard->show_dashboard($moreParams); diff --git a/view/digiriskstandard/digiriskstandard_informationssharing.php b/view/digiriskstandard/digiriskstandard_informationssharing.php index 2b95e6074..7ac1ba2c0 100644 --- a/view/digiriskstandard/digiriskstandard_informationssharing.php +++ b/view/digiriskstandard/digiriskstandard_informationssharing.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2021-2024 EVARISK * * 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 @@ -30,20 +30,25 @@ die('Include of digiriskdolibarr main fails'); } +// Load Dolibarr libraries require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; +// Load Saturne libraries +require_once __DIR__ . '/../../../saturne/class/saturnedashboard.class.php'; + +// Load DigiriskDolibarr libraries require_once __DIR__ . '/../../class/digiriskstandard.class.php'; require_once __DIR__ . '/../../class/digiriskresources.class.php'; require_once __DIR__ . '/../../class/digiriskdolibarrdocuments/informationssharing.class.php'; require_once __DIR__ . '/../../lib/digiriskdolibarr_digiriskstandard.lib.php'; require_once __DIR__ . '/../../lib/digiriskdolibarr_function.lib.php'; -global $db, $conf, $langs, $hookmanager, $user; +global $conf, $db, $hookmanager, $langs, $moduleNameLowerCase, $user; // Load translation files required by the page -saturne_load_langs(['other']); +saturne_load_langs(); // Get parameters $action = GETPOST('action', 'aZ09'); @@ -54,6 +59,7 @@ $document = new InformationsSharing($db); $contact = new Contact($db); $project = new Project($db); +$dashboard = new SaturneDashboard($db, $moduleNameLowerCase); $hookmanager->initHooks(array('digiriskelementinformationssharing', 'digiriskstandardview', 'globalcard')); // Note that conf->hooks_modules contains array @@ -62,25 +68,26 @@ $upload_dir = $conf->digiriskdolibarr->multidir_output[isset($conf->entity) ? $conf->entity : 1]; // Security check - Protection if external user -$permissiontoread = $user->rights->digiriskdolibarr->digiriskstandard->read && $user->rights->digiriskdolibarr->informationssharing->read; +$permissionToRead = $user->rights->digiriskdolibarr->digiriskstandard->read && $user->rights->digiriskdolibarr->informationssharing->read; $permissiontoadd = $user->rights->digiriskdolibarr->informationssharing->write; $permissiontodelete = $user->rights->digiriskdolibarr->informationssharing->delete; -saturne_check_access($permissiontoread); +saturne_check_access($permissionToRead); /* * Actions */ -$parameters = array(); -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +$parameters = []; +$resHook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($resHook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) { - $error = 0; +if (empty($resHook)) { $previousRef = $object->ref; $object->ref = ''; - // Actions builddoc, forcebuilddoc, remove_file. + // Actions builddoc, forcebuilddoc, remove_file require_once __DIR__ . '/../../../saturne/core/tpl/documents/documents_action.tpl.php'; // Action to generate pdf from odt file @@ -96,51 +103,35 @@ $title = $langs->trans('InformationsSharing'); $helpUrl = 'FR:Module_Digirisk#Soci.C3.A9t.C3.A9.2FOrganisation'; -digirisk_header($title, $helpUrl); ?> - -
- -fetch_optionals(); +digirisk_header($title, $helpUrl); saturne_get_fiche_head($object, 'standardInformationsSharing', $title); // Object card // ------------------------------------------------------------ // Project -$morehtmlref = '
'; +$moreHtmlRef = '
'; $project->fetch($conf->global->DIGIRISKDOLIBARR_DU_PROJECT); -$morehtmlref .= $langs->trans('Project') . ' : ' . getNomUrlProject($project, 1, 'blank', 1); -$morehtmlref .= '
'; +$moreHtmlRef .= $langs->trans('Project') . ' : ' . getNomUrlProject($project, 1, 'blank', 1); +$moreHtmlRef .= '
'; $moduleNameLowerCase = 'mycompany'; -saturne_banner_tab($object,'ref','none', 0, 'ref', 'ref', $morehtmlref, true); +saturne_banner_tab($object,'ref','none', 0, 'ref', 'ref', $moreHtmlRef, true); $moduleNameLowerCase = 'digiriskdolibarr'; -print '' . $langs->trans('ConfigureSecurityAndSocialData') . ' '; -print '
'; print '
'; -print '' . "\n"; - -//JSON Decode and show fields -require_once __DIR__ . '/../../core/tpl/digiriskdocuments/digiriskdolibarr_informationssharingfields_view.tpl.php'; - -print '
'; -print '
'; +$moreParams = ['loadInformationsSharing' => 1]; +$dashboard->show_dashboard($moreParams); print dol_get_fiche_end(); // Document Generation -- Génération des documents $dirFiles = 'informationssharing'; -$filedir = $upload_dir . '/' . $dirFiles ; -$urlsource = $_SERVER["PHP_SELF"]; -$modulepart = 'digiriskdolibarr:InformationsSharing'; - -if ($permissiontoadd || $permissiontoread) { - $genallowed = 1; -} +$fileDir = $upload_dir . '/' . $dirFiles ; +$urlSource = $_SERVER["PHP_SELF"]; +$modulePart = 'digiriskdolibarr:InformationsSharing'; -print saturne_show_documents($modulepart, $dirFiles, $filedir, $urlsource, 1,1, '', 1, 0, 0, 0, 0, '', 0, '', empty($soc->default_lang) ? '' : $soc->default_lang, $object); +print saturne_show_documents($modulePart, $dirFiles, $fileDir, $urlSource, $permissiontoadd, $permissiontodelete, '', 1, 0, 0, 0, 0, '', '', $langs->defaultlang, 0, $object); // End of page llxFooter(); diff --git a/view/digiriskstandard/digiriskstandard_legaldisplay.php b/view/digiriskstandard/digiriskstandard_legaldisplay.php index 8ad7ebcf8..19964c6f0 100644 --- a/view/digiriskstandard/digiriskstandard_legaldisplay.php +++ b/view/digiriskstandard/digiriskstandard_legaldisplay.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2021-2024 EVARISK * * 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 @@ -16,9 +16,9 @@ */ /** - * \file view/digiriskstandard/digiriskstandard_legaldisplay.php - * \ingroup digiriskdolibarr - * \brief Page to view legaldisplay + * \file view/digiriskstandard/digiriskstandard_legaldisplay.php + * \ingroup digiriskdolibarr + * \brief Page to view legaldisplay */ // Load DigiriskDolibarr environment @@ -30,60 +30,64 @@ die('Include of digiriskdolibarr main fails'); } -require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php'; +// Load Dolibarr libraries require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; +// Load Saturne libraries +require_once __DIR__ . '/../../../saturne/class/saturneschedules.class.php'; +require_once __DIR__ . '/../../../saturne/class/saturnedashboard.class.php'; + +// Load DigiriskDolibarr libraries require_once __DIR__ . '/../../class/digiriskstandard.class.php'; -require_once __DIR__ . '/../../class/digiriskresources.class.php'; require_once __DIR__ . '/../../class/digiriskdolibarrdocuments/legaldisplay.class.php'; require_once __DIR__ . '/../../lib/digiriskdolibarr_digiriskstandard.lib.php'; require_once __DIR__ . '/../../lib/digiriskdolibarr_function.lib.php'; -require_once __DIR__ . '/../../../saturne/class/saturneschedules.class.php'; - -global $db, $conf, $langs, $user, $hookmanager; +global $conf, $db, $hookmanager, $langs, $moduleNameLowerCase, $user; // Load translation files required by the page -saturne_load_langs(['other']); +saturne_load_langs(); // Get parameters $action = GETPOST('action', 'aZ09'); $subaction = GETPOST('subaction', 'aZ09'); // Initialize technical objects -$object = new DigiriskStandard($db); -$document = new LegalDisplay($db); -$contact = new Contact($db); -$usertmp = new User($db); -$project = new Project($db); +$object = new DigiriskStandard($db); +$document = new LegalDisplay($db); +$usertmp = new User($db); +$contact = new Contact($db); +$project = new Project($db); +$dashboard = new SaturneDashboard($db, $moduleNameLowerCase); -$hookmanager->initHooks(array('digiriskelementlegaldisplay', 'digiriskstandardview', 'globalcard')); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(['digiriskelementlegaldisplay', 'digiriskstandardview', 'globalcard']); // Note that conf->hooks_modules contains array $object->fetch($conf->global->DIGIRISKDOLIBARR_ACTIVE_STANDARD); $upload_dir = $conf->digiriskdolibarr->multidir_output[$conf->entity ?? 1]; // Security check - Protection if external user -$permissiontoread = $user->rights->digiriskdolibarr->digiriskstandard->read && $user->rights->digiriskdolibarr->legaldisplay->read; +$permissionToRead = $user->rights->digiriskdolibarr->digiriskstandard->read && $user->rights->digiriskdolibarr->legaldisplay->read; $permissiontoadd = $user->rights->digiriskdolibarr->legaldisplay->write; $permissiontodelete = $user->rights->digiriskdolibarr->legaldisplay->delete; -saturne_check_access($permissiontoread); +saturne_check_access($permissionToRead); /* * Actions */ -$parameters = array(); -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +$parameters = []; +$resHook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($resHook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) { - $error = 0; +if (empty($resHook)) { $previousRef = $object->ref; $object->ref = ''; - // Actions builddoc, forcebuilddoc, remove_file. + // Actions builddoc, forcebuilddoc, remove_file require_once __DIR__ . '/../../../saturne/core/tpl/documents/documents_action.tpl.php'; // Action to generate pdf from odt file @@ -99,51 +103,36 @@ $title = $langs->trans('LegalDisplay'); $helpUrl = 'FR:Module_Digirisk#Soci.C3.A9t.C3.A9.2FOrganisation'; -digirisk_header($title, $helpUrl); ?> - -
- -fetch_optionals(); +digirisk_header($title, $helpUrl); saturne_get_fiche_head($object, 'standardLegalDisplay', $title); // Object card // ------------------------------------------------------------ // Project -$morehtmlref = '
'; +$moreHtmlRef = '
'; $project->fetch($conf->global->DIGIRISKDOLIBARR_DU_PROJECT); -$morehtmlref .= $langs->trans('Project') . ' : ' . getNomUrlProject($project, 1, 'blank', 1); -$morehtmlref .= '
'; +$moreHtmlRef .= $langs->trans('Project') . ' : ' . getNomUrlProject($project, 1, 'blank', 1); +$moreHtmlRef .= '
'; $moduleNameLowerCase = 'mycompany'; -saturne_banner_tab($object,'ref','none', 0, 'ref', 'ref', $morehtmlref, true); +saturne_banner_tab($object,'ref','none', 0, 'ref', 'ref', $moreHtmlRef, true); $moduleNameLowerCase = 'digiriskdolibarr'; -print '' . $langs->trans('ConfigureSecurityAndSocialData') . ' '; -print '
'; +//print ''; print '
'; -print '' . "\n"; - -//JSON Decode and show fields -require_once __DIR__ . '/../../core/tpl/digiriskdocuments/digiriskdolibarr_legaldisplayfields_view.tpl.php'; - -print '
'; -print '
'; +$moreParams = ['loadLegalDisplay' => 1]; +$dashboard->show_dashboard($moreParams); print dol_get_fiche_end(); // Document Generation -- Génération des documents $dirFiles = 'legaldisplay'; -$filedir = $upload_dir . '/' . $dirFiles; -$urlsource = $_SERVER["PHP_SELF"]; -$modulepart = 'digiriskdolibarr:LegalDisplay'; - -if ($permissiontoadd || $permissiontoread) { - $genallowed = 1; -} +$fileDir = $upload_dir . '/' . $dirFiles; +$urlSource = $_SERVER["PHP_SELF"]; +$modulePart = 'digiriskdolibarr:LegalDisplay'; -print saturne_show_documents($modulepart, $dirFiles, $filedir, $urlsource, 1,1, '', 1, 0, 0, 0, 0, '', 0, '', empty($soc->default_lang) ? '' : $soc->default_lang, $object); +print saturne_show_documents($modulePart, $dirFiles, $fileDir, $urlSource, $permissiontoadd, $permissiontodelete, '', 1, 0, 0, 0, 0, '', '', $langs->defaultlang, 0, $object); // End of page llxFooter();