Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
7.78% |
14 / 180 |
|
12.50% |
1 / 8 |
CRAP | |
0.00% |
0 / 1 |
OverviewGenerator | |
7.78% |
14 / 180 |
|
12.50% |
1 / 8 |
8424.11 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
14 / 14 |
|
100.00% |
1 / 1 |
1 | |||
setCollectivity | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
2 | |||
generateObjectPart | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 | |||
generateOrganismIntroductionPart | |
0.00% |
0 / 43 |
|
0.00% |
0 / 1 |
156 | |||
generateRegistries | |
0.00% |
0 / 39 |
|
0.00% |
0 / 1 |
462 | |||
generateManagementSystemAndCompliance | |
0.00% |
0 / 21 |
|
0.00% |
0 / 1 |
702 | |||
generateContinuousImprovements | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
30 | |||
generateAnnexeMention | |
0.00% |
0 / 30 |
|
0.00% |
0 / 1 |
1260 |
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\Word; |
25 | |
26 | use App\Application\Symfony\Security\UserProvider; |
27 | use App\Domain\Registry\Model\ConformiteOrganisation\Evaluation; |
28 | use App\Domain\User\Dictionary\ContactCivilityDictionary; |
29 | use App\Domain\User\Model\Collectivity; |
30 | use App\Domain\User\Model\ReviewData; |
31 | use PhpOffice\PhpWord\Element\Section; |
32 | use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; |
33 | |
34 | class OverviewGenerator extends AbstractGenerator |
35 | { |
36 | /** |
37 | * @var TreatmentGenerator |
38 | */ |
39 | protected $treatmentGenerator; |
40 | |
41 | /** |
42 | * @var ContractorGenerator |
43 | */ |
44 | protected $contractorGenerator; |
45 | |
46 | /** |
47 | * @var MaturityGenerator |
48 | */ |
49 | protected $maturityGenerator; |
50 | |
51 | /** |
52 | * @var MesurementGenerator |
53 | */ |
54 | protected $mesurementGenerator; |
55 | |
56 | /** |
57 | * @var RequestGenerator |
58 | */ |
59 | protected $requestGenerator; |
60 | |
61 | /** |
62 | * @var ViolationGenerator |
63 | */ |
64 | protected $violationGenerator; |
65 | |
66 | /** |
67 | * @var ToolGenerator |
68 | */ |
69 | protected $toolGenerator; |
70 | |
71 | /** |
72 | * @var ConformiteTraitementGenerator |
73 | */ |
74 | protected $conformiteTraitementGenerator; |
75 | |
76 | /** |
77 | * @var ConformiteOrganisationGenerator |
78 | */ |
79 | protected $conformiteOrganisationGenerator; |
80 | |
81 | /** |
82 | * @var UserGenerator |
83 | */ |
84 | protected $userGenerator; |
85 | |
86 | /** |
87 | * @var ProofGenerator |
88 | */ |
89 | protected $proofGenerator; |
90 | |
91 | /** |
92 | * @var string |
93 | */ |
94 | protected $logoDir; |
95 | |
96 | /** |
97 | * @var string |
98 | */ |
99 | protected $dpdLogo; |
100 | |
101 | public function __construct( |
102 | UserProvider $userProvider, |
103 | ParameterBagInterface $parameterBag, |
104 | TreatmentGenerator $treatmentGenerator, |
105 | ContractorGenerator $contractorGenerator, |
106 | MaturityGenerator $maturityGenerator, |
107 | MesurementGenerator $mesurementGenerator, |
108 | RequestGenerator $requestGenerator, |
109 | ViolationGenerator $violationGenerator, |
110 | ConformiteTraitementGenerator $conformiteTraitementGenerator, |
111 | ConformiteOrganisationGenerator $conformiteOrganisationGenerator, |
112 | UserGenerator $userGenerator, |
113 | ProofGenerator $proofGenerator, |
114 | ToolGenerator $toolGenerator, |
115 | string $logoDir, |
116 | string $dpdLogo, |
117 | ) { |
118 | parent::__construct($userProvider, $parameterBag); |
119 | $this->treatmentGenerator = $treatmentGenerator; |
120 | $this->contractorGenerator = $contractorGenerator; |
121 | $this->maturityGenerator = $maturityGenerator; |
122 | $this->mesurementGenerator = $mesurementGenerator; |
123 | $this->requestGenerator = $requestGenerator; |
124 | $this->violationGenerator = $violationGenerator; |
125 | $this->conformiteTraitementGenerator = $conformiteTraitementGenerator; |
126 | $this->conformiteOrganisationGenerator = $conformiteOrganisationGenerator; |
127 | $this->userGenerator = $userGenerator; |
128 | $this->proofGenerator = $proofGenerator; |
129 | $this->toolGenerator = $toolGenerator; |
130 | $this->logoDir = $logoDir; |
131 | $this->dpdLogo = $dpdLogo; |
132 | } |
133 | |
134 | public function setCollectivity(Collectivity $collectivity) |
135 | { |
136 | parent::setCollectivity($collectivity); |
137 | $this->treatmentGenerator->setCollectivity($collectivity); |
138 | $this->contractorGenerator->setCollectivity($collectivity); |
139 | $this->maturityGenerator->setCollectivity($collectivity); |
140 | $this->mesurementGenerator->setCollectivity($collectivity); |
141 | $this->requestGenerator->setCollectivity($collectivity); |
142 | $this->violationGenerator->setCollectivity($collectivity); |
143 | $this->conformiteTraitementGenerator->setCollectivity($collectivity); |
144 | $this->conformiteOrganisationGenerator->setCollectivity($collectivity); |
145 | $this->userGenerator->setCollectivity($collectivity); |
146 | $this->proofGenerator->setCollectivity($collectivity); |
147 | } |
148 | |
149 | public function generateObjectPart(Section $section): void |
150 | { |
151 | if ($this->collectivity) { |
152 | $collectivity = $this->collectivity; |
153 | } else { |
154 | $collectivity = $this->userProvider->getAuthenticatedUser()->getCollectivity(); |
155 | } |
156 | |
157 | $section->addTitle('Objet', 1); |
158 | |
159 | $section->addText( |
160 | "Ce document constitue le bilan de gestion des données à caractère personnel de la structure {$collectivity->getName()}." |
161 | ); |
162 | } |
163 | |
164 | public function generateOrganismIntroductionPart(Section $section): void |
165 | { |
166 | if ($this->collectivity) { |
167 | $collectivity = $this->collectivity; |
168 | } else { |
169 | $collectivity = $this->userProvider->getAuthenticatedUser()->getCollectivity(); |
170 | } |
171 | |
172 | $section->addTitle('Présentation de la structure', 1); |
173 | |
174 | $section->addTitle('Identité de la structure', 2); |
175 | $section->addText( |
176 | \ucfirst($collectivity->getName()) . ' (' . \ucfirst($collectivity->getType()) . ')' . |
177 | (!empty($collectivity->getPopulation()) ? ', de ' . $collectivity->getPopulation() . ' habitants' : '') . |
178 | (!empty($collectivity->getNbrAgents()) ? ' comprenant ' . $collectivity->getNbrAgents() . ' salariés' : '') . |
179 | " a pour SIREN {$collectivity->getSiren()}" . |
180 | (!empty($collectivity->getFinessGeo()) ? ' (' . $collectivity->getFinessGeo() . ')' : '') . |
181 | " et est domicilié au {$collectivity->getAddress()->getLineOne()}" . |
182 | (!empty($collectivity->getAddress()->getLineTwo()) ? ', ' . $collectivity->getAddress()->getLineTwo() : '') . |
183 | ", {$collectivity->getAddress()->getZipCode()}, {$collectivity->getAddress()->getCity()}." |
184 | ); |
185 | |
186 | if (!empty($collectivity->getWebsite())) { |
187 | $section->addText("Pour consulter le site Internet : {$collectivity->getWebsite()}."); |
188 | } |
189 | |
190 | $section->addTitle('Engagement de la direction', 2); |
191 | |
192 | if (!empty($collectivity->getReportingBlockManagementCommitment())) { |
193 | \PhpOffice\PhpWord\Shared\Html::addHtml($section, $collectivity->getReportingBlockManagementCommitment(), false, false); |
194 | } else { |
195 | $section->addText("La direction de {$collectivity->getName()} a établi, documenté, mis en œuvre une politique de gestion des données à caractère personnel."); |
196 | $section->addText('Cette politique décrit les mesures techniques et organisationnelles.'); |
197 | $section->addText("Cette politique a pour objectif de permettre à {$collectivity->getName()} de respecter dans le temps les exigences du RGPD et de pouvoir le démontrer."); |
198 | } |
199 | |
200 | $section->addTitle('Composition du comité Informatique et Liberté', 2); |
201 | |
202 | $section->addText("Le comité informatique et liberté est chargé de suivre l'amélioration de la mise en conformité dans le temps. Il est composé de :"); |
203 | |
204 | $legalManager = $collectivity->getLegalManager(); |
205 | $legalManagerCivility = ContactCivilityDictionary::getCivilities()[$legalManager->getCivility()]; |
206 | $section->addListItem("{$legalManagerCivility} {$legalManager->getFullName()}, {$legalManager->getJob()}"); |
207 | |
208 | $referent = $collectivity->getReferent(); |
209 | $referentCivility = $referent->getCivility() ? ContactCivilityDictionary::getCivilities()[$referent->getCivility()] : null; |
210 | $section->addListItem("{$referentCivility} {$referent->getFullName()}, {$referent->getJob()}"); |
211 | |
212 | $itManager = $collectivity->getItManager(); |
213 | if ($collectivity->isDifferentItManager()) { |
214 | $itManagerCivility = ContactCivilityDictionary::getCivilities()[$itManager->getCivility()]; |
215 | $section->addListItem("{$itManagerCivility} {$itManager->getFullName()}, {$itManager->getJob()}"); |
216 | } |
217 | |
218 | $dpo = $collectivity->getDpo(); |
219 | if ($collectivity->isDifferentDpo()) { |
220 | $dpoCivility = ContactCivilityDictionary::getCivilities()[$dpo->getCivility()]; |
221 | $section->addListItem("{$dpoCivility} {$dpo->getFullName()}, {$dpo->getJob()}"); |
222 | } |
223 | |
224 | foreach ($collectivity->getComiteIlContacts() as $comiteIlContact) { |
225 | $contact = $comiteIlContact->getContact(); |
226 | $civility = ContactCivilityDictionary::getCivilities()[$contact->getCivility()]; |
227 | $section->addListItem("{$civility} {$contact->getFullName()}, {$contact->getJob()}"); |
228 | } |
229 | } |
230 | |
231 | public function generateRegistries( |
232 | Section $section, |
233 | array $treatments = [], |
234 | array $contractors = [], |
235 | array $requests = [], |
236 | array $violations = [], |
237 | array $tools = [], |
238 | ): void { |
239 | if ($this->collectivity) { |
240 | $collectivity = $this->collectivity; |
241 | } else { |
242 | $collectivity = $this->userProvider->getAuthenticatedUser()->getCollectivity(); |
243 | } |
244 | |
245 | $registries = [ |
246 | ReviewData::TREATMENT_REGISTRY, |
247 | ReviewData::CONTRACTOR_REGISTRY, |
248 | ReviewData::TOOL_REGISTRY, |
249 | ReviewData::REQUEST_REGISTRY, |
250 | ReviewData::VIOLATION_REGISTRY, |
251 | ]; |
252 | $registryCount = 0; |
253 | foreach ($registries as $registry) { |
254 | if ($collectivity && $collectivity->getReviewData() && in_array($registry, $collectivity->getReviewData()->getSections())) { |
255 | // cancel registry if it is tool registry but the module is not active |
256 | if (ReviewData::TOOL_REGISTRY === $registry && !$collectivity->isHasModuleTools()) { |
257 | --$registryCount; |
258 | } |
259 | ++$registryCount; |
260 | } |
261 | } |
262 | if ($registryCount) { |
263 | $section->addTitle('Bilan des registres', 1); |
264 | $section->addText("{$collectivity->getName()} recense {$registryCount} registres : "); |
265 | } |
266 | if (in_array(ReviewData::TREATMENT_REGISTRY, $collectivity->getReviewData()->getSections())) { |
267 | $section->addListItem('Traitements'); |
268 | } |
269 | if (in_array(ReviewData::CONTRACTOR_REGISTRY, $collectivity->getReviewData()->getSections())) { |
270 | $section->addListItem('Sous-traitants'); |
271 | } |
272 | if ($collectivity->isHasModuleTools() && in_array(ReviewData::TOOL_REGISTRY, $collectivity->getReviewData()->getSections())) { |
273 | $section->addListItem('Logiciels et supports'); |
274 | } |
275 | if (in_array(ReviewData::REQUEST_REGISTRY, $collectivity->getReviewData()->getSections())) { |
276 | $section->addListItem('Demandes des personnes concernées'); |
277 | } |
278 | if (in_array(ReviewData::VIOLATION_REGISTRY, $collectivity->getReviewData()->getSections())) { |
279 | $section->addListItem('Violations de données'); |
280 | } |
281 | |
282 | if (in_array(ReviewData::TREATMENT_REGISTRY, $collectivity->getReviewData()->getSections())) { |
283 | $this->treatmentGenerator->addGlobalOverview($section, $treatments); |
284 | } |
285 | if (in_array(ReviewData::CONTRACTOR_REGISTRY, $collectivity->getReviewData()->getSections())) { |
286 | $this->contractorGenerator->addGlobalOverview($section, $contractors); |
287 | } |
288 | if (in_array(ReviewData::TOOL_REGISTRY, $collectivity->getReviewData()->getSections()) && $collectivity->isHasModuleTools()) { |
289 | $this->toolGenerator->addSyntheticView($section, $tools, true, true, $collectivity); |
290 | } |
291 | if (in_array(ReviewData::REQUEST_REGISTRY, $collectivity->getReviewData()->getSections())) { |
292 | $this->requestGenerator->addGlobalOverview($section, $requests); |
293 | } |
294 | if (in_array(ReviewData::VIOLATION_REGISTRY, $collectivity->getReviewData()->getSections())) { |
295 | $this->violationGenerator->addGlobalOverview($section, $violations); |
296 | } |
297 | } |
298 | |
299 | public function generateManagementSystemAndCompliance( |
300 | Section $section, |
301 | array $maturity = [], |
302 | array $treatments = [], |
303 | array $mesurements = [], |
304 | ?Evaluation $evaluation = null, |
305 | ): void { |
306 | $maturity['bilanReport'] = true; |
307 | |
308 | if ($this->collectivity) { |
309 | $collectivity = $this->collectivity; |
310 | } else { |
311 | $collectivity = $this->userProvider->getAuthenticatedUser()->getCollectivity(); |
312 | } |
313 | |
314 | if ( |
315 | ($collectivity->getReviewData() && in_array(ReviewData::CONFORMITY_EVALUATION, $collectivity->getReviewData()->getSections())) |
316 | || ($collectivity->isHasModuleConformiteTraitement() && $collectivity->getReviewData() && in_array(ReviewData::TREATMENT_CONFORMITY, $collectivity->getReviewData()->getSections())) |
317 | || ($collectivity->isHasModuleConformiteOrganisation() && $collectivity->getReviewData() && in_array(ReviewData::COLLECTIVITY_CONFORMITY, $collectivity->getReviewData()->getSections())) |
318 | || ($collectivity->getReviewData() && in_array(ReviewData::PROTECT_ACTIONS, $collectivity->getReviewData()->getSections())) |
319 | || ($collectivity->isHasModuleConformiteTraitement() && $collectivity->getReviewData() && in_array(ReviewData::AIPD, $collectivity->getReviewData()->getSections())) |
320 | ) { |
321 | $section->addTitle('Système de management des données à caractère personnel et conformité', 1); |
322 | } |
323 | |
324 | if ($collectivity->getReviewData() && in_array(ReviewData::CONFORMITY_EVALUATION, $collectivity->getReviewData()->getSections())) { |
325 | $this->maturityGenerator->addContextView($section, $maturity); |
326 | $this->maturityGenerator->addSyntheticView($section, $maturity); |
327 | } |
328 | |
329 | if ($collectivity->isHasModuleConformiteTraitement() && $collectivity->getReviewData() && (in_array(ReviewData::AIPD, $collectivity->getReviewData()->getSections()) || in_array(ReviewData::TREATMENT_CONFORMITY, $collectivity->getReviewData()->getSections()))) { |
330 | $withAIPD = in_array(ReviewData::AIPD, $collectivity->getReviewData()->getSections()); |
331 | $withConform = in_array(ReviewData::TREATMENT_CONFORMITY, $collectivity->getReviewData()->getSections()); |
332 | $this->conformiteTraitementGenerator->addGlobalOverview($section, $treatments, $withAIPD, $withConform); |
333 | } |
334 | if ($collectivity->isHasModuleConformiteOrganisation() && $collectivity->getReviewData() && in_array(ReviewData::COLLECTIVITY_CONFORMITY, $collectivity->getReviewData()->getSections())) { |
335 | $this->conformiteOrganisationGenerator->addGlobalOverview($section, $evaluation); |
336 | } |
337 | if ($collectivity->getReviewData() && in_array(ReviewData::PROTECT_ACTIONS, $collectivity->getReviewData()->getSections())) { |
338 | $this->mesurementGenerator->addGlobalOverview($section, $mesurements); |
339 | } |
340 | } |
341 | |
342 | public function generateContinuousImprovements(Section $section): void |
343 | { |
344 | if ($this->collectivity) { |
345 | $collectivity = $this->collectivity; |
346 | } else { |
347 | $collectivity = $this->userProvider->getAuthenticatedUser()->getCollectivity(); |
348 | } |
349 | if ($collectivity->getReviewData() && in_array(ReviewData::CONTINUOUS_AMELIORATION, $collectivity->getReviewData()->getSections())) { |
350 | $section->addTitle("Principe d'amélioration continue", 1); |
351 | $section->addText('Le système de management des données à caractère personnel s’inscrit dans un principe d’amélioration continue. En conséquence :'); |
352 | if (!empty($collectivity->getReportingBlockManagementCommitment())) { |
353 | \PhpOffice\PhpWord\Shared\Html::addHtml($section, $collectivity->getReportingBlockContinuousImprovement(), false, false); |
354 | } else { |
355 | $section->addListItem('Le référent opérationnel continue de mettre à jour le registre avec les éventuels nouveaux traitements effectués.'); |
356 | $section->addListItem('Le référent opérationnel continue de mettre à jour le registre avec les éventuels nouveaux sous-traitants.'); |
357 | $section->addListItem('Le comité génère un bilan chaque année et met en place les mesures correctives adéquates.'); |
358 | } |
359 | $section->addText('Le responsable du traitement atteste avoir pris connaissance de l’ensemble des documents, approuve le bilan et s’engage à mettre en œuvre le plan d’action.'); |
360 | $section->addText('Signature du responsable du traitement'); |
361 | $section->addTextBreak(3); |
362 | $section->addPageBreak(); |
363 | } |
364 | } |
365 | |
366 | public function generateAnnexeMention($document, Section $section, array $treatments = [], array $violations = [], array $mesurements = []): void |
367 | { |
368 | if ( |
369 | $this->collectivity && $this->collectivity->getReviewData() && ( |
370 | in_array(ReviewData::TREATMENT_REGISTRY, $this->collectivity->getReviewData()->getSections()) |
371 | || in_array(ReviewData::VIOLATION_REGISTRY, $this->collectivity->getReviewData()->getSections()) |
372 | || (in_array(ReviewData::TREATMENT_CONFORMITY, $this->collectivity->getReviewData()->getSections()) && $this->collectivity->isHasModuleConformiteTraitement()) |
373 | || in_array(ReviewData::PROOF_LIST, $this->collectivity->getReviewData()->getSections()) |
374 | || in_array(ReviewData::PROTECT_ACTIONS, $this->collectivity->getReviewData()->getSections()) |
375 | || (in_array(ReviewData::AIPD, $this->collectivity->getReviewData()->getSections()) && $this->collectivity->isHasModuleConformiteTraitement()) |
376 | || in_array(ReviewData::USER_LIST, $this->collectivity->getReviewData()->getSections()) |
377 | ) |
378 | ) { |
379 | $section->addTitle('Annexes'); |
380 | } |
381 | if ($this->collectivity && $this->collectivity->getReviewData() && in_array(ReviewData::TREATMENT_REGISTRY, $this->collectivity->getReviewData()->getSections())) { |
382 | $AnnexeTreatmentListSection = $document->addSection(['orientation' => 'portrait']); |
383 | $this->treatmentGenerator->TreatmentAnnexeList($AnnexeTreatmentListSection, $treatments); |
384 | } |
385 | |
386 | if ($this->collectivity && $this->collectivity->getReviewData() && in_array(ReviewData::VIOLATION_REGISTRY, $this->collectivity->getReviewData()->getSections())) { |
387 | $RiskAnnexeSection = $document->addSection(['orientation' => 'landscape']); |
388 | $this->violationGenerator->AnnexeList($RiskAnnexeSection, $violations); |
389 | } |
390 | if ($this->collectivity && $this->collectivity->getReviewData() && in_array(ReviewData::PROOF_LIST, $this->collectivity->getReviewData()->getSections())) { |
391 | $ProofAnnexeSection = $document->addSection(['orientation' => 'portrait']); |
392 | $this->proofGenerator->ProofList($ProofAnnexeSection); |
393 | } |
394 | if ($this->collectivity && $this->collectivity->getReviewData() && in_array(ReviewData::PROTECT_ACTIONS, $this->collectivity->getReviewData()->getSections())) { |
395 | $protectionActionSection = $document->addSection(['orientation' => 'portrait']); |
396 | $this->mesurementGenerator->ProtectionActionAppliedAnnexeTable($protectionActionSection, $mesurements); |
397 | } |
398 | if ($this->collectivity && $this->collectivity->isHasModuleConformiteTraitement() && $this->collectivity->getReviewData() && in_array(ReviewData::TREATMENT_CONFORMITY, $this->collectivity->getReviewData()->getSections())) { |
399 | $RiskAnnexeSection = $document->addSection(['orientation' => 'landscape']); |
400 | $this->conformiteTraitementGenerator->SyntheticAnnexeList($RiskAnnexeSection, $treatments); |
401 | } |
402 | if ($this->collectivity && $this->collectivity->isHasModuleConformiteTraitement() && $this->collectivity->getReviewData() && in_array(ReviewData::AIPD, $this->collectivity->getReviewData()->getSections())) { |
403 | $riskAipdSectionBis = $document->addSection(['orientation' => 'landscape']); |
404 | $this->treatmentGenerator->RiskTreatmentAnnexeList($riskAipdSectionBis, $treatments); |
405 | } |
406 | if ($this->collectivity && $this->collectivity->getReviewData() && in_array(ReviewData::USER_LIST, $this->collectivity->getReviewData()->getSections())) { |
407 | $AnnexeUserListSection = $document->addSection(['orientation' => 'portrait']); |
408 | $this->userGenerator->UserList($AnnexeUserListSection); |
409 | } |
410 | } |
411 | } |