forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pnotes.inc
84 lines (71 loc) · 2.49 KB
/
pnotes.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
require_once("{$GLOBALS['srcdir']}/sql.inc");
function getPnoteById($id, $cols = "*")
{
return sqlQuery("SELECT $cols FROM pnotes WHERE id='$id' " .
"order by date DESC limit 0,1");
}
function getPnotesByDate($date, $activity = "1", $cols = "*", $pid = "%",
$limit = "all", $start = 0, $username = '')
{
$sql = "SELECT $cols FROM pnotes WHERE date LIKE '%$date%' " .
"AND pid LIKE '$pid' ";
if ($activity != "all")
$sql .= "AND activity = '$activity' ";
if ($username)
$sql .= "AND assigned_to = '$username' ";
$sql .= "ORDER BY date DESC";
if($limit != "all")
$sql .= " LIMIT $start, $limit";
$res = sqlStatement($sql);
for ($iter = 0;$row = sqlFetchArray($res);$iter++)
$all[$iter] = $row;
return $all;
}
function getPnotesByPid ($pid, $activity = "1", $cols = "*", $limit=10, $start=0)
{
$res = sqlStatement("SELECT $cols FROM pnotes WHERE pid LIKE '$pid' " .
"AND activity = '$activity' ORDER BY date DESC LIMIT $start,$limit");
for ($iter = 0; $row = sqlFetchArray($res); $iter++)
$all[$iter] = $row;
return $all;
}
function addPnote($pid, $newtext, $authorized = '0', $activity = '1',
$title='Unassigned', $assigned_to = '')
{
$body = date('Y-m-d H:i') . ' (' . $_SESSION['authUser'];
if ($assigned_to) $body .= " to $assigned_to";
$body = addslashes($body . ') ' . $newtext);
return sqlInsert("INSERT INTO pnotes (date, body, pid, user, groupname, " .
"authorized, activity, title, assigned_to) VALUES (NOW(), '$body', '$pid', '" .
$_SESSION['authUser'] . "', '". $_SESSION['authProvider'] .
"', '$authorized', '$activity', '$title', '$assigned_to')");
}
function updatePnote($id, $newtext, $title, $assigned_to)
{
$row = getPnoteById($id);
if (! $row) die("updatePnote() did not find id '$id'");
$activity = $assigned_to ? '1' : '0';
$body = $row['body'] . "\n" . date('Y-m-d H:i') .
' (' . $_SESSION['authUser'];
if ($assigned_to) $body .= " to $assigned_to";
$body = addslashes($body . ') ' . $newtext);
sqlStatement("UPDATE pnotes SET " .
"body = '$body', activity = '$activity', title='$title', " .
"assigned_to = '$assigned_to' WHERE id = '$id'");
}
function authorizePnote($id, $authorized = "1")
{
sqlQuery("UPDATE pnotes SET authorized = '$authorized' WHERE id = '$id'");
}
function disappearPnote($id)
{
sqlStatement("UPDATE pnotes SET activity = '0' WHERE id='$id'");
return true;
}
function reappearPnote ($id)
{
sqlStatement("UPDATE pnotes SET activity = '1' WHERE id='$id'");
return true;
}
?>