2 [-*****************************************************************************-]
3 [-* This is the source code for both day/default.html and week/default.html. *-]
4 [-* They should always be identical. If you change one, copy to the other! *-]
5 [-*****************************************************************************-]
6 [-* Copyright (C)
2005 Rod Roark
<rod@sunsetsystems.com
> and others *-]
8 [-* This program is free software; you can redistribute it and/or *-]
9 [-* modify it under the terms of the GNU General Public License *-]
10 [-* as published by the Free Software Foundation; either version
2 *-]
11 [-* of the License, or (at your option) any later version. *-]
12 [-*****************************************************************************-]
13 [-config_load
file=
"default.conf"-]
14 [-*Load the Language Definitions*-]
15 [-config_load
file=
"lang.$USER_LANG"-]
16 [-include
file=
"$TPL_NAME/views/header.html"-]
17 [-* we want to include out stylesheet for this view*-]
18 [-fetch
file=
"$TPL_STYLE_PATH/day.css" assign=
"css"-]
22 a { text-decoration:none; }
23 .tacell { font-size:
10pt; background-color:#ddffdd; text-align:right; }
24 .tucell { font-size:
10pt; background-color:#ffbbbb; text-align:right; }
25 .eacell { font-size:
10pt; background-color:#ffffff; }
26 .eucell { font-size:
10pt; background-color:#ffbbbb; }
27 .nobot { border-bottom-width:
0px; }
28 .notop { border-top-width:
0px; }
31 <script language='JavaScript'
>
32 function newEvt(startampm
, starttimeh
, starttimem
, eventdate
, providerid
) {
33 location
= 'index.php?module=PostCalendar&func=submit' +
34 '&event_startampm=' + startampm
+
35 '&event_starttimeh=' + starttimeh
+
36 '&event_starttimem=' + starttimem
+
37 '&Date=' + eventdate
+
38 '&event_userid=' + providerid
;
40 function oldEvt(eventdate
, eventid
) {
41 location
= 'index.php?module=PostCalendar&func=view&viewtype=details' +
42 '&Date=' + eventdate
+
46 top
.location
= '../../patient_file/patient_file.php' +
47 '?set_pid=' + pid
+ '&pid=' + pid
;
53 // [-if $PRINT_VIEW !=
1-]
54 // [-*Main Navigation*-]
55 // [-include
file=
"$TPL_NAME/views/global/navigation.html"-]
58 $A_EVENTS =& $this-
>_tpl_vars['A_EVENTS'];
59 $S_EVENTS =& $this-
>_tpl_vars['S_EVENTS'];
60 $providers =& $this-
>_tpl_vars['providers'];
61 $times =& $this-
>_tpl_vars['times'];
62 $interval = $this-
>_tpl_vars['interval'];
63 $viewtype = $this-
>_tpl_vars['VIEW_TYPE'];
64 $PREV_WEEK_URL = $this-
>_tpl_vars['PREV_WEEK_URL'];
65 $NEXT_WEEK_URL = $this-
>_tpl_vars['NEXT_WEEK_URL'];
66 $PREV_DAY_URL = $this-
>_tpl_vars['PREV_DAY_URL'];
67 $NEXT_DAY_URL = $this-
>_tpl_vars['NEXT_DAY_URL'];
69 $Date = postcalendar_getDate();
70 if (!isset($y)) $y = substr($Date,
0,
4);
71 if (!isset($m)) $m = substr($Date,
4,
2);
72 if (!isset($d)) $d = substr($Date,
6,
2);
74 // echo
"<!-- There are " . count($A_EVENTS) .
" A_EVENTS days -->\n";
76 $MULTIDAY = count($A_EVENTS)
> 1;
78 $provinfo = getProviderInfo();
80 echo
"<form action='index.php?module=PostCalendar&func=view' method='post'>\n";
82 echo
"<table border='0' cellpadding='0' cellspacing='0' width='99%'>\n";
83 echo
" <tr><td colspan='3' height='5'></td></tr>\n";
86 // Build the scrolling selection list of providers.
87 echo
" <td rowspan='2' align='left' valign='top' width='33%' nowrap>\n";
88 echo
" <select multiple size='3' name='pc_username[]'>\n";
89 echo
" <option value='__PC_ALL__'>All Users</option>\n";
90 foreach ($provinfo as $doc) {
91 $username = $doc['username'];
92 echo
" <option value='$username'";
93 foreach ($providers as $provider)
94 if ($provider['username'] == $username) echo
" selected";
95 echo
">" . $doc['fname'] .
" " . $doc['lname'] .
"</option>\n";
100 // Build the date and view type selectors and the Go button.
101 echo
" <td align='center' valign='top' width='34%' nowrap>\n";
102 echo
" <select name='jumpmonth'>\n";
103 foreach (array('
01' =
> 'Jan', '
02' =
> 'Feb', '
03' =
> 'Mar', '
04' =
> 'Apr',
104 '
05' =
> 'May', '
06' =
> 'Jun', '
07' =
> 'Jul', '
08' =
> 'Aug',
105 '
09' =
> 'Sep', '
10' =
> 'Oct', '
11' =
> 'Nov', '
12' =
> 'Dec')
107 echo
" <option value='$key'";
108 if ($key == $m) echo
" selected";
109 echo
">$value</option>\n";
112 echo
"<select name='jumpday'>\n";
113 for ($i =
1; $i <=
31; ++$i) {
114 echo
" <option value='$i'";
115 if ($i == $d) echo
" selected";
116 echo
">$i</option>\n";
119 echo
"<select name='jumpyear'>\n";
120 for ($i =
2005; $i <=
2015; ++$i) {
121 echo
" <option value='$i'";
122 if ($i == $y) echo
" selected";
123 echo
">$i</option>\n";
126 echo
" <select name='viewtype'>\n";
127 foreach (array('day' =
> 'Day', 'week' =
> 'Week', 'month' =
> 'Month', 'year' =
> 'Year')
129 echo
" <option value='$key'";
130 if ($key == $viewtype) echo
" selected";
131 echo
">$value</option>\n";
134 echo
" <input type='submit' name='submit' value='Go' />\n";
137 // Show the Add and Search buttons.
138 echo
" <td align='right' valign='top' width='33%' nowrap>\n";
139 echo
" <input type='button' value='Add' onclick='location=\"index.php?module=PostCalendar&func=submit&Date=$Date&event_starttimeh=
23&event_startampm=
2\
"' />\n";
140 echo
" <input type='button' value='Search' onclick='location=\"index.php?module=PostCalendar&func=search\
"' />\n";
144 // Show the date/range and its previous- and next-day/week selectors.
146 echo
" <td align='center' width='34%' nowrap>\n";
147 $atmp = array_keys($A_EVENTS);
149 echo
"<a href='$PREV_WEEK_URL'><<</a> \n";
150 echo date(
"F j Y", strtotime($atmp[
0]));
152 echo date(
"F j Y", strtotime($atmp[count($atmp)-
1]));
153 echo
" <a href='$NEXT_WEEK_URL'>>></a>\n";
155 echo
"<a href='$PREV_DAY_URL'><<</a> \n";
156 echo date(
"l, F j, Y", strtotime($atmp[
0]));
157 echo
" <a href='$NEXT_DAY_URL'>>></a>\n";
160 echo
" <td align='right' width='33%' nowrap>\n";
171 [-assign
var=
"dayname" value=$DATE|date_format:
"%w"-]
172 [-assign
var=
"day" value=$DATE|date_format:
"%d"|string_format:
"%1d"-]
173 [-assign
var=
"month" value=$DATE|date_format:
"%m"|string_format:
"%1d"-]
174 [-assign
var=
"year" value=$DATE|date_format:
"%Y"|string_format:
"%4d"-]
176 [-pc_sort_events
var=
"S_EVENTS" sort=
"time" order=
"asc" value=$A_EVENTS-]
180 echo
"<table width='100%' border='1' cellpadding='1' cellspacing='0' >\n";
183 foreach ($A_EVENTS as $date =
> $events) {
184 $need_headers = true;
185 $eventdate = substr($date,
0,
4) . substr($date,
5,
2) . substr($date,
8,
2);
187 // If multiple days then show a date header for each.
190 echo
" <td colspan='" . (count($providers) *
2) .
"' align='center'>" .
191 date(
"l, F j, Y", strtotime($date)) .
"</td>";
195 $arr_events = $S_EVENTS[$date];
196 list($slotkey, $slotevent) = each($arr_events);
198 // This is an array of provider status information for this day,
199 // used to properly assign table cell attributes.
203 $lastslotindex = count($times) -
1;
205 // For each time slot...
206 foreach ($times as $slottime) {
207 $startampm = ($slottime['mer']) ==
"pm" ?
2 :
1;
208 $starttimeh = $slottime['hour'];
209 $starttimem = $slottime['minute'];
211 // Repeat doc names at
1PM. This is a kludge; omit it for released code.
212 // if ($starttimeh ==
13 && $starttimem ==
0) $need_headers = true;
214 // Get all events just for this time slot now, because we can pick up where
215 // we left off and because we don't want to re-scan all events for the day
216 // for each table cell.
219 for (; isset($slotkey); list($slotkey, $slotevent) = each($arr_events)) {
220 $starth = substr($slotevent['startTime'],
0,
2);
221 $startm = substr($slotevent['startTime'],
3,
2);
223 if ($starth
> $starttimeh) break;
224 if ($startm
>= ($starttimem + $interval)) break;
225 $arr_slot[$slotkey] = $slotevent;
227 $catid = $slotevent['catid'];
228 $providerid = $slotevent['aid'];
229 $durminutes = ceil($slotevent['duration'] /
60);
230 $durslots = ceil($durminutes / $interval);
232 // While we're here, collect information for setting cell colors.
233 if ($catid ==
2) { // in office
234 $provstat[$providerid]['in'] = true;
236 else if ($catid ==
3) { // out of office
237 $provstat[$providerid]['in'] = false;
239 else if ($catid ==
4 || $catid ==
8 || $catid ==
11) { // unavailable types
240 $endindex = $slotindex + $durslots;
241 for ($i = $slotindex; $i < $endindex; ++$i) {
242 $provstat[$providerid][$i]['res'] = true;
245 // if duration
> slot size then mark slots for border control.
247 $endindex = $slotindex + $durslots -
1;
248 for ($i = $slotindex; $i < $endindex; ++$i) {
249 $provstat[$providerid][$i]['ext'] = true;
254 // Write a header row with the provider names if appropriate.
256 $need_headers = false;
258 foreach ($providers as $provider) {
259 echo
" <td colspan='2' align='center'>";
260 echo $provider['fname'][
0] .
" " . $provider['lname'];
268 // We are now ready to write the table row for the current time slot.
269 // This loops once for each provider to be displayed.
271 foreach ($providers as $provider) {
272 $providerid = $provider['id'];
274 $content =
""; // this will be the event cell content
277 if ($provstat[$providerid][$slotindex]['res'] || ! $provstat[$providerid]['in']) {
281 // Remove top and/or bottom table cell borders using CSS when events span
282 // time slots or when the practitioner is not in-office. Using
"rowspan"
283 // would be a difficult and inferior solution to this problem.
286 if ($slotindex < $lastslotindex &&
287 ($provstat[$providerid][$slotindex]['ext'] || !$provstat[$providerid]['in'])) {
288 $tdstyle .=
" nobot";
290 if ($slotindex
> 0 && ($provstat[$providerid][$slotindex-
1]['ext'] ||
291 !($provstat[$providerid]['in'] || $provstat[$providerid]['wasin']))) {
292 $tdstyle .=
" notop";
295 $disptimeh = ($starttimeh
> 12) ? ($starttimeh -
12) : $starttimeh;
297 echo
" <td class='t$clsuffix'";
298 if ($slotindex ==
0) echo
" width='1%'";
300 echo
"<a href='javascript:newEvt($startampm,$starttimeh,$starttimem,$eventdate,$providerid)'>";
301 echo
"$disptimeh:$starttimem";
304 echo
" <td class='e$clsuffix$tdstyle'>";
306 // Scan all events for this time slot and generate the associated HTML for
307 // this doc. JavaScript is used in hrefs to reduce the volume of output.
310 while (list($eventkey, $event) = each($arr_slot)) {
311 if ($event['aid'] != $providerid) continue;
312 if ($content) $content .=
" ";
313 $starth = substr($event['startTime'],
0,
2);
314 $startm = substr($event['startTime'],
3,
2);
315 $eventid = $event['eid'];
316 $patientid = $event['pid'];
317 $commapos = strpos($event['patient_name'],
",");
318 $lname = addslashes(ucfirst(strtolower(substr($event['patient_name'],
0, $commapos))));
319 $fname = addslashes(ucfirst(strtolower(substr($event['patient_name'], $commapos +
2))));
320 $patient_dob = $event['patient_dob'];
321 $patient_age = $event['patient_age'];
322 $catid = $event['catid'];
323 $catname = $event['catname'];
324 $title =
"$fname, age $patient_age ($patient_dob) " . addslashes($event['hometext']);
325 if ($catid ==
2 || $catid ==
3 || $catid ==
4 || $catid ==
8 || $catid ==
11) {
326 if ($catid ==
2) $catname =
"IN";
327 else if ($catid ==
3) $catname =
"OUT";
328 else if ($catid ==
4) $catname =
"VACATION";
329 else if ($catid ==
8) $catname =
"LUNCH";
330 else if ($catid ==
11) $catname =
"RESERVED";
331 // Omit lunch, vacation, etc. if the doc is not in-office.
332 if ($provstat[$providerid]['in'] || $catid <
4) {
333 $content .=
"<a href='javascript:oldEvt($eventdate,$eventid)'>";
334 $content .= $catname .
"</a>";
337 else { // some sort of patient appointment
338 $content .=
"<a href='javascript:oldEvt($eventdate,$eventid)' title='$catname'>";
339 $content .= $startm .
"</a>";
340 $content .=
"<a href='javascript:goPid($patientid)' title='$title'>-";
341 if ($catid ==
1) $content .=
"<strike>";
343 if ($catid ==
1) $content .=
"</strike>";
348 if (! $content) $content =
" ";
349 echo $content .
"</td>\n";
351 // Keep track of whether the doc was in during the previous time slot.
352 $provstat[$providerid]['wasin'] = $provstat[$providerid]['in'];
365 // [-include
file=
"$TPL_NAME/views/global/footer.html"-]
366 // [-include
file=
"$TPL_NAME/views/footer.html"-]