Verified Commit 2bbae900 authored by Damien's avatar Damien
Browse files

FEAT #16982 TIME 5:30 Yousign positions

parent 8a2d4822
......@@ -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']);
......
......@@ -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];
}
}
}
}
......
......@@ -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') {
......
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