95b3a7e249157abcb31d081588a4ea0403e8dd5e
[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($this->leftMargin, $iline5 ,$this->leftMargin, $iline7);
63                 if ($this->l['a_meta_dir'] == 'rtl') // avoid line overwrite in rtl language
64                         $this->LineTo($this->cols[$cols - 2], $iline5 ,$this->cols[$cols - 2], $iline7);
65                 else    
66                         $this->LineTo($this->cols[$cols - 2] + 4, $iline5 ,$this->cols[$cols - 2] + 4, $iline7);
67                 $this->LineTo($right, $iline5 ,$right, $iline7);
68
69                 // Company Logo
70                 $this->NewLine();
71                 $logo = company_path() . "/images/" . $this->company['coy_logo'];
72                 if ($this->company['coy_logo'] != '' && file_exists($logo))
73                 {
74                         $this->AddImage($logo, $ccol, $this->row, 0, 40);
75                 }
76                 else
77                 {
78                         $this->fontSize += 4;
79                         $this->Font('bold');
80                         $this->Text($ccol, $this->company['coy_name'], $icol);
81                         $this->Font();
82                         $this->fontSize -= 4;
83                 }
84                 // Document title
85                 $this->SetTextColor(190, 190, 190);
86                 $this->fontSize += 10;
87                 $this->Font('bold');
88                 $this->TextWrap($mcol, $this->row, $this->pageWidth - $this->rightMargin - $mcol - 20, $this->title, 'right');
89                 $this->Font();
90                 $this->fontSize -= 10;
91                 $this->NewLine();
92                 $this->SetTextColor(0, 0, 0);
93                 $adrline = $this->row;
94
95                 // Company data
96                 $this->TextWrapLines($ccol, $icol, $this->company['postal_address']);
97                 $this->Font('italic');
98                 if (@$this->company['phone'])
99                 {
100                         $this->Text($ccol, _("Phone"), $c2col);
101                         $this->Text($c2col, $this->company['phone'], $mcol);
102                         $this->NewLine();
103                 }
104                 if (@$this->company['fax'])
105                 {
106                         $this->Text($ccol, _("Fax"), $c2col);
107                         $this->Text($c2col, $this->company['fax'], $mcol);
108                         $this->NewLine();
109                 }
110                 if (@$this->company['email'])
111                 {
112                         $this->Text($ccol, _("Email"), $c2col);
113
114                         $url = "mailto:" . $this->company['email'];
115                         $this->SetTextColor(0, 0, 255);
116                         $this->Text($c2col, $this->company['email'], $mcol);
117                         $this->SetTextColor(0, 0, 0);
118                         $this->addLink($url, $c2col, $this->row, $mcol, $this->row + $this->lineHeight);
119
120                         $this->NewLine();
121                 }
122                 if (@$this->company['gst_no'])
123                 {
124                         $this->Text($ccol, _("Our VAT No."), $c2col);
125                         $this->Text($c2col, $this->company['gst_no'], $mcol);
126                         $this->NewLine();
127                 }
128                 if (@$this->formData['domicile'])
129                 {
130                         $this->Text($ccol, _("Domicile"), $c2col);
131                         $this->Text($c2col, $this->company['domicile'], $mcol);
132                         $this->NewLine();
133                 }
134                 $this->Font();
135                 $this->row = $adrline;
136                 $this->NewLine(3);
137                 $this->Text($mcol + 100, _("Date"));
138                 $this->Text($mcol + 180, sql2date($this->formData['document_date']));
139
140                 $this->NewLine();
141                 $this->Text($mcol + 100, $this->formData['document_name']);
142                 $this->Text($mcol + 180, $this->formData['document_number']);
143                 $this->NewLine(2);
144         
145                 if ($this->pageNumber > 1)
146                         $this->Text($mcol + 180, _("Page") . ' ' . $this->pageNumber);
147                 $this->row = $iline1 - $this->lineHeight;
148                 $this->fontSize -= 4;
149                 $this->Text($ccol, $Addr1['title'], $icol);
150                 $this->Text($mcol, $Addr2['title']);
151                 $this->fontSize += 4;
152
153 // address1
154                 $temp = $this->row = $this->row - $this->lineHeight - 5;
155                 $this->Text($ccol, $Addr1['name'], $icol);
156                 $this->NewLine();
157                 $this->TextWrapLines($ccol, $icol - $ccol, $Addr1['address']);
158
159 // address2
160                 $this->row = $temp;
161                 $this->Text($mcol, $Addr2['name']);
162                 $this->NewLine();
163                 $this->TextWrapLines($mcol, $this->rightMargin - $mcol, $Addr2['address'], 'left', 0, 0, NULL, 1);
164
165                 // Auxiliary document information
166                 $col = $this->leftMargin;
167                 foreach($aux_info as $info_header => $info_content)
168                 {
169
170                         $this->row = $iline2 - $this->lineHeight - 1;
171                         $this->TextWrap($col, $this->row, $width, $info_header, 'C');
172                         $this->row = $iline3 - $this->lineHeight - 1;
173                         $this->TextWrap($col, $this->row, $width, $info_content, 'C');
174                         $col += $width;
175                 }
176                 // Payment terms
177                 $this->row -= (2 * $this->lineHeight);
178                 $this->Font('italic');
179                 $this->TextWrap($ccol, $this->row, $right-$ccol, $Payment_Terms);
180                 $this->Font();
181
182                 // Line headers
183                 $this->row = $iline5 - $this->lineHeight - 1;
184                 $this->Font('bold');
185                 $count = count($this->headers);
186                 $this->cols[$count] = $right - 3;
187                 for ($i = 0; $i < $count; $i++)
188                         $this->TextCol($i, $i + 1, $this->headers[$i], -2);
189                 $this->Font();
190
191                 // Footer
192                 $this->Font('italic');
193                 $this->row = $iline7 - $this->lineHeight - 6;
194
195                 foreach ($Footer as $line => $txt)
196                 {
197                         if (!is_numeric($line)) // title => link
198                         {
199                                 $this->fontSize -= 2;
200                                 $this->TextWrap($ccol, $this->row, $right - $ccol, $line, 'C');
201                                 $this->row -= $this->lineHeight;
202                                 $this->SetTextColor(0, 0, 255);
203                                 $this->TextWrap($ccol, $this->row, $right - $ccol, $txt, 'C');
204                                 $this->SetTextColor(0, 0, 0);
205                                 $this->addLink($txt, $ccol, $this->row, $this->pageWidth - $this->rightMargin, $this->row + $this->lineHeight);
206                                 $this->fontSize += 2;
207                         }
208                         else
209                                 $this->TextWrap($ccol, $this->row, $right - $ccol, $txt, 'C');
210                         $this->row -= $this->lineHeight;
211
212                 }
213
214                 $this->Font();
215                 $temp = $iline6 - $this->lineHeight - 2;