Skip to content
Snippets Groups Projects
Commit e4de05c0 authored by Guillaume Heurtier's avatar Guillaume Heurtier
Browse files

FEAT #12280 TIME 0:20 refactor summary sheet

parent d6756563
No related branches found
No related tags found
No related merge requests found
...@@ -46,6 +46,37 @@ class ResourceDataExportController ...@@ -46,6 +46,37 @@ class ResourceDataExportController
return $response->withStatus(400)->withJson(['errors' => 'Body resources is empty']); return $response->withStatus(400)->withJson(['errors' => 'Body resources is empty']);
} }
$defaultUnits = [
[
"unit" => "qrcode",
"label" => ""
],
[
"unit" => "primaryInformations",
"label" => _PRIMARY_INFORMATION
],
[
"unit" => "senderRecipientInformations",
"label" => _DEST_INFORMATION
],
[
"unit" => "secondaryInformations",
"label" => _SECONDARY_INFORMATION
],
[
"unit" => "diffusionList",
"label" => _DIFFUSION_LIST
],
[
"unit" => "opinionWorkflow",
"label" => _AVIS_WORKFLOW
],
[
"unit" => "visaWorkflow",
"label" => _VISA_WORKFLOW
]
];
// Array containing all path to the pdf files to merge // Array containing all path to the pdf files to merge
$documentPaths = []; $documentPaths = [];
...@@ -54,56 +85,23 @@ class ResourceDataExportController ...@@ -54,56 +85,23 @@ class ResourceDataExportController
$unitsSummarySheet = []; $unitsSummarySheet = [];
if (!empty($body['summarySheet'])) { if (!empty($body['summarySheet'])) {
$unitsSummarySheet = $body['summarySheet']; $unitsSummarySheet = $body['summarySheet'];
} else if (count($body['resources']) > 1) {
$unitsSummarySheet = $defaultUnits;
} }
$forceSummarySheet = count($body['resources']) > 1;
$resIds = array_column($body['resources'], 'resId'); $resIds = array_column($body['resources'], 'resId');
if (!ResController::hasRightByResId(['resId' => $resIds, 'userId' => $GLOBALS['id']])) { if (!ResController::hasRightByResId(['resId' => $resIds, 'userId' => $GLOBALS['id']])) {
return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']);
} }
foreach ($body['resources'] as $resource) { foreach ($body['resources'] as $resource) {
$withSummarySheet = $forceSummarySheet || !empty($unitsSummarySheet); $withSummarySheet = !empty($unitsSummarySheet) || !empty($resource['summarySheet']);
if (!$withSummarySheet) {
$withSummarySheet = !empty($resource['summarySheet']);
}
if ($withSummarySheet) { if ($withSummarySheet) {
if (!empty($resource['summarySheet']) && is_array($resource['summarySheet'])) { if (!empty($resource['summarySheet']) && is_array($resource['summarySheet'])) {
$units = $resource['summarySheet']; $units = $resource['summarySheet'];
} else if (!empty($unitsSummarySheet)) {
$units = $unitsSummarySheet;
} else { } else {
$units = [ $units = $unitsSummarySheet;
[
"unit" => "qrcode",
"label" => ""
],
[
"unit" => "primaryInformations",
"label" => "Informations pricipales"
],
[
"unit" => "senderRecipientInformations",
"label" => "Informations de destination"
],
[
"unit" => "secondaryInformations",
"label" => "Informations secondaires"
],
[
"unit" => "diffusionList",
"label" => "Liste de diffusion"
],
[
"unit" => "opinionWorkflow",
"label" => "Circuit d'avis"
],
[
"unit" => "visaWorkflow",
"label" => "Circuit de visa"
]
];
} }
$documentPaths[] = ResourceDataExportController::getSummarySheet(['units' => $units, 'resId' => $resource['resId']]); $documentPaths[] = ResourceDataExportController::getSummarySheet(['units' => $units, 'resId' => $resource['resId']]);
...@@ -730,7 +728,7 @@ class ResourceDataExportController ...@@ -730,7 +728,7 @@ class ResourceDataExportController
$pdf = new Fpdi('P', 'pt'); $pdf = new Fpdi('P', 'pt');
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
SummarySheetController::createSummarySheet($pdf, [ // TODO check missing border for date limite de traitement SummarySheetController::createSummarySheet($pdf, [
'resource' => $resource, 'resource' => $resource,
'units' => $units, 'units' => $units,
'login' => $GLOBALS['userId'], 'login' => $GLOBALS['userId'],
......
...@@ -462,3 +462,4 @@ define("_CONTACT", "Contact"); ...@@ -462,3 +462,4 @@ define("_CONTACT", "Contact");
define("_CHRONO_NUMBER_MASTER", "Resource chrono number"); define("_CHRONO_NUMBER_MASTER", "Resource chrono number");
define("_SENT_BY", "Sent by"); define("_SENT_BY", "Sent by");
define('_TO_CCI', 'On copy hidden'); define('_TO_CCI', 'On copy hidden');
define('_PRIMARY_INFORMATION', 'Primary information');
...@@ -461,3 +461,4 @@ define("_CONTACT", "Contact"); ...@@ -461,3 +461,4 @@ define("_CONTACT", "Contact");
define("_CHRONO_NUMBER_MASTER", "Numéro chrono courrier"); define("_CHRONO_NUMBER_MASTER", "Numéro chrono courrier");
define("_SENT_BY", "Envoyé par"); define("_SENT_BY", "Envoyé par");
define('_TO_CCI', 'En copie caché'); define('_TO_CCI', 'En copie caché');
define('_PRIMARY_INFORMATION', 'Informations principales');
...@@ -467,3 +467,4 @@ define("_SUBJECT", "Subject"); //TO TRANSLATE ...@@ -467,3 +467,4 @@ define("_SUBJECT", "Subject"); //TO TRANSLATE
define("_CHRONO_NUMBER_MASTER", "Resource chrono number"); //TO TRANSLATE define("_CHRONO_NUMBER_MASTER", "Resource chrono number"); //TO TRANSLATE
define("_SENT_BY", "Sent by"); //TO TRANSLATE define("_SENT_BY", "Sent by"); //TO TRANSLATE
define('_TO_CCI', 'On copy hidden'); //TO TRANSLATE define('_TO_CCI', 'On copy hidden'); //TO TRANSLATE
define('_PRIMARY_INFORMATION', 'Primary information'); //TO TRANSLATE
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