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.
11 // 2012-01-01 - Added display of home and cell phone and fixed header
13 require_once("../globals.php");
14 require_once("../../library/patient.inc");
15 require_once("$srcdir/formatting.inc.php");
16 require_once "$srcdir/options.inc.php";
17 require_once "$srcdir/formdata.inc.php";
18 require_once "$srcdir/appointments.inc.php";
20 $alertmsg = ''; // not used yet but maybe later
21 $patient = $_REQUEST['patient'];
23 if ($patient && ! $_POST['form_from_date']) {
24 // If a specific patient, default to 2 years ago.
26 $from_date = date("$tmp-m-d");
28 $from_date = fixDate($_POST['form_from_date'], date('Y-m-d'));
29 $to_date = fixDate($_POST['form_to_date'], date('Y-m-d'));
32 $show_available_times = false;
33 if ( $_POST['form_show_available'] ) {
34 $show_available_times = true;
36 //$to_date = fixDate($_POST['form_to_date'], '');
37 $provider = $_POST['form_provider'];
38 $facility = $_POST['form_facility']; //(CHEMED) facility filter
39 $form_orderby = getComparisonOrder( $_REQUEST['form_orderby'] ) ?
$_REQUEST['form_orderby'] : 'date';
46 <?php
html_header_show();?
>
48 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
50 <title
><?php
xl('Appointments Report','e'); ?
></title
>
52 <script type
="text/javascript" src
="../../library/overlib_mini.js"></script
>
53 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
54 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
55 <script type
="text/javascript" src
="../../library/js/jquery.1.3.2.js"></script
>
57 <script type
="text/javascript">
59 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
61 function dosort(orderby
) {
62 var f
= document
.forms
[0];
63 f
.form_orderby
.value
= orderby
;
68 function oldEvt(eventid
) {
69 dlgopen('../main/calendar/add_edit_event.php?eid=' + eventid
, 'blank', 550, 270);
72 function refreshme() {
74 document
.forms
[0].submit();
79 <style type
="text/css">
80 /* specifically include & exclude from printing */
86 #report_parameters_daterange {
90 #report_results table {
95 /* specifically exclude some from the screen */
97 #report_parameters_daterange {
105 <body
class="body_top">
107 <!-- Required
for the popup date selectors
-->
109 style
="position: absolute; visibility: hidden; z-index: 1000;"></div
>
111 <span
class='title'><?php
xl('Report','e'); ?
> - <?php
xl('Appointments','e'); ?
></span
>
113 <div id
="report_parameters_daterange"><?php
echo date("d F Y", strtotime($form_from_date)) ." to ". date("d F Y", strtotime($form_to_date)); ?
>
116 <form method
='post' name
='theform' id
='theform' action
='appointments_report.php'>
118 <div id
="report_parameters">
123 <div style
='float: left'>
127 <td
class='label'><?php
xl('Facility','e'); ?
>:</td
>
128 <td
><?php
dropdown_facility(strip_escape_custom($facility), 'form_facility'); ?
>
130 <td
class='label'><?php
xl('Provider','e'); ?
>:</td
>
133 // Build a drop-down list of providers.
136 $query = "SELECT id, lname, fname FROM users WHERE ".
137 "authorized = 1 $provider_facility_filter ORDER BY lname, fname"; //(CHEMED) facility filter
139 $ures = sqlStatement($query);
141 echo " <select name='form_provider'>\n";
142 echo " <option value=''>-- " . xl('All') . " --\n";
144 while ($urow = sqlFetchArray($ures)) {
145 $provid = $urow['id'];
146 echo " <option value='$provid'";
147 if ($provid == $_POST['form_provider']) echo " selected";
148 echo ">" . $urow['lname'] . ", " . $urow['fname'] . "\n";
154 <td
><input type
='checkbox' name
='form_show_available'
155 title
='<?php xl('Show Available Times
','e
'); ?>'
156 <?php
if ( $show_available_times ) echo ' checked'; ?
>> <?php
xl( 'Show Available Times','e' ); ?
>
160 <td
class='label'><?php
xl('From','e'); ?
>:</td
>
161 <td
><input type
='text' name
='form_from_date' id
="form_from_date"
162 size
='10' value
='<?php echo $form_from_date ?>'
163 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)'
164 title
='yyyy-mm-dd'> <img src
='../pic/show_calendar.gif'
165 align
='absbottom' width
='24' height
='22' id
='img_from_date'
166 border
='0' alt
='[?]' style
='cursor: pointer'
167 title
='<?php xl('Click here to choose a date
','e
'); ?>'></td
>
168 <td
class='label'><?php
xl('To','e'); ?
>:</td
>
169 <td
><input type
='text' name
='form_to_date' id
="form_to_date"
170 size
='10' value
='<?php echo $form_to_date ?>'
171 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)'
172 title
='yyyy-mm-dd'> <img src
='../pic/show_calendar.gif'
173 align
='absbottom' width
='24' height
='22' id
='img_to_date'
174 border
='0' alt
='[?]' style
='cursor: pointer'
175 title
='<?php xl('Click here to choose a date
','e
'); ?>'></td
>
182 <td align
='left' valign
='middle' height
="100%">
183 <table style
='border-left: 1px solid; width: 100%; height: 100%'>
186 <div style
='margin-left: 15px'>
187 <a href
='#' class='css_button' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
188 <span
> <?php
xl('Submit','e'); ?
> </span
> </a
>
189 <?php
if ($_POST['form_refresh'] ||
$_POST['form_orderby'] ) { ?
>
190 <a href
='#' class='css_button' onclick
='window.print()'>
191 <span
> <?php
xl('Print','e'); ?
> </span
> </a
>
192 <a href
='#' class='css_button' onclick
='window.open("../patient_file/printed_fee_sheet.php?fill=2","_blank")'>
193 <span
> <?php
xl('Superbills','e'); ?
> </span
> </a
>
197 <tr
> 
; 
;<?php
xl('Most column headers can be clicked to change sort order','e') ?
></tr
>
204 <!-- end of search parameters
--> <?php
205 if ($_POST['form_refresh'] ||
$_POST['form_orderby']) {
207 <div id
="report_results">
211 <th
><a href
="nojs.php" onclick
="return dosort('doctor')"
212 <?php
if ($form_orderby == "doctor") echo " style=\"color:#00cc00\"" ?
>><?php
xl('Provider','e'); ?
>
215 <th
><a href
="nojs.php" onclick
="return dosort('date')"
216 <?php
if ($form_orderby == "date") echo " style=\"color:#00cc00\"" ?
>><?php
xl('Date','e'); ?
></a
>
219 <th
><a href
="nojs.php" onclick
="return dosort('time')"
220 <?php
if ($form_orderby == "time") echo " style=\"color:#00cc00\"" ?
>><?php
xl('Time','e'); ?
></a
>
223 <th
><a href
="nojs.php" onclick
="return dosort('patient')"
224 <?php
if ($form_orderby == "patient") echo " style=\"color:#00cc00\"" ?
>><?php
xl('Patient','e'); ?
></a
>
227 <th
><a href
="nojs.php" onclick
="return dosort('pubpid')"
228 <?php
if ($form_orderby == "pubpid") echo " style=\"color:#00cc00\"" ?
>><?php
xl('ID','e'); ?
></a
>
231 <th
><?php
xl('Home','e'); //Sorting by phone# not really useful ?></th>
233 <th
><?php
xl('Cell','e'); //Sorting by phone# not really useful ?></th>
235 <th
><a href
="nojs.php" onclick
="return dosort('type')"
236 <?php
if ($form_orderby == "type") echo " style=\"color:#00cc00\"" ?
>><?php
xl('Type','e'); ?
></a
>
239 <th
><a href
="nojs.php" onclick
="return dosort('comment')"
240 <?php
if ($form_orderby == "comment") echo " style=\"color:#00cc00\"" ?
>><?php
xl('Comment','e'); ?
></a
>
245 <!-- added
for better
print-ability
-->
249 $appointments = fetchAppointments( $from_date, $to_date, $patient, $provider, $facility );
251 if ( $show_available_times ) {
252 $availableSlots = getAvailableSlots( $from_date, $to_date, $provider, $facility );
253 $appointments = array_merge( $appointments, $availableSlots );
256 $appointments = sortAppointments( $appointments, $form_orderby );
257 $pid_list = array(); // Initialize list of PIDs for Superbill option
259 foreach ( $appointments as $appointment ) {
260 array_push($pid_list,$appointment['pid']);
261 $patient_id = $appointment['pid'];
262 $docname = $appointment['ulname'] . ', ' . $appointment['ufname'] . ' ' . $appointment['umname'];
268 <tr bgcolor
='<?php echo $bgcolor ?>'>
269 <td
class="detail"> 
;<?php
echo ($docname == $lastdocname) ?
"" : $docname ?
>
272 <td
class="detail"><?php
echo oeFormatShortDate($appointment['pc_eventDate']) ?
>
275 <td
class="detail"><?php
echo oeFormatTime($appointment['pc_startTime']) ?
>
278 <td
class="detail"> 
;<?php
echo $appointment['fname'] . " " . $appointment['lname'] ?
>
281 <td
class="detail"> 
;<?php
echo $appointment['pubpid'] ?
></td
>
283 <td
class="detail"> 
;<?php
echo $appointment['phone_home'] ?
></td
>
285 <td
class="detail"> 
;<?php
echo $appointment['phone_cell'] ?
></td
>
287 <td
class="detail"> 
;<?php
echo xl_appt_category($appointment['pc_catname']) ?
>
290 <td
class="detail"> 
;<?php
echo $appointment['pc_hometext'] ?
></td
>
295 $lastdocname = $docname;
297 // assign the session key with the $pid_list array - note array might be empty -- handle on the printed_fee_sheet.php page.
298 $_SESSION['pidList'] = $pid_list;
303 <!-- end of search results
--> <?php
} else { ?
>
304 <div
class='text'><?php
echo xl('Please input search criteria above, and click Submit to view results.', 'e' ); ?
>
306 <?php
} ?
> <input type
="hidden" name
="form_orderby"
307 value
="<?php echo $form_orderby ?>" /> <input type
="hidden"
308 name
="patient" value
="<?php echo $patient ?>" /> <input type
='hidden'
309 name
='form_refresh' id
='form_refresh' value
='' /></form
>
311 <script type
="text/javascript">
314 if ($alertmsg) { echo " alert('$alertmsg');\n"; }
321 <!-- stuff
for the popup calendar
-->
322 <style type
="text/css">
323 @import
url(../../library
/dynarch_calendar
.css
);
325 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
326 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
327 <script type
="text/javascript"
328 src
="../../library/dynarch_calendar_setup.js"></script
>
329 <script type
="text/javascript">
330 Calendar
.setup({inputField
:"form_from_date", ifFormat
:"%Y-%m-%d", button
:"img_from_date"});
331 Calendar
.setup({inputField
:"form_to_date", ifFormat
:"%Y-%m-%d", button
:"img_to_date"});