Added missing aux info on sales order/quotation reports.
[fa-stable.git] / reporting / includes / doctext.inc
1 <?php
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 ***********************************************************************/
12 /*****
13 *
14 *       Set document type dependent elements of common page layout.
15 *
16 */
17         $Addr1 = array(
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']
21         );
22         $Addr2 = array(
23                         'title' => _("Delivered To"),
24                         'name' => @$this->formData['deliver_to'],
25                         'address' => @$this->formData['delivery_address']
26         );
27
28         // default item column headers
29         $this->headers = array(_("Item Code"), _("Item Description"), _("Quantity"),
30                 _("Unit"), _("Price"), _("Discount %"), _("Total"));
31
32         // for links use 'text' => 'url'
33         $Footer[0] = _("All amounts stated in") . " - " . @$this->formData['curr_code'];
34
35         switch ($this->formData['doctype'])
36         {
37                 case ST_SALESQUOTE:
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'];
42                         $aux_info = array(
43                                 _("Customers Reference") => $this->formData["customer_ref"],
44                                 _("Sales Person") => get_salesman_name($this->formData['salesman']),
45                                 _("Your VAT no.") => $this->formData['tax_id'],
46                                 _("Our Quotation No") => $this->formData['order_no'],
47                                 _("Valid until") => sql2date($this->formData['delivery_date']),
48                         );
49                         break;
50
51                 case ST_SALESORDER:
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'];
57
58                         $aux_info = array(
59                                 _("Customers Reference") => $this->formData["customer_ref"],
60                                 _("Sales Person") => get_salesman_name($this->formData['salesman']),
61                                 _("Your VAT no.") => $this->formData['tax_id'],
62                                 _("Our Order No") => $this->formData['order_no'],
63                                 _("Delivery Date") => sql2date($this->formData['delivery_date']),
64                         );
65                         break;
66
67                 case ST_CUSTDELIVERY:
68                         $this->title = ($packing_slip==1 ? _("PACKING SLIP") : _("DELIVERY NOTE"));
69                         $this->formData['document_name'] = _("Delivery Note No.");
70                         if (@$packing_slip)
71                                 $Payment_Terms = '';
72                         $ref = $this->formData['order_'];
73                         if ($print_invoice_no == 0)
74                         {
75                                 $ref = get_reference(ST_SALESORDER, $this->formData['order_']);
76                                 if (!$ref)
77                                         $ref = $this->formData['order_'];
78                         }
79                         $aux_info = array(
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']),
85                         );
86                         break;
87
88                 case ST_CUSTCREDIT:
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'];
92
93                         $aux_info = array(
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_'],
98                                 _("Due Date") => '',
99                         );
100                         break;
101
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'];
107
108                         $deliveries = get_sales_parent_numbers(ST_SALESINVOICE, $this->formData['trans_no']);
109                         if ($print_invoice_no == 0)
110                         {
111                                 foreach($deliveries as $n => $delivery) {
112                                         $deliveries[$n] = get_reference(ST_CUSTDELIVERY, $delivery);
113                                 }
114                         }
115                         $aux_info = array(
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']),
121                         );
122                         break;
123
124                 case ST_SUPPAYMENT:
125                         global $systypes_array;
126
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");
133                         $Addr2['name'] = '';
134                         $Addr2['address'] = '';
135
136                         $aux_info = array(
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']),
142                         );
143                         $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("Due Date"), _("Total Amount"), _("Left to Allocate"), _("This Allocation"));
144                         break;
145
146                 case ST_PURCHORDER:
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'];
158
159                         $aux_info = array(
160                                 _("Customers Reference") => $this->formData['supp_account_no'],
161                                 _("Sales Person") => '',
162                                 _("Your VAT no.") => '',
163                                 _("Our Order No") => '',
164                                 _("Due Date") => '',
165                         );
166
167                         $this->headers = array(_("Item Code"), _("Item Description"),
168                                 _("Delivery Date"), _("Quantity"),      _("Unit"), _("Price"), _("Total"));
169                         break;
170
171                 case ST_CUSTPAYMENT:
172                         global $systypes_array;
173
174                         $this->title = _("RECEIPT");
175                         $this->formData['document_name'] =_("Receipt No.");
176                         $Addr1['title'] = _("With thanks from");
177                         $aux_info = array(
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']),
183                         );
184                         $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("Due Date"), _("Total Amount"), _("Left to Allocate"), _("This Allocation"));
185                         break;
186
187                 case ST_WORKORDER:
188                         global $wo_types_array;
189
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'];
196                         $aux_info = array(
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"],
202                         );
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"));
206                         unset($Footer[0]);
207                         break;
208
209
210                 case ST_STATEMENT:
211                         $this->formData['document_name'] = '';
212                         $this->formData['domicile'] = $this->company['domicile'];
213                         $Payment_Terms = '';
214                         $this->title = _("STATEMENT");
215                         $aux_info = array(
216                                 _("Customers Reference") => '',
217                                 _("Sales Person") => '',
218                                 _("Your VAT no.") => $this->formData['tax_id'],
219                                 _("Our Order No") => '',
220                                 _("Delivery Date") => '',
221                         );
222                         $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("DueDate"), _("Charges"),
223                                 _("Credits"), _("Allocated"), _("Outstanding"));
224         }
225
226         // default values
227         if (!isset($this->formData['document_date']))
228                 $this->formData['document_date'] = $this->formData['tran_date'];
229
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'];
233
234         if (!isset($Payment_Terms))
235         {
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"];
241         }
242
243         // footer generic content
244         if (@$this->formData['bank_name'])
245                 $Footer[] = _("Bank"). ": ".$this->formData['bank_name']. ", " . _("Bank Account") . ": " . $this->formData['bank_account_number'];
246
247         if (@$this->formData['payment_service'])        //payment link
248         {
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'],
253                         'amount' => $amt,
254                         'currency' => $this->formData['curr_code'],
255                         'comment' => $this->title . " " . $this->formData['reference']
256                         ));
257                 $Footer[_("You can pay through"). " $service: "] = "$url";
258         }
259
260         if ($this->formData['doctype'] == ST_CUSTPAYMENT)
261                 $Footer[] = _("* Subject to Realisation of the Cheque.");
262
263         if ($this->params['comments'] != '')
264                 $Footer[] = $this->params['comments'];
265
266         if (($this->formData['doctype'] == ST_SALESINVOICE || $this->formData['doctype'] == ST_STATEMENT) && $this->company['legal_text'] != "") 
267         {
268                 foreach(explode("\n", $this->company['legal_text']) as $line)
269                         $Footer[] = $line;
270         }
271
272 ?>