Skip to content
Snippets Groups Projects
Commit 82004508 authored by Florian Azizian's avatar Florian Azizian
Browse files

FEAT #1417 TIME 1:30 send summary sheet in attachment (maarchParapheur)

parent d854dd65
Branches
Tags
No related merge requests found
...@@ -75,76 +75,77 @@ class MaarchParapheurController ...@@ -75,76 +75,77 @@ class MaarchParapheurController
'data' => [$aArgs['resIdMaster']] 'data' => [$aArgs['resIdMaster']]
]); ]);
if ($aArgs['objectSent'] == 'mail') { if (empty($mainResource)) {
if (empty($mainResource)) { return ['error' => 'Mail does not exist'];
return ['error' => 'Mail does not exist']; }
}
$units = []; $units = [];
$units[] = ['unit' => 'primaryInformations']; $units[] = ['unit' => 'primaryInformations'];
$units[] = ['unit' => 'secondaryInformations', 'label' => _SECONDARY_INFORMATION]; $units[] = ['unit' => 'secondaryInformations', 'label' => _SECONDARY_INFORMATION];
$units[] = ['unit' => 'senderRecipientInformations', 'label' => _DEST_INFORMATION]; $units[] = ['unit' => 'senderRecipientInformations', 'label' => _DEST_INFORMATION];
$units[] = ['unit' => 'diffusionList', 'label' => _DIFFUSION_LIST]; $units[] = ['unit' => 'diffusionList', 'label' => _DIFFUSION_LIST];
$units[] = ['unit' => 'visaWorkflow', 'label' => _VISA_WORKFLOW]; $units[] = ['unit' => 'visaWorkflow', 'label' => _VISA_WORKFLOW];
$units[] = ['unit' => 'opinionWorkflow', 'label' => _AVIS_WORKFLOW]; $units[] = ['unit' => 'opinionWorkflow', 'label' => _AVIS_WORKFLOW];
$units[] = ['unit' => 'notes', 'label' => _NOTES_COMMENT]; $units[] = ['unit' => 'notes', 'label' => _NOTES_COMMENT];
// Data for resources // Data for resources
$tmpIds = [$aArgs['resIdMaster']]; $tmpIds = [$aArgs['resIdMaster']];
$data = []; $data = [];
foreach ($units as $unit) { foreach ($units as $unit) {
if ($unit['unit'] == 'notes') { if ($unit['unit'] == 'notes') {
$data['notes'] = NoteModel::get([ $data['notes'] = NoteModel::get([
'select' => ['id', 'note_text', 'user_id', 'creation_date', 'identifier'], 'select' => ['id', 'note_text', 'user_id', 'creation_date', 'identifier'],
'where' => ['identifier in (?)'], 'where' => ['identifier in (?)'],
'data' => [$tmpIds], 'data' => [$tmpIds],
'order_by' => ['identifier']]); 'order_by' => ['identifier']]);
$userEntities = EntityModel::getByLogin(['login' => $aArgs['userId'], 'select' => ['entity_id']]); $userEntities = EntityModel::getByLogin(['login' => $aArgs['userId'], 'select' => ['entity_id']]);
$data['userEntities'] = []; $data['userEntities'] = [];
foreach ($userEntities as $userEntity) { foreach ($userEntities as $userEntity) {
$data['userEntities'][] = $userEntity['entity_id']; $data['userEntities'][] = $userEntity['entity_id'];
}
} elseif ($unit['unit'] == 'opinionWorkflow') {
$data['listInstancesOpinion'] = ListInstanceModel::get([
'select' => ['item_id', 'process_date', 'res_id'],
'where' => ['difflist_type = ?', 'res_id in (?)'],
'data' => ['AVIS_CIRCUIT', $tmpIds],
'orderBy' => ['listinstance_id']
]);
} elseif ($unit['unit'] == 'visaWorkflow') {
$data['listInstancesVisa'] = ListInstanceModel::get([
'select' => ['item_id', 'requested_signature', 'process_date', 'res_id'],
'where' => ['difflist_type = ?', 'res_id in (?)'],
'data' => ['VISA_CIRCUIT', $tmpIds],
'orderBy' => ['listinstance_id']
]);
} elseif ($unit['unit'] == 'diffusionList') {
$data['listInstances'] = ListInstanceModel::get([
'select' => ['item_id', 'item_type', 'item_mode', 'res_id'],
'where' => ['difflist_type = ?', 'res_id in (?)'],
'data' => ['entity_id', $tmpIds],
'orderBy' => ['listinstance_id']
]);
} elseif ($unit['unit'] == 'senderRecipientInformations') {
$data['mlbCollExt'] = ResModel::getExt([
'select' => ['category_id', 'address_id', 'exp_user_id', 'dest_user_id', 'is_multicontacts', 'res_id'],
'where' => ['res_id in (?)'],
'data' => [$tmpIds]
]);
} }
} elseif ($unit['unit'] == 'opinionWorkflow') {
$data['listInstancesOpinion'] = ListInstanceModel::get([
'select' => ['item_id', 'process_date', 'res_id'],
'where' => ['difflist_type = ?', 'res_id in (?)'],
'data' => ['AVIS_CIRCUIT', $tmpIds],
'orderBy' => ['listinstance_id']
]);
} elseif ($unit['unit'] == 'visaWorkflow') {
$data['listInstancesVisa'] = ListInstanceModel::get([
'select' => ['item_id', 'requested_signature', 'process_date', 'res_id'],
'where' => ['difflist_type = ?', 'res_id in (?)'],
'data' => ['VISA_CIRCUIT', $tmpIds],
'orderBy' => ['listinstance_id']
]);
} elseif ($unit['unit'] == 'diffusionList') {
$data['listInstances'] = ListInstanceModel::get([
'select' => ['item_id', 'item_type', 'item_mode', 'res_id'],
'where' => ['difflist_type = ?', 'res_id in (?)'],
'data' => ['entity_id', $tmpIds],
'orderBy' => ['listinstance_id']
]);
} elseif ($unit['unit'] == 'senderRecipientInformations') {
$data['mlbCollExt'] = ResModel::getExt([
'select' => ['category_id', 'address_id', 'exp_user_id', 'dest_user_id', 'is_multicontacts', 'res_id'],
'where' => ['res_id in (?)'],
'data' => [$tmpIds]
]);
} }
}
$pdf = new Fpdi('P', 'pt'); $pdf = new Fpdi('P', 'pt');
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
SummarySheetController::createSummarySheet($pdf, ['resource' => $mainResource[0], 'units' => $units, 'login' => $aArgs['userId'], 'data' => $data]); SummarySheetController::createSummarySheet($pdf, ['resource' => $mainResource[0], 'units' => $units, 'login' => $aArgs['userId'], 'data' => $data]);
$tmpPath = CoreConfigModel::getTmpPath(); $tmpPath = CoreConfigModel::getTmpPath();
$filename = $tmpPath . "summarySheet_".$aArgs['resIdMaster'] . "_" . $aArgs['userId'] ."_".rand().".pdf"; $filename = $tmpPath . "summarySheet_".$aArgs['resIdMaster'] . "_" . $aArgs['userId'] ."_".rand().".pdf";
$pdf->Output($filename, 'F'); $pdf->Output($filename, 'F');
$concatPdf = new Fpdi('P', 'pt'); $concatPdf = new Fpdi('P', 'pt');
$concatPdf->setPrintHeader(false); $concatPdf->setPrintHeader(false);
if ($aArgs['objectSent'] == 'mail') {
foreach ([$filename, $arrivedMailMainfilePath] as $file) { foreach ([$filename, $arrivedMailMainfilePath] as $file) {
$pageCount = $concatPdf->setSourceFile($file); $pageCount = $concatPdf->setSourceFile($file);
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) { for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
...@@ -222,6 +223,13 @@ class MaarchParapheurController ...@@ -222,6 +223,13 @@ class MaarchParapheurController
'title' => $mainResource[0]['subject'], 'title' => $mainResource[0]['subject'],
'reference' => $mainResource[0]['alt_identifier'] 'reference' => $mainResource[0]['alt_identifier']
]]; ]];
$summarySheetEncodedZip = MaarchParapheurController::createZip(['filepath' => $filename, 'filename' => "summarySheet.pdf"]);
$attachmentsData[] = [
'encodedDocument' => $summarySheetEncodedZip,
'title' => "summarySheet.pdf",
'reference' => ""
];
} else { } else {
$attachmentsData = []; $attachmentsData = [];
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment