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'])
51 echo
" top.RTop.location = '../../patient_file/summary/demographics.php' " .
52 "+ '?set_pid=' + pid;\n";
55 echo
" top.location = '../../patient_file/patient_file.php' " .
56 "+ '?set_pid=' + pid + '&pid=' + pid;\n";
61 function GoToToday(theForm
){
62 var todays_date
= new Date();
63 var theMonth
= todays_date
.getMonth() + 1;
64 theMonth
= theMonth
< 10 ? "0" + theMonth
: theMonth
;
65 theForm
.jumpdate
.value
= todays_date
.getFullYear() + "-" + theMonth
+ "-" + todays_date
.getDate();
74 // this is my proposed setting in the globals config file so we don't
75 // need to mess with altering the pn database AND the config file
76 //pnModSetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek', $GLOBALS['schedule_dow_start']);
78 // build a day-of-week (DOW) list so we may properly build the calendars later in this code
80 $tmpDOW = pnModGetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek');
81 // bound check and auto-correction
82 if ($tmpDOW
<0 || $tmpDOW
>6) {
83 pnModSetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek', '
0');
86 while (count($DOWlist) <
7) {
87 array_push($DOWlist, $tmpDOW);
89 if ($tmpDOW
> 6) $tmpDOW =
0;
92 // A_CATEGORY is an ordered array of associative-array categories.
93 // Keys of interest are: id, name, color, desc, event_duration.
95 // echo
"<!-- A_CATEGORY = "; print_r($this-
>_tpl_vars['A_CATEGORY']); echo
" -->\n"; // debugging
96 // echo
"<!-- A_EVENTS = "; print_r($this-
>_tpl_vars['A_EVENTS']); echo
" -->\n"; // debugging
98 $A_CATEGORY =& $this-
>_tpl_vars['A_CATEGORY'];
100 // [-if $PRINT_VIEW !=
1-]
101 // [-*Main Navigation*-]
102 // [-include
file=
"$TPL_NAME/views/global/navigation.html"-]
105 $A_EVENTS =& $this-
>_tpl_vars['A_EVENTS'];
106 $providers =& $this-
>_tpl_vars['providers'];
107 $times =& $this-
>_tpl_vars['times'];
108 $interval = $this-
>_tpl_vars['interval'];
109 $viewtype = $this-
>_tpl_vars['VIEW_TYPE'];
110 $PREV_WEEK_URL = $this-
>_tpl_vars['PREV_WEEK_URL'];
111 $NEXT_WEEK_URL = $this-
>_tpl_vars['NEXT_WEEK_URL'];
112 $PREV_DAY_URL = $this-
>_tpl_vars['PREV_DAY_URL'];
113 $NEXT_DAY_URL = $this-
>_tpl_vars['NEXT_DAY_URL'];
115 $Date = postcalendar_getDate();
116 if (!isset($y)) $y = substr($Date,
0,
4);
117 if (!isset($m)) $m = substr($Date,
4,
2);
118 if (!isset($d)) $d = substr($Date,
6,
2);
120 // echo
"<!-- There are " . count($A_EVENTS) .
" A_EVENTS days -->\n";
122 //==================================
123 //FACILITY FILTERING (CHEMED)
124 $facilities = getUserFacilities($_SESSION['authId']); // from users_facility
125 if (count($facilities) ==
1 || !$_SESSION['pc_facility']) {
126 $_SESSION['pc_facility'] = $facilities[
0]['id'];
128 if ( $_SESSION['pc_facility'] ) {
129 $provinfo = getProviderInfo('%', true, $_SESSION['pc_facility']);
131 $provinfo = getProviderInfo();
133 //EOS FACILITY FILTERING (CHEMED)
134 //==================================
138 <!-- stuff form element here to avoid the margin padding it introduces into the page in some browsers -->
139 <form name='theform' id='theform' action='index.php?module=PostCalendar&func=view&tplview=default&pc_category=&pc_topic=' method='post' onsubmit='return top.restoreSession()'
>
140 <input type=
"hidden" name=
"jumpdate" id=
"jumpdate" value=
"">
141 <input type=
"hidden" name=
"viewtype" id=
"viewtype" value=
"[-php-]echo $viewtype;[-/php-]">
143 echo
" <input type='button' value='" .xl (
"Add").
"' onclick='newEvt(1, 9, 00, $Date, 0, 0)' />\n";
144 echo
" <input type='button' value='" . xl (
"Search") .
145 "' onclick='top.restoreSession();location=\"index.php?module=PostCalendar&func=search\
"' />\n";
149 <div id=
"topToolbarRight"> <!-- this wraps some of the top toolbar items -->
152 <a href='[-php-]echo $PREV_MONTH_URL[-/php-]' onclick='top.restoreSession()'
>
153 <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>
154 <a href='[-php-]echo $NEXT_MONTH_URL[-/php-]' onclick='top.restoreSession()'
>
155 <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>
157 <input type='submit' name='bnsubmit' value='[-php-]echo xl (
"Today")[-/php-]' onClick='GoToToday(theform);'
/>
160 <div id=
"viewPicker">
162 <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-]" />
164 <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-]" />
166 <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-]" />
168 <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-]" />
170 </div> <!-- end topToolbarRight -->
172 <div id=
"datePicker">
173 <table border=
"0" cellpadding=
"0" cellspacing=
"0">
176 // caldate depends on what the user has clicked
177 $caldate = strtotime($Date);
178 $cMonth = date(
"m", $caldate);
179 $cYear = date(
"Y", $caldate);
180 $cDay = date(
"d", $caldate);
182 // compute the previous month date
183 // stay on the same day if possible
185 $pMonth = $cMonth -
1;
187 if ($pMonth <
1) { $pMonth =
12; $pYear = $cYear -
1; }
188 while (! checkdate($pMonth, $pDay, $pYear)) { $pDay = $pDay -
1; }
189 $prevMonth = sprintf(
"%d%02d%02d",$pYear,$pMonth,$pDay);
191 // compute the next month
192 // stay on the same day if possible
194 $nMonth = $cMonth +
1;
196 if ($nMonth
> 12) { $nMonth =
1; $nYear = $cYear +
1; }
197 while (! checkdate($nMonth, $nDay, $nYear)) { $nDay = $nDay -
1; }
198 $nextMonth = sprintf(
"%d%02d%02d",$nYear,$nMonth,$nDay);
200 <td class=
"tdDOW-small tdDatePicker tdNav" id=
"[-php-]echo $prevMonth[-/php-]" title=
"[-php-]echo xl(date("F
", strtotime($prevMonth)));[-/php-]"><</td>
201 <td colspan=
"5" class=
"tdMonthName-small">
203 echo xl(date('F', $caldate));
206 <td class=
"tdDOW-small tdDatePicker tdNav" id=
"[-php-]echo $nextMonth[-/php-]" title=
"[-php-]echo xl(date("F
", strtotime($nextMonth)));[-/php-]">></td>
209 foreach ($DOWlist as $dow) {
210 echo
"<td class='tdDOW-small'>".$this-
>_tpl_vars['A_SHORT_DAY_NAMES'][$dow].
"</td>";
215 $atmp = array_keys($A_EVENTS);
217 foreach ($atmp as $currdate) {
218 $currdate = strtotime($currdate);
219 if (date('w', $currdate) == $DOWlist[
0]) {
226 $tdClass =
"tdMonthDay-small";
227 if (date('m', $currdate) != $month) {
228 $tdClass =
"tdOtherMonthDay-small";
230 if ((date('w', $currdate) ==
0) || (date('w', $currdate) ==
6)) {
231 $tdClass =
"tdWeekend-small";
234 if (date('Ymd',$currdate) == $Date) {
235 // $Date is defined near the top of this file
236 // and is equal to whatever date the user has clicked
237 $tdClass .=
" currentDate";
240 // add a class so that jQuery can grab these days for the 'click' event
241 $tdClass .=
" tdDatePicker";
245 $td .=
"class=\"".$tdClass."\
" ";
246 //$td .=
"id=\"".date("Ymd
", $currdate)."\
" ";
247 $td .=
"id=\"".date("Ymd
", $currdate)."\
" ";
248 $td .=
"title=\"" . xl('Go to') . " ".date('F', $currdate)."\
" ";
249 $td .=
"> ".date('d', $currdate).
"</td>\n";
253 if (date('w', $currdate) == $DOWlist[
6]) echo
"</tr>\n";
259 <div id=
"bigCalHeader">
261 echo xl(date('F', strtotime($Date))) .
" " . date('Y', strtotime($Date));
265 <div id=
"providerPicker">
266 [-php-] xl('Providers','e'); [-/php-]
269 // ==============================
270 // FACILITY FILTERING (lemonsoftware)
271 // $facilities = getFacilities();
272 if ($_SESSION['authorizeduser'] ==
1) {
273 $facilities = getFacilities();
275 $facilities = getUserFacilities($_SESSION['authId']); // from users_facility
276 if (count($facilities) ==
1)
277 $_SESSION['pc_facility'] = key($facilities);
279 if (count($facilities)
> 1) {
280 echo
" <select name='pc_facility' id='pc_facility'>\n";
281 if ( !$_SESSION['pc_facility'] ) $selected =
"selected='selected'";
282 // echo
" <option value='0' $selected>" .xl('All Facilities').
"</option>\n";
283 if (!$GLOBALS['restrict_user_facility']) echo
" <option value='0' $selected>" . xl('All Facilities') .
"</option>\n";
285 foreach ($facilities as $fa) {
286 $selected = ( $_SESSION['pc_facility'] == $fa['id']) ?
"selected='selected'" :
"" ;
287 echo
" <option value='" .$fa['id'].
"' $selected>" .$fa['name'].
"</option>\n";
292 // ==============================
294 echo
" <select multiple size='5' name='pc_username[]' id='pc_username'>\n";
295 echo
" <option value='__PC_ALL__'>" .xl (
"All Users").
"</option>\n";
296 foreach ($provinfo as $doc) {
297 $username = $doc['username'];
298 echo
" <option value='$username'";
299 foreach ($providers as $provider)
300 if ($provider['username'] == $username) echo
" selected";
301 echo
">" . $doc['lname'] .
", " . $doc['fname'] .
"</option>\n";
310 [-assign
var=
"dayname" value=$DATE|date_format:
"%w"-]
311 [-assign
var=
"day" value=$DATE|date_format:
"%d"|string_format:
"%1d"-]
312 [-assign
var=
"month" value=$DATE|date_format:
"%m"|string_format:
"%1d"-]
313 [-assign
var=
"year" value=$DATE|date_format:
"%Y"|string_format:
"%4d"-]
318 foreach ($A_EVENTS as $date =
> $events) {
320 foreach ($events as $oneE) {
324 echo
"<hr width=100%>";
329 // This loops once for each provider to be displayed.
331 foreach ($providers as $provider) {
332 $providerid = $provider['id'];
336 echo
" <td colspan='7' class='providerheader'>";
337 echo $provider['fname'].
" ".$provider['lname'];
341 // output date headers
343 $defaultDate =
""; // used when creating link for a 'new' event
344 $in_cat_id =
0; // used when creating link for a 'new' event
346 foreach ($A_EVENTS as $date =
> $events) {
347 if ($defaultDate ==
"") $defaultDate = date(
"Ymd", strtotime($date));
348 echo
"<td align='center' class='month_dateheader'>";
349 echo xl(date(
"D", strtotime($date)));
351 if ($dowCount++ ==
6) { break; }
356 // output a TD with an inner containing DIV positioned 'relative'
358 foreach ($A_EVENTS as $date =
> $events) {
359 $eventdate = substr($date,
0,
4) . substr($date,
5,
2) . substr($date,
8,
2);
361 $gotoURL = pnModURL(__POSTCALENDAR__,'user','view',
362 array('tplview'=
>$template_view,
364 'Date'=
> date(
"Ymd", strtotime($date)),
365 'pc_username'=
>$pc_username,
366 'pc_category'=
>$category,
367 'pc_topic'=
>$topic));
369 if (date(
"w", strtotime($date)) == $DOWlist[
0]) { echo
"<tr>"; }
370 echo
"<td class='schedule'>";
372 echo
"<div class='calendar_day'>\n";
374 echo
"<div class='month_daylink'>";
375 echo
"<a href='".$gotoURL.
"' alt='Go to ".date(
"d M Y",strtotime($date)).
"' title='" . xl('Go to') .
" " .date(
"d M Y", strtotime($date)).
"'>";
376 echo date(
"d", strtotime($date)).
"</a></div>";
378 if (count($events) ==
0) { echo
" "; }
380 foreach ($events as $event) {
381 // skip events for other providers
382 // yeah, we've got that sort of overhead here... it ain't perfect
383 if ($providerid != $event['aid']) { continue; }
385 // Omit IN and OUT events to reduce clutter in this month view
386 if (($event['catid'] ==
2) || ($event['catid'] ==
3)) { continue; }
388 // specially handle all-day events
389 if ($event['alldayevent'] ==
1) {
390 $tmpTime = $times[
0];
391 if (strlen($tmpTime['hour']) <
2) { $tmpTime['hour'] =
"0".$tmpTime['hour']; }
392 if (strlen($tmpTime['minute']) <
2) { $tmpTime['minute'] =
"0".$tmpTime['minute']; }
393 $event['startTime'] = $tmpTime['hour'].
":".$tmpTime['minute'].
":00";
394 $event['duration'] = ($calEndMin - $calStartMin) *
60; // measured in seconds
397 // figure the start time and minutes (from midnight)
398 $starth = substr($event['startTime'],
0,
2);
399 $startm = substr($event['startTime'],
3,
2);
400 $eStartMin = $starth *
60 + $startm;
401 $startDateTime = strtotime($date.
" ".$event['startTime']);
403 // determine the class for the event DIV based on the event category
404 $evtClass =
"event_appointment";
405 switch ($event['catid']) {
406 case
1: // NO-SHOW appt
407 $evtClass =
"event_noshow";
410 $evtClass =
"event_in";
412 case
3: // OUT of office
413 $evtClass =
"event_out";
418 $evtClass =
"event_reserved";
420 default: // some appointment
421 $evtClass =
"event_appointment";
425 // now, output the event DIV
427 $eventid = $event['eid'];
428 $patientid = $event['pid'];
429 $commapos = strpos($event['patient_name'],
",");
430 $lname = substr($event['patient_name'],
0, $commapos);
431 $fname = substr($event['patient_name'], $commapos +
2);
432 $patient_dob = $event['patient_dob'];
433 $patient_age = $event['patient_age'];
434 $catid = $event['catid'];
435 $comment = addslashes($event['hometext']);
436 $catname = $event['catname'];
437 $title =
"Age $patient_age ($patient_dob)";
439 // format the time specially
440 $displayTime = date(
"g", $startDateTime);
441 if (date(
"i", $startDateTime) ==
"00") {
442 $displayTime .= (date(
"a", $startDateTime));
445 $displayTime .= (date(
":ia", $startDateTime));
448 if ($comment && $GLOBALS['calendar_appt_style'] <
4) $title .=
" " . $comment;
450 // the divTitle is what appears when the user hovers the mouse over the DIV
451 $divTitle = date(
"D, d M Y", strtotime($date));
454 if ($catid ==
4 || $catid ==
8 || $catid ==
11) {
455 if ($catid ==
4) $catname = xl(
"VACATION");
456 else if ($catid ==
8) $catname = xl(
"LUNCH");
457 else if ($catid ==
11) $catname = xl(
"RESERVED");
460 if ($comment) $atitle .=
" $comment";
461 $divTitle .=
"\n[".$atitle .
"]";
462 $content .= $displayTime;
463 $content .=
" ".$catname;
466 // some sort of patient appointment
468 $divTitle .=
"\r\n[".$catname .
"] ".htmlspecialchars($fname,ENT_QUOTES).
" ".htmlspecialchars($lname,ENT_QUOTES);
469 $content .= $displayTime;
471 // include patient name and link to their details
472 $link_title = htmlspecialchars($fname,ENT_QUOTES).
" ".htmlspecialchars($lname,ENT_QUOTES).
" \n";
473 $link_title .= xl('Age') .
": ".$patient_age.
"\n" . xl('DOB') .
": ".$patient_dob.
"\n";
474 $link_title .=
"(" . xl('Click to view') .
")";
475 $content .=
"<a href='javascript:goPid($patientid)' title='$link_title'>";
476 $content .=
"<img src='$TPL_IMAGE_PATH/user-green.gif' border='0' title='$link_title' alt='View Patient' />";
480 // no patient id, just output the category name
481 $content .=
" ".$catname;
484 $divTitle .=
"\n(" . xl('double click to edit') .
")";
486 echo
"<div class='".$evtClass.
" month_event' style='background-color:".$event[
"catcolor"].
487 "' title='".$divTitle.
"'".
488 " id='".$eventdate.
"-".$eventid.
"'".
496 if (date(
"w", strtotime($date)) == $DOWlist[
6]) { echo
"</tr>"; }
504 // [-include
file=
"$TPL_NAME/views/global/footer.html"-]
505 // [-include
file=
"$TPL_NAME/views/footer.html"-]
508 </div> <!-- end bigCal DIV -->
512 <script language='JavaScript'
>
514 $(document
).ready(function(){
515 $("#pc_username").change(function() { ChangeProviders(this); });
516 $("#pc_facility").change(function() { ChangeProviders(this); });
517 $("#dayview").click(function() { ChangeView(this); });
518 $("#weekview").click(function() { ChangeView(this); });
519 //$("#monthview").click(function() { ChangeView(this); });
520 //$("#yearview").click(function() { ChangeView(this); });
521 $(".tdDatePicker").click(function() { ChangeDate(this); });
522 $("#datePicker .tdNav").mouseover(function() { $(this).toggleClass("tdDatePickerHighlight"); });
523 $("#datePicker .tdNav").mouseout(function() { $(this).toggleClass("tdDatePickerHighlight"); });
524 $("#printview").click(function() { PrintView(this); });
525 $(".month_event").dblclick(function() { EditEvent(this); });
526 $(".month_event").mouseover(function() { $(this).toggleClass("event_highlight"); });
527 $(".month_event").mouseout(function() { $(this).toggleClass("event_highlight"); });
530 /* edit an existing event */
531 var EditEvent = function(eObj
) {
532 //alert ('editing '+eObj.id);
533 // split the object ID into date and event ID
535 var parts
= new Array();
536 parts
= objID
.split("-");
537 // call the oldEvt function to bring up the event editor
538 oldEvt(parts
[0], parts
[1]);
542 /* pop up a window to print the current view
544 var PrintView = function (eventObject
) {
545 printURL
= "[-php-]echo pnModURL(__POSTCALENDAR__,'user','view',
546 array('tplview'=>$template_view,
547 'viewtype'=>$viewtype,
550 'pc_username'=>$pc_username,
551 'pc_category'=>$category,
552 'pc_topic'=>$topic));[-/php-]";
553 window
.open(printURL
,'printwindow','width=740,height=480,toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,copyhistory=no,resizable=yes');
557 /* change the current date based upon what the user clicked in
560 var ChangeDate = function(eObj
) {
561 baseURL
= "[-php-]echo pnModURL(__POSTCALENDAR__,'user','view',
562 array('tplview'=>$template_view,
563 'viewtype'=>$viewtype,
564 'Date'=> '~REPLACEME~',
565 'pc_username'=>$pc_username,
566 'pc_category'=>$category,
567 'pc_topic'=>$topic));[-/php-]";
568 newURL
= baseURL
.replace(/~REPLACEME~/, eObj
.id
);
569 document
.location
.href
=newURL
;
572 /* change the provider(s)
574 var ChangeProviders = function (eventObject
) {
575 $('#theform').submit();
578 /* change the calendar view
580 var ChangeView = function (eventObject
) {
581 if (eventObject
.id
== "dayview") {
582 $("#viewtype").val('day');
584 else if (eventObject
.id
== "weekview") {
585 $("#viewtype").val('week');
587 else if (eventObject
.id
== "monthview") {
588 $("#viewtype").val('month');
590 else if (eventObject
.id
== "yearview") {
591 $("#viewtype").val('year');
593 $('#theform').submit();