Changed default startup_up app to be in user preferences. Default 'Sales'.
[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
14 $systypes_array = array (
15                                         0=> array ('name' => _("Journal Entry")),
16                                         1=> array ('name' => _("Bank Payment")),
17                                         2=> array ('name' => _("Bank Deposit")),
18                                         4=> array ('name' => _("Funds Transfer")),
19                     10=> array ('name' => _("Sales Invoice")),
20                     11=> array ('name' => _("Customer Credit Note")),
21                     12=> array ('name' => _("Customer Payment")),
22                     13=> array ('name' => _("Delivery Note")),
23                     16=> array ('name' => _("Location Transfer")),
24                     17=> array ('name' => _("Inventory Adjustment")),
25                     18=> array ('name' => _("Purchase Order")),
26                     20=> array ('name' => _("Supplier Invoice")),
27                     21=> array ('name' => _("Supplier Credit Note")),
28                     22=> array ('name' => _("Supplier Payment")),
29                     25=> array ('name' => _("Purchase Order Delivery")),
30                     26=> array ('name' => _("Work Order")),
31                     28=> array ('name' => _("Work Order Issue")),
32                     29=> array ('name' => _("Work Order Production")),
33                     30=> array ('name' => _("Sales Order")),
34                     35=> array ('name' => _("Cost Update")),
35                     40=> array ('name' => _("Dimension"))
36                                         );
37 class systypes 
38 {
39
40         function journal_entry() 
41         {
42                 return 0;
43         }
44
45         function bank_payment() 
46         {
47                 return 1;
48         }
49
50         function bank_deposit() 
51         {
52                 return 2;
53         }
54
55         function bank_transfer() 
56         {
57                 return 4;
58         }
59
60         function cust_payment() 
61         {
62                 return 12;
63         }
64
65         function cust_dispatch() 
66         {
67                 return 13;
68         }
69
70         function location_transfer() 
71         {
72                 return 16;
73         }
74
75         function inventory_adjustment() 
76         {
77                 return 17;
78         }
79
80         function po() 
81         {
82                 return 18;
83         }
84
85         function supp_payment() 
86         {
87                 return 22;
88         }
89
90         function work_order() 
91         {
92                 return 26;
93         }
94
95         function sales_order() 
96         {
97                 return 30;
98         }
99
100         function cost_update() 
101         {
102                 return 35;
103         }
104
105         function dimension() 
106         {
107                 return 40;
108         }
109
110         function name($index) 
111         {
112                 global $systypes_array;
113                 if ($index < 0)
114                         return '';
115                 return $systypes_array[$index]['name'];
116         }
117 }
118
119 //----------------------------------------------------------------------------------
120
121 $bank_account_types_array = array (
122         0=> array ('id' => 0, 'name' => _("Savings Account"), 'ptype' => _("Transfer")),
123         1=> array ('id' => 1, 'name' => _("Chequing Account"),'ptype' => _("Cheque")),
124         2=> array ('id' => 2, 'name' => _("Credit Account"), 'ptype' => _("Credit")),
125         3=> array ('id' => 3, 'name' => _("Cash Account"), 'ptype' => _("Cash"))
126         );
127
128 class bank_account_types 
129 {
130
131         function get_all() 
132         {
133                 global $bank_account_types_array;
134                 return $bank_account_types_array;;
135         }
136
137         function name($index) 
138         {
139                 global $bank_account_types_array;
140                 return $bank_account_types_array[$index]['name'];
141         }
142         
143         function transfer_type($index) 
144         {
145                 global $bank_account_types_array;
146                 return $bank_account_types_array[$index]['ptype'];
147         }
148 }
149
150 /* Menu tabs */
151 $tabs = array('orders'=>_("Sales"), 'AP'=>_("Purchases"), 'stock'=>_("Items and Inventory"), 'manuf'=>_("Manufacturing"), 
152         'proj'=>_("Dimensions"), 'GL'=>_("Banking and General Ledger"), 'system'=>_("Setup"));
153
154 //----------------------------------------------------------------------------------
155
156 include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc");
157 include_once($path_to_root . "/purchasing/includes/purchasing_db.inc");
158 include_once($path_to_root . "/sales/includes/sales_db.inc");
159 include_once($path_to_root . "/dimensions/includes/dimensions_db.inc");
160
161 $payment_person_types_array = array (
162                                                         0=> array ('id' => 0, 'name' => _("Miscellaneous")),
163                                                         1=> array ('id' => 1, 'name' => _("Work Order")),
164                                                         2=> array ('id' => 2, 'name' => _("Customer")),
165                                                         3=> array ('id' => 3, 'name' => _("Supplier")),
166                                                         4=> array ('id' => 4, 'name' => _("Quick Entry"))
167                                                         );
168
169 class payment_person_types 
170 {
171
172         function get_all() 
173         {
174                 global $payment_person_types_array;
175                 return $payment_person_types_array;
176         }
177
178     function misc()  
179     { 
180         return 0; 
181     }
182
183     function WorkOrder()  
184     { 
185         return 1; 
186     }
187
188     function customer()  
189     { 
190         return 2; 
191     }
192
193     function supplier()  
194     { 
195         return 3; 
196     }
197
198     function QuickEntry()  
199     { 
200         return 4; 
201     }
202
203     function dimension()  
204     { 
205         return 5; 
206     }
207
208     function type_name($type)
209     {
210         global $payment_person_types_array;
211         return $payment_person_types_array[$type]['name'];
212     }
213
214     function person_name($type, $person_id, $full=true)
215     {
216         switch ($type)
217         {
218                 case payment_person_types::misc() :
219                         return $person_id;
220                 case payment_person_types::QuickEntry() :
221                         $qe = get_quick_entry($person_id);
222                         return ($full?payment_person_types::type_name($type) . " ":"") . $qe["description"];
223                 case payment_person_types::WorkOrder() :
224                         global $wo_cost_types;
225                         return $wo_cost_types[$person_id];
226                 case payment_person_types::customer() :
227                         return ($full?payment_person_types::type_name($type) . " ":"") . get_customer_name($person_id);
228                 case payment_person_types::supplier() :
229                         return ($full?payment_person_types::type_name($type) . " ":"") . get_supplier_name($person_id);
230                 default :
231                         //DisplayDBerror("Invalid type sent to person_name");
232                         //return;
233                         return '';
234         }
235     }
236
237     function person_currency($type, $person_id)
238     {
239         switch ($type)
240         {
241                 case payment_person_types::misc() :
242                 case payment_person_types::QuickEntry() :
243                 case payment_person_types::WorkOrder() :
244                         return get_company_currency();
245
246                 case payment_person_types::customer() :
247                         return get_customer_currency($person_id);
248
249                 case payment_person_types::supplier() :
250                         return get_supplier_currency($person_id);
251
252                 default :
253                         return get_company_currency();
254         }
255     }
256
257     function has_items($type)
258     {
259         switch ($type)
260         {
261                 case payment_person_types::misc() :
262                         return true;
263                 case payment_person_types::QuickEntry() :
264                         return db_has_quick_entries();
265                 case payment_person_types::WorkOrder() : // 070305 changed to open workorders JH
266                         return db_has_open_workorders();
267                 case payment_person_types::customer() :
268                         return db_has_customers();
269                 case payment_person_types::supplier() :
270                         return db_has_suppliers();
271                 default :
272                         display_db_error("Invalid type sent to has_items", "");
273                         return false;
274         }
275     }
276 }
277
278 //----------------------------------------------------------------------------------
279
280 $wo_types_array = array (
281                                                 0=> array ('id' => 0, 'name' => _("Assemble")),
282                                                 1=> array ('id' => 1, 'name' => _("Unassemble")),
283                                                 2=> array ('id' => 2, 'name' => _("Advanced Manufacture"))
284                                                 );
285
286 class wo_types 
287 {
288
289         function assemble() 
290         { 
291                 return 0; 
292         }
293
294         function unassemble() 
295         { 
296                 return 1; 
297         }
298
299         function advanced() 
300         { 
301                 return 2; 
302         }
303
304         function get_all() 
305         {
306                 global $wo_types_array;
307                 return $wo_types_array;;
308         }
309
310         function name($index) 
311         {
312                 global $wo_types_array;
313                 return $wo_types_array[$index]['name'];
314         }
315 }
316
317 define('CL_NONE', 0); // for backward compatibility
318 define('CL_ASSETS', 1);
319 define('CL_LIABILITIES', 2);
320 define('CL_EQUITY', 3);
321 define('CL_INCOME', 4);
322 define('CL_COGS', 5);
323 define('CL_EXPENSE', 6);
324
325 $class_types = array(
326                 CL_ASSETS => _("Assets"),
327                 CL_LIABILITIES => _("Liabilities"),
328                 CL_EQUITY => _("Equity"),
329                 CL_INCOME => _("Income"),
330                 CL_COGS => _("Cost of Goods Sold"),
331                 CL_EXPENSE => _("Expense"),
332 );
333
334 function get_class_type_convert($ctype)
335 {
336         global $use_oldstyle_convert;
337         if (isset($use_oldstyle_convert) && $use_oldstyle_convert == 1)
338                 return (($ctype >= CL_INCOME || $ctype == CL_NONE) ? -1 : 1);
339         else    
340                 return ((($ctype >= CL_LIABILITIES && $ctype <= CL_INCOME) || $ctype == CL_NONE) ? -1 : 1);
341 }
342 define('WO_LABOUR', 0);
343 define('WO_OVERHEAD', 1);
344
345 $wo_cost_types = array(
346                 WO_LABOUR => _("Labour Cost"),
347                 WO_OVERHEAD => _("Overhead Cost"),
348 );
349
350 $quick_actions = array(
351         '=' => _('Remainder'), // post current base amount to GL account
352         'a' => _('Amount'), // post amount to GL account
353         'a+' => _('Amount, increase base'), // post amount to GL account and increase base
354         'a-' => _('Amount, reduce base'), // post amount to GL account and reduce base
355         '%' => _('% amount of base'),   // store acc*amount% to GL account
356         '%+' => _('% amount of base, increase base'),   // ditto & increase base amount
357         '%-' => _('% amount of base, reduce base'),     // ditto & reduce base amount
358         'T' => _('Taxes added'), // post taxes calculated on base amount
359         'T+' => _('Taxes added, increase base'), // ditto & increase base amount
360         'T-' => _('Taxes added, reduce base'), // ditto & reduce base amount
361         't' => _('Taxes included'), // post taxes calculated on base amount
362         't+' => _('Taxes included, increase base'), // ditto & increase base amount
363         't-' => _('Taxes included, reduce base') // ditto & reduce base amount
364 );
365
366 define('QE_PAYMENT', '1');
367 define('QE_DEPOSIT', '2');
368 define('QE_JOURNAL', '3');
369 define('QE_SUPPINV', '4');
370
371 $quick_entry_types = array(
372                 QE_DEPOSIT => _("Bank Deposit"),
373                 QE_PAYMENT => _("Bank Payment"),
374                 QE_JOURNAL => _("Journal Entry"),
375                 QE_SUPPINV => _("Supplier Invoice/Credit")
376 );
377
378 // Types of stock items
379 $stock_types = array(
380                 'M' => _("Manufactured"),
381                 'B' => _("Purchased"),
382                 'D' => _("Service")
383 );
384 ?>