2 [-*****************************************************************************-]
3 [-* Copyright (C)
2005-
2006 Rod Roark
<rod@sunsetsystems.com
> and others *-]
5 [-* This program is free software; you can redistribute it and/or *-]
6 [-* modify it under the terms of the GNU General Public License *-]
7 [-* as published by the Free Software Foundation; either version
2 *-]
8 [-* of the License, or (at your option) any later version. *-]
9 [-*****************************************************************************-]
10 [-config_load
file=
"default.conf"-]
11 [-*Load the Language Definitions*-]
12 [-config_load
file=
"lang.$USER_LANG"-]
13 [-include
file=
"$TPL_NAME/views/header.html"-]
14 [-* we want to include out stylesheet for this view*-]
15 [-fetch
file=
"$TPL_STYLE_PATH/day.css" assign=
"css"-]
23 font-family: Arial, Helvetica, sans-serif;
27 background-color:#ddffdd;
32 background-color:#ffbbbb;
37 background-color:#ffffff;
41 background-color:#ffbbbb;
50 border-bottom-width:
0px;
55 border-bottom-width:
0px;
59 div.tiny { width:
1px; height:
1px; font-size:
1px; }
62 <style type=
"text/css">@import url
(../../../library/dynarch_calendar.css);</style>
63 <script type=
"text/javascript" src=
"../../../library/dialog.js"></script>
64 <script type=
"text/javascript" src=
"../../../library/textformat.js"></script>
65 <script type=
"text/javascript" src=
"../../../library/dynarch_calendar.js"></script>
66 [-php-] include_once(
"{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); [-/php-]
67 <script type=
"text/javascript" src=
"../../../library/dynarch_calendar_setup.js"></script>
69 <script language='JavaScript'
>
71 var mypcc
= '[-php-] echo $GLOBALS['phone_country_code
'] [-/php-]';
73 // This is called from the event editor popup.
74 function refreshme() {
76 document
.forms
[0].submit();
79 function newEvt(startampm
, starttimeh
, starttimem
, eventdate
, providerid
, catid
) {
80 dlgopen('add_edit_event.php?startampm=' + startampm
+
81 '&starttimeh=' + starttimeh
+ '&starttimem=' + starttimem
+
82 '&date=' + eventdate
+ '&userid=' + providerid
+ '&catid=' + catid
,
86 function oldEvt(eventdate
, eventid
) {
87 dlgopen('add_edit_event.php?date='+eventdate
+'&eid=' + eventid
, '_blank', 550, 310);
93 if ($GLOBALS
['concurrent_layout'])
96 echo
" top.RTop.location = '../../patient_file/summary/demographics.php' " .
97 "+ '?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 $facilities = getUserFacilities($_SESSION['authId']); // from users_facility
156 if (count($facilities) ==
1 || !$_SESSION['pc_facility']) {
157 $_SESSION['pc_facility'] = $facilities[
0]['id'];
159 if ( $_SESSION['pc_facility'] ) {
160 $provinfo = getProviderInfo('%', true, $_SESSION['pc_facility']);
162 $provinfo = getProviderInfo();
164 // echo
"<form name='theform' action='index.php?module=PostCalendar&func=view" .
165 echo
"<form id='theform' name='theform' action='index.php?module=PostCalendar&func=view" .
166 "&tplview=default&pc_category=&pc_topic=' " .
167 "method='post' onsubmit='return top.restoreSession()'>\n";
169 echo
"<table border='0' cellpadding='0' cellspacing='0' width='99%'>\n";
170 echo
" <tr><td colspan='3' height='5'></td></tr>\n";
173 // Build the scrolling selection list of providers.
174 echo
" <td rowspan='2' align='left' valign='top' width='33%' nowrap>\n";
175 echo
" <select multiple size='3' name='pc_username[]'>\n";
176 echo
" <option value='__PC_ALL__'>" .xl (
"All Users").
"</option>\n";
177 foreach ($provinfo as $doc) {
178 $username = $doc['username'];
179 echo
" <option value='$username'";
180 foreach ($providers as $provider)
181 if ($provider['username'] == $username) echo
" selected";
182 echo
">" . $doc['fname'] .
" " . $doc['lname'] .
"</option>\n";
186 /*********************************************************************
187 // ==============================
188 // FACILITY FILTERING (lemonsoftware)
189 $facilities = getFacilities();
190 echo
" <select name='pc_facility'>\n";
191 if ( !$_SESSION['pc_facility'] ) $selected =
"selected='selected'";
192 echo
" <option value='0' $selected>" .xl('All Facilities').
"</option>\n";
193 foreach ($facilities as $fa) {
194 $selected = ( $_SESSION['pc_facility'] == $fa['id']) ?
"selected='selected'" :
"" ;
195 echo
" <option value='" .$fa['id'].
"' $selected>" .$fa['name'].
"</option>\n";
198 *********************************************************************/
199 // ==============================
200 // FACILITY FILTERING (lemonsoftware)
201 if ($_SESSION['authorizeduser'] ==
1) {
202 $facilities = getFacilities();
204 $facilities = getUserFacilities($_SESSION['authId']); // from users_facility
205 if (count($facilities) ==
1)
206 $_SESSION['pc_facility'] = ($facilities[
0]['id']);
208 if (count($facilities)
> 1) {
209 echo
" <select name='pc_facility' id='pc_facility' onChange='document.getElementById(\"theform\
").submit();'>\n";
210 if ( !$_SESSION['pc_facility'] ) $selected =
"selected='selected'";
211 if ( !$GLOBALS['restrict_user_facility']) echo
" <option value='0' $selected>" . xl('All Facilities') .
"</option>\n";
212 foreach ($facilities as $fa) {
213 $selected = ( $_SESSION['pc_facility'] == $fa['id']) ?
"selected='selected'" :
"" ;
214 echo
" <option value='" . $fa['id'] .
"' $selected>" . $fa['name'] .
"</option>\n";
218 /********************************************************************/
221 // ==============================
225 // Build the date and view type selectors and the Go button and the Today button.
226 echo
" <td align='center' valign='top' width='34%' nowrap>\n";
228 echo
" <input type='text' size='10' name='jumpdate' id='jumpdate'\n" .
229 " value='$y-$m-$d' title='yyyy-mm-dd date to go to'\n" .
230 " onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />\n" .
231 " <img src='../../pic/show_calendar.gif' id='img_jumpdate' align='absbottom'\n" .
232 " width='24' height='22' border='0' alt='[?]' style='cursor:pointer'\n" .
233 " title='" .xl (
"Click here to choose a date").
"'>\n";
235 echo
" <select name='viewtype'>\n";
236 foreach ( array ('day' =
> xl(
"Day View"), 'week' =
> xl(
"Week View"), 'month' =
> xl(
"Month View"), 'year' =
> xl(
"Year View"))
238 echo
" <option value='$key'";
239 if ($key == $viewtype) echo
" selected";
240 echo
">$value</option>\n";
243 echo
" <input type='submit' name='bnsubmit' value='" .xl (
"Go").
"' />\n";
244 echo
" <input type='submit' name='bnsubmit' value='" .xl (
"Today").
"' onClick='GoToToday(theform);' />\n";
247 // Show the Add and Search buttons.
248 echo
" <td align='right' valign='top' width='33%' nowrap>\n";
249 echo
" <input type='button' value='" .xl (
"Add").
"' onclick='newEvt(1, 9, 00, $Date, 0, 0)' />\n";
250 echo
" <input type='button' value='" . xl (
"Search") .
251 "' onclick='top.restoreSession();location=\"index.php?module=PostCalendar&func=search\
"' />\n";
255 // Show the date/range and its previous- and next-day/week selectors.
257 echo
" <td align='center' width='34%' nowrap>\n";
258 $atmp = array_keys($A_EVENTS);
261 echo
"<a href='$PREV_WEEK_URL' onclick='top.restoreSession()'><<</a> \n";
262 echo dateformat(strtotime($atmp[
0]));
264 echo dateformat(strtotime($atmp[count($atmp)-
1]));
265 echo
" <a href='$NEXT_WEEK_URL' onclick='top.restoreSession()'>>></a>\n";
267 echo
"<a href='$PREV_DAY_URL' onclick='top.restoreSession()'><<</a> \n";
268 echo dateformat(strtotime($atmp[
0]), true);
269 echo
" <a href='$NEXT_DAY_URL' onclick='top.restoreSession()'>>></a>\n";
272 echo
" <td align='right' width='33%' nowrap>\n";
283 <script language='JavaScript'
>
284 Calendar
.setup({inputField
:"jumpdate", ifFormat
:"%Y-%m-%d", button
:"img_jumpdate"});
287 [-assign
var=
"dayname" value=$DATE|date_format:
"%w"-]
288 [-assign
var=
"day" value=$DATE|date_format:
"%d"|string_format:
"%1d"-]
289 [-assign
var=
"month" value=$DATE|date_format:
"%m"|string_format:
"%1d"-]
290 [-assign
var=
"year" value=$DATE|date_format:
"%Y"|string_format:
"%4d"-]
292 [-pc_sort_events
var=
"S_EVENTS" sort=
"time" order=
"asc" value=$A_EVENTS-]
296 echo
"<table width='100%' border='1' cellpadding='1' cellspacing='0' >\n";
297 $tdstylearr = array('bordyy', 'bordny', 'bordyn', 'bordnn');
300 foreach ($A_EVENTS as $date =
> $events) {
301 $need_headers = true;
302 $eventdate = substr($date,
0,
4) . substr($date,
5,
2) . substr($date,
8,
2);
304 // If multiple days then show a date header for each.
307 echo
" <td colspan='" . (count($providers) *
2) .
"' align='center'>" .
308 dateformat(strtotime($date), true) .
"</td>";
312 $arr_events = $S_EVENTS[$date];
313 list($slotkey, $slotevent) = each($arr_events);
315 // This is an array of provider status information for this day,
316 // used to properly assign table cell attributes.
320 $lastslotindex = count($times) -
1;
322 // For each time slot...
323 foreach ($times as $slottime) {
324 $startampm = ($slottime['mer']) ==
"pm" ?
2 :
1;
325 $starttimeh = $slottime['hour'];
326 $starttimem = $slottime['minute'];
327 $slotendmins = $starttimeh *
60 + $starttimem + $interval;
329 // Repeat doc names at
1PM. This is a kludge; omit it for released code.
330 // if ($starttimeh ==
13 && $starttimem ==
0) $need_headers = true;
332 // Get all events for all providers just for this time slot now, because we
333 // can pick up where we left off and because we don't want to re-scan all
334 // events for the day for each table cell.
337 for (; isset($slotkey); list($slotkey, $slotevent) = each($arr_events)) {
338 $starth = substr($slotevent['startTime'],
0,
2);
339 $startm = substr($slotevent['startTime'],
3,
2);
341 if (($starth *
60 + $startm)
>= $slotendmins) break;
343 $arr_slot[$slotkey] = $slotevent;
345 $catid = $slotevent['catid'];
346 $providerid = $slotevent['aid'];
347 $durminutes = ceil($slotevent['duration'] /
60);
348 $durslots = ceil($durminutes / $interval);
350 // While we're here, collect information for cell cosmetics.
351 if ($catid ==
2) { // in office
352 $provstat[$providerid]['in'] = true;
354 // Save preferred category info for this IN event.
355 $provstat[$providerid]['in_cat'] = -
1;
356 $provstat[$providerid]['in_slot0'] = $slotindex;
357 $provstat[$providerid]['in_slots'] =
1;
358 if ($slotevent['prefcatid']) {
359 foreach ($A_CATEGORY as $catkey =
> $catval) {
360 if ($catval['id'] == $slotevent['prefcatid']) {
361 $provstat[$providerid]['in_cat'] = $catkey;
362 $provstat[$providerid]['in_slots'] =
363 ceil(ceil($catval['event_duration'] /
60) / $interval);
368 if ($provstat[$providerid]['in_cat'] <
0) {
369 echo
"<!-- Unmatched prefcatid = " . $slotevent['prefcatid'] .
" -->\n"; // debugging
374 else if ($catid ==
3) { // out of office
375 $provstat[$providerid]['in'] = false;
377 else if ($catid ==
4 || $catid ==
8 || $catid ==
11) { // unavailable types
378 // unavailable slots are marked 'res' for appropriate coloring.
379 $endindex = $slotindex + $durslots;
380 for ($i = $slotindex; $i < $endindex; ++$i) {
381 $provstat[$providerid][$i]['res'] = true;
384 // If duration
> slot size then mark slots for border control. A slot
385 // marked 'ext' is not to have a border between itself and the slot below.
387 $endindex = $slotindex + $durslots -
1;
388 for ($i = $slotindex; $i < $endindex; ++$i) {
389 $provstat[$providerid][$i]['ext'] = true;
393 // Finished getting event information for this time slot.
395 // Write a header row with the provider names if appropriate.
397 $need_headers = false;
399 foreach ($providers as $provider) {
400 echo
" <td colspan='2' align='center'>";
401 echo $provider['fname'][
0] .
" " . $provider['lname'];
409 // We are now ready to write the table row for the current time slot.
410 // This loops once for each provider to be displayed.
412 foreach ($providers as $provider) {
413 $providerid = $provider['id'];
415 // Mark this as a no-bottom-border slot if the preferred category
416 // duration extends beyond it.
418 // echo
"<!-- slotindex=$slotindex in=" . $provstat[$providerid]['in'] .
419 //
" in_cat=" . $provstat[$providerid]['in_cat'] .
420 //
" in_slot0=" . $provstat[$providerid]['in_slot0'] .
421 //
" in_slots=" . $provstat[$providerid]['in_slots'] .
" -->\n"; // debugging
423 if ($provstat[$providerid]['in']) {
424 if (($slotindex +
1 - $provstat[$providerid]['in_slot0']) % $provstat[$providerid]['in_slots'])
425 $provstat[$providerid][$slotindex]['ext'] = true;
428 $content =
""; // this will be the event cell content
431 if ($provstat[$providerid][$slotindex]['res'] || ! $provstat[$providerid]['in']) {
435 // Remove top and/or bottom table cell borders using CSS when events span
436 // time slots or when the practitioner is not in-office. Using
"rowspan"
437 // would be a difficult and inferior solution to this problem.
441 if ($slotindex < $lastslotindex &&
442 ($provstat[$providerid][$slotindex]['ext'] || !$provstat[$providerid]['in'])) {
443 $tdstyleix +=
1; // no bottom
445 if ($slotindex
> 0 && ($provstat[$providerid][$slotindex-
1]['ext'] ||
446 !($provstat[$providerid]['in'] || $provstat[$providerid]['wasin']))) {
447 $tdstyleix +=
2; // no top
450 $tdstyle = ' ' . $tdstylearr[$tdstyleix];
452 $disptimeh = ($starttimeh
> 12) ? ($starttimeh -
12) : $starttimeh;
455 if ($provstat[$providerid]['in_cat']
>=
0) {
456 $category =& $A_CATEGORY[$provstat[$providerid]['in_cat']];
457 if ($category['id']) $in_cat_id = $category['id'];
460 // If a slot omits the top border, then we omit the TOD cell's top border
461 // and skip writing its time-of-day text. This way we can get some rows
462 // with no content at all, which should produce a more compact and readable
465 echo
" <td class='t$clsuffix$tdstyle'";
466 if ($slotindex ==
0) echo
" width='1%'";
469 echo
"<a href='javascript:newEvt($startampm,$starttimeh,$starttimem,$eventdate,$providerid,$in_cat_id)'>";
470 echo
"$disptimeh:$starttimem</a>";
472 echo
"<div class=tiny></div>"; //
1x1 px content so the browser does not suppress borders
476 echo
" <td class='e$clsuffix$tdstyle'";
477 if ($clsuffix ==
"acell" && $in_cat_id) {
478 echo
" style='background-color:" . $category['color'] .
"'";
479 echo
" title='" . $category['name'] .
"'";
483 // Scan all events for this time slot and generate the associated HTML for
484 // this doc. JavaScript is used in hrefs to reduce the volume of output.
487 while (list($eventkey, $event) = each($arr_slot)) {
488 if ($event['aid'] != $providerid) continue;
489 if ($content) $content .=
" ";
490 $starth = substr($event['startTime'],
0,
2);
491 $startm = substr($event['startTime'],
3,
2);
492 $eventid = $event['eid'];
493 $patientid = $event['pid'];
494 $commapos = strpos($event['patient_name'],
",");
495 $lname = substr($event['patient_name'],
0, $commapos);
496 $fname = substr($event['patient_name'], $commapos +
2);
497 $patient_dob = $event['patient_dob'];
498 $patient_age = $event['patient_age'];
499 $title = xl('Age') .
" $patient_age ($patient_dob)";
500 $catid = $event['catid'];
501 $comment = addslashes($event['hometext']);
502 $catname = $event['catname'];
503 if ($comment && $GLOBALS['calendar_appt_style'] <
4)
504 $title .=
" " . $comment;
505 if ($catid ==
2 || $catid ==
3 || $catid ==
4 || $catid ==
8 || $catid ==
11) {
506 if ($catid ==
2) $catname = xl('IN');
507 else if ($catid ==
3) $catname = xl('OUT');
508 else if ($catid ==
4) $catname = xl('VACATION');
509 else if ($catid ==
8) $catname = xl('LUNCH');
510 else if ($catid ==
11) $catname = xl('RESERVED');
511 // Omit lunch, vacation, etc. if the doc is not in-office.
512 if ($provstat[$providerid]['in'] || $catid <
4) {
513 $content .=
"<a href='javascript:oldEvt($eventdate,$eventid)'>";
514 $content .= $catname;
515 if ($comment) $content .=
" - $comment";
519 else if ($patientid) { // some sort of patient appointment
520 $content .=
"<a href='javascript:oldEvt($eventdate,$eventid)' title='$catname'>";
521 // $content .= $starth . ':' . $startm . htmlspecialchars($event['apptstatus']) .
"</a>";
522 $content .= $starth . ':' . $startm . '
' . htmlspecialchars($event['apptstatus']) .
" </a>";
523 $content .=
"<a href='javascript:goPid($patientid)' title='$title'>";
524 if ($catid ==
1) $content .=
"<strike>";
525 $content .= htmlspecialchars($lname);
526 if ($GLOBALS['calendar_appt_style'] !=
1) {
527 $content .=
"," . htmlspecialchars($fname);
528 if ($event['title'] && $GLOBALS['calendar_appt_style']
>=
3) {
529 $content .=
"(" . $event['title'];
530 if ($event['hometext'] && $GLOBALS['calendar_appt_style']
>=
4)
531 $content .=
": <font color='green'>" . htmlspecialchars(trim($event['hometext'])) .
"</font>";
535 if ($catid ==
1) $content .=
"</strike>";
538 else { // some other non-patient event
539 $content .=
"<a href='javascript:oldEvt($eventdate,$eventid)' title='$catname' " .
540 "style='background-color:" . $event['catcolor'] .
"'>";
541 $content .= $starth . ':' . $startm . '
' . htmlspecialchars($event['apptstatus']) .
" ";
542 if ($GLOBALS['calendar_appt_style'] !=
1) {
543 if ($event['title'] && $GLOBALS['calendar_appt_style']
>=
3) {
544 $content .= $event['title'];
545 if ($event['hometext'] && $GLOBALS['calendar_appt_style']
>=
4)
546 $content .=
": " . htmlspecialchars(trim($event['hometext']));
553 if (! $content) $content =
"<div class=tiny></div>"; // so the browser does not suppress borders
554 echo $content .
"</td>\n";
556 // Keep track of whether the doc was in during the previous time slot.
557 $provstat[$providerid]['wasin'] = $provstat[$providerid]['in'];
570 // [-include
file=
"$TPL_NAME/views/global/footer.html"-]
571 // [-include
file=
"$TPL_NAME/views/footer.html"-]