]>
git.agnieray.net Git - galette.git/blob - galette/lib/Galette/IO/PdfGroups.php
195e2b2825af9cefc72aebd53917a4849b505baf
4 * Copyright © 2003-2024 The Galette Team
6 * This file is part of Galette (https://galette.eu).
8 * Galette is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU 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.
13 * Galette 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 General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
24 use Galette\Core\Preferences
;
25 use Galette\Core\PrintLogo
;
27 use Galette\Core\Login
;
28 use Galette\Entity\Group
;
33 * @author Johan Cwiklinski <johan@x-tnd.be>
36 class PdfGroups
extends Pdf
38 public const SHEET_FONT
= self
::FONT_SIZE
- 2;
40 private string $doc_title;
43 * Main constructor, set creator and author
45 * @param Preferences $prefs Preferences
47 public function __construct(Preferences
$prefs)
49 parent
::__construct($prefs);
50 $this->filename
= __('groups_list') . '.pdf';
55 * Draws PDF page Header
59 public function Header(): void
// phpcs:ignore PSR1.Methods.CamelCapsMethodName
64 _T("Members by groups"),
82 private function init(): void
84 // Set document information
85 $this->doc_title
= _T("Members by groups");
86 $this->SetTitle($this->doc_title
);
87 $this->SetSubject(_T("Generated by Galette"));
89 // Enable Auto Page breaks
90 $this->SetAutoPageBreak(true, 20);
93 $this->SetTextColor(0, 0, 0);
96 $this->setMargins(10, 20);
97 $this->setHeaderMargin(10);
100 $this->SetFont(self
::FONT
, '', self
::SHEET_FONT
);
103 $this->showPagination();
109 * @param array<Group> $groups Groups list
110 * @param Login $login Login instance
114 public function draw(array $groups, Login
$login): void
118 $this->PageHeader($this->doc_title
);
121 foreach ($groups as $group) {
122 $id = $group->getId();
123 if (!$login->isGroupManager($id)) {
125 'Trying to export group ' . $id . ' as PDF without appropriate permissions',
131 if ($first === false) {
134 $this->SetFont('', 'B', self
::SHEET_FONT +
1);
135 $this->Cell(190, 4, $group->getName(), 0, 1, 'C');
136 $this->SetFont('', '', self
::SHEET_FONT
);
138 $managers_list = $group->getManagers();
140 foreach ($managers_list as $m) {
141 $managers[] = $m->sfullname
;
143 if (count($managers) > 0) {
147 _T("Managers:") . ' ' . implode(', ', $managers),
150 ($this->i18n
->isRTL() ?
'L' : 'R')
155 $this->SetFont('', 'B');
156 $this->SetFillColor(255, 255, 255);
157 $this->Cell(80, 7, _T("Name"), 1, 0, 'C', true);
158 $this->Cell(50, 7, _T("Email"), 1, 0, 'C', true);
159 $this->Cell(30, 7, _T("Phone"), 1, 0, 'C', true);
160 $this->Cell(30, 7, _T("GSM"), 1, 1, 'C', true);
162 $this->SetFont('', 'B');
164 $members = $group->getMembers();
166 foreach ($members as $m) {
167 $align = ($this->i18n
->isRTL() ?
'R' : 'L');
168 $this->Cell(80, 7, $m->sname
, 1, 0, $align);
169 $this->Cell(50, 7, $m->email
, 1, 0, $align);
170 $this->Cell(30, 7, $m->phone
, 1, 0, $align);
171 $this->Cell(30, 7, $m->gsm
, 1, 1, $align);
173 $this->Cell(190, 0, '', 'T');