Skip to content

Commit

Permalink
Evarisk#3864 [Audit] add: recipient field
Browse files Browse the repository at this point in the history
  • Loading branch information
evarisk-micka committed Jun 12, 2024
1 parent d742572 commit 5344da1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public function RiskAssessmentDocumentFillJSON()
$user->fetch($recipientId);

$json['RiskAssessmentDocument']['destinataireDUER'] .= dol_strtoupper($user->lastname) . ' ' . ucfirst($user->firstname) . chr(0x0A);
$json['RiskAssessmentDocument']['telephone'] .= $user->office_phone . chr(0x0A);
$json['RiskAssessmentDocument']['portable'] .= $user->user_mobile . chr(0x0A);
$json['RiskAssessmentDocument']['telephone'] .= (dol_strlen($user->office_phone) > 0 ? $user->office_phone : '-') . chr(0x0A);
$json['RiskAssessmentDocument']['portable'] .= (dol_strlen($user->user_mobile) > 0 ? $user->user_mobile : '-') . chr(0x0A);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public function write_file(SaturneDocuments $objectDocument, Translate $outputLa
$riskSign = new RiskSign($this->db);
$evaluator = new Evaluator($this->db);
$accident = new Accident($this->db);
$user = new User($this->db);

$arraySoc = $this->get_substitutionarray_mysoc($mysoc, $outputLangs);
$tmpArray['mycompany_photo_fullsize'] = $arraySoc['mycompany_logo'];
Expand All @@ -119,7 +120,7 @@ public function write_file(SaturneDocuments $objectDocument, Translate $outputLa
complete_substitutions_array($tmpArray, $outputLangs, $objectDocument);
$objectDocument->element = $previousObjectDocumentElement;

if (!empty($moreParam['dateStart']) && $moreParam['dateEnd']) {
if (!empty($moreParam['dateStart']) && !empty($moreParam['dateEnd'])) {
$startDate = dol_print_date($moreParam['dateStart'], 'dayrfc');
$endDate = dol_print_date($moreParam['dateEnd'], 'dayrfc');
$filter = " AND (t.date_creation BETWEEN '$startDate' AND '$endDate' OR t.tms BETWEEN '$startDate' AND '$endDate')";
Expand All @@ -133,6 +134,21 @@ public function write_file(SaturneDocuments $objectDocument, Translate $outputLa
$moreParam['specificFilter'] = $specificFilter;
}

if (!empty($moreParam['recipient']) && is_array($moreParam['recipient'])) {
$userRecipient = $moreParam['recipient'];

$tmpArray['destinataireDUER'] = '';
$tmpArray['telephone'] = '';
$tmpArray['portable'] = '';
foreach ($userRecipient as $recipientId) {
$user->fetch($recipientId);

$tmpArray['destinataireDUER'] .= dol_strtoupper($user->lastname) . ' ' . ucfirst($user->firstname) . chr(0x0A);
$tmpArray['telephone'] .= (dol_strlen($user->office_phone) > 0 ? $user->office_phone : '-') . chr(0x0A);
$tmpArray['portable'] .= (dol_strlen($user->user_mobile) > 0 ? $user->user_mobile : '-') . chr(0x0A);
}
}

$groupments = [];
$workUnits = [];
$digiriskElements = $digiriskElement->getActiveDigiriskElements(0, $moreParam);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
if (GETPOST('daterange')) {
$moreParams['dateStart'] = dol_mktime(0, 0, 0, GETPOST('datestartmonth', 'int'), GETPOST('datestartday', 'int'), GETPOST('datestartyear', 'int'));
$moreParams['dateEnd'] = dol_mktime(0, 0, 0, GETPOST('dateendmonth', 'int'), GETPOST('dateendday', 'int'), GETPOST('dateendyear', 'int'));
$moreParams['recipient'] = GETPOST('recipient');
}
}

Expand Down Expand Up @@ -136,6 +137,12 @@
print $langs->trans('UseDateRange');
print '<input type="checkbox" id="daterange" name="daterange" checked>';
print '</td></tr>';

// Destinataire
$userRecipient = json_decode($conf->global->DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_RECIPIENT);
print '<tr class="oddeven"><td>' . $langs->trans("Recipient") . '</td>';
print '<td>' . $form->select_dolusers($userRecipient, 'recipient', 0, null, 0, '', '', 0, 0, 0, '', 0, '', 'minwidth400', 0, 0, true);
print '</td></tr>';
print '</table>';

$objRef = dol_sanitizeFileName($object->ref);
Expand Down

0 comments on commit 5344da1

Please sign in to comment.