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 $id = $this->formData['payment_terms'];
38 $sql = "SELECT terms, days_before_due FROM ".TB_PREF."payment_terms WHERE terms_indicator=".db_escape($id);
39 $result = db_query($sql,"could not get paymentterms");
40 $row = db_fetch($result);
41 $Payment_Terms = _("Payment Terms") . ': ' . $row["terms"];
42 if ($this->formData['doctype'] == ST_SALESINVOICE && $this->formData['prepaid'])
43 $this->formData['prepaid'] = ($row['days_before_due'] >= 0) ? 'final' : 'partial';
47 switch ($this->formData['doctype'])
50 $this->title = _("SALES QUOTATION");
51 $this->formData['document_name'] =_("Quotation No.");
52 $this->formData['document_date'] = $this->formData['ord_date'];
53 $this->formData['document_number'] = $print_invoice_no == 0 && isset($this->formData['reference'])
54 ? $this->formData['reference'] : $this->formData['order_no'];
56 _("Customer's Reference") => $this->formData["customer_ref"],
57 _("Sales Person") => get_salesman_name($this->formData['salesman']),
58 _("Your VAT no.") => $this->formData['tax_id'],
59 _("Our Quotation No") => $this->formData['order_no'],
60 _("Valid until") => sql2date($this->formData['delivery_date']),
65 $this->title = ($print_as_quote==1 ? _("QUOTE") : ($this->formData['prepaid'] ? _("PREPAYMENT ORDER") : _("SALES ORDER")));
66 $this->formData['document_name'] =_("Order No.");
67 $this->formData['document_date'] = $this->formData['ord_date'];
68 $this->formData['document_number'] = $print_invoice_no == 0 && isset($this->formData['reference'])
69 ? $this->formData['reference'] : $this->formData['order_no'];
70 $this->formData['document_amount'] = $this->formData['order_no'];
73 _("Customer's Reference") => $this->formData["customer_ref"],
74 _("Sales Person") => get_salesman_name($this->formData['salesman']),
75 _("Your VAT no.") => $this->formData['tax_id'],
76 _("Our Order No") => $this->formData['order_no'],
77 _("Delivery Date") => sql2date($this->formData['delivery_date']),
82 $this->title = ($packing_slip==1 ? _("PACKING SLIP") : _("DELIVERY NOTE"));
83 $this->formData['document_name'] = _("Delivery Note No.");
86 $ref = $this->formData['order_'];
87 if ($print_invoice_no == 0)
89 $ref = get_reference(ST_SALESORDER, $this->formData['order_']);
91 $ref = $this->formData['order_'];
94 _("Customer's 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") => $ref,
98 _("To Be Invoiced Before") => sql2date($this->formData['due_date']),
103 $this->title = _("CREDIT NOTE");
104 $this->formData['document_name'] =_("Credit No.");
105 $Footer[0] = _("Please quote Credit no. when paying. All amounts stated in") . " - " . $this->formData['curr_code'];
108 _("Customer's Reference") => @$this->formData["customer_ref"],
109 _("Sales Person") => get_salesman_name($this->formData['salesman']),
110 _("Your VAT no.") => $this->formData['tax_id'],
111 _("Our Order No") => $this->formData['order_'],
116 case ST_SALESINVOICE:
117 $this->title = $this->formData['prepaid']=='partial' ? _("PREPAYMENT INVOICE")
118 : ($this->formData['prepaid']=='final' ? _("FINAL INVOICE") : _("INVOICE"));
119 $this->formData['document_name'] =_("Invoice No.");
120 $this->formData['domicile'] = $this->company['domicile'];
121 $Footer[0] = _("Please quote Invoice no. when paying. All amounts stated in"). " - " . $this->formData['curr_code'];
123 $deliveries = get_sales_parent_numbers(ST_SALESINVOICE, $this->formData['trans_no']);
124 if ($print_invoice_no == 0)
126 foreach($deliveries as $n => $delivery) {
127 $deliveries[$n] = get_reference(ST_CUSTDELIVERY, $delivery);
131 _("Customer's Reference") => $this->formData["customer_ref"],
132 _("Sales Person") => get_salesman_name($this->formData['salesman']),
133 _("Your VAT no.") => $this->formData['tax_id'],
135 if ($this->formData['prepaid']=='partial')
137 $aux_info[_("Date of Payment")] = sql2date(get_oldest_payment_date($this->formData['trans_no']));
138 $aux_info[_("Our Order No")] = $this->formData['order_'];
140 if ($this->formData['prepaid'] =='final')
141 $aux_info[_("Invoice Date")] = sql2date($this->formData['tran_date']);
143 $aux_info[_("Date of Sale")] = sql2date(get_oldest_delivery_date($this->formData['trans_no']));
144 $aux_info[_("Due Date")] = sql2date($this->formData['due_date']);
149 global $systypes_array;
151 $this->title = _("REMITTANCE");
152 $this->formData['document_name'] =_("Remittance No.");
153 $Addr1['title'] = _("Order To");
154 $Addr1['name'] = $this->formData['supp_name'];
155 $Addr1['address'] = $this->formData['address'];
156 $Addr2['title'] = _("Charge To");
158 $Addr2['address'] = '';
161 _("Customer's Reference") => $this->formData['supp_account_no'],
162 _("Type") =>$systypes_array[$this->formData["type"]],
163 _("Your VAT no.") => $this->formData['tax_id'],
164 _("Supplier's Reference") => '',
165 _("Due Date") => sql2date($this->formData['tran_date']),
167 $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("Due Date"), _("Total Amount"), _("Left to Allocate"), _("This Allocation"));
171 $this->title = _("PURCHASE ORDER");
172 $this->formData['document_name'] =_("Purchase Order No.");
173 $Addr1['title'] = _("Order To");
174 $Addr1['name'] = $this->formData['supp_name'];
175 $Addr1['address'] = $this->formData['address'];
176 $Addr2['title'] = _("Deliver To");
177 $Addr2['name'] = $this->company['coy_name'];
178 //$Addr2['address'] = $this->company['postal_address']; No, don't destroy delivery address!
179 $this->formData['document_date'] = $this->formData['ord_date'];
180 $this->formData['document_number'] = $print_invoice_no == 0 && isset($this->formData['reference'])
181 ? $this->formData['reference'] : $this->formData['order_no'];
184 _("Customer's Reference") => $this->formData['supp_account_no'],
185 _("Sales Person") => $this->formData['contact'],
186 _("Your VAT no.") => $this->formData['tax_id'],
187 _("Supplier's Reference") => $this->formData['requisition_no'],
188 _("Order Date") => sql2date($this->formData['document_date']),
191 $this->headers = array(_("Item Code"), _("Item Description"),
192 _("Delivery Date"), _("Quantity"), _("Unit"), _("Price"), _("Total"));
196 global $systypes_array;
198 $this->title = _("RECEIPT");
199 $this->formData['document_name'] =_("Receipt No.");
200 $Addr1['title'] = _("With thanks from");
202 _("Customer's Reference") => $this->formData["debtor_ref"],
203 _("Type") =>$systypes_array[$this->formData["type"]],
204 _("Your VAT no.") => $this->formData['tax_id'],
205 _("Our Order No") => $this->formData['order_'],
206 _("Due Date") => sql2date($this->formData['tran_date']),
208 $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("Due Date"), _("Total Amount"), _("Left to Allocate"), _("This Allocation"));
212 global $wo_types_array;
214 $this->title = _("WORK ORDER");
215 $this->formData['document_name'] =_("Work Order No.");
216 $this->formData['document_date'] = $this->formData['date_'];
217 $this->formData['document_number'] = $this->formData['id'];
218 $Addr1['name'] = $this->formData['location_name'];
219 $Addr1['address'] = $this->formData['delivery_address'];
221 _("Reference") => $this->formData['wo_ref'],
222 _("Type") => $wo_types_array[$this->formData["type"]],
223 _("Manufactured Item") => $this->formData["StockItemName"],
224 _("Into Location") => $this->formData["location_name"],
225 _("Quantity") => $this->formData["units_issued"],
227 $Payment_Terms = _("Required By").": ".sql2date($this->formData["required_by"]);
228 $this->headers = array(_("Item Code"), _("Item Description"),
229 _("From Location"), _("Work Centre"), _("Unit Quantity"), _("Total Quantity"), _("Units Issued"));
235 $this->formData['document_name'] = '';
236 $this->formData['domicile'] = $this->company['domicile'];
238 $this->title = _("STATEMENT");
240 _("Customer's Reference") => '',
241 _("Sales Person") => '',
242 _("Your VAT no.") => $this->formData['tax_id'],
243 _("Our Order No") => '',
244 _("Delivery Date") => '',
246 $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("DueDate"), _("Charges"),
247 _("Credits"), _("Allocated"), _("Outstanding"));
251 if (!isset($this->formData['document_date']))
252 $this->formData['document_date'] = $this->formData['tran_date'];
254 if (!isset($this->formData['document_number']))
255 $this->formData['document_number'] = $print_invoice_no == 0 && isset($this->formData['reference'])
256 ? $this->formData['reference'] : @$this->formData['trans_no'];
258 // footer generic content
259 if (@$this->formData['bank_name'])
260 $Footer[] = _("Bank"). ": ".$this->formData['bank_name']. ", " . _("Bank Account") . ": " . $this->formData['bank_account_number'];
262 if (@$this->formData['payment_service']) //payment link
264 $amt = number_format($this->formData["ov_freight"] + $this->formData["ov_gst"] + $this->formData["ov_amount"], user_price_dec());
265 $service = $this->formData['payment_service'];
266 $url = payment_link($service, array(
267 'company_email' => $this->company['email'],
269 'currency' => $this->formData['curr_code'],
270 'comment' => $this->title . " " . $this->formData['reference']
272 $Footer[_("You can pay through"). " $service: "] = "$url";
275 if ($this->formData['doctype'] == ST_CUSTPAYMENT)
276 $Footer[] = _("* Subject to Realisation of the Cheque.");
278 if ($this->params['comments'] != '')
279 $Footer[] = $this->params['comments'];
281 if (($this->formData['doctype'] == ST_SALESINVOICE || $this->formData['doctype'] == ST_STATEMENT) && $this->company['legal_text'] != "")
283 foreach(explode("\n", $this->company['legal_text']) as $line)
287 $this->formData['recipient_name'] = $Addr1['name'];