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_item_category($description, $tax_type_id, $sales_account,
13 $cogs_account, $inventory_account, $adjustment_account, $assembly_account,
14 $units, $mb_flag, $dim1, $dim2)
16 $sql = "INSERT INTO ".TB_PREF."stock_category (description, dflt_tax_type,
17 dflt_units, dflt_mb_flag, dflt_sales_act, dflt_cogs_act,
18 dflt_inventory_act, dflt_adjustment_act, dflt_assembly_act,
21 .db_escape($description).","
22 .db_escape($tax_type_id).","
23 .db_escape($units).","
24 .db_escape($mb_flag).","
25 .db_escape($sales_account).","
26 .db_escape($cogs_account).","
27 .db_escape($inventory_account).","
28 .db_escape($adjustment_account).","
29 .db_escape($assembly_account).","
31 .db_escape($dim2).")";
33 db_query($sql,"an item category could not be added");
36 function update_item_category($id, $description, $tax_type_id,
37 $sales_account, $cogs_account, $inventory_account, $adjustment_account,
38 $assembly_account, $units, $mb_flag, $dim1, $dim2)
41 $sql = "UPDATE ".TB_PREF."stock_category SET "
42 ."description = ".db_escape($description).","
43 ."dflt_tax_type = ".db_escape($tax_type_id).","
44 ."dflt_units = ".db_escape($units).","
45 ."dflt_mb_flag = ".db_escape($mb_flag).","
46 ."dflt_sales_act = ".db_escape($sales_account).","
47 ."dflt_cogs_act = ".db_escape($cogs_account).","
48 ."dflt_inventory_act = ".db_escape($inventory_account).","
49 ."dflt_adjustment_act = ".db_escape($adjustment_account).","
50 ."dflt_assembly_act = ".db_escape($assembly_account).","
51 ."dflt_dim1 = ".db_escape($dim1).","
52 ."dflt_dim2 = ".db_escape($dim2)
53 ." WHERE category_id = '$id'";
55 db_query($sql,"an item category could not be updated");
58 function delete_item_category($id)
60 $sql="DELETE FROM ".TB_PREF."stock_category WHERE category_id='$id'";
62 db_query($sql,"an item category could not be deleted");
65 function get_item_category($id)
67 $sql="SELECT * FROM ".TB_PREF."stock_category WHERE category_id='$id'";
69 $result = db_query($sql,"an item category could not be retrieved");
71 return db_fetch($result);
74 function get_category_name($id)
76 $sql = "SELECT description FROM ".TB_PREF."stock_category WHERE category_id=$id";
78 $result = db_query($sql, "could not get sales type");
80 $row = db_fetch_row($result);