Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
3.01% |
5 / 166 |
|
33.33% |
1 / 3 |
CRAP | |
0.00% |
0 / 1 |
ToolGenerator | |
3.01% |
5 / 166 |
|
33.33% |
1 / 3 |
743.27 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
addSyntheticView | |
0.00% |
0 / 32 |
|
0.00% |
0 / 1 |
132 | |||
addDetailedView | |
0.00% |
0 / 129 |
|
0.00% |
0 / 1 |
272 |
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\Dictionary\ToolTypeDictionary; |
28 | use App\Domain\Registry\Model\Tool; |
29 | use PhpOffice\PhpWord\Element\Section; |
30 | use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; |
31 | use Symfony\Contracts\Translation\TranslatorInterface; |
32 | |
33 | class ToolGenerator extends AbstractGenerator implements ImpressionGeneratorInterface |
34 | { |
35 | protected TranslatorInterface $translator; |
36 | |
37 | public function __construct( |
38 | UserProvider $userProvider, |
39 | ParameterBagInterface $parameterBag, |
40 | TranslatorInterface $translator, |
41 | ) { |
42 | parent::__construct( |
43 | $userProvider, |
44 | $parameterBag |
45 | ); |
46 | |
47 | $this->translator = $translator; |
48 | } |
49 | |
50 | public function addSyntheticView(Section $section, array $data, bool $forOverviewReport = false, bool $bilan = false, $collectivity = null): void |
51 | { |
52 | // Break page for overview report |
53 | if ($forOverviewReport && !$bilan) { |
54 | $section->addPageBreak(); |
55 | } |
56 | |
57 | $section->addTitle('Registre des logiciels et supports', $forOverviewReport ? 2 : 1); |
58 | |
59 | if (empty($data)) { |
60 | $section->addText('Un registre des logiciels et des supports est tenu à jour par la structure ' . $collectivity->getName() . '. À ce jour, il n’y a pas eu de logiciel ou support renseigné.'); |
61 | } else { |
62 | $section->addText('Un recensement des logiciels et des supports de ' . $collectivity->getName() . ' a été effectué.'); |
63 | $l = 0; |
64 | $s = 0; |
65 | foreach ($data as $tool) { |
66 | /* @var Tool $tool */ |
67 | if (ToolTypeDictionary::SOFTWARE === $tool->getType()) { |
68 | ++$l; |
69 | } |
70 | if (ToolTypeDictionary::SUPPORT === $tool->getType()) { |
71 | ++$s; |
72 | } |
73 | } |
74 | $section->addText('Il y a ' . $l . ' logiciel(s) identifié(s) et ' . $s . ' support(s) identifié(s).'); |
75 | |
76 | // Table data |
77 | // Add header |
78 | $tableData = [ |
79 | [ |
80 | 'Nom', |
81 | 'Type', |
82 | 'Éditeur', |
83 | 'Sous-traitants', |
84 | ], |
85 | ]; |
86 | // Add content |
87 | foreach ($data as $tool) { |
88 | /* @var Tool $tool */ |
89 | $tableData[] = [ |
90 | $tool->getName(), |
91 | ToolTypeDictionary::getTypes()[$tool->getType()], |
92 | $tool->getEditor(), |
93 | Tool::generateLinkedDataColumn($tool->getContractors()), |
94 | ]; |
95 | } |
96 | |
97 | $this->addTable($section, $tableData, true, self::TABLE_ORIENTATION_HORIZONTAL); |
98 | |
99 | // Don't break page if it's overview report |
100 | if (!$forOverviewReport && !$bilan) { |
101 | $section->addPageBreak(); |
102 | } |
103 | } |
104 | } |
105 | |
106 | public function addDetailedView(Section $section, array $data): void |
107 | { |
108 | $section->addTitle('Détail des logiciels et supports', 1); |
109 | |
110 | foreach ($data as $key => $tool) { |
111 | /* @var Tool $tool */ |
112 | if (0 !== $key) { |
113 | $section->addPageBreak(); |
114 | } |
115 | $section->addTitle($tool->getName(), 2); |
116 | |
117 | $generalInformationsData = [ |
118 | [ |
119 | 'Nom', |
120 | $tool->getName(), |
121 | ], |
122 | ]; |
123 | |
124 | // Ajouter les services si le module est actif |
125 | if ($tool->getCollectivity()->getIsServicesEnabled()) { |
126 | $generalInformationsData[] = [ |
127 | 'Service', |
128 | $tool->getService(), |
129 | ]; |
130 | } |
131 | |
132 | $generalInformationsData = array_merge($generalInformationsData, [ |
133 | [ |
134 | 'Type', |
135 | ToolTypeDictionary::getTypes()[$tool->getType()], |
136 | ], |
137 | [ |
138 | 'Description', |
139 | $tool->getDescription(), |
140 | ], |
141 | [ |
142 | 'Éditeur', |
143 | $tool->getEditor(), |
144 | ], |
145 | [ |
146 | 'Sous-traitants', |
147 | Tool::generateLinkedDataColumn($tool->getContractors()), |
148 | ], |
149 | [ |
150 | 'Date de mise en production', |
151 | $tool->getProdDate() ? $tool->getProdDate()->format('d/m/Y') : '', |
152 | ], |
153 | [ |
154 | 'Pays d\'hébergement ou de stockage', |
155 | $this->translator->trans($tool->getCountryType()), |
156 | ], |
157 | ]); |
158 | |
159 | if (Tool::COUNTRY_FRANCE !== $tool->getCountryType()) { |
160 | $generalInformationsData[] = [ |
161 | 'Nom du pays', |
162 | $tool->getCountryName(), |
163 | ]; |
164 | } |
165 | |
166 | if (Tool::COUNTRY_OTHER === $tool->getCountryType()) { |
167 | $generalInformationsData[] = [ |
168 | 'Garanties pour le transfert', |
169 | $tool->getCountryGuarantees(), |
170 | ]; |
171 | } |
172 | |
173 | $generalInformationsData[] = [ |
174 | 'Personne en charge', |
175 | $tool->getManager(), |
176 | ]; |
177 | |
178 | $generalInformationsData[] = [ |
179 | 'Autres informations', |
180 | $tool->getOtherInfo(), |
181 | ]; |
182 | |
183 | $securityData = [ |
184 | [ |
185 | 'Archivage', |
186 | $tool->getArchival()->isCheck() ? 'Oui' : 'Non', |
187 | $tool->getArchival()->getComment(), |
188 | ], |
189 | [ |
190 | 'Chiffrement', |
191 | $tool->getEncrypted()->isCheck() ? 'Oui' : 'Non', |
192 | $tool->getEncrypted()->getComment(), |
193 | ], |
194 | [ |
195 | 'Contrôle d\'accès', |
196 | $tool->getAccessControl()->isCheck() ? 'Oui' : 'Non', |
197 | $tool->getAccessControl()->getComment(), |
198 | ], |
199 | [ |
200 | 'Mise à jour', |
201 | $tool->getUpdate()->isCheck() ? 'Oui' : 'Non', |
202 | $tool->getUpdate()->getComment(), |
203 | ], |
204 | [ |
205 | 'Sauvegarde', |
206 | $tool->getBackup()->isCheck() ? 'Oui' : 'Non', |
207 | $tool->getBackup()->getComment(), |
208 | ], |
209 | [ |
210 | 'Suppression', |
211 | $tool->getDeletion()->isCheck() ? 'Oui' : 'Non', |
212 | $tool->getDeletion()->getComment(), |
213 | ], |
214 | [ |
215 | 'Traçabilité', |
216 | $tool->getTracking()->isCheck() ? 'Oui' : 'Non', |
217 | $tool->getTracking()->getComment(), |
218 | ], |
219 | [ |
220 | 'Zone de commentaire libre', |
221 | $tool->getHasComment()->isCheck() ? 'Oui' : 'Non', |
222 | $tool->getHasComment()->getComment(), |
223 | ], |
224 | [ |
225 | 'Autres', |
226 | $tool->getOther()->isCheck() ? 'Oui' : 'Non', |
227 | $tool->getOther()->getComment(), |
228 | ], |
229 | ]; |
230 | |
231 | $historyData = [ |
232 | [ |
233 | 'Date de création', |
234 | $this->getDate($tool->getCreatedAt()), |
235 | ], |
236 | [ |
237 | 'Dernière de modification', |
238 | $this->getDate($tool->getUpdatedAt()), |
239 | ], |
240 | [ |
241 | 'Modifié par', |
242 | $tool->getUpdatedBy(), |
243 | ], |
244 | ]; |
245 | |
246 | $section->addTitle('Informations générales', 3); |
247 | $this->addTable($section, $generalInformationsData, false, self::TABLE_ORIENTATION_VERTICAL); |
248 | |
249 | $section->addTitle('Mesures de sécurité et confidentialité', 3); |
250 | $this->addTable($section, $securityData, false, self::TABLE_ORIENTATION_VERTICAL); |
251 | |
252 | $section->addTitle('Éléments associés', 3); |
253 | $this->addLinkedData($section, $tool); |
254 | |
255 | $section->addTitle('Historique', 3); |
256 | $this->addTable($section, $historyData, false, self::TABLE_ORIENTATION_VERTICAL); |
257 | } |
258 | } |
259 | } |