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 if (!in_array($this->formData['doctype'], array(ST_STATEMENT, ST_WORKORDER)))
37 $row = get_payment_terms($this->formData['payment_terms']);
38 $Payment_Terms = _("Payment Terms") . ': ' . $row["terms"];
39 if ($this->formData['doctype'] == ST_SALESINVOICE && $this->formData['prepaid'])
40 $this->formData['prepaid'] = ($row['days_before_due'] >= 0) ? 'final' : 'partial';
44 switch ($this->formData['doctype'])
47 $this->title = _("SALES QUOTATION");
48 $this->formData['document_name'] =_("Quotation No.");
49 $this->formData['document_date'] = $this->formData['ord_date'];
50 $this->formData['document_number'] = $SysPrefs->print_invoice_no() == 0 && isset($this->formData['reference'])
51 ? $this->formData['reference'] : $this->formData['order_no'];
53 _("Customer's Reference") => $this->formData["customer_ref"],
54 _("Sales Person") => get_salesman_name($this->formData['salesman']),
55 _("Your VAT no.") => $this->formData['tax_id'],
56 _("Our Quotation No") => $this->formData['order_no'],
57 _("Valid until") => sql2date($this->formData['delivery_date']),
62 $this->title = ($print_as_quote==1 ? _("QUOTE") : ($this->formData['prepaid'] ? _("PREPAYMENT ORDER") : _("SALES ORDER")));
63 $this->formData['document_name'] =_("Order No.");
64 $this->formData['document_date'] = $this->formData['ord_date'];
65 $this->formData['document_number'] = $SysPrefs->print_invoice_no() == 0 && isset($this->formData['reference'])
66 ? $this->formData['reference'] : $this->formData['order_no'];
67 $this->formData['document_amount'] = $this->formData['order_no'];
70 _("Customer's Reference") => $this->formData["customer_ref"],
71 _("Sales Person") => get_salesman_name($this->formData['salesman']),
72 _("Your VAT no.") => $this->formData['tax_id'],
73 _("Our Order No") => $this->formData['order_no'],
74 _("Delivery Date") => sql2date($this->formData['delivery_date']),
79 $this->title = ($packing_slip==1 ? _("PACKING SLIP") : _("DELIVERY NOTE"));
80 $this->formData['document_name'] = _("Delivery Note No.");
83 $ref = $this->formData['order_'];
84 if ($SysPrefs->print_invoice_no() == 0)
86 $ref = get_reference(ST_SALESORDER, $this->formData['order_']);
88 $ref = $this->formData['order_'];
91 _("Customer's Reference") => $this->formData["customer_ref"],
92 _("Sales Person") => get_salesman_name($this->formData['salesman']),
93 _("Your VAT no.") => $this->formData['tax_id'],
94 _("Our Order No") => $ref,
95 _("To Be Invoiced Before") => sql2date($this->formData['due_date']),
100 $this->title = _("CREDIT NOTE");
101 $this->formData['document_name'] =_("Credit No.");
102 $Footer[0] = _("Please quote Credit no. when paying. All amounts stated in") . " - " . $this->formData['curr_code'];
105 _("Customer's Reference") => @$this->formData["customer_ref"],
106 _("Sales Person") => get_salesman_name($this->formData['salesman']),
107 _("Your VAT no.") => $this->formData['tax_id'],
108 _("Our Order No") => $this->formData['order_'],
113 case ST_SALESINVOICE:
114 $this->title = $this->formData['prepaid']=='partial' ? _("PREPAYMENT INVOICE")
115 : ($this->formData['prepaid']=='final' ? _("FINAL INVOICE") : _("INVOICE"));
116 $this->formData['document_name'] =_("Invoice No.");
117 $this->formData['domicile'] = $this->company['domicile'];
118 $Footer[0] = _("Please quote Invoice no. when paying. All amounts stated in"). " - " . $this->formData['curr_code'];
120 $deliveries = get_sales_parent_numbers(ST_SALESINVOICE, $this->formData['trans_no']);
121 if ($SysPrefs->print_invoice_no() == 0)
123 foreach($deliveries as $n => $delivery) {
124 $deliveries[$n] = get_reference(ST_CUSTDELIVERY, $delivery);
128 _("Customer's Reference") => $this->formData["customer_ref"],
129 _("Sales Person") => get_salesman_name($this->formData['salesman']),
130 _("Your VAT no.") => $this->formData['tax_id'],
132 if ($this->formData['prepaid']=='partial')
134 $aux_info[_("Date of Payment")] = sql2date(get_oldest_payment_date($this->formData['trans_no']));
135 $aux_info[_("Our Order No")] = $this->formData['order_'];
137 if ($this->formData['prepaid'] =='final')
138 $aux_info[_("Invoice Date")] = sql2date($this->formData['tran_date']);
140 $aux_info[_("Date of Sale")] = sql2date(get_oldest_delivery_date($this->formData['trans_no']));
141 $aux_info[_("Due Date")] = sql2date($this->formData['due_date']);
146 global $systypes_array;
148 $this->title = _("REMITTANCE");
149 $this->formData['document_name'] =_("Remittance No.");
150 $Addr1['title'] = _("Order To");
151 $Addr1['name'] = $this->formData['supp_name'];
152 $Addr1['address'] = $this->formData['address'];
153 $Addr2['title'] = _("Charge To");
155 $Addr2['address'] = '';
158 _("Customer's Reference") => $this->formData['supp_account_no'],
159 _("Type") =>$systypes_array[$this->formData["type"]],
160 _("Your VAT no.") => $this->formData['tax_id'],
161 _("Supplier's Reference") => '',
162 _("Due Date") => sql2date($this->formData['tran_date']),
164 $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("Due Date"), _("Total Amount"), _("Left to Allocate"), _("This Allocation"));
168 $this->title = _("PURCHASE ORDER");
169 $this->formData['document_name'] =_("Purchase Order No.");
170 $Addr1['title'] = _("Order To");
171 $Addr1['name'] = $this->formData['supp_name'];
172 $Addr1['address'] = $this->formData['address'];
173 $Addr2['title'] = _("Deliver To");
174 $Addr2['name'] = $this->company['coy_name'];
175 //$Addr2['address'] = $this->company['postal_address']; No, don't destroy delivery address!
176 $this->formData['document_date'] = $this->formData['ord_date'];
177 $this->formData['document_number'] = $SysPrefs->print_invoice_no() == 0 && isset($this->formData['reference'])
178 ? $this->formData['reference'] : $this->formData['order_no'];
181 _("Customer's Reference") => $this->formData['supp_account_no'],
182 _("Sales Person") => $this->formData['contact'],
183 _("Your VAT no.") => $this->formData['tax_id'],
184 _("Supplier's Reference") => $this->formData['requisition_no'],
185 _("Order Date") => sql2date($this->formData['document_date']),
188 $this->headers = array(_("Item Code"), _("Item Description"),
189 _("Delivery Date"), _("Quantity"), _("Unit"), _("Price"), _("Total"));
193 global $systypes_array;
195 $this->title = _("RECEIPT");
196 $this->formData['document_name'] =_("Receipt No.");
197 $Addr1['title'] = _("With thanks from");
199 _("Customer's Reference") => $this->formData["debtor_ref"],
200 _("Type") =>$systypes_array[$this->formData["type"]],
201 _("Your VAT no.") => $this->formData['tax_id'],
202 _("Our Order No") => $this->formData['order_'],
203 _("Due Date") => sql2date($this->formData['tran_date']),
205 $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("Due Date"), _("Total Amount"), _("Left to Allocate"), _("This Allocation"));
209 global $wo_types_array;
211 $this->title = _("WORK ORDER");
212 $this->formData['document_name'] =_("Work Order No.");
213 $this->formData['document_date'] = $this->formData['date_'];
214 $this->formData['document_number'] = $this->formData['id'];
215 $Addr1['name'] = $this->formData['location_name'];
216 $Addr1['address'] = $this->formData['delivery_address'];
218 _("Reference") => $this->formData['wo_ref'],
219 _("Type") => $wo_types_array[$this->formData["type"]],
220 _("Manufactured Item") => $this->formData["StockItemName"],
221 _("Into Location") => $this->formData["location_name"],
222 _("Quantity") => $this->formData["units_issued"],
224 $Payment_Terms = _("Required By").": ".sql2date($this->formData["required_by"]);
225 $this->headers = array(_("Item Code"), _("Item Description"),
226 _("From Location"), _("Work Centre"), _("Unit Quantity"), _("Total Quantity"), _("Units Issued"));
232 $this->formData['document_name'] = '';
233 $this->formData['domicile'] = $this->company['domicile'];
235 $this->title = _("STATEMENT");
237 _("Customer's Reference") => '',
238 _("Sales Person") => '',
239 _("Your VAT no.") => $this->formData['tax_id'],
240 _("Our Order No") => '',
241 _("Delivery Date") => '',
243 $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("DueDate"), _("Charges"),
244 _("Credits"), _("Allocated"), _("Outstanding"));
248 if (!isset($this->formData['document_date']))
249 $this->formData['document_date'] = $this->formData['tran_date'];
251 if (!isset($this->formData['document_number']))
252 $this->formData['document_number'] = $SysPrefs->print_invoice_no() == 0 && isset($this->formData['reference'])
253 ? $this->formData['reference'] : @$this->formData['trans_no'];
255 // footer generic content
256 if (@$this->formData['bank_name'])
257 $Footer[] = _("Bank"). ": ".$this->formData['bank_name']. ", " . _("Bank Account") . ": " . $this->formData['bank_account_number'];
259 if (@$this->formData['payment_service']) //payment link
261 $amt = number_format($this->formData["ov_freight"] + $this->formData["ov_gst"] + $this->formData["ov_amount"], user_price_dec());
262 $service = $this->formData['payment_service'];
263 $url = payment_link($service, array(
264 'company_email' => $this->company['email'],
266 'currency' => $this->formData['curr_code'],
267 'comment' => $this->title . " " . $this->formData['reference']
269 $Footer[_("You can pay through"). " $service: "] = "$url";
272 if ($this->formData['doctype'] == ST_CUSTPAYMENT)
273 $Footer[] = _("* Subject to Realisation of the Cheque.");
275 if ($this->params['comments'] != '')
276 $Footer[] = $this->params['comments'];
278 if (($this->formData['doctype'] == ST_SALESINVOICE || $this->formData['doctype'] == ST_STATEMENT) && $this->company['legal_text'] != "")
280 foreach(explode("\n", $this->company['legal_text']) as $line)
284 $this->formData['recipient_name'] = $Addr1['name'];