2 // Copyright (C) 2005-2010 Rod Roark <rod@sunsetsystems.com>
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 // This report shows upcoming appointments with filtering and
10 // sorting by patient, practitioner, appointment type, and date.
12 require_once("../globals.php");
13 require_once("../../library/patient.inc");
14 require_once("$srcdir/formatting.inc.php");
15 require_once "$srcdir/options.inc.php";
16 require_once "$srcdir/formdata.inc.php";
17 require_once "$srcdir/appointments.inc.php";
19 $alertmsg = ''; // not used yet but maybe later
20 $patient = $_REQUEST['patient'];
22 if ($patient && ! $_POST['form_from_date']) {
23 // If a specific patient, default to 2 years ago.
25 $from_date = date("$tmp-m-d");
27 $from_date = fixDate($_POST['form_from_date'], date('Y-m-d'));
28 $to_date = fixDate($_POST['form_to_date'], date('Y-m-d'));
31 $show_available_times = false;
32 if ( $_POST['form_show_available'] ) {
33 $show_available_times = true;
35 //$to_date = fixDate($_POST['form_to_date'], '');
36 $provider = $_POST['form_provider'];
37 $facility = $_POST['form_facility']; //(CHEMED) facility filter
38 $form_orderby = getComparisonOrder( $_REQUEST['form_orderby'] ) ?
$_REQUEST['form_orderby'] : 'date';
45 <?php
html_header_show();?
>
47 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
49 <title
><?php
xl('Appointments Report','e'); ?
></title
>
51 <script type
="text/javascript" src
="../../library/overlib_mini.js"></script
>
52 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
53 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
54 <script type
="text/javascript" src
="../../library/js/jquery.1.3.2.js"></script
>
56 <script LANGUAGE
="JavaScript">
58 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
60 function dosort(orderby
) {
61 var f
= document
.forms
[0];
62 f
.form_orderby
.value
= orderby
;
67 function oldEvt(eventid
) {
68 dlgopen('../main/calendar/add_edit_event.php?eid=' + eventid
, 'blank', 550, 270);
71 function refreshme() {
73 document
.forms
[0].submit();
78 <style type
="text/css">
79 /* specifically include & exclude from printing */
85 #report_parameters_daterange {
89 #report_results table {
94 /* specifically exclude some from the screen */
96 #report_parameters_daterange {
104 <body
class="body_top">
106 <!-- Required
for the popup date selectors
-->
108 style
="position: absolute; visibility: hidden; z-index: 1000;"></div
>
110 <span
class='title'><?php
xl('Report','e'); ?
> - <?php
xl('Appointments','e'); ?
></span
>
112 <div id
="report_parameters_daterange"><?php
echo date("d F Y", strtotime($form_from_date)) ." to ". date("d F Y", strtotime($form_to_date)); ?
>
115 <form method
='post' name
='theform' id
='theform'
116 action
='appointments_report.php'>
117 <form name
='theform' id
='theform' method
='post'
118 action
='referrals_report.php'>
120 <div id
="report_parameters">
125 <div style
='float: left'>
129 <td
class='label'><?php
xl('Facility','e'); ?
>:</td
>
130 <td
><?php
dropdown_facility(strip_escape_custom($facility), 'form_facility'); ?
>
132 <td
class='label'><?php
xl('Provider','e'); ?
>:</td
>
135 // Build a drop-down list of providers.
138 $query = "SELECT id, lname, fname FROM users WHERE ".
139 "authorized = 1 $provider_facility_filter ORDER BY lname, fname"; //(CHEMED) facility filter
141 $ures = sqlStatement($query);
143 echo " <select name='form_provider'>\n";
144 echo " <option value=''>-- " . xl('All') . " --\n";
146 while ($urow = sqlFetchArray($ures)) {
147 $provid = $urow['id'];
148 echo " <option value='$provid'";
149 if ($provid == $_POST['form_provider']) echo " selected";
150 echo ">" . $urow['lname'] . ", " . $urow['fname'] . "\n";
156 <td
><input type
='checkbox' name
='form_show_available'
157 title
='<?php xl('Show Available Times
','e
'); ?>'
158 <?php
if ( $show_available_times ) echo ' checked'; ?
>> <?php
xl( 'Show Available Times','e' ); ?
>
162 <td
class='label'><?php
xl('From','e'); ?
>:</td
>
163 <td
><input type
='text' name
='form_from_date' id
="form_from_date"
164 size
='10' value
='<?php echo $form_from_date ?>'
165 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)'
166 title
='yyyy-mm-dd'> <img src
='../pic/show_calendar.gif'
167 align
='absbottom' width
='24' height
='22' id
='img_from_date'
168 border
='0' alt
='[?]' style
='cursor: pointer'
169 title
='<?php xl('Click here to choose a date
','e
'); ?>'></td
>
170 <td
class='label'><?php
xl('To','e'); ?
>:</td
>
171 <td
><input type
='text' name
='form_to_date' id
="form_to_date"
172 size
='10' value
='<?php echo $form_to_date ?>'
173 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)'
174 title
='yyyy-mm-dd'> <img src
='../pic/show_calendar.gif'
175 align
='absbottom' width
='24' height
='22' id
='img_to_date'
176 border
='0' alt
='[?]' style
='cursor: pointer'
177 title
='<?php xl('Click here to choose a date
','e
'); ?>'></td
>
184 <td align
='left' valign
='middle' height
="100%">
185 <table style
='border-left: 1px solid; width: 100%; height: 100%'>
188 <div style
='margin-left: 15px'><a href
='#' class='css_button'
189 onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
190 <span
> <?php
xl('Submit','e'); ?
> </span
> </a
> <?php
if ($_POST['form_refresh'] ||
$_POST['form_orderby'] ) { ?
>
191 <a href
='#' class='css_button' onclick
='window.print()'> <span
> <?php
xl('Print','e'); ?
>
192 </span
> </a
> <?php
} ?
></div
>
201 <!-- end of search parameters
--> <?php
202 if ($_POST['form_refresh'] ||
$_POST['form_orderby']) {
204 <div id
="report_results">
208 <th
><a href
="nojs.php" onclick
="return dosort('doctor')"
209 <?php
if ($form_orderby == "doctor") echo " style=\"color:#00cc00\"" ?
>><?php
xl('Provider','e'); ?
>
212 <th
><a href
="nojs.php" onclick
="return dosort('date')"
213 <?php
if ($form_orderby == "date") echo " style=\"color:#00cc00\"" ?
>><?php
xl('Date','e'); ?
></a
>
216 <th
><a href
="nojs.php" onclick
="return dosort('time')"
217 <?php
if ($form_orderby == "time") echo " style=\"color:#00cc00\"" ?
>><?php
xl('Time','e'); ?
></a
>
220 <th
><a href
="nojs.php" onclick
="return dosort('patient')"
221 <?php
if ($form_orderby == "patient") echo " style=\"color:#00cc00\"" ?
>><?php
xl('Patient','e'); ?
></a
>
224 <th
><a href
="nojs.php" onclick
="return dosort('pubpid')"
225 <?php
if ($form_orderby == "pubpid") echo " style=\"color:#00cc00\"" ?
>><?php
xl('ID','e'); ?
></a
>
228 <th
><a href
="nojs.php" onclick
="return dosort('type')"
229 <?php
if ($form_orderby == "type") echo " style=\"color:#00cc00\"" ?
>><?php
xl('Type','e'); ?
></a
>
232 <th
><a href
="nojs.php" onclick
="return dosort('comment')"
233 <?php
if ($form_orderby == "comment") echo " style=\"color:#00cc00\"" ?
>><?php
xl('Comment','e'); ?
></a
>
238 <!-- added
for better
print-ability
-->
242 $appointments = fetchAppointments( $from_date, $to_date, $patient, $provider, $facility );
244 if ( $show_available_times ) {
245 $availableSlots = getAvailableSlots( $from_date, $to_date, $provider, $facility );
246 $appointments = array_merge( $appointments, $availableSlots );
249 $appointments = sortAppointments( $appointments, $form_orderby );
251 foreach ( $appointments as $appointment ) {
252 $patient_id = $appointment['pid'];
253 $docname = $appointment['ulname'] . ', ' . $appointment['ufname'] . ' ' . $appointment['umname'];
259 <tr bgcolor
='<?php echo $bgcolor ?>'>
260 <td
class="detail"> 
;<?php
echo ($docname == $lastdocname) ?
"" : $docname ?
>
263 <td
class="detail"><?php
echo oeFormatShortDate($appointment['pc_eventDate']) ?
>
266 <td
class="detail"><?php
echo oeFormatTime($appointment['pc_startTime']) ?
>
269 <td
class="detail"> 
;<?php
echo $appointment['fname'] . " " . $appointment['lname'] ?
>
272 <td
class="detail"> 
;<?php
echo $appointment['pubpid'] ?
></td
>
274 <td
class="detail"> 
;<?php
echo xl_appt_category($appointment['pc_catname']) ?
>
277 <td
class="detail"> 
;<?php
echo $appointment['pc_hometext'] ?
></td
>
282 $lastdocname = $docname;
289 <!-- end of search results
--> <?php
} else { ?
>
290 <div
class='text'><?php
echo xl('Please input search criteria above, and click Submit to view results.', 'e' ); ?
>
292 <?php
} ?
> <input type
="hidden" name
="form_orderby"
293 value
="<?php echo $form_orderby ?>" /> <input type
="hidden"
294 name
="patient" value
="<?php echo $patient ?>" /> <input type
='hidden'
295 name
='form_refresh' id
='form_refresh' value
='' /></form
>
300 if ($alertmsg) { echo " alert('$alertmsg');\n"; }
307 <!-- stuff
for the popup calendar
-->
308 <style type
="text/css">
309 @import
url(../../library
/dynarch_calendar
.css
);
311 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
312 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
313 <script type
="text/javascript"
314 src
="../../library/dynarch_calendar_setup.js"></script
>
315 <script language
="Javascript">
316 Calendar
.setup({inputField
:"form_from_date", ifFormat
:"%Y-%m-%d", button
:"img_from_date"});
317 Calendar
.setup({inputField
:"form_to_date", ifFormat
:"%Y-%m-%d", button
:"img_to_date"});