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//	FrontAccounting system transaction types
14//
15define('ST_JOURNAL', 0);
16
17define('ST_BANKPAYMENT', 1);
18define('ST_BANKDEPOSIT', 2);
19define('ST_BANKTRANSFER', 4);
20
21define('ST_SALESINVOICE', 10);
22define('ST_CUSTCREDIT', 11);
23define('ST_CUSTPAYMENT', 12);
24define('ST_CUSTDELIVERY', 13);
25
26define('ST_LOCTRANSFER', 16);
27define('ST_INVADJUST', 17);
28
29define('ST_PURCHORDER', 18);
30define('ST_SUPPINVOICE', 20);
31define('ST_SUPPCREDIT', 21);
32define('ST_SUPPAYMENT', 22);
33define('ST_SUPPRECEIVE', 25);
34
35define('ST_WORKORDER', 26);
36define('ST_MANUISSUE', 28);
37define('ST_MANURECEIVE', 29);
38
39
40define('ST_SALESORDER', 30);
41define('ST_SALESQUOTE', 32);
42define('ST_COSTUPDATE', 35);
43define('ST_DIMENSION', 40);
44
45// Don't include these defines in the $systypes_array.
46// They are used for documents only.
47define ('ST_STATEMENT', 91);
48define ('ST_CHEQUE', 92);
49
50// document inheritance
51$document_child_types = array(
52		ST_SALESQUOTE => ST_SALESORDER,
53		ST_SALESORDER => ST_CUSTDELIVERY,
54		ST_CUSTDELIVERY => ST_SALESINVOICE,
55		ST_SALESINVOICE => ST_CUSTCREDIT,
56
57		ST_PURCHORDER => ST_SUPPRECEIVE,
58		ST_SUPPRECEIVE => ST_SUPPINVOICE,
59		ST_SUPPINVOICE => ST_SUPPCREDIT,
60);
61
62function get_child_type($type)
63{
64	global $document_child_types;
65	return isset($document_child_types[$type]) ? $document_child_types[$type] : 0;
66}
67
68function get_parent_type($type)
69{
70	global $document_child_types;
71	$child = array_search($type, $document_child_types);
72	return $child ? $child : 0;
73}
74
75//----------------------------------------------------------------------------------
76//		Bank transaction types
77//
78define('BT_TRANSFER', 0);
79define('BT_CHEQUE', 1);
80define('BT_CREDIT', 2);
81define('BT_CASH', 3);
82
83include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc");
84include_once($path_to_root . "/purchasing/includes/purchasing_db.inc");
85include_once($path_to_root . "/sales/includes/sales_db.inc");
86include_once($path_to_root . "/dimensions/includes/dimensions_db.inc");
87//----------------------------------------------------------------------------------
88//	Payment types
89//
90define('PT_MISC', 0);
91define('PT_WORKORDER', 1);
92define('PT_CUSTOMER', 2);
93define('PT_SUPPLIER', 3);
94define('PT_QUICKENTRY', 4);
95define('PT_DIMESION', 5);
96
97function payment_person_currency($type, $person_id)  {
98	switch ($type)
99	{
100		case PT_MISC :
101		case PT_QUICKENTRY :
102		case PT_WORKORDER :
103			return get_company_currency();
104
105		case PT_CUSTOMER :
106			return get_customer_currency($person_id);
107
108		case PT_SUPPLIER :
109			return get_supplier_currency($person_id);
110
111		default :
112			return get_company_currency();
113	}
114}
115
116function payment_person_name($type, $person_id, $full=true) {
117	global $payment_person_types;
118
119	switch ($type)
120	{
121		case PT_MISC :
122			return $person_id;
123		case PT_QUICKENTRY :
124			$qe = get_quick_entry($person_id);
125			return ($full ? $payment_person_types[$type] . " ":"") . $qe["description"];
126		case PT_WORKORDER :
127			global $wo_cost_types;
128			return $wo_cost_types[$person_id];
129		case PT_CUSTOMER :
130			return ($full ?$payment_person_types[$type] . " ":"") . get_customer_name($person_id);
131		case PT_SUPPLIER :
132			return ($full ? $payment_person_types[$type] . " ":"") . get_supplier_name($person_id);
133		default :
134			//DisplayDBerror("Invalid type sent to person_name");
135			//return;
136			return '';
137	}
138}
139
140function payment_person_has_items($type) {
141	switch ($type)
142	{
143		case PT_MISC :
144			return true;
145		case PT_QUICKENTRY :
146			return db_has_quick_entries();
147		case PT_WORKORDER : // 070305 changed to open workorders JH
148			return db_has_open_workorders();
149		case PT_CUSTOMER :
150			return db_has_customers();
151		case PT_SUPPLIER :
152			return db_has_suppliers();
153		default :
154			display_db_error("Invalid type sent to has_items", "");
155			return false;
156	}
157}
158//----------------------------------------------------------------------------------
159//	Payment terms categories
160//
161define('PM_ANY', 0);
162define('PM_CASH', 1);
163define('PM_CREDIT', 2);
164
165//----------------------------------------------------------------------------------
166//	Manufacturing types
167//
168define('WO_ASSEMBLY', 0);
169define('WO_UNASSEMBLY', 1);
170define('WO_ADVANCED', 2);
171
172define('WO_LABOUR', 0);
173define('WO_OVERHEAD', 1);
174
175//----------------------------------------------------------------------------------
176//	GL account classes
177//
178define('CL_NONE', 0); // for backward compatibility
179define('CL_ASSETS', 1);
180define('CL_LIABILITIES', 2);
181define('CL_EQUITY', 3);
182define('CL_INCOME', 4);
183define('CL_COGS', 5);
184define('CL_EXPENSE', 6);
185
186function get_class_type_convert($ctype)
187{
188	global $use_oldstyle_convert;
189	if (isset($use_oldstyle_convert) && $use_oldstyle_convert == 1)
190		return (($ctype >= CL_INCOME || $ctype == CL_NONE) ? -1 : 1);
191	else
192		return ((($ctype >= CL_LIABILITIES && $ctype <= CL_INCOME) || $ctype == CL_NONE) ? -1 : 1);
193}
194//----------------------------------------------------------------------------------
195//	Quick entry types
196//
197define('QE_PAYMENT', '1');
198define('QE_DEPOSIT', '2');
199define('QE_JOURNAL', '3');
200define('QE_SUPPINV', '4');
201
202//----------------------------------------------------------------------------------
203//	Special option values for various list selectors.
204//
205define('ANY_TEXT', '');
206define('ANY_NUMERIC', -1);
207define('ALL_TEXT', '');
208define('ALL_NUMERIC', -1);
209
210//----------------------------------------------------------------------------------
211// Special class values for tables (start_table())
212define('TABLESTYLE',  1);
213define('TABLESTYLE2', 2);
214define('TABLESTYLE_NOBORDER', 3);
215
216//----------------------------------------------------------------------------------
217
218define('TAG_ACCOUNT',   1);
219define('TAG_DIMENSION', 2);
220
221//----------------------------------------------------------------------------------
222// Payment term types
223
224define('PTT_PRE', 1);
225define('PTT_CASH', 2);
226define('PTT_DAYS', 3);
227define('PTT_FOLLOWING', 4);
228
229include_once($path_to_root . '/includes/sysnames.inc');
230
231//---------------------------------------------------------------------------------
232// Constants optionally redefined locally
233//
234defined('ICON_EDIT') || define('ICON_EDIT', 'edit.gif');
235defined('ICON_DELETE') || define('ICON_DELETE', 'delete.gif');
236defined('ICON_ADD')	|| define('ICON_ADD', 'ok.gif');
237defined('ICON_UPDATE') || define('ICON_UPDATE', 'ok.gif');
238defined('ICON_OK') || define('ICON_OK', 'ok.gif');
239defined('ICON_CANCEL') || define('ICON_CANCEL', 'cancel.png');
240defined('ICON_GL') || define('ICON_GL', 'gl.png');
241defined('ICON_PRINT') || define('ICON_PRINT', 'print.png');
242defined('ICON_PDF') || define('ICON_PDF', 'pdf.gif');
243defined('ICON_DOC') || define('ICON_DOC', 'invoice.gif');
244defined('ICON_CREDIT') || define('ICON_CREDIT', 'credit.gif');
245defined('ICON_RECEIVE') || define('ICON_RECEIVE', 'receive.gif');
246defined('ICON_DOWN') || define('ICON_DOWN', 'download.gif');
247defined('ICON_MONEY') || define('ICON_MONEY', 'money.png');
248defined('ICON_REMOVE') || define('ICON_REMOVE', 'remove.png');
249defined('ICON_REPORT') || define('ICON_REPORT', 'report.png');
250defined('ICON_VIEW') || define('ICON_VIEW', 'view.gif');
251defined('ICON_SUBMIT') || define('ICON_SUBMIT', 'ok.gif');
252defined('ICON_ESCAPE') || define('ICON_ESCAPE', 'escape.png');
253defined('ICON_ALLOC') || define('ICON_ALLOC', 'alloc.png');
254
255?>