Skip to content
Snippets Groups Projects
Commit 0b4cde74 authored by Guillaume Heurtier's avatar Guillaume Heurtier
Browse files

FEAT #12428 TIME 2:30 summary sheet generation with contacts

parent d41e6c91
No related branches found
No related tags found
No related merge requests found
...@@ -481,18 +481,35 @@ class SummarySheetController ...@@ -481,18 +481,35 @@ class SummarySheetController
} }
} elseif ($unit['unit'] == 'senderRecipientInformations') { } elseif ($unit['unit'] == 'senderRecipientInformations') {
$senders = ContactController::getFormattedContacts(['resId' => $resource['res_id'], 'mode' => 'sender']); $senders = null;
$recipients = ContactController::getFormattedContacts(['resId' => $resource['res_id'], 'mode' => 'recipient']); if (in_array('senders', $fieldsIdentifier)) {
$senders = ContactController::getFormattedContacts([
'resId' => $resource['res_id'],
'mode' => 'sender'
]);
if (!empty($senders) && count($senders) > 2) {
$nbSenders = count($senders);
$senders = [];
$senders[0] = $nbSenders . ' ' . _CONTACTS;
}
}
if (!empty($senders) && count($senders) > 2) { $recipients = null;
$nbSenders = count($senders); if (in_array('recipients', $fieldsIdentifier)) {
$senders = []; $recipients = ContactController::getFormattedContacts([
$senders[0] = $nbSenders . ' ' . _CONTACTS; 'resId' => $resource['res_id'],
'mode' => 'recipient'
]);
if (!empty($recipients) && count($recipients) > 2) {
$nbRecipients = count($recipients);
$recipients = [];
$recipients[0] = $nbRecipients . ' ' . _CONTACTS;
}
} }
if (!empty($recipients) && count($recipients) > 2) {
$nbRecipients = count($recipients); // If senders and recipients are both null, they are not part of the model so we continue to the next unit
$recipients = []; if ($senders === null && $recipients === null) {
$recipients[0] = $nbRecipients . ' ' . _CONTACTS; continue;
} }
$pdf->SetY($pdf->GetY() + 40); $pdf->SetY($pdf->GetY() + 40);
...@@ -504,30 +521,60 @@ class SummarySheetController ...@@ -504,30 +521,60 @@ class SummarySheetController
$pdf->SetY($pdf->GetY() + 2); $pdf->SetY($pdf->GetY() + 2);
$pdf->SetFont('', '', 10); $pdf->SetFont('', '', 10);
$pdf->Cell($widthMultiCell, 15, _SENDERS, 1, 0, 'C', false);
$pdf->Cell($widthCell, 15, '', 0, 0, 'C', false); $correspondents = [];
$pdf->Cell($widthMultiCell, 15, _RECIPIENTS, 1, 1, 'C', false); if ($senders !== null && $recipients !== null) {
if (empty($senders) && empty($recipients)) { if (empty($senders[0]) && empty($recipients[0])) {
$pdf->MultiCell($widthMultiCell, 40, _UNDEFINED, 1, 'L', false, 0, '', '', true, 0, true); $correspondents = [null, null];
$pdf->MultiCell($widthCell, 40, '', 0, 'L', false, 0, '', '', true, 0, true); } else {
$pdf->MultiCell($widthMultiCell, 40, _UNDEFINED, 1, 'L', false, 1, '', '', true, 0, true); for ($i = 0; !empty($senders[$i]) || !empty($recipients[$i]); $i++) {
} else { $correspondents[] = $senders[$i] ?? null;
for ($i = 0; !empty($senders[$i]) || !empty($recipients[$i]); $i++) { $correspondents[] = $recipients[$i] ?? null;
if ($i == 0 && empty($senders[$i])) {
$pdf->MultiCell($widthMultiCell, 40, _UNDEFINED, 1, 'L', false, 0, '', '', true, 0, true);
} else {
$pdf->MultiCell($widthMultiCell, 40, empty($senders[$i]) ? '' : $senders[$i], empty($senders[$i]) ? 0 : 1, 'L', false, 0, '', '', true, 0, true);
} }
}
$pdf->MultiCell($widthCell, 40, '', 0, 'L', false, 0, '', '', true, 0, true); $pdf->Cell($widthMultiCell, 15, _SENDERS, 1, 0, 'C', false);
$pdf->Cell($widthCell, 15, '', 0, 0, 'C', false);
$pdf->Cell($widthMultiCell, 15, _RECIPIENTS, 1, 1, 'C', false);
} else if ($senders !== null && $recipients === null) {
$correspondents = $senders;
if ($i == 0 && empty($recipients[$i])) { $pdf->Cell($widthMultiCell, 15, _SENDERS, 1, 1, 'C', false);
$pdf->MultiCell($widthMultiCell, 40, _UNDEFINED, 1, 'L', false, 1, '', '', true, 0, true); } else if ($senders === null && $recipients !== null) {
} else { $correspondents = $recipients;
$pdf->MultiCell($widthMultiCell, 40, empty($recipients[$i]) ? '' : $recipients[$i], empty($recipients[$i]) ? 0 : 1, 'L', false, 1, '', '', true, 0, true);
$pdf->Cell($widthMultiCell, 15, _RECIPIENTS, 1, 1, 'C', false);
}
// allow to skip an element in the senders or recipients column if we already printed UNDEFINED once
$columnUndefined = [false, false];
$nextLine = 1;
foreach ($correspondents as $correspondent) {
// if senders and recipients are not null, nextLine alternate between 0 and 1, otherwise its always 1
if ($senders !== null && $recipients !== null) {
$nextLine = ($nextLine + 1) % 2;
if ($columnUndefined[$nextLine]) {
$pdf->MultiCell($widthMultiCell, 40, '', 0, 'L', false, 0, '', '', true, 0, true);
$pdf->MultiCell($widthCell, 40, '', 0, 'L', false, $nextLine, '', '', true, 0, true);
continue;
} }
} else {
$nextLine = 1;
}
if (empty($correspondent)) {
$columnUndefined[$nextLine] = true;
$pdf->MultiCell($widthMultiCell, 40, _UNDEFINED, 1, 'L', false, $nextLine, '', '', true, 0, true);
} else {
$pdf->MultiCell($widthMultiCell, 40, empty($correspondent) ? '' : $correspondent, empty($correspondent) ? 0 : 1, 'L', false, $nextLine, '', '', true, 0, true);
}
if ($nextLine == 0) {
$pdf->MultiCell($widthCell, 40, '', 0, 'L', false, 0, '', '', true, 0, true);
} }
} }
} elseif ($unit['unit'] == 'diffusionList') { } elseif ($unit['unit'] == 'diffusionList') {
$assignee = ''; $assignee = '';
$destination = ''; $destination = '';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment