Changed the default header2.inc.
[fa-stable.git] / reporting / includes / header2.inc
1 <?php
2
3                 $this->row = $this->pageHeight - $this->topMargin;
4
5                 $upper = $this->row - 2 * $this->lineHeight;
6                 $lower = $this->bottomMargin + 6 * $this->lineHeight;
7                 $iline1 = $upper - 7 * $this->lineHeight;
8                 $iline2 = $iline1 - 8 * $this->lineHeight;
9                 $iline3 = $iline2 - 1.5 * $this->lineHeight;
10                 $iline4 = $iline3 - 1.5 * $this->lineHeight;
11                 $iline5 = $iline4 - 3 * $this->lineHeight;
12                 $iline6 = $iline5 - 1.5 * $this->lineHeight;
13                 $iline7 = $lower;
14                 $right = $this->pageWidth - $this->rightMargin;
15                 $width = ($right - $this->leftMargin) / 6;
16                 $icol = $this->pageWidth / 2;
17                 $ccol = $this->cols[0] + 4;
18                 $c2col = $ccol + 60;
19                 $ccol2 = $icol / 2;
20                 $mcol = $icol + 8;
21                 $mcol2 = $this->pageWidth - $ccol2;
22                 $cols = count($this->cols);
23                 $this->SetDrawColor(205, 205, 205);
24                 $this->Line($iline1, 3);
25                 $this->SetDrawColor(128, 128, 128);
26                 $this->Line($iline1);
27                 $this->rectangle($this->leftMargin, $iline2, $right - $this->leftMargin, $iline2 - $iline3, "F", null, array(222, 231, 236));   
28                 $this->Line($iline2);
29                 $this->Line($iline3);
30                 $this->Line($iline4);
31                 $this->rectangle($this->leftMargin, $iline5, $right - $this->leftMargin, $iline5 - $iline6, "F", null, array(222, 231, 236));   
32                 $this->Line($iline5);
33                 $this->Line($iline6);
34                 $this->Line($iline7);
35                 $this->LineTo($this->leftMargin, $iline2 ,$this->leftMargin, $iline4);
36                 $col = $this->leftMargin;
37                 for ($i = 0; $i < 5; $i++)
38                 {
39                         $this->LineTo($col += $width, $iline2,$col, $iline4);
40                 }       
41                 $this->LineTo($right, $iline2 ,$right, $iline4);
42                 $this->LineTo($this->leftMargin, $iline5 ,$this->leftMargin, $iline7);
43                 $this->LineTo($this->cols[$cols - 2] + 4, $iline5 ,$this->cols[$cols - 2] + 4, $iline7);
44                 $this->LineTo($right, $iline5 ,$right, $iline7);
45
46                 $this->NewLine();
47                 if ($this->company['coy_logo'] != '')
48                 {
49                         $logo = $comp_path .'/'. user_company() . "/images/" . $this->company['coy_logo'];
50                         $this->AddImage($logo, $ccol, $this->row - 10, 0, 40);
51                 }
52                 else
53                 {
54                         $this->fontSize += 4;
55                         $this->Font('bold');
56                         $this->Text($ccol, $this->company['coy_name'], $icol);
57                         $this->Font();
58                         $this->fontSize -= 4;
59                 }
60                 $this->SetTextColor(190, 190, 190);
61                 $this->fontSize += 10;
62                 $this->Font('bold');
63                 $this->TextWrap($mcol, $this->row, $this->pageWidth - $this->rightMargin - $mcol - 20, $this->title, 'right');
64                 $this->Font();
65                 $this->fontSize -= 10;
66                 $this->NewLine();
67                 $this->SetTextColor(0, 0, 0);
68                 $adrline = $this->row;
69                 $this->TextWrapLines($ccol, $icol, $this->company['postal_address']);
70                 $this->Font('italic');
71                 if ($this->company['phone'] != "")
72                 {
73                         $this->Text($ccol, _("Phone"), $c2col);
74                         $this->Text($c2col, $this->company['phone'], $mcol);
75                         $this->NewLine();
76                 }       
77                 if ($this->company['fax'] != "")
78                 {
79                         $this->Text($ccol, _("Fax"), $c2col);
80                         $this->Text($c2col, $this->company['fax'], $mcol);
81                         $this->NewLine();
82                 }       
83                 if ($this->company['email'] != "")
84                 {
85                         $this->Text($ccol, _("Email"), $c2col);
86
87                         $url = "mailto:" . $this->company['email'];
88                         $this->SetTextColor(0, 0, 255);
89                         $this->Text($c2col, $this->company['email'], $mcol);
90                         $this->SetTextColor(0, 0, 0);
91                         $this->addLink($url, $c2col, $this->row, $mcol, $this->row + $this->lineHeight);
92
93                         $this->NewLine();
94                 }       
95                 if ($this->company['gst_no'] != "")
96                 {
97                         $this->Text($ccol, $doc_Our_VAT_no, $c2col);
98                         $this->Text($c2col, $this->company['gst_no'], $mcol);
99                         $this->NewLine();
100                 }       
101                 $this->Font();
102                 $this->row = $adrline;
103                 $this->NewLine(3);
104                 $this->Text($mcol + 100, $doc_Date.":");
105                 if ($doctype == 8 || $doctype == 9)
106                         $this->Text($mcol + 180, sql2date($myrow['ord_date']));
107                 else
108                         $this->Text($mcol + 180, sql2date($myrow['tran_date']));
109                 $this->NewLine();
110                 $this->Text($mcol + 100, $doc_Invoice_no);
111                 if ($doctype == 8 || $doctype == 9) // PO or SO
112                         $this->Text($mcol + 180, $myrow['order_no']);
113                 else if (isset($myrow['trans_no']) && isset($myrow['reference'])) // INV/CRE/STA
114                 {
115                         if ($print_invoice_no == 1)
116                                 $this->Text($mcol + 180, $myrow['trans_no']);
117                         else
118                                 $this->Text($mcol + 180, $myrow['reference']);
119                 }
120
121                 if ($this->pageNumber > 1 && !strstr($this->filename, "Bulk"))
122                         $this->Text($this->endLine - 35, _("Page") . ' ' . $this->pageNumber);
123                 $this->row = $iline1 - $this->lineHeight;
124                 $this->fontSize -= 4;
125                 $this->Text($ccol, $doc_Charge_To, $icol);
126                 $this->Text($mcol, $doc_Delivered_To);
127                 $this->fontSize += 4;
128
129                 $this->row = $this->row - $this->lineHeight - 5;
130
131                 $temp = $this->row;
132                 if ($doctype == 9)
133                 {
134                         $this->Text($ccol, $myrow['name'], $icol);
135                 }
136                 else
137                 {
138                         if ($doctype == 8)
139                                 $this->Text($ccol, $myrow['supp_name'], $icol);
140                         else
141                                 $this->Text($ccol, $myrow['DebtorName'], $icol);
142                         $this->NewLine();
143                         $this->TextWrapLines($ccol, $icol - $ccol, $myrow['address']);
144                 }
145                 if ($sales_order != NULL)
146                 {
147                         $this->row = $temp;
148                         if ($doctype == 8)
149                                 $this->Text($mcol, $this->company['coy_name']);
150                         else
151                                 $this->Text($mcol, $sales_order['deliver_to']);
152                         $this->NewLine();
153                         $this->TextWrapLines($mcol, $this->rightMargin - $mcol, $sales_order['delivery_address']);
154                 }
155                 $this->row = $iline2 - $this->lineHeight - 1;
156                 $col = $this->leftMargin;
157                 $this->TextWrap($col, $this->row, $width, $doc_Customers_Ref, 'C');
158                 $col += $width;
159                 $this->TextWrap($col, $this->row, $width, $doc_Our_Ref, 'C');
160                 $col += $width;
161                 $this->TextWrap($col, $this->row, $width, $doc_Your_VAT_no, 'C');
162                 $col += $width;
163                 $this->TextWrap($col, $this->row, $width, $doc_Our_Order_No, 'C');
164                 $col += $width;
165                 $this->TextWrap($col, $this->row, $width, $doc_Payment_Terms, 'C');
166                 $col += $width;
167                 $this->TextWrap($col, $this->row, $width, $doc_Due_Date, 'C');
168                 $this->row = $iline3 - $this->lineHeight - 1;
169                 $col = $this->leftMargin;
170                 if ($sales_order != NULL)
171                         $this->TextWrap($col, $this->row, $width, $sales_order["customer_ref"], 'C');
172                 $col += $width; 
173                 if ($branch != null)
174                 {
175                         $id = $branch['salesman'];
176                         $sql = "SELECT salesman_name  FROM ".TB_PREF."salesman WHERE salesman_code='$id'";
177                         $result = db_query($sql,"could not get sales person");
178                         $row = db_fetch($result);
179                         $this->TextWrap($col, $this->row, $width, $row['salesman_name'], 'C');
180                 }               
181                 $col += $width; 
182                 if ($doctype != 8 && isset($myrow['tax_id']))
183                         $this->TextWrap($col, $this->row, $width, $myrow['tax_id'], 'C');
184                 $col += $width; 
185                 if (isset($myrow['order_']))
186                         $this->TextWrap($col, $this->row, $width, $myrow['order_'], 'C');
187                 $col += $width; 
188                 $id = $myrow['payment_terms'];
189                 $sql = "SELECT terms FROM ".TB_PREF."payment_terms WHERE terms_indicator='$id'";
190                 $result = db_query($sql,"could not get paymentterms");
191                 $row = db_fetch($result);
192                 $this->TextWrap($col, $this->row, $width, $row["terms"], 'C');
193                 $col += $width; 
194                 if ($doctype == 9)
195                         $this->TextWrap($col, $this->row, $width, sql2date($myrow['delivery_date']), 'C');
196                 else if ($doctype != 8 && isset($myrow['due_date']))
197                         $this->TextWrap($col, $this->row, $width, sql2date($myrow['due_date']), 'C');
198                 
199                 $this->row = $iline5 - $this->lineHeight - 1;
200                 $this->Font('bold');
201                 $count = count($this->headers);
202                 if (user_pagesize() == "Letter")
203                         $this->cols[$count] += 40;
204                 else    
205                         $this->cols[$count] += 5;
206                 for ($i = 0; $i < $count; $i++)
207                         $this->TextCol($i, $i + 1, $this->headers[$i], -2);
208                 $this->Font();
209                 $this->Font('italic');
210                 $this->row = $iline7 - $this->lineHeight - 6;
211                 $this->TextWrap($ccol, $this->row, $right - $ccol, $doc_Please_Quote . " - " . $myrow['curr_code'], 'C');
212                 $this->NewLine();
213
214                 if (isset($bankaccount['bank_name']))
215                 {
216                         $txt = $doc_Bank . ": ".$bankaccount['bank_name']. ", " . $doc_Bank_Account . ": " . $bankaccount['bank_account_number'];
217                         $this->TextWrap($ccol, $this->row, $right - $ccol, $txt, 'C');
218                         $this->NewLine();
219                 }       
220                 if ($doctype == 10 && $branch['disable_branch'] > 0) // payment links
221                 {
222                         if ($branch['disable_branch'] == 1)
223                         {
224                                 $amt = number_format($myrow["ov_freight"] + $myrow["ov_gst"] +  $myrow["ov_amount"], user_price_dec());
225                                 $txt = $doc_Payment_Link . " PayPal: ";
226                                 $name = urlencode($this->title . " " . $myrow['reference']);
227                                 $url = "https://www.paypal.com/xclick/business=" . $this->company['email'] . "&item_name=" .
228                                         $name . "&amount=" . $amt . "&currency_code=" . $myrow['curr_code'];
229                                 $this->fontSize -= 2;
230                                 $this->TextWrap($ccol, $this->row, $right - $ccol, $txt, 'C');
231                                 $this->NewLine();
232                                 $this->SetTextColor(0, 0, 255);
233                                 $this->TextWrap($ccol, $this->row, $right - $ccol, $url, 'C');
234                                 $this->SetTextColor(0, 0, 0);
235                                 $this->addLink($url, $ccol, $this->row, $this->pageWidth - $this->rightMargin, $this->row + $this->lineHeight);
236                                 $this->fontSize += 2;
237                                 $this->NewLine();
238                         }
239                 }
240                 if ($this->params['comments'] != '')
241                 {
242                         $this->TextWrap($ccol, $this->row, $right - $ccol, $this->params['comments'], 'C');
243                         $this->NewLine();
244                 }
245                 $this->Font();
246                 $temp = $iline6 - $this->lineHeight - 2;
247 ?>