Double semicolon line endings fixed by @apmuthu.
[fa-stable.git] / fixed_assets / includes / fa_classes_db.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 function get_fixed_asset_classes()
14 {
15         $sql="SELECT * FROM ".TB_PREF."stock_fa_class";
16
17         $result = db_query($sql,"fixed asset classes could not be retrieved");
18
19         return $result;
20 }
21
22 function get_fixed_asset_classname($class)
23 {
24         $sql="SELECT description FROM ".TB_PREF."stock_fa_class WHERE fa_class_id = ".db_escape($class);
25
26         $result = db_query($sql,"fixed asset class name could not be retrieved");
27
28         $row = db_fetch_row($result);
29         
30         return $row[0];
31 }
32
33 function update_fixed_asset_class($fa_class_id, $parent_id, $description, $long_description, $depreciation_rate)
34 {
35         $sql = "UPDATE ".TB_PREF."stock_fa_class SET
36                 parent_id=".db_escape($parent_id).",
37                 description=".db_escape($description).",
38                 long_description=".db_escape($long_description).",
39     depreciation_rate=".db_escape($depreciation_rate)."
40     WHERE fa_class_id=".db_escape($fa_class_id);
41
42         db_query($sql, "The fixed asset class could not be updated");
43 }
44
45 function add_fixed_asset_class($fa_class_id, $parent_id, $description, $long_description, $depreciation_rate)
46 {
47   $sql = "INSERT INTO ".TB_PREF."stock_fa_class (fa_class_id, parent_id, description, long_description,
48      depreciation_rate) VALUES ("
49     .db_escape($fa_class_id).", ".db_escape($parent_id).", "
50         .db_escape($description).", ".db_escape($long_description).", "
51     .db_escape($depreciation_rate).")";
52
53         db_query($sql, "The fixed asset class could not be added");
54 }
55
56 function delete_fixed_asset_class($fa_class_id)
57 {
58   $sql = "DELETE FROM ".TB_PREF."stock_fa_class WHERE fa_class_id=".db_escape($fa_class_id);
59
60         db_query($sql, "The fixed asset class could not be deleted");
61 }