source: branches/2.2/reports/inc/class.uireports_fpdf.inc.php @ 4570

Revision 4570, 3.3 KB checked in by thiagoaos, 13 years ago (diff)

Ticket #1955 - Adição de 2 relatórios e ajuste no relatório de cotas.

Line 
1<?php
2/*******************************************************************************
3 * FPDF                                                                         *
4 *                                                                              *
5 * Version: 1.6                                                                 *
6 * Date:    2008-08-03                                                          *
7 * Author:  Olivier PLATHEY                                                     *
8 *******************************************************************************/
9
10require('class.fpdf.inc.php');
11
12class 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 Footer()
123        {
124                // Esta função foi implemantada para realizar o rodapé dos relatórios
125                $titulo_system = $GLOBALS['phpgw_info']['apps']['reports']['title'];
126                $SubTitulo = $GLOBALS['phpgw_info']['apps']['reports']['subtitle'];
127
128                //Seleciona Arial itálico 8
129                $this->SetY(-15);
130                $this->SetFont('Arial','I',8);
131                $this->SetTextColor(0,0,100);
132                $this->SetFillColor(224,235,255);
133
134                //Imprime o número da página
135                $this->Rect(9,281,197,6,'D');
136                $this->Cell(55,4,$titulo_system,0,0,'L',1);
137                $this->Cell(100,4,$SubTitulo,0,0,'C',1);
138                $this->Cell(40,4,'Página n. '.$this->PageNo(),0,1,'R',1);
139        }
140
141}
142?>
Note: See TracBrowser for help on using the repository browser.