Copyright notes at top op every source file
[fa-stable.git] / inventory / includes / db / items_category_db.inc
1 <?php
2 /**********************************************************************
3     Copyright (C) FrontAccounting, LLC.
4         Released under the terms of the GNU Affero General Public License,
5         AGPL, as published by the Free Software Foundation, either version 
6         3 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/agpl-3.0.html>.
11 ***********************************************************************/
12 function add_item_category($description)
13
14 {
15         $sql = "INSERT INTO ".TB_PREF."stock_category (description)
16                 VALUES (".db_escape($description).")";
17
18         db_query($sql,"an item category could not be added");
19 }
20
21 function update_item_category($ItemCategory, $description)
22
23 {
24         $sql = "UPDATE ".TB_PREF."stock_category SET description = ".db_escape($description)."
25         WHERE category_id = '$ItemCategory'";
26
27         db_query($sql,"an item category could not be updated");
28 }
29
30 function delete_item_category($ItemCategory)
31 {
32         $sql="DELETE FROM ".TB_PREF."stock_category WHERE category_id='$ItemCategory'";
33
34         db_query($sql,"an item category could not be deleted");
35 }
36
37 function get_item_category($ItemCategory)
38 {
39         $sql="SELECT * FROM ".TB_PREF."stock_category WHERE category_id='$ItemCategory'";
40
41         $result = db_query($sql,"an item category could not be retrieved");
42
43         return db_fetch($result);
44 }
45
46 function get_category_name($id)
47 {
48         $sql = "SELECT description FROM ".TB_PREF."stock_category WHERE category_id=$id";
49
50         $result = db_query($sql, "could not get sales type");
51
52         $row = db_fetch_row($result);
53         return $row[0];
54 }
55
56 ?>