diff --git a/src/app/acknowledgementReceipt/controllers/AcknowledgementReceiptController.php b/src/app/acknowledgementReceipt/controllers/AcknowledgementReceiptController.php index 0dced5771891f84b1e45daecec3850eb008b4fb8..c589cb7ae48f5b5e4263fdc415b396ecfd7e4427 100644 --- a/src/app/acknowledgementReceipt/controllers/AcknowledgementReceiptController.php +++ b/src/app/acknowledgementReceipt/controllers/AcknowledgementReceiptController.php @@ -24,6 +24,7 @@ use Respect\Validation\Validator; use setasign\Fpdi\Tcpdf\Fpdi; use Slim\Psr7\Request; use SrcCore\http\Response; +use SrcCore\models\CoreConfigModel; use User\models\UserModel; class AcknowledgementReceiptController @@ -127,6 +128,10 @@ class AcknowledgementReceiptController if (empty($resourcesInBasket) || !ResController::hasRightByResId(['resId' => $resourcesInBasket, 'userId' => $GLOBALS['id']])) { return $response->withStatus(403)->withJson(['errors' => 'Documents out of perimeter']); } + $libPath = CoreConfigModel::getFpdiPdfParserLibrary(); + if (file_exists($libPath)) { + require_once($libPath); + } $pdf = new Fpdi('P', 'pt'); $pdf->setPrintHeader(false); diff --git a/src/app/attachment/controllers/AttachmentController.php b/src/app/attachment/controllers/AttachmentController.php index 4174e34575c45f59431c097cbc81c2514bfb48b1..de079792ac11e44180cecae4505b5d2e3458cc8b 100755 --- a/src/app/attachment/controllers/AttachmentController.php +++ b/src/app/attachment/controllers/AttachmentController.php @@ -743,6 +743,10 @@ class AttachmentController $pageCount = count($pages); } else { try { + $libPath = CoreConfigModel::getFpdiPdfParserLibrary(); + if (file_exists($libPath)) { + require_once($libPath); + } $pdf = new Fpdi('P', 'pt'); $pageCount = $pdf->setSourceFile($pathToPdf); } catch (\Exception $e) { diff --git a/src/app/entity/controllers/EntitySeparatorController.php b/src/app/entity/controllers/EntitySeparatorController.php index af0051e75049ea08f33d8606794ca2a7514d73cf..f6177b3f04ca1811d5740aea7899e1d9ab6988bd 100755 --- a/src/app/entity/controllers/EntitySeparatorController.php +++ b/src/app/entity/controllers/EntitySeparatorController.php @@ -24,6 +24,7 @@ use Respect\Validation\Validator; use setasign\Fpdi\Tcpdf\Fpdi; use Slim\Psr7\Request; use SrcCore\http\Response; +use SrcCore\models\CoreConfigModel; class EntitySeparatorController { @@ -61,6 +62,10 @@ class EntitySeparatorController } } + $libPath = CoreConfigModel::getFpdiPdfParserLibrary(); + if (file_exists($libPath)) { + require_once($libPath); + } $pdf = new Fpdi('P', 'pt'); $pdf->setPrintHeader(false); @@ -94,10 +99,10 @@ class EntitySeparatorController 'black', // foreground color [-2, -2, -2, -2] // padding (use absolute or negative values as multiplication factors) )->setBackgroundColor('white'); // background color - + $pdf->Image('@'.$bobj->getPngData(), 0, 40, 200, '', '', '', '', false, 300, 'C'); } - + $pdf->SetY($pdf->GetY() + 300); $pdf->Cell(0, 20, _PRINT_SEP_TITLE, 0, 2, 'C', false); $pdf->SetY($pdf->GetY() + 60); diff --git a/src/app/external/exportSeda/controllers/ExportSEDATrait.php b/src/app/external/exportSeda/controllers/ExportSEDATrait.php index 4a8c980327cb3ad036c6605e373e298fe8c311ac..2ba0afc3f2c6cba1458015804f765ba60d25f882 100644 --- a/src/app/external/exportSeda/controllers/ExportSEDATrait.php +++ b/src/app/external/exportSeda/controllers/ExportSEDATrait.php @@ -445,6 +445,10 @@ trait ExportSEDATrait $sender = json_decode($args['data']['sender'], true); $data = "Courriel n°" . $args['data']['id'] . "\nDe : " . $sender['email'] . "\nPour : " . implode(", ", json_decode($args['data']['recipients'], true)) . "\nObjet : " . $args['data']['object'] . "\n\n" . strip_tags(html_entity_decode($body)); + $libPath = CoreConfigModel::getFpdiPdfParserLibrary(); + if (file_exists($libPath)) { + require_once($libPath); + } $pdf = new Fpdi('P', 'pt'); $pdf->setPrintHeader(false); $pdf->AddPage(); @@ -511,6 +515,10 @@ trait ExportSEDATrait ]); $fieldsIdentifier = array_column($indexingFields, 'identifier'); + $libPath = CoreConfigModel::getFpdiPdfParserLibrary(); + if (file_exists($libPath)) { + require_once($libPath); + } $pdf = new Fpdi('P', 'pt'); $pdf->setPrintHeader(false); diff --git a/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php b/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php index 4fdc24db3dda72fa25f0962cc0513af56a49abe6..7ea1fd08d5e30d339377e5dcaacbc639f0225717 100755 --- a/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php +++ b/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php @@ -154,6 +154,10 @@ class MaarchParapheurController ]); $fieldsIdentifier = array_column($indexingFields, 'identifier'); + $libPath = CoreConfigModel::getFpdiPdfParserLibrary(); + if (file_exists($libPath)) { + require_once($libPath); + } $pdf = new Fpdi('P', 'pt'); $pdf->setPrintHeader(false); @@ -324,9 +328,9 @@ class MaarchParapheurController return ['error' => 'Docserver does not exist ' . $adrInfo['docserver_id']]; } $filePath = $docserverInfo['path_template'] . str_replace('#', '/', $adrInfo['path']) . $adrInfo['filename']; - + $encodedZipDocument = MaarchParapheurController::createZip(['filepath' => $filePath, 'filename' => $adrInfo['filename']]); - + $attachmentsData = []; if (!empty($encodedMainZipFile)) { $attachmentsData = [[ @@ -423,7 +427,7 @@ class MaarchParapheurController if (!empty($response['response']['errors']) || !empty($response['errors'])) { return ['error' => 'Error during processing in MaarchParapheur : ' . $response['response']['errors'] ?? $response['errors']]; } - + $attachmentToFreeze[$collId][$resId] = $response['response']['id']; } if (!empty($integratedResource)) { @@ -495,7 +499,7 @@ class MaarchParapheurController } $bodyData['linkId'] = $aArgs['resIdMaster']; - + $response = CurlModel::exec([ 'url' => rtrim($aArgs['config']['data']['url'], '/') . '/rest/documents', 'basicAuth' => ['user' => $aArgs['config']['data']['userId'], 'password' => $aArgs['config']['data']['password']], @@ -510,7 +514,7 @@ class MaarchParapheurController if (!empty($response['response']['errors']) || !empty($response['errors'])) { return ['error' => 'Error during processing in MaarchParapheur : ' . $response['response']['errors'] ?? $response['errors']]; } - + $attachmentToFreeze['letterbox_coll'][$integratedResource[0]['res_id']] = $response['response']['id']; } } @@ -644,7 +648,7 @@ class MaarchParapheurController continue; } $state = MaarchParapheurController::getState(['workflow' => $documentWorkflow]); - + if (in_array($state['status'], ['validated', 'refused'])) { $signedDocument = MaarchParapheurController::getDocument(['config' => $aArgs['config'], 'documentId' => $value['external_id'], 'status' => $state['status']]); $aArgs['idsToRetrieve'][$version][$resId]['format'] = 'pdf'; @@ -825,7 +829,7 @@ class MaarchParapheurController if (!$check) { return $response->withStatus(400)->withJson(['errors' => 'login is empty or wrong format']); } - + $userController = new UserController(); $error = $userController->hasUsersRights(['id' => $aArgs['id']]); if (!empty($error['error'])) { @@ -899,7 +903,7 @@ class MaarchParapheurController if (!$check) { return $response->withStatus(400)->withJson(['errors' => 'maarchParapheurUserId is empty or not an integer']); } - + $userController = new UserController(); $error = $userController->hasUsersRights(['id' => $aArgs['id']]); if (!empty($error['error'])) { @@ -1076,7 +1080,7 @@ class MaarchParapheurController if (empty($userSignatures)) { return $response->withStatus(400)->withJson(['errors' => 'User has no signature']); } - + $docserver = DocserverModel::getCurrentDocserver(['typeId' => 'TEMPLATES', 'collId' => 'templates', 'select' => ['path_template']]); if (empty($docserver['path_template']) || !file_exists($docserver['path_template'])) { return $response->withStatus(400)->withJson(['errors' => 'Path for signature docserver does not exists']); @@ -1100,7 +1104,7 @@ class MaarchParapheurController "signatures" => $signatures, "externalApplication" => 'maarchCourrier' ]; - + foreach ($loadedXml->signatoryBook as $value) { if ($value->id == "maarchParapheur") { $url = $value->url; diff --git a/src/app/external/externalSignatoryBook/controllers/XParaphController.php b/src/app/external/externalSignatoryBook/controllers/XParaphController.php index 17f05584a9dde87d4217b14e6867a65bc4da11db..48ba253d6b6f228a839be0556da5380324e0ebf2 100755 --- a/src/app/external/externalSignatoryBook/controllers/XParaphController.php +++ b/src/app/external/externalSignatoryBook/controllers/XParaphController.php @@ -76,7 +76,7 @@ class XParaphController foreach ($attachments as $value) { $resId = $value['res_id']; $collId = 'attachments_coll'; - + $adrInfo = ConvertPdfController::getConvertedPdfById(['resId' => $resId, 'collId' => $collId]); $docserverInfo = DocserverModel::getByDocserverId(['docserverId' => $adrInfo['docserver_id']]); $filePath = $docserverInfo['path_template'] . str_replace('#', '/', $adrInfo['path']) . $adrInfo['filename']; @@ -97,7 +97,7 @@ class XParaphController $filesize = filesize($filePath); $fileContent = file_get_contents($filePath); - + $xmlStep = ''; foreach ($aArgs['steps'] as $key => $step) { $order = $key + 1; @@ -155,10 +155,10 @@ class XParaphController 'select' => ['external_id'], 'id' => $resId ]); - + $externalId = json_decode($aAttachment[0]['external_id'], true); $externalId['xparaphDepot'] = ['login' => $aArgs['info']['login'], 'siret' => $aArgs['info']['siret']]; - + AttachmentModel::update([ 'set' => ['external_id' => json_encode($externalId)], 'where' => ['res_id = ?'], @@ -256,7 +256,11 @@ class XParaphController ]); unlink($pathFilename); $pdfToSend = $documentConverted['fullFilename']; - + + $libPath = CoreConfigModel::getFpdiPdfParserLibrary(); + if (file_exists($libPath)) { + require_once($libPath); + } $pdf = new Fpdi('P', 'pt'); $pdf->setPrintHeader(false); $nbPages = $pdf->setSourceFile($pdfToSend); @@ -377,7 +381,7 @@ class XParaphController foreach ($userWorkflow as $value) { $workflow[] = $value; } - + return $response->withJson(['workflow' => $workflow]); } } @@ -432,7 +436,7 @@ class XParaphController $file = base64_decode($processedFile['zip']); $unzipName = 'tmp_file_' .rand(). '_xParaph_' .rand(); $tmpName = $unzipName . '.zip'; - + file_put_contents($tmpPath . $tmpName, $file); $zip = new \ZipArchive(); @@ -459,7 +463,7 @@ class XParaphController $file = base64_decode($processedFile['zip']); $unzipName = 'tmp_file_' .rand(). '_xParaph_' .rand(); $tmpName = $unzipName . '.zip'; - + file_put_contents($tmpPath . $tmpName, $file); $zip = new \ZipArchive(); @@ -619,7 +623,7 @@ class XParaphController } $externalId = json_decode($user['external_id'], true); - + $accountFound = false; foreach ($externalId['xParaph'] as $key => $value) { if ($value['login'] == $data['login'] && $value['siret'] == $data['siret']) { @@ -662,7 +666,7 @@ class XParaphController $externalId = json_decode($user['external_id'], true); $externalId['xParaph'][] = ["login" => $body['login'], "siret" => $body['siret']]; - + UserModel::updateExternalId(['id' => $user['id'], 'externalId' => json_encode($externalId)]); HistoryController::add([ diff --git a/src/app/note/controllers/NoteController.php b/src/app/note/controllers/NoteController.php index e3e8fa1708068df1aeffe5d2d99399cc10771dbc..1629be47f6fb387571c4a2c831fb7f7b342334cd 100755 --- a/src/app/note/controllers/NoteController.php +++ b/src/app/note/controllers/NoteController.php @@ -53,7 +53,7 @@ class NoteController } $notes = NoteModel::getByUserIdForResource(['select' => ['*'], 'resId' => $args['resId'], 'userId' => $GLOBALS['id'], 'limit' => $limit]); - + foreach ($notes as $key => $note) { $user = UserModel::getById(['select' => ['firstname', 'lastname'], 'id' => $note['user_id']]); $primaryEntity = UserModel::getPrimaryEntityById(['id' => $note['user_id'], 'select' => ['entities.entity_label']]); @@ -115,7 +115,7 @@ class NoteController 'user_id' => $GLOBALS['id'], 'note_text' => $body['value'] ]); - + if (!empty($noteId) && !empty($body['entities'])) { foreach ($body['entities'] as $entity) { NoteEntityModel::create(['item_id' => $entity, 'note_id' => $noteId]); @@ -316,6 +316,10 @@ class NoteController ValidatorModel::notEmpty($aArgs, ['ids']); ValidatorModel::arrayType($aArgs, ['ids']); + $libPath = CoreConfigModel::getFpdiPdfParserLibrary(); + if (file_exists($libPath)) { + require_once($libPath); + } $pdf = new Fpdi('P', 'pt'); $pdf->setPrintHeader(false); $pdf->AddPage(); diff --git a/src/app/registeredMail/controllers/RegisteredMailController.php b/src/app/registeredMail/controllers/RegisteredMailController.php index cdf0d9c6e73eea68572a5e3549d641c45739278c..374fb24df29be878187c23f0116a18e99b7b2979 100644 --- a/src/app/registeredMail/controllers/RegisteredMailController.php +++ b/src/app/registeredMail/controllers/RegisteredMailController.php @@ -552,6 +552,10 @@ class RegisteredMailController { $registeredMailNumber = $args['registeredMailNumber']; + $libPath = CoreConfigModel::getFpdiPdfParserLibrary(); + if (file_exists($libPath)) { + require_once($libPath); + } $pdf = new Fpdi(); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); @@ -944,14 +948,14 @@ class RegisteredMailController if (!empty($storeResult['errors'])) { return ['errors' => '[storeResource] ' . $storeResult['errors']]; } - + $data['docserver_id'] = $storeResult['docserver_id']; $data['filename'] = $storeResult['file_destination_name']; $data['filesize'] = $storeResult['fileSize']; $data['path'] = $storeResult['directory']; $data['fingerprint'] = $storeResult['fingerPrint']; $data['format'] = 'pdf'; - + ResModel::update(['set' => $data, 'where' => ['res_id = ?'], 'data' => [$args['resId']]]); } @@ -960,6 +964,10 @@ class RegisteredMailController public static function getDepositListPdf(array $args) { + $libPath = CoreConfigModel::getFpdiPdfParserLibrary(); + if (file_exists($libPath)) { + require_once($libPath); + } $pdf = new Fpdi(); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); diff --git a/src/app/resource/controllers/ExportController.php b/src/app/resource/controllers/ExportController.php index 1b4fcd4350334fb230529b6c90d488ffd66893c0..e003ba097fdac6540d057c630833ce53ef9cb936 100755 --- a/src/app/resource/controllers/ExportController.php +++ b/src/app/resource/controllers/ExportController.php @@ -305,6 +305,10 @@ class ExportController $orientation = 'L'; } + $libPath = CoreConfigModel::getFpdiPdfParserLibrary(); + if (file_exists($libPath)) { + require_once($libPath); + } $pdf = new Fpdi($orientation, 'pt'); $pdf->setPrintHeader(false); diff --git a/src/app/resource/controllers/FolderPrintController.php b/src/app/resource/controllers/FolderPrintController.php index 1d77e2d392e96aac742febfd4934ed04147cf3ce..346ad9d8aa2e98502251cafded2aca74170ea136 100755 --- a/src/app/resource/controllers/FolderPrintController.php +++ b/src/app/resource/controllers/FolderPrintController.php @@ -599,12 +599,12 @@ class FolderPrintController // delete all tmp email_*.pdf, attachment_*.pdf, summarySheet_*.pdf, convertedAr_*.pdf and listNotes_*.pdf after merged is complete foreach ($documentPaths as $documentPath) { - if (strpos($documentPath, "email_") !== false || strpos($documentPath, "attachment_") !== false || strpos($documentPath, "summarySheet_") !== false + if (strpos($documentPath, "email_") !== false || strpos($documentPath, "attachment_") !== false || strpos($documentPath, "summarySheet_") !== false || strpos($documentPath, "convertedAr_") !== false || strpos($documentPath, "listNotes_") !== false) { unlink($documentPath); } } - + $folderPrintPaths[] = $filePathOnTmp; } } @@ -724,6 +724,10 @@ class FolderPrintController $notes[] = ['user' => $userName, 'note' => $noteText, 'date' => $date]; } + $libPath = CoreConfigModel::getFpdiPdfParserLibrary(); + if (file_exists($libPath)) { + require_once($libPath); + } $pdf = new Fpdi('P', 'pt'); $pdf->setPrintHeader(false); $pdf->AddPage(); @@ -796,6 +800,10 @@ class FolderPrintController $sendDate = _UNDEFINED; } + $libPath = CoreConfigModel::getFpdiPdfParserLibrary(); + if (file_exists($libPath)) { + require_once($libPath); + } $pdf = new Fpdi('P', 'pt'); $pdf->setPrintHeader(false); $pdf->AddPage(); @@ -843,6 +851,10 @@ class FolderPrintController $contentHtml = file_get_contents($args['pathHtml']); + $libPath = CoreConfigModel::getFpdiPdfParserLibrary(); + if (file_exists($libPath)) { + require_once($libPath); + } $pdf = new Fpdi('P', 'pt'); $pdf->setPrintHeader(false); $pdf->AddPage(); @@ -891,6 +903,10 @@ class FolderPrintController $creationDate = new \DateTime($attachment['creation_date']); $creationDate = $creationDate->format('d-m-Y H:i'); + $libPath = CoreConfigModel::getFpdiPdfParserLibrary(); + if (file_exists($libPath)) { + require_once($libPath); + } $pdf = new Fpdi('P', 'pt'); $pdf->setPrintHeader(false); $pdf->AddPage(); @@ -1035,7 +1051,7 @@ class FolderPrintController return $filePathInTmpNoExtension . '.pdf'; } - + private static function getSummarySheet(array $args) { ValidatorModel::notEmpty($args, ['units', 'resId']); @@ -1065,6 +1081,10 @@ class FolderPrintController ]); $fieldsIdentifier = array_column($indexingFields, 'identifier'); + $libPath = CoreConfigModel::getFpdiPdfParserLibrary(); + if (file_exists($libPath)) { + require_once($libPath); + } $pdf = new Fpdi('P', 'pt'); $pdf->setPrintHeader(false); diff --git a/src/app/resource/controllers/ResController.php b/src/app/resource/controllers/ResController.php index e2e9a15df2f2fdd8431c3c0a8ffd7b11842ccb2d..62978dc640e4e1e6f500035a20118d36539c292a 100755 --- a/src/app/resource/controllers/ResController.php +++ b/src/app/resource/controllers/ResController.php @@ -276,7 +276,7 @@ class ResController extends ResourceControlController public function canUpdateFile(array $args) { $resource = $args['resource']; - + $canUpdate = $GLOBALS['id'] == $resource['typist']; $resourcePrivilege = ''; @@ -600,7 +600,7 @@ class ResController extends ResourceControlController ]); $signatoryId = $listInstance[0]['item_id'] ?? $creatorId; - + return $response->withJson([ 'encodedDocument' => base64_encode($fileContent), 'originalFormat' => $originalFormat, @@ -924,6 +924,10 @@ class ResController extends ResourceControlController $pageCount = count($pages); } else { try { + $libPath = CoreConfigModel::getFpdiPdfParserLibrary(); + if (file_exists($libPath)) { + require_once($libPath); + } $pdf = new Fpdi('P', 'pt'); $pageCount = $pdf->setSourceFile($pathToPdf); } catch (\Exception $e) { @@ -1674,4 +1678,4 @@ class ResController extends ResourceControlController return true; } -} \ No newline at end of file +} diff --git a/src/app/resource/controllers/SummarySheetController.php b/src/app/resource/controllers/SummarySheetController.php index 949d0029d5e9dab927c9adee92a9d9c7227fd919..4d52eba131050bcc06cc2e5954d033c32930515e 100755 --- a/src/app/resource/controllers/SummarySheetController.php +++ b/src/app/resource/controllers/SummarySheetController.php @@ -73,6 +73,10 @@ class SummarySheetController 'groupBy' => ['model_id'] ]); + $libPath = CoreConfigModel::getFpdiPdfParserLibrary(); + if (file_exists($libPath)) { + require_once($libPath); + } $pdf = new Fpdi('P', 'pt'); $pdf->setPrintHeader(false); @@ -430,7 +434,7 @@ class SummarySheetController $docserverPathFile = str_replace('//', '/', $docserverPathFile); $docserverPathFile = str_replace('#', '/', $docserverPathFile); } - + $typistLabel = UserModel::getLabelledUserById(['id' => $resource['typist']]); $fulltextInfo = ResModel::getById(['select' => ['fulltext_result'], 'resId' => $resource['res_id']]); @@ -441,13 +445,13 @@ class SummarySheetController $pdf->SetFont('', 'B', 11); $pdf->Cell(0, 15, $unit['label'], 0, 2, 'L', false); $pdf->SetY($pdf->GetY() + 2); - + $pdf->SetFont('', '', 10); $pdf->MultiCell($widthNotes, 30, _TYPIST . " : {$typistLabel}", 1, 'L', false, 0, '', '', true, 0, true); $creationDate = TextFormatModel::formatDate($resource['creation_date'], 'd-m-Y'); $pdf->MultiCell($widthNotes, 30, _CREATION_DATE . " : {$creationDate}", 1, 'L', false, 1, '', '', true, 0, true); - + $nextLine = 1; if (!empty($resource['filesize'])) { $resource['filesize'] = StoreController::getFormattedSizeFromBytes(['size' => $resource['filesize']]); @@ -489,16 +493,16 @@ class SummarySheetController // Get all the ids of technical custom fields $customFields = CustomFieldModel::get(['where' => ['mode = ?'], 'data' => ['technical'], 'orderBy' => ['label']]); $customFieldsIds = array_column($customFields, 'id'); - + if (!empty($customFieldsIds)) { $customFieldsRawValues = array_column($customFields, 'values', 'id'); $customFieldsRawTypes = array_column($customFields, 'type', 'id'); $customFields = array_column($customFields, 'label', 'id'); - + $customFieldsValues = $customFieldsValues[0]['custom_fields'] ?? null; $customFieldsValues = json_decode($customFieldsValues, true); } - + $pdf->SetY($pdf->GetY() + 40); if (($pdf->GetY() + 57) > $bottomHeight) { $pdf->AddPage(); @@ -507,12 +511,12 @@ class SummarySheetController $pdf->Cell(0, 15, $unit['label'], 0, 2, 'L', false); $pdf->SetY($pdf->GetY() + 2); $pdf->SetFont('', '', 10); - + $nextLine = 1; if (!empty($customFieldsIds)) { $fieldsType = CustomFieldModel::get(['select' => ['type', 'id'], 'where' => ['id in (?)'], 'data' => [$customFieldsIds]]); $fieldsType = array_column($fieldsType, 'type', 'id'); - + foreach ($customFieldsIds as $customFieldsId) { $label = $customFields[$customFieldsId]; $rawValues = json_decode($customFieldsRawValues[$customFieldsId], true); @@ -521,7 +525,7 @@ class SummarySheetController $rawValues['resId'] = $resource['res_id']; } $rawValues = CustomFieldModel::getValuesSQL($rawValues); - + $rawValues = array_column($rawValues, 'label', 'key'); if (is_array($customFieldsValues[$customFieldsId])) { foreach ($customFieldsValues[$customFieldsId] as $key => $value) { @@ -553,7 +557,7 @@ class SummarySheetController } else { $value = isset($customFieldsValues[$customFieldsId]) ? '<b>' . $customFieldsValues[$customFieldsId] . '</b>' : '<i>' . _UNDEFINED . '</i>'; } - + $nextLine = ($nextLine + 1) % 2; $pdf->MultiCell($widthNotes, 30, $label . " : {$value}", 1, 'L', false, $nextLine, '', '', true, 0, true); $pdf->SetFont('', '', 10); @@ -925,6 +929,10 @@ class SummarySheetController $parameter = ParameterModel::getById(['select' => ['param_value_string'], 'id' => 'traffic_record_summary_sheet']); + $libPath = CoreConfigModel::getFpdiPdfParserLibrary(); + if (file_exists($libPath)) { + require_once($libPath); + } $pdf2 = new Fpdi('P', 'pt'); $pdf2->setPrintHeader(false); $pdf2->AddPage(); diff --git a/src/app/resource/controllers/WatermarkController.php b/src/app/resource/controllers/WatermarkController.php index 0ee7708b706fa79f8589e245a24aebda4d7dc418..094b3981415192fd4c41b8999534c7048760219c 100644 --- a/src/app/resource/controllers/WatermarkController.php +++ b/src/app/resource/controllers/WatermarkController.php @@ -60,7 +60,7 @@ class WatermarkController if (!empty($libPath)) { require_once($libPath); - $flattenedFile = CoreConfigModel::getTmpPath() . "tmp_file_{$GLOBALS['id']}_" .rand(). "_watermark.pdf"; + $flattenedFile = CoreConfigModel::getTmpPath() . "tmp_file_{$GLOBALS['id']}_" . rand() . "_watermark.pdf"; $writer = new \SetaPDF_Core_Writer_File($flattenedFile); $document = \SetaPDF_Core_Document::loadByFilename($args['path'], $writer); @@ -72,9 +72,15 @@ class WatermarkController $args['path'] = $flattenedFile; } + $libPath = CoreConfigModel::getFpdiPdfParserLibrary(); + if (file_exists($libPath)) { + require_once($libPath); + } try { + $watermarkFile = CoreConfigModel::getTmpPath() . "tmp_file_{$GLOBALS['id']}_" . rand() . "_watermark.pdf"; + file_put_contents($watermarkFile, file_get_contents($args['path'])); $pdf = new Fpdi('P', 'pt'); - $nbPages = $pdf->setSourceFile($args['path']); + $nbPages = $pdf->setSourceFile($watermarkFile); $pdf->setPrintHeader(false); for ($i = 1; $i <= $nbPages; $i++) { $page = $pdf->importPage($i, 'CropBox'); @@ -165,7 +171,7 @@ class WatermarkController if (!empty($libPath)) { require_once($libPath); - $flattenedFile = CoreConfigModel::getTmpPath() . "tmp_file_{$GLOBALS['id']}_" .rand(). "_watermark.pdf"; + $flattenedFile = CoreConfigModel::getTmpPath() . "tmp_file_{$GLOBALS['id']}_" . rand() . "_watermark.pdf"; $writer = new \SetaPDF_Core_Writer_File($flattenedFile); $document = \SetaPDF_Core_Document::loadByFilename($args['path'], $writer); @@ -177,9 +183,15 @@ class WatermarkController $args['path'] = $flattenedFile; } + $libPath = CoreConfigModel::getFpdiPdfParserLibrary(); + if (file_exists($libPath)) { + require_once($libPath); + } try { + $watermarkFile = CoreConfigModel::getTmpPath() . "tmp_file_{$GLOBALS['id']}_" . rand() . "_watermark.pdf"; + file_put_contents($watermarkFile, file_get_contents($args['path'])); $pdf = new Fpdi('P', 'pt'); - $nbPages = $pdf->setSourceFile($args['path']); + $nbPages = $pdf->setSourceFile($watermarkFile); $pdf->setPrintHeader(false); for ($i = 1; $i <= $nbPages; $i++) { $page = $pdf->importPage($i, 'CropBox'); diff --git a/src/core/models/CoreConfigModel.php b/src/core/models/CoreConfigModel.php index 137af8dadacb25afc5a94928fcc5cdd5528d8ddc..0ae565ebd5f0ac673f3df9f5d63ba4539e14562e 100755 --- a/src/core/models/CoreConfigModel.php +++ b/src/core/models/CoreConfigModel.php @@ -206,6 +206,27 @@ class CoreConfigModel return $librariesDirectory; } + public static function getSetaPdfFormFillerLibrary() + { + $libDir = CoreConfigModel::getLibrariesDirectory(); + $libPath = null; + + if (!empty($libDir) && is_file($libDir . 'SetaPDF-FormFiller-Full/library/SetaPDF/Autoload.php')) { + $libPath = $libDir . 'SetaPDF-FormFiller-Full/library/SetaPDF/Autoload.php'; + } + return $libPath; + } + + public static function getFpdiPdfParserLibrary() + { + $libDir = CoreConfigModel::getLibrariesDirectory(); + $libPath = null; + + if (!empty($libDir) && is_file($libDir . 'FPDI-PDF-Parser/src/autoload.php')) { + $libPath = $libDir . 'FPDI-PDF-Parser/src/autoload.php'; + } + return $libPath; + } public static function getSetaSignFormFillerLibrary() { $libDir = CoreConfigModel::getLibrariesDirectory(); @@ -220,7 +241,7 @@ class CoreConfigModel } } return $libPath; - } + } public static function getLoggingMethod() {