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"-]
15 [-*Values used in setting timeslot and event heights*-]
17 /* if you change these be sure to change their matching values in
18 * the CSS for the calendar, found in interface/themes/ajax_calendar.css
20 $timeslotHeightVal=
20;
21 $
timeslotHeightUnit=
"px";
24 <script language='JavaScript'
>
26 var mypcc
= '[-php-] echo $GLOBALS['phone_country_code
'] [-/php-]';
28 // This is called from the event editor popup.
29 function refreshme() {
31 document
.forms
[0].submit();
34 function newEvt(startampm
, starttimeh
, starttimem
, eventdate
, providerid
, catid
) {
35 dlgopen('add_edit_event.php?startampm=' + startampm
+
36 '&starttimeh=' + starttimeh
+ '&starttimem=' + starttimem
+
37 '&date=' + eventdate
+ '&userid=' + providerid
+ '&catid=' + catid
,
41 function oldEvt(eventdate
, eventid
) {
42 dlgopen('add_edit_event.php?date='+eventdate
+'&eid=' + eventid
, '_blank', 550, 270);
48 if ($GLOBALS
['concurrent_layout'])
50 if( $GLOBALS
['dutchpc'] )
52 echo
" top.RTop.location = '../../patient_file/summary/demographics_dutch.php' " .
53 "+ '?set_pid=' + pid;\n";
56 echo
" top.RTop.location = '../../patient_file/summary/demographics.php' " .
57 "+ '?set_pid=' + pid;\n";
61 echo
" top.location = '../../patient_file/patient_file.php' " .
62 "+ '?set_pid=' + pid + '&pid=' + pid;\n";
67 function GoToToday(theForm
){
68 var todays_date
= new Date();
69 var theMonth
= todays_date
.getMonth() + 1;
70 theMonth
= theMonth
< 10 ? "0" + theMonth
: theMonth
;
71 theForm
.jumpdate
.value
= todays_date
.getFullYear() + "-" + theMonth
+ "-" + todays_date
.getDate();
80 // this is my proposed setting in the globals config file so we don't
81 // need to mess with altering the pn database AND the config file
82 //pnModSetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek', $GLOBALS['schedule_dow_start']);
84 // build a day-of-week (DOW) list so we may properly build the calendars later in this code
86 $tmpDOW = pnModGetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek');
87 // bound check and auto-correction
88 if ($tmpDOW
<0 || $tmpDOW
>6) {
89 pnModSetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek', '
0');
92 while (count($DOWlist) <
7) {
93 array_push($DOWlist, $tmpDOW);
95 if ($tmpDOW
> 6) $tmpDOW =
0;
98 // A_CATEGORY is an ordered array of associative-array categories.
99 // Keys of interest are: id, name, color, desc, event_duration.
101 // echo
"<!-- A_CATEGORY = "; print_r($this-
>_tpl_vars['A_CATEGORY']); echo
" -->\n"; // debugging
102 // echo
"<!-- A_EVENTS = "; print_r($this-
>_tpl_vars['A_EVENTS']); echo
" -->\n"; // debugging
104 $A_CATEGORY =& $this-
>_tpl_vars['A_CATEGORY'];
106 // [-if $PRINT_VIEW !=
1-]
107 // [-*Main Navigation*-]
108 // [-include
file=
"$TPL_NAME/views/global/navigation.html"-]
111 $A_EVENTS =& $this-
>_tpl_vars['A_EVENTS'];
112 $providers =& $this-
>_tpl_vars['providers'];
113 $times =& $this-
>_tpl_vars['times'];
114 $interval = $this-
>_tpl_vars['interval'];
115 $viewtype = $this-
>_tpl_vars['VIEW_TYPE'];
116 $PREV_WEEK_URL = $this-
>_tpl_vars['PREV_WEEK_URL'];
117 $NEXT_WEEK_URL = $this-
>_tpl_vars['NEXT_WEEK_URL'];
118 $PREV_DAY_URL = $this-
>_tpl_vars['PREV_DAY_URL'];
119 $NEXT_DAY_URL = $this-
>_tpl_vars['NEXT_DAY_URL'];
121 $Date = postcalendar_getDate();
122 if (!isset($y)) $y = substr($Date,
0,
4);
123 if (!isset($m)) $m = substr($Date,
4,
2);
124 if (!isset($d)) $d = substr($Date,
6,
2);
126 // echo
"<!-- There are " . count($A_EVENTS) .
" A_EVENTS days -->\n";
128 //==================================
129 //FACILITY FILTERING (CHEMED)
130 if ( $_SESSION['pc_facility'] ) {
131 $provinfo = getProviderInfo('%', true, $_SESSION['pc_facility']);
133 $provinfo = getProviderInfo();
135 //EOS FACILITY FILTERING (CHEMED)
136 //==================================
140 <!-- stuff form element here to avoid the margin padding it introduces into the page in some browsers -->
141 <form name='theform' id='theform' action='index.php?module=PostCalendar&func=view&tplview=default&pc_category=&pc_topic=' method='post' onsubmit='return top.restoreSession()'
>
142 <input type=
"hidden" name=
"jumpdate" id=
"jumpdate" value=
"">
143 <input type=
"hidden" name=
"viewtype" id=
"viewtype" value=
"[-php-]echo $viewtype;[-/php-]">
145 echo
" <input type='button' value='" .xl (
"Add").
"' onclick='newEvt(1, 9, 00, $Date, 0, 0)' />\n";
146 echo
" <input type='button' value='" . xl (
"Search") .
147 "' onclick='top.restoreSession();location=\"index.php?module=PostCalendar&func=search\
"' />\n";
151 <div id=
"topToolbarRight"> <!-- this wraps some of the top toolbar items -->
154 <a href='[-php-]echo $PREV_MONTH_URL[-/php-]' onclick='top.restoreSession()'
>
155 <img id=
"prevmonth" src=
"[-$TPL_IMAGE_PATH-]/leftbtn.gif" border=
"0" title=
"[-php-]echo xl("Previous Month
")[-/php-]" alt=
"[-php-]echo xl ("Previous Month
")[-/php-]" /></a>
156 <a href='[-php-]echo $NEXT_MONTH_URL[-/php-]' onclick='top.restoreSession()'
>
157 <img id=
"nextmonth" src=
"[-$TPL_IMAGE_PATH-]/rightbtn.gif" border=
"0" title=
"[-php-]echo xl("Next Month
")[-/php-]" alt=
"[-php-]echo xl ("Next Month
")[-/php-]" /></a>
159 <input type='submit' name='bnsubmit' value='[-php-]echo xl (
"Today")[-/php-]' onClick='GoToToday(theform);'
/>
162 <div id=
"viewPicker">
164 <img id=
"printview" src=
"[-$TPL_IMAGE_PATH-]/print.gif" border=
"0" title=
"[-php-]echo xl("Print View
")[-/php-]" alt=
"[-php-]echo xl ("Print View
")[-/php-]" />
166 <img id=
"dayview" src=
"[-$TPL_IMAGE_PATH-]/day.gif" border=
"0" title=
"[-php-]echo xl("Day View
")[-/php-]" alt=
"[-php-]echo xl ("Day View
")[-/php-]" />
168 <img id=
"weekview" src=
"[-$TPL_IMAGE_PATH-]/week.gif" border=
"0" title=
"[-php-]echo xl ("Week View
")[-/php-]" alt=
"[-php-]echo xl ("Week View
")[-/php-]" />
170 <img id=
"monthview" class=
"currentview" src=
"[-$TPL_IMAGE_PATH-]/month.gif" border=
"0" title=
"[-php-]echo xl ("Month View
")[-/php-]" alt=
"[-php-]echo xl ("Month View
")[-/php-]" />
172 </div> <!-- end topToolbarRight -->
174 <div id=
"datePicker">
175 <table border=
"0" cellpadding=
"0" cellspacing=
"0">
178 // caldate depends on what the user has clicked
179 $caldate = strtotime($Date);
180 $cMonth = date(
"m", $caldate);
181 $cYear = date(
"Y", $caldate);
182 $cDay = date(
"d", $caldate);
184 // compute the previous month date
185 // stay on the same day if possible
187 $pMonth = $cMonth -
1;
189 if ($pMonth <
1) { $pMonth =
12; $pYear = $cYear -
1; }
190 while (! checkdate($pMonth, $pDay, $pYear)) { $pDay = $pDay -
1; }
191 $prevMonth = sprintf(
"%d%02d%02d",$pYear,$pMonth,$pDay);
193 // compute the next month
194 // stay on the same day if possible
196 $nMonth = $cMonth +
1;
198 if ($nMonth
> 12) { $nMonth =
1; $nYear = $cYear +
1; }
199 while (! checkdate($nMonth, $nDay, $nYear)) { $nDay = $nDay -
1; }
200 $nextMonth = sprintf(
"%d%02d%02d",$nYear,$nMonth,$nDay);
202 <td class=
"tdDOW-small tdDatePicker tdNav" id=
"[-php-]echo $prevMonth[-/php-]" title=
"[-php-]echo date("F
", strtotime($prevMonth));[-/php-]"><</td>
203 <td colspan=
"5" class=
"tdMonthName-small">
205 echo date('F', $caldate);
208 <td class=
"tdDOW-small tdDatePicker tdNav" id=
"[-php-]echo $nextMonth[-/php-]" title=
"[-php-]echo date("F
", strtotime($nextMonth));[-/php-]">></td>
211 foreach ($DOWlist as $dow) {
212 echo
"<td class='tdDOW-small'>".$this-
>_tpl_vars['A_SHORT_DAY_NAMES'][$dow].
"</td>";
217 $atmp = array_keys($A_EVENTS);
219 foreach ($atmp as $currdate) {
220 $currdate = strtotime($currdate);
221 if (date('w', $currdate) == $DOWlist[
0]) {
228 $tdClass =
"tdMonthDay-small";
229 if (date('m', $currdate) != $month) {
230 $tdClass =
"tdOtherMonthDay-small";
232 if ((date('w', $currdate) ==
0) || (date('w', $currdate) ==
6)) {
233 $tdClass =
"tdWeekend-small";
236 if (date('Ymd',$currdate) == $Date) {
237 // $Date is defined near the top of this file
238 // and is equal to whatever date the user has clicked
239 $tdClass .=
" currentDate";
242 // add a class so that jQuery can grab these days for the 'click' event
243 $tdClass .=
" tdDatePicker";
247 $td .=
"class=\"".$tdClass."\
" ";
248 //$td .=
"id=\"".date("Ymd
", $currdate)."\
" ";
249 $td .=
"id=\"".date("Ymd
", $currdate)."\
" ";
250 $td .=
"title=\"Go to
".date('F', $currdate)."\
" ";
251 $td .=
"> ".date('d', $currdate).
"</td>\n";
255 if (date('w', $currdate) == $DOWlist[
6]) echo
"</tr>\n";
261 <div id=
"bigCalHeader">
263 echo date('F Y', strtotime($Date));
267 <div id=
"providerPicker">
271 // ==============================
272 // FACILITY FILTERING (lemonsoftware)
273 $facilities = getFacilities();
274 if (count($facilities)
> 1) {
275 echo
" <select name='pc_facility' id='pc_facility'>\n";
276 if ( !$_SESSION['pc_facility'] ) $selected =
"selected='selected'";
277 echo
" <option value='0' $selected>" .xl('All Facilities').
"</option>\n";
278 foreach ($facilities as $fa) {
279 $selected = ( $_SESSION['pc_facility'] == $fa['id']) ?
"selected='selected'" :
"" ;
280 echo
" <option value='" .$fa['id'].
"' $selected>" .$fa['name'].
"</option>\n";
285 // ==============================
287 echo
" <select multiple size='5' name='pc_username[]' id='pc_username'>\n";
288 echo
" <option value='__PC_ALL__'>" .xl (
"All Users").
"</option>\n";
289 foreach ($provinfo as $doc) {
290 $username = $doc['username'];
291 echo
" <option value='$username'";
292 foreach ($providers as $provider)
293 if ($provider['username'] == $username) echo
" selected";
294 echo
">" . $doc['lname'] .
", " . $doc['fname'] .
"</option>\n";
303 [-assign
var=
"dayname" value=$DATE|date_format:
"%w"-]
304 [-assign
var=
"day" value=$DATE|date_format:
"%d"|string_format:
"%1d"-]
305 [-assign
var=
"month" value=$DATE|date_format:
"%m"|string_format:
"%1d"-]
306 [-assign
var=
"year" value=$DATE|date_format:
"%Y"|string_format:
"%4d"-]
311 foreach ($A_EVENTS as $date =
> $events) {
313 foreach ($events as $oneE) {
317 echo
"<hr width=100%>";
322 // This loops once for each provider to be displayed.
324 foreach ($providers as $provider) {
325 $providerid = $provider['id'];
329 echo
" <td colspan='7' class='providerheader'>";
330 echo $provider['fname'].
" ".$provider['lname'];
334 // output date headers
336 $defaultDate =
""; // used when creating link for a 'new' event
337 $in_cat_id =
0; // used when creating link for a 'new' event
339 foreach ($A_EVENTS as $date =
> $events) {
340 if ($defaultDate ==
"") $defaultDate = date(
"Ymd", strtotime($date));
341 echo
"<td align='center' class='month_dateheader'>";
342 echo date(
"D", strtotime($date));
344 if ($dowCount++ ==
6) { break; }
349 // output a TD with an inner containing DIV positioned 'relative'
351 foreach ($A_EVENTS as $date =
> $events) {
352 $eventdate = substr($date,
0,
4) . substr($date,
5,
2) . substr($date,
8,
2);
354 $gotoURL = pnModURL(__POSTCALENDAR__,'user','view',
355 array('tplview'=
>$template_view,
357 'Date'=
> date(
"Ymd", strtotime($date)),
358 'pc_username'=
>$pc_username,
359 'pc_category'=
>$category,
360 'pc_topic'=
>$topic));
362 if (date(
"w", strtotime($date)) == $DOWlist[
0]) { echo
"<tr>"; }
363 echo
"<td class='schedule'>";
365 echo
"<div class='calendar_day'>\n";
367 echo
"<div class='month_daylink'>";
368 echo
"<a href='".$gotoURL.
"' alt='Go to ".date(
"d M Y", strtotime($date)).
"' title='Go to ".date(
"d M Y", strtotime($date)).
"'>";
369 echo date(
"d", strtotime($date)).
"</a></div>";
371 if (count($events) ==
0) { echo
" "; }
373 foreach ($events as $event) {
374 // skip events for other providers
375 // yeah, we've got that sort of overhead here... it ain't perfect
376 if ($providerid != $event['aid']) { continue; }
378 // Omit IN and OUT events to reduce clutter in this month view
379 if (($event['catid'] ==
2) || ($event['catid'] ==
3)) { continue; }
381 // specially handle all-day events
382 if ($event['alldayevent'] ==
1) {
383 $tmpTime = $times[
0];
384 if (strlen($tmpTime['hour']) <
2) { $tmpTime['hour'] =
"0".$tmpTime['hour']; }
385 if (strlen($tmpTime['minute']) <
2) { $tmpTime['minute'] =
"0".$tmpTime['minute']; }
386 $event['startTime'] = $tmpTime['hour'].
":".$tmpTime['minute'].
":00";
387 $event['duration'] = ($calEndMin - $calStartMin) *
60; // measured in seconds
390 // figure the start time and minutes (from midnight)
391 $starth = substr($event['startTime'],
0,
2);
392 $startm = substr($event['startTime'],
3,
2);
393 $eStartMin = $starth *
60 + $startm;
394 $startDateTime = strtotime($date.
" ".$event['startTime']);
396 // determine the class for the event DIV based on the event category
397 $evtClass =
"event_appointment";
398 switch ($event['catid']) {
399 case
1: // NO-SHOW appt
400 $evtClass =
"event_noshow";
403 $evtClass =
"event_in";
405 case
3: // OUT of office
406 $evtClass =
"event_out";
411 $evtClass =
"event_reserved";
413 default: // some appointment
414 $evtClass =
"event_appointment";
418 // now, output the event DIV
420 $eventid = $event['eid'];
421 $patientid = $event['pid'];
422 $commapos = strpos($event['patient_name'],
",");
423 $lname = addslashes(ucfirst(strtolower(substr($event['patient_name'],
0, $commapos))));
424 $fname = addslashes(ucfirst(strtolower(substr($event['patient_name'], $commapos +
2))));
425 $patient_dob = $event['patient_dob'];
426 $patient_age = $event['patient_age'];
427 $catid = $event['catid'];
428 $comment = addslashes($event['hometext']);
429 $catname = $event['catname'];
430 $title =
"Age $patient_age ($patient_dob)";
432 // format the time specially
433 $displayTime = date(
"g", $startDateTime);
434 if (date(
"i", $startDateTime) ==
"00") {
435 $displayTime .= (date(
"a", $startDateTime));
438 $displayTime .= (date(
":ia", $startDateTime));
441 if ($comment && $GLOBALS['calendar_appt_style'] <
4) $title .=
" " . $comment;
443 // the divTitle is what appears when the user hovers the mouse over the DIV
444 $divTitle = date(
"D, d M Y", strtotime($date));
447 if ($catid ==
4 || $catid ==
8 || $catid ==
11) {
448 if ($catid ==
4) $catname =
"VACATION";
449 else if ($catid ==
8) $catname =
"LUNCH";
450 else if ($catid ==
11) $catname =
"RESERVED";
453 if ($comment) $atitle .=
" $comment";
454 //$divTitle .=
"\n[".$atitle .
"] ".$divTitle;
455 $divTitle .=
"\n[".$atitle .
"]";
456 //$content =
"<a href='javascript:oldEvt($eventdate,$eventid)' title='$atitle'>";
457 $content .= $displayTime;
458 $content .=
" ".$catname;
459 //if ($comment) $content .=
" - $comment";
460 //$content .=
"</a>";
463 // some sort of patient appointment
465 $divTitle .=
"\r\n[".$catname .
"] ".$fname.
" ".$lname;
466 //$content =
"<a href='javascript:oldEvt($eventdate,$eventid)' title='$title'>";
467 $content .= $displayTime;
468 //$content .= htmlspecialchars($event['apptstatus']);
469 //$content .=
"</a>";
471 // include patient name and link to their details
472 $content .=
"<a href='javascript:goPid($patientid)' title='$title'>";
473 $iTitle =
"View Patient [".$fname.
" ".$lname.
"]";
474 $content .=
"<img src='$TPL_IMAGE_PATH/user-green.gif' border='0' title='".$iTitle.
"' alt='".$iTitle.
"' />";
475 //if ($catid ==
1) $content .=
"<strike>";
476 //$content .= $lname;
477 //if ($catid ==
1) $content .=
"</strike>";
481 // no patient id, just output the category name
482 $content .=
" ".$catname;
485 $divTitle .=
"\n(double click to edit)";
487 echo
"<div class='".$evtClass.
" month_event' style='background-color:".$event[
"catcolor"].
488 "' title='".$divTitle.
"'".
489 " id='".$eventdate.
"-".$eventid.
"'".
497 if (date(
"w", strtotime($date)) == $DOWlist[
6]) { echo
"</tr>"; }
505 // [-include
file=
"$TPL_NAME/views/global/footer.html"-]
506 // [-include
file=
"$TPL_NAME/views/footer.html"-]
509 </div> <!-- end bigCal DIV -->
513 <script language='JavaScript'
>
515 $(document
).ready(function(){
516 $("#pc_username").change(function() { ChangeProviders(this); });
517 $("#pc_facility").change(function() { ChangeProviders(this); });
518 $("#dayview").click(function() { ChangeView(this); });
519 $("#weekview").click(function() { ChangeView(this); });
520 //$("#monthview").click(function() { ChangeView(this); });
521 //$("#yearview").click(function() { ChangeView(this); });
522 $(".tdDatePicker").click(function() { ChangeDate(this); });
523 $("#datePicker .tdNav").mouseover(function() { $(this).toggleClass("tdDatePickerHighlight"); });
524 $("#datePicker .tdNav").mouseout(function() { $(this).toggleClass("tdDatePickerHighlight"); });
525 $("#printview").click(function() { PrintView(this); });
526 $(".month_event").dblclick(function() { EditEvent(this); });
527 $(".month_event").mouseover(function() { $(this).toggleClass("event_highlight"); });
528 $(".month_event").mouseout(function() { $(this).toggleClass("event_highlight"); });
531 /* edit an existing event */
532 var EditEvent = function(eObj
) {
533 //alert ('editing '+eObj.id);
534 // split the object ID into date and event ID
536 var parts
= new Array();
537 parts
= objID
.split("-");
538 // call the oldEvt function to bring up the event editor
539 oldEvt(parts
[0], parts
[1]);
543 /* pop up a window to print the current view
545 var PrintView = function (eventObject
) {
546 printURL
= "[-php-]echo pnModURL(__POSTCALENDAR__,'user','view',
547 array('tplview'=>$template_view,
548 'viewtype'=>$viewtype,
551 'pc_username'=>$pc_username,
552 'pc_category'=>$category,
553 'pc_topic'=>$topic));[-/php-]";
554 window
.open(printURL
,'printwindow','width=740,height=480,toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,copyhistory=no,resizable=yes');
558 /* change the current date based upon what the user clicked in
561 var ChangeDate = function(eObj
) {
562 baseURL
= "[-php-]echo pnModURL(__POSTCALENDAR__,'user','view',
563 array('tplview'=>$template_view,
564 'viewtype'=>$viewtype,
565 'Date'=> '~REPLACEME~',
566 'pc_username'=>$pc_username,
567 'pc_category'=>$category,
568 'pc_topic'=>$topic));[-/php-]";
569 newURL
= baseURL
.replace(/~REPLACEME~/, eObj
.id
);
570 document
.location
.href
=newURL
;
573 /* change the provider(s)
575 var ChangeProviders = function (eventObject
) {
576 $('#theform').submit();
579 /* change the calendar view
581 var ChangeView = function (eventObject
) {
582 if (eventObject
.id
== "dayview") {
583 $("#viewtype").val('day');
585 else if (eventObject
.id
== "weekview") {
586 $("#viewtype").val('week');
588 else if (eventObject
.id
== "monthview") {
589 $("#viewtype").val('month');
591 else if (eventObject
.id
== "yearview") {
592 $("#viewtype").val('year');
594 $('#theform').submit();