in some php versions touch will give an error, error output supressed by @
[openemr.git] / library / pnotes.inc
blob5f94f8bf4821ba36a9c81dcd66f83756d6d20ced
1 <?php
2 require_once("{$GLOBALS['srcdir']}/sql.inc");
4 function getPnoteById ($id, $cols = "*")
6         return sqlQuery("select $cols from pnotes where id='$id' order by date DESC limit 0,1");
9 function getPnotesByDate ($date, $activity = "1", $cols = "*", $pid = "%", $limit="all", $start=0)
12         if($limit == "all")
13         {
15                 $sql = "select $cols from pnotes where date like '%$date%' and pid like '$pid' ";
16                 if ($activity != "all")
17                         $sql .= "and activity = '$activity' ";
18                 $sql .= "order by date DESC";
19         }
20         else
21         {
22                 $sql = "select $cols from pnotes where date like '%$date%' and pid like '$pid' ";
23                 if ($activity != "all")
24                         $sql .= "and activity = '$activity' ";
25                 $sql .= "order by date DESC LIMIT $start, $limit";
26         }
28         $res = sqlStatement($sql);
29         
30         for ($iter = 0;$row = sqlFetchArray($res);$iter++)
31                 $all[$iter] = $row;
32         return $all;
35 function getPnotesByPid ($pid, $activity = "1", $cols = "*", $limit=10, $start=0)
37         $res = sqlStatement("select $cols from pnotes where pid like '$pid' and activity = '$activity' order by date DESC LIMIT $start,$limit");
38         for ($iter = 0;$row = sqlFetchArray($res);$iter++)
39                 $all[$iter] = $row;
40         return $all;
43 function addPnote($pid, $body, $authorized = "0", $activity = "1")
45         $body = mysql_escape_string($body);
46         return sqlInsert("insert into pnotes (date, body, pid, user, groupname, authorized, activity) values (NOW(), '$body','$pid', '" . $_SESSION['authUser'] . "', '". $_SESSION['authProvider'] ."', '$authorized', '$activity')");
49 function authorizePnote($id, $authorized = "1")
51         sqlQuery("update pnotes set authorized = '$authorized' where id = '$id'");
54 function disappearPnote($id)
56         sqlStatement("update pnotes set activity = '0' where id='$id'");
57         return true;
60 function reappearPnote ($id)
62         sqlStatement("update pnotes set activity = '1' where id='$id'");
63         return true;