diff --git a/src/app/document/controllers/DocumentController.php b/src/app/document/controllers/DocumentController.php index d69aee9650437e3cbcfb093f4ca7cc8e848bbf61..a126ab0cf41a0292b56eaa29e8a8d9e6d33faa6b 100755 --- a/src/app/document/controllers/DocumentController.php +++ b/src/app/document/controllers/DocumentController.php @@ -507,6 +507,11 @@ class DocumentController ]); $firstWorkflowId = null; + $pdf = new Fpdi('P', 'pt'); + $veryTemporaryPath = CoreConfigModel::getTmpPath() . "tmp_file_{$GLOBALS['id']}_" .rand(). "_coord.pdf"; + file_put_contents($veryTemporaryPath, base64_decode($encodedDocument['encodedDocument'])); + $pdf->setSourceFile($veryTemporaryPath); + unlink($veryTemporaryPath); foreach ($body['workflow'] as $key => $workflow) { if (!SignatureController::isValidSignatureMode(['mode' => $workflow['signatureMode']])) { $workflow['signatureMode'] = 'stamp'; @@ -525,6 +530,22 @@ class DocumentController $firstWorkflowId = $workflowId; } if (empty($workflow['userId'])) { + if (!empty($workflow['signaturePositions'])) { + foreach ($workflow['signaturePositions'] as $signaturePosition) { + $pageWidth = $pdf->getPageWidth($signaturePosition['page'] - 1); + $pageHeight = $pdf->getPageHeight($signaturePosition['page'] - 1); + + $llx = $pageWidth * $signaturePosition['positionX'] / 100; + $llx = round($llx); + $lly = $pageHeight - ($pageHeight * $signaturePosition['positionY'] / 100) - 40; + $lly = round($lly); + $urx = $llx + 100; + $urx = round($urx); + $ury = $lly + 40; + $ury = round($ury); + $workflow['externalInformations']['signaturePositions'][] = ['page' => $signaturePosition['page'], 'position' => "{$llx},{$lly},{$urx},{$ury}"]; + } + } $informations = []; if ($workflow['externalInformations']['type'] == 'yousign') { $informations = YousignController::formatExternalInformations($workflow['externalInformations']); diff --git a/src/app/history/controllers/HistoryController.php b/src/app/history/controllers/HistoryController.php index 8f1670afcc233ea30a0a4b5e3862ded42c4d0fc0..895587ff9e3fb75ac912c3feb147e15da1a1267f 100755 --- a/src/app/history/controllers/HistoryController.php +++ b/src/app/history/controllers/HistoryController.php @@ -466,17 +466,19 @@ class HistoryController $informations = json_decode($workflowExternalInformations['informations'], true); if ($informations['type'] == 'yousign' && !empty($informations['yousignProcedureId'])) { $yousignProof = YousignController::getProofByWorkflowId(['workflowId' => $step['id']]); - $archivePath = $tmpPath . 'yousignProof' . $GLOBALS['id'] . "_" . rand() . '.zip'; - file_put_contents($archivePath, base64_decode($yousignProof)); - $zipArchive = new \ZipArchive(); - $zipArchive->open($archivePath); - $nameInArchive = $zipArchive->getNameIndex(0); - $yousignPdfProof = $zipArchive->getFromIndex(0); - $yousignPath = $tmpPath . 'yousignProof' . $GLOBALS['id'] . "_" . rand() . '.pdf'; - file_put_contents($yousignPath, $yousignPdfProof); - unlink($archivePath); - - $documentPathToZip[] = ['path' => $yousignPath, 'filename' => $nameInArchive]; + if (empty($yousignProof['errors'])) { + $archivePath = $tmpPath . 'yousignProof' . $GLOBALS['id'] . "_" . rand() . '.zip'; + file_put_contents($archivePath, base64_decode($yousignProof)); + $zipArchive = new \ZipArchive(); + $zipArchive->open($archivePath); + $nameInArchive = $zipArchive->getNameIndex(0); + $yousignPdfProof = $zipArchive->getFromIndex(0); + $yousignPath = $tmpPath . 'yousignProof' . $GLOBALS['id'] . "_" . rand() . '.pdf'; + file_put_contents($yousignPath, $yousignPdfProof); + unlink($archivePath); + + $documentPathToZip[] = ['path' => $yousignPath, 'filename' => $nameInArchive]; + } } } } diff --git a/src/app/workflow/controllers/YousignController.php b/src/app/workflow/controllers/YousignController.php index 920c8be98272709fae7b5e858b0d08d5b133c98e..8f78c2dcaa08beaaf57bddfa1ca226505b43000a 100755 --- a/src/app/workflow/controllers/YousignController.php +++ b/src/app/workflow/controllers/YousignController.php @@ -356,7 +356,7 @@ class YousignController 'type' => 'yousign', 'security' => 'sms', 'role' => 'sign', - 'signaturePositions' => [['page' => 1, 'position' => '364,105,462,145']] //TODO Remove after front + 'signaturePositions' => [] ]; if (!empty($args['security']) && $args['security'] == 'email') {