Moved page number, when more than 1 page, on documents down 2 lines.
[fa-stable.git] / reporting / includes / header2.inc
1 <?php
2 /**********************************************************************
3     Copyright (C) FrontAccounting, LLC.
4         Released under the terms of the GNU General Public License, GPL, 
5         as published by the Free Software Foundation, either version 3 
6         of the License, or (at your option) any later version.
7     This program is distributed in the hope that it will be useful,
8     but WITHOUT ANY WARRANTY; without even the implied warranty of
9     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
10     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12
13 /**
14         Document blueprint use following parameters set in doctext.inc:
15
16         $Addr1, $Addr2 - address info
17         $Payment_Terms - payment terms line
18         $Footer - footer texts
19         $this->company - company info
20         $this->title - report title
21         $this->formData - some other info
22 ***/
23
24                 $this->row = $this->pageHeight - $this->topMargin;
25
26                 $upper = $this->row - 2 * $this->lineHeight;
27                 $lower = $this->bottomMargin + 8 * $this->lineHeight;
28                 $iline1 = $upper - 7.5 * $this->lineHeight;
29                 $iline2 = $iline1 - 8 * $this->lineHeight;
30                 $iline3 = $iline2 - 1.5 * $this->lineHeight;
31                 $iline4 = $iline3 - 1.5 * $this->lineHeight;
32                 $iline5 = $iline4 - 3 * $this->lineHeight;
33                 $iline6 = $iline5 - 1.5 * $this->lineHeight;
34                 $iline7 = $lower;
35                 $right = $this->pageWidth - $this->rightMargin;
36                 $width = ($right - $this->leftMargin) / 5;
37                 $icol = $this->pageWidth / 2;
38                 $ccol = $this->cols[0] + 4;
39                 $c2col = $ccol + 60;
40                 $ccol2 = $icol / 2;
41                 $mcol = $icol + 8;
42                 $mcol2 = $this->pageWidth - $ccol2;
43                 $cols = count($this->cols);
44                 $this->SetDrawColor(205, 205, 205);
45                 $this->Line($iline1, 3);
46                 $this->SetDrawColor(128, 128, 128);
47                 $this->Line($iline1);
48                 $this->rectangle($this->leftMargin, $iline2, $right - $this->leftMargin, $iline2 - $iline3, "F", null, array(222, 231, 236));   
49                 $this->Line($iline2);
50                 $this->Line($iline3);
51                 $this->Line($iline4);
52                 $this->rectangle($this->leftMargin, $iline5, $right - $this->leftMargin, $iline5 - $iline6, "F", null, array(222, 231, 236));   
53                 $this->Line($iline5);
54                 $this->Line($iline6);
55                 $this->Line($iline7);
56                 $this->LineTo($this->leftMargin, $iline2 ,$this->leftMargin, $iline4);
57                 $col = $this->leftMargin;
58                 for ($i = 0; $i < 5; $i++)
59                 {
60                         $this->LineTo($col += $width, $iline2,$col, $iline4);
61                 }
62                 $this->LineTo($right, $iline2 ,$right, $iline4);
63                 $this->LineTo($this->leftMargin, $iline5 ,$this->leftMargin, $iline7);
64                 if ($this->l['a_meta_dir'] == 'rtl') // avoid line overwrite in rtl language
65                         $this->LineTo($this->cols[$cols - 2], $iline5 ,$this->cols[$cols - 2], $iline7);
66                 else    
67                         $this->LineTo($this->cols[$cols - 2] + 4, $iline5 ,$this->cols[$cols - 2] + 4, $iline7);
68                 $this->LineTo($right, $iline5 ,$right, $iline7);
69
70                 // Company Logo
71                 $this->NewLine();
72                 $logo = company_path() . "/images/" . $this->company['coy_logo'];
73                 if ($this->company['coy_logo'] != '' && file_exists($logo))
74                 {
75                         $this->AddImage($logo, $ccol, $this->row, 0, 40);
76                 }
77                 else
78                 {
79                         $this->fontSize += 4;
80                         $this->Font('bold');
81                         $this->Text($ccol, $this->company['coy_name'], $icol);
82                         $this->Font();
83                         $this->fontSize -= 4;
84                 }
85                 // Document title
86                 $this->SetTextColor(190, 190, 190);
87                 $this->fontSize += 10;
88                 $this->Font('bold');
89                 $this->TextWrap($mcol, $this->row, $this->pageWidth - $this->rightMargin - $mcol - 20, $this->title, 'right');
90                 $this->Font();
91                 $this->fontSize -= 10;
92                 $this->NewLine();
93                 $this->SetTextColor(0, 0, 0);
94                 $adrline = $this->row;
95
96                 // Company data
97                 $this->TextWrapLines($ccol, $icol, $this->company['postal_address']);
98                 $this->Font('italic');
99                 if (@$this->company['phone'])
100                 {
101                         $this->Text($ccol, _("Phone"), $c2col);
102                         $this->Text($c2col, $this->company['phone'], $mcol);
103                         $this->NewLine();
104                 }
105                 if (@$this->company['fax'])
106                 {
107                         $this->Text($ccol, _("Fax"), $c2col);
108                         $this->Text($c2col, $this->company['fax'], $mcol);
109                         $this->NewLine();
110                 }
111                 if (@$this->company['email'])
112                 {
113                         $this->Text($ccol, _("Email"), $c2col);
114
115                         $url = "mailto:" . $this->company['email'];
116                         $this->SetTextColor(0, 0, 255);
117                         $this->Text($c2col, $this->company['email'], $mcol);
118                         $this->SetTextColor(0, 0, 0);
119                         $this->addLink($url, $c2col, $this->row, $mcol, $this->row + $this->lineHeight);
120
121                         $this->NewLine();
122                 }
123                 if (@$this->company['gst_no'])
124                 {
125                         $this->Text($ccol, _("Our VAT No."), $c2col);
126                         $this->Text($c2col, $this->company['gst_no'], $mcol);
127                         $this->NewLine();
128                 }
129                 if (@$this->formData['domicile'])
130                 {
131                         $this->Text($ccol, _("Domicile"), $c2col);
132                         $this->Text($c2col, $this->company['domicile'], $mcol);
133                         $this->NewLine();
134                 }
135                 $this->Font();
136                 $this->row = $adrline;
137                 $this->NewLine(3);
138                 $this->Text($mcol + 100, _("Date"));
139                 $this->Text($mcol + 180, sql2date($this->formData['document_date']));
140
141                 $this->NewLine();
142                 $this->Text($mcol + 100, $this->formData['document_name']);
143                 $this->Text($mcol + 180, $this->formData['document_number']);
144                 $this->NewLine(2);
145         
146                 if ($this->pageNumber > 1)
147                         $this->Text($mcol + 180, _("Page") . ' ' . $this->pageNumber);
148                 $this->row = $iline1 - $this->lineHeight;
149                 $this->fontSize -= 4;
150                 $this->Text($ccol, $Addr1['title'], $icol);
151                 $this->Text($mcol, $Addr2['title']);
152                 $this->fontSize += 4;
153
154 // address1
155                 $temp = $this->row = $this->row - $this->lineHeight - 5;
156                 $this->Text($ccol, $Addr1['name'], $icol);
157                 $this->NewLine();
158                 $this->TextWrapLines($ccol, $icol - $ccol, $Addr1['address']);
159
160 // address2
161                 $this->row = $temp;
162                 $this->Text($mcol, $Addr2['name']);
163                 $this->NewLine();
164                 $this->TextWrapLines($mcol, $this->rightMargin - $mcol, $Addr2['address']);
165
166                 // Auxiliary document information
167                 $col = $this->leftMargin;
168                 foreach($aux_info as $info_header => $info_content)
169                 {
170
171                         $this->row = $iline2 - $this->lineHeight - 1;
172                         $this->TextWrap($col, $this->row, $width, $info_header, 'C');
173                         $this->row = $iline3 - $this->lineHeight - 1;
174                         $this->TextWrap($col, $this->row, $width, $info_content, 'C');
175                         $col += $width;
176                 }
177                 // Payment terms
178                 $this->row -= (2 * $this->lineHeight);
179                 $this->Font('italic');
180                 $this->TextWrap($ccol, $this->row, $right-$ccol, $Payment_Terms);
181                 $this->Font();
182
183                 // Line headers
184                 $this->row = $iline5 - $this->lineHeight - 1;
185                 $this->Font('bold');
186                 $count = count($this->headers);
187                 $this->cols[$count] = $right - 3;
188                 for ($i = 0; $i < $count; $i++)
189                         $this->TextCol($i, $i + 1, $this->headers[$i], -2);
190                 $this->Font();
191
192                 // Footer
193                 $this->Font('italic');
194                 $this->row = $iline7 - $this->lineHeight - 6;
195
196                 foreach ($Footer as $line => $txt)
197                 {
198                         if (!is_numeric($line)) // title => link
199                         {
200                                 $this->fontSize -= 2;
201                                 $this->TextWrap($ccol, $this->row, $right - $ccol, $line, 'C');
202                                 $this->row -= $this->lineHeight;
203                                 $this->SetTextColor(0, 0, 255);
204                                 $this->TextWrap($ccol, $this->row, $right - $ccol, $txt, 'C');
205                                 $this->SetTextColor(0, 0, 0);
206                                 $this->addLink($txt, $ccol, $this->row, $this->pageWidth - $this->rightMargin, $this->row + $this->lineHeight);
207                                 $this->fontSize += 2;
208                         }
209                         else
210                                 $this->TextWrap($ccol, $this->row, $right - $ccol, $txt, 'C');
211                         $this->row -= $this->lineHeight;
212
213                 }
214
215                 $this->Font();
216                 $temp = $iline6 - $this->lineHeight - 2;
217 ?>