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() {
78 document
.forms
[0].submit();
81 function newEvt(startampm
, starttimeh
, starttimem
, eventdate
, providerid
, catid
) {
82 dlgopen('add_edit_event.php?startampm=' + startampm
+
83 '&starttimeh=' + starttimeh
+ '&starttimem=' + starttimem
+
84 '&date=' + eventdate
+ '&userid=' + providerid
+ '&catid=' + catid
,
88 function oldEvt(eventdate
, eventid
) {
89 dlgopen('add_edit_event.php?eid=' + eventid
, '_blank', 550, 270);
94 if ($GLOBALS
['concurrent_layout']) {
95 echo
" top.RTop.location = '../../patient_file/summary/demographics.php' " .
96 "+ '?set_pid=' + pid;\n";
98 echo
" top.location = '../../patient_file/patient_file.php' " .
99 "+ '?set_pid=' + pid + '&pid=' + pid;\n";
104 function GoToToday(theForm
){
105 var todays_date
= new Date();
106 var theMonth
= todays_date
.getMonth() + 1;
107 theMonth
= theMonth
< 10 ? "0" + theMonth
: theMonth
;
108 theForm
.jumpdate
.value
= todays_date
.getFullYear() + "-" + theMonth
+ "-" + todays_date
.getDate();
114 <!-- Required for the popup date selectors -->
115 <div id=
"overDiv" style=
"position:absolute; visibility:hidden; z-index:1000;"></div>
119 // A_CATEGORY is an ordered array of associative-array categories.
120 // Keys of interest are: id, name, color, desc, event_duration.
122 // echo
"<!-- A_CATEGORY = "; print_r($this-
>_tpl_vars['A_CATEGORY']); echo
" -->\n"; // debugging
123 // echo
"<!-- A_EVENTS = "; print_r($this-
>_tpl_vars['A_EVENTS']); echo
" -->\n"; // debugging
125 $A_CATEGORY =& $this-
>_tpl_vars['A_CATEGORY'];
127 // [-if $PRINT_VIEW !=
1-]
128 // [-*Main Navigation*-]
129 // [-include
file=
"$TPL_NAME/views/global/navigation.html"-]
132 $A_EVENTS =& $this-
>_tpl_vars['A_EVENTS'];
133 // $S_EVENTS =& $this-
>_tpl_vars['S_EVENTS']; // Deleted by Rod
134 $providers =& $this-
>_tpl_vars['providers'];
135 $times =& $this-
>_tpl_vars['times'];
136 $interval = $this-
>_tpl_vars['interval'];
137 $viewtype = $this-
>_tpl_vars['VIEW_TYPE'];
138 $PREV_WEEK_URL = $this-
>_tpl_vars['PREV_WEEK_URL'];
139 $NEXT_WEEK_URL = $this-
>_tpl_vars['NEXT_WEEK_URL'];
140 $PREV_DAY_URL = $this-
>_tpl_vars['PREV_DAY_URL'];
141 $NEXT_DAY_URL = $this-
>_tpl_vars['NEXT_DAY_URL'];
143 $Date = postcalendar_getDate();
144 if (!isset($y)) $y = substr($Date,
0,
4);
145 if (!isset($m)) $m = substr($Date,
4,
2);
146 if (!isset($d)) $d = substr($Date,
6,
2);
148 // echo
"<!-- There are " . count($A_EVENTS) .
" A_EVENTS days -->\n";
150 $MULTIDAY = count($A_EVENTS)
> 1;
152 $provinfo = getProviderInfo();
154 echo
"<form name='theform' action='index.php?module=PostCalendar&func=view" .
155 "&tplview=default&pc_category=&pc_topic=' " .
158 echo
"<table border='0' cellpadding='0' cellspacing='0' width='99%'>\n";
159 echo
" <tr><td colspan='3' height='5'></td></tr>\n";
162 // Build the scrolling selection list of providers.
163 echo
" <td rowspan='2' align='left' valign='top' width='33%' nowrap>\n";
164 echo
" <select multiple size='3' name='pc_username[]'>\n";
165 echo
" <option value='__PC_ALL__'>" .xl (
"All Users").
"</option>\n";
166 foreach ($provinfo as $doc) {
167 $username = $doc['username'];
168 echo
" <option value='$username'";
169 foreach ($providers as $provider)
170 if ($provider['username'] == $username) echo
" selected";
171 echo
">" . $doc['fname'] .
" " . $doc['lname'] .
"</option>\n";
176 // Build the date and view type selectors and the Go button and the Today button.
177 echo
" <td align='center' valign='top' width='34%' nowrap>\n";
179 echo
" <input type='text' size='10' name='jumpdate' id='jumpdate'\n" .
180 " value='$y-$m-$d' title='yyyy-mm-dd date to go to'\n" .
181 " onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />\n" .
182 " <img src='../../pic/show_calendar.gif' id='img_jumpdate' align='absbottom'\n" .
183 " width='24' height='22' border='0' alt='[?]' style='cursor:pointer'\n" .
184 " title='" .xl (
"Click here to choose a date").
"'>\n";
186 echo
" <select name='viewtype'>\n";
187 foreach ( array ('day' =
> xl(
"Day View"), 'week' =
> xl(
"Week View"), 'month' =
> xl(
"Month View"), 'year' =
> xl(
"Year View"))
189 echo
" <option value='$key'";
190 if ($key == $viewtype) echo
" selected";
191 echo
">$value</option>\n";
194 echo
" <input type='submit' name='bnsubmit' value='" .xl (
"Go").
"' />\n";
195 echo
" <input type='submit' name='bnsubmit' value='" .xl (
"Today").
"' onClick='GoToToday(theform);' />\n";
198 // Show the Add and Search buttons.
199 echo
" <td align='right' valign='top' width='33%' nowrap>\n";
200 echo
" <input type='button' value='" .xl (
"Add").
"' onclick='newEvt(1, 9, 00, $Date, 0, 0)' />\n";
201 echo
" <input type='button' value='" .xl (
"Search").
"' onclick='location=\"index.php?module=PostCalendar&func=search\
"' />\n";
205 // Show the date/range and its previous- and next-day/week selectors.
207 echo
" <td align='center' width='34%' nowrap>\n";
208 $atmp = array_keys($A_EVENTS);
211 echo
"<a href='$PREV_WEEK_URL'><<</a> \n";
212 echo dateformat(strtotime($atmp[
0]));
214 echo dateformat(strtotime($atmp[count($atmp)-
1]));
215 echo
" <a href='$NEXT_WEEK_URL'>>></a>\n";
217 echo
"<a href='$PREV_DAY_URL'><<</a> \n";
218 echo dateformat(strtotime($atmp[
0]));
219 echo
" <a href='$NEXT_DAY_URL'>>></a>\n";
222 echo
" <td align='right' width='33%' nowrap>\n";
233 <script language='JavaScript'
>
234 Calendar
.setup({inputField
:"jumpdate", ifFormat
:"%Y-%m-%d", button
:"img_jumpdate"});
237 [-assign
var=
"dayname" value=$DATE|date_format:
"%w"-]
238 [-assign
var=
"day" value=$DATE|date_format:
"%d"|string_format:
"%1d"-]
239 [-assign
var=
"month" value=$DATE|date_format:
"%m"|string_format:
"%1d"-]
240 [-assign
var=
"year" value=$DATE|date_format:
"%Y"|string_format:
"%4d"-]
242 [-pc_sort_events
var=
"S_EVENTS" sort=
"time" order=
"asc" value=$A_EVENTS-]
246 echo
"<table width='100%' border='1' cellpadding='1' cellspacing='0' >\n";
247 $tdstylearr = array('bordyy', 'bordny', 'bordyn', 'bordnn');
250 foreach ($A_EVENTS as $date =
> $events) {
251 $need_headers = true;
252 $eventdate = substr($date,
0,
4) . substr($date,
5,
2) . substr($date,
8,
2);
254 // If multiple days then show a date header for each.
257 echo
" <td colspan='" . (count($providers) *
2) .
"' align='center'>" .
258 dateformat(strtotime($date)) .
"</td>";
262 $arr_events = $S_EVENTS[$date];
263 list($slotkey, $slotevent) = each($arr_events);
265 // This is an array of provider status information for this day,
266 // used to properly assign table cell attributes.
270 $lastslotindex = count($times) -
1;
272 // For each time slot...
273 foreach ($times as $slottime) {
274 $startampm = ($slottime['mer']) ==
"pm" ?
2 :
1;
275 $starttimeh = $slottime['hour'];
276 $starttimem = $slottime['minute'];
277 $slotendmins = $starttimeh *
60 + $starttimem + $interval;
279 // Repeat doc names at
1PM. This is a kludge; omit it for released code.
280 // if ($starttimeh ==
13 && $starttimem ==
0) $need_headers = true;
282 // Get all events for all providers just for this time slot now, because we
283 // can pick up where we left off and because we don't want to re-scan all
284 // events for the day for each table cell.
287 for (; isset($slotkey); list($slotkey, $slotevent) = each($arr_events)) {
288 $starth = substr($slotevent['startTime'],
0,
2);
289 $startm = substr($slotevent['startTime'],
3,
2);
291 if (($starth *
60 + $startm)
>= $slotendmins) break;
293 $arr_slot[$slotkey] = $slotevent;
295 $catid = $slotevent['catid'];
296 $providerid = $slotevent['aid'];
297 $durminutes = ceil($slotevent['duration'] /
60);
298 $durslots = ceil($durminutes / $interval);
300 // While we're here, collect information for cell cosmetics.
301 if ($catid ==
2) { // in office
302 $provstat[$providerid]['in'] = true;
304 // Save preferred category info for this IN event.
305 $provstat[$providerid]['in_cat'] = -
1;
306 $provstat[$providerid]['in_slot0'] = $slotindex;
307 $provstat[$providerid]['in_slots'] =
1;
308 if ($slotevent['prefcatid']) {
309 foreach ($A_CATEGORY as $catkey =
> $catval) {
310 if ($catval['id'] == $slotevent['prefcatid']) {
311 $provstat[$providerid]['in_cat'] = $catkey;
312 $provstat[$providerid]['in_slots'] =
313 ceil(ceil($catval['event_duration'] /
60) / $interval);
318 if ($provstat[$providerid]['in_cat'] <
0) {
319 echo
"<!-- Unmatched prefcatid = " . $slotevent['prefcatid'] .
" -->\n"; // debugging
324 else if ($catid ==
3) { // out of office
325 $provstat[$providerid]['in'] = false;
327 else if ($catid ==
4 || $catid ==
8 || $catid ==
11) { // unavailable types
328 // unavailable slots are marked 'res' for appropriate coloring.
329 $endindex = $slotindex + $durslots;
330 for ($i = $slotindex; $i < $endindex; ++$i) {
331 $provstat[$providerid][$i]['res'] = true;
334 // If duration
> slot size then mark slots for border control. A slot
335 // marked 'ext' is not to have a border between itself and the slot below.
337 $endindex = $slotindex + $durslots -
1;
338 for ($i = $slotindex; $i < $endindex; ++$i) {
339 $provstat[$providerid][$i]['ext'] = true;
343 // Finished getting event information for this time slot.
345 // Write a header row with the provider names if appropriate.
347 $need_headers = false;
349 foreach ($providers as $provider) {
350 echo
" <td colspan='2' align='center'>";
351 echo $provider['fname'][
0] .
" " . $provider['lname'];
359 // We are now ready to write the table row for the current time slot.
360 // This loops once for each provider to be displayed.
362 foreach ($providers as $provider) {
363 $providerid = $provider['id'];
365 // Mark this as a no-bottom-border slot if the preferred category
366 // duration extends beyond it.
368 // echo
"<!-- slotindex=$slotindex in=" . $provstat[$providerid]['in'] .
369 //
" in_cat=" . $provstat[$providerid]['in_cat'] .
370 //
" in_slot0=" . $provstat[$providerid]['in_slot0'] .
371 //
" in_slots=" . $provstat[$providerid]['in_slots'] .
" -->\n"; // debugging
373 if ($provstat[$providerid]['in']) {
374 if (($slotindex +
1 - $provstat[$providerid]['in_slot0']) % $provstat[$providerid]['in_slots'])
375 $provstat[$providerid][$slotindex]['ext'] = true;
378 $content =
""; // this will be the event cell content
381 if ($provstat[$providerid][$slotindex]['res'] || ! $provstat[$providerid]['in']) {
385 // Remove top and/or bottom table cell borders using CSS when events span
386 // time slots or when the practitioner is not in-office. Using
"rowspan"
387 // would be a difficult and inferior solution to this problem.
391 if ($slotindex < $lastslotindex &&
392 ($provstat[$providerid][$slotindex]['ext'] || !$provstat[$providerid]['in'])) {
393 $tdstyleix +=
1; // no bottom
395 if ($slotindex
> 0 && ($provstat[$providerid][$slotindex-
1]['ext'] ||
396 !($provstat[$providerid]['in'] || $provstat[$providerid]['wasin']))) {
397 $tdstyleix +=
2; // no top
400 $tdstyle = ' ' . $tdstylearr[$tdstyleix];
402 $disptimeh = ($starttimeh
> 12) ? ($starttimeh -
12) : $starttimeh;
405 if ($provstat[$providerid]['in_cat']
>=
0) {
406 $category =& $A_CATEGORY[$provstat[$providerid]['in_cat']];
407 if ($category['id']) $in_cat_id = $category['id'];
410 // If a slot omits the top border, then we omit the TOD cell's top border
411 // and skip writing its time-of-day text. This way we can get some rows
412 // with no content at all, which should produce a more compact and readable
415 echo
" <td class='t$clsuffix$tdstyle'";
416 if ($slotindex ==
0) echo
" width='1%'";
419 echo
"<a href='javascript:newEvt($startampm,$starttimeh,$starttimem,$eventdate,$providerid,$in_cat_id)'>";
420 echo
"$disptimeh:$starttimem</a>";
422 echo
"<div class=tiny></div>"; //
1x1 px content so the browser does not suppress borders
426 echo
" <td class='e$clsuffix$tdstyle'";
427 if ($clsuffix ==
"acell" && $in_cat_id) {
428 echo
" style='background-color:" . $category['color'] .
"'";
429 echo
" title='" . $category['name'] .
"'";
433 // Scan all events for this time slot and generate the associated HTML for
434 // this doc. JavaScript is used in hrefs to reduce the volume of output.
437 while (list($eventkey, $event) = each($arr_slot)) {
438 if ($event['aid'] != $providerid) continue;
439 if ($content) $content .=
" ";
440 $starth = substr($event['startTime'],
0,
2);
441 $startm = substr($event['startTime'],
3,
2);
442 $eventid = $event['eid'];
443 $patientid = $event['pid'];
444 $commapos = strpos($event['patient_name'],
",");
445 $lname = addslashes(ucfirst(strtolower(substr($event['patient_name'],
0, $commapos))));
446 $fname = addslashes(ucfirst(strtolower(substr($event['patient_name'], $commapos +
2))));
447 $patient_dob = $event['patient_dob'];
448 $patient_age = $event['patient_age'];
449 $catid = $event['catid'];
450 $catname = $event['catname'];
451 $title =
"Age $patient_age ($patient_dob)";
452 if ($event['hometext'] && $GLOBALS['calendar_appt_style'] <
4)
453 $title .=
" " . addslashes($event['hometext']);
454 if ($catid ==
2 || $catid ==
3 || $catid ==
4 || $catid ==
8 || $catid ==
11) {
455 if ($catid ==
2) $catname =
"IN";
456 else if ($catid ==
3) $catname =
"OUT";
457 else if ($catid ==
4) $catname =
"VACATION";
458 else if ($catid ==
8) $catname =
"LUNCH";
459 else if ($catid ==
11) $catname =
"RESERVED";
460 // Omit lunch, vacation, etc. if the doc is not in-office.
461 if ($provstat[$providerid]['in'] || $catid <
4) {
462 $content .=
"<a href='javascript:oldEvt($eventdate,$eventid)'>";
463 $content .= $catname .
"</a>";
466 else { // some sort of patient appointment
467 $content .=
"<a href='javascript:oldEvt($eventdate,$eventid)' title='$catname'>";
468 $content .= $starth . ':' . $startm . htmlspecialchars($event['apptstatus']) .
"</a>";
469 $content .=
"<a href='javascript:goPid($patientid)' title='$title'>";
470 if ($catid ==
1) $content .=
"<strike>";
472 if ($GLOBALS['calendar_appt_style'] !=
1) {
473 $content .=
"," . $fname;
474 if ($event['title'] && $GLOBALS['calendar_appt_style']
>=
3) {
475 $content .=
"(" . $event['title'];
476 if ($event['hometext'] && $GLOBALS['calendar_appt_style']
>=
4)
477 $content .=
": <font color='green'>" . htmlspecialchars(trim($event['hometext'])) .
"</font>";
481 if ($catid ==
1) $content .=
"</strike>";
486 if (! $content) $content =
"<div class=tiny></div>"; // so the browser does not suppress borders
487 echo $content .
"</td>\n";
489 // Keep track of whether the doc was in during the previous time slot.
490 $provstat[$providerid]['wasin'] = $provstat[$providerid]['in'];
503 // [-include
file=
"$TPL_NAME/views/global/footer.html"-]
504 // [-include
file=
"$TPL_NAME/views/footer.html"-]