1d15d7c2882368bec063416a800667acc768a029
[fa-stable.git] / manufacturing / includes / db / work_centres_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 function add_work_centre($name, $description)
13 {
14         $sql = "INSERT INTO ".TB_PREF."workcentres (name, description)
15                 VALUES (".db_escape($name).",".db_escape($description).")";
16
17         db_query($sql, "could not add work centre");
18 }
19
20 function update_work_centre($type_id, $name, $description)
21 {
22         $sql = "UPDATE ".TB_PREF."workcentres SET name=".db_escape($name).", description=".db_escape($description)."
23                 WHERE id=".db_escape($type_id);
24
25         db_query($sql, "could not update work centre");
26 }
27
28 function get_all_work_centres($all=false)
29 {
30         $sql = "SELECT * FROM ".TB_PREF."workcentres";
31         if (!$all) $sql .= " WHERE !inactive";
32
33         return db_query($sql, "could not get all work centres");
34 }
35
36 function get_work_centre($type_id)
37 {
38         $sql = "SELECT * FROM ".TB_PREF."workcentres WHERE id=".db_escape($type_id);
39
40         $result = db_query($sql, "could not get work centre");
41
42         return db_fetch($result);
43 }
44
45 function delete_work_centre($type_id)
46 {
47         $sql="DELETE FROM ".TB_PREF."workcentres WHERE id=".db_escape($type_id);
48
49         db_query($sql, "could not delete work centre");
50 }
51