73bdaa10ed9353971145b0b0459f252d249c8810
[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'] = $print_invoice_no == 0 && isset($this->formData['reference'])
42                                 ? $this->formData['reference'] : $this->formData['order_no'];
43                         $aux_info = array(
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']),
49                         );
50                         break;
51
52                 case ST_SALESORDER:
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'];
59
60                         $aux_info = array(
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']),
66                         );
67                         break;
68
69                 case ST_CUSTDELIVERY:
70                         $this->title = ($packing_slip==1 ? _("PACKING SLIP") : _("DELIVERY NOTE"));
71                         $this->formData['document_name'] = _("Delivery Note No.");
72                         if (@$packing_slip)
73                                 $Payment_Terms = '';
74                         $ref = $this->formData['order_'];
75                         if ($print_invoice_no == 0)
76                         {
77                                 $ref = get_reference(ST_SALESORDER, $this->formData['order_']);
78                                 if (!$ref)
79                                         $ref = $this->formData['order_'];
80                         }
81                         $aux_info = array(
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']),
87                         );
88                         break;
89
90                 case ST_CUSTCREDIT:
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'];
94
95                         $aux_info = array(
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_'],
100                                 _("Due Date") => '',
101                         );
102                         break;
103
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'];
109
110                         $deliveries = get_sales_parent_numbers(ST_SALESINVOICE, $this->formData['trans_no']);
111                         if ($print_invoice_no == 0)
112                         {
113                                 foreach($deliveries as $n => $delivery) {
114                                         $deliveries[$n] = get_reference(ST_CUSTDELIVERY, $delivery);
115                                 }
116                         }
117                         $aux_info = array(
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']),
123                         );
124                         break;
125
126                 case ST_SUPPAYMENT:
127                         global $systypes_array;
128
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");
135                         $Addr2['name'] = '';
136                         $Addr2['address'] = '';
137
138                         $aux_info = array(
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']),
144                         );
145                         $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("Due Date"), _("Total Amount"), _("Left to Allocate"), _("This Allocation"));
146                         break;
147
148                 case ST_PURCHORDER:
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'];
160
161                         $aux_info = array(
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']),
167                         );
168
169                         $this->headers = array(_("Item Code"), _("Item Description"),
170                                 _("Delivery Date"), _("Quantity"),      _("Unit"), _("Price"), _("Total"));
171                         break;
172
173                 case ST_CUSTPAYMENT:
174                         global $systypes_array;
175
176                         $this->title = _("RECEIPT");
177                         $this->formData['document_name'] =_("Receipt No.");
178                         $Addr1['title'] = _("With thanks from");
179                         $aux_info = array(
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']),
185                         );
186                         $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("Due Date"), _("Total Amount"), _("Left to Allocate"), _("This Allocation"));
187                         break;
188
189                 case ST_WORKORDER:
190                         global $wo_types_array;
191
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'];
198                         $aux_info = array(
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"],
204                         );
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"));
208                         unset($Footer[0]);
209                         break;
210
211
212                 case ST_STATEMENT:
213                         $this->formData['document_name'] = '';
214                         $this->formData['domicile'] = $this->company['domicile'];
215                         $Payment_Terms = '';
216                         $this->title = _("STATEMENT");
217                         $aux_info = array(
218                                 _("Customer's Reference") => '',
219                                 _("Sales Person") => '',
220                                 _("Your VAT no.") => $this->formData['tax_id'],
221                                 _("Our Order No") => '',
222                                 _("Delivery Date") => '',
223                         );
224                         $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("DueDate"), _("Charges"),
225                                 _("Credits"), _("Allocated"), _("Outstanding"));
226         }
227
228         // default values
229         if (!isset($this->formData['document_date']))
230                 $this->formData['document_date'] = $this->formData['tran_date'];
231
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'];
235
236         if (!isset($Payment_Terms))
237         {
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"];
243         }
244
245         // footer generic content
246         if (@$this->formData['bank_name'])
247                 $Footer[] = _("Bank"). ": ".$this->formData['bank_name']. ", " . _("Bank Account") . ": " . $this->formData['bank_account_number'];
248
249         if (@$this->formData['payment_service'])        //payment link
250         {
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'],
255                         'amount' => $amt,
256                         'currency' => $this->formData['curr_code'],
257                         'comment' => $this->title . " " . $this->formData['reference']
258                         ));
259                 $Footer[_("You can pay through"). " $service: "] = "$url";
260         }
261
262         if ($this->formData['doctype'] == ST_CUSTPAYMENT)
263                 $Footer[] = _("* Subject to Realisation of the Cheque.");
264
265         if ($this->params['comments'] != '')
266                 $Footer[] = $this->params['comments'];
267
268         if (($this->formData['doctype'] == ST_SALESINVOICE || $this->formData['doctype'] == ST_STATEMENT) && $this->company['legal_text'] != "") 
269         {
270                 foreach(explode("\n", $this->company['legal_text']) as $line)
271                         $Footer[] = $line;
272         }
273
274 ?>