Add date format cleaner for x12 5010 - tmccormi
[openemr.git] / patients / get_appointments.php
blobf7e9706969de3ae02f4484d62745a48caae8578c
1 <?php
2 // Copyright (C) 2011 Cassian LUP <cassi.lup@gmail.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 //SANITIZE ALL ESCAPES
10 $sanitize_all_escapes=true;
12 //STOP FAKE REGISTER GLOBALS
13 $fake_register_globals=false;
15 //landing page definition -- where to go if something goes wrong
16 $landingpage = "index.php";
19 // kick out if patient not authenticated
20 session_start();
21 if ( isset($_SESSION['pid']) && isset($_SESSION['patient_portal_onsite']) ) {
22 $pid = $_SESSION['pid'];
24 else {
25 session_destroy();
26 header('Location: '.$landingpage.'?w');
27 exit;
31 $ignoreAuth=true;
32 include_once('../interface/globals.php');
34 $query = "SELECT e.pc_eid, e.pc_aid, e.pc_title, e.pc_eventDate, " .
35 "e.pc_startTime, e.pc_hometext, u.fname, u.lname, u.mname, " .
36 "c.pc_catname " .
37 "FROM openemr_postcalendar_events AS e, users AS u, " .
38 "openemr_postcalendar_categories AS c WHERE " .
39 "e.pc_pid = ? AND e.pc_eventDate >= CURRENT_DATE AND " .
40 "u.id = e.pc_aid AND e.pc_catid = c.pc_catid " .
41 "ORDER BY e.pc_eventDate, e.pc_startTime";
43 //echo $query;
45 $res = sqlStatement($query, array($pid) );
47 //echo "test";
48 if(sqlNumRows($res)>0)
50 $count = 0;
52 while($row = sqlFetchArray($res)) {
53 $count++;
54 $dayname = xl(date("l", strtotime($row['pc_eventDate'])));
55 $dispampm = "am";
56 $disphour = substr($row['pc_startTime'], 0, 2) + 0;
57 $dispmin = substr($row['pc_startTime'], 3, 2);
58 if ($disphour >= 12) {
59 $dispampm = "pm";
60 if ($disphour > 12) $disphour -= 12;
62 if ($row['pc_hometext'] != "") {
63 $etitle = 'Comments'.": ".$row['pc_hometext']."\r\n";
64 } else {
65 $etitle = "";
67 if ($GLOBALS['portal_onsite_appt_modify']) {
68 echo "<a href='add_edit_event_user.php?eid=" . htmlspecialchars($row['pc_eid'],ENT_QUOTES) .
69 "' class='edit_event iframe' title='" . htmlspecialchars($etitle,ENT_QUOTES) . "'>";
71 echo "<b>" . htmlspecialchars($dayname . ", " . $row['pc_eventDate'],ENT_NOQUOTES) . "</b><br>";
72 echo htmlspecialchars("$disphour:$dispmin " . $dispampm . " " . $row['pc_catname'],ENT_NOQUOTES) . "<br>\n";
73 echo htmlspecialchars($row['fname'] . " " . $row['lname'],ENT_NOQUOTES);
74 if ($GLOBALS['portal_onsite_appt_modify']) {
75 echo "</a><br>\n";
77 else {
78 echo "<br>\n";
81 if (isset($res) && $res != null) {
82 if ( $count < 1 ) { echo "&nbsp;&nbsp;" . htmlspecialchars('None',ENT_NOQUOTES); }
84 } else { // if no appts
85 echo htmlspecialchars( xl('No Appointments'),ENT_NOQUOTES);