d431e97d108a2d3f72ff322e65327097749338eb
[fa-stable.git] / includes / db / comments_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
14 function get_comments($type, $type_no)
15 {
16         $sql = "SELECT * FROM ".TB_PREF."comments WHERE type=$type AND id=$type_no";
17
18         return db_query($sql, "could not query comments transaction table");
19 }
20
21 //--------------------------------------------------------------------------------------------------
22
23 function add_comments($type, $type_no, $date_, $memo_)
24 {
25         if ($memo_ != null && $memo_ != "")
26         {
27         $date = date2sql($date_);
28         $sql = "INSERT INTO ".TB_PREF."comments (type, id, date_, memo_)
29                 VALUES ($type, $type_no, '$date', ".db_escape($memo_).")";
30
31         db_query($sql, "could not add comments transaction entry");
32         }
33 }
34
35 //--------------------------------------------------------------------------------------------------
36
37 function update_comments($type, $id, $date_, $memo_)
38 {
39         if ($date_ == null)
40         {
41         delete_comments($type, $id);
42         add_comments($type, $id, Today(), $memo_);
43         }
44         else
45         {
46                 $date = date2sql($date_);
47         $sql = "UPDATE ".TB_PREF."comments SET memo_=".db_escape($memo_)." WHERE type=$type AND id=$id AND date_='$date'";
48         db_query($sql, "could not update comments");
49         }
50 }
51
52 //--------------------------------------------------------------------------------------------------
53
54 function delete_comments($type, $type_no)
55 {
56         $sql = "DELETE FROM ".TB_PREF."comments WHERE type=$type AND id=$type_no";
57
58         db_query($sql, "could not delete from comments transaction table");
59 }
60
61 //--------------------------------------------------------------------------------------------------
62
63 ?>