Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 283 |
|
0.00% |
0 / 22 |
CRAP | |
0.00% |
0 / 1 |
TreatmentGenerator | |
0.00% |
0 / 283 |
|
0.00% |
0 / 22 |
6642 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
initializeExtract | |
0.00% |
0 / 33 |
|
0.00% |
0 / 1 |
12 | |||
collectivityHeaders | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
initializeCollectivity | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
treatmentGeneralInformationsHeaders | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
2 | |||
initializeTreatmentGeneralInformations | |
0.00% |
0 / 24 |
|
0.00% |
0 / 1 |
306 | |||
treatmentDataCategoryHeaders | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
initializeTreatmentDataCategory | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
treatmentRecipientsHeaders | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
initializeTreatmentRecipients | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
treatmentHistoricHeaders | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
initializeTreatmentHistoric | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
treatmentDetailsHeaders | |
0.00% |
0 / 29 |
|
0.00% |
0 / 1 |
2 | |||
initializeTreatmentDetails | |
0.00% |
0 / 39 |
|
0.00% |
0 / 1 |
272 | |||
treatmentSecurityHeaders | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
2 | |||
initializeTreatmentSecurity | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
90 | |||
treatmentSpecificHeaders | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
2 | |||
initializeTreatmentSpecific | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
90 | |||
treatmentProofHeaders | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
initializeTreatmentProof | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
treatmentConformiteHeaders | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
initializeTreatmentConformite | |
0.00% |
0 / 30 |
|
0.00% |
0 / 1 |
90 |
1 | <?php |
2 | |
3 | /** |
4 | * This file is part of the MADIS - RGPD Management application. |
5 | * |
6 | * @copyright Copyright (c) 2018-2019 Soluris - Solutions Numériques Territoriales Innovantes |
7 | * |
8 | * This program is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU Affero General Public License as published by |
10 | * the Free Software Foundation, either version 3 of the License, or |
11 | * (at your option) any later version. |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU Affero General Public License for more details. |
17 | * |
18 | * You should have received a copy of the GNU Affero General Public License |
19 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
20 | */ |
21 | |
22 | declare(strict_types=1); |
23 | |
24 | namespace App\Domain\Reporting\Generator\Csv; |
25 | |
26 | use App\Domain\Registry\Calculator\Completion\ConformiteTraitementCompletion; |
27 | use App\Domain\Registry\Dictionary\ConformiteTraitementLevelDictionary; |
28 | use App\Domain\Registry\Dictionary\MesurementStatusDictionary; |
29 | use App\Domain\Registry\Dictionary\TreatmentAuthorDictionary; |
30 | use App\Domain\Registry\Dictionary\TreatmentCollectingMethodDictionary; |
31 | use App\Domain\Registry\Dictionary\TreatmentLegalBasisDictionary; |
32 | use App\Domain\Registry\Dictionary\TreatmentUltimateFateDictionary; |
33 | use App\Domain\Registry\Model\Mesurement; |
34 | use App\Domain\User\Repository\Collectivity; |
35 | use App\Infrastructure\ORM\Registry\Repository\ConformiteTraitement\Question; |
36 | use App\Infrastructure\ORM\Registry\Repository\Treatment; |
37 | use Symfony\Component\Security\Core\Security; |
38 | use Symfony\Contracts\Translation\TranslatorInterface; |
39 | |
40 | class TreatmentGenerator extends AbstractGenerator |
41 | { |
42 | /** |
43 | * @var TranslatorInterface |
44 | */ |
45 | private $translator; |
46 | |
47 | /** |
48 | * @var Collectivity |
49 | */ |
50 | private $collectivityRepository; |
51 | |
52 | /** |
53 | * @var Treatment |
54 | */ |
55 | private $treatmentRepository; |
56 | |
57 | /** |
58 | * @var Question |
59 | */ |
60 | private $questionRepository; |
61 | |
62 | /** |
63 | * @var Security |
64 | */ |
65 | private $security; |
66 | |
67 | public function __construct( |
68 | TranslatorInterface $translatorInterface, |
69 | Collectivity $collectivityRepository, |
70 | Treatment $treatmentRepository, |
71 | Question $questionRepository, |
72 | Security $security, |
73 | ) { |
74 | $this->translator = $translatorInterface; |
75 | $this->collectivityRepository = $collectivityRepository; |
76 | $this->treatmentRepository = $treatmentRepository; |
77 | $this->questionRepository = $questionRepository; |
78 | $this->security = $security; |
79 | } |
80 | |
81 | public function initializeExtract(): array |
82 | { |
83 | $headers = array_merge( |
84 | ['Nom'], |
85 | $this->collectivityHeaders(), |
86 | $this->treatmentGeneralInformationsHeaders(), |
87 | $this->treatmentDataCategoryHeaders(), |
88 | $this->treatmentRecipientsHeaders(), |
89 | $this->treatmentHistoricHeaders(), |
90 | $this->treatmentDetailsHeaders(), |
91 | $this->treatmentSecurityHeaders(), |
92 | $this->treatmentSpecificHeaders(), |
93 | $this->treatmentProofHeaders(), |
94 | $this->treatmentConformiteHeaders(), |
95 | ); |
96 | $data = [$headers]; |
97 | |
98 | $user = null; |
99 | if (!$this->security->isGranted('ROLE_ADMIN')) { |
100 | $user = $this->security->getUser(); |
101 | } |
102 | |
103 | /** @var \App\Domain\Registry\Model\Treatment $treatment */ |
104 | foreach ($this->treatmentRepository->findAllByActiveCollectivity(true, $user) as $treatment) { |
105 | $extract = array_merge( |
106 | [$treatment->getName()], |
107 | $this->initializeCollectivity($treatment->getCollectivity()), |
108 | $this->initializeTreatmentGeneralInformations($treatment), |
109 | $this->initializeTreatmentDataCategory($treatment), |
110 | $this->initializeTreatmentRecipients($treatment), |
111 | $this->initializeTreatmentHistoric($treatment), |
112 | $this->initializeTreatmentDetails($treatment), |
113 | $this->initializeTreatmentSecurity($treatment), |
114 | $this->initializeTreatmentSpecific($treatment), |
115 | $this->initializeTreatmentProof($treatment), |
116 | $this->initializeTreatmentConformite($treatment), |
117 | ); |
118 | array_push($data, $extract); |
119 | } |
120 | |
121 | return $data; |
122 | } |
123 | |
124 | private function collectivityHeaders(): array |
125 | { |
126 | $collectivityTrans = $this->translator->trans('global.label.organization'); |
127 | |
128 | return [ |
129 | $collectivityTrans . ' - ' . $this->translator->trans('user.organization.label.name'), |
130 | $collectivityTrans . ' - ' . $this->translator->trans('user.organization.label.siren'), |
131 | $collectivityTrans . ' - ' . $this->translator->trans('global.label.address.insee'), |
132 | ]; |
133 | } |
134 | |
135 | private function initializeCollectivity(\App\Domain\User\Model\Collectivity $collectivity) |
136 | { |
137 | return [ |
138 | $collectivity->getName(), |
139 | $collectivity->getSiren(), |
140 | $collectivity->getAddress()->getInsee(), |
141 | ]; |
142 | } |
143 | |
144 | private function treatmentGeneralInformationsHeaders() |
145 | { |
146 | return [ |
147 | $this->translator->trans('registry.treatment.label.author'), |
148 | $this->translator->trans('registry.treatment.label.coordonnees_responsable_traitement'), |
149 | $this->translator->trans('registry.treatment.label.goal'), |
150 | $this->translator->trans('registry.treatment.label.manager'), |
151 | $this->translator->trans('registry.treatment.label.active'), |
152 | $this->translator->trans('registry.treatment.label.legal_basis'), |
153 | $this->translator->trans('registry.treatment.label.legal_basis_justification'), |
154 | $this->translator->trans('registry.treatment.label.observation'), |
155 | $this->translator->trans('registry.treatment.label.public_registry'), |
156 | $this->translator->trans('registry.treatment.label.exempt_AIPD'), |
157 | $this->translator->trans('registry.treatment.label.dpoMessage'), |
158 | ]; |
159 | } |
160 | |
161 | private function initializeTreatmentGeneralInformations(\App\Domain\Registry\Model\Treatment $treatment): array |
162 | { |
163 | $yes = $this->translator->trans('global.label.yes'); |
164 | $no = $this->translator->trans('global.label.no'); |
165 | |
166 | $goal = $treatment->getGoal(); |
167 | $legalBasisJustification = $treatment->getLegalBasisJustification(); |
168 | $observation = $treatment->getObservation(); |
169 | if (!\is_null($goal) && isset($goal[0]) && '-' === $goal[0]) { |
170 | $goal = ' ' . $goal; |
171 | } |
172 | if (!\is_null($legalBasisJustification) && isset($legalBasisJustification[0]) && '-' === $legalBasisJustification[0]) { |
173 | $legalBasisJustification = ' ' . $legalBasisJustification; |
174 | } |
175 | if (!\is_null($observation) && isset($observation[0]) && '-' === $observation[0]) { |
176 | $observation = ' ' . $observation; |
177 | } |
178 | |
179 | return [ |
180 | !\is_null($treatment->getAuthor()) && array_key_exists($treatment->getAuthor(), TreatmentAuthorDictionary::getAuthors()) ? TreatmentAuthorDictionary::getAuthors()[$treatment->getAuthor()] : $treatment->getAuthor(), |
181 | $treatment->getCoordonneesResponsableTraitement(), |
182 | $goal, |
183 | $treatment->getManager(), |
184 | $treatment->isActive() ? $this->translator->trans('global.label.active') : $this->translator->trans('global.label.inactive'), |
185 | !\is_null($treatment->getLegalBasis()) && array_key_exists($treatment->getLegalBasis(), TreatmentLegalBasisDictionary::getBasis()) ? TreatmentLegalBasisDictionary::getBasis()[$treatment->getLegalBasis()] : $treatment->getLegalBasis(), |
186 | $legalBasisJustification, |
187 | $observation, |
188 | $treatment->getPublic() ? $yes : $no, |
189 | $treatment->getExemptAIPD() ? $yes : $no, |
190 | $treatment->getDpoMessage(), |
191 | ]; |
192 | } |
193 | |
194 | private function treatmentDataCategoryHeaders() |
195 | { |
196 | $dataCategoryTrans = $this->translator->trans('registry.treatment.tab.data_category'); |
197 | |
198 | return [ |
199 | $this->translator->trans('registry.treatment.label.data_category'), |
200 | $dataCategoryTrans . ' - ' . $this->translator->trans('registry.treatment.label.data_category_other'), |
201 | ]; |
202 | } |
203 | |
204 | private function initializeTreatmentDataCategory(\App\Domain\Registry\Model\Treatment $treatment): array |
205 | { |
206 | return [ |
207 | implode(' - ', \iterable_to_array($treatment->getDataCategories())), |
208 | $treatment->getDataCategoryOther(), |
209 | ]; |
210 | } |
211 | |
212 | private function treatmentRecipientsHeaders() |
213 | { |
214 | $recipientsTrans = $this->translator->trans('registry.treatment.tab.recipients'); |
215 | |
216 | return [ |
217 | $recipientsTrans . ' - ' . $this->translator->trans('registry.treatment.label.recipient_category'), |
218 | $recipientsTrans . ' - ' . $this->translator->trans('global.label.linked_contractor'), |
219 | ]; |
220 | } |
221 | |
222 | private function initializeTreatmentRecipients(\App\Domain\Registry\Model\Treatment $treatment): array |
223 | { |
224 | return [ |
225 | $treatment->getRecipientCategory(), |
226 | implode(' - ', \iterable_to_array($treatment->getContractors())) ?: '', |
227 | ]; |
228 | } |
229 | |
230 | private function treatmentHistoricHeaders() |
231 | { |
232 | $historicTrans = $this->translator->trans('global.tab.history'); |
233 | |
234 | return [ |
235 | $historicTrans . ' - ' . $this->translator->trans('global.label.created_by'), |
236 | $historicTrans . ' - ' . $this->translator->trans('global.label.created_at'), |
237 | $historicTrans . ' - ' . $this->translator->trans('global.label.updated_at'), |
238 | ]; |
239 | } |
240 | |
241 | private function initializeTreatmentHistoric(\App\Domain\Registry\Model\Treatment $treatment): array |
242 | { |
243 | return [ |
244 | $treatment->getCreator(), |
245 | $this->getDate($treatment->getCreatedAt()), |
246 | $this->getDate($treatment->getUpdatedAt()), |
247 | ]; |
248 | } |
249 | |
250 | private function treatmentDetailsHeaders() |
251 | { |
252 | $detailsTrans = $this->translator->trans('registry.treatment.tab.details'); |
253 | $concernedPeople = $this->translator->trans('registry.treatment.label.concerned_people'); |
254 | $delayTrans = $this->translator->trans('registry.treatment.label.shelflife'); |
255 | |
256 | return [ |
257 | $detailsTrans . ' - ' . $concernedPeople . ' - ' . $this->translator->trans('registry.treatment.label.concerned_people_particular'), |
258 | $detailsTrans . ' - ' . $concernedPeople . ' - ' . $this->translator->trans('registry.treatment.label.concerned_people_particular') . ' - Commentaire', |
259 | $detailsTrans . ' - ' . $concernedPeople . ' - ' . $this->translator->trans('registry.treatment.label.concerned_people_user'), |
260 | $detailsTrans . ' - ' . $concernedPeople . ' - ' . $this->translator->trans('registry.treatment.label.concerned_people_user') . ' - Commentaire', |
261 | $detailsTrans . ' - ' . $concernedPeople . ' - ' . $this->translator->trans('registry.treatment.label.concerned_people_agent'), |
262 | $detailsTrans . ' - ' . $concernedPeople . ' - ' . $this->translator->trans('registry.treatment.label.concerned_people_agent') . ' - Commentaire', |
263 | $detailsTrans . ' - ' . $concernedPeople . ' - ' . $this->translator->trans('registry.treatment.label.concerned_people_elected'), |
264 | $detailsTrans . ' - ' . $concernedPeople . ' - ' . $this->translator->trans('registry.treatment.label.concerned_people_elected') . ' - Commentaire', |
265 | $detailsTrans . ' - ' . $concernedPeople . ' - ' . $this->translator->trans('registry.treatment.label.concerned_people_company'), |
266 | $detailsTrans . ' - ' . $concernedPeople . ' - ' . $this->translator->trans('registry.treatment.label.concerned_people_company') . ' - Commentaire', |
267 | $detailsTrans . ' - ' . $concernedPeople . ' - ' . $this->translator->trans('registry.treatment.label.concerned_people_partner'), |
268 | $detailsTrans . ' - ' . $concernedPeople . ' - ' . $this->translator->trans('registry.treatment.label.concerned_people_partner') . ' - Commentaire', |
269 | $detailsTrans . ' - ' . $concernedPeople . ' - ' . $this->translator->trans('registry.treatment.label.concerned_people_usager'), |
270 | $detailsTrans . ' - ' . $concernedPeople . ' - ' . $this->translator->trans('registry.treatment.label.concerned_people_usager') . ' - Commentaire', |
271 | $detailsTrans . ' - ' . $concernedPeople . ' - ' . $this->translator->trans('registry.treatment.label.concerned_people_other'), |
272 | $detailsTrans . ' - ' . $concernedPeople . ' - ' . $this->translator->trans('registry.treatment.label.concerned_people_other') . ' - Commentaire', |
273 | $detailsTrans . ' - ' . $this->translator->trans('registry.treatment.label.estimated_concerned_people'), |
274 | $detailsTrans . ' - ' . $this->translator->trans('registry.treatment.label.tools_if_inactif'), |
275 | $detailsTrans . ' - ' . $this->translator->trans('registry.treatment.label.paper_processing'), |
276 | $detailsTrans . ' - ' . $delayTrans . ' - ' . $this->translator->trans('registry.treatment.label.shelflife_duration'), |
277 | $detailsTrans . ' - ' . $delayTrans . ' - ' . $this->translator->trans('registry.treatment.label.shelflife_name'), |
278 | $detailsTrans . ' - ' . $delayTrans . ' - ' . $this->translator->trans('registry.treatment.label.shelflife_ultimate_fate'), |
279 | $detailsTrans . ' - ' . $this->translator->trans('registry.treatment.label.data_origin'), |
280 | $detailsTrans . ' - ' . $this->translator->trans('registry.treatment.label.collecting_method'), |
281 | ]; |
282 | } |
283 | |
284 | private function initializeTreatmentDetails(\App\Domain\Registry\Model\Treatment $treatment): array |
285 | { |
286 | $yes = $this->translator->trans('global.label.yes'); |
287 | $no = $this->translator->trans('global.label.no'); |
288 | |
289 | $shelfLifes = $treatment->getShelfLifes(); |
290 | |
291 | $duration = ''; |
292 | $name = ''; |
293 | $ultimateFate = ''; |
294 | |
295 | if (count($shelfLifes) > 0) { |
296 | foreach ($shelfLifes as $key => $shelfLife) { |
297 | $duration .= $key + 1 . ': ' . $shelfLife->duration . " \r\n"; |
298 | $name .= $key + 1 . ': ' . $shelfLife->name . "\r\n"; |
299 | $ultimateFate .= $key + 1 . ': ' . TreatmentUltimateFateDictionary::getUltimateFates()[$shelfLife->ultimateFate] . "\r\n"; |
300 | } |
301 | } |
302 | |
303 | return [ |
304 | $treatment->getConcernedPeopleParticular()->isCheck() ? $yes : $no, |
305 | $treatment->getConcernedPeopleParticular()->getComment(), |
306 | $treatment->getConcernedPeopleUser()->isCheck() ? $yes : $no, |
307 | $treatment->getConcernedPeopleUser()->getComment(), |
308 | $treatment->getConcernedPeopleUsager()->isCheck() ? $yes : $no, |
309 | $treatment->getConcernedPeopleUsager()->getComment(), |
310 | $treatment->getConcernedPeopleAgent()->isCheck() ? $yes : $no, |
311 | $treatment->getConcernedPeopleAgent()->getComment(), |
312 | $treatment->getConcernedPeopleElected()->isCheck() ? $yes : $no, |
313 | $treatment->getConcernedPeopleElected()->getComment(), |
314 | $treatment->getConcernedPeopleCompany()->isCheck() ? $yes : $no, |
315 | $treatment->getConcernedPeopleCompany()->getComment(), |
316 | $treatment->getConcernedPeoplePartner()->isCheck() ? $yes : $no, |
317 | $treatment->getConcernedPeoplePartner()->getComment(), |
318 | $treatment->getConcernedPeopleOther()->isCheck() ? $yes : $no, |
319 | $treatment->getConcernedPeopleOther()->getComment(), |
320 | $treatment->getEstimatedConcernedPeople(), |
321 | $treatment->getCollectivity() && $treatment->getCollectivity()->isHasModuleTools() ? $treatment->getToolsString() : $treatment->getSoftware(), |
322 | $treatment->isPaperProcessing() ? $this->translator->trans('global.label.active') : $this->translator->trans('global.label.inactive'), |
323 | $duration, |
324 | $name, |
325 | $ultimateFate, |
326 | $treatment->getDataOrigin(), |
327 | !\is_null($treatment->getCollectingMethod()) ? join(', ', array_map(function ($cm) { |
328 | return array_key_exists($cm, TreatmentCollectingMethodDictionary::getMethods()) ? TreatmentCollectingMethodDictionary::getMethods()[$cm] : $cm; |
329 | }, $treatment->getCollectingMethod())) : '', |
330 | ]; |
331 | } |
332 | |
333 | private function treatmentSecurityHeaders() |
334 | { |
335 | $securityTrans = $this->translator->trans('registry.treatment.tab.security'); |
336 | |
337 | return [ |
338 | $securityTrans . ' - ' . $this->translator->trans('registry.treatment.label.security_access_control'), |
339 | $securityTrans . ' - ' . $this->translator->trans('registry.treatment.label.security_access_control') . ' - Commentaire', |
340 | $securityTrans . ' - ' . $this->translator->trans('registry.treatment.label.security_update'), |
341 | $securityTrans . ' - ' . $this->translator->trans('registry.treatment.label.security_update') . ' - Commentaire', |
342 | $securityTrans . ' - ' . $this->translator->trans('registry.treatment.label.security_saving'), |
343 | $securityTrans . ' - ' . $this->translator->trans('registry.treatment.label.security_saving') . ' - Commentaire', |
344 | $securityTrans . ' - ' . $this->translator->trans('registry.treatment.label.security_tracability'), |
345 | $securityTrans . ' - ' . $this->translator->trans('registry.treatment.label.security_tracability') . ' - Commentaire', |
346 | $securityTrans . ' - ' . $this->translator->trans('registry.treatment.label.security_other'), |
347 | $securityTrans . ' - ' . $this->translator->trans('registry.treatment.label.security_other') . ' - Commentaire', |
348 | $securityTrans . ' - ' . $this->translator->trans('registry.treatment.label.security_entitled_persons'), |
349 | $securityTrans . ' - ' . $this->translator->trans('registry.treatment.label.security_open_accounts'), |
350 | $securityTrans . ' - ' . $this->translator->trans('registry.treatment.label.security_specificities_delivered'), |
351 | ]; |
352 | } |
353 | |
354 | private function initializeTreatmentSecurity(\App\Domain\Registry\Model\Treatment $treatment): array |
355 | { |
356 | $yes = $this->translator->trans('global.label.yes'); |
357 | $no = $this->translator->trans('global.label.no'); |
358 | |
359 | return [ |
360 | $treatment->getSecurityAccessControl()->isCheck() ? $yes : $no, |
361 | $treatment->getSecurityAccessControl()->getComment(), |
362 | $treatment->getSecurityUpdate()->isCheck() ? $yes : $no, |
363 | $treatment->getSecurityUpdate()->getComment(), |
364 | $treatment->getSecuritySaving()->isCheck() ? $yes : $no, |
365 | $treatment->getSecuritySaving()->getComment(), |
366 | $treatment->getSecurityTracability()->isCheck() ? $yes : $no, |
367 | $treatment->getSecurityTracability()->getComment(), |
368 | $treatment->getSecurityOther()->isCheck() ? $yes : $no, |
369 | $treatment->getSecurityOther()->getComment(), |
370 | $treatment->isSecurityEntitledPersons() ? $yes : $no, |
371 | $treatment->isSecurityOpenAccounts() ? $yes : $no, |
372 | $treatment->isSecuritySpecificitiesDelivered() ? $yes : $no, |
373 | ]; |
374 | } |
375 | |
376 | private function treatmentSpecificHeaders() |
377 | { |
378 | $specificTrans = $this->translator->trans('registry.treatment.tab.specific'); |
379 | |
380 | return [ |
381 | $specificTrans . ' - ' . $this->translator->trans('registry.treatment.label.large_scale_collection'), |
382 | $specificTrans . ' - ' . $this->translator->trans('registry.treatment.label.data_crossing'), |
383 | $specificTrans . ' - ' . $this->translator->trans('registry.treatment.label.automated_decisions_with_legal_effect'), |
384 | $specificTrans . ' - ' . $this->translator->trans('registry.treatment.label.evaluation_or_rating'), |
385 | $specificTrans . ' - ' . $this->translator->trans('registry.treatment.label.automatic_exclusion_service'), |
386 | $specificTrans . ' - ' . $this->translator->trans('registry.treatment.label.vulnerable_people'), |
387 | $specificTrans . ' - ' . $this->translator->trans('registry.treatment.label.systematic_monitoring'), |
388 | $specificTrans . ' - ' . $this->translator->trans('registry.treatment.label.innovative_use'), |
389 | ]; |
390 | } |
391 | |
392 | private function initializeTreatmentSpecific(\App\Domain\Registry\Model\Treatment $treatment): array |
393 | { |
394 | $yes = $this->translator->trans('global.label.yes'); |
395 | $no = $this->translator->trans('global.label.no'); |
396 | |
397 | return [ |
398 | $treatment->isLargeScaleCollection() ? $yes : $no, |
399 | $treatment->isDataCrossing() ? $yes : $no, |
400 | $treatment->isAutomatedDecisionsWithLegalEffect() ? $yes : $no, |
401 | $treatment->isEvaluationOrRating() ? $yes : $no, |
402 | $treatment->isAutomaticExclusionService() ? $yes : $no, |
403 | $treatment->isVulnerablePeople() ? $yes : $no, |
404 | $treatment->isSystematicMonitoring() ? $yes : $no, |
405 | $treatment->isInnovativeUse() ? $yes : $no, |
406 | ]; |
407 | } |
408 | |
409 | private function treatmentProofHeaders() |
410 | { |
411 | return [ |
412 | 'Nb ' . $this->translator->trans('global.label.linked_proof'), |
413 | ]; |
414 | } |
415 | |
416 | private function initializeTreatmentProof(\App\Domain\Registry\Model\Treatment $treatment): array |
417 | { |
418 | return [ |
419 | count($treatment->getProofs()), |
420 | ]; |
421 | } |
422 | |
423 | private function treatmentConformiteHeaders() |
424 | { |
425 | $conformiteTraitementHeaders = [ |
426 | $this->translator->trans('registry.treatment.label.conformite_traitement'), |
427 | $this->translator->trans('registry.treatment.label.conformite_traitement_created_at'), |
428 | $this->translator->trans('registry.treatment.label.conformite_traitement_updated_at'), |
429 | ]; |
430 | |
431 | foreach ($this->questionRepository->findAll(['position' => 'asc']) as $question) { |
432 | $conformiteTraitementHeaders[] = $this->translator->trans('registry.treatment.label.conformite_traitement') . ' - Question : ' . $question->getQuestion(); |
433 | } |
434 | |
435 | return $conformiteTraitementHeaders; |
436 | } |
437 | |
438 | private function initializeTreatmentConformite(\App\Domain\Registry\Model\Treatment $treatment): array |
439 | { |
440 | if (!$treatment->getCollectivity()->isHasModuleConformiteTraitement()) { |
441 | return ['Module non actif']; |
442 | } |
443 | |
444 | $conformtiteTraitement = $treatment->getConformiteTraitement(); |
445 | if (\is_null($conformtiteTraitement)) { |
446 | return ['Non effectuée']; |
447 | } |
448 | |
449 | $data = [ |
450 | ConformiteTraitementLevelDictionary::getConformites()[ConformiteTraitementCompletion::getConformiteTraitementLevel($conformtiteTraitement)], |
451 | $this->getDate($conformtiteTraitement->getCreatedAt()), |
452 | $this->getDate($conformtiteTraitement->getUpdatedAt()), |
453 | ]; |
454 | |
455 | $responses = $treatment->getConformiteTraitement()->getReponses(); |
456 | |
457 | $ordered = []; |
458 | foreach ($responses as $reponse) { |
459 | $ordered[$reponse->getQuestion()->getPosition()] = $reponse; |
460 | } |
461 | |
462 | \ksort($ordered); |
463 | |
464 | foreach ($ordered as $reponse) { |
465 | if ($reponse->isConforme()) { |
466 | $data[] = 'Conforme'; |
467 | continue; |
468 | } |
469 | |
470 | if (\count($reponse->getActionProtections()) > 0) { |
471 | $planified = array_filter(\iterable_to_array($reponse->getActionProtections()), function (Mesurement $mesurement) { |
472 | return MesurementStatusDictionary::STATUS_NOT_APPLIED === $mesurement->getStatus() |
473 | && !\is_null($mesurement->getPlanificationDate()) |
474 | ; |
475 | }); |
476 | |
477 | if (\count($planified) > 0) { |
478 | $data[] = 'Non-conforme mineure'; |
479 | continue; |
480 | } |
481 | } |
482 | |
483 | $data[] = 'Non-conforme majeure'; |
484 | } |
485 | |
486 | return $data; |
487 | } |
488 | } |