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 ***********************************************************************/
14 * Set document type dependent elements of common page layout.
18 'title' => _("Charge To"),
19 'name' => @$this->formData['br_name'] ? $this->formData['br_name'] : @$this->formData['DebtorName'],
20 'address' => @$this->formData['br_address'] ? $this->formData['br_address'] : @$this->formData['address']
23 'title' => _("Delivered To"),
24 'name' => @$this->formData['deliver_to'],
25 'address' => @$this->formData['delivery_address']
28 // default item column headers
29 $this->headers = array(_("Item Code"), _("Item Description"), _("Quantity"),
30 _("Unit"), _("Price"), _("Discount %"), _("Total"));
32 // for links use 'text' => 'url'
33 $Footer[0] = _("All amounts stated in") . " - " . @$this->formData['curr_code'];
35 switch ($this->formData['doctype'])
38 $this->title = _("SALES QUOTATION");
39 $this->formData['document_name'] =_("Quotation No.");
40 $this->formData['document_date'] = $this->formData['ord_date'];
41 $this->formData['document_number'] = $this->formData['order_no'];
43 _("Customers Reference") => $this->formData["customer_ref"],
44 _("Sales Person") => get_salesman_name($this->formData['salesman']),
45 _("Your VAT no.") => '',
46 _("Our Order No") => '',
47 _("Valid until") => sql2date($this->formData['delivery_date']),
52 $this->title = ($print_as_quote==1 ? _("QUOTE") : _("SALES ORDER"));
53 $this->formData['document_name'] =_("Order No.");
54 $this->formData['document_date'] = $this->formData['ord_date'];
55 $this->formData['document_number'] = $this->formData['order_no'];
56 $this->formData['document_amount'] = $this->formData['order_no'];
59 _("Customers Reference") => $this->formData["customer_ref"],
60 _("Sales Person") => get_salesman_name($this->formData['salesman']),
61 _("Your VAT no.") => '',
62 _("Our Order No") => '',
63 _("Delivery Date") => sql2date($this->formData['delivery_date']),
68 $this->title = ($packing_slip==1 ? _("PACKING SLIP") : _("DELIVERY NOTE"));
69 $this->formData['document_name'] = _("Delivery Note No.");
72 $ref = $this->formData['order_'];
73 if ($print_invoice_no == 0)
75 $ref = get_reference(ST_SALESORDER, $this->formData['order_']);
77 $ref = $this->formData['order_'];
80 _("Customers Reference") => $this->formData["customer_ref"],
81 _("Sales Person") => get_salesman_name($this->formData['salesman']),
82 _("Your VAT no.") => $this->formData['tax_id'],
83 _("Our Order No") => $ref,
84 _("To Be Invoiced Before") => sql2date($this->formData['due_date']),
89 $this->title = _("CREDIT NOTE");
90 $this->formData['document_name'] =_("Credit No.");
91 $Footer[0] = _("Please quote Credit no. when paying. All amounts stated in") . " - " . $this->formData['curr_code'];
94 _("Customers Reference") => @$this->formData["customer_ref"],
95 _("Sales Person") => get_salesman_name($this->formData['salesman']),
96 _("Your VAT no.") => $this->formData['tax_id'],
97 _("Our Order No") => $this->formData['order_'],
102 case ST_SALESINVOICE:
103 $this->title = _("INVOICE");
104 $this->formData['document_name'] =_("Invoice No.");
105 $this->formData['domicile'] = $this->company['domicile'];
106 $Footer[0] = _("Please quote Invoice no. when paying. All amounts stated in"). " - " . $this->formData['curr_code'];
108 $deliveries = get_sales_parent_numbers(ST_SALESINVOICE, $this->formData['trans_no']);
109 if ($print_invoice_no == 0)
111 foreach($deliveries as $n => $delivery) {
112 $deliveries[$n] = get_reference(ST_CUSTDELIVERY, $delivery);
116 _("Customers Reference") => $this->formData["customer_ref"],
117 _("Sales Person") => get_salesman_name($this->formData['salesman']),
118 _("Your VAT no.") => $this->formData['tax_id'],
119 _("Delivery Note No.") => implode(',', $deliveries),
120 _("Due Date") => sql2date($this->formData['due_date']),
125 global $systypes_array;
127 $this->title = _("REMITTANCE");
128 $this->formData['document_name'] =_("Remittance No.");
129 $Addr1['title'] = _("Order To");
130 $Addr1['name'] = $this->formData['supp_name'];
131 $Addr1['address'] = $this->formData['address'];
132 $Addr2['title'] = _("Charge To");
134 $Addr2['address'] = '';
137 _("Customers Reference") => $this->formData['supp_account_no'],
138 _("Type") =>$systypes_array[$this->formData["type"]],
139 _("Your VAT no.") => $this->formData['tax_id'],
140 _("Our Order No") => '',
141 _("Due Date") => sql2date($this->formData['tran_date']),
143 $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("Due Date"), _("Total Amount"), _("Left to Allocate"), _("This Allocation"));
147 $this->title = _("PURCHASE ORDER");
148 $this->formData['document_name'] =_("Purchase Order No.");
149 $Addr1['title'] = _("Order To");
150 $Addr1['name'] = $this->formData['supp_name'];
151 $Addr1['address'] = $this->formData['address'];
152 $Addr2['title'] = _("Deliver To");
153 $Addr2['name'] = $this->company['coy_name'];
154 $Addr2['address'] = $this->company['postal_address'];
155 $this->formData['document_date'] = $this->formData['ord_date'];
156 $this->formData['document_number'] = $this->formData['order_no'];
159 _("Customers Reference") => $this->formData['supp_account_no'],
160 _("Sales Person") => '',
161 _("Your VAT no.") => '',
162 _("Our Order No") => '',
166 $this->headers = array(_("Item Code"), _("Item Description"),
167 _("Delivery Date"), _("Quantity"), _("Unit"), _("Price"), _("Total"));
171 global $systypes_array;
173 $this->title = _("RECEIPT");
174 $this->formData['document_name'] =_("Receipt No.");
175 $Addr1['title'] = _("With thanks from");
177 _("Customers Reference") => $this->formData["debtor_ref"],
178 _("Type") =>$systypes_array[$this->formData["type"]],
179 _("Your VAT no.") => $this->formData['tax_id'],
180 _("Our Order No") => $this->formData['order_'],
181 _("Due Date") => sql2date($this->formData['tran_date']),
183 $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("Due Date"), _("Total Amount"), _("Left to Allocate"), _("This Allocation"));
187 global $wo_types_array;
189 $this->title = _("WORK ORDER");
190 $this->formData['document_name'] =_("Work Order No.");
191 $this->formData['document_date'] = $this->formData['date_'];
192 $this->formData['document_number'] = $this->formData['id'];
193 $Addr1['name'] = $this->formData['location_name'];
194 $Addr1['address'] = $this->formData['delivery_address'];
196 _("Reference") => $this->formData['wo_ref'],
197 _("Type") => $wo_types_array[$this->formData["type"]],
198 _("Manufactured Item") => $this->formData["StockItemName"],
199 _("Into Location") => $this->formData["location_name"],
200 _("Quantity") => $this->formData["units_issued"],
202 $Payment_Terms = _("Required By").": ".sql2date($this->formData["required_by"]);
203 $this->headers = array(_("Item Code"), _("Item Description"),
204 _("From Location"), _("Work Centre"), _("Unit Quantity"), _("Total Quantity"), _("Units Issued"));
210 $this->formData['document_name'] = '';
211 $this->formData['domicile'] = $this->company['domicile'];
213 $this->title = _("STATEMENT");
215 _("Customers Reference") => '',
216 _("Sales Person") => '',
217 _("Your VAT no.") => $this->formData['tax_id'],
218 _("Our Order No") => '',
219 _("Delivery Date") => '',
221 $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("DueDate"), _("Charges"),
222 _("Credits"), _("Allocated"), _("Outstanding"));
226 if (!isset($this->formData['document_date']))
227 $this->formData['document_date'] = $this->formData['tran_date'];
229 if (!isset($this->formData['document_number']))
230 $this->formData['document_number'] = $print_invoice_no == 0 && isset($this->formData['reference'])
231 ? $this->formData['reference'] : @$this->formData['trans_no'];
233 if (!isset($Payment_Terms))
235 $id = $this->formData['payment_terms'];
236 $sql = "SELECT terms FROM ".TB_PREF."payment_terms WHERE terms_indicator=".db_escape($id);
237 $result = db_query($sql,"could not get paymentterms");
238 $row = db_fetch($result);
239 $Payment_Terms = _("Payment Terms") . ': ' . $row["terms"];
242 // footer generic content
243 if (@$this->formData['bank_name'])
244 $Footer[] = _("Bank"). ": ".$this->formData['bank_name']. ", " . _("Bank Account") . ": " . $this->formData['bank_account_number'];
246 if (@$this->formData['payment_service']) //payment link
248 $amt = number_format($this->formData["ov_freight"] + $this->formData["ov_gst"] + $this->formData["ov_amount"], user_price_dec());
249 $service = $this->formData['payment_service'];
250 $url = payment_link($service, array(
251 'company_email' => $this->company['email'],
253 'currency' => $this->formData['curr_code'],
254 'comment' => $this->title . " " . $this->formData['reference']
256 $Footer[_("You can pay through"). " $service: "] = "$url";
259 if ($this->formData['doctype'] == ST_CUSTPAYMENT)
260 $Footer[] = _("* Subject to Realisation of the Cheque.");
262 if ($this->params['comments'] != '')
263 $Footer[] = $this->params['comments'];
265 if (($this->formData['doctype'] == ST_SALESINVOICE || $this->formData['doctype'] == ST_STATEMENT) && $this->company['legal_text'] != "")
267 foreach(explode("\n", $this->company['legal_text']) as $line)