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