Eye Form tweaks
[openemr.git] / library / onotes.inc
bloba4714ae37894d1811b7b397c6f1e8c41abbae2dd
1 <?php
2 /**
3  *  Office notes library
4  *
5  * LICENSE: This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 3
8  * of the License, or (at your option) any later version.
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
15  *
16  * @package OpenEMR
17  * @author  Brady Miller <brady@sparmy.com>
18  * @link    http://www.open-emr.org
19  */
21 function getOnoteById ($id, $cols = "*")
23         return sqlQuery("select $cols from onotes where id=? order by date DESC limit 0,1", array($id));
26 function getOnoteByDate ($date, $activity = "1", $cols = "*", $limit="all", $offset="0")
29         $sqlBindArray = array();
30         if($limit == "all")
31         {
32                 $sql = "select $cols from onotes where date like ? ";
33                 array_push($sqlBindArray,"%".$date."%");
34                 if ($activity != "all") {
35                         $sql .= "and activity=? ";
36                         array_push($sqlBindArray,$activity);
37                 }
39                 $sql .= "order by date DESC";
40         }
41         else
42         {
43                 $sql = "select $cols from onotes where date like ? ";
44                 array_push($sqlBindArray,"%".$date."%");
45                 if ($activity != "all") {
46                         $sql .= "and activity =? ";
47                         array_push($sqlBindArray,$activity);
48                 }
50                 $sql .= "order by date DESC LIMIT ".escape_limit($offset).",".escape_limit($limit);
51         }
52         
53         $res = sqlStatement($sql,$sqlBindArray);
55         for ($iter = 0;$row = sqlFetchArray($res);$iter++)
56                 $all[$iter] = $row;
57         return $all;
60 function addOnote($body, $activity = "1")
62         return sqlInsert("insert into onotes (date, body, user, groupname, activity) values (NOW(),?,?,?,?)", array($body,$_SESSION['authUser'],$_SESSION['authProvider'],$activity));
65 function disappearOnote($id)
67         sqlStatement("update onotes set activity = '0' where id=?", array($id));
68         return true;
71 function reappearOnote ($id)
73         sqlStatement("update onotes set activity = '1' where id=?", array($id));
74         return true;