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'] = $print_invoice_no == 0 && isset($this->formData['reference'])
42 ? $this->formData['reference'] : $this->formData['order_no'];
44 _("Customer's Reference") => $this->formData["customer_ref"],
45 _("Sales Person") => get_salesman_name($this->formData['salesman']),
46 _("Your VAT no.") => $this->formData['tax_id'],
47 _("Our Quotation No") => $this->formData['order_no'],
48 _("Valid until") => sql2date($this->formData['delivery_date']),
53 $this->title = ($print_as_quote==1 ? _("QUOTE") : _("SALES ORDER"));
54 $this->formData['document_name'] =_("Order No.");
55 $this->formData['document_date'] = $this->formData['ord_date'];
56 $this->formData['document_number'] = $print_invoice_no == 0 && isset($this->formData['reference'])
57 ? $this->formData['reference'] : $this->formData['order_no'];
58 $this->formData['document_amount'] = $this->formData['order_no'];
61 _("Customer's Reference") => $this->formData["customer_ref"],
62 _("Sales Person") => get_salesman_name($this->formData['salesman']),
63 _("Your VAT no.") => $this->formData['tax_id'],
64 _("Our Order No") => $this->formData['order_no'],
65 _("Delivery Date") => sql2date($this->formData['delivery_date']),
70 $this->title = ($packing_slip==1 ? _("PACKING SLIP") : _("DELIVERY NOTE"));
71 $this->formData['document_name'] = _("Delivery Note No.");
74 $ref = $this->formData['order_'];
75 if ($print_invoice_no == 0)
77 $ref = get_reference(ST_SALESORDER, $this->formData['order_']);
79 $ref = $this->formData['order_'];
82 _("Customer's Reference") => $this->formData["customer_ref"],
83 _("Sales Person") => get_salesman_name($this->formData['salesman']),
84 _("Your VAT no.") => $this->formData['tax_id'],
85 _("Our Order No") => $ref,
86 _("To Be Invoiced Before") => sql2date($this->formData['due_date']),
91 $this->title = _("CREDIT NOTE");
92 $this->formData['document_name'] =_("Credit No.");
93 $Footer[0] = _("Please quote Credit no. when paying. All amounts stated in") . " - " . $this->formData['curr_code'];
96 _("Customer's Reference") => @$this->formData["customer_ref"],
97 _("Sales Person") => get_salesman_name($this->formData['salesman']),
98 _("Your VAT no.") => $this->formData['tax_id'],
99 _("Our Order No") => $this->formData['order_'],
104 case ST_SALESINVOICE:
105 $this->title = _("INVOICE");
106 $this->formData['document_name'] =_("Invoice No.");
107 $this->formData['domicile'] = $this->company['domicile'];
108 $Footer[0] = _("Please quote Invoice no. when paying. All amounts stated in"). " - " . $this->formData['curr_code'];
110 $deliveries = get_sales_parent_numbers(ST_SALESINVOICE, $this->formData['trans_no']);
111 if ($print_invoice_no == 0)
113 foreach($deliveries as $n => $delivery) {
114 $deliveries[$n] = get_reference(ST_CUSTDELIVERY, $delivery);
118 _("Customer's Reference") => $this->formData["customer_ref"],
119 _("Sales Person") => get_salesman_name($this->formData['salesman']),
120 _("Your VAT no.") => $this->formData['tax_id'],
121 _("Delivery Note No.") => implode(',', $deliveries),
122 _("Due Date") => sql2date($this->formData['due_date']),
127 global $systypes_array;
129 $this->title = _("REMITTANCE");
130 $this->formData['document_name'] =_("Remittance No.");
131 $Addr1['title'] = _("Order To");
132 $Addr1['name'] = $this->formData['supp_name'];
133 $Addr1['address'] = $this->formData['address'];
134 $Addr2['title'] = _("Charge To");
136 $Addr2['address'] = '';
139 _("Customer's Reference") => $this->formData['supp_account_no'],
140 _("Type") =>$systypes_array[$this->formData["type"]],
141 _("Your VAT no.") => $this->formData['tax_id'],
142 _("Supplier's Reference") => '',
143 _("Due Date") => sql2date($this->formData['tran_date']),
145 $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("Due Date"), _("Total Amount"), _("Left to Allocate"), _("This Allocation"));
149 $this->title = _("PURCHASE ORDER");
150 $this->formData['document_name'] =_("Purchase Order No.");
151 $Addr1['title'] = _("Order To");
152 $Addr1['name'] = $this->formData['supp_name'];
153 $Addr1['address'] = $this->formData['address'];
154 $Addr2['title'] = _("Deliver To");
155 $Addr2['name'] = $this->company['coy_name'];
156 //$Addr2['address'] = $this->company['postal_address']; No, don't destroy delivery address!
157 $this->formData['document_date'] = $this->formData['ord_date'];
158 $this->formData['document_number'] = $print_invoice_no == 0 && isset($this->formData['reference'])
159 ? $this->formData['reference'] : $this->formData['order_no'];
162 _("Customer's Reference") => $this->formData['supp_account_no'],
163 _("Sales Person") => $this->formData['contact'],
164 _("Your VAT no.") => $this->formData['tax_id'],
165 _("Supplier's Reference") => $this->formData['requisition_no'],
166 _("Order Date") => sql2date($this->formData['document_date']),
169 $this->headers = array(_("Item Code"), _("Item Description"),
170 _("Delivery Date"), _("Quantity"), _("Unit"), _("Price"), _("Total"));
174 global $systypes_array;
176 $this->title = _("RECEIPT");
177 $this->formData['document_name'] =_("Receipt No.");
178 $Addr1['title'] = _("With thanks from");
180 _("Customer's Reference") => $this->formData["debtor_ref"],
181 _("Type") =>$systypes_array[$this->formData["type"]],
182 _("Your VAT no.") => $this->formData['tax_id'],
183 _("Our Order No") => $this->formData['order_'],
184 _("Due Date") => sql2date($this->formData['tran_date']),
186 $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("Due Date"), _("Total Amount"), _("Left to Allocate"), _("This Allocation"));
190 global $wo_types_array;
192 $this->title = _("WORK ORDER");
193 $this->formData['document_name'] =_("Work Order No.");
194 $this->formData['document_date'] = $this->formData['date_'];
195 $this->formData['document_number'] = $this->formData['id'];
196 $Addr1['name'] = $this->formData['location_name'];
197 $Addr1['address'] = $this->formData['delivery_address'];
199 _("Reference") => $this->formData['wo_ref'],
200 _("Type") => $wo_types_array[$this->formData["type"]],
201 _("Manufactured Item") => $this->formData["StockItemName"],
202 _("Into Location") => $this->formData["location_name"],
203 _("Quantity") => $this->formData["units_issued"],
205 $Payment_Terms = _("Required By").": ".sql2date($this->formData["required_by"]);
206 $this->headers = array(_("Item Code"), _("Item Description"),
207 _("From Location"), _("Work Centre"), _("Unit Quantity"), _("Total Quantity"), _("Units Issued"));
213 $this->formData['document_name'] = '';
214 $this->formData['domicile'] = $this->company['domicile'];
216 $this->title = _("STATEMENT");
218 _("Customer's Reference") => '',
219 _("Sales Person") => '',
220 _("Your VAT no.") => $this->formData['tax_id'],
221 _("Our Order No") => '',
222 _("Delivery Date") => '',
224 $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("DueDate"), _("Charges"),
225 _("Credits"), _("Allocated"), _("Outstanding"));
229 if (!isset($this->formData['document_date']))
230 $this->formData['document_date'] = $this->formData['tran_date'];
232 if (!isset($this->formData['document_number']))
233 $this->formData['document_number'] = $print_invoice_no == 0 && isset($this->formData['reference'])
234 ? $this->formData['reference'] : @$this->formData['trans_no'];
236 if (!isset($Payment_Terms))
238 $id = $this->formData['payment_terms'];
239 $sql = "SELECT terms FROM ".TB_PREF."payment_terms WHERE terms_indicator=".db_escape($id);
240 $result = db_query($sql,"could not get paymentterms");
241 $row = db_fetch($result);
242 $Payment_Terms = _("Payment Terms") . ': ' . $row["terms"];
245 // footer generic content
246 if (@$this->formData['bank_name'])
247 $Footer[] = _("Bank"). ": ".$this->formData['bank_name']. ", " . _("Bank Account") . ": " . $this->formData['bank_account_number'];
249 if (@$this->formData['payment_service']) //payment link
251 $amt = number_format($this->formData["ov_freight"] + $this->formData["ov_gst"] + $this->formData["ov_amount"], user_price_dec());
252 $service = $this->formData['payment_service'];
253 $url = payment_link($service, array(
254 'company_email' => $this->company['email'],
256 'currency' => $this->formData['curr_code'],
257 'comment' => $this->title . " " . $this->formData['reference']
259 $Footer[_("You can pay through"). " $service: "] = "$url";
262 if ($this->formData['doctype'] == ST_CUSTPAYMENT)
263 $Footer[] = _("* Subject to Realisation of the Cheque.");
265 if ($this->params['comments'] != '')
266 $Footer[] = $this->params['comments'];
268 if (($this->formData['doctype'] == ST_SALESINVOICE || $this->formData['doctype'] == ST_STATEMENT) && $this->company['legal_text'] != "")
270 foreach(explode("\n", $this->company['legal_text']) as $line)
274 $this->formData['recipient_name'] = $Addr1['name'];