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 function add_account_type($id, $name, $class_id, $parent)
14 $sql = "INSERT INTO ".TB_PREF."chart_types (id, name, class_id, parent)
15 VALUES ($id, ".db_escape($name).", $class_id, $parent)";
17 db_query($sql, "could not add account type");
20 function update_account_type($id, $name, $class_id, $parent)
22 $sql = "UPDATE ".TB_PREF."chart_types SET name=".db_escape($name).",
23 class_id=$class_id, parent=$parent WHERE id = $id";
25 db_query($sql, "could not update account type");
28 function get_account_types($all=false)
30 $sql = "SELECT * FROM ".TB_PREF."chart_types";
32 if (!$all) $sql .= " WHERE !inactive";
33 $sql .= " ORDER BY class_id, id";
35 return db_query($sql, "could not get account types");
38 function get_account_type($id)
40 $sql = "SELECT * FROM ".TB_PREF."chart_types WHERE id = $id";
42 $result = db_query($sql, "could not get account type");
44 return db_fetch($result);
47 function get_account_type_name($id)
49 $sql = "SELECT name FROM ".TB_PREF."chart_types WHERE id = $id";
51 $result = db_query($sql, "could not get account type");
53 $row = db_fetch_row($result);
57 function delete_account_type($id)
59 $sql = "DELETE FROM ".TB_PREF."chart_types WHERE id = $id";
61 db_query($sql, "could not delete account type");
64 function add_account_class($id, $name, $ctype)
66 $sql = "INSERT INTO ".TB_PREF."chart_class (cid, class_name, ctype)
67 VALUES ($id, ".db_escape($name).", $ctype)";
69 db_query($sql, "could not add account type");
72 function update_account_class($id, $name, $ctype)
74 $sql = "UPDATE ".TB_PREF."chart_class SET class_name=".db_escape($name).",
75 ctype=$ctype WHERE cid = $id";
77 db_query($sql, "could not update account type");
80 function get_account_classes($all=false)
82 $sql = "SELECT * FROM ".TB_PREF."chart_class";
83 if (!$all) $sql .= " WHERE !inactive";
84 $sql .= " ORDER BY cid";
86 return db_query($sql, "could not get account types");
89 function get_account_class($id)
91 $sql = "SELECT * FROM ".TB_PREF."chart_class WHERE cid = $id";
93 $result = db_query($sql, "could not get account type");
95 return db_fetch($result);
98 function get_account_class_name($id)
100 $sql = "SELECT class_name FROM ".TB_PREF."chart_class WHERE cid = $id";
102 $result = db_query($sql, "could not get account type");
104 $row = db_fetch_row($result);
108 function delete_account_class($id)
110 $sql = "DELETE FROM ".TB_PREF."chart_class WHERE cid = $id";
112 db_query($sql, "could not delete account type");