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.
20 'title' => _("Charge To"),
21 'name' => @$this->formData['br_name'] ? $this->formData['br_name'] : @$this->formData['DebtorName'],
22 'address' => @$this->formData['br_address'] ? $this->formData['br_address'] : @$this->formData['address']
25 'title' => _("Delivered To"),
26 'name' => @$this->formData['deliver_to'],
27 'address' => @$this->formData['delivery_address']
30 // default item column headers
31 $this->headers = array(_("Item Code"), _("Item Description"), _("Quantity"),
32 _("Unit"), _("Price"), _("Discount %"), _("Total"));
34 // for links use 'text' => 'url'
35 $Footer[0] = _("All amounts stated in") . " - " . @$this->formData['curr_code'];
37 if (!in_array($this->formData['doctype'], array(ST_STATEMENT, ST_WORKORDER)))
39 $row = get_payment_terms($this->formData['payment_terms']);
40 $Payment_Terms = _("Payment Terms") . ': ' . $row["terms"];
41 if ($this->formData['doctype'] == ST_SALESINVOICE && $this->formData['prepaid'])
42 $this->formData['prepaid'] = ($row['days_before_due'] >= 0) ? 'final' : 'partial';
46 switch ($this->formData['doctype'])
49 $this->title = _("SALES QUOTATION");
50 $this->formData['document_name'] =_("Quotation No.");
51 $this->formData['document_date'] = $this->formData['ord_date'];
52 $this->formData['document_number'] = $SysPrefs->print_invoice_no() == 0 && isset($this->formData['reference'])
53 ? $this->formData['reference'] : $this->formData['order_no'];
55 _("Customer's Reference") => $this->formData["customer_ref"],
56 _("Sales Person") => get_salesman_name($this->formData['salesman']),
57 _("Your VAT no.") => $this->formData['tax_id'],
58 _("Our Quotation No") => $this->formData['order_no'],
59 _("Valid until") => sql2date($this->formData['delivery_date']),
64 $this->title = ($this->params['print_quote'] ? _("QUOTE") : ($this->formData['prepaid'] ? _("PREPAYMENT ORDER") : _("SALES ORDER")));
65 $this->formData['document_name'] =_("Order No.");
66 $this->formData['document_date'] = $this->formData['ord_date'];
67 $this->formData['document_number'] = $SysPrefs->print_invoice_no() == 0 && isset($this->formData['reference'])
68 ? $this->formData['reference'] : $this->formData['order_no'];
69 $this->formData['document_amount'] = $this->formData['order_no'];
72 _("Customer's Reference") => $this->formData["customer_ref"],
73 _("Sales Person") => get_salesman_name($this->formData['salesman']),
74 _("Your VAT no.") => $this->formData['tax_id'],
75 _("Our Order No") => $this->formData['order_no'],
76 _("Delivery Date") => sql2date($this->formData['delivery_date']),
81 $this->title = ($this->params['packing_slip'] ? _("PACKING SLIP") : _("DELIVERY NOTE"));
82 $this->formData['document_name'] = _("Delivery Note No.");
85 $ref = $this->formData['order_'];
86 if ($SysPrefs->print_invoice_no() == 0)
88 $ref = get_reference(ST_SALESORDER, $this->formData['order_']);
90 $ref = $this->formData['order_'];
93 _("Customer's Reference") => $this->formData["customer_ref"],
94 _("Sales Person") => get_salesman_name($this->formData['salesman']),
95 _("Your VAT no.") => $this->formData['tax_id'],
96 _("Our Order No") => $ref,
97 _("To Be Invoiced Before") => sql2date($this->formData['due_date']),
102 $this->title = _("CREDIT NOTE");
103 $this->formData['document_name'] =_("Credit No.");
104 $Footer[0] = _("Please quote Credit no. when paying. All amounts stated in") . " - " . $this->formData['curr_code'];
107 _("Customer's Reference") => @$this->formData["customer_ref"],
108 _("Sales Person") => get_salesman_name($this->formData['salesman']),
109 _("Your VAT no.") => $this->formData['tax_id'],
110 _("Our Order No") => $this->formData['order_'],
115 case ST_SALESINVOICE:
116 $this->title = $this->formData['prepaid']=='partial' ? _("PREPAYMENT INVOICE")
117 : ($this->formData['prepaid']=='final' ? _("FINAL INVOICE") : _("INVOICE"));
118 $this->formData['document_name'] =_("Invoice No.");
119 $this->formData['domicile'] = $this->company['domicile'];
120 $Footer[0] = _("Please quote Invoice no. when paying. All amounts stated in"). " - " . $this->formData['curr_code'];
122 $deliveries = get_sales_parent_numbers(ST_SALESINVOICE, $this->formData['trans_no']);
123 if ($SysPrefs->print_invoice_no() == 0)
125 foreach($deliveries as $n => $delivery) {
126 $deliveries[$n] = get_reference(ST_CUSTDELIVERY, $delivery);
130 _("Customer's Reference") => $this->formData["customer_ref"],
131 _("Sales Person") => get_salesman_name($this->formData['salesman']),
132 _("Your VAT no.") => $this->formData['tax_id'],
134 if ($this->formData['prepaid']=='partial')
136 $aux_info[_("Date of Payment")] = sql2date(get_oldest_payment_date($this->formData['trans_no']));
137 $aux_info[_("Our Order No")] = $this->formData['order_'];
139 if ($this->formData['prepaid'] =='final')
140 $aux_info[_("Invoice Date")] = sql2date($this->formData['tran_date']);
142 $aux_info[_("Date of Sale")] = sql2date(get_oldest_delivery_date($this->formData['trans_no']));
143 $aux_info[_("Due Date")] = sql2date($this->formData['due_date']);
148 global $systypes_array;
150 $this->title = _("REMITTANCE");
151 $this->formData['document_name'] =_("Remittance No.");
152 $Addr1['title'] = _("Order To");
153 $Addr1['name'] = $this->formData['supp_name'];
154 $Addr1['address'] = $this->formData['address'];
155 $Addr2['title'] = _("Charge To");
157 $Addr2['address'] = '';
160 _("Customer's Reference") => $this->formData['supp_account_no'],
161 _("Type") =>$systypes_array[$this->formData["type"]],
162 _("Your VAT no.") => $this->formData['tax_id'],
163 _("Supplier's Reference") => '',
164 _("Due Date") => sql2date($this->formData['tran_date']),
166 $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("Due Date"), _("Total Amount"), _("Left to Allocate"), _("This Allocation"));
170 $this->title = _("PURCHASE ORDER");
171 $this->formData['document_name'] =_("Purchase Order No.");
172 $Addr1['title'] = _("Order To");
173 $Addr1['name'] = $this->formData['supp_name'];
174 $Addr1['address'] = $this->formData['address'];
175 $Addr2['title'] = _("Deliver To");
176 $Addr2['name'] = $this->company['coy_name'];
177 //$Addr2['address'] = $this->company['postal_address']; No, don't destroy delivery address!
178 $this->formData['document_date'] = $this->formData['ord_date'];
179 $this->formData['document_number'] = $SysPrefs->print_invoice_no() == 0 && isset($this->formData['reference'])
180 ? $this->formData['reference'] : $this->formData['order_no'];
183 _("Customer's Reference") => $this->formData['supp_account_no'],
184 _("Sales Person") => $this->formData['contact'],
185 _("Your VAT no.") => $this->formData['tax_id'],
186 _("Supplier's Reference") => @$this->formData['requisition_no'],
187 _("Order Date") => sql2date($this->formData['document_date']),
190 $this->headers = array(_("Item Code"), _("Item Description"),
191 _("Delivery Date"), _("Quantity"), _("Unit"), _("Price"), _("Total"));
195 global $systypes_array;
197 $this->title = _("RECEIPT");
198 $this->formData['document_name'] =_("Receipt No.");
199 $Addr1['title'] = _("With thanks from");
200 if ($this->formData['order_'] == "0")
201 $this->formData['order_'] = "";
203 _("Customer's Reference") => $this->formData["debtor_ref"],
204 _("Type") =>$systypes_array[$this->formData["type"]],
205 _("Your VAT no.") => $this->formData['tax_id'],
206 _("Our Order No") => $this->formData['order_'],
207 _("Due Date") => sql2date($this->formData['tran_date']),
209 $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("Due Date"), _("Total Amount"), _("Left to Allocate"), _("This Allocation"));
213 global $wo_types_array;
215 $this->title = _("WORK ORDER");
216 $this->formData['document_name'] =_("Work Order No.");
217 $this->formData['document_date'] = $this->formData['date_'];
218 $this->formData['document_number'] = $this->formData['id'];
219 $Addr1['name'] = $this->formData['location_name'];
220 $Addr1['address'] = $this->formData['delivery_address'];
222 _("Reference") => $this->formData['wo_ref'],
223 _("Type") => $wo_types_array[$this->formData["type"]],
224 _("Manufactured Item") => $this->formData["StockItemName"],
225 _("Into Location") => $this->formData["location_name"],
226 _("Quantity") => $this->formData["units_issued"],
228 $Payment_Terms = _("Required By").": ".sql2date($this->formData["required_by"]);
229 $this->headers = array(_("Item Code"), _("Item Description"),
230 _("From Location"), _("Work Centre"), _("Unit Quantity"), _("Total Quantity"), _("Units Issued"));
236 $this->formData['document_name'] = '';
237 $this->formData['domicile'] = $this->company['domicile'];
239 $this->title = _("STATEMENT");
241 _("Customer's Reference") => '',
242 _("Sales Person") => '',
243 _("Your VAT no.") => $this->formData['tax_id'],
244 _("Our Order No") => '',
245 _("Delivery Date") => '',
247 $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("DueDate"), _("Debits"),
248 _("Credits"), _("Allocated"), _("Outstanding"));
252 if (!isset($this->formData['document_date']))
253 $this->formData['document_date'] = $this->formData['tran_date'];
255 if (!isset($this->formData['document_number']))
256 $this->formData['document_number'] = $SysPrefs->print_invoice_no() == 0 && isset($this->formData['reference'])
257 ? $this->formData['reference'] : @$this->formData['trans_no'];
259 // footer generic content
260 if (@$this->formData['bank_name'])
261 $Footer[] = _("Bank"). ": ".$this->formData['bank_name']. ", " . _("Bank Account") . ": " . $this->formData['bank_account_number'];
263 if (@$this->formData['payment_service']) //payment link
265 $amt = number_format($this->formData["ov_freight"] + $this->formData["ov_gst"] + $this->formData["ov_amount"], user_price_dec());
266 $service = $this->formData['payment_service'];
267 $url = payment_link($service, array(
268 'company_email' => $this->company['email'],
270 'currency' => $this->formData['curr_code'],
271 'comment' => $this->title . " " . $this->formData['reference']
273 $Footer[_("You can pay through"). " $service: "] = "$url";
276 if ($this->formData['doctype'] == ST_CUSTPAYMENT)
277 $Footer[] = _("* Subject to Realisation of the Cheque.");
279 if ($this->params['comments'] != '')
280 $Footer[] = $this->params['comments'];
282 if (($this->formData['doctype'] == ST_SALESINVOICE || $this->formData['doctype'] == ST_STATEMENT) && $this->company['legal_text'] != "")
284 foreach(explode("\n", $this->company['legal_text']) as $line)
288 $this->formData['recipient_name'] = $Addr1['name'];