1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
public function action_etiquettes()
{
$query = Model_Adherent::query()->order_by(array('nom', 'prenom'));
$filter_form = Form_AdherentFilter::forge();
$filter_form->apply_query($query);
$adherents = $query->get();
$adhnb = count($adherents);
$adhimpr = 0;
/* @var $pdf FPDF */
$pdf = \Pdf\Pdf::forge('fpdf')->init();
$pdf->SetFont('Arial', '', 10);
$pdf->SetMargins(0, 0, 0);
$pdf->SetAutoPageBreak(false);
$pdf->AddPage();
$x = 5;
$y = 5;
foreach ($adherents as $adherent) {
$adhimpr++;
$pdf->setXY($x, $y);
$label = utf8_decode(trim($adherent->nom) . ' ' . trim($adherent->prenom)) . "\n";
$label .= utf8_decode($adherent->adresse) . "\n";
if ($adherent->ville) {
$label .= utf8_decode($adherent->ville->cp . " " . $adherent->ville->ville) . "\n";
}
$pdf->MultiCell(70, 6, $label, 0, 'L');
$pdf->Ln();
$pdf->SetX($x);
$x += 70;
if ($x >= 210) {
$x = 5;
$y += 42;
if ($y >= 294 && $adhnb > $adhimpr) {
$y = 5;
$pdf->AddPage();
}
}
}
$pdf->Output();
exit;
} |
Partager