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'] = $print_invoice_no == 0 && isset($this->formData['reference'])
157 ? $this->formData['reference'] : $this->formData['order_no'];
160 _("Customers Reference") => $this->formData['supp_account_no'],
161 _("Sales Person") => '',
162 _("Your VAT no.") => '',
163 _("Our Order No") => '',
167 $this->headers = array(_("Item Code"), _("Item Description"),
168 _("Delivery Date"), _("Quantity"), _("Unit"), _("Price"), _("Total"));
172 global $systypes_array;
174 $this->title = _("RECEIPT");
175 $this->formData['document_name'] =_("Receipt No.");
176 $Addr1['title'] = _("With thanks from");
178 _("Customers Reference") => $this->formData["debtor_ref"],
179 _("Type") =>$systypes_array[$this->formData["type"]],
180 _("Your VAT no.") => $this->formData['tax_id'],
181 _("Our Order No") => $this->formData['order_'],
182 _("Due Date") => sql2date($this->formData['tran_date']),
184 $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("Due Date"), _("Total Amount"), _("Left to Allocate"), _("This Allocation"));
188 global $wo_types_array;
190 $this->title = _("WORK ORDER");
191 $this->formData['document_name'] =_("Work Order No.");
192 $this->formData['document_date'] = $this->formData['date_'];
193 $this->formData['document_number'] = $this->formData['id'];
194 $Addr1['name'] = $this->formData['location_name'];
195 $Addr1['address'] = $this->formData['delivery_address'];
197 _("Reference") => $this->formData['wo_ref'],
198 _("Type") => $wo_types_array[$this->formData["type"]],
199 _("Manufactured Item") => $this->formData["StockItemName"],
200 _("Into Location") => $this->formData["location_name"],
201 _("Quantity") => $this->formData["units_issued"],
203 $Payment_Terms = _("Required By").": ".sql2date($this->formData["required_by"]);
204 $this->headers = array(_("Item Code"), _("Item Description"),
205 _("From Location"), _("Work Centre"), _("Unit Quantity"), _("Total Quantity"), _("Units Issued"));
211 $this->formData['document_name'] = '';
212 $this->formData['domicile'] = $this->company['domicile'];
214 $this->title = _("STATEMENT");
216 _("Customers Reference") => '',
217 _("Sales Person") => '',
218 _("Your VAT no.") => $this->formData['tax_id'],
219 _("Our Order No") => '',
220 _("Delivery Date") => '',
222 $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("DueDate"), _("Charges"),
223 _("Credits"), _("Allocated"), _("Outstanding"));
227 if (!isset($this->formData['document_date']))
228 $this->formData['document_date'] = $this->formData['tran_date'];
230 if (!isset($this->formData['document_number']))
231 $this->formData['document_number'] = $print_invoice_no == 0 && isset($this->formData['reference'])
232 ? $this->formData['reference'] : @$this->formData['trans_no'];
234 if (!isset($Payment_Terms))
236 $id = $this->formData['payment_terms'];
237 $sql = "SELECT terms FROM ".TB_PREF."payment_terms WHERE terms_indicator=".db_escape($id);
238 $result = db_query($sql,"could not get paymentterms");
239 $row = db_fetch($result);
240 $Payment_Terms = _("Payment Terms") . ': ' . $row["terms"];
243 // footer generic content
244 if (@$this->formData['bank_name'])
245 $Footer[] = _("Bank"). ": ".$this->formData['bank_name']. ", " . _("Bank Account") . ": " . $this->formData['bank_account_number'];
247 if (@$this->formData['payment_service']) //payment link
249 $amt = number_format($this->formData["ov_freight"] + $this->formData["ov_gst"] + $this->formData["ov_amount"], user_price_dec());
250 $service = $this->formData['payment_service'];
251 $url = payment_link($service, array(
252 'company_email' => $this->company['email'],
254 'currency' => $this->formData['curr_code'],
255 'comment' => $this->title . " " . $this->formData['reference']
257 $Footer[_("You can pay through"). " $service: "] = "$url";
260 if ($this->formData['doctype'] == ST_CUSTPAYMENT)
261 $Footer[] = _("* Subject to Realisation of the Cheque.");
263 if ($this->params['comments'] != '')
264 $Footer[] = $this->params['comments'];
266 if (($this->formData['doctype'] == ST_SALESINVOICE || $this->formData['doctype'] == ST_STATEMENT) && $this->company['legal_text'] != "")
268 foreach(explode("\n", $this->company['legal_text']) as $line)