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