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

FEAT #9082 All resources for summary sheet

parent 66d9c710
No related branches found
No related tags found
No related merge requests found
...@@ -27,6 +27,7 @@ use Resource\models\ResourceListModel; ...@@ -27,6 +27,7 @@ use Resource\models\ResourceListModel;
use setasign\Fpdi\Tcpdf\Fpdi; use setasign\Fpdi\Tcpdf\Fpdi;
use Slim\Http\Request; use Slim\Http\Request;
use Slim\Http\Response; use Slim\Http\Response;
use SrcCore\controllers\PreparedClauseController;
use SrcCore\models\CoreConfigModel; use SrcCore\models\CoreConfigModel;
use SrcCore\models\TextFormatModel; use SrcCore\models\TextFormatModel;
use SrcCore\models\ValidatorModel; use SrcCore\models\ValidatorModel;
...@@ -45,27 +46,42 @@ class SummarySheetController ...@@ -45,27 +46,42 @@ class SummarySheetController
} }
$queryParamsData = $request->getQueryParams(); $queryParamsData = $request->getQueryParams();
/*$queryParamsData['units'] = base64_encode(json_encode([ // $queryParamsData['units'] = base64_encode(json_encode([
['label' => 'Informations', 'unit' => 'primaryInformations'], // ['label' => 'Informations', 'unit' => 'primaryInformations'],
['label' => 'Informations Secondaires', 'unit' => 'secondaryInformations'], // ['label' => 'Informations Secondaires', 'unit' => 'secondaryInformations'],
['label' => 'Liste de diffusion', 'unit' => 'diffusionList'], // ['label' => 'Liste de diffusion', 'unit' => 'diffusionList'],
['label' => 'Ptit avis les potos.', 'unit' => 'freeField'], // ['label' => 'Ptit avis les potos.', 'unit' => 'freeField'],
['label' => 'Annotation(s)', 'unit' => 'notes'], // ['label' => 'Annotation(s)', 'unit' => 'notes'],
['label' => 'Circuit de visa', 'unit' => 'visaWorkflow'], // ['label' => 'Circuit de visa', 'unit' => 'visaWorkflow'],
['label' => 'Circuit d\'avis', 'unit' => 'opinionWorkflow'], // ['label' => 'Circuit d\'avis', 'unit' => 'opinionWorkflow'],
['label' => 'Commentaires', 'unit' => 'freeField'], // ['label' => 'Commentaires', 'unit' => 'freeField'],
['unit' => 'qrcode'], // ['unit' => 'qrcode'],
]));*/ // ]));
// $queryParamsData['resources'] = [237, 352];
$units = empty($queryParamsData['units']) ? [] : (array)json_decode(base64_decode($queryParamsData['units'])); $units = empty($queryParamsData['units']) ? [] : (array)json_decode(base64_decode($queryParamsData['units']));
$basket = BasketModel::getById(['id' => $aArgs['basketId'], 'select' => ['basket_clause', 'basket_res_order', 'basket_name']]); $basket = BasketModel::getById(['id' => $aArgs['basketId'], 'select' => ['basket_clause', 'basket_res_order', 'basket_name']]);
$user = UserModel::getById(['id' => $aArgs['userId'], 'select' => ['user_id']]); $user = UserModel::getById(['id' => $aArgs['userId'], 'select' => ['user_id']]);
$allQueryData = ResourceListController::getResourcesListQueryData(['data' => $queryParamsData, 'basketClause' => $basket['basket_clause'], 'login' => $user['user_id']]); $whereClause = PreparedClauseController::getPreparedClause(['clause' => $basket['basket_clause'], 'login' => $user['user_id']]);
if (!empty($allQueryData['order'])) { $rawResourcesInBasket = ResModel::getOnView([
$queryParamsData['order'] = $allQueryData['order']; 'select' => ['res_id'],
'where' => [$whereClause]
]);
$allResourcesInBasket = [];
foreach ($rawResourcesInBasket as $resource) {
$allResourcesInBasket[] = $resource['res_id'];
}
$order = 'CASE res_view_letterbox.res_id ';
foreach ($queryParamsData['resources'] as $key => $resId) {
if (!in_array($resId, $allResourcesInBasket)) {
return $response->withStatus(403)->withJson(['errors' => 'Resources out of perimeter']);
}
$order .= "WHEN {$resId} THEN {$key} ";
} }
$order .= 'END';
$select = ['res_id', 'subject', 'alt_identifier']; $select = ['res_id', 'subject', 'alt_identifier'];
foreach ($units as $unit) { foreach ($units as $unit) {
...@@ -81,13 +97,12 @@ class SummarySheetController ...@@ -81,13 +97,12 @@ class SummarySheetController
$select = array_merge($select, $informations); $select = array_merge($select, $informations);
} }
} }
$resources = ResourceListModel::getOnView([
$resources = ResModel::getOnView([
'select' => $select, 'select' => $select,
'table' => $allQueryData['table'], 'where' => ['res_view_letterbox.res_id in (?)'],
'leftJoin' => $allQueryData['leftJoin'], 'data' => [$queryParamsData['resources']],
'where' => $allQueryData['where'], 'orderBy' => [$order]
'data' => $allQueryData['queryData'],
'orderBy' => empty($queryParamsData['order']) ? [$basket['basket_res_order']] : [$queryParamsData['order']]
]); ]);
$pdf = new Fpdi('P', 'pt'); $pdf = new Fpdi('P', 'pt');
......
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