Skip to content

Commit

Permalink
fix: legaldisplay&informationssharing bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
evarisk-theo committed Jan 29, 2021
1 parent 76cd512 commit fade43d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 51 deletions.
59 changes: 30 additions & 29 deletions class/informationssharing.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,77 +173,78 @@ public function InformationssharingFillJSON($object) {
// *** JSON FILLING ***
if (!empty ($digirisk_resources)) {

$json['InformationsSharing']['delegues_du_personnels_date'] = $conf->global->DIGIRISK_CSE_ELECTION_DATE;
$json['InformationsSharing']['delegues_du_personnels_date'] = $conf->global->DIGIRISK_DP_ELECTION_DATE;
$json['InformationsSharing']['delegues_du_personnels_titulaires'] = '';

if (!empty ($digirisk_resources['TitularsCSE']->id )) {
foreach ($digirisk_resources['TitularsCSE']->id as $cse_titular) {
if (!empty ($digirisk_resources['TitularsDP']->id )) {
foreach ($digirisk_resources['TitularsDP']->id as $dp_titular) {

$cse_titulars = new User($this->db);
$result = $cse_titulars->fetch($cse_titular);
$dp_titulars = new User($this->db);
$result = $dp_titulars->fetch($dp_titular);
if ($result > 0) {
$json['InformationsSharing']['delegues_du_personnels_titulaires'] .= $cse_titulars->firstname . " " . $cse_titulars->lastname ;
$json['InformationsSharing']['delegues_du_personnels_titulaires'] .= $dp_titulars->firstname . " " . $dp_titulars->lastname ;
}
}
}

$json['InformationsSharing']['delegues_du_personnels_suppleants'] = '';

if (!empty ($digirisk_resources['AlternatesCSE']->id )) {
foreach ($digirisk_resources['AlternatesCSE']->id as $cse_alternate) {
if (!empty ($digirisk_resources['AlternatesDP']->id )) {
foreach ($digirisk_resources['AlternatesDP']->id as $dp_alternate) {

$cse_alternates = new User($this->db);
$result = $cse_alternates->fetch($cse_alternate);
$dp_alternates = new User($this->db);
$result = $dp_alternates->fetch($dp_alternate);
if ($result > 0) {
$json['InformationsSharing']['delegues_du_personnels_suppleants'] .= $cse_alternates->firstname . " " . $cse_alternates->lastname ;
$json['InformationsSharing']['delegues_du_personnels_suppleants'] .= $dp_alternates->firstname . " " . $dp_alternates->lastname ;
}
}
}

$json['InformationsSharing']['delegues_du_personnels_suppleants'] = '';

if (!empty ($digirisk_resources['AlternatesCSE']->id )) {
foreach ($digirisk_resources['AlternatesCSE']->id as $cse_alternate) {
if (!empty ($digirisk_resources['AlternatesDP']->id )) {
foreach ($digirisk_resources['AlternatesDP']->id as $dp_alternate) {

$cse_alternates = new User($this->db);
$result = $cse_alternates->fetch($cse_alternate);
$dp_alternates = new User($this->db);
$result = $dp_alternates->fetch($dp_alternate);
if ($result > 0) {
$json['InformationsSharing']['delegues_du_personnels_suppleants'] .= $cse_alternates->firstname . " " . $cse_alternates->lastname ;
$json['InformationsSharing']['delegues_du_personnels_suppleants'] .= $dp_alternates->firstname . " " . $dp_alternates->lastname ;
}
}
}

$json['InformationsSharing']['membres_du_comite_entreprise_date'] = $conf->global->DIGIRISK_DP_ELECTION_DATE;
// CSE
$json['InformationsSharing']['membres_du_comite_entreprise_date'] = $conf->global->DIGIRISK_CSE_ELECTION_DATE;


$json['InformationsSharing']['membres_du_comite_entreprise_titulaires'] = '';

if (!empty ($digirisk_resources['TitularsDP']->id )) {
foreach ($digirisk_resources['TitularsDP']->id as $dp_titular) {
if (!empty ($digirisk_resources['TitularsCSE']->id )) {
foreach ($digirisk_resources['TitularsCSE']->id as $cse_titular) {

$dp_titulars = new User($this->db);
$result = $dp_titulars->fetch($dp_titular);
$cse_titulars = new User($this->db);
$result = $cse_titulars->fetch($cse_titular);
if ($result > 0) {
$json['InformationsSharing']['membres_du_comite_entreprise_titulaires'] .= $dp_titulars->firstname . " " . $dp_titulars->lastname ;
$json['InformationsSharing']['membres_du_comite_entreprise_titulaires'] .= $cse_titulars->firstname . " " . $cse_titulars->lastname ;
}
}
}

$json['InformationsSharing']['membres_du_comite_entreprise_suppleants'] = '';

if (!empty ($digirisk_resources['AlternatesDP']->id )) {
foreach ($digirisk_resources['AlternatesDP']->id as $dp_alternate) {
if (!empty ($digirisk_resources['AlternatesCSE']->id )) {
foreach ($digirisk_resources['AlternatesCSE']->id as $cse_alternate) {

$dp_alternates = new User($this->db);
$result = $dp_alternates->fetch($dp_alternate);
$cse_alternates = new User($this->db);
$result = $cse_alternates->fetch($cse_alternate);
if ($result > 0) {
$json['InformationsSharing']['membres_du_comite_entreprise_suppleants'] .= $dp_alternates->firstname . " " . $dp_alternates->lastname ;
$json['InformationsSharing']['membres_du_comite_entreprise_suppleants'] .= $cse_alternates->firstname . " " . $cse_alternates->lastname ;
}
}
}

$object->json = json_encode($json, JSON_UNESCAPED_UNICODE);
return $object->json;
$object->json = json_encode($json, JSON_UNESCAPED_UNICODE);
return $object->json;

}
else
Expand Down
33 changes: 11 additions & 22 deletions class/legaldisplay.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ public function LegaldisplayFillJSON($object) {
$labour_doctor_societe = new Societe($this->db);
$result = $labour_doctor_societe->fetch($digirisk_resources['LabourDoctorSociety']->id[0]);

if ($result < 0) dol_print_error($langs->trans('NoLabourDoctorAssigned'), $labour_doctor_societe->error);
elseif ($result > 0) {
if ($result > 0) {

$labour_doctor_openinghours = $thirdparty_openinghours->fetch_by_element($labour_doctor_societe->id, $labour_doctor_societe->element);
$json['LegalDisplay']['occupational_health_service']['openinghours'] = "\r\n" . $labour_doctor_openinghours->day0 . "\r\n" . $labour_doctor_openinghours->day1 . "\r\n" . $labour_doctor_openinghours->day2 . "\r\n" . $labour_doctor_openinghours->day3 . "\r\n" . $labour_doctor_openinghours->day4 . "\r\n" . $labour_doctor_openinghours->day5 . "\r\n" . $labour_doctor_openinghours->day6;
Expand All @@ -189,8 +188,7 @@ public function LegaldisplayFillJSON($object) {
$labour_doctor_contact = new Contact($this->db);
$result = $labour_doctor_contact->fetch($digirisk_resources['LabourDoctorContact']->id[0]);

if ($result < 0) dol_print_error($langs->trans('NoLabourDoctorAssigned'), $labour_doctor_contact->error);
elseif ($result > 0) {
if ($result > 0) {
$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;
Expand All @@ -201,8 +199,7 @@ public function LegaldisplayFillJSON($object) {
$labour_inspector_societe = new Societe($this->db);
$result = $labour_inspector_societe->fetch($digirisk_resources['LabourInspectorSociety']->id[0]);

if ($result < 0) dol_print_error($langs->trans('NoLabourInspectorAssigned'), $labour_inspector_societe->error);
elseif ($result > 0) {
if ($result > 0) {

$labour_inspector_openinghours = $thirdparty_openinghours->fetch_by_element($labour_inspector_societe->id, $labour_inspector_societe->element);
$json['LegalDisplay']['detective_work']['openinghours'] = "\r\n" . $labour_inspector_openinghours->day0 . "\r\n" . $labour_inspector_openinghours->day1 . "\r\n" . $labour_inspector_openinghours->day2 . "\r\n" . $labour_inspector_openinghours->day3 . "\r\n" . $labour_inspector_openinghours->day4 . "\r\n" . $labour_inspector_openinghours->day5 . "\r\n" . $labour_inspector_openinghours->day6;
Expand All @@ -212,8 +209,7 @@ public function LegaldisplayFillJSON($object) {
$labour_inspector_contact = new Contact($this->db);
$result = $labour_inspector_contact->fetch($digirisk_resources['LabourInspectorContact']->id[0]);

if ($result < 0) dol_print_error($langs->trans('NoLabourInspectorAssigned'), $labour_inspector_contact->error);
elseif ($result > 0) {
if ($result > 0) {
$json['LegalDisplay']['detective_work']['name'] = $labour_inspector_contact->firstname . " " . $labour_inspector_contact->lastname;
$json['LegalDisplay']['detective_work']['address'] = preg_replace('/\s\s+/', ' ', $labour_inspector_contact->address);
$json['LegalDisplay']['detective_work']['zip'] = $labour_inspector_contact->zip;
Expand All @@ -224,56 +220,49 @@ public function LegaldisplayFillJSON($object) {
$samu = new Societe($this->db);
$result = $samu->fetch($digirisk_resources['SAMU']->id[0]);

if ($result < 0) dol_print_error($langs->trans('NoSamuAssigned'), $samu->error);
elseif ($result > 0) {
if ($result > 0) {
$json['LegalDisplay']['emergency_service']['samu'] = $samu->phone;
}

$police = new Societe($this->db);
$result = $police->fetch($digirisk_resources['Police']->id[0]);

if ($result < 0) dol_print_error($langs->trans('NoPoliceAssigned'), $police->error);
elseif ($result > 0) {
if ($result > 0) {
$json['LegalDisplay']['emergency_service']['police'] = $police->phone;
}

$pompier = new Societe($this->db);
$result = $pompier->fetch($digirisk_resources['Pompiers']->id[0]);

if ($result < 0) dol_print_error($langs->trans('NoPoliceAssigned'), $pompier->error);
elseif ($result > 0) {
if ($result > 0) {
$json['LegalDisplay']['emergency_service']['pompier'] = $pompier->phone;
}

$emergency = new Societe($this->db);
$result = $emergency->fetch($digirisk_resources['AllEmergencies']->id[0]);

if ($result < 0) dol_print_error($langs->trans('NoAllEmergenciesAssigned'), $emergency->error);
elseif ($result > 0) {
if ($result > 0) {
$json['LegalDisplay']['emergency_service']['emergency'] = $emergency->phone;
}

$rights_defender = new Societe($this->db);
$result = $rights_defender->fetch($digirisk_resources['RightsDefender']->id[0]);

if ($result < 0) dol_print_error($langs->trans('NoRightsDefenderAssigned'), $rights_defender->error);
elseif ($result > 0) {
if ($result > 0) {
$json['LegalDisplay']['emergency_service']['right_defender'] = $rights_defender->phone;
}

$antipoison = new Societe($this->db);
$result = $antipoison->fetch($digirisk_resources['Antipoison']->id[0]);

if ($result < 0) dol_print_error($langs->trans('NoRightsDefenderAssigned'), $antipoison->error);
elseif ($result > 0) {
if ($result > 0) {
$json['LegalDisplay']['emergency_service']['poison_control_center'] = $antipoison->phone;
}

$responsible_prevent = new User($this->db);
$result = $responsible_prevent->fetch($digirisk_resources['Responsible']->id[0]);

if ($result < 0) dol_print_error($langs->trans('NoResponsibleAssigned'), $responsible_prevent->error);
elseif ($result > 0) {
if ($result > 0) {
$json['LegalDisplay']['safety_rule']['responsible_for_preventing'] = $responsible_prevent->firstname . " " . $responsible_prevent->lastname;
$json['LegalDisplay']['safety_rule']['phone'] = $responsible_prevent->office_phone;
}
Expand Down

0 comments on commit fade43d

Please sign in to comment.