Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
20.69% |
6 / 29 |
|
25.00% |
1 / 4 |
CRAP | |
0.00% |
0 / 1 |
ProofGenerator | |
20.69% |
6 / 29 |
|
25.00% |
1 / 4 |
23.96 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
addSyntheticView | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
addDetailedView | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
Prooflist | |
0.00% |
0 / 21 |
|
0.00% |
0 / 1 |
12 |
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\ProofTypeDictionary; |
28 | use App\Domain\Registry\Model\Proof; |
29 | use Doctrine\ORM\EntityManagerInterface; |
30 | use PhpOffice\PhpWord\Element\Section; |
31 | use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; |
32 | use Symfony\Contracts\Translation\TranslatorInterface; |
33 | |
34 | class ProofGenerator extends AbstractGenerator implements ImpressionGeneratorInterface |
35 | { |
36 | protected TranslatorInterface $translator; |
37 | private $entityManager; |
38 | |
39 | public function __construct( |
40 | EntityManagerInterface $entityManager, |
41 | UserProvider $userProvider, |
42 | ParameterBagInterface $parameterBag, |
43 | TranslatorInterface $translator, |
44 | ) { |
45 | parent::__construct( |
46 | $userProvider, |
47 | $parameterBag, |
48 | ); |
49 | |
50 | $this->translator = $translator; |
51 | $this->entityManager = $entityManager; |
52 | } |
53 | |
54 | public function addSyntheticView(Section $section, array $data, bool $forOverviewReport = false): void |
55 | { |
56 | } |
57 | |
58 | public function addDetailedView(Section $section, array $data): void |
59 | { |
60 | } |
61 | |
62 | public function Prooflist(Section $section) |
63 | { |
64 | if ($this->collectivity) { |
65 | $collectivity = $this->collectivity; |
66 | } else { |
67 | $collectivity = $this->userProvider->getAuthenticatedUser()->getCollectivity(); |
68 | } |
69 | |
70 | $proofs = $this->entityManager->getRepository(Proof::class)->findBy(['collectivity' => $collectivity]); |
71 | |
72 | $section->addTitle('Liste des preuves', 2); |
73 | $proofAnnexListTable = $section->addTable($this->tableStyle); |
74 | $proofAnnexListTable->addRow(null, ['tblHeader' => true, 'cantsplit' => true]); |
75 | $cell = $proofAnnexListTable->addCell(2500, $this->cellHeadStyle); |
76 | $cell->addText('Nom', $this->textHeadStyle); |
77 | $cell = $proofAnnexListTable->addCell(2500, $this->cellHeadStyle); |
78 | $cell->addText('Type', $this->textHeadStyle); |
79 | $cell = $proofAnnexListTable->addCell(2500, $this->cellHeadStyle); |
80 | $cell->addText('Date de dépôt', $this->textHeadStyle); |
81 | |
82 | foreach ($proofs as $item) { |
83 | $proofAnnexListTable->addRow(null, ['cantsplit' => true]); |
84 | $cell = $proofAnnexListTable->addCell(2500); |
85 | $cell->addText($item->getName()); |
86 | $cell = $proofAnnexListTable->addCell(2500); |
87 | $cell->addText(ProofTypeDictionary::getTypes()[$item->getType()]); |
88 | $cell = $proofAnnexListTable->addCell(2500); |
89 | $cell->addText($item->getCreatedAt()->format('d/m/Y')); |
90 | } |
91 | } |
92 | } |