1 | <?php
|
---|
2 | /*******************************************************************************
|
---|
3 | * FPDF *
|
---|
4 | * *
|
---|
5 | * Version: 1.6 *
|
---|
6 | * Date: 2008-08-03 *
|
---|
7 | * Author: Olivier PLATHEY *
|
---|
8 | *******************************************************************************/
|
---|
9 |
|
---|
10 | require('class.fpdf.inc.php');
|
---|
11 |
|
---|
12 | class uireports_fpdf extends FPDF
|
---|
13 | {
|
---|
14 | var $a = "1";
|
---|
15 | var $b = "1";
|
---|
16 |
|
---|
17 | var $widths;
|
---|
18 | var $aligns;
|
---|
19 |
|
---|
20 | function __construct($orientation = "P") {
|
---|
21 | parent::__construct($orientation);
|
---|
22 | }
|
---|
23 |
|
---|
24 | function SetWidths($w)
|
---|
25 | {
|
---|
26 | //Set the array of column widths
|
---|
27 | $this->widths=$w;
|
---|
28 | }
|
---|
29 |
|
---|
30 | function SetAligns($a)
|
---|
31 | {
|
---|
32 | //Set the array of column alignments
|
---|
33 | $this->aligns=$a;
|
---|
34 | }
|
---|
35 |
|
---|
36 | function Row($data)
|
---|
37 | {
|
---|
38 | //Calculate the height of the row
|
---|
39 | $nb=0;
|
---|
40 | for($i=0;$i< count($data);$i++)
|
---|
41 | $nb=max($nb,$this->NbLines($this->widths[$i],$data[$i]));
|
---|
42 | $h=5*$nb;
|
---|
43 | //Issue a page break first if needed
|
---|
44 | $this->CheckPageBreak($h);
|
---|
45 | //Draw the cells of the row
|
---|
46 | for($i=0;$i< count($data);$i++)
|
---|
47 | {
|
---|
48 | $w=$this->widths[$i];
|
---|
49 | $a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
|
---|
50 | //Save the current position
|
---|
51 | $x=$this->GetX();
|
---|
52 | $y=$this->GetY();
|
---|
53 | //Draw the border
|
---|
54 | $this->Rect($x,$y,$w,$h);
|
---|
55 | //Print the text
|
---|
56 | $this->MultiCell($w,5,$data[$i],0,$a);
|
---|
57 | //Put the position to the right of the cell
|
---|
58 | $this->SetXY($x+$w,$y);
|
---|
59 | }
|
---|
60 | //Go to the next line
|
---|
61 | $this->Ln($h);
|
---|
62 | }
|
---|
63 |
|
---|
64 | function CheckPageBreak($h)
|
---|
65 | {
|
---|
66 | //If the height h would cause an overflow, add a new page immediately
|
---|
67 | if($this->GetY()+$h>$this->PageBreakTrigger)
|
---|
68 | $this->AddPage($this->CurOrientation);
|
---|
69 | }
|
---|
70 |
|
---|
71 | function NbLines($w,$txt)
|
---|
72 | {
|
---|
73 | //Computes the number of lines a MultiCell of width w will take
|
---|
74 | $cw=&$this->CurrentFont['cw'];
|
---|
75 | if($w==0)
|
---|
76 | $w=$this->w-$this->rMargin-$this->x;
|
---|
77 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
|
---|
78 | $s=str_replace("\r",'',$txt);
|
---|
79 | $nb=strlen($s);
|
---|
80 | if($nb>0 and $s[$nb-1]=="\n")
|
---|
81 | $nb--;
|
---|
82 | $sep=-1;
|
---|
83 | $i=0;
|
---|
84 | $j=0;
|
---|
85 | $l=0;
|
---|
86 | $nl=1;
|
---|
87 | while($i<$nb)
|
---|
88 | {
|
---|
89 | $c=$s[$i];
|
---|
90 | if($c=="\n")
|
---|
91 | {
|
---|
92 | $i++;
|
---|
93 | $sep=-1;
|
---|
94 | $j=$i;
|
---|
95 | $l=0;
|
---|
96 | $nl++;
|
---|
97 | continue;
|
---|
98 | }
|
---|
99 | if($c==' ')
|
---|
100 | $sep=$i;
|
---|
101 | $l+=$cw[$c];
|
---|
102 | if($l>$wmax)
|
---|
103 | {
|
---|
104 | if($sep==-1)
|
---|
105 | {
|
---|
106 | if($i==$j)
|
---|
107 | $i++;
|
---|
108 | }
|
---|
109 | else
|
---|
110 | $i=$sep+1;
|
---|
111 | $sep=-1;
|
---|
112 | $j=$i;
|
---|
113 | $l=0;
|
---|
114 | $nl++;
|
---|
115 | }
|
---|
116 | else
|
---|
117 | $i++;
|
---|
118 | }
|
---|
119 | return $nl;
|
---|
120 | }
|
---|
121 |
|
---|
122 | /* function Header()
|
---|
123 | {
|
---|
124 | $SubTituloR = lang('report cota organization');
|
---|
125 |
|
---|
126 | //Restore font and colors
|
---|
127 | $this->SetFont('Arial','',8);
|
---|
128 | $this->SetFillColor(224,235,255);
|
---|
129 | $this->SetTextColor(0);
|
---|
130 |
|
---|
131 | $this->Cell(95,5,lang('name'),1,0,'L',1);
|
---|
132 | // $pdf->Cell(53,5,lang('report email'),1,0,'L',1);
|
---|
133 | $this->Cell(17,5,lang('cota'),1,0,'C',1);
|
---|
134 | $this->Cell(31,5,lang('cota used'),1,0,'C',1);
|
---|
135 | $this->Cell(29,5,lang('percent cota'),1,0,'C',1);
|
---|
136 | $this->Cell(20,5,lang('status'),1,1,'C',1);
|
---|
137 |
|
---|
138 | return;
|
---|
139 | }
|
---|
140 | */
|
---|
141 | function Footer()
|
---|
142 | {
|
---|
143 | // Esta função foi implemantada para realizar o rodapé dos relatórios
|
---|
144 |
|
---|
145 | $titulo_system = $GLOBALS['phpgw_info']['apps']['reports1_0']['title'];
|
---|
146 | $SubTitulo = $GLOBALS['phpgw_info']['apps']['reports1_0']['subtitle'];
|
---|
147 |
|
---|
148 | //Seleciona Arial itálico 8
|
---|
149 | $this->SetY(-15);
|
---|
150 | $this->SetFont('Arial','I',8);
|
---|
151 | $this->SetTextColor(0,0,100);
|
---|
152 | $this->SetFillColor(224,235,255);
|
---|
153 |
|
---|
154 | //Imprime o número da página
|
---|
155 | // $this->Cell(0,5,$titulo_system.' '.$SubTitulo.' Página n. '.$this->PageNo(),1,0,'C',1);
|
---|
156 |
|
---|
157 | $this->Rect(9,281,197,6,'D');
|
---|
158 | $this->Cell(55,4,$titulo_system,0,0,'L',1);
|
---|
159 | $this->Cell(100,4,$SubTitulo,0,0,'C',1);
|
---|
160 | $this->Cell(40,4,'Página n. '.$this->PageNo(),0,1,'R',1);
|
---|
161 | }
|
---|
162 |
|
---|
163 | }
|
---|
164 | ?>
|
---|