*** empty log message ***
[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                     16=> array ('name' => _("Location Transfer")),
14                     17=> array ('name' => _("Inventory Adjustment")),
15                     18=> array ('name' => _("Purchase Order")),
16                     20=> array ('name' => _("Supplier Invoice")),
17                     21=> array ('name' => _("Supplier Credit Note")),
18                     22=> array ('name' => _("Supplier Payment")),
19                     25=> array ('name' => _("Purchase Order Delivery")),
20                     26=> array ('name' => _("Work Order")),
21                     28=> array ('name' => _("Work Order Issue")),
22                     29=> array ('name' => _("Work Order Production")),
23                     30=> array ('name' => _("Sales Order")),
24                     35=> array ('name' => _("Cost Update")),
25                     40=> array ('name' => _("Dimension"))
26                                         );
27 class systypes 
28 {
29
30         function journal_entry() 
31         {
32                 return 0;
33         }
34
35         function bank_payment() 
36         {
37                 return 1;
38         }
39
40         function bank_deposit() 
41         {
42                 return 2;
43         }
44
45         function bank_transfer() 
46         {
47                 return 4;
48         }
49
50         function cust_payment() 
51         {
52                 return 12;
53         }
54
55         function location_transfer() 
56         {
57                 return 16;
58         }
59
60         function inventory_adjustment() 
61         {
62                 return 17;
63         }
64
65         function po() 
66         {
67                 return 18;
68         }
69
70         function supp_payment() 
71         {
72                 return 22;
73         }
74
75         function work_order() 
76         {
77                 return 26;
78         }
79
80         function sales_order() 
81         {
82                 return 30;
83         }
84
85         function cost_update() 
86         {
87                 return 35;
88         }
89
90         function dimension() 
91         {
92                 return 40;
93         }
94
95         function name($index) 
96         {
97                 global $systypes_array;
98                 if ($index < 0)
99                         return '';
100                 return $systypes_array[$index]['name'];
101         }
102 }
103
104 //----------------------------------------------------------------------------------
105
106 $bank_account_types_array = array (
107                                                 0=> array ('id' => 0, 'name' => _("Savings Account")),
108                                                 1=> array ('id' => 1, 'name' => _("Chequing Account")),
109                                                 2=> array ('id' => 2, 'name' => _("Credit Account")),
110                                                 3=> array ('id' => 3, 'name' => _("Cash Account"))
111                                                 );
112
113 class bank_account_types 
114 {
115
116         function get_all() 
117         {
118                 global $bank_account_types_array;
119                 return $bank_account_types_array;;
120         }
121
122         function name($index) 
123         {
124                 global $bank_account_types_array;
125                 return $bank_account_types_array[$index]['name'];
126         }
127 }
128
129 //----------------------------------------------------------------------------------
130
131 include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc");
132 include_once($path_to_root . "/purchasing/includes/purchasing_db.inc");
133 include_once($path_to_root . "/sales/includes/sales_db.inc");
134 include_once($path_to_root . "/dimensions/includes/dimensions_db.inc");
135
136 $payment_person_types_array = array (
137                                                         0=> array ('id' => 0, 'name' => _("Miscellaneous")),
138                                                         1=> array ('id' => 1, 'name' => _("Work Order")),
139                                                         2=> array ('id' => 2, 'name' => _("Customer")),
140                                                         3=> array ('id' => 3, 'name' => _("Supplier")),
141                                                         );
142
143 class payment_person_types 
144 {
145
146         function get_all() 
147         {
148                 global $payment_person_types_array;
149                 return $payment_person_types_array;
150         }
151
152     function misc()  
153     { 
154         return 0; 
155     }
156
157     function WorkOrder()  
158     { 
159         return 1; 
160     }
161
162     function customer()  
163     { 
164         return 2; 
165     }
166
167     function supplier()  
168     { 
169         return 3; 
170     }
171
172     function dimension()  
173     { 
174         return 4; 
175     }
176
177     //function Project()  { return 4; }
178
179     function type_name($type)
180     {
181         global $payment_person_types_array;
182         return $payment_person_types_array[$type]['name'];
183     }
184
185     function person_name($type, $person_id, $full=true)
186     {
187         switch ($type)
188         {
189                 case payment_person_types::misc() :
190                         return $person_id;
191                 case payment_person_types::WorkOrder() :
192                         $wo = get_work_order($person_id);
193                         return ($full?payment_person_types::type_name($type) . " ":"") . $wo["wo_ref"];
194                 case payment_person_types::customer() :
195                         return ($full?payment_person_types::type_name($type) . " ":"") . get_customer_name($person_id);
196                 case payment_person_types::supplier() :
197                         return ($full?payment_person_types::type_name($type) . " ":"") . get_supplier_name($person_id);
198                 //case payment_person_types::Project() :
199                 //      return ($full?payment_person_types::type_name($type) . " ":"") . get_dimension_string($person_id);
200                 default :
201                         //DisplayDBerror("Invalid type sent to person_name");
202                         //return;
203                         return '';
204         }
205     }
206
207     function person_currency($type, $person_id)
208     {
209         switch ($type)
210         {
211                 case payment_person_types::misc() :
212                 case payment_person_types::WorkOrder() :
213                 //case payment_person_types::Project() :
214                         return get_company_currency();
215
216                 case payment_person_types::customer() :
217                         return get_customer_currency($person_id);
218
219                 case payment_person_types::supplier() :
220                         return get_supplier_currency($person_id);
221
222                 default :
223                         return get_company_currency();
224         }
225     }
226
227     function has_items($type)
228     {
229         switch ($type)
230         {
231                 case payment_person_types::misc() :
232                         return true;
233                 case payment_person_types::WorkOrder() : // 070305 changed to open workorders ES
234                         return db_has_open_workorders();
235                 case payment_person_types::customer() :
236                         return db_has_customers();
237                 case payment_person_types::supplier() :
238                         return db_has_suppliers();
239                 //case payment_person_types::Project() :
240                 //      return db_has_dimensions();
241                 default :
242                         display_db_error("Invalid type sent to has_items", "");
243                         return;
244         }
245     }
246 }
247
248 //----------------------------------------------------------------------------------
249
250 $wo_types_array = array (
251                                                 0=> array ('id' => 0, 'name' => _("Assemble")),
252                                                 1=> array ('id' => 1, 'name' => _("Unassemble")),
253                                                 2=> array ('id' => 2, 'name' => _("Advanced Manufacture"))
254                                                 );
255
256 class wo_types 
257 {
258
259         function assemble() 
260         { 
261                 return 0; 
262         }
263
264         function unassemble() 
265         { 
266                 return 1; 
267         }
268
269         function advanced() 
270         { 
271                 return 2; 
272         }
273
274         function get_all() 
275         {
276                 global $wo_types_array;
277                 return $wo_types_array;;
278         }
279
280         function name($index) 
281         {
282                 global $wo_types_array;
283                 return $wo_types_array[$index]['name'];
284         }
285 }
286
287
288 ?>