noalyss Version-9
card_pdf.class.php
Go to the documentation of this file.
1<?php
2/**
3 * @file
4 * @brief
5 *
6 */
7/**
8 * @class
9 * @brief Class Card_PDF
10 */
11class Card_PDF extends \PDF
12{
13 private $card;
14 function __construct($p_card_id)
15 {
16 global $cn;
17 $this->card=new \Fiche ($cn,$p_card_id);
18 $this->card->load();
19 parent::__construct($cn, "P");
20 $this->setDossierInfo($this->card->strAttribut(ATTR_DEF_QUICKCODE));
21 }
22
23 /**
24 * @return mixed
25 */
26 public function getCardId()
27 {
28 return $this->card->get_id();
29 }
30
31 /**
32 * @param mixed $card_id
33 */
34 public function setCardId($card_id)
35 {
36 $this->card->set_id($card_id);
37 $this->card->load();
38 }
39
40 public function export()
41 {
42 $nb_attribut = count($this->card->attribut);
43// var_dump(
44// $this->card->attribut
45// );
46 if ($nb_attribut == 0) {
47 throw new \Exception(_("card_pdf.044 , card_inexistante"));
48 }
49 $this->setTitle($this->card->get_quick_code()." ".strtoupper($this->card->strAttribut(1))
50 ." ".$this->card->strAttribut(32,0), true);
51 $this->SetAuthor('NOALYSS');
52 $this->AliasNbPages();
53 $this->AddPage();
54
55 $this->setFont("DejaVu", '', 7);
56 $this->SetDrawColor(214, 209, 209);
57 for ($i=0;$i<$nb_attribut;$i++)
58 {
59 $border="B";
60 $this->write_cell(60,5,$this->card->attribut[$i]->ad_text,$border);
61 $this->write_cell(100,5,$this->card->attribut[$i]->av_text,$border);
62 $this->line_new(5);
63 }
64
65
66 $filename=$this->card->strAttribut(1)."-".$this->card->strAttribut(23).".pdf";
67 $filename=sanitize_filename($filename);
68 $this->Output($filename,"D");
69 }
70
71}
sanitize_filename($filename)
removed invalid character when computing a filename, the suffix is kept
Definition: ac_common.php:1784
__construct($p_card_id)
setCardId($card_id)
line_new($p_step=null)
Print all the cell stored and call Ln (new line)
write_cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
API for creating PDF, unicode, based on tfpdf.
Definition: pdf.class.php:34
setDossierInfo($dossier="n/a")
Definition: pdf.class.php:52
const ATTR_DEF_QUICKCODE
Definition: constant.php:237
$card_id