Skip to content

Commit

Permalink
Evarisk#3682 [Class] fix: add gauge on widgets on legal display and i…
Browse files Browse the repository at this point in the history
…nformation sharing
  • Loading branch information
evarisk-charles committed Feb 26, 2024
1 parent 4d3e0d9 commit 006f9a3
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 5 deletions.
15 changes: 14 additions & 1 deletion class/digiriskdolibarrdocuments/informationssharing.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ public function load_dashboard(): array

$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];

require_once __DIR__ . '/../../core/tpl/digiriskdolibarr_informationssharing_percentages.tpl.php';

$dashboardData['widgets'] = [
'labour_doctor' => [
'label' => [
Expand All @@ -196,6 +204,7 @@ public function load_dashboard(): array
1 => dol_strlen($informationsSharing->occupational_health_service->phone) > 0 ? $informationsSharing->occupational_health_service->phone : $langs->trans('NoData'),
],
'picto' => 'fas fa-user-md',
'progressBar' => '<div class="progress-group"><div class="progress sm"><div class="progress-bar progress-info" style="width: ' . $percentageLabourDoctor . '%;" title="0%"><div class="progress-bar progress-bar-consumed" style="width: 0%;" title="0%"></div></div></div></div>',
'widgetName' => $langs->transnoentities('Society')
],
'labour_inspector' => [
Expand All @@ -210,6 +219,7 @@ public function load_dashboard(): array
1 => dol_strlen($informationsSharing->detective_work->phone) > 0 ? $informationsSharing->detective_work->phone : $langs->trans('NoData')
],
'picto' => 'fas fa-briefcase',
'progressBar' => '<div class="progress-group"><div class="progress sm"><div class="progress-bar progress-info" style="width: ' . $percentageDetectiveWork . '%;" title="0%"><div class="progress-bar progress-bar-consumed" style="width: 0%;" title="0%"></div></div></div></div>',
'widgetName' => $langs->transnoentities('Society')
],
'harassment_officer' => [
Expand All @@ -228,6 +238,7 @@ public function load_dashboard(): array
3 => dol_strlen($informationsSharing->harassment_officer_cse->phone) > 0 ? $informationsSharing->harassment_officer_cse->phone : $langs->trans('NoData'),
],
'picto' => 'fas fa-bullhorn',
'progressBar' => '<div class="progress-group"><div class="progress sm"><div class="progress-bar progress-info" style="width: ' . $percentageHarassmentOfficer . '%;" title="0%"><div class="progress-bar progress-bar-consumed" style="width: 0%;" title="0%"></div></div></div></div>',
'widgetName' => $langs->transnoentities('Society')
],
'delegues_du_personnels' => [
Expand All @@ -245,6 +256,7 @@ public function load_dashboard(): array
0 => dol_strlen($informationsSharing->delegues_du_personnels_date) > 0 ? $informationsSharing->delegues_du_personnels_date : $langs->trans('NoData')
],
'picto' => 'fas fa-users',
'progressBar' => '<div class="progress-group"><div class="progress sm"><div class="progress-bar progress-info" style="width: ' . $percentageDeleguePersonnel . '%;" title="0%"><div class="progress-bar progress-bar-consumed" style="width: 0%;" title="0%"></div></div></div></div>',
'widgetName' => $langs->transnoentities('Society')
],
'membres_du_comite_entreprise' => [
Expand All @@ -259,9 +271,10 @@ public function load_dashboard(): array
2 => dol_strlen($informationsSharing->membres_du_comite_entreprise_suppleantsFullName) > 0 ? $informationsSharing->membres_du_comite_entreprise_suppleantsFullName : $langs->trans('NoData'),
],
'content' => [
0 => dol_strlen($informationsSharing->delegues_du_personnels_date) > 0 ? $informationsSharing->delegues_du_personnels_date : $langs->trans('NoData')
0 => dol_strlen($informationsSharing->membres_du_comite_entreprise_date) > 0 ? $informationsSharing->membres_du_comite_entreprise_date : $langs->trans('NoData')
],
'picto' => 'fas fa-user-graduate',
'progressBar' => '<div class="progress-group"><div class="progress sm"><div class="progress-bar progress-info" style="width: ' . $percentageMembreComitee . '%;" title="0%"><div class="progress-bar progress-bar-consumed" style="width: 0%;" title="0%"></div></div></div></div>',
'widgetName' => $langs->transnoentities('Society')
],
];
Expand Down
26 changes: 22 additions & 4 deletions class/digiriskdolibarrdocuments/legaldisplay.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,17 @@ public function load_dashboard(): array

$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->detective_work->opening_hours_details->monday, $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];

require_once __DIR__ . '/../../core/tpl/digiriskdolibarr_legaldisplay_percentages.tpl.php';

$dashboardData['widgets'] = [
'labour_doctor' => [
'label' => [
Expand All @@ -287,9 +298,10 @@ public function load_dashboard(): array
3 => dol_strlen($legalDisplay->occupational_health_service->town) > 0 ? $legalDisplay->occupational_health_service->town : $langs->trans('NoData'),
4 => dol_strlen($legalDisplay->occupational_health_service->phone) > 0 ? $legalDisplay->occupational_health_service->phone : $langs->trans('NoData'),
],
'link' => '<a href="../../admin/securityconf.php" target="_blank">' . $langs->trans('ConfigureSecurityAndSocialData') . ' <i class="fas fa-external-link-alt"></i></a>',
'picto' => 'fas fa-user-md',
'widgetName' => $langs->transnoentities('Society')
'link' => '<a href="../../admin/securityconf.php" target="_blank">' . $langs->trans('ConfigureSecurityAndSocialData') . ' <i class="fas fa-external-link-alt"></i></a>',
'picto' => 'fas fa-user-md',
'progressBar' => '<div class="progress-group"><div class="progress sm"><div class="progress-bar progress-info" style="width: ' . $percentageLabourDoctor . '%;" title="0%"><div class="progress-bar progress-bar-consumed" style="width: 0%;" title="0%"></div></div></div></div>',
'widgetName' => $langs->transnoentities('Society')
],
'labour_doctor_schedules' => [
'label' => [
Expand All @@ -313,6 +325,7 @@ public function load_dashboard(): array
],
'link' => '<a href="' . dol_buildpath('saturne/view/saturne_schedules.php?id=' . $legalDisplay->occupational_health_service->id . '&element_type=societe&module_name=societe', 1) .'" target="_blank">' . $langs->trans('ConfigureSecurityAndSocialData') . ' <i class="fas fa-external-link-alt"></i></a>',
'picto' => 'fas fa-clock',
'progressBar' => '<div class="progress-group"><div class="progress sm"><div class="progress-bar progress-info" style="width: ' . $percentageLabourDoctorTime . '%;" title="0%"><div class="progress-bar progress-bar-consumed" style="width: 0%;" title="0%"></div></div></div></div>',
'widgetName' => $langs->transnoentities('Society')
],
'labour_inspector' => [
Expand All @@ -322,7 +335,6 @@ public function load_dashboard(): array
$langs->transnoentities('Address') ?? '',
$langs->transnoentities('Town') ?? '',
$langs->transnoentities('Phone') ?? '',
$langs->transnoentities('Link') ?? '',
],
'customContent' => [
0 => dol_strlen($legalDisplay->detective_work->fullname) > 0 ? $legalDisplay->detective_work->fullname : $langs->trans('NoData'),
Expand All @@ -335,6 +347,7 @@ public function load_dashboard(): array
],
'link' => '<a href="../../admin/securityconf.php" target="_blank">' . $langs->trans('ConfigureSecurityAndSocialData') . ' <i class="fas fa-external-link-alt"></i></a>',
'picto' => 'fas fa-briefcase',
'progressBar' => '<div class="progress-group"><div class="progress sm"><div class="progress-bar progress-info" style="width: ' . $percentageDetectiveWork . '%;" title="0%"><div class="progress-bar progress-bar-consumed" style="width: 0%;" title="0%"></div></div></div></div>',
'widgetName' => $langs->transnoentities('Society')
],
'detective_work_schedules' => [
Expand All @@ -359,6 +372,7 @@ public function load_dashboard(): array
],
'link' => '<a href="' . dol_buildpath('saturne/view/saturne_schedules.php?id=' . $legalDisplay->detective_work->id . '&element_type=societe&module_name=societe', 1) .'"" target="_blank">' . $langs->trans('ConfigureSecurityAndSocialData') . ' <i class="fas fa-external-link-alt"></i></a>',
'picto' => 'fas fa-clock',
'progressBar' => '<div class="progress-group"><div class="progress sm"><div class="progress-bar progress-info" style="width: ' . $percentageDetectiveWorkTime . '%;" title="0%"><div class="progress-bar progress-bar-consumed" style="width: 0%;" title="0%"></div></div></div></div>',
'widgetName' => $langs->transnoentities('Society')
],
'emergency_calls' => [
Expand All @@ -380,6 +394,7 @@ public function load_dashboard(): array
],
'link' => '<a href="../../admin/securityconf.php" target="_blank">' . $langs->trans('ConfigureSecurityAndSocialData') . ' <i class="fas fa-external-link-alt"></i></a>',
'picto' => 'fas fa-ambulance',
'progressBar' => '<div class="progress-group"><div class="progress sm"><div class="progress-bar progress-info" style="width: ' . $percentageEmergencyService . '%;" title="0%"><div class="progress-bar progress-bar-consumed" style="width: 0%;" title="0%"></div></div></div></div>',
'widgetName' => $langs->transnoentities('Emergency')
],
'safety_rule' => [
Expand All @@ -395,6 +410,7 @@ public function load_dashboard(): array
],
'link' => '<a href="../../admin/securityconf.php" target="_blank">' . $langs->trans('ConfigureSecurityAndSocialData') . ' <i class="fas fa-external-link-alt"></i></a>',
'picto' => 'fas fa-user-tie',
'progressBar' => '<div class="progress-group"><div class="progress sm"><div class="progress-bar progress-info" style="width: ' . $percentageSafetyRule . '%;" title="0%"><div class="progress-bar progress-bar-consumed" style="width: 0%;" title="0%"></div></div></div></div>',
'widgetName' => $langs->transnoentities('Emergency')
],
'working_time' => [
Expand All @@ -418,6 +434,7 @@ public function load_dashboard(): array
],
'link' => '<a href="' . dol_buildpath('../admin/openinghours.php', 1) .'"" target="_blank">' . $langs->trans('ConfigureSecurityAndSocialData') . ' <i class="fas fa-external-link-alt"></i></a>',
'picto' => 'fas fa-clock',
'progressBar' => '<div class="progress-group"><div class="progress sm"><div class="progress-bar progress-info" style="width: ' . $percentageWorkingHour . '%;" title="0%"><div class="progress-bar progress-bar-consumed" style="width: 0%;" title="0%"></div></div></div></div>',
'widgetName' => $langs->transnoentities('Emergency')
],
'information' => [
Expand All @@ -437,6 +454,7 @@ public function load_dashboard(): array
],
'link' => '<a href="../../admin/securityconf.php" target="_blank">' . $langs->trans('ConfigureSecurityAndSocialData') . ' <i class="fas fa-external-link-alt"></i></a>',
'picto' => 'fas fa-info',
'progressBar' => '<div class="progress-group"><div class="progress sm"><div class="progress-bar progress-info" style="width: ' . $percentageParameters . '%;" title="0%"><div class="progress-bar progress-bar-consumed" style="width: 0%;" title="0%"></div></div></div></div>',
'widgetName' => $langs->transnoentities('Emergency')
],
];
Expand Down
60 changes: 60 additions & 0 deletions core/tpl/digiriskdolibarr_informationssharing_percentages.tpl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php
/* Copyright (C) 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* or see https://www.gnu.org/
*/

// foreach to recolt all the values
foreach ($labourDoctor as $value) {
$labourDoctorTotal++;
if (dol_strlen($value) > 0) {
$LabourDoctorCheck++;
}
}

foreach ($detectiveWork as $value) {
$detectiveWorkTotal++;
if (dol_strlen($value) > 0) {
$detectiveWorkCheck++;
}
}

foreach ($harassmentOfficer as $value) {
$harassmentOfficerTotal++;
if (dol_strlen($value) > 0) {
$harassmentOfficerCheck++;
}
}

foreach ($deleguePersonnel as $value) {
$deleguePersonnelTotal++;
if (dol_strlen($value) > 0) {
$deleguePersonnelCheck++;
}
}

foreach ($membreComitee as $value) {
$membreComiteeTotal++;
if (dol_strlen($value) > 0) {
$membreComiteeCheck++;
}
}

// calculs for the percentage of the gauge
$percentageLabourDoctor = $LabourDoctorCheck / $labourDoctorTotal * 100;
$percentageDetectiveWork = $detectiveWorkCheck / $detectiveWorkTotal * 100;
$percentageHarassmentOfficer = $harassmentOfficerCheck / $harassmentOfficerTotal * 100;
$percentageDeleguePersonnel = $deleguePersonnelCheck / $deleguePersonnelTotal * 100;
$percentageMembreComitee = $membreComiteeCheck / $membreComiteeTotal * 100;
Loading

0 comments on commit 006f9a3

Please sign in to comment.