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