$doc_title = $post['sheet_type'];
}
- $pdf = new Galette\IO\PdfAttendanceSheet($this->preferences);
- $pdf->doc_title = $doc_title;
- // Set document information
- $pdf->SetTitle($doc_title);
-
- if (isset($post['sheet_title']) && trim($post['sheet_title']) != '') {
- $pdf->sheet_title = $post['sheet_title'];
- }
- if (isset($post['sheet_sub_title']) && trim($post['sheet_sub_title']) != '') {
- $pdf->sheet_sub_title = $post['sheet_sub_title'];
- }
- if (isset($post['sheet_date']) && trim($post['sheet_date']) != '') {
- $dformat = __("Y-m-d");
- $date = DateTime::createFromFormat(
- $dformat,
- $post['sheet_date']
- );
- $pdf->sheet_date = $date;
- }
+ $data = [
+ 'doc_title' => $doc_title,
+ 'title' => $post['sheet_title'] ?? null,
+ 'subtitle' => $post['sheet_sub_title'] ?? null,
+ 'sheet_date'=> $post['sheet_date'] ?? null
+ ];
+ $pdf = new Galette\IO\PdfAttendanceSheet($this->zdb, $this->preferences, $data);
//with or without images?
if (isset($post['sheet_photos']) && $post['sheet_photos'] === '1') {
$pdf->withImages();
$hfooter .= $this->model->hfooter;
$this->writeHtml($hfooter);
} else {
- $this->SetFont(self::FONT, '', self::FONT_SIZE);
+ $this->SetFont(self::FONT, '', self::FONT_SIZE - 2);
$this->SetTextColor(0, 0, 0);
$name = preg_replace(
_T("Association %s")
);
- /** FIXME: get configured postal address */
- $coordonnees_line1 = $name . ' - ' . $this->preferences->pref_adresse;
- /** FIXME: pref_adresse2 should be removed */
- if (trim($this->preferences->pref_adresse2) != '') {
- $coordonnees_line1 .= ', ' . $this->preferences->pref_adresse2;
- }
- $coordonnees_line2 = $this->preferences->pref_cp . ' ' .
- $this->preferences->pref_ville;
+ $address = $this->preferences->getPostalAddress();
- $this->Cell(
+ $this->MultiCell(
0,
4,
- $coordonnees_line1,
+ $address,
0,
- 1,
'C',
- 0,
- $this->preferences->pref_website
- );
- $this->Cell(
- 0,
- 4,
- $coordonnees_line2,
- 0,
- 0,
- 'C',
- 0,
- $this->preferences->pref_website
);
if ($this->paginated) {
$this->Ln(2);
$ystart = $this->GetY();
- $this->Cell(
- 0,
+ $this->MultiCell(
+ 180 - $wlogo,
6,
$this->preferences->pref_nom,
0,
- 1,
- 'L',
- 0,
- $this->preferences->pref_website
+ 'L'
);
$this->SetFont(self::FONT, 'B', self::FONT_SIZE + 2);
namespace Galette\IO;
+use Galette\Core\Db;
use Galette\Core\Preferences;
use Galette\Core\PrintLogo;
+use Galette\Entity\PdfModel;
use Analog\Analog;
/**
*/
public function Header() // phpcs:ignore PSR1.Methods.CamelCapsMethodName
{
- $this->SetFont(Pdf::FONT, '', self::SHEET_FONT);
- $head_title = $this->doc_title;
- if ($this->sheet_title !== null) {
- $head_title .= ' - ' . $this->sheet_title;
- }
- if ($this->sheet_sub_title !== null) {
- $head_title .= ' - ' . $this->sheet_sub_title;
- }
- if ($this->sheet_date !== null) {
- $head_title .= ' - ' . $this->sheet_date->format(__("Y-m-d"));
+ if ($this->PageNo() > 1) {
+ $this->SetFont(Pdf::FONT, '', self::SHEET_FONT);
+ $head_title = $this->doc_title;
+ if ($this->sheet_title !== null) {
+ $head_title .= ' - ' . $this->sheet_title;
+ }
+ if ($this->sheet_sub_title !== null) {
+ $head_title .= ' - ' . $this->sheet_sub_title;
+ }
+ if ($this->sheet_date !== null) {
+ $head_title .= ' - ' . $this->sheet_date->format(__("Y-m-d"));
+ }
+ $this->Cell(0, 10, $head_title, 1, false, 'C', 0, '', 0, false, 'M', 'M');
}
- $this->Cell(0, 10, $head_title, 0, false, 'C', 0, '', 0, false, 'M', 'M');
}
/**
* Main constructor, set creator and author
*
+ * @param Db $zdb Database instance
* @param Preferences $prefs Preferences
+ * @param array $data Data to set
*/
- public function __construct(Preferences $prefs)
+ public function __construct(Db $zdb, Preferences $prefs, $data = [])
{
- parent::__construct($prefs);
+ $class = PdfModel::getTypeClass(__CLASS__);
+ $model = new $class($zdb, $prefs, PdfModel::MAIN_MODEL);
+
+ // Set document and model information
+ $this->doc_title = $data['doc_title'];
+ $this->SetTitle($data['doc_title']);
+
+ if (isset($data['title']) && trim($data['title']) != '') {
+ $this->sheet_title = $data['title'];
+ $model->title = $this->sheet_title;
+ }
+ if (isset($data['subtitle']) && trim($data['subtitle']) != '') {
+ $this->sheet_sub_title = $data['subtitle'];
+ $model->subtitle = $this->sheet_sub_title;
+ }
+ if (isset($data['sheet_date']) && trim($data['sheet_date']) != '') {
+ $dformat = __("Y-m-d");
+ $date = \DateTime::createFromFormat(
+ $dformat,
+ $data['sheet_date']
+ );
+ $this->sheet_date = $date;
+ }
+
+ parent::__construct($prefs, $model);
$this->init();
}
/**
$this->AddPage();
$this->PageHeader($doc_title);
- if ($this->sheet_title !== null) {
- $this->Cell(190, 7, $this->sheet_title, 0, 1, 'C');
- }
- if ($this->sheet_sub_title) {
- $this->Cell(190, 7, $this->sheet_sub_title, 0, 1, 'C');
- }
if ($this->sheet_date) {
$date_fmt = null;
if (PHP_OS === 'Linux') {