Skip to content
Snippets Groups Projects
Verified Commit 2bbae900 authored by Damien's avatar Damien
Browse files

FEAT #16982 TIME 5:30 Yousign positions

parent 8a2d4822
No related branches found
No related tags found
No related merge requests found
...@@ -507,6 +507,11 @@ class DocumentController ...@@ -507,6 +507,11 @@ class DocumentController
]); ]);
$firstWorkflowId = null; $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) { foreach ($body['workflow'] as $key => $workflow) {
if (!SignatureController::isValidSignatureMode(['mode' => $workflow['signatureMode']])) { if (!SignatureController::isValidSignatureMode(['mode' => $workflow['signatureMode']])) {
$workflow['signatureMode'] = 'stamp'; $workflow['signatureMode'] = 'stamp';
...@@ -525,6 +530,22 @@ class DocumentController ...@@ -525,6 +530,22 @@ class DocumentController
$firstWorkflowId = $workflowId; $firstWorkflowId = $workflowId;
} }
if (empty($workflow['userId'])) { 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 = []; $informations = [];
if ($workflow['externalInformations']['type'] == 'yousign') { if ($workflow['externalInformations']['type'] == 'yousign') {
$informations = YousignController::formatExternalInformations($workflow['externalInformations']); $informations = YousignController::formatExternalInformations($workflow['externalInformations']);
......
...@@ -466,17 +466,19 @@ class HistoryController ...@@ -466,17 +466,19 @@ class HistoryController
$informations = json_decode($workflowExternalInformations['informations'], true); $informations = json_decode($workflowExternalInformations['informations'], true);
if ($informations['type'] == 'yousign' && !empty($informations['yousignProcedureId'])) { if ($informations['type'] == 'yousign' && !empty($informations['yousignProcedureId'])) {
$yousignProof = YousignController::getProofByWorkflowId(['workflowId' => $step['id']]); $yousignProof = YousignController::getProofByWorkflowId(['workflowId' => $step['id']]);
$archivePath = $tmpPath . 'yousignProof' . $GLOBALS['id'] . "_" . rand() . '.zip'; if (empty($yousignProof['errors'])) {
file_put_contents($archivePath, base64_decode($yousignProof)); $archivePath = $tmpPath . 'yousignProof' . $GLOBALS['id'] . "_" . rand() . '.zip';
$zipArchive = new \ZipArchive(); file_put_contents($archivePath, base64_decode($yousignProof));
$zipArchive->open($archivePath); $zipArchive = new \ZipArchive();
$nameInArchive = $zipArchive->getNameIndex(0); $zipArchive->open($archivePath);
$yousignPdfProof = $zipArchive->getFromIndex(0); $nameInArchive = $zipArchive->getNameIndex(0);
$yousignPath = $tmpPath . 'yousignProof' . $GLOBALS['id'] . "_" . rand() . '.pdf'; $yousignPdfProof = $zipArchive->getFromIndex(0);
file_put_contents($yousignPath, $yousignPdfProof); $yousignPath = $tmpPath . 'yousignProof' . $GLOBALS['id'] . "_" . rand() . '.pdf';
unlink($archivePath); file_put_contents($yousignPath, $yousignPdfProof);
unlink($archivePath);
$documentPathToZip[] = ['path' => $yousignPath, 'filename' => $nameInArchive];
$documentPathToZip[] = ['path' => $yousignPath, 'filename' => $nameInArchive];
}
} }
} }
} }
......
...@@ -356,7 +356,7 @@ class YousignController ...@@ -356,7 +356,7 @@ class YousignController
'type' => 'yousign', 'type' => 'yousign',
'security' => 'sms', 'security' => 'sms',
'role' => 'sign', 'role' => 'sign',
'signaturePositions' => [['page' => 1, 'position' => '364,105,462,145']] //TODO Remove after front 'signaturePositions' => []
]; ];
if (!empty($args['security']) && $args['security'] == 'email') { if (!empty($args['security']) && $args['security'] == 'email') {
......
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