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/>.
25 use Galette\Core\Preferences
;
26 use Galette\Entity\Adherent
;
27 use Galette\Entity\PdfModel
;
28 use Galette\Entity\PdfAdhesionFormModel
;
35 * @author Guillaume Rousse <guillomovitch@gmail.com>
36 * @author Johan Cwiklinski <johan@x-tnd.be>
39 class PdfAdhesionForm
extends Pdf
42 protected Adherent
$adh;
43 protected Preferences
$prefs;
44 protected string $filename;
50 * @param Adherent $adh Adherent
51 * @param Db $zdb Database instance
52 * @param Preferences $prefs Preferences instance
54 public function __construct(Adherent
$adh, Db
$zdb, Preferences
$prefs)
58 $this->prefs
= $prefs;
60 $model = $this->getModel();
61 parent
::__construct($prefs, $model);
63 $this->filename
= $adh->id ?
64 __("adherent_form") . '.' . $adh->id
. '.pdf' : __("adherent_form") . '.pdf';
69 if ($model !== null) {
80 protected function getModel(): ?PdfModel
82 $model = new PdfAdhesionFormModel($this->zdb
, $this->prefs
);
83 $model->setMember($this->adh
);
91 * @param string $path Path
95 public function store(string $path): bool
97 if (file_exists($path) && is_dir($path) && is_writeable($path)) {
98 $this->path
= $path . '/' . $this->filename
;
99 $this->Output($this->path
, 'F');
103 __METHOD__
. ' ' . $path .
104 ' does not exists or is not a directory or is not writeable.',
116 public function getPath(): string
118 return realpath($this->path
);