Actions
Fonctionnalité #15975
ferméReview - afficher l'objet dans le courrier envoyé au iparapheur
Début:
19/01/2021
Echéance:
06/04/2021
Description
En tant qu'utilisateur, j'envoie un document dans le iparapheur.
Lorsque je le consulte dans le iparapheur, je vois comme objet du courrier "Projet courrier numéro 91491_12413_315213"
Cela n'est pas parlant pour les utilisateurs.
Il faudrait afficher l'objet du courrier dans le iparapheur.
Pour ce faire, j'ai ajusté le code du fichier :
/var/www/html/maarch_courrier/src/app/external/externalSignatoryBook/controllers/IParapheurController.php
en modifiant ça:
public static function upload($aArgs)
{
$sousType = $aArgs['sousType'];
// Retrieve the annexes of the attachment to sign (other attachments and the original document)
$annexes = [];
$annexes['letterbox'] = ResModel::get([
'select' => ['res_id', 'path', 'filename', 'docserver_id', 'format', 'category_id', 'external_id', 'integrations'],
'where' => ['res_id = ?'],
'data' => [$aArgs['resIdMaster']]
]);
if (!empty($annexes['letterbox'][0]['docserver_id'])) {
$adrMainInfo = ConvertPdfController::getConvertedPdfById(['resId' => $aArgs['resIdMaster'], 'collId' => 'letterbox_coll']);
$letterboxPath = DocserverModel::getByDocserverId(['docserverId' => $adrMainInfo['docserver_id'], 'select' => ['path_template']]);
$annexes['letterbox'][0]['filePath'] = $letterboxPath['path_template'] . str_replace('#', '/', $adrMainInfo['path']) . $adrMainInfo['filename'];
}
$attachments = AttachmentModel::get([
'select' => ['res_id', 'docserver_id', 'path', 'filename', 'format', 'attachment_type'],
'where' => ['res_id_master = ?', 'attachment_type not in (?)', "status NOT IN ('DEL','OBS', 'FRZ', 'TMP', 'SEND_MASS')", "in_signature_book = 'true'"],
'data' => [$aArgs['resIdMaster'], ['signed_response']]
]);
$attachmentTypes = AttachmentModel::getAttachmentsTypesByXML();
foreach ($attachments as $key => $value) {
if (!$attachmentTypes[$value['attachment_type']]['sign']) {
$adrInfo = AdrModel::getConvertedDocumentById(['resId' => $value['res_id'], 'collId' => 'attachments_coll', 'type' => 'PDF']);
$annexeAttachmentPath = DocserverModel::getByDocserverId(['docserverId' => $adrInfo['docserver_id'], 'select' => ['path_template']]);
$value['filePath'] = $annexeAttachmentPath['path_template'] . str_replace('#', DIRECTORY_SEPARATOR, $adrInfo['path']) . $adrInfo['filename'];
unset($attachments[$key]);
$annexes['attachments'][] = $value;
}
}
// END annexes
$attachmentToFreeze = [];
foreach ($attachments as $attachment) {
$resId = $attachment['res_id'];
$collId = 'attachments_coll';
$dossierId = $resId . '_' . rand(0001, 9999);
$response = IParapheurController::uploadFile([
'resId' => $resId,
'collId' => $collId,
'resIdMaster' => $aArgs['resIdMaster'],
'annexes' => $annexes,
'sousType' => $sousType,
'config' => $aArgs['config'],
'dossierId' => $dossierId
]);
if (!empty($response['error'])) {
return $response;
} else {
$attachmentToFreeze[$collId][$resId] = $dossierId;
}
}
// Send main document if in signature book
if (!empty($annexes['letterbox'][0])) {
$mainDocumentIntegration = json_decode($annexes['letterbox'][0]['integrations'], true);
$externalId = json_decode($annexes['letterbox'][0]['external_id'], true);
if ($mainDocumentIntegration['inSignatureBook'] && empty($externalId['signatureBookId'])) {
$resId = $annexes['letterbox'][0]['res_id'];
$collId = 'letterbox_coll';
$dossierId = $resId . '_' . rand(0001, 9999);
unset($annexes['letterbox']);
$response = IParapheurController::uploadFile([
'resId' => $resId,
'collId' => $collId,
'resIdMaster' => $aArgs['resIdMaster'],
'annexes' => $annexes,
'sousType' => $sousType,
'config' => $aArgs['config'],
'dossierId' => $dossierId
]);
if (!empty($response['error'])) {
return $response;
} else {
$attachmentToFreeze[$collId][$resId] = $dossierId;
}
}
}
return ['sended' => $attachmentToFreeze];
}
public static function uploadFile($aArgs)
{
$dossierId = $aArgs['dossierId'];
$adrInfo = ConvertPdfController::getConvertedPdfById(['resId' => $aArgs['resId'], 'collId' => $aArgs['collId']]);
if (empty($adrInfo['docserver_id']) || strtolower(pathinfo($adrInfo['filename'], PATHINFO_EXTENSION)) != 'pdf') {
return ['error' => 'Document ' . $aArgs['resIdMaster'] . ' is not converted in pdf'];
}
$attachmentPath = DocserverModel::getByDocserverId(['docserverId' => $adrInfo['docserver_id'], 'select' => ['path_template']]);
$attachmentFilePath = $attachmentPath['path_template'] . str_replace('#', '/', $adrInfo['path']) . $adrInfo['filename'];
$dossierTitre = 'Projet courrier numéro ' . $aArgs['resId'];
$mainResource = ResModel::getById(['resId' => $aArgs['resIdMaster'], 'select' => ['process_limit_date']]);
if (empty($mainResource['process_limit_date'])) {
$processLimitDate = $mainResource['process_limit_date'] = date('Y-m-d', strtotime(date("Y-m-d"). ' + 14 days'));
} else {
$processLimitDateTmp = explode(" ", $mainResource['process_limit_date']);
$processLimitDate = $processLimitDateTmp[0];
}
par
public static function upload($aArgs)
{
$sousType = $aArgs['sousType'];
// Retrieve the annexes of the attachment to sign (other attachments and the original document)
$annexes = [];
$annexes['letterbox'] = ResModel::get([
'select' => ['res_id', 'path', 'filename', 'docserver_id', 'format', 'category_id', 'external_id', 'integrations'],
'where' => ['res_id = ?'],
'data' => [$aArgs['resIdMaster']]
]);
if (!empty($annexes['letterbox'][0]['docserver_id'])) {
$adrMainInfo = ConvertPdfController::getConvertedPdfById(['resId' => $aArgs['resIdMaster'], 'collId' => 'letterbox_coll']);
$letterboxPath = DocserverModel::getByDocserverId(['docserverId' => $adrMainInfo['docserver_id'], 'select' => ['path_template']]);
$annexes['letterbox'][0]['filePath'] = $letterboxPath['path_template'] . str_replace('#', '/', $adrMainInfo['path']) . $adrMainInfo['filename'];
}
$attachments = AttachmentModel::get([
'select' => ['res_id', 'docserver_id', 'path', 'filename', 'format', 'attachment_type','title'],
'where' => ['res_id_master = ?', 'attachment_type not in (?)', "status NOT IN ('DEL','OBS', 'FRZ', 'TMP', 'SEND_MASS')", "in_signature_book = 'true'"],
'data' => [$aArgs['resIdMaster'], ['signed_response']]
]);
$attachmentTypes = AttachmentModel::getAttachmentsTypesByXML();
foreach ($attachments as $key => $value) {
if (!$attachmentTypes[$value['attachment_type']]['sign']) {
$adrInfo = AdrModel::getConvertedDocumentById(['resId' => $value['res_id'], 'collId' => 'attachments_coll', 'type' => 'PDF']);
$annexeAttachmentPath = DocserverModel::getByDocserverId(['docserverId' => $adrInfo['docserver_id'], 'select' => ['path_template']]);
$value['filePath'] = $annexeAttachmentPath['path_template'] . str_replace('#', DIRECTORY_SEPARATOR, $adrInfo['path']) . $adrInfo['filename'];
unset($attachments[$key]);
$annexes['attachments'][] = $value;
}
}
// END annexes
$attachmentToFreeze = [];
foreach ($attachments as $attachment) {
$resId = $attachment['res_id'];
$title = $attachment['title'];
$collId = 'attachments_coll';
$dossierId = $resId . '_' . rand(0001, 9999);
$response = IParapheurController::uploadFile([
'resId' => $resId,
'collId' => $collId,
'resIdMaster' => $aArgs['resIdMaster'],
'annexes' => $annexes,
'sousType' => $sousType,
'config' => $aArgs['config'],
'dossierId' => $dossierId,
'title' => $title
]);
if (!empty($response['error'])) {
return $response;
} else {
$attachmentToFreeze[$collId][$resId] = $dossierId;
}
}
// Send main document if in signature book
if (!empty($annexes['letterbox'][0])) {
$mainDocumentIntegration = json_decode($annexes['letterbox'][0]['integrations'], true);
$externalId = json_decode($annexes['letterbox'][0]['external_id'], true);
if ($mainDocumentIntegration['inSignatureBook'] && empty($externalId['signatureBookId'])) {
$resId = $annexes['letterbox'][0]['res_id'];
$collId = 'letterbox_coll';
$dossierId = $resId . '_' . rand(0001, 9999);
unset($annexes['letterbox']);
$response = IParapheurController::uploadFile([
'resId' => $resId,
'collId' => $collId,
'resIdMaster' => $aArgs['resIdMaster'],
'annexes' => $annexes,
'sousType' => $sousType,
'config' => $aArgs['config'],
'dossierId' => $dossierId
]);
if (!empty($response['error'])) {
return $response;
} else {
$attachmentToFreeze[$collId][$resId] = $dossierId;
}
}
}
return ['sended' => $attachmentToFreeze];
}
public static function uploadFile($aArgs)
{
$dossierId = $aArgs['dossierId'];
$adrInfo = ConvertPdfController::getConvertedPdfById(['resId' => $aArgs['resId'], 'collId' => $aArgs['collId']]);
if (empty($adrInfo['docserver_id']) || strtolower(pathinfo($adrInfo['filename'], PATHINFO_EXTENSION)) != 'pdf') {
return ['error' => 'Document ' . $aArgs['resIdMaster'] . ' is not converted in pdf'];
}
$attachmentPath = DocserverModel::getByDocserverId(['docserverId' => $adrInfo['docserver_id'], 'select' => ['path_template']]);
$attachmentFilePath = $attachmentPath['path_template'] . str_replace('#', '/', $adrInfo['path']) . $adrInfo['filename'];
$dossierTitre = 'Courrier : '. $aArgs['title'] .' Référence : '. $aArgs['resId'];
$mainResource = ResModel::getById(['resId' => $aArgs['resIdMaster'], 'select' => ['process_limit_date']]);
if (empty($mainResource['process_limit_date'])) {
$processLimitDate = $mainResource['process_limit_date'] = date('Y-m-d', strtotime(date("Y-m-d"). ' + 14 days'));
} else {
$processLimitDateTmp = explode(" ", $mainResource['process_limit_date']);
$processLimitDate = $processLimitDateTmp[0];
}
La partie la plus intéressante est celle ci:
$attachmentPath = DocserverModel::getByDocserverId(['docserverId' => $adrInfo['docserver_id'], 'select' => ['path_template']]);
$attachmentFilePath = $attachmentPath['path_template'] . str_replace('#', '/', $adrInfo['path']) . $adrInfo['filename'];
$dossierTitre = 'Courrier : '. $aArgs['title'] .' Référence : '. $aArgs['resId'];
Maintenant on obtient:
Fichiers
Actions