Moving 2.0 development version to main trunk.
[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                                                         );
148
149 class payment_person_types 
150 {
151
152         function get_all() 
153         {
154                 global $payment_person_types_array;
155                 return $payment_person_types_array;
156         }
157
158     function misc()  
159     { 
160         return 0; 
161     }
162
163     function WorkOrder()  
164     { 
165         return 1; 
166     }
167
168     function customer()  
169     { 
170         return 2; 
171     }
172
173     function supplier()  
174     { 
175         return 3; 
176     }
177
178     function dimension()  
179     { 
180         return 4; 
181     }
182
183     //function Project()  { return 4; }
184
185     function type_name($type)
186     {
187         global $payment_person_types_array;
188         return $payment_person_types_array[$type]['name'];
189     }
190
191     function person_name($type, $person_id, $full=true)
192     {
193         switch ($type)
194         {
195                 case payment_person_types::misc() :
196                         return $person_id;
197                 case payment_person_types::WorkOrder() :
198                         $wo = get_work_order($person_id);
199                         return ($full?payment_person_types::type_name($type) . " ":"") . $wo["wo_ref"];
200                 case payment_person_types::customer() :
201                         return ($full?payment_person_types::type_name($type) . " ":"") . get_customer_name($person_id);
202                 case payment_person_types::supplier() :
203                         return ($full?payment_person_types::type_name($type) . " ":"") . get_supplier_name($person_id);
204                 //case payment_person_types::Project() :
205                 //      return ($full?payment_person_types::type_name($type) . " ":"") . get_dimension_string($person_id);
206                 default :
207                         //DisplayDBerror("Invalid type sent to person_name");
208                         //return;
209                         return '';
210         }
211     }
212
213     function person_currency($type, $person_id)
214     {
215         switch ($type)
216         {
217                 case payment_person_types::misc() :
218                 case payment_person_types::WorkOrder() :
219                 //case payment_person_types::Project() :
220                         return get_company_currency();
221
222                 case payment_person_types::customer() :
223                         return get_customer_currency($person_id);
224
225                 case payment_person_types::supplier() :
226                         return get_supplier_currency($person_id);
227
228                 default :
229                         return get_company_currency();
230         }
231     }
232
233     function has_items($type)
234     {
235         switch ($type)
236         {
237                 case payment_person_types::misc() :
238                         return true;
239                 case payment_person_types::WorkOrder() : // 070305 changed to open workorders ES
240                         return db_has_open_workorders();
241                 case payment_person_types::customer() :
242                         return db_has_customers();
243                 case payment_person_types::supplier() :
244                         return db_has_suppliers();
245                 //case payment_person_types::Project() :
246                 //      return db_has_dimensions();
247                 default :
248                         display_db_error("Invalid type sent to has_items", "");
249                         return;
250         }
251     }
252 }
253
254 //----------------------------------------------------------------------------------
255
256 $wo_types_array = array (
257                                                 0=> array ('id' => 0, 'name' => _("Assemble")),
258                                                 1=> array ('id' => 1, 'name' => _("Unassemble")),
259                                                 2=> array ('id' => 2, 'name' => _("Advanced Manufacture"))
260                                                 );
261
262 class wo_types 
263 {
264
265         function assemble() 
266         { 
267                 return 0; 
268         }
269
270         function unassemble() 
271         { 
272                 return 1; 
273         }
274
275         function advanced() 
276         { 
277                 return 2; 
278         }
279
280         function get_all() 
281         {
282                 global $wo_types_array;
283                 return $wo_types_array;;
284         }
285
286         function name($index) 
287         {
288                 global $wo_types_array;
289                 return $wo_types_array[$index]['name'];
290         }
291 }
292
293
294 ?>