Eliminated non-static method calls and other bulk fixes to fix php5 warnings
[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                 // New version (without vertical lines)
13
14         global $wo_types_array;
15         
16                 $this->row = $this->pageHeight - $this->topMargin;
17
18                 $upper = $this->row - 2 * $this->lineHeight;
19                 $lower = $this->bottomMargin + 6 * $this->lineHeight;
20                 $iline1 = $upper - 7.5 * $this->lineHeight;
21                 $iline2 = $iline1 - 8 * $this->lineHeight;
22                 $iline3 = $iline2 - 1.5 * $this->lineHeight;
23                 $iline4 = $iline3 - 1.5 * $this->lineHeight;
24                 $iline5 = $iline4 - 3 * $this->lineHeight;
25                 $iline6 = $iline5 - 1.5 * $this->lineHeight;
26                 $iline7 = $lower;
27                 $right = $this->pageWidth - $this->rightMargin;
28                 $width = ($right - $this->leftMargin) / 6;
29                 $icol = $this->pageWidth / 2;
30                 $ccol = $this->cols[0] + 4;
31                 $c2col = $ccol + 60;
32                 $ccol2 = $icol / 2;
33                 $mcol = $icol + 8;
34                 $mcol2 = $this->pageWidth - $ccol2;
35                 $cols = count($this->cols);
36                 $this->SetDrawColor(205, 205, 205);
37                 $this->Line($iline1, 3);
38                 $this->SetDrawColor(128, 128, 128);
39                 $this->Line($iline1);
40                 $this->rectangle($this->leftMargin, $iline2, $right - $this->leftMargin, $iline2 - $iline3, "F", null, array(222, 231, 236));   
41                 $this->Line($iline2);
42                 $this->Line($iline3);
43                 $this->Line($iline4);
44                 $this->rectangle($this->leftMargin, $iline5, $right - $this->leftMargin, $iline5 - $iline6, "F", null, array(222, 231, 236));   
45                 $this->Line($iline5);
46                 $this->Line($iline6);
47                 $this->Line($iline7);
48                 $this->LineTo($this->leftMargin, $iline2 ,$this->leftMargin, $iline4);
49                 $col = $this->leftMargin;
50                 for ($i = 0; $i < 5; $i++)
51                 {
52                         $this->LineTo($col += $width, $iline2,$col, $iline4);
53                 }       
54                 $this->LineTo($right, $iline2 ,$right, $iline4);
55                 $this->LineTo($this->leftMargin, $iline5 ,$this->leftMargin, $iline7);
56                 $this->LineTo($this->cols[$cols - 2] + 4, $iline5 ,$this->cols[$cols - 2] + 4, $iline7);
57                 $this->LineTo($right, $iline5 ,$right, $iline7);
58
59                 $this->NewLine();
60                 if ($this->company['coy_logo'] != '')
61                 {
62                         $logo = $comp_path .'/'. user_company() . "/images/" . $this->company['coy_logo'];
63                         $this->AddImage($logo, $ccol, $this->row, 0, 40);
64                 }
65                 else
66                 {
67                         $this->fontSize += 4;
68                         $this->Font('bold');
69                         $this->Text($ccol, $this->company['coy_name'], $icol);
70                         $this->Font();
71                         $this->fontSize -= 4;
72                 }
73                 $this->SetTextColor(190, 190, 190);
74                 $this->fontSize += 10;
75                 $this->Font('bold');
76                 $this->TextWrap($mcol, $this->row, $this->pageWidth - $this->rightMargin - $mcol - 20, $this->title, 'right');
77                 $this->Font();
78                 $this->fontSize -= 10;
79                 $this->NewLine();
80                 $this->SetTextColor(0, 0, 0);
81                 $adrline = $this->row;
82                 $this->TextWrapLines($ccol, $icol, $this->company['postal_address']);
83                 $this->Font('italic');
84                 if ($this->company['phone'] != "")
85                 {
86                         $this->Text($ccol, _("Phone"), $c2col);
87                         $this->Text($c2col, $this->company['phone'], $mcol);
88                         $this->NewLine();
89                 }       
90                 if ($this->company['fax'] != "")
91                 {
92                         $this->Text($ccol, _("Fax"), $c2col);
93                         $this->Text($c2col, $this->company['fax'], $mcol);
94                         $this->NewLine();
95                 }       
96                 if ($this->company['email'] != "")
97                 {
98                         $this->Text($ccol, _("Email"), $c2col);
99
100                         $url = "mailto:" . $this->company['email'];
101                         $this->SetTextColor(0, 0, 255);
102                         $this->Text($c2col, $this->company['email'], $mcol);
103                         $this->SetTextColor(0, 0, 0);
104                         $this->addLink($url, $c2col, $this->row, $mcol, $this->row + $this->lineHeight);
105
106                         $this->NewLine();
107                 }       
108                 if ($this->company['gst_no'] != "")
109                 {
110                         $this->Text($ccol, $doc_Our_VAT_no, $c2col);
111                         $this->Text($c2col, $this->company['gst_no'], $mcol);
112                         $this->NewLine();
113                 }
114                 if (($doctype == 10 || $doctype == 12) && $this->company['domicile'] != "")
115                 {
116                         $this->Text($ccol, $doc_Domicile, $c2col);
117                         $this->Text($c2col, $this->company['domicile'], $mcol);
118                         $this->NewLine();
119                 }
120                 $this->Font();
121                 $this->row = $adrline;
122                 $this->NewLine(3);
123                 $this->Text($mcol + 100, $doc_Date.":");
124                 if ($doctype == 7 || $doctype == 8 || $doctype == 9)
125                         $this->Text($mcol + 180, sql2date($myrow['ord_date']));
126                 elseif ($doctype == 26) 
127                         $this->Text($mcol + 180, sql2date($myrow['date_']));
128                 else
129                         $this->Text($mcol + 180, sql2date($myrow['tran_date']));
130                 $this->NewLine();
131                 $this->Text($mcol + 100, $doc_Invoice_no);
132                 if ($doctype == 7 || $doctype == 8 || $doctype == 9) // QUOTE, PO or SO
133                         $this->Text($mcol + 180, $myrow['order_no']);
134                 elseif ($doctype == 26) 
135                         $this->Text($mcol + 180, $myrow['id']);
136                 else if (isset($myrow['trans_no']) && isset($myrow['reference'])) // INV/CRE/STA
137                 {
138                         if ($print_invoice_no == 1)
139                                 $this->Text($mcol + 180, $myrow['trans_no']);
140                         else
141                                 $this->Text($mcol + 180, $myrow['reference']);
142                 }
143
144                 if ($this->pageNumber > 1 && !strstr($this->filename, "Bulk"))
145                         $this->Text($this->endLine - 35, _("Page") . ' ' . $this->pageNumber);
146                 $this->row = $iline1 - $this->lineHeight;
147                 $this->fontSize -= 4;
148                 $this->Text($ccol, $doc_Charge_To, $icol);
149                 $this->Text($mcol, $doc_Delivered_To);
150                 $this->fontSize += 4;
151
152                 $this->row = $this->row - $this->lineHeight - 5;
153
154                 $temp = $this->row;
155                 if ($doctype == 7 || $doctype == 9)
156                 {
157                         $this->Text($ccol, $myrow['name'], $icol);
158                 }
159                 elseif ($doctype == 26)
160                 {
161                         $this->Text($ccol, $myrow['location_name'], $icol);
162                         $this->NewLine();
163                         $this->TextWrapLines($ccol, $icol - $ccol, $myrow['delivery_address']);
164                 }
165                 else
166                 {
167                         if ($doctype == 8) {
168                                 $name = $myrow['supp_name'];
169                                 $addr = $myrow['address'];
170                         } else {
171                                 if (trim($branch['br_address']) != '') {
172                                         $name = $branch['br_name'];
173                                         $addr = $branch['br_address'];
174                                 } else {
175                                         $name = $myrow['DebtorName'];
176                                         $addr = $myrow['address'];
177                                 }
178                         }
179                         $this->Text($ccol, $name, $icol);
180                         $this->NewLine();
181                         $this->TextWrapLines($ccol, $icol - $ccol, $addr);
182                 }
183                 if ($sales_order != NULL)
184                 {
185                         $this->row = $temp;
186                         if ($doctype == 8)
187                                 $this->Text($mcol, $this->company['coy_name']);
188                         else
189                                 $this->Text($mcol, $sales_order['deliver_to']);
190                         $this->NewLine();
191                         $this->TextWrapLines($mcol, $this->rightMargin - $mcol, $sales_order['delivery_address']);
192                 }
193                 $this->row = $iline2 - $this->lineHeight - 1;
194                 $col = $this->leftMargin;
195                 $this->TextWrap($col, $this->row, $width, $doc_Customers_Ref, 'C');
196                 $col += $width;
197                 $this->TextWrap($col, $this->row, $width, $doc_Our_Ref, 'C');
198                 $col += $width;
199                 $this->TextWrap($col, $this->row, $width, $doc_Your_VAT_no, 'C');
200                 $col += $width;
201                 if ($doctype == 10)
202                         $this->TextWrap($col, $this->row, $width, $doc_Delivery_no, 'C');
203                 else
204                         $this->TextWrap($col, $this->row, $width, $doc_Our_Order_No, 'C');
205                 $col += $width;
206                 $this->TextWrap($col, $this->row, $width, $doc_Payment_Terms, 'C');
207                 $col += $width;
208                 $this->TextWrap($col, $this->row, $width, $doc_Due_Date, 'C');
209                 $this->row = $iline3 - $this->lineHeight - 1;
210                 $col = $this->leftMargin;
211                 if ($doctype == 8)
212                         $this->TextWrap($col, $this->row, $width, $myrow['supp_account_no'], 'C');
213                 elseif ($doctype == 26)
214                         $this->TextWrap($col, $this->row, $width, $myrow['wo_ref'], 'C');
215                 elseif (isset($sales_order["customer_ref"]))
216                         $this->TextWrap($col, $this->row, $width, $sales_order["customer_ref"], 'C');
217                 $col += $width; 
218                 if ($branch != null)
219                 {
220                         $id = $branch['salesman'];
221                         $sql = "SELECT salesman_name  FROM ".TB_PREF."salesman WHERE salesman_code='$id'";
222                         $result = db_query($sql,"could not get sales person");
223                         $row = db_fetch($result);
224                         $this->TextWrap($col, $this->row, $width, $row['salesman_name'], 'C');
225                 }               
226                 elseif ($doctype == 26)
227                         $this->TextWrap($col, $this->row, $width, $wo_types_array[$myrow["type"]], 'C');
228                 $col += $width; 
229                 if ($doctype == 26)
230                         $this->TextWrap($col, $this->row, $width, $myrow["StockItemName"], 'C');
231                 elseif ($doctype != 8 && isset($myrow['tax_id']))
232                         $this->TextWrap($col, $this->row, $width, $myrow['tax_id'], 'C');
233                 $col += $width; 
234                 if ($doctype == 10)
235                 {
236                         $deliveries = get_parent_trans(10,$myrow['trans_no']);
237                         $line = "";
238                         foreach ($deliveries as $delivery)
239                         {
240                                 if ($line == "")
241                                         $line .= "$delivery";
242                                 else
243                                         $line .= ",$delivery";
244                         }               
245                         $this->TextWrap($col, $this->row, $width, $line, 'C');
246                 }
247                 elseif ($doctype == 26)
248                         $this->TextWrap($col, $this->row, $width, $myrow["location_name"], 'C');
249                 elseif (isset($myrow['order_']))
250                         $this->TextWrap($col, $this->row, $width, $myrow['order_'], 'C');
251                 $col += $width;
252                 if ($doctype == 26)
253                         $this->TextWrap($col, $this->row, $width, sql2date($myrow["required_by"]), 'C');
254                 else
255                 {
256                         $id = $myrow['payment_terms'];
257                         $sql = "SELECT terms FROM ".TB_PREF."payment_terms WHERE terms_indicator='$id'";
258                         $result = db_query($sql,"could not get paymentterms");
259                         $row = db_fetch($result);
260                         $this->TextWrap($col, $this->row, $width, $row["terms"], 'C');
261                 }       
262                 $col += $width; 
263                 if ($doctype == 9 || $doctype == 7)
264                         $this->TextWrap($col, $this->row, $width, sql2date($myrow['delivery_date']), 'C');
265                 elseif ($doctype == 26) 
266                         $this->TextWrap($col, $this->row, $width, $myrow["units_issued"], 'C');
267                 else if ($doctype != 8 && $doctype != 11 && isset($myrow['due_date']))
268                         $this->TextWrap($col, $this->row, $width, sql2date($myrow['due_date']), 'C');
269                 
270                 $this->row = $iline5 - $this->lineHeight - 1;
271                 $this->Font('bold');
272                 $count = count($this->headers);
273                 $this->cols[$count] = $right - 3;
274                 for ($i = 0; $i < $count; $i++)
275                         $this->TextCol($i, $i + 1, $this->headers[$i], -2);
276                 $this->Font();
277                 $this->Font('italic');
278                 $this->row = $iline7 - $this->lineHeight - 6;
279                 if ($doctype != 26)
280                         $this->TextWrap($ccol, $this->row, $right - $ccol, $doc_Please_Quote . " - " . $myrow['curr_code'], 'C');
281                 $this->NewLine();
282
283                 if (isset($bankaccount['bank_name']))
284                 {
285                         $txt = $doc_Bank . ": ".$bankaccount['bank_name']. ", " . $doc_Bank_Account . ": " . $bankaccount['bank_account_number'];
286                         $this->TextWrap($ccol, $this->row, $right - $ccol, $txt, 'C');
287                         $this->NewLine();
288                 }       
289                 if ($doctype == 10 && $branch['disable_branch'] > 0) // payment links
290                 {
291                         if ($branch['disable_branch'] == 1)
292                         {
293                                 $amt = number_format($myrow["ov_freight"] + $myrow["ov_gst"] +  $myrow["ov_amount"], user_price_dec());
294                                 $txt = $doc_Payment_Link . " PayPal: ";
295                                 $name = urlencode($this->title . " " . $myrow['reference']);
296                                 $url = "https://www.paypal.com/xclick/business=" . $this->company['email'] . "&item_name=" .
297                                         $name . "&amount=" . $amt . "&currency_code=" . $myrow['curr_code'];
298                                 $this->fontSize -= 2;
299                                 $this->TextWrap($ccol, $this->row, $right - $ccol, $txt, 'C');
300                                 $this->NewLine();
301                                 $this->SetTextColor(0, 0, 255);
302                                 $this->TextWrap($ccol, $this->row, $right - $ccol, $url, 'C');
303                                 $this->SetTextColor(0, 0, 0);
304                                 $this->addLink($url, $ccol, $this->row, $this->pageWidth - $this->rightMargin, $this->row + $this->lineHeight);
305                                 $this->fontSize += 2;
306                                 $this->NewLine();
307                         }
308                 }
309                 if ($this->params['comments'] != '')
310                 {
311                         $this->TextWrap($ccol, $this->row, $right - $ccol, $this->params['comments'], 'C');
312                         $this->NewLine();
313                 }
314                 if (($doctype == 10 || $doctype == 12) && $this->company['legal_text'] != "") 
315                 {
316                         $this->TextWrap($ccol, $this->row, $right - $ccol, $this->company['legal_text'], 'C');
317 //                      $this->NewLine();
318                 }
319                 $this->Font();
320                 $temp = $iline6 - $this->lineHeight - 2;
321 ?>