Eliminated non-static method calls and some more fixes to avoid log warnings on php4&5
[fa-stable.git] / includes / types.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 define('ST_JOURNAL', 0);
14
15 define('ST_BANKPAYMENT', 1);
16 define('ST_BANKDEPOSIT', 2);
17 define('ST_BANKTRANSFER', 4);
18
19 define('ST_SALESINVOICE', 10);
20 define('ST_CUSTCREDIT', 11);
21 define('ST_CUSTPAYMENT', 12);
22 define('ST_CUSTDELIVERY', 13);
23 define('ST_LOCTRANSFER', 16);
24 define('ST_INVADJUST', 17);
25 define('ST_PURCHORDER', 18);
26 define('ST_SUPPINVOICE', 20);
27 define('ST_SUPPCREDIT', 21);
28 define('ST_SUPPAYMENT', 22);
29 define('ST_SUPPRECEIVE', 25);
30
31 define('ST_WORKORDER', 26);
32
33 define('ST_SALESORDER', 30);
34 define('ST_SALESQUOTE', 32);
35 define('ST_COSTUPDATE', 35);
36 define('ST_DIMENSION', 40);
37
38 define('ST_MANUISSUE', 28);
39 define('ST_MANURECEIVE', 29);
40
41 $systypes_array = array (
42         ST_JOURNAL => _("Journal Entry"),
43         ST_BANKPAYMENT => _("Bank Payment"),
44         ST_BANKDEPOSIT => _("Bank Deposit"),
45         ST_BANKTRANSFER => _("Funds Transfer"),
46         ST_SALESINVOICE => _("Sales Invoice"),
47         ST_CUSTCREDIT => _("Customer Credit Note"),
48         ST_CUSTPAYMENT => _("Customer Payment"),
49         ST_CUSTDELIVERY => _("Delivery Note"),
50         ST_LOCTRANSFER => _("Location Transfer"),
51         ST_INVADJUST => _("Inventory Adjustment"),
52         ST_PURCHORDER => _("Purchase Order"),
53         ST_SUPPINVOICE => _("Supplier Invoice"),
54         ST_SUPPCREDIT => _("Supplier Credit Note"),
55         ST_SUPPAYMENT => _("Supplier Payment"),
56         ST_SUPPRECEIVE => _("Purchase Order Delivery"),
57         ST_WORKORDER => _("Work Order"),
58         ST_MANUISSUE => _("Work Order Issue"),
59         ST_MANURECEIVE => _("Work Order Production"),
60         ST_SALESORDER => _("Sales Order"),
61         ST_SALESQUOTE => _("Sales Quotation"),
62         ST_COSTUPDATE => _("Cost Update"),
63         ST_DIMENSION => _("Dimension")
64         );
65
66 //----------------------------------------------------------------------------------
67 define('BT_TRANSFER', 0);
68 define('BT_CHEQUE', 1);
69 define('BT_CREDIT', 2);
70 define('BT_CASH', 3);
71
72 $bank_account_types = array (
73         BT_TRANSFER => _("Savings Account"),
74                 _("Chequing Account"),
75                 _("Credit Account"),
76                 _("Cash Account")
77         );
78
79 $bank_transfer_types = array(
80         BT_TRANSFER => _("Transfer"),
81                         _("Cheque"),
82                         _("Credit"),
83                         _("Cash")
84         );
85
86 //----------------------------------------------------------------------------------
87 /* Menu tabs */
88 $tabs = array('orders'=>_("Sales"), 'AP'=>_("Purchases"), 'stock'=>_("Items and Inventory"), 'manuf'=>_("Manufacturing"), 
89         'proj'=>_("Dimensions"), 'GL'=>_("Banking and General Ledger"), 'system'=>_("Setup"));
90
91 //----------------------------------------------------------------------------------
92
93 include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc");
94 include_once($path_to_root . "/purchasing/includes/purchasing_db.inc");
95 include_once($path_to_root . "/sales/includes/sales_db.inc");
96 include_once($path_to_root . "/dimensions/includes/dimensions_db.inc");
97
98 define('PT_MISC', 0);
99 define('PT_WORKORDER', 1);
100 define('PT_CUSTOMER', 2);
101 define('PT_SUPPLIER', 3);
102 define('PT_QUICKENTRY', 4);
103 define('PT_DIMESION', 5);
104
105 $payment_person_types = array (
106         PT_MISC => _("Miscellaneous"),
107                                 _("Work Order"),
108                                 _("Customer"),
109                                 _("Supplier"),
110                                 _("Quick Entry")
111         );
112
113
114 function payment_person_currency($type, $person_id)  {
115         switch ($type)
116         {
117                 case PT_MISC :
118                 case PT_QUICKENTRY :
119                 case PT_WORKORDER :
120                         return get_company_currency();
121
122                 case PT_CUSTOMER :
123                         return get_customer_currency($person_id);
124
125                 case PT_SUPPLIER :
126                         return get_supplier_currency($person_id);
127
128                 default :
129                         return get_company_currency();
130         }
131 }
132
133 function payment_person_name($type, $person_id, $full=true) {
134         global $payment_person_types;
135
136         switch ($type)
137         {
138                 case PT_MISC :
139                         return $person_id;
140                 case PT_QUICKENTRY :
141                         $qe = get_quick_entry($person_id);
142                         return ($full ? $payment_person_types[$type] . " ":"") . $qe["description"];
143                 case PT_WORKORDER :
144                         global $wo_cost_types;
145                         return $wo_cost_types[$person_id];
146                 case PT_CUSTOMER :
147                         return ($full ?$payment_person_types[$type] . " ":"") . get_customer_name($person_id);
148                 case PT_SUPPLIER :
149                         return ($full ? $payment_person_types[$type] . " ":"") . get_supplier_name($person_id);
150                 default :
151                         //DisplayDBerror("Invalid type sent to person_name");
152                         //return;
153                         return '';
154         }
155 }
156
157 function payment_person_has_items($type) {
158         switch ($type)
159         {
160                 case PT_MISC :
161                         return true;
162                 case PT_QUICKENTRY :
163                         return db_has_quick_entries();
164                 case PT_WORKORDER : // 070305 changed to open workorders JH
165                         return db_has_open_workorders();
166                 case PT_CUSTOMER :
167                         return db_has_customers();
168                 case PT_SUPPLIER :
169                         return db_has_suppliers();
170                 default :
171                         display_db_error("Invalid type sent to has_items", "");
172                         return false;
173         }
174 }
175
176 //----------------------------------------------------------------------------------
177
178 define('WO_ASSEMBLY', 0);
179 define('WO_UNASSEMBLY', 1);
180 define('WO_ADVANCED', 2);
181
182 $wo_types_array = array (
183         WO_ASSEMBLY => _("Assemble"),
184         WO_UNASSEMBLY => _("Unassemble"),
185         WO_ADVANCED => _("Advanced Manufacture")
186         );
187
188 //----------------------------------------------------------------------------------
189
190 define('CL_NONE', 0); // for backward compatibility
191 define('CL_ASSETS', 1);
192 define('CL_LIABILITIES', 2);
193 define('CL_EQUITY', 3);
194 define('CL_INCOME', 4);
195 define('CL_COGS', 5);
196 define('CL_EXPENSE', 6);
197
198 $class_types = array(
199                 CL_ASSETS => _("Assets"),
200                 CL_LIABILITIES => _("Liabilities"),
201                 CL_EQUITY => _("Equity"),
202                 CL_INCOME => _("Income"),
203                 CL_COGS => _("Cost of Goods Sold"),
204                 CL_EXPENSE => _("Expense"),
205 );
206
207 function get_class_type_convert($ctype)
208 {
209         global $use_oldstyle_convert;
210         if (isset($use_oldstyle_convert) && $use_oldstyle_convert == 1)
211                 return (($ctype >= CL_INCOME || $ctype == CL_NONE) ? -1 : 1);
212         else    
213                 return ((($ctype >= CL_LIABILITIES && $ctype <= CL_INCOME) || $ctype == CL_NONE) ? -1 : 1);
214 }
215 define('WO_LABOUR', 0);
216 define('WO_OVERHEAD', 1);
217
218 $wo_cost_types = array(
219                 WO_LABOUR => _("Labour Cost"),
220                 WO_OVERHEAD => _("Overhead Cost"),
221 );
222
223 $quick_actions = array(
224         '=' => _('Remainder'), // post current base amount to GL account
225         'a' => _('Amount'), // post amount to GL account
226         'a+' => _('Amount, increase base'), // post amount to GL account and increase base
227         'a-' => _('Amount, reduce base'), // post amount to GL account and reduce base
228         '%' => _('% amount of base'),   // store acc*amount% to GL account
229         '%+' => _('% amount of base, increase base'),   // ditto & increase base amount
230         '%-' => _('% amount of base, reduce base'),     // ditto & reduce base amount
231         'T' => _('Taxes added'), // post taxes calculated on base amount
232         'T+' => _('Taxes added, increase base'), // ditto & increase base amount
233         'T-' => _('Taxes added, reduce base'), // ditto & reduce base amount
234         't' => _('Taxes included'), // post taxes calculated on base amount
235         't+' => _('Taxes included, increase base'), // ditto & increase base amount
236         't-' => _('Taxes included, reduce base') // ditto & reduce base amount
237 );
238
239 define('QE_PAYMENT', '1');
240 define('QE_DEPOSIT', '2');
241 define('QE_JOURNAL', '3');
242 define('QE_SUPPINV', '4');
243
244 $quick_entry_types = array(
245                 QE_DEPOSIT => _("Bank Deposit"),
246                 QE_PAYMENT => _("Bank Payment"),
247                 QE_JOURNAL => _("Journal Entry"),
248                 QE_SUPPINV => _("Supplier Invoice/Credit")
249 );
250
251 // Types of stock items
252 $stock_types = array(
253                 'M' => _("Manufactured"),
254                 'B' => _("Purchased"),
255                 'D' => _("Service")
256 );
257
258 /*
259         Special option values for various list selectors.
260 */
261 define('ANY_TEXT', '');
262 define('ANY_NUMERIC', -1);
263 define('ALL_TEXT', '');
264 define('ALL_NUMERIC', -1);
265
266 ?>