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 ***********************************************************************/
13 $this->row = $this->pageHeight - $this->topMargin;
15 $upper = $this->row - 2 * $this->lineHeight;
16 $lower = $this->bottomMargin + 6 * $this->lineHeight;
17 $iline1 = $upper - 7.5 * $this->lineHeight;
18 $iline2 = $iline1 - 8 * $this->lineHeight;
19 $iline3 = $iline2 - 1.5 * $this->lineHeight;
20 $iline4 = $iline3 - 1.5 * $this->lineHeight;
21 $iline5 = $iline4 - 3 * $this->lineHeight;
22 $iline6 = $iline5 - 1.5 * $this->lineHeight;
24 $right = $this->pageWidth - $this->rightMargin;
25 $width = ($right - $this->leftMargin) / 6;
26 $icol = $this->pageWidth / 2;
27 $ccol = $this->cols[0] + 4;
31 $mcol2 = $this->pageWidth - $ccol2;
32 $cols = count($this->cols);
33 $this->SetDrawColor(205, 205, 205);
34 $this->Line($iline1, 3);
35 $this->SetDrawColor(128, 128, 128);
37 $this->rectangle($this->leftMargin, $iline2, $right - $this->leftMargin, $iline2 - $iline3, "F", null, array(222, 231, 236));
41 $this->rectangle($this->leftMargin, $iline5, $right - $this->leftMargin, $iline5 - $iline6, "F", null, array(222, 231, 236));
45 $this->LineTo($this->leftMargin, $iline2 ,$this->leftMargin, $iline4);
46 $col = $this->leftMargin;
47 for ($i = 0; $i < 5; $i++)
49 $this->LineTo($col += $width, $iline2,$col, $iline4);
51 $this->LineTo($right, $iline2 ,$right, $iline4);
52 $this->LineTo($this->leftMargin, $iline5 ,$this->leftMargin, $iline7);
53 $this->LineTo($this->cols[$cols - 2] + 4, $iline5 ,$this->cols[$cols - 2] + 4, $iline7);
54 $this->LineTo($right, $iline5 ,$right, $iline7);
57 if ($this->company['coy_logo'] != '')
59 $logo = $comp_path .'/'. user_company() . "/images/" . $this->company['coy_logo'];
60 $this->AddImage($logo, $ccol, $this->row - 10, 0, 40);
66 $this->Text($ccol, $this->company['coy_name'], $icol);
70 $this->SetTextColor(190, 190, 190);
71 $this->fontSize += 10;
73 $this->TextWrap($mcol, $this->row, $this->pageWidth - $this->rightMargin - $mcol - 20, $this->title, 'right');
75 $this->fontSize -= 10;
77 $this->SetTextColor(0, 0, 0);
78 $adrline = $this->row;
79 $this->TextWrapLines($ccol, $icol, $this->company['postal_address']);
80 $this->Font('italic');
81 if ($this->company['phone'] != "")
83 $this->Text($ccol, _("Phone"), $c2col);
84 $this->Text($c2col, $this->company['phone'], $mcol);
87 if ($this->company['fax'] != "")
89 $this->Text($ccol, _("Fax"), $c2col);
90 $this->Text($c2col, $this->company['fax'], $mcol);
93 if ($this->company['email'] != "")
95 $this->Text($ccol, _("Email"), $c2col);
97 $url = "mailto:" . $this->company['email'];
98 $this->SetTextColor(0, 0, 255);
99 $this->Text($c2col, $this->company['email'], $mcol);
100 $this->SetTextColor(0, 0, 0);
101 $this->addLink($url, $c2col, $this->row, $mcol, $this->row + $this->lineHeight);
105 if ($this->company['gst_no'] != "")
107 $this->Text($ccol, $doc_Our_VAT_no, $c2col);
108 $this->Text($c2col, $this->company['gst_no'], $mcol);
111 if (($doctype == 10 || $doctype == 12) && $this->company['domicile'] != "")
113 $this->Text($ccol, $doc_Domicile, $c2col);
114 $this->Text($c2col, $this->company['domicile'], $mcol);
118 $this->row = $adrline;
120 $this->Text($mcol + 100, $doc_Date.":");
121 if ($doctype == 8 || $doctype == 9)
122 $this->Text($mcol + 180, sql2date($myrow['ord_date']));
124 $this->Text($mcol + 180, sql2date($myrow['tran_date']));
126 $this->Text($mcol + 100, $doc_Invoice_no);
127 if ($doctype == 8 || $doctype == 9) // PO or SO
128 $this->Text($mcol + 180, $myrow['order_no']);
129 else if (isset($myrow['trans_no']) && isset($myrow['reference'])) // INV/CRE/STA
131 if ($print_invoice_no == 1)
132 $this->Text($mcol + 180, $myrow['trans_no']);
134 $this->Text($mcol + 180, $myrow['reference']);
137 if ($this->pageNumber > 1 && !strstr($this->filename, "Bulk"))
138 $this->Text($this->endLine - 35, _("Page") . ' ' . $this->pageNumber);
139 $this->row = $iline1 - $this->lineHeight;
140 $this->fontSize -= 4;
141 $this->Text($ccol, $doc_Charge_To, $icol);
142 $this->Text($mcol, $doc_Delivered_To);
143 $this->fontSize += 4;
145 $this->row = $this->row - $this->lineHeight - 5;
150 $this->Text($ccol, $myrow['name'], $icol);
155 $name = $myrow['supp_name'];
156 $addr = $myrow['address'];
158 if (trim($branch['br_address']) != '') {
159 $name = $branch['br_name'];
160 $addr = $branch['br_address'];
162 $name = $myrow['DebtorName'];
163 $addr = $myrow['address'];
166 $this->Text($ccol, $name, $icol);
168 $this->TextWrapLines($ccol, $icol - $ccol, $addr);
170 if ($sales_order != NULL)
174 $this->Text($mcol, $this->company['coy_name']);
176 $this->Text($mcol, $sales_order['deliver_to']);
178 $this->TextWrapLines($mcol, $this->rightMargin - $mcol, $sales_order['delivery_address']);
180 $this->row = $iline2 - $this->lineHeight - 1;
181 $col = $this->leftMargin;
182 $this->TextWrap($col, $this->row, $width, $doc_Customers_Ref, 'C');
184 $this->TextWrap($col, $this->row, $width, $doc_Our_Ref, 'C');
186 $this->TextWrap($col, $this->row, $width, $doc_Your_VAT_no, 'C');
189 $this->TextWrap($col, $this->row, $width, $doc_Delivery_no, 'C');
191 $this->TextWrap($col, $this->row, $width, $doc_Our_Order_No, 'C');
193 $this->TextWrap($col, $this->row, $width, $doc_Payment_Terms, 'C');
195 $this->TextWrap($col, $this->row, $width, $doc_Due_Date, 'C');
196 $this->row = $iline3 - $this->lineHeight - 1;
197 $col = $this->leftMargin;
199 $this->TextWrap($col, $this->row, $width, $myrow['supp_account_no'], 'C');
200 elseif (isset($sales_order["customer_ref"]))
201 $this->TextWrap($col, $this->row, $width, $sales_order["customer_ref"], 'C');
205 $id = $branch['salesman'];
206 $sql = "SELECT salesman_name FROM ".TB_PREF."salesman WHERE salesman_code='$id'";
207 $result = db_query($sql,"could not get sales person");
208 $row = db_fetch($result);
209 $this->TextWrap($col, $this->row, $width, $row['salesman_name'], 'C');
212 if ($doctype != 8 && isset($myrow['tax_id']))
213 $this->TextWrap($col, $this->row, $width, $myrow['tax_id'], 'C');
217 $deliveries = get_parent_trans(10,$myrow['trans_no']);
219 foreach ($deliveries as $delivery)
222 $line .= "$delivery";
224 $line .= ",$delivery";
226 $this->TextWrap($col, $this->row, $width, $line, 'C');
228 elseif (isset($myrow['order_']))
229 $this->TextWrap($col, $this->row, $width, $myrow['order_'], 'C');
231 $id = $myrow['payment_terms'];
232 $sql = "SELECT terms FROM ".TB_PREF."payment_terms WHERE terms_indicator='$id'";
233 $result = db_query($sql,"could not get paymentterms");
234 $row = db_fetch($result);
235 $this->TextWrap($col, $this->row, $width, $row["terms"], 'C');
238 $this->TextWrap($col, $this->row, $width, sql2date($myrow['delivery_date']), 'C');
239 else if ($doctype != 8 && $doctype != 11 && isset($myrow['due_date']))
240 $this->TextWrap($col, $this->row, $width, sql2date($myrow['due_date']), 'C');
242 $this->row = $iline5 - $this->lineHeight - 1;
244 $count = count($this->headers);
245 $this->cols[$count] = $right - 3;
246 for ($i = 0; $i < $count; $i++)
247 $this->TextCol($i, $i + 1, $this->headers[$i], -2);
249 $this->Font('italic');
250 $this->row = $iline7 - $this->lineHeight - 6;
251 $this->TextWrap($ccol, $this->row, $right - $ccol, $doc_Please_Quote . " - " . $myrow['curr_code'], 'C');
254 if (isset($bankaccount['bank_name']))
256 $txt = $doc_Bank . ": ".$bankaccount['bank_name']. ", " . $doc_Bank_Account . ": " . $bankaccount['bank_account_number'];
257 $this->TextWrap($ccol, $this->row, $right - $ccol, $txt, 'C');
260 if ($doctype == 10 && $branch['disable_branch'] > 0) // payment links
262 if ($branch['disable_branch'] == 1)
264 $amt = number_format($myrow["ov_freight"] + $myrow["ov_gst"] + $myrow["ov_amount"], user_price_dec());
265 $txt = $doc_Payment_Link . " PayPal: ";
266 $name = urlencode($this->title . " " . $myrow['reference']);
267 $url = "https://www.paypal.com/xclick/business=" . $this->company['email'] . "&item_name=" .
268 $name . "&amount=" . $amt . "¤cy_code=" . $myrow['curr_code'];
269 $this->fontSize -= 2;
270 $this->TextWrap($ccol, $this->row, $right - $ccol, $txt, 'C');
272 $this->SetTextColor(0, 0, 255);
273 $this->TextWrap($ccol, $this->row, $right - $ccol, $url, 'C');
274 $this->SetTextColor(0, 0, 0);
275 $this->addLink($url, $ccol, $this->row, $this->pageWidth - $this->rightMargin, $this->row + $this->lineHeight);
276 $this->fontSize += 2;
280 if ($this->params['comments'] != '')
282 $this->TextWrap($ccol, $this->row, $right - $ccol, $this->params['comments'], 'C');
285 if (($doctype == 10 || $doctype == 12) && $this->company['legal_text'] != "")
287 $this->TextWrap($ccol, $this->row, $right - $ccol, $this->company['legal_text'], 'C');
291 $temp = $iline6 - $this->lineHeight - 2;