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 type=
"text/javascript" src=
"../../../library/dialog.js"></script>
32 <script type=
"text/javascript" src=
"../../../library/overlib_mini.js"></script>
33 <script type=
"text/javascript" src=
"../../../library/calendar.js"></script>
34 <script type=
"text/javascript" src=
"../../../library/textformat.js"></script>
36 <script language='JavaScript'
>
38 var mypcc
= '[-php-] echo $GLOBALS['phone_country_code
'] [-/php-]';
40 // This is called from the event editor popup.
41 function refreshme() {
42 document
.forms
[0].submit();
45 function newEvt(startampm
, starttimeh
, starttimem
, eventdate
, providerid
) {
46 dlgopen('add_edit_event.php?startampm=' + startampm
+
47 '&starttimeh=' + starttimeh
+ '&starttimem=' + starttimem
+
48 '&date=' + eventdate
+ '&userid=' + providerid
,
52 function oldEvt(eventdate
, eventid
) {
53 dlgopen('add_edit_event.php?eid=' + eventid
, '_blank', 550, 270);
57 top
.location
= '../../patient_file/patient_file.php' +
58 '?set_pid=' + pid
+ '&pid=' + pid
;
63 <!-- Required for the popup date selectors -->
64 <div id=
"overDiv" style=
"position:absolute; visibility:hidden; z-index:1000;"></div>
68 // [-if $PRINT_VIEW !=
1-]
69 // [-*Main Navigation*-]
70 // [-include
file=
"$TPL_NAME/views/global/navigation.html"-]
73 $A_EVENTS =& $this-
>_tpl_vars['A_EVENTS'];
74 $S_EVENTS =& $this-
>_tpl_vars['S_EVENTS'];
75 $providers =& $this-
>_tpl_vars['providers'];
76 $times =& $this-
>_tpl_vars['times'];
77 $interval = $this-
>_tpl_vars['interval'];
78 $viewtype = $this-
>_tpl_vars['VIEW_TYPE'];
79 $PREV_WEEK_URL = $this-
>_tpl_vars['PREV_WEEK_URL'];
80 $NEXT_WEEK_URL = $this-
>_tpl_vars['NEXT_WEEK_URL'];
81 $PREV_DAY_URL = $this-
>_tpl_vars['PREV_DAY_URL'];
82 $NEXT_DAY_URL = $this-
>_tpl_vars['NEXT_DAY_URL'];
84 $Date = postcalendar_getDate();
85 if (!isset($y)) $y = substr($Date,
0,
4);
86 if (!isset($m)) $m = substr($Date,
4,
2);
87 if (!isset($d)) $d = substr($Date,
6,
2);
89 // echo
"<!-- There are " . count($A_EVENTS) .
" A_EVENTS days -->\n";
91 $MULTIDAY = count($A_EVENTS)
> 1;
93 $provinfo = getProviderInfo();
95 echo
"<form name='theform' action='index.php?module=PostCalendar&func=view' method='post'>\n";
97 echo
"<table border='0' cellpadding='0' cellspacing='0' width='99%'>\n";
98 echo
" <tr><td colspan='3' height='5'></td></tr>\n";
101 // Build the scrolling selection list of providers.
102 echo
" <td rowspan='2' align='left' valign='top' width='33%' nowrap>\n";
103 echo
" <select multiple size='3' name='pc_username[]'>\n";
104 echo
" <option value='__PC_ALL__'>All Users</option>\n";
105 foreach ($provinfo as $doc) {
106 $username = $doc['username'];
107 echo
" <option value='$username'";
108 foreach ($providers as $provider)
109 if ($provider['username'] == $username) echo
" selected";
110 echo
">" . $doc['fname'] .
" " . $doc['lname'] .
"</option>\n";
115 // Build the date and view type selectors and the Go button.
116 echo
" <td align='center' valign='top' width='34%' nowrap>\n";
118 echo
" <input type='text' size='10' name='jumpdate'\n" .
119 " value='$y-$m-$d'\n" .
120 " title='yyyy-mm-dd date to go to'\n" .
121 " onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />\n" .
122 " <a href=\"javascript:show_calendar('theform.jumpdate')\
"\n" .
123 " title='Click here to choose a date'\n" .
124 " ><img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22' border='0' alt='[?]'></a>\n";
126 echo
" <select name='viewtype'>\n";
127 foreach (array('day' =
> 'Day View', 'week' =
> 'Week View', 'month' =
> 'Month View', 'year' =
> 'Year View')
129 echo
" <option value='$key'";
130 if ($key == $viewtype) echo
" selected";
131 echo
">$value</option>\n";
134 echo
" <input type='submit' name='bnsubmit' 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='newEvt(1, 9, 00, $Date, 0)' />\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'];
210 $slotendmins = $starttimeh *
60 + $starttimem + $interval;
212 // Repeat doc names at
1PM. This is a kludge; omit it for released code.
213 // if ($starttimeh ==
13 && $starttimem ==
0) $need_headers = true;
215 // Get all events just for this time slot now, because we can pick up where
216 // we left off and because we don't want to re-scan all events for the day
217 // for each table cell.
220 for (; isset($slotkey); list($slotkey, $slotevent) = each($arr_events)) {
221 $starth = substr($slotevent['startTime'],
0,
2);
222 $startm = substr($slotevent['startTime'],
3,
2);
224 if (($starth *
60 + $startm)
>= $slotendmins) break;
226 $arr_slot[$slotkey] = $slotevent;
228 $catid = $slotevent['catid'];
229 $providerid = $slotevent['aid'];
230 $durminutes = ceil($slotevent['duration'] /
60);
231 $durslots = ceil($durminutes / $interval);
233 // While we're here, collect information for setting cell colors.
234 if ($catid ==
2) { // in office
235 $provstat[$providerid]['in'] = true;
237 else if ($catid ==
3) { // out of office
238 $provstat[$providerid]['in'] = false;
240 else if ($catid ==
4 || $catid ==
8 || $catid ==
11) { // unavailable types
241 $endindex = $slotindex + $durslots;
242 for ($i = $slotindex; $i < $endindex; ++$i) {
243 $provstat[$providerid][$i]['res'] = true;
246 // if duration
> slot size then mark slots for border control.
248 $endindex = $slotindex + $durslots -
1;
249 for ($i = $slotindex; $i < $endindex; ++$i) {
250 $provstat[$providerid][$i]['ext'] = true;
255 // Write a header row with the provider names if appropriate.
257 $need_headers = false;
259 foreach ($providers as $provider) {
260 echo
" <td colspan='2' align='center'>";
261 echo $provider['fname'][
0] .
" " . $provider['lname'];
269 // We are now ready to write the table row for the current time slot.
270 // This loops once for each provider to be displayed.
272 foreach ($providers as $provider) {
273 $providerid = $provider['id'];
275 $content =
""; // this will be the event cell content
278 if ($provstat[$providerid][$slotindex]['res'] || ! $provstat[$providerid]['in']) {
282 // Remove top and/or bottom table cell borders using CSS when events span
283 // time slots or when the practitioner is not in-office. Using
"rowspan"
284 // would be a difficult and inferior solution to this problem.
287 if ($slotindex < $lastslotindex &&
288 ($provstat[$providerid][$slotindex]['ext'] || !$provstat[$providerid]['in'])) {
289 $tdstyle .=
" nobot";
291 if ($slotindex
> 0 && ($provstat[$providerid][$slotindex-
1]['ext'] ||
292 !($provstat[$providerid]['in'] || $provstat[$providerid]['wasin']))) {
293 $tdstyle .=
" notop";
296 $disptimeh = ($starttimeh
> 12) ? ($starttimeh -
12) : $starttimeh;
298 echo
" <td class='t$clsuffix'";
299 if ($slotindex ==
0) echo
" width='1%'";
301 echo
"<a href='javascript:newEvt($startampm,$starttimeh,$starttimem,$eventdate,$providerid)'>";
302 echo
"$disptimeh:$starttimem";
305 echo
" <td class='e$clsuffix$tdstyle'>";
307 // Scan all events for this time slot and generate the associated HTML for
308 // this doc. JavaScript is used in hrefs to reduce the volume of output.
311 while (list($eventkey, $event) = each($arr_slot)) {
312 if ($event['aid'] != $providerid) continue;
313 if ($content) $content .=
" ";
314 $starth = substr($event['startTime'],
0,
2);
315 $startm = substr($event['startTime'],
3,
2);
316 $eventid = $event['eid'];
317 $patientid = $event['pid'];
318 $commapos = strpos($event['patient_name'],
",");
319 $lname = addslashes(ucfirst(strtolower(substr($event['patient_name'],
0, $commapos))));
320 $fname = addslashes(ucfirst(strtolower(substr($event['patient_name'], $commapos +
2))));
321 $patient_dob = $event['patient_dob'];
322 $patient_age = $event['patient_age'];
323 $catid = $event['catid'];
324 $catname = $event['catname'];
325 $title =
"Age $patient_age ($patient_dob) " . addslashes($event['hometext']);
326 if ($catid ==
2 || $catid ==
3 || $catid ==
4 || $catid ==
8 || $catid ==
11) {
327 if ($catid ==
2) $catname =
"IN";
328 else if ($catid ==
3) $catname =
"OUT";
329 else if ($catid ==
4) $catname =
"VACATION";
330 else if ($catid ==
8) $catname =
"LUNCH";
331 else if ($catid ==
11) $catname =
"RESERVED";
332 // Omit lunch, vacation, etc. if the doc is not in-office.
333 if ($provstat[$providerid]['in'] || $catid <
4) {
334 $content .=
"<a href='javascript:oldEvt($eventdate,$eventid)'>";
335 $content .= $catname .
"</a>";
338 else { // some sort of patient appointment
339 $content .=
"<a href='javascript:oldEvt($eventdate,$eventid)' title='$catname'>";
340 $content .= $startm . htmlspecialchars($event['apptstatus']) .
"</a>";
341 $content .=
"<a href='javascript:goPid($patientid)' title='$title'>";
342 if ($catid ==
1) $content .=
"<strike>";
344 if ($GLOBALS['calendar_appt_style'] !=
1) {
345 $content .=
"," . $fname;
346 if ($event['title'] && $GLOBALS['calendar_appt_style'] ==
3)
347 $content .=
"(" . $event['title'] .
")";
349 if ($catid ==
1) $content .=
"</strike>";
354 if (! $content) $content =
" ";
355 echo $content .
"</td>\n";
357 // Keep track of whether the doc was in during the previous time slot.
358 $provstat[$providerid]['wasin'] = $provstat[$providerid]['in'];
371 // [-include
file=
"$TPL_NAME/views/global/footer.html"-]
372 // [-include
file=
"$TPL_NAME/views/footer.html"-]