73efbfe1107bfefd8665c95f6985c34cedce5aad
[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")),
114                                                 1=> array ('id' => 1, 'name' => _("Chequing Account")),
115                                                 2=> array ('id' => 2, 'name' => _("Credit Account")),
116                                                 3=> array ('id' => 3, 'name' => _("Cash Account"))
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
135 //----------------------------------------------------------------------------------
136
137 include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc");
138 include_once($path_to_root . "/purchasing/includes/purchasing_db.inc");
139 include_once($path_to_root . "/sales/includes/sales_db.inc");
140 include_once($path_to_root . "/dimensions/includes/dimensions_db.inc");
141
142 $payment_person_types_array = array (
143                                                         0=> array ('id' => 0, 'name' => _("Miscellaneous")),
144                                                         1=> array ('id' => 1, 'name' => _("Work Order")),
145                                                         2=> array ('id' => 2, 'name' => _("Customer")),
146                                                         3=> array ('id' => 3, 'name' => _("Supplier")),
147                                                         4=> array ('id' => 4, 'name' => _("Quick Entry"))
148                                                         );
149
150 class payment_person_types 
151 {
152
153         function get_all() 
154         {
155                 global $payment_person_types_array;
156                 return $payment_person_types_array;
157         }
158
159     function misc()  
160     { 
161         return 0; 
162     }
163
164     function WorkOrder()  
165     { 
166         return 1; 
167     }
168
169     function customer()  
170     { 
171         return 2; 
172     }
173
174     function supplier()  
175     { 
176         return 3; 
177     }
178
179     function QuickEntry()  
180     { 
181         return 4; 
182     }
183
184     function dimension()  
185     { 
186         return 5; 
187     }
188
189     function type_name($type)
190     {
191         global $payment_person_types_array;
192         return $payment_person_types_array[$type]['name'];
193     }
194
195     function person_name($type, $person_id, $full=true)
196     {
197         switch ($type)
198         {
199                 case payment_person_types::misc() :
200                         return $person_id;
201                 case payment_person_types::QuickEntry() :
202                         $qe = get_quick_entry($person_id);
203                         return ($full?payment_person_types::type_name($type) . " ":"") . $qe["description"];
204                 case payment_person_types::WorkOrder() :
205                         $wo = get_work_order($person_id);
206                         return ($full?payment_person_types::type_name($type) . " ":"") . $wo["wo_ref"];
207                 case payment_person_types::customer() :
208                         return ($full?payment_person_types::type_name($type) . " ":"") . get_customer_name($person_id);
209                 case payment_person_types::supplier() :
210                         return ($full?payment_person_types::type_name($type) . " ":"") . get_supplier_name($person_id);
211                 default :
212                         //DisplayDBerror("Invalid type sent to person_name");
213                         //return;
214                         return '';
215         }
216     }
217
218     function person_currency($type, $person_id)
219     {
220         switch ($type)
221         {
222                 case payment_person_types::misc() :
223                 case payment_person_types::QuickEntry() :
224                 case payment_person_types::WorkOrder() :
225                         return get_company_currency();
226
227                 case payment_person_types::customer() :
228                         return get_customer_currency($person_id);
229
230                 case payment_person_types::supplier() :
231                         return get_supplier_currency($person_id);
232
233                 default :
234                         return get_company_currency();
235         }
236     }
237
238     function has_items($type)
239     {
240         switch ($type)
241         {
242                 case payment_person_types::misc() :
243                         return true;
244                 case payment_person_types::QuickEntry() :
245                         return db_has_quick_entries();
246                 case payment_person_types::WorkOrder() : // 070305 changed to open workorders JH
247                         return db_has_open_workorders();
248                 case payment_person_types::customer() :
249                         return db_has_customers();
250                 case payment_person_types::supplier() :
251                         return db_has_suppliers();
252                 default :
253                         display_db_error("Invalid type sent to has_items", "");
254                         return false;
255         }
256     }
257 }
258
259 //----------------------------------------------------------------------------------
260
261 $wo_types_array = array (
262                                                 0=> array ('id' => 0, 'name' => _("Assemble")),
263                                                 1=> array ('id' => 1, 'name' => _("Unassemble")),
264                                                 2=> array ('id' => 2, 'name' => _("Advanced Manufacture"))
265                                                 );
266
267 class wo_types 
268 {
269
270         function assemble() 
271         { 
272                 return 0; 
273         }
274
275         function unassemble() 
276         { 
277                 return 1; 
278         }
279
280         function advanced() 
281         { 
282                 return 2; 
283         }
284
285         function get_all() 
286         {
287                 global $wo_types_array;
288                 return $wo_types_array;;
289         }
290
291         function name($index) 
292         {
293                 global $wo_types_array;
294                 return $wo_types_array[$index]['name'];
295         }
296 }
297
298
299 ?>