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-
2006 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"-]
26 font-family: Arial, Helvetica, sans-serif;
30 background-color:#ddffdd;
35 background-color:#ffbbbb;
40 background-color:#ffffff;
44 background-color:#ffbbbb;
53 border-bottom-width:
0px;
58 border-bottom-width:
0px;
62 div.tiny { width:
1px; height:
1px; font-size:
1px; }
65 <style type=
"text/css">@import url
(../../../library/dynarch_calendar.css);</style>
66 <script type=
"text/javascript" src=
"../../../library/dialog.js"></script>
67 <script type=
"text/javascript" src=
"../../../library/textformat.js"></script>
68 <script type=
"text/javascript" src=
"../../../library/dynarch_calendar.js"></script>
69 <script type=
"text/javascript" src=
"../../../library/dynarch_calendar_en.js"></script>
70 <script type=
"text/javascript" src=
"../../../library/dynarch_calendar_setup.js"></script>
72 <script language='JavaScript'
>
74 var mypcc
= '[-php-] echo $GLOBALS['phone_country_code
'] [-/php-]';
76 // This is called from the event editor popup.
77 function refreshme() {
79 document
.forms
[0].submit();
82 function newEvt(startampm
, starttimeh
, starttimem
, eventdate
, providerid
, catid
) {
83 dlgopen('add_edit_event.php?startampm=' + startampm
+
84 '&starttimeh=' + starttimeh
+ '&starttimem=' + starttimem
+
85 '&date=' + eventdate
+ '&userid=' + providerid
+ '&catid=' + catid
,
89 function oldEvt(eventdate
, eventid
) {
90 dlgopen('add_edit_event.php?eid=' + eventid
, '_blank', 550, 270);
96 if ($GLOBALS
['concurrent_layout']) {
97 echo
" top.RTop.location = '../../patient_file/summary/demographics.php' " .
98 "+ '?set_pid=' + pid;\n";
100 echo
" top.location = '../../patient_file/patient_file.php' " .
101 "+ '?set_pid=' + pid + '&pid=' + pid;\n";
106 function GoToToday(theForm
){
107 var todays_date
= new Date();
108 var theMonth
= todays_date
.getMonth() + 1;
109 theMonth
= theMonth
< 10 ? "0" + theMonth
: theMonth
;
110 theForm
.jumpdate
.value
= todays_date
.getFullYear() + "-" + theMonth
+ "-" + todays_date
.getDate();
111 top
.restoreSession();
117 <!-- Required for the popup date selectors -->
118 <div id=
"overDiv" style=
"position:absolute; visibility:hidden; z-index:1000;"></div>
122 // A_CATEGORY is an ordered array of associative-array categories.
123 // Keys of interest are: id, name, color, desc, event_duration.
125 // echo
"<!-- A_CATEGORY = "; print_r($this-
>_tpl_vars['A_CATEGORY']); echo
" -->\n"; // debugging
126 // echo
"<!-- A_EVENTS = "; print_r($this-
>_tpl_vars['A_EVENTS']); echo
" -->\n"; // debugging
128 $A_CATEGORY =& $this-
>_tpl_vars['A_CATEGORY'];
130 // [-if $PRINT_VIEW !=
1-]
131 // [-*Main Navigation*-]
132 // [-include
file=
"$TPL_NAME/views/global/navigation.html"-]
135 $A_EVENTS =& $this-
>_tpl_vars['A_EVENTS'];
136 // $S_EVENTS =& $this-
>_tpl_vars['S_EVENTS']; // Deleted by Rod
137 $providers =& $this-
>_tpl_vars['providers'];
138 $times =& $this-
>_tpl_vars['times'];
139 $interval = $this-
>_tpl_vars['interval'];
140 $viewtype = $this-
>_tpl_vars['VIEW_TYPE'];
141 $PREV_WEEK_URL = $this-
>_tpl_vars['PREV_WEEK_URL'];
142 $NEXT_WEEK_URL = $this-
>_tpl_vars['NEXT_WEEK_URL'];
143 $PREV_DAY_URL = $this-
>_tpl_vars['PREV_DAY_URL'];
144 $NEXT_DAY_URL = $this-
>_tpl_vars['NEXT_DAY_URL'];
146 $Date = postcalendar_getDate();
147 if (!isset($y)) $y = substr($Date,
0,
4);
148 if (!isset($m)) $m = substr($Date,
4,
2);
149 if (!isset($d)) $d = substr($Date,
6,
2);
151 // echo
"<!-- There are " . count($A_EVENTS) .
" A_EVENTS days -->\n";
153 $MULTIDAY = count($A_EVENTS)
> 1;
155 $provinfo = getProviderInfo();
157 echo
"<form name='theform' action='index.php?module=PostCalendar&func=view" .
158 "&tplview=default&pc_category=&pc_topic=' " .
159 "method='post' onsubmit='return top.restoreSession()'>\n";
161 echo
"<table border='0' cellpadding='0' cellspacing='0' width='99%'>\n";
162 echo
" <tr><td colspan='3' height='5'></td></tr>\n";
165 // Build the scrolling selection list of providers.
166 echo
" <td rowspan='2' align='left' valign='top' width='33%' nowrap>\n";
167 echo
" <select multiple size='3' name='pc_username[]'>\n";
168 echo
" <option value='__PC_ALL__'>" .xl (
"All Users").
"</option>\n";
169 foreach ($provinfo as $doc) {
170 $username = $doc['username'];
171 echo
" <option value='$username'";
172 foreach ($providers as $provider)
173 if ($provider['username'] == $username) echo
" selected";
174 echo
">" . $doc['fname'] .
" " . $doc['lname'] .
"</option>\n";
178 // ==============================
179 // FACILITY FILTERING (lemonsoftware)
180 $facilities = getFacilities();
181 echo
" <select name='pc_facility'>\n";
182 if ( !$_SESSION['pc_facility'] ) $selected =
"selected='selected'";
183 echo
" <option value='0' $selected>" .xl('All Facilities').
"</option>\n";
184 foreach ($facilities as $fa) {
185 $selected = ( $_SESSION['pc_facility'] == $fa['id']) ?
"selected='selected'" :
"" ;
186 echo
" <option value='" .$fa['id'].
"' $selected>" .$fa['name'].
"</option>\n";
190 // ==============================
194 // Build the date and view type selectors and the Go button and the Today button.
195 echo
" <td align='center' valign='top' width='34%' nowrap>\n";
197 echo
" <input type='text' size='10' name='jumpdate' id='jumpdate'\n" .
198 " value='$y-$m-$d' title='yyyy-mm-dd date to go to'\n" .
199 " onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />\n" .
200 " <img src='../../pic/show_calendar.gif' id='img_jumpdate' align='absbottom'\n" .
201 " width='24' height='22' border='0' alt='[?]' style='cursor:pointer'\n" .
202 " title='" .xl (
"Click here to choose a date").
"'>\n";
204 echo
" <select name='viewtype'>\n";
205 foreach ( array ('day' =
> xl(
"Day View"), 'week' =
> xl(
"Week View"), 'month' =
> xl(
"Month View"), 'year' =
> xl(
"Year View"))
207 echo
" <option value='$key'";
208 if ($key == $viewtype) echo
" selected";
209 echo
">$value</option>\n";
212 echo
" <input type='submit' name='bnsubmit' value='" .xl (
"Go").
"' />\n";
213 echo
" <input type='submit' name='bnsubmit' value='" .xl (
"Today").
"' onClick='GoToToday(theform);' />\n";
216 // Show the Add and Search buttons.
217 echo
" <td align='right' valign='top' width='33%' nowrap>\n";
218 echo
" <input type='button' value='" .xl (
"Add").
"' onclick='newEvt(1, 9, 00, $Date, 0, 0)' />\n";
219 echo
" <input type='button' value='" . xl (
"Search") .
220 "' onclick='top.restoreSession();location=\"index.php?module=PostCalendar&func=search\
"' />\n";
224 // Show the date/range and its previous- and next-day/week selectors.
226 echo
" <td align='center' width='34%' nowrap>\n";
227 $atmp = array_keys($A_EVENTS);
230 echo
"<a href='$PREV_WEEK_URL' onclick='top.restoreSession()'><<</a> \n";
231 echo dateformat(strtotime($atmp[
0]));
233 echo dateformat(strtotime($atmp[count($atmp)-
1]));
234 echo
" <a href='$NEXT_WEEK_URL' onclick='top.restoreSession()'>>></a>\n";
236 echo
"<a href='$PREV_DAY_URL' onclick='top.restoreSession()'><<</a> \n";
237 echo dateformat(strtotime($atmp[
0]), true);
238 echo
" <a href='$NEXT_DAY_URL' onclick='top.restoreSession()'>>></a>\n";
241 echo
" <td align='right' width='33%' nowrap>\n";
252 <script language='JavaScript'
>
253 Calendar
.setup({inputField
:"jumpdate", ifFormat
:"%Y-%m-%d", button
:"img_jumpdate"});
256 [-assign
var=
"dayname" value=$DATE|date_format:
"%w"-]
257 [-assign
var=
"day" value=$DATE|date_format:
"%d"|string_format:
"%1d"-]
258 [-assign
var=
"month" value=$DATE|date_format:
"%m"|string_format:
"%1d"-]
259 [-assign
var=
"year" value=$DATE|date_format:
"%Y"|string_format:
"%4d"-]
261 [-pc_sort_events
var=
"S_EVENTS" sort=
"time" order=
"asc" value=$A_EVENTS-]
265 echo
"<table width='100%' border='1' cellpadding='1' cellspacing='0' >\n";
266 $tdstylearr = array('bordyy', 'bordny', 'bordyn', 'bordnn');
269 foreach ($A_EVENTS as $date =
> $events) {
270 $need_headers = true;
271 $eventdate = substr($date,
0,
4) . substr($date,
5,
2) . substr($date,
8,
2);
273 // If multiple days then show a date header for each.
276 echo
" <td colspan='" . (count($providers) *
2) .
"' align='center'>" .
277 dateformat(strtotime($date), true) .
"</td>";
281 $arr_events = $S_EVENTS[$date];
282 list($slotkey, $slotevent) = each($arr_events);
284 // This is an array of provider status information for this day,
285 // used to properly assign table cell attributes.
289 $lastslotindex = count($times) -
1;
291 // For each time slot...
292 foreach ($times as $slottime) {
293 $startampm = ($slottime['mer']) ==
"pm" ?
2 :
1;
294 $starttimeh = $slottime['hour'];
295 $starttimem = $slottime['minute'];
296 $slotendmins = $starttimeh *
60 + $starttimem + $interval;
298 // Repeat doc names at
1PM. This is a kludge; omit it for released code.
299 // if ($starttimeh ==
13 && $starttimem ==
0) $need_headers = true;
301 // Get all events for all providers just for this time slot now, because we
302 // can pick up where we left off and because we don't want to re-scan all
303 // events for the day for each table cell.
306 for (; isset($slotkey); list($slotkey, $slotevent) = each($arr_events)) {
307 $starth = substr($slotevent['startTime'],
0,
2);
308 $startm = substr($slotevent['startTime'],
3,
2);
310 if (($starth *
60 + $startm)
>= $slotendmins) break;
312 $arr_slot[$slotkey] = $slotevent;
314 $catid = $slotevent['catid'];
315 $providerid = $slotevent['aid'];
316 $durminutes = ceil($slotevent['duration'] /
60);
317 $durslots = ceil($durminutes / $interval);
319 // While we're here, collect information for cell cosmetics.
320 if ($catid ==
2) { // in office
321 $provstat[$providerid]['in'] = true;
323 // Save preferred category info for this IN event.
324 $provstat[$providerid]['in_cat'] = -
1;
325 $provstat[$providerid]['in_slot0'] = $slotindex;
326 $provstat[$providerid]['in_slots'] =
1;
327 if ($slotevent['prefcatid']) {
328 foreach ($A_CATEGORY as $catkey =
> $catval) {
329 if ($catval['id'] == $slotevent['prefcatid']) {
330 $provstat[$providerid]['in_cat'] = $catkey;
331 $provstat[$providerid]['in_slots'] =
332 ceil(ceil($catval['event_duration'] /
60) / $interval);
337 if ($provstat[$providerid]['in_cat'] <
0) {
338 echo
"<!-- Unmatched prefcatid = " . $slotevent['prefcatid'] .
" -->\n"; // debugging
343 else if ($catid ==
3) { // out of office
344 $provstat[$providerid]['in'] = false;
346 else if ($catid ==
4 || $catid ==
8 || $catid ==
11) { // unavailable types
347 // unavailable slots are marked 'res' for appropriate coloring.
348 $endindex = $slotindex + $durslots;
349 for ($i = $slotindex; $i < $endindex; ++$i) {
350 $provstat[$providerid][$i]['res'] = true;
353 // If duration
> slot size then mark slots for border control. A slot
354 // marked 'ext' is not to have a border between itself and the slot below.
356 $endindex = $slotindex + $durslots -
1;
357 for ($i = $slotindex; $i < $endindex; ++$i) {
358 $provstat[$providerid][$i]['ext'] = true;
362 // Finished getting event information for this time slot.
364 // Write a header row with the provider names if appropriate.
366 $need_headers = false;
368 foreach ($providers as $provider) {
369 echo
" <td colspan='2' align='center'>";
370 echo $provider['fname'][
0] .
" " . $provider['lname'];
378 // We are now ready to write the table row for the current time slot.
379 // This loops once for each provider to be displayed.
381 foreach ($providers as $provider) {
382 $providerid = $provider['id'];
384 // Mark this as a no-bottom-border slot if the preferred category
385 // duration extends beyond it.
387 // echo
"<!-- slotindex=$slotindex in=" . $provstat[$providerid]['in'] .
388 //
" in_cat=" . $provstat[$providerid]['in_cat'] .
389 //
" in_slot0=" . $provstat[$providerid]['in_slot0'] .
390 //
" in_slots=" . $provstat[$providerid]['in_slots'] .
" -->\n"; // debugging
392 if ($provstat[$providerid]['in']) {
393 if (($slotindex +
1 - $provstat[$providerid]['in_slot0']) % $provstat[$providerid]['in_slots'])
394 $provstat[$providerid][$slotindex]['ext'] = true;
397 $content =
""; // this will be the event cell content
400 if ($provstat[$providerid][$slotindex]['res'] || ! $provstat[$providerid]['in']) {
404 // Remove top and/or bottom table cell borders using CSS when events span
405 // time slots or when the practitioner is not in-office. Using
"rowspan"
406 // would be a difficult and inferior solution to this problem.
410 if ($slotindex < $lastslotindex &&
411 ($provstat[$providerid][$slotindex]['ext'] || !$provstat[$providerid]['in'])) {
412 $tdstyleix +=
1; // no bottom
414 if ($slotindex
> 0 && ($provstat[$providerid][$slotindex-
1]['ext'] ||
415 !($provstat[$providerid]['in'] || $provstat[$providerid]['wasin']))) {
416 $tdstyleix +=
2; // no top
419 $tdstyle = ' ' . $tdstylearr[$tdstyleix];
421 $disptimeh = ($starttimeh
> 12) ? ($starttimeh -
12) : $starttimeh;
424 if ($provstat[$providerid]['in_cat']
>=
0) {
425 $category =& $A_CATEGORY[$provstat[$providerid]['in_cat']];
426 if ($category['id']) $in_cat_id = $category['id'];
429 // If a slot omits the top border, then we omit the TOD cell's top border
430 // and skip writing its time-of-day text. This way we can get some rows
431 // with no content at all, which should produce a more compact and readable
434 echo
" <td class='t$clsuffix$tdstyle'";
435 if ($slotindex ==
0) echo
" width='1%'";
438 echo
"<a href='javascript:newEvt($startampm,$starttimeh,$starttimem,$eventdate,$providerid,$in_cat_id)'>";
439 echo
"$disptimeh:$starttimem</a>";
441 echo
"<div class=tiny></div>"; //
1x1 px content so the browser does not suppress borders
445 echo
" <td class='e$clsuffix$tdstyle'";
446 if ($clsuffix ==
"acell" && $in_cat_id) {
447 echo
" style='background-color:" . $category['color'] .
"'";
448 echo
" title='" . $category['name'] .
"'";
452 // Scan all events for this time slot and generate the associated HTML for
453 // this doc. JavaScript is used in hrefs to reduce the volume of output.
456 while (list($eventkey, $event) = each($arr_slot)) {
457 if ($event['aid'] != $providerid) continue;
458 if ($content) $content .=
" ";
459 $starth = substr($event['startTime'],
0,
2);
460 $startm = substr($event['startTime'],
3,
2);
461 $eventid = $event['eid'];
462 $patientid = $event['pid'];
463 $commapos = strpos($event['patient_name'],
",");
464 $lname = addslashes(ucfirst(strtolower(substr($event['patient_name'],
0, $commapos))));
465 $fname = addslashes(ucfirst(strtolower(substr($event['patient_name'], $commapos +
2))));
466 $patient_dob = $event['patient_dob'];
467 $patient_age = $event['patient_age'];
468 $catid = $event['catid'];
469 $comment = $event['hometext'];
470 $catname = $event['catname'];
471 $title =
"Age $patient_age ($patient_dob)";
472 if ($event['hometext'] && $GLOBALS['calendar_appt_style'] <
4)
473 $title .=
" " . addslashes($event['hometext']);
474 if ($catid ==
2 || $catid ==
3 || $catid ==
4 || $catid ==
8 || $catid ==
11) {
475 if ($catid ==
2) $catname =
"IN";
476 else if ($catid ==
3) $catname =
"OUT";
477 else if ($catid ==
4) $catname =
"VACATION";
478 else if ($catid ==
8) $catname =
"LUNCH";
479 else if ($catid ==
11) $catname =
"RESERVED";
480 // Omit lunch, vacation, etc. if the doc is not in-office.
481 if ($provstat[$providerid]['in'] || $catid <
4) {
482 $content .=
"<a href='javascript:oldEvt($eventdate,$eventid)'>";
483 $content .= $catname .
" - $comment</a>";
486 else { // some sort of patient appointment
487 $content .=
"<a href='javascript:oldEvt($eventdate,$eventid)' title='$catname'>";
488 $content .= $starth . ':' . $startm . htmlspecialchars($event['apptstatus']) .
"</a>";
489 $content .=
"<a href='javascript:goPid($patientid)' title='$title'>";
490 if ($catid ==
1) $content .=
"<strike>";
492 if ($GLOBALS['calendar_appt_style'] !=
1) {
493 $content .=
"," . $fname;
494 if ($event['title'] && $GLOBALS['calendar_appt_style']
>=
3) {
495 $content .=
"(" . $event['title'];
496 if ($event['hometext'] && $GLOBALS['calendar_appt_style']
>=
4)
497 $content .=
": <font color='green'>" . htmlspecialchars(trim($event['hometext'])) .
"</font>";
501 if ($catid ==
1) $content .=
"</strike>";
506 if (! $content) $content =
"<div class=tiny></div>"; // so the browser does not suppress borders
507 echo $content .
"</td>\n";
509 // Keep track of whether the doc was in during the previous time slot.
510 $provstat[$providerid]['wasin'] = $provstat[$providerid]['in'];
523 // [-include
file=
"$TPL_NAME/views/global/footer.html"-]
524 // [-include
file=
"$TPL_NAME/views/footer.html"-]