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 <script type=
"text/javascript" src=
"../../../library/dynarch_calendar_en.js"></script>
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, 270);
93 if ($GLOBALS
['concurrent_layout'])
95 // larry :: dbc change
96 if( $GLOBALS
['dutchpc'] )
98 echo
" top.RTop.location = '../../patient_file/summary/demographics_dutch.php' " .
99 "+ '?set_pid=' + pid;\n";
102 echo
" top.RTop.location = '../../patient_file/summary/demographics.php' " .
103 "+ '?set_pid=' + pid;\n";
105 // larry :: end of dbc change
107 echo
" top.location = '../../patient_file/patient_file.php' " .
108 "+ '?set_pid=' + pid + '&pid=' + pid;\n";
113 function GoToToday(theForm
){
114 var todays_date
= new Date();
115 var theMonth
= todays_date
.getMonth() + 1;
116 theMonth
= theMonth
< 10 ? "0" + theMonth
: theMonth
;
117 theForm
.jumpdate
.value
= todays_date
.getFullYear() + "-" + theMonth
+ "-" + todays_date
.getDate();
118 top
.restoreSession();
124 <!-- Required for the popup date selectors -->
125 <div id=
"overDiv" style=
"position:absolute; visibility:hidden; z-index:1000;"></div>
129 // A_CATEGORY is an ordered array of associative-array categories.
130 // Keys of interest are: id, name, color, desc, event_duration.
132 // echo
"<!-- A_CATEGORY = "; print_r($this-
>_tpl_vars['A_CATEGORY']); echo
" -->\n"; // debugging
133 // echo
"<!-- A_EVENTS = "; print_r($this-
>_tpl_vars['A_EVENTS']); echo
" -->\n"; // debugging
135 $A_CATEGORY =& $this-
>_tpl_vars['A_CATEGORY'];
137 // [-if $PRINT_VIEW !=
1-]
138 // [-*Main Navigation*-]
139 // [-include
file=
"$TPL_NAME/views/global/navigation.html"-]
142 $A_EVENTS =& $this-
>_tpl_vars['A_EVENTS'];
143 // $S_EVENTS =& $this-
>_tpl_vars['S_EVENTS']; // Deleted by Rod
144 $providers =& $this-
>_tpl_vars['providers'];
145 $times =& $this-
>_tpl_vars['times'];
146 $interval = $this-
>_tpl_vars['interval'];
147 $viewtype = $this-
>_tpl_vars['VIEW_TYPE'];
148 $PREV_WEEK_URL = $this-
>_tpl_vars['PREV_WEEK_URL'];
149 $NEXT_WEEK_URL = $this-
>_tpl_vars['NEXT_WEEK_URL'];
150 $PREV_DAY_URL = $this-
>_tpl_vars['PREV_DAY_URL'];
151 $NEXT_DAY_URL = $this-
>_tpl_vars['NEXT_DAY_URL'];
153 $Date = postcalendar_getDate();
154 if (!isset($y)) $y = substr($Date,
0,
4);
155 if (!isset($m)) $m = substr($Date,
4,
2);
156 if (!isset($d)) $d = substr($Date,
6,
2);
158 // echo
"<!-- There are " . count($A_EVENTS) .
" A_EVENTS days -->\n";
160 $MULTIDAY = count($A_EVENTS)
> 1;
162 $facilities = getUserFacilities($_SESSION['authId']); // from users_facility
163 if (count($facilities) ==
1 || !$_SESSION['pc_facility']) {
164 $_SESSION['pc_facility'] = $facilities[
0]['id'];
166 if ( $_SESSION['pc_facility'] ) {
167 $provinfo = getProviderInfo('%', true, $_SESSION['pc_facility']);
169 $provinfo = getProviderInfo();
171 // echo
"<form name='theform' action='index.php?module=PostCalendar&func=view" .
172 echo
"<form id='theform' name='theform' action='index.php?module=PostCalendar&func=view" .
173 "&tplview=default&pc_category=&pc_topic=' " .
174 "method='post' onsubmit='return top.restoreSession()'>\n";
176 echo
"<table border='0' cellpadding='0' cellspacing='0' width='99%'>\n";
177 echo
" <tr><td colspan='3' height='5'></td></tr>\n";
180 // Build the scrolling selection list of providers.
181 echo
" <td rowspan='2' align='left' valign='top' width='33%' nowrap>\n";
182 echo
" <select multiple size='3' name='pc_username[]'>\n";
183 echo
" <option value='__PC_ALL__'>" .xl (
"All Users").
"</option>\n";
184 foreach ($provinfo as $doc) {
185 $username = $doc['username'];
186 echo
" <option value='$username'";
187 foreach ($providers as $provider)
188 if ($provider['username'] == $username) echo
" selected";
189 echo
">" . $doc['fname'] .
" " . $doc['lname'] .
"</option>\n";
193 /*********************************************************************
194 // ==============================
195 // FACILITY FILTERING (lemonsoftware)
196 $facilities = getFacilities();
197 echo
" <select name='pc_facility'>\n";
198 if ( !$_SESSION['pc_facility'] ) $selected =
"selected='selected'";
199 echo
" <option value='0' $selected>" .xl('All Facilities').
"</option>\n";
200 foreach ($facilities as $fa) {
201 $selected = ( $_SESSION['pc_facility'] == $fa['id']) ?
"selected='selected'" :
"" ;
202 echo
" <option value='" .$fa['id'].
"' $selected>" .$fa['name'].
"</option>\n";
205 *********************************************************************/
206 // ==============================
207 // FACILITY FILTERING (lemonsoftware)
208 if ($_SESSION['authorizeduser'] ==
1) {
209 $facilities = getFacilities();
211 $facilities = getUserFacilities($_SESSION['authId']); // from users_facility
212 if (count($facilities) ==
1)
213 $_SESSION['pc_facility'] = ($facilities[
0]['id']);
215 if (count($facilities)
> 1) {
216 echo
" <select name='pc_facility' id='pc_facility' onChange='document.getElementById(\"theform\
").submit();'>\n";
217 if ( !$_SESSION['pc_facility'] ) $selected =
"selected='selected'";
218 if ( !$GLOBALS['restrict_user_facility']) echo
" <option value='0' $selected>" . xl('All Facilities') .
"</option>\n";
219 foreach ($facilities as $fa) {
220 $selected = ( $_SESSION['pc_facility'] == $fa['id']) ?
"selected='selected'" :
"" ;
221 echo
" <option value='" . $fa['id'] .
"' $selected>" . $fa['name'] .
"</option>\n";
225 /********************************************************************/
228 // ==============================
232 // Build the date and view type selectors and the Go button and the Today button.
233 echo
" <td align='center' valign='top' width='34%' nowrap>\n";
235 echo
" <input type='text' size='10' name='jumpdate' id='jumpdate'\n" .
236 " value='$y-$m-$d' title='yyyy-mm-dd date to go to'\n" .
237 " onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />\n" .
238 " <img src='../../pic/show_calendar.gif' id='img_jumpdate' align='absbottom'\n" .
239 " width='24' height='22' border='0' alt='[?]' style='cursor:pointer'\n" .
240 " title='" .xl (
"Click here to choose a date").
"'>\n";
242 echo
" <select name='viewtype'>\n";
243 foreach ( array ('day' =
> xl(
"Day View"), 'week' =
> xl(
"Week View"), 'month' =
> xl(
"Month View"), 'year' =
> xl(
"Year View"))
245 echo
" <option value='$key'";
246 if ($key == $viewtype) echo
" selected";
247 echo
">$value</option>\n";
250 echo
" <input type='submit' name='bnsubmit' value='" .xl (
"Go").
"' />\n";
251 echo
" <input type='submit' name='bnsubmit' value='" .xl (
"Today").
"' onClick='GoToToday(theform);' />\n";
254 // Show the Add and Search buttons.
255 echo
" <td align='right' valign='top' width='33%' nowrap>\n";
256 echo
" <input type='button' value='" .xl (
"Add").
"' onclick='newEvt(1, 9, 00, $Date, 0, 0)' />\n";
257 echo
" <input type='button' value='" . xl (
"Search") .
258 "' onclick='top.restoreSession();location=\"index.php?module=PostCalendar&func=search\
"' />\n";
262 // Show the date/range and its previous- and next-day/week selectors.
264 echo
" <td align='center' width='34%' nowrap>\n";
265 $atmp = array_keys($A_EVENTS);
268 echo
"<a href='$PREV_WEEK_URL' onclick='top.restoreSession()'><<</a> \n";
269 echo dateformat(strtotime($atmp[
0]));
271 echo dateformat(strtotime($atmp[count($atmp)-
1]));
272 echo
" <a href='$NEXT_WEEK_URL' onclick='top.restoreSession()'>>></a>\n";
274 echo
"<a href='$PREV_DAY_URL' onclick='top.restoreSession()'><<</a> \n";
275 echo dateformat(strtotime($atmp[
0]), true);
276 echo
" <a href='$NEXT_DAY_URL' onclick='top.restoreSession()'>>></a>\n";
279 echo
" <td align='right' width='33%' nowrap>\n";
290 <script language='JavaScript'
>
291 Calendar
.setup({inputField
:"jumpdate", ifFormat
:"%Y-%m-%d", button
:"img_jumpdate"});
294 [-assign
var=
"dayname" value=$DATE|date_format:
"%w"-]
295 [-assign
var=
"day" value=$DATE|date_format:
"%d"|string_format:
"%1d"-]
296 [-assign
var=
"month" value=$DATE|date_format:
"%m"|string_format:
"%1d"-]
297 [-assign
var=
"year" value=$DATE|date_format:
"%Y"|string_format:
"%4d"-]
299 [-pc_sort_events
var=
"S_EVENTS" sort=
"time" order=
"asc" value=$A_EVENTS-]
303 echo
"<table width='100%' border='1' cellpadding='1' cellspacing='0' >\n";
304 $tdstylearr = array('bordyy', 'bordny', 'bordyn', 'bordnn');
307 foreach ($A_EVENTS as $date =
> $events) {
308 $need_headers = true;
309 $eventdate = substr($date,
0,
4) . substr($date,
5,
2) . substr($date,
8,
2);
311 // If multiple days then show a date header for each.
314 echo
" <td colspan='" . (count($providers) *
2) .
"' align='center'>" .
315 dateformat(strtotime($date), true) .
"</td>";
319 $arr_events = $S_EVENTS[$date];
320 list($slotkey, $slotevent) = each($arr_events);
322 // This is an array of provider status information for this day,
323 // used to properly assign table cell attributes.
327 $lastslotindex = count($times) -
1;
329 // For each time slot...
330 foreach ($times as $slottime) {
331 $startampm = ($slottime['mer']) ==
"pm" ?
2 :
1;
332 $starttimeh = $slottime['hour'];
333 $starttimem = $slottime['minute'];
334 $slotendmins = $starttimeh *
60 + $starttimem + $interval;
336 // Repeat doc names at
1PM. This is a kludge; omit it for released code.
337 // if ($starttimeh ==
13 && $starttimem ==
0) $need_headers = true;
339 // Get all events for all providers just for this time slot now, because we
340 // can pick up where we left off and because we don't want to re-scan all
341 // events for the day for each table cell.
344 for (; isset($slotkey); list($slotkey, $slotevent) = each($arr_events)) {
345 $starth = substr($slotevent['startTime'],
0,
2);
346 $startm = substr($slotevent['startTime'],
3,
2);
348 if (($starth *
60 + $startm)
>= $slotendmins) break;
350 $arr_slot[$slotkey] = $slotevent;
352 $catid = $slotevent['catid'];
353 $providerid = $slotevent['aid'];
354 $durminutes = ceil($slotevent['duration'] /
60);
355 $durslots = ceil($durminutes / $interval);
357 // While we're here, collect information for cell cosmetics.
358 if ($catid ==
2) { // in office
359 $provstat[$providerid]['in'] = true;
361 // Save preferred category info for this IN event.
362 $provstat[$providerid]['in_cat'] = -
1;
363 $provstat[$providerid]['in_slot0'] = $slotindex;
364 $provstat[$providerid]['in_slots'] =
1;
365 if ($slotevent['prefcatid']) {
366 foreach ($A_CATEGORY as $catkey =
> $catval) {
367 if ($catval['id'] == $slotevent['prefcatid']) {
368 $provstat[$providerid]['in_cat'] = $catkey;
369 $provstat[$providerid]['in_slots'] =
370 ceil(ceil($catval['event_duration'] /
60) / $interval);
375 if ($provstat[$providerid]['in_cat'] <
0) {
376 echo
"<!-- Unmatched prefcatid = " . $slotevent['prefcatid'] .
" -->\n"; // debugging
381 else if ($catid ==
3) { // out of office
382 $provstat[$providerid]['in'] = false;
384 else if ($catid ==
4 || $catid ==
8 || $catid ==
11) { // unavailable types
385 // unavailable slots are marked 'res' for appropriate coloring.
386 $endindex = $slotindex + $durslots;
387 for ($i = $slotindex; $i < $endindex; ++$i) {
388 $provstat[$providerid][$i]['res'] = true;
391 // If duration
> slot size then mark slots for border control. A slot
392 // marked 'ext' is not to have a border between itself and the slot below.
394 $endindex = $slotindex + $durslots -
1;
395 for ($i = $slotindex; $i < $endindex; ++$i) {
396 $provstat[$providerid][$i]['ext'] = true;
400 // Finished getting event information for this time slot.
402 // Write a header row with the provider names if appropriate.
404 $need_headers = false;
406 foreach ($providers as $provider) {
407 echo
" <td colspan='2' align='center'>";
408 echo $provider['fname'][
0] .
" " . $provider['lname'];
416 // We are now ready to write the table row for the current time slot.
417 // This loops once for each provider to be displayed.
419 foreach ($providers as $provider) {
420 $providerid = $provider['id'];
422 // Mark this as a no-bottom-border slot if the preferred category
423 // duration extends beyond it.
425 // echo
"<!-- slotindex=$slotindex in=" . $provstat[$providerid]['in'] .
426 //
" in_cat=" . $provstat[$providerid]['in_cat'] .
427 //
" in_slot0=" . $provstat[$providerid]['in_slot0'] .
428 //
" in_slots=" . $provstat[$providerid]['in_slots'] .
" -->\n"; // debugging
430 if ($provstat[$providerid]['in']) {
431 if (($slotindex +
1 - $provstat[$providerid]['in_slot0']) % $provstat[$providerid]['in_slots'])
432 $provstat[$providerid][$slotindex]['ext'] = true;
435 $content =
""; // this will be the event cell content
438 if ($provstat[$providerid][$slotindex]['res'] || ! $provstat[$providerid]['in']) {
442 // Remove top and/or bottom table cell borders using CSS when events span
443 // time slots or when the practitioner is not in-office. Using
"rowspan"
444 // would be a difficult and inferior solution to this problem.
448 if ($slotindex < $lastslotindex &&
449 ($provstat[$providerid][$slotindex]['ext'] || !$provstat[$providerid]['in'])) {
450 $tdstyleix +=
1; // no bottom
452 if ($slotindex
> 0 && ($provstat[$providerid][$slotindex-
1]['ext'] ||
453 !($provstat[$providerid]['in'] || $provstat[$providerid]['wasin']))) {
454 $tdstyleix +=
2; // no top
457 $tdstyle = ' ' . $tdstylearr[$tdstyleix];
459 $disptimeh = ($starttimeh
> 12) ? ($starttimeh -
12) : $starttimeh;
462 if ($provstat[$providerid]['in_cat']
>=
0) {
463 $category =& $A_CATEGORY[$provstat[$providerid]['in_cat']];
464 if ($category['id']) $in_cat_id = $category['id'];
467 // If a slot omits the top border, then we omit the TOD cell's top border
468 // and skip writing its time-of-day text. This way we can get some rows
469 // with no content at all, which should produce a more compact and readable
472 echo
" <td class='t$clsuffix$tdstyle'";
473 if ($slotindex ==
0) echo
" width='1%'";
476 echo
"<a href='javascript:newEvt($startampm,$starttimeh,$starttimem,$eventdate,$providerid,$in_cat_id)'>";
477 echo
"$disptimeh:$starttimem</a>";
479 echo
"<div class=tiny></div>"; //
1x1 px content so the browser does not suppress borders
483 echo
" <td class='e$clsuffix$tdstyle'";
484 if ($clsuffix ==
"acell" && $in_cat_id) {
485 echo
" style='background-color:" . $category['color'] .
"'";
486 echo
" title='" . $category['name'] .
"'";
490 // Scan all events for this time slot and generate the associated HTML for
491 // this doc. JavaScript is used in hrefs to reduce the volume of output.
494 while (list($eventkey, $event) = each($arr_slot)) {
495 if ($event['aid'] != $providerid) continue;
496 if ($content) $content .=
" ";
497 $starth = substr($event['startTime'],
0,
2);
498 $startm = substr($event['startTime'],
3,
2);
499 $eventid = $event['eid'];
500 $patientid = $event['pid'];
501 $commapos = strpos($event['patient_name'],
",");
502 $lname = addslashes(ucfirst(strtolower(substr($event['patient_name'],
0, $commapos))));
503 $fname = addslashes(ucfirst(strtolower(substr($event['patient_name'], $commapos +
2))));
504 $patient_dob = $event['patient_dob'];
505 $patient_age = $event['patient_age'];
506 $catid = $event['catid'];
507 $comment = addslashes($event['hometext']);
508 $catname = $event['catname'];
509 $title = xl('Age') .
" $patient_age ($patient_dob)";
510 if ($comment && $GLOBALS['calendar_appt_style'] <
4)
511 $title .=
" " . $comment;
512 if ($catid ==
2 || $catid ==
3 || $catid ==
4 || $catid ==
8 || $catid ==
11) {
513 if ($catid ==
2) $catname = xl('IN');
514 else if ($catid ==
3) $catname = xl('OUT');
515 else if ($catid ==
4) $catname = xl('VACATION');
516 else if ($catid ==
8) $catname = xl('LUNCH');
517 else if ($catid ==
11) $catname = xl('RESERVED');
518 // Omit lunch, vacation, etc. if the doc is not in-office.
519 if ($provstat[$providerid]['in'] || $catid <
4) {
520 $content .=
"<a href='javascript:oldEvt($eventdate,$eventid)'>";
521 $content .= $catname;
522 if ($comment) $content .=
" - $comment";
526 else { // some sort of patient appointment
527 $content .=
"<a href='javascript:oldEvt($eventdate,$eventid)' title='$catname'>";
528 // $content .= $starth . ':' . $startm . htmlspecialchars($event['apptstatus']) .
"</a>";
529 $content .= $starth . ':' . $startm . '
' . htmlspecialchars($event['apptstatus']) .
" </a>";
530 $content .=
"<a href='javascript:goPid($patientid)' title='$title'>";
531 if ($catid ==
1) $content .=
"<strike>";
533 if ($GLOBALS['calendar_appt_style'] !=
1) {
534 $content .=
"," . $fname;
535 if ($event['title'] && $GLOBALS['calendar_appt_style']
>=
3) {
536 $content .=
"(" . $event['title'];
537 if ($event['hometext'] && $GLOBALS['calendar_appt_style']
>=
4)
538 $content .=
": <font color='green'>" . htmlspecialchars(trim($event['hometext'])) .
"</font>";
542 if ($catid ==
1) $content .=
"</strike>";
547 if (! $content) $content =
"<div class=tiny></div>"; // so the browser does not suppress borders
548 echo $content .
"</td>\n";
550 // Keep track of whether the doc was in during the previous time slot.
551 $provstat[$providerid]['wasin'] = $provstat[$providerid]['in'];
564 // [-include
file=
"$TPL_NAME/views/global/footer.html"-]
565 // [-include
file=
"$TPL_NAME/views/footer.html"-]