Commit 8199b251 authored by Jean-Laurent DUZANT's avatar Jean-Laurent DUZANT
Browse files

FIX #19325 TIME 0:30 Use ConvertPdfController instead of Fpdi && delete all...

FIX #19325 TIME 0:30 Use ConvertPdfController instead of Fpdi && delete all tmp email_*.pdf, attachment_*.pdf, summarySheet_*.pdf, convertedAr_*.pdf and listNotes_*.pdf after pdf merged is complete - Jean-Laurent
parent 5e9c88fe
......@@ -596,6 +596,12 @@ class FolderPrintController
if (!file_exists($filePathOnTmp)) {
return $response->withStatus(500)->withJson(['errors' => 'Merge PDF file not created']);
}
// delete all tmp email_*.pdf, attachment_*.pdf, summarySheet_*.pdf, convertedAr_*.pdf and listNotes_*.pdf after merged is complete
foreach ($documentPaths as $documentPath) {
unlink($documentPath);
}
$folderPrintPaths[] = $filePathOnTmp;
}
}
......@@ -974,52 +980,55 @@ class FolderPrintController
$status = _EMAIL_ERROR_SENT;
}
// make branch
$pdf = new Fpdi('P', 'pt');
$pdf->setPrintHeader(false);
$pdf->AddPage();
$dimensions = $pdf->getPageDimensions();
$widthNoMargins = $dimensions['w'] - $dimensions['rm'] - $dimensions['lm'];
$width = $widthNoMargins / 2;
$widthQuarter = $widthNoMargins / 4;
$widthThreeQuarter = $widthQuarter * 3;
$pdf->SetFont('', 'B', 12);
$pdf->Cell($width, 15, _EMAIL, 0, 0, 'L', false);
$pdf->SetFont('', '', 11);
$pdf->Cell($width, 15, $sentDate, 0, 1, 'R', false);
$pdf->SetY($pdf->GetY() + 5);
$pdf->SetFont('', '', 10);
$pdf->MultiCell($widthQuarter, 30, '<b>' . _SENDER.'</b>', 1, 'L', false, 0, '', '', true, 0, true);
$pdf->MultiCell($widthThreeQuarter, 30, $sender, 1, 'L', false, 1, '', '', true, 0, true);
$pdf->MultiCell($widthQuarter, 30, '<b>' . _RECIPIENTS . '</b>', 1, 'L', false, 0, '', '', true, 0, true);
$pdf->MultiCell($widthThreeQuarter, 30, $recipients, 1, 'L', false, 1, '', '', true, 0, true);
$pdf->MultiCell($widthQuarter, 30, '<b>' . _TO_CC . '</b>', 1, 'L', false, 0, '', '', true, 0, true);
$pdf->MultiCell($widthThreeQuarter, 30, $recipientsCopy, 1, 'L', false, 1, '', '', true, 0, true);
$pdf->MultiCell($widthQuarter, 30, '<b>' . _TO_CCI . '</b>', 1, 'L', false, 0, '', '', true, 0, true);
$pdf->MultiCell($widthThreeQuarter, 30, $recipientsCopyHidden, 1, 'L', false, 1, '', '', true, 0, true);
$pdf->MultiCell($widthQuarter, 30, '<b>' . _SUBJECT . '</b>', 1, 'L', false, 0, '', '', true, 0, true);
$pdf->MultiCell($widthThreeQuarter, 30, $subject, 1, 'L', false, 1, '', '', true, 0, true);
$pdf->MultiCell($widthQuarter, 30, '<b>' . _STATUS . '</b>', 1, 'L', false, 0, '', '', true, 0, true);
$pdf->MultiCell($widthThreeQuarter, 30, $status, 1, 'L', false, 1, '', '', true, 0, true);
$pdf->SetY($pdf->GetY() + 5);
$pdf->writeHTML($email['body']);
$widthTable_px = "1200px";
$cellPaddingBottom_px = "30px";
$emailMeta = "<table style=\"width: $widthTable_px;\" cellspacing=\"0\" cellpadding=\"5\">
<tbody>
<tr style=\"border-syle: none;\">
<td style=\"\"><b>"._EMAIL."</b></td>
<td style=\"text-align: right; \">$sentDate</td>
</tr>
</tbody>
</table>
<table style=\"width: $widthTable_px; border-style: solid; border-color: #000000;\" border=\"1\" cellspacing=\"0\" cellpadding=\"5\">
<tbody>
<tr>
<td style=\"padding-bottom: $cellPaddingBottom_px;\"><b>"._SENDER."</b></td>
<td style=\"padding-bottom: $cellPaddingBottom_px;\">$sender</td>
</tr>
<tr>
<td style=\"padding-bottom: $cellPaddingBottom_px;\"><b>"._RECIPIENTS."</b></td>
<td style=\"padding-bottom: $cellPaddingBottom_px;\">$recipients</td>
</tr>
<tr>
<td style=\"padding-bottom: $cellPaddingBottom_px;\"><b>"._TO_CC."</b></td>
<td style=\"padding-bottom: $cellPaddingBottom_px;\">$recipientsCopy</td>
</tr>
<tr>
<td style=\"padding-bottom: $cellPaddingBottom_px;\"><b>"._TO_CCI."</b></td>
<td style=\"padding-bottom: $cellPaddingBottom_px;\">$recipientsCopyHidden</td>
</tr>
<tr>
<td style=\"padding-bottom: $cellPaddingBottom_px;\"><b>"._SUBJECT."</b></td>
<td style=\"padding-bottom: $cellPaddingBottom_px;\">$subject</td>
</tr>
<tr>
<td style=\"padding-bottom: $cellPaddingBottom_px;\"><b>"._STATUS."</b></td>
<td style=\"padding-bottom: $cellPaddingBottom_px;\">$status</td>
</tr>
</tbody>
</table><br>";
$emailMeta_emailDataBody = $emailMeta.$email['body'];
$tmpDir = CoreConfigModel::getTmpPath();
$filePathOnTmp = $tmpDir . 'email_' . $email['id'] . '_' . $GLOBALS['id'] . '.pdf';
$pdf->Output($filePathOnTmp, 'F');
$filePathInTmpNoExtension = $tmpDir . 'email_' . $email['id'] . '_' . $GLOBALS['id'];
file_put_contents($filePathInTmpNoExtension.'.html', mb_convert_encoding($emailMeta_emailDataBody, 'HTML', 'UTF-8'));
ConvertPdfController::convertInPdf(['fullFilename' => $filePathInTmpNoExtension.'.html']);
return $filePathOnTmp;
if(file_exists($filePathInTmpNoExtension.'.html')){ unlink($filePathInTmpNoExtension.'.html');}
return $filePathInTmpNoExtension.'.pdf';
}
private static function getSummarySheet(array $args)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment