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