4cde8738ba5e99ae30b38f277c3d0d04643232e1
[fa-stable.git] / includes / types.inc
1 <?php
2
3 //----------------------------------------------------------------------------------
4
5 $systypes_array = array (
6                                         0=> array ('name' => _("Journal Entry")),
7                                         1=> array ('name' => _("Bank Payment")),
8                                         2=> array ('name' => _("Bank Deposit")),
9                                         4=> array ('name' => _("Funds Transfer")),
10                     10=> array ('name' => _("Sales Invoice")),
11                     11=> array ('name' => _("Customer Credit Note")),
12                     12=> array ('name' => _("Customer Payment")),
13                     13=> array ('name' => _("Delivery Note")),
14                     16=> array ('name' => _("Location Transfer")),
15                     17=> array ('name' => _("Inventory Adjustment")),
16                     18=> array ('name' => _("Purchase Order")),
17                     20=> array ('name' => _("Supplier Invoice")),
18                     21=> array ('name' => _("Supplier Credit Note")),
19                     22=> array ('name' => _("Supplier Payment")),
20                     25=> array ('name' => _("Purchase Order Delivery")),
21                     26=> array ('name' => _("Work Order")),
22                     28=> array ('name' => _("Work Order Issue")),
23                     29=> array ('name' => _("Work Order Production")),
24                     30=> array ('name' => _("Sales Order")),
25                     35=> array ('name' => _("Cost Update")),
26                     40=> array ('name' => _("Dimension"))
27                                         );
28 class systypes 
29 {
30
31         function journal_entry() 
32         {
33                 return 0;
34         }
35
36         function bank_payment() 
37         {
38                 return 1;
39         }
40
41         function bank_deposit() 
42         {
43                 return 2;
44         }
45
46         function bank_transfer() 
47         {
48                 return 4;
49         }
50
51         function cust_payment() 
52         {
53                 return 12;
54         }
55
56         function cust_dispatch() 
57         {
58                 return 13;
59         }
60
61         function location_transfer() 
62         {
63                 return 16;
64         }
65
66         function inventory_adjustment() 
67         {
68                 return 17;
69         }
70
71         function po() 
72         {
73                 return 18;
74         }
75
76         function supp_payment() 
77         {
78                 return 22;
79         }
80
81         function work_order() 
82         {
83                 return 26;
84         }
85
86         function sales_order() 
87         {
88                 return 30;
89         }
90
91         function cost_update() 
92         {
93                 return 35;
94         }
95
96         function dimension() 
97         {
98                 return 40;
99         }
100
101         function name($index) 
102         {
103                 global $systypes_array;
104                 if ($index < 0)
105                         return '';
106                 return $systypes_array[$index]['name'];
107         }
108 }
109
110 //----------------------------------------------------------------------------------
111
112 $bank_account_types_array = array (
113         0=> array ('id' => 0, 'name' => _("Savings Account"), 'ptype' => _("Transfer")),
114         1=> array ('id' => 1, 'name' => _("Chequing Account"),'ptype' => _("Cheque")),
115         2=> array ('id' => 2, 'name' => _("Credit Account"), 'ptype' => _("Credit")),
116         3=> array ('id' => 3, 'name' => _("Cash Account"), 'ptype' => _("Cash"))
117         );
118
119 class bank_account_types 
120 {
121
122         function get_all() 
123         {
124                 global $bank_account_types_array;
125                 return $bank_account_types_array;;
126         }
127
128         function name($index) 
129         {
130                 global $bank_account_types_array;
131                 return $bank_account_types_array[$index]['name'];
132         }
133         
134         function transfer_type($index) 
135         {
136                 global $bank_account_types_array;
137                 return $bank_account_types_array[$index]['ptype'];
138         }
139 }
140 //----------------------------------------------------------------------------------
141
142 include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc");
143 include_once($path_to_root . "/purchasing/includes/purchasing_db.inc");
144 include_once($path_to_root . "/sales/includes/sales_db.inc");
145 include_once($path_to_root . "/dimensions/includes/dimensions_db.inc");
146
147 $payment_person_types_array = array (
148                                                         0=> array ('id' => 0, 'name' => _("Miscellaneous")),
149                                                         1=> array ('id' => 1, 'name' => _("Work Order")),
150                                                         2=> array ('id' => 2, 'name' => _("Customer")),
151                                                         3=> array ('id' => 3, 'name' => _("Supplier")),
152                                                         4=> array ('id' => 4, 'name' => _("Quick Entry"))
153                                                         );
154
155 class payment_person_types 
156 {
157
158         function get_all() 
159         {
160                 global $payment_person_types_array;
161                 return $payment_person_types_array;
162         }
163
164     function misc()  
165     { 
166         return 0; 
167     }
168
169     function WorkOrder()  
170     { 
171         return 1; 
172     }
173
174     function customer()  
175     { 
176         return 2; 
177     }
178
179     function supplier()  
180     { 
181         return 3; 
182     }
183
184     function QuickEntry()  
185     { 
186         return 4; 
187     }
188
189     function dimension()  
190     { 
191         return 5; 
192     }
193
194     function type_name($type)
195     {
196         global $payment_person_types_array;
197         return $payment_person_types_array[$type]['name'];
198     }
199
200     function person_name($type, $person_id, $full=true)
201     {
202         switch ($type)
203         {
204                 case payment_person_types::misc() :
205                         return $person_id;
206                 case payment_person_types::QuickEntry() :
207                         $qe = get_quick_entry($person_id);
208                         return ($full?payment_person_types::type_name($type) . " ":"") . $qe["description"];
209                 case payment_person_types::WorkOrder() :
210                         $wo = get_work_order($person_id);
211                         return ($full?payment_person_types::type_name($type) . " ":"") . $wo["wo_ref"];
212                 case payment_person_types::customer() :
213                         return ($full?payment_person_types::type_name($type) . " ":"") . get_customer_name($person_id);
214                 case payment_person_types::supplier() :
215                         return ($full?payment_person_types::type_name($type) . " ":"") . get_supplier_name($person_id);
216                 default :
217                         //DisplayDBerror("Invalid type sent to person_name");
218                         //return;
219                         return '';
220         }
221     }
222
223     function person_currency($type, $person_id)
224     {
225         switch ($type)
226         {
227                 case payment_person_types::misc() :
228                 case payment_person_types::QuickEntry() :
229                 case payment_person_types::WorkOrder() :
230                         return get_company_currency();
231
232                 case payment_person_types::customer() :
233                         return get_customer_currency($person_id);
234
235                 case payment_person_types::supplier() :
236                         return get_supplier_currency($person_id);
237
238                 default :
239                         return get_company_currency();
240         }
241     }
242
243     function has_items($type)
244     {
245         switch ($type)
246         {
247                 case payment_person_types::misc() :
248                         return true;
249                 case payment_person_types::QuickEntry() :
250                         return db_has_quick_entries();
251                 case payment_person_types::WorkOrder() : // 070305 changed to open workorders JH
252                         return db_has_open_workorders();
253                 case payment_person_types::customer() :
254                         return db_has_customers();
255                 case payment_person_types::supplier() :
256                         return db_has_suppliers();
257                 default :
258                         display_db_error("Invalid type sent to has_items", "");
259                         return false;
260         }
261     }
262 }
263
264 //----------------------------------------------------------------------------------
265
266 $wo_types_array = array (
267                                                 0=> array ('id' => 0, 'name' => _("Assemble")),
268                                                 1=> array ('id' => 1, 'name' => _("Unassemble")),
269                                                 2=> array ('id' => 2, 'name' => _("Advanced Manufacture"))
270                                                 );
271
272 class wo_types 
273 {
274
275         function assemble() 
276         { 
277                 return 0; 
278         }
279
280         function unassemble() 
281         { 
282                 return 1; 
283         }
284
285         function advanced() 
286         { 
287                 return 2; 
288         }
289
290         function get_all() 
291         {
292                 global $wo_types_array;
293                 return $wo_types_array;;
294         }
295
296         function name($index) 
297         {
298                 global $wo_types_array;
299                 return $wo_types_array[$index]['name'];
300         }
301 }
302
303 $quick_actions = array(
304         '=' => _('Remainder'), // post current base amount to GL account
305         '-' => _('Amount, reduce base'), // post amount to GL account and reduce base
306         '+' => _('Amount, increase base'), // post amount to GL account and increase base
307         '%' => _('% amount of base'),   // store acc*amount% to GL account
308         '%+' => _('% amount of base, increase base'),   // ditto & increase base amount
309         '%-' => _('% amount of base, reduce base'),     // ditto & reduce base amount
310         'T' => _('Taxes added'), // post taxes calculated on base amount
311         'T+' => _('Taxes added, increase base'), // ditto & increase base amount
312         'T-' => _('Taxes added, reduce base'), // ditto & reduce base amount
313         't' => _('Taxes included'), // post taxes calculated on base amount
314         't+' => _('Taxes included, increase base'), // ditto & increase base amount
315         't-' => _('Taxes included, reduce base') // ditto & reduce base amount
316 );
317
318 define('QE_DEPOSIT', '1');
319 define('QE_PAYMENT', '2');
320 define('QE_JOURNAL', '3');
321 define('QE_SUPPINV', '4');
322
323 $quick_entry_types = array(
324                 QE_DEPOSIT => _("Bank Deposit"),
325                 QE_PAYMENT => _("Bank Payment"),
326                 QE_JOURNAL => _("Journal Entry"),
327                 QE_SUPPINV => _("Supplier Invoice/Credit")
328 );
329
330
331
332 ?>