Skip to content

Commit

Permalink
Merge pull request #3145 from evarisk-micka/add_multiselect_recipient
Browse files Browse the repository at this point in the history
#2677 [RiskAssessmentDocument] add: multiselect recipient
  • Loading branch information
nicolas-eoxia authored Apr 15, 2024
2 parents ef028f1 + 0067dde commit 9f68c2a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
23 changes: 13 additions & 10 deletions class/digiriskdolibarrdocuments/riskassessmentdocument.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,19 @@ public function RiskAssessmentDocumentFillJSON()
$json['RiskAssessmentDocument']['emetteurDUER'] = $user->lastname . ' ' . $user->firstname;
$json['RiskAssessmentDocument']['dateGeneration'] = dol_print_date($now, '%d/%m/%Y %H:%M:%S', 'tzuser');

if ($conf->global->DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_RECIPIENT > 0) {
$user->fetch($conf->global->DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_RECIPIENT);

$json['RiskAssessmentDocument']['destinataireDUER'] = $user->lastname . ' ' . $user->firstname;
$json['RiskAssessmentDocument']['telephone'] = $user->office_phone;
$json['RiskAssessmentDocument']['portable'] = $user->user_mobile;
}else {
$json['RiskAssessmentDocument']['destinataireDUER'] = '';
$json['RiskAssessmentDocument']['telephone'] = '';
$json['RiskAssessmentDocument']['portable'] = '';
$userRecipient = json_decode($conf->global->DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_RECIPIENT);

$json['RiskAssessmentDocument']['destinataireDUER'] = '';
$json['RiskAssessmentDocument']['telephone'] = '';
$json['RiskAssessmentDocument']['portable'] = '';
if (is_array($userRecipient) && !empty($userRecipient)) {
foreach ($userRecipient as $recipientId) {
$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']['methodologie'] = $conf->global->DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_METHOD;
Expand Down
2 changes: 1 addition & 1 deletion core/modules/modDigiriskDolibarr.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ public function __construct($db)
// CONST RISK ASSESSMENTDOCUMENT
$i++ => ['DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_AUDIT_START_DATE', 'date', '', '', 0, 'current'],
$i++ => ['DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_AUDIT_END_DATE', 'date', '', '', 0, 'current'],
$i++ => ['DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_RECIPIENT', 'integer', 0, '', 0, 'current'],
$i++ => ['DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_RECIPIENT', 'chaine', '', '', 0, 'current'],
$i++ => ['DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_METHOD', 'chaine', $langs->transnoentities('RiskAssessmentDocumentMethod'), '', 0, 'current'],
$i++ => ['DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_SOURCES', 'chaine', $langs->transnoentities('RiskAssessmentDocumentSources'), '', 0, 'current'],
$i++ => ['DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_IMPORTANT_NOTES', 'chaine', $langs->transnoentities('RiskAssessmentDocumentImportantNote'), '', 0, 'current'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
print '</td></tr>';

// Destinataire

$userRecipient = json_decode($conf->global->DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_RECIPIENT);
print '<tr>';
print '<td class="titlefield"><label for="Recipient">' . $langs->trans("Recipient") . '</label></td><td colspan="2">';
print $form->select_dolusers($conf->global->DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_RECIPIENT, 'Recipient', 0, null, 0, '', '', 0, 0, 0, '', 0, '', '', 0, 0);
print $form->select_dolusers($userRecipient, 'Recipient', 0, null, 0, '', '', 0, 0, 0, '', 0, '', '', 0, 0, true);
print '</td></tr>';

// Méthodologie
Expand Down Expand Up @@ -98,8 +98,13 @@
// Destinataire
print '<tr>';
print '<td class="titlefield">' . $langs->trans("Recipient") . '</td><td colspan="2">';
$user->fetch($conf->global->DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_RECIPIENT);
print $user->lastname . ' ' . $user->firstname;
$recipients = json_decode($conf->global->DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_RECIPIENT);
if (is_array($recipients) && !empty($recipients)) {
foreach ($recipients as $recipientId) {
$user->fetch($recipientId);
print $user->getNomUrl(1) . '<br>';
}
}
print '</td></tr>';

// Méthodologie
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
if (($action == 'update' && ! GETPOST("cancel", 'alpha')) || ($action == 'updateedit') && $permissiontoadd) {
$auditStartDate = GETPOST('AuditStartDate', 'none');
$auditEndDate = GETPOST('AuditEndDate', 'none');
$recipent = GETPOST('Recipient', 'alpha');
$recipient = GETPOST('Recipient', 'array');
$method = GETPOST('Method', 'none');
$sources = GETPOST('Sources', 'none');
$importantNote = GETPOST('ImportantNote', 'none');
Expand All @@ -120,7 +120,7 @@
}
}

dolibarr_set_const($db, "DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_RECIPIENT", $recipent, 'integer', 0, '', $conf->entity);
dolibarr_set_const($db, "DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_RECIPIENT", json_encode($recipient), 'chaine', 0, '', $conf->entity);

dolibarr_set_const($db, "DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_METHOD", $method, 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_SOURCES", $sources, 'chaine', 0, '', $conf->entity);
Expand Down

0 comments on commit 9f68c2a

Please sign in to comment.