Fix for the Open in New Window in Patient/Client->Patients search gui, take 2.
[openemr.git] / library / onotes.inc
blobe927e9bea0c97a5bcf0fbbdf96686c42e073d06f
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                 $sql .= "order by date DESC";
38         }
39         else
40         {
41                 $sql = "select $cols from onotes where date like ? ";
42                 array_push($sqlBindArray,"%".$date."%");
43                 if ($activity != "all")
44                         $sql .= "and activity =? ";
45                         array_push($sqlBindArray,$activity);
46                 $sql .= "order by date DESC LIMIT ".escape_limit($offset).",".escape_limit($limit);
47         }
48         
49         $res = sqlStatement($sql,$sqlBindArray);
51         for ($iter = 0;$row = sqlFetchArray($res);$iter++)
52                 $all[$iter] = $row;
53         return $all;
56 function addOnote($body, $activity = "1")
58         return sqlInsert("insert into onotes (date, body, user, groupname, activity) values (NOW(),?,?,?,?)", array($body,$_SESSION['authUser'],$_SESSION['authProvider'],$activity));
61 function disappearOnote($id)
63         sqlStatement("update onotes set activity = '0' where id=?", array($id));
64         return true;
67 function reappearOnote ($id)
69         sqlStatement("update onotes set activity = '1' where id=?", array($id));
70         return true;