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)
14 global $wo_types_array, $systypes_array;
16 $this->row = $this->pageHeight - $this->topMargin;
18 $upper = $this->row - 2 * $this->lineHeight;
19 $lower = $this->bottomMargin + 8 * $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;
27 $right = $this->pageWidth - $this->rightMargin;
28 $width = ($right - $this->leftMargin) / 5;
29 $icol = $this->pageWidth / 2;
30 $ccol = $this->cols[0] + 4;
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);
40 $this->rectangle($this->leftMargin, $iline2, $right - $this->leftMargin, $iline2 - $iline3, "F", null, array(222, 231, 236));
44 $this->rectangle($this->leftMargin, $iline5, $right - $this->leftMargin, $iline5 - $iline6, "F", null, array(222, 231, 236));
48 $this->LineTo($this->leftMargin, $iline2 ,$this->leftMargin, $iline4);
49 $col = $this->leftMargin;
50 for ($i = 0; $i < 5; $i++)
52 $this->LineTo($col += $width, $iline2,$col, $iline4);
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);
60 if ($this->company['coy_logo'] != '')
62 $logo = $comp_path .'/'. user_company() . "/images/" . $this->company['coy_logo'];
63 $this->AddImage($logo, $ccol, $this->row, 0, 40);
69 $this->Text($ccol, $this->company['coy_name'], $icol);
73 $this->SetTextColor(190, 190, 190);
74 $this->fontSize += 10;
76 $this->TextWrap($mcol, $this->row, $this->pageWidth - $this->rightMargin - $mcol - 20, $this->title, 'right');
78 $this->fontSize -= 10;
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'] != "")
86 $this->Text($ccol, _("Phone"), $c2col);
87 $this->Text($c2col, $this->company['phone'], $mcol);
90 if ($this->company['fax'] != "")
92 $this->Text($ccol, _("Fax"), $c2col);
93 $this->Text($c2col, $this->company['fax'], $mcol);
96 if ($this->company['email'] != "")
98 $this->Text($ccol, _("Email"), $c2col);
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);
108 if ($this->company['gst_no'] != "")
110 $this->Text($ccol, $doc_Our_VAT_no, $c2col);
111 $this->Text($c2col, $this->company['gst_no'], $mcol);
114 if (($doctype == ST_SALESINVOICE || $doctype == ST_CUSTPAYMENT) && $this->company['domicile'] != "")
116 $this->Text($ccol, $doc_Domicile, $c2col);
117 $this->Text($c2col, $this->company['domicile'], $mcol);
121 $this->row = $adrline;
123 $this->Text($mcol + 100, $doc_Date);
124 if ($doctype == ST_SALESQUOTE || $doctype == ST_PURCHORDER || $doctype == ST_SALESORDER)
125 $this->Text($mcol + 180, sql2date($myrow['ord_date']));
126 elseif ($doctype == ST_WORKORDER)
127 $this->Text($mcol + 180, sql2date($myrow['date_']));
129 $this->Text($mcol + 180, sql2date($myrow['tran_date']));
131 $this->Text($mcol + 100, $doc_Invoice_no);
132 if ($doctype == ST_SALESQUOTE || $doctype == ST_PURCHORDER || $doctype == ST_SALESORDER) // QUOTE, PO or SO
134 if ($print_invoice_no == 1)
135 $this->Text($mcol + 180, $myrow['order_no']);
137 $this->Text($mcol + 180, $myrow['reference']);
139 elseif ($doctype == ST_WORKORDER)
140 $this->Text($mcol + 180, $myrow['id']);
141 else if (isset($myrow['trans_no']) && isset($myrow['reference'])) // INV/CRE/STA
143 if ($print_invoice_no == 1)
144 $this->Text($mcol + 180, $myrow['trans_no']);
146 $this->Text($mcol + 180, $myrow['reference']);
149 if ($this->pageNumber > 1 && !strstr($this->filename, "Bulk"))
150 $this->Text($this->endLine - 35, _("Page") . ' ' . $this->pageNumber);
151 $this->row = $iline1 - $this->lineHeight;
152 $this->fontSize -= 4;
153 $this->Text($ccol, $doc_Charge_To, $icol);
154 $this->Text($mcol, $doc_Delivered_To);
155 $this->fontSize += 4;
157 $this->row = $this->row - $this->lineHeight - 5;
160 if ($doctype == ST_SALESQUOTE || $doctype == ST_SALESORDER)
162 $this->Text($ccol, $myrow['name'], $icol);
164 elseif ($doctype == ST_WORKORDER)
166 $this->Text($ccol, $myrow['location_name'], $icol);
168 $this->TextWrapLines($ccol, $icol - $ccol, $myrow['delivery_address']);
172 if ($doctype == ST_PURCHORDER || $doctype == ST_SUPPAYMENT) {
173 $name = $myrow['supp_name'];
174 $addr = $myrow['address'];
176 if (trim($branch['br_address']) != '') {
177 $name = $branch['br_name'];
178 $addr = $branch['br_address'];
180 $name = $myrow['DebtorName'];
181 $addr = $myrow['address'];
184 $this->Text($ccol, $name, $icol);
186 $this->TextWrapLines($ccol, $icol - $ccol, $addr);
188 if ($sales_order != NULL)
191 if ($doctype == ST_PURCHORDER)
192 $this->Text($mcol, $this->company['coy_name']);
193 elseif ($doctype != ST_SUPPAYMENT)
194 $this->Text($mcol, $sales_order['deliver_to']);
196 if ($doctype != ST_SUPPAYMENT)
197 $this->TextWrapLines($mcol, $this->rightMargin - $mcol, $sales_order['delivery_address']);
199 $this->row = $iline2 - $this->lineHeight - 1;
200 $col = $this->leftMargin;
201 $this->TextWrap($col, $this->row, $width, $doc_Customers_Ref, 'C');
203 $this->TextWrap($col, $this->row, $width, $doc_Our_Ref, 'C');
205 $this->TextWrap($col, $this->row, $width, $doc_Your_VAT_no, 'C');
207 if ($doctype == ST_SALESINVOICE)
208 $this->TextWrap($col, $this->row, $width, $doc_Delivery_no, 'C');
210 $this->TextWrap($col, $this->row, $width, $doc_Our_Order_No, 'C');
212 $this->TextWrap($col, $this->row, $width, $doc_Due_Date, 'C');
213 $this->row = $iline3 - $this->lineHeight - 1;
214 $col = $this->leftMargin;
215 if ($doctype == ST_PURCHORDER || $doctype == ST_SUPPAYMENT)
216 $this->TextWrap($col, $this->row, $width, $myrow['supp_account_no'], 'C');
217 elseif ($doctype == ST_WORKORDER)
218 $this->TextWrap($col, $this->row, $width, $myrow['wo_ref'], 'C');
219 elseif (isset($sales_order["customer_ref"]))
220 $this->TextWrap($col, $this->row, $width, $sales_order["customer_ref"], 'C');
224 $id = $branch['salesman'];
225 $sql = "SELECT salesman_name FROM ".TB_PREF."salesman WHERE salesman_code='$id'";
226 $result = db_query($sql,"could not get sales person");
227 $row = db_fetch($result);
228 $this->TextWrap($col, $this->row, $width, $row['salesman_name'], 'C');
230 elseif ($doctype == ST_SUPPAYMENT)
231 $this->TextWrap($col, $this->row, $width, $systypes_array[$myrow["type"]], 'C');
232 elseif ($doctype == ST_WORKORDER)
233 $this->TextWrap($col, $this->row, $width, $wo_types_array[$myrow["type"]], 'C');
235 if ($doctype == ST_WORKORDER)
236 $this->TextWrap($col, $this->row, $width, $myrow["StockItemName"], 'C');
237 elseif ($doctype != ST_PURCHORDER && isset($myrow['tax_id']))
238 $this->TextWrap($col, $this->row, $width, $myrow['tax_id'], 'C');
240 if ($doctype == ST_SALESINVOICE)
242 $deliveries = get_parent_trans(ST_SALESINVOICE, $myrow['trans_no']);
244 foreach ($deliveries as $delivery)
246 if ($print_invoice_no == 0)
248 $ref = get_reference(ST_CUSTDELIVERY, $delivery);
253 $line .= "$delivery";
255 $line .= ",$delivery";
257 $this->TextWrap($col, $this->row, $width, $line, 'C');
259 elseif ($doctype == ST_CUSTDELIVERY)
261 $ref = $myrow['order_'];
262 if ($print_invoice_no == 0)
264 $ref = get_reference(ST_SALESORDER, $myrow['order_']);
266 $ref = $myrow['order_'];
268 $this->TextWrap($col, $this->row, $width, $ref, 'C');
270 elseif ($doctype == ST_WORKORDER)
271 $this->TextWrap($col, $this->row, $width, $myrow["location_name"], 'C');
272 elseif (isset($myrow['order_']))
273 $this->TextWrap($col, $this->row, $width, $myrow['order_'], 'C');
275 if ($doctype == ST_SALESORDER || $doctype == ST_SALESQUOTE)
276 $this->TextWrap($col, $this->row, $width, sql2date($myrow['delivery_date']), 'C');
277 elseif ($doctype == ST_WORKORDER)
278 $this->TextWrap($col, $this->row, $width, $myrow["units_issued"], 'C');
279 elseif ($doctype != ST_PURCHORDER && $doctype != ST_CUSTCREDIT && isset($myrow['due_date']))
280 $this->TextWrap($col, $this->row, $width, sql2date($myrow['due_date']), 'C');
281 if (!isset($packing_slip) || $packing_slip == 0)
283 $this->row -= (2 * $this->lineHeight);
284 if ($doctype == ST_WORKORDER)
285 $str = sql2date($myrow["required_by"]);
288 $id = $myrow['payment_terms'];
289 $sql = "SELECT terms FROM ".TB_PREF."payment_terms WHERE terms_indicator='$id'";
290 $result = db_query($sql,"could not get paymentterms");
291 $row = db_fetch($result);
292 $str = $row["terms"];
294 $this->Font('italic');
295 $this->TextWrap($ccol, $this->row, $right-$ccol, $doc_Payment_Terms . ": " . $str);
298 $this->row = $iline5 - $this->lineHeight - 1;
300 $count = count($this->headers);
301 $this->cols[$count] = $right - 3;
302 for ($i = 0; $i < $count; $i++)
303 $this->TextCol($i, $i + 1, $this->headers[$i], -2);
305 $this->Font('italic');
306 $this->row = $iline7 - $this->lineHeight - 6;
307 if ($doctype != ST_WORKORDER)
308 $this->TextWrap($ccol, $this->row, $right - $ccol, $doc_Please_Quote . " - " . $myrow['curr_code'], 'C');
309 $this->row -= $this->lineHeight;
311 if (isset($bankaccount['bank_name']))
313 $txt = $doc_Bank . ": ".$bankaccount['bank_name']. ", " . $doc_Bank_Account . ": " . $bankaccount['bank_account_number'];
314 $this->TextWrap($ccol, $this->row, $right - $ccol, $txt, 'C');
315 $this->row -= $this->lineHeight;
317 if ($doctype == ST_SALESINVOICE && $branch['disable_branch'] > 0) // payment links
319 if ($branch['disable_branch'] == 1)
321 $amt = number_format($myrow["ov_freight"] + $myrow["ov_gst"] + $myrow["ov_amount"], user_price_dec());
322 $txt = $doc_Payment_Link . " PayPal: ";
323 $name = urlencode($this->title . " " . $myrow['reference']);
324 $url = "https://www.paypal.com/xclick/business=" . $this->company['email'] . "&item_name=" .
325 $name . "&amount=" . $amt . "¤cy_code=" . $myrow['curr_code'];
326 $this->fontSize -= 2;
327 $this->TextWrap($ccol, $this->row, $right - $ccol, $txt, 'C');
328 $this->row -= $this->lineHeight;
329 $this->SetTextColor(0, 0, 255);
330 $this->TextWrap($ccol, $this->row, $right - $ccol, $url, 'C');
331 $this->SetTextColor(0, 0, 0);
332 $this->addLink($url, $ccol, $this->row, $this->pageWidth - $this->rightMargin, $this->row + $this->lineHeight);
333 $this->fontSize += 2;
334 $this->row -= $this->lineHeight;
337 if ($this->params['comments'] != '')
339 $this->TextWrap($ccol, $this->row, $right - $ccol, $this->params['comments'], 'C');
340 $this->row -= $this->lineHeight;
342 if (($doctype == ST_SALESINVOICE || $doctype == ST_CUSTPAYMENT) && $this->company['legal_text'] != "")
344 $this->TextWrapLines($ccol, $right - $ccol, $this->company['legal_text'], 'C');
347 $temp = $iline6 - $this->lineHeight - 2;