]>
git.agnieray.net Git - galette.git/blob - galette/lib/Galette/IO/PdfMembersLabels.php
31a179ef9a7467ddcb9a6101833757a85e24a005
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
10 * Copyright © 2014 The Galette Team
12 * This file is part of Galette (http://galette.tuxfamily.org).
14 * Galette is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
19 * Galette is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
30 * @author Johan Cwiklinski <johan@x-tnd.be>
31 * @copyright 2014 The Galette Team
32 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
34 * @link http://galette.tuxfamily.org
35 * @since Available since 0.8.2dev - 2014-12-01
40 use Galette\Core\Preferences
;
49 * @abstract Class for expanding TCPDF.
50 * @author Johan Cwiklinski <johan@x-tnd.be>
51 * @copyright 2014 The Galette Team
52 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
53 * @link http://galette.tuxfamily.org
54 * @since Available since 0.8.2dev - 2014-12-01
57 class PdfMembersLabels
extends Pdf
66 * Main constructor, set creator and author
68 * @param Preferences $prefs Preferences
70 public function __construct(Preferences
$prefs)
72 parent
::__construct($prefs);
74 $this->filename
= __('labels_print_filename') . '.pdf';
83 private function init()
85 // Set document information
86 $this->SetTitle(_T("Member's Labels"));
87 $this->SetSubject(_T("Generated by Galette"));
88 $this->SetKeywords(_T("Labels"));
90 // No hearders and footers
91 $this->SetPrintHeader(false);
92 $this->SetPrintFooter(false);
93 $this->setFooterMargin(0);
94 $this->setHeaderMargin(0);
97 $this->SetDisplayMode('fullpage');
99 // Disable Auto Page breaks
100 $this->SetAutoPageBreak(false, 0);
103 $this->SetDrawColor(160, 160, 160);
104 $this->SetTextColor(0);
108 $this->preferences
->pref_etiq_marges_h
,
109 $this->preferences
->pref_etiq_marges_v
113 //$this->SetFont(self::FONT);
117 $this->xorigin
= $this->preferences
->pref_etiq_marges_h
;
118 $this->yorigin
= $this->preferences
->pref_etiq_marges_v
;
121 $this->lw
= round($this->preferences
->pref_etiq_hsize
);
123 $this->lh
= round($this->preferences
->pref_etiq_vsize
);
125 $this->line_h
=round($this->lh
/5);
131 * @param array $members Members
135 public function drawLabels($members)
138 foreach ($members as $member) {
139 // Detect page breaks
140 $colsrows = $this->preferences
->pref_etiq_cols
141 * $this->preferences
->pref_etiq_rows
;
142 if ($nb_etiq %
$colsrows == 0) {
146 $this->SetFont(self
::FONT
, 'B', $this->preferences
->pref_etiq_corps
);
148 // Compute label position
149 $col = $nb_etiq %
$this->preferences
->pref_etiq_cols
;
150 $row = ($nb_etiq / $this->preferences
->pref_etiq_cols
)
151 %
$this->preferences
->pref_etiq_rows
;
153 $x = $this->xorigin +
$col*(
154 round($this->preferences
->pref_etiq_hsize
) +
155 round($this->preferences
->pref_etiq_hspace
)
157 $y = $this->yorigin +
$row*(
158 round($this->preferences
->pref_etiq_vsize
) +
159 round($this->preferences
->pref_etiq_vspace
)
161 // Draw a frame around the label
162 $this->Rect($x, $y, $this->lw
, $this->lh
);
164 $this->SetXY($x, $y);
165 $this->Cell($this->lw
, $this->line_h
, $member->sfullname
, 0, 0, 'L', 0);
166 // Print first line of address
167 $this->SetFont(self
::FONT
, '', $this->preferences
->pref_etiq_corps
);
168 $this->SetXY($x, $y +
$this->line_h
);
170 //calculte font size to display address and address continuation
171 $max_text_size = $this->preferences
->pref_etiq_hsize
;
172 $text = mb_strlen($member->address
) > mb_strlen($member->address_continuation
) ?
174 $member->address_continuation
;
178 $this->preferences
->pref_etiq_corps
181 $this->Cell($this->lw
, $this->line_h
, $member->address
, 0, 0, 'L', 0);
182 // Print second line of address
183 $this->SetXY($x, $y +
$this->line_h
*2);
187 $member->address_continuation
,
193 // Print zip code and town
194 $this->SetFont(self
::FONT
, 'B', $this->preferences
->pref_etiq_corps
);
195 $text = $member->zipcode
. ' - ' . $member->town
;
199 $this->preferences
->pref_etiq_corps
,
203 $this->SetXY($x, $y +
$this->line_h
*3);
214 $this->SetFont(self
::FONT
, 'I', $this->preferences
->pref_etiq_corps
);
215 $this->SetXY($x, $y +
$this->line_h
*4);
216 $this->Cell($this->lw
, $this->line_h
, $member->country
, 0, 0, 'R', 0);