Cleanup: removed all closing tags in php files.
[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="
17                 .db_escape($type)." AND id=".db_escape($type_no);
18
19         return db_query($sql, "could not query comments transaction table");
20 }
21
22 //--------------------------------------------------------------------------------------------------
23
24 function add_comments($type, $type_no, $date_, $memo_)
25 {
26         if ($memo_ != null && $memo_ != "")
27         {
28         $date = date2sql($date_);
29         $sql = "INSERT INTO ".TB_PREF."comments (type, id, date_, memo_)
30                 VALUES (".db_escape($type).", ".db_escape($type_no)
31                         .", '$date', ".db_escape($memo_).")";
32
33         db_query($sql, "could not add comments transaction entry");
34         }
35 }
36
37 //--------------------------------------------------------------------------------------------------
38
39 function update_comments($type, $id, $date_, $memo_)
40 {
41         if ($date_ == null)
42         {
43         delete_comments($type, $id);
44         add_comments($type, $id, Today(), $memo_);
45         }
46         else
47         {
48                 $date = date2sql($date_);
49         $sql = "UPDATE ".TB_PREF."comments SET memo_=".db_escape($memo_)
50                         ." WHERE type=".db_escape($type)." AND id=".db_escape($id)
51                         ." AND date_='$date'";
52         db_query($sql, "could not update comments");
53         }
54 }
55
56 //--------------------------------------------------------------------------------------------------
57
58 function delete_comments($type, $type_no)
59 {
60         $sql = "DELETE FROM ".TB_PREF."comments WHERE type=".db_escape($type)
61                 ." AND id=".db_escape($type_no);
62
63         db_query($sql, "could not delete from comments transaction table");
64 }
65
66 //--------------------------------------------------------------------------------------------------
67