2 //function returns the next most recent appointment given a pid
3 function getNextAppointment ($pid) {
4 $query = "select * from calendar where pid=$pid and time>now() order by time limit 1";
5 $rez = sqlStatement($query);
6 echo "<!-- getNextAppointment $pid -$query- -->";
7 return sqlFetchArray($rez);
11 //this function returns calendar data given date and provider
12 function getCalendarDay($datetime,$owner,$groupname) {
13 $query = "select * from calendar where time like '$datetime%' and owner like '$owner' and groupname like '$groupname' order by time";
14 $rez = sqlStatement($query);
15 for($iter=0; $row=sqlFetchArray($rez); $iter++)
16 $returnval[$iter]=$row;
18 echo "<!-- getCalendarDay -$query- $datetime $owner $groupname -->";
22 //toggle the status of a noshow calendar entry
23 function toggleNoShow( $cid) {
24 $rez = sqlStatement("select noshow from calendar where id=$cid");
25 $row=sqlFetchArray($rez);
26 $oldnoshowval = $row{noshow};
27 $newnoshowval = !($oldnoshowval);
28 $query = "update calendar set noshow='$newnoshowval' where id=$cid";
33 //return array of provider usernames
34 function getProviderUsernames() {
35 $rez = sqlStatement("select distinct username,lname,fname from users where authorized=1");
36 for($iter=0; $row=sqlFetchArray($rez); $iter++)
37 $returnval[$iter]=$row;
43 function getIDfromUser($name) {
44 $query = "select id from users where username=\"" . mysql_real_escape_string($name) . "\" limit 1";
45 $rez = sqlStatement($query);
46 $row = sqlFetchArray($rez);
47 if (!is_numeric($row['id']))
52 function getAuthorizedIDs() {
53 $query = "select id, username from users where authorized=1 ";
54 $rez = sqlStatement($query);
55 for($iter=0; $row=sqlFetchArray($rez); $iter++)
56 $returnval[$iter]=$row;
61 function getUserInfo() {
62 $rez = sqlStatement("select distinct id,username,lname,fname, authorized, info, facility from users");
63 for($iter=0; $row=sqlFetchArray($rez); $iter++)
64 $returnval[$iter]=$row;
68 function getUsername($uID) {
69 $pi = getProviderInfo($uID,false);
70 if (strlen($pi["username"]) > 0) {
71 return $pi['username'];
77 //retrieve the name based on the username
78 function getNamefromUsername($username) {
79 $query = "select * from users where username like '$username'";
80 $res = sqlQuery($query);
85 //retrieve calendar information from calendar id
86 function getCalendarfromID ($calid) {
88 //this table is deprecated and has been removed from new versions
89 //return sqlQuery("select * from calendar where id='$calid'");
93 //get calendar dates in a range of dates
94 function getCalendarRanges ($fromdate, $todate, $username) {
95 $rez = sqlStatement("select * from calendar where time>='$fromdate' and time<'$todate' and owner like '$username' order by time");
96 for($iter=0; $row=sqlFetchArray($rez); $iter++)
97 $returnval[$iter]=$row;
104 //get calendar dates in a range of dates
105 function getCalendarbyTimeandRange ($time, $fromdate, $todate, $username) {
106 $query = "select * from calendar where time like '% $time%' and time>='$fromdate' and time<'$todate' and owner like '$username' order by time";
107 $rez = sqlStatement($query);
108 for($iter=0; $row=sqlFetchArray($rez); $iter++)
109 $returnval[$iter]=$row;
110 echo "<!-- getcalendarbytimeandrange -$query- -->";
116 //add new calendar entry item
117 function newCalendarItem (
127 sqlQuery("insert into calendar set pid=$pid,time='$time',reason='$reason',owner='$owner',groupname='$groupname',date=now()");
130 //delete a calendar entry item
131 function deleteCalendarItem( $calid,$pid) {
132 sqlQuery("delete from calendar where id='$calid' and pid='$pid'");
137 //save an edited calendar entry item
138 function saveCalendarUpdate (
149 sqlQuery("update calendar set pid=$pid,time='$time',reason='$reason',owner='$owner',groupname='$groupname',date=now() where id='$calid'");
153 //replicated functionality of postcalendar_getDate
154 function pc_getDate($format='%Y%m%d') {
155 // list($Date,$jumpday,$jumpmonth,$jumpyear) = pnVarCleanFromInput('Date','jumpday','jumpmonth','jumpyear');
157 // if we still don't have a date then calculate it
159 // check the jump menu
160 if(!isset($jumpday)) $jumpday = strftime('%d',$time);
161 if(!isset($jumpmonth)) $jumpmonth = strftime('%m',$time);
162 if(!isset($jumpyear)) $jumpyear = strftime('%Y',$time);
163 // create the correct date string
164 $Date = (int) "$jumpyear$jumpmonth$jumpday";
166 $y = substr($Date,0,4);
167 $m = substr($Date,4,2);
168 $d = substr($Date,6,2);
169 return strftime($format,mktime(0,0,0,$m,$d,$y));