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