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
+ '&userid=' + providerid
+ '&starttimem=' + starttimem
+
37 '&date=' + eventdate
+ '&catid=' + catid
,
41 function oldEvt(eventdate
, eventid
, pccattype
) {
42 dlgopen('add_edit_event.php?date='+eventdate
+'&eid=' + eventid
+'&prov=' + pccattype
, '_blank', 575, 375);
48 if ($GLOBALS
['concurrent_layout'])
51 echo
" top.RTop.location = '../../patient_file/summary/demographics.php' " .
52 "+ '?set_pid=' + pid;\n";
56 echo
" top.location = '../../patient_file/patient_file.php' " .
57 "+ '?set_pid=' + pid + '&pid=' + pid;\n";
62 function GoToToday(theForm
){
63 var todays_date
= new Date();
64 var theMonth
= todays_date
.getMonth() + 1;
65 theMonth
= theMonth
< 10 ? "0" + theMonth
: theMonth
;
66 theForm
.jumpdate
.value
= todays_date
.getFullYear() + "-" + theMonth
+ "-" + todays_date
.getDate();
75 // this is my proposed setting in the globals config file so we don't
76 // need to mess with altering the pn database AND the config file
77 //pnModSetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek', $GLOBALS['schedule_dow_start']);
79 // build a day-of-week (DOW) list so we may properly build the calendars later in this code
81 $tmpDOW = pnModGetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek');
82 // bound check and auto-correction
83 if ($tmpDOW
<0 || $tmpDOW
>6) {
84 pnModSetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek', '
0');
87 while (count($DOWlist) <
7) {
88 array_push($DOWlist, $tmpDOW);
90 if ($tmpDOW
> 6) $tmpDOW =
0;
93 // A_CATEGORY is an ordered array of associative-array categories.
94 // Keys of interest are: id, name, color, desc, event_duration.
96 // echo
"<!-- A_CATEGORY = "; print_r($this-
>_tpl_vars['A_CATEGORY']); echo
" -->\n"; // debugging
97 // echo
"<!-- A_EVENTS = "; print_r($this-
>_tpl_vars['A_EVENTS']); echo
" -->\n"; // debugging
99 $A_CATEGORY =& $this-
>_tpl_vars['A_CATEGORY'];
101 // [-if $PRINT_VIEW !=
1-]
102 // [-*Main Navigation*-]
103 // [-include
file=
"$TPL_NAME/views/global/navigation.html"-]
106 $A_EVENTS =& $this-
>_tpl_vars['A_EVENTS'];
107 // $S_EVENTS =& $this-
>_tpl_vars['S_EVENTS']; // Deleted by Rod
108 $providers =& $this-
>_tpl_vars['providers'];
109 $times =& $this-
>_tpl_vars['times'];
110 $interval = $this-
>_tpl_vars['interval'];
111 $viewtype = $this-
>_tpl_vars['VIEW_TYPE'];
112 $PREV_WEEK_URL = $this-
>_tpl_vars['PREV_WEEK_URL'];
113 $NEXT_WEEK_URL = $this-
>_tpl_vars['NEXT_WEEK_URL'];
114 $PREV_DAY_URL = $this-
>_tpl_vars['PREV_DAY_URL'];
115 $NEXT_DAY_URL = $this-
>_tpl_vars['NEXT_DAY_URL'];
117 $Date = postcalendar_getDate();
118 if (!isset($y)) $y = substr($Date,
0,
4);
119 if (!isset($m)) $m = substr($Date,
4,
2);
120 if (!isset($d)) $d = substr($Date,
6,
2);
122 // echo
"<!-- There are " . count($A_EVENTS) .
" A_EVENTS days -->\n";
124 $MULTIDAY = count($A_EVENTS)
> 1;
126 //==================================
127 //FACILITY FILTERING (CHEMED)
128 $facilities = getUserFacilities($_SESSION['authId']); // from users_facility
129 if ( $_SESSION['pc_facility'] ) {
130 $provinfo = getProviderInfo('%', true, $_SESSION['pc_facility']);
132 $provinfo = getProviderInfo();
134 //EOS FACILITY FILTERING (CHEMED)
135 //==================================
138 <div id=
"topheader"> </div>
139 <div id=
"topToolbarRight"> <!-- this wraps some of the top toolbar items -->
141 <!-- stuff form element here to avoid the margin padding it introduces into the page in some browsers -->
142 <form name='theform' id='theform' action='index.php?module=PostCalendar&func=view&tplview=default&pc_category=&pc_topic=' method='post' onsubmit='return top.restoreSession()'
>
143 <input type=
"hidden" name=
"jumpdate" id=
"jumpdate" value=
"">
144 <input type=
"hidden" name=
"viewtype" id=
"viewtype" value=
"[-php-]echo $viewtype;[-/php-]">
146 echo
" <a href='#' value='" .xl (
"Add").
"' onclick='newEvt(1, 9, 00, $Date, 0, 0)' class='css_button'/><span>".xl(
"Add").
"</span></a>\n";
147 echo
" <a href='#' value='" . xl (
"Search") .
148 "' onclick='top.restoreSession();location=\"index.php?module=PostCalendar&func=search\
"' class='css_button'/><span>".xl(
"Search").
"</span></a>\n";
153 <div id=
"dateNAV" style=
"width:33%;">
154 <a href='#' name='bnsubmit' value='[-php-]echo xl (
"Today")[-/php-]' onClick='GoToToday(theform);' class='css_button'
/><span>[-php-] echo xl(
"Today")[-/php-]
</span></a>
155 <a href='[-php-]echo $PREV_DAY_URL[-/php-]' onclick='top.restoreSession()'
>
156 <img id=
"prevday" src=
"[-$TPL_IMAGE_PATH-]/leftbtn.gif" border=
"0" title=
"[-php-]echo xl("Previous Day
")[-/php-]" alt=
"[-php-]echo xl ("Previous Day
")[-/php-]" style=
"padding-top:5px"/></a>
157 <a href='[-php-]echo $NEXT_DAY_URL[-/php-]' onclick='top.restoreSession()'
>
158 <img id=
"nextday" src=
"[-$TPL_IMAGE_PATH-]/rightbtn.gif" border=
"0" title=
"[-php-]echo xl("Next Day
")[-/php-]" alt=
"[-php-]echo xl ("Next Day
")[-/php-]" /></a>
161 $atmp = array_keys($A_EVENTS);
162 echo dateformat (strtotime($atmp[
0]),true);
166 <div id=
"viewPicker">
168 echo
" <a href='#' type='button' id='printview' title='" .xl (
"Print View").
"' class='css_button'/><span>".xl(
"Print").
"</span></a>\n";
169 echo
" <a href='#' type='button' value='" .xl (
"Refresh").
"' onclick='javascript:refreshme()' class='css_button'/><span>".xl(
"Refresh").
"</span></a>\n";
170 echo
" <a href='#' type='button' id='dayview' title='" .htmlspecialchars( xl('Day View'), ENT_QUOTES).
"' class='css_button'/><span>".htmlspecialchars( xl('Day'), ENT_QUOTES).
"</span></a>\n";
171 echo
" <a href='#' type='button' id='weekview' title='" .htmlspecialchars( xl('Week View'), ENT_QUOTES).
"' class='css_button'/><span>".htmlspecialchars( xl('Week'), ENT_QUOTES).
"</span></a>\n";
172 echo
" <a href='#' type='button' id='monthview' title='" .htmlspecialchars( xl('Month View'), ENT_QUOTES).
"' class='css_button'/><span>".htmlspecialchars( xl('Month'), ENT_QUOTES).
"</span></a>\n";
175 </div> <!-- end topToolbarRight -->
177 <div id=
"bottomLeft">
178 <div id=
"datePicker">
180 <table border=
"0" cellpadding=
"0" cellspacing=
"0">
183 $atmp = array_keys($A_EVENTS);
184 $caldate = strtotime($atmp[
0]);
185 $cMonth = date(
"m", $caldate);
186 $cYear = date(
"Y", $caldate);
187 $cDay = date(
"d", $caldate);
189 // compute the previous month date
190 // stay on the same day if possible
192 $pMonth = $cMonth -
1;
194 if ($pMonth <
1) { $pMonth =
12; $pYear = $cYear -
1; }
195 while (! checkdate($pMonth, $pDay, $pYear)) { $pDay = $pDay -
1; }
196 $prevMonth = sprintf(
"%d%02d%02d",$pYear,$pMonth,$pDay);
198 // compute the next month
199 // stay on the same day if possible
201 $nMonth = $cMonth +
1;
203 if ($nMonth
> 12) { $nMonth =
1; $nYear = $cYear +
1; }
204 while (! checkdate($nMonth, $nDay, $nYear)) { $nDay = $nDay -
1; }
205 $nextMonth = sprintf(
"%d%02d%02d",$nYear,$nMonth,$nDay);
207 <td class=
"tdDOW-small tdDatePicker" id=
"[-php-]echo $prevMonth[-/php-]" title=
"[-php-]echo xl(date("F
", strtotime($prevMonth)));[-/php-]"><</td>
208 <td colspan=
"5" class=
"tdMonthName-small">
210 echo xl(date('F', $caldate));
213 <td class=
"tdDOW-small tdDatePicker" id=
"[-php-]echo $nextMonth[-/php-]" title=
"[-php-]echo xl(date("F
", strtotime($nextMonth)));[-/php-]">></td>
216 foreach ($DOWlist as $dow) {
217 echo
"<td class='tdDOW-small'>".$this-
>_tpl_vars['A_SHORT_DAY_NAMES'][$dow].
"</td>";
222 $atmp = array_keys($A_EVENTS);
223 $caldate = strtotime($atmp[
0]);
224 $caldateEnd = strtotime($atmp[
6]);
226 // to make a complete week row we need to compute the real
227 // start and end dates for the view
228 list ($year, $month, $day) = explode(
" ", date('Y m d', $caldate));
229 $startdate = strtotime($year.$month.
"01");
230 $enddate = strtotime($year.$month.date(
"t", $startdate).
" 23:59");
231 while (date('w', $startdate) != $DOWlist[
0]) { $startdate -=
60*
60*
24; }
232 while (date('w', $enddate) != $DOWlist[
6]) { $enddate +=
60*
60*
24; }
234 $currdate = $startdate;
235 while ($currdate <= $enddate) {
236 if (date('w', $currdate) == $DOWlist[
0]) {
243 $tdClass =
"tdMonthDay-small";
244 if (date('m', $currdate) != $month) {
245 $tdClass =
"tdOtherMonthDay-small";
247 if ((date('w', $currdate) ==
0) || (date('w', $currdate) ==
6)) {
248 $tdClass =
"tdWeekend-small";
251 if (date('Ymd',$currdate) == $Date) {
252 // $Date is defined near the top of this file
253 // and is equal to whatever date the user has clicked
254 $tdClass .=
" currentDate";
257 // add a class so that jQuery can grab these days for the 'click' event
258 $tdClass .=
" tdDatePicker";
262 $td .=
"class=\"".$tdClass."\
" ";
263 //$td .=
"id=\"".date("Ymd
", $currdate)."\
" ";
264 $td .=
"id=\"".date("Ymd
", $currdate)."\
" ";
265 $td .=
"title=\"" . xl('Go to') . " ".date('M d, Y', $currdate)."\
" ";
266 $td .=
"> ".date('d', $currdate).
"</td>\n";
270 if (date('w', $currdate) == $DOWlist[
6]) echo
"</tr>\n";
272 // time correction = plus
1000 seconds, for some unknown reason
273 $currdate += (
60*
60*
24)+
1000;
279 <div id=
"bigCalHeader">
282 <div id=
"providerPicker">
283 [-php-] xl('Providers','e'); [-/php-]
286 // ==============================
287 // FACILITY FILTERING (lemonsoftware)
288 /*********************************************************************
289 $facilities = getFacilities();
290 *********************************************************************/
291 if ($_SESSION['authorizeduser'] ==
1) {
292 $facilities = getFacilities();
294 $facilities = getUserFacilities($_SESSION['authId']); // from users_facility
295 if (count($facilities) ==
1)
296 $_SESSION['pc_facility'] = key($facilities);
298 /********************************************************************/
299 if (count($facilities)
> 1) {
300 echo
" <select name='pc_facility' id='pc_facility' class='view1' >\n";
301 if ( !$_SESSION['pc_facility'] ) $selected =
"selected='selected'";
302 // echo
" <option value='0' $selected>" .xl('All Facilities').
"</option>\n";
303 if (!$GLOBALS['restrict_user_facility']) echo
" <option value='0' $selected>" . xl('All Facilities') .
"</option>\n";
304 foreach ($facilities as $fa) {
305 $selected = ( $_SESSION['pc_facility'] == $fa['id']) ?
"selected='selected'" :
"" ;
306 echo
" <option style=background-color:".htmlspecialchars($fa['color'],ENT_QUOTES).
" value='" .htmlspecialchars($fa['id'],ENT_QUOTES).
"' $selected>" .htmlspecialchars($fa['name'],ENT_QUOTES).
"</option>\n";
311 // ==============================
313 echo
" <select multiple size='5' name='pc_username[]' id='pc_username' class='view2'>\n";
314 echo
" <option value='__PC_ALL__'>" .xl (
"All Users").
"</option>\n";
315 foreach ($provinfo as $doc) {
316 $username = $doc['username'];
317 echo
" <option value='$username'";
318 foreach ($providers as $provider)
319 if ($provider['username'] == $username) echo
" selected";
320 echo
">" . htmlspecialchars($doc['lname'],ENT_QUOTES) .
", " . htmlspecialchars($doc['fname'],ENT_QUOTES) .
"</option>\n";
327 if($_SESSION['pc_facility'] ==
0){
329 <div id=
"facilityColor">
332 foreach ($facilities as $f){
333 echo
" <tr><td><div class='view1' style=background-color:".$f['color'].
";font-weight:bold>".htmlspecialchars($f['name'],ENT_QUOTES).
"</div></td></tr>";
344 [-assign
var=
"dayname" value=$DATE|date_format:
"%w"-]
345 [-assign
var=
"day" value=$DATE|date_format:
"%d"|string_format:
"%1d"-]
346 [-assign
var=
"month" value=$DATE|date_format:
"%m"|string_format:
"%1d"-]
347 [-assign
var=
"year" value=$DATE|date_format:
"%Y"|string_format:
"%4d"-]
349 [-pc_sort_events
var=
"S_EVENTS" sort=
"time" order=
"asc" value=$A_EVENTS-]
350 </div> <!-- end bottomLeft -->
354 echo
"<table border='0' cellpadding='1' cellspacing='0' width='100%'>\n";
356 // output the TD with the times DIV
358 echo
"<td id='times'><div><table>\n";
359 echo
"<td class='timeslot'> </td>";
360 //============================================================================================================================
361 foreach ($times as $slottime) {
362 $startampm = ($slottime['mer']) ==
"pm" ?
2 :
1;
363 $starttimeh = $slottime['hour'];
364 $disptimeh = ($starttimeh
> 12) ? ($starttimeh -
12) : $starttimeh;
365 $starttimem = $slottime['minute'];
366 $slotendmins = $starttimeh *
60 + $starttimem + $interval;
368 // default to the first displayed provider
369 $providerid = $providers[
0]['id'];
371 echo
"<tr><td class='timeslot'>";
372 echo
"<a href='javascript:newEvt($startampm,$starttimeh,$starttimem,$Date,$providerid,0)' title='" . htmlspecialchars(xl(
"New Appointment"),ENT_QUOTES) .
"' alt='" .htmlspecialchars(xl(
"New Appointment"),ENT_QUOTES).
"'>";
373 echo
"$disptimeh:$starttimem";
377 echo
"</table></div></td>";
380 // This loops once for each provider to be displayed.
382 foreach ($providers as $provider) {
383 $providerid = $provider['id'];
385 // to specially handle the IN/OUT events I'm doing something new here
386 // for each IN event it will have a duration lasting until the next
387 // OUT event or until the end of the day
388 $tmpTime = $times[
0];
389 $calStartMin = ($tmpTime['hour'] *
60) + $tmpTime['minute'];
390 $tmpTime = $times[count($times)-
1];
391 $calEndMin = ($tmpTime['hour'] *
60) + $tmpTime['minute'];
393 // having a 'title' for the TD makes the date appear by the mouse pointer
394 // this is nice when all you see are times on the left side and no head
395 // row with the dates or day-of-week (DOW)
396 echo
"<td class='schedule' title='".htmlspecialchars($provider[
"fname"],ENT_QUOTES).
" ".htmlspecialchars($provider[
"lname"],ENT_QUOTES).
"'>";
397 echo
"<div class='providerheader'>";
398 echo htmlspecialchars($provider['fname'],ENT_QUOTES).
" ".htmlspecialchars($provider['lname'],ENT_QUOTES).
"</div>";
399 echo
"<div class='calendar_day'>";
402 // output a TD with an inner containing DIV positioned 'relative'
403 // within that DIV we place our event DIVs using 'absolute' positioning
404 foreach ($A_EVENTS as $date =
> $events) {
405 $eventdate = substr($date,
0,
4) . substr($date,
5,
2) . substr($date,
8,
2);
407 // determine if events overlap and adjust their width and left position as needed
408 //
26 Feb
2008 - This needs fine tuning or total replacement
409 // - it doesn't work as well as I'd like - JRM
410 $eventPositions = array();
411 foreach ($times as $slottime) {
412 $starttimeh = $slottime['hour'];
413 $starttimem = $slottime['minute'];
415 $slotstartmins = $starttimeh *
60 + $starttimem;
416 $slotendmins = $starttimeh *
60 + $starttimem + $interval;
418 $events_in_timeslot = array();
419 foreach ($events as $e1) {
420 // ignore IN and OUT events
421 if (($e1['catid'] ==
2) || ($e1['catid'] ==
3)) { continue; }
422 // skip events without an ID (why they are in the loop, I have no idea)
423 if ($e1['eid'] ==
"") { continue; }
424 // skip events for other providers
425 if ($providerid != $e1['aid']) { continue; }
427 // specially handle all-day events
428 if ($e1['alldayevent'] ==
1) {
429 $tmpTime = $times[
0];
430 if (strlen($tmpTime['hour']) <
2) { $tmpTime['hour'] =
"0".$tmpTime['hour']; }
431 if (strlen($tmpTime['minute']) <
2) { $tmpTime['minute'] =
"0".$tmpTime['minute']; }
432 $e1['startTime'] = $tmpTime['hour'].
":".$tmpTime['minute'].
":00";
433 $e1['duration'] = ($calEndMin - $calStartMin) *
60; // measured in seconds
436 // create a numeric start and end for comparison
437 $starth = substr($e1['startTime'],
0,
2);
438 $startm = substr($e1['startTime'],
3,
2);
439 $e1Start = ($starth *
60) + $startm;
440 $e1End = $e1Start + $e1['duration']/
60;
442 // three ways to overlap:
443 // start-in, end-in, span
444 if ((($e1Start
>= $slotstartmins) && ($e1Start < $slotendmins)) // start-in
445 || (($e1End
> $slotstartmins) && ($e1End <= $slotendmins)) // end-in
446 || (($e1Start < $slotstartmins) && ($e1End
> $slotendmins))) // span
448 array_push($events_in_timeslot, $e1['eid']);
452 $width =
100 / count($events_in_timeslot);
454 // loop over the events in this timeslot and adjust their width
455 foreach ($events_in_timeslot as $eid) {
456 // set the width if not already set or if the current width is smaller
457 // than was was previously set
458 if (! isset($eventPositions[$eid]-
>width)) { $eventPositions[$eid]-
>width = $width; }
459 else if ($eventPositions[$eid]-
>width
> $width) { $eventPositions[$eid]-
>width = $width; }
461 // set the left position if not already set or if the current left is
462 // greater than what was previously set
463 if (! isset($eventPositions[$eid]-
>leftpos)) { $eventPositions[$eid]-
>leftpos = $leftpos; }
464 else if ($eventPositions[$eid]-
>leftpos < $leftpos) { $eventPositions[$eid]-
>leftpos = $leftpos; }
466 // increment the leftpos by the width
469 } // end overlap detection
471 // now loop over the events for the day and output their DIVs
472 foreach ($events as $event) {
473 // skip events for other providers
474 // yeah, we've got that sort of overhead here... it ain't perfect
475 if ($providerid != $event['aid']) { continue; }
477 // skip events without an ID (why they are in the loop, I have no idea)
478 if ($event['eid'] ==
"") { continue; }
480 // specially handle all-day events
481 if ($event['alldayevent'] ==
1) {
482 $tmpTime = $times[
0];
483 if (strlen($tmpTime['hour']) <
2) { $tmpTime['hour'] =
"0".$tmpTime['hour']; }
484 if (strlen($tmpTime['minute']) <
2) { $tmpTime['minute'] =
"0".$tmpTime['minute']; }
485 $event['startTime'] = $tmpTime['hour'].
":".$tmpTime['minute'].
":00";
486 $event['duration'] = ($calEndMin - $calStartMin) *
60; // measured in seconds
489 // figure the start time and minutes (from midnight)
490 $starth = substr($event['startTime'],
0,
2);
491 $startm = substr($event['startTime'],
3,
2);
492 $eStartMin = $starth *
60 + $startm;
493 $dispstarth = ($starth
> 12) ? ($starth -
12) : $starth; // used to display the hour
495 // determine the class for the event DIV based on the event category
496 $evtClass =
"event_appointment";
497 switch ($event['catid']) {
498 case
1: // NO-SHOW appt
499 $evtClass =
"event_noshow";
502 $evtClass =
"event_in";
504 case
3: // OUT of office
505 $evtClass =
"event_out";
510 $evtClass =
"event_reserved";
512 default: // some appointment
513 $evtClass =
"event_appointment";
517 // if this is an IN or OUT event then we have some extra special
518 // processing to be done
519 // the IN event creates a DIV until the OUT event
520 // or, without an OUT DIV matching the IN event
521 // then the IN event runs until the end of the day
522 if ($event['catid'] ==
2) {
523 // locate a matching OUT for this specific IN
526 foreach ($events as $outevent) {
527 // skip events for other providers
528 if ($providerid != $outevent['aid']) { continue; }
529 // skip events with blank IDs
530 if ($outevent['eid'] ==
"") { continue; }
532 if ($outevent['eid'] == $event['eid']) { $found = true; continue; }
533 if (($found == true) && ($outevent['catid'] ==
3)) {
534 // calculate the duration from this event to the outevent
535 $outH = substr($outevent['startTime'],
0,
2);
536 $outM = substr($outevent['startTime'],
3,
2);
537 $outMins = ($outH *
60) + $outM;
538 $event['duration'] = ($outMins - $eStartMin) *
60; // duration is in seconds
544 // no OUT was found so this event's duration goes
545 // until the end of the day
546 $event['duration'] = ($calEndMin - $eStartMin) *
60; // duration is in seconds
550 // calculate the TOP value for the event DIV
551 // diff between event start and schedule start
552 $eMinDiff = $eStartMin - $calStartMin;
553 // diff divided by the time interval of the schedule
554 $eStartInterval = $eMinDiff / $interval;
555 // times the interval height
556 $eStartPos = $eStartInterval * $timeslotHeightVal;
557 $evtTop = $eStartPos.$timeslotHeightUnit;
559 // calculate the HEIGHT value for the event DIV
560 // diff between end and start of event
561 $eEndMin = $eStartMin + ($event['duration']/
60);
562 // prevent the overall height of the event from going beyond the bounds
564 if ($eEndMin
> $calEndMin) { $eEndMin = $calEndMin + $interval; }
565 $eMinDiff = $eEndMin - $eStartMin;
566 // diff divided by the time interval of the schedule
567 $eEndInterval = $eMinDiff / $interval;
568 // times the interval height
569 $eHeight = $eEndInterval * $timeslotHeightVal;
570 $evtHeight = $eHeight.$timeslotHeightUnit;
572 // determine the DIV width based on any overlapping events
573 // see further above for the overlapping calculation code
576 if (isset($eventPositions[$event['eid']])) {
577 $divWidth =
"width: ".$eventPositions[$event['eid']]-
>width.
"%";
578 $divLeft =
"left: ".$eventPositions[$event['eid']]-
>leftpos.
"%";
581 $eventid = $event['eid'];
582 $eventtype = sqlQuery(
"SELECT pc_cattype FROM openemr_postcalendar_categories as oc LEFT OUTER JOIN openemr_postcalendar_events as oe ON oe.pc_catid=oc.pc_catid WHERE oe.pc_eid='".$eventid.
"'");
584 if($eventtype['pc_cattype']==
1)
586 $patientid = $event['pid'];
587 $commapos = strpos($event['patient_name'],
",");
588 $lname = substr($event['patient_name'],
0, $commapos);
589 $fname = substr($event['patient_name'], $commapos +
2);
590 $patient_dob = $event['patient_dob'];
591 $patient_age = $event['patient_age'];
592 $catid = $event['catid'];
593 $comment = addslashes($event['hometext']);
594 $catname = $event['catname'];
595 $title =
"Age $patient_age ($patient_dob)";
599 if ($comment && $GLOBALS['calendar_appt_style'] <
4) $title .=
" " . $comment;
601 // the divTitle is what appears when the user hovers the mouse over the DIV
602 $divTitle = htmlspecialchars($provider[
"fname"],ENT_QUOTES).
" ".htmlspecialchars($provider[
"lname"],ENT_QUOTES);
603 $result = sqlStatement(
"SELECT name,id,color FROM facility WHERE id=(SELECT pc_facility FROM openemr_postcalendar_events WHERE pc_eid=".$eventid.
")");
604 $row = sqlFetchArray($result);
605 $color=$event[
"catcolor"];
606 if($GLOBALS['event_color']==
2)
607 $color=$row['color'];
608 $divTitle .=
"\n" .htmlspecialchars($row['name'],ENT_QUOTES);
610 if ($catid ==
2 || $catid ==
3 || $catid ==
4 || $catid ==
8 || $catid ==
11) {
611 if ($catid ==
2) $catname = xl(
"IN");
612 else if ($catid ==
3) $catname = xl(
"OUT");
613 else if ($catid ==
4) $catname = xl(
"VACATION");
614 else if ($catid ==
8) $catname = xl(
"LUNCH");
615 else if ($catid ==
11) $catname = xl(
"RESERVED");
618 if ($comment) $atitle .=
" $comment";
619 $divTitle .=
"\n[".$atitle .
"]";
620 $content .= $catname;
621 if ($event['recurrtype'] ==
1) $content .=
"<img src='$TPL_IMAGE_PATH/repeating8.png' border='0' style='margin:0px 2px 0px 2px;' title='".htmlspecialchars(xl(
"Repeating event"),ENT_QUOTES).
"' alt='".htmlspecialchars(xl(
"Repeating event"),ENT_QUOTES).
"'>";
622 if ($comment) $content .=
" $comment";
625 // some sort of patient appointment
626 $divTitle .=
"\r\n[".$catname.' '.htmlspecialchars($comment, ENT_QUOTES) .
"]".htmlspecialchars($fname, ENT_QUOTES).
" ".htmlspecialchars($lname, ENT_QUOTES);
627 $content .=
"<span class='appointment'>";
628 $content .= $dispstarth . ':' . $startm;
629 if ($event['recurrtype'] ==
1) $content .=
"<img src='$TPL_IMAGE_PATH/repeating8.png' border='0' style='margin:0px 2px 0px 2px;' title='".htmlspecialchars(xl(
"Repeating event"),ENT_QUOTES).
"' alt='".htmlspecialchars(xl(
"Repeating event"),ENT_QUOTES).
"'>";
630 // $content .= htmlspecialchars($event['apptstatus']);
631 $content .= '
'.htmlspecialchars($event['apptstatus']);
633 $link_title = htmlspecialchars($fname,ENT_QUOTES).
" ".htmlspecialchars($lname,ENT_QUOTES).
" \n";
634 $link_title .= xl('Age') .
": " . $patient_age .
" \n" . xl('DOB') .
": " . $patient_dob .
" \n";
635 $link_title .= xl('Age') .
": ".$patient_age.
"\n" . xl('DOB') .
": ".$patient_dob.htmlspecialchars($comment, ENT_QUOTES).
"\n";
636 $link_title .=
"(" . xl('Click to view') .
")";
637 $content .=
"<a href='javascript:goPid($patientid)' title='$link_title'>";
638 $content .=
"<img src='$TPL_IMAGE_PATH/user-green.gif' border='0' title='$link_title' alt='View Patient' />";
639 if ($catid ==
1) $content .=
"<strike>";
640 $content .= htmlspecialchars($lname);
641 if ($GLOBALS['calendar_appt_style'] !=
1) {
642 $content .=
"," . htmlspecialchars($fname);
643 if ($event['title'] && $GLOBALS['calendar_appt_style']
>=
3) {
644 $content .=
"(" . $event['title'];
645 if ($event['hometext'] && $GLOBALS['calendar_appt_style']
>=
4)
646 $content .=
": <font color='green'>" . htmlspecialchars(trim($event['hometext'])) .
"</font>";
650 if ($catid ==
1) $content .=
"</strike>";
654 // no patient id, just output the category name
655 $content .= $catname;
657 $content .=
"</span>";
660 $divTitle .=
"\n(" . xl('double click to edit') .
")";
662 if($_SESSION['pc_facility'] ==
0){
663 // a special case for the 'IN' event this puts the time ABOVE
664 // the normal DIV so it doesn't overlap another event DIV and include the time
665 if ($event['catid'] ==
2) {
666 $inTop = ($eStartPos - $timeslotHeightVal).$timeslotHeightUnit;
667 echo
"<div class='".$evtClass.
" event' style='top:".$inTop.
668 "; height:".$timeslotHeightVal.$timeslotHeightUnit.
671 "; background:transparent".
673 "' title='".$divTitle.
"'".
674 " id='".$eventdate.
"-".$eventid.
"-".$pccattype.
"'".
676 $content = $dispstarth . ':' . $startm .
" " . $content;
681 // output the DIV and content
682 echo
"<div class='".$evtClass.
" event' style='top:".$evtTop.
"; height:".$evtHeight.
683 "; background-color:".$color.
686 "' title='".$divTitle.
"'".
687 " id='".$eventdate.
"-".$eventid.
"-".$pccattype.
"'".
689 // second part for the special IN event
690 if ($event['catid'] !=
2) { echo $content; }
693 elseif($_SESSION['pc_facility'] == $row['id']){
694 if ($event['catid'] ==
2) {
695 $inTop = ($eStartPos - $timeslotHeightVal).$timeslotHeightUnit;
696 echo
"<div class='".$evtClass.
" event' style='top:".$inTop.
697 "; height:".$timeslotHeightVal.$timeslotHeightUnit.
700 "; background:transparent".
702 "' title='".$divTitle.
"'".
703 " id='".$eventdate.
"-".$eventid.
"-".$pccattype.
"'".
705 $content = $dispstarth . ':' . $startm .
" " . $content;
710 // output the DIV and content
711 echo
"<div class='".$evtClass.
" event' style='top:".$evtTop.
"; height:".$evtHeight.
712 "; background-color:".$event[
"catcolor"].
715 "' title='".$divTitle.
"'".
716 " id='".$eventdate.
"-".$eventid.
"-".$pccattype.
"'".
718 // second part for the special IN event
719 if ($event['catid'] !=
2) { echo $content; }
724 if ($event['catid'] ==
2) {
725 $inTop = ($eStartPos - $timeslotHeightVal).$timeslotHeightUnit;
726 echo
"<div class='".$evtClass.
" event' style='top:".$inTop.
727 "; height:".$timeslotHeightVal.$timeslotHeightUnit.
730 "; background:#DDDDDD".
732 "' title='".$divTitle.
"'".
733 " id='".$eventdate.
"-".$eventid.
"-".$pccattype.
"'".
735 $content =
"<span style='color:red;text-align:center;font-weight:bold'>".htmlspecialchars($row['name'],ENT_QUOTES).
"</span>";
740 // output the DIV and content
741 echo
"<div class='".$evtClass.
" event' style='top:".$evtTop.
"; height:".$evtHeight.
742 "; background-color:#DDDDDD".
745 "' title='".$divTitle.
"'".
746 " id='".$eventdate.
"-".$eventid.
"-".$pccattype.
"'".
748 // second part for the special IN event
749 if ($event['catid'] !=
2) { echo
"<span style='color:red;text-align:center;font-weight:bold'>".htmlspecialchars($row['name'],ENT_QUOTES).
"</span>"; }
760 } // end provider loop
761 //============================================================================================================================
767 // [-include
file=
"$TPL_NAME/views/global/footer.html"-]
768 // [-include
file=
"$TPL_NAME/views/footer.html"-]
771 </div> <!-- end bigCal DIV -->
775 <script language='JavaScript'
>
777 $(document
).ready(function(){
778 $("#pc_username").change(function() { ChangeProviders(this); });
779 $("#pc_facility").change(function() { ChangeProviders(this); });
780 //$("#dayview").click(function() { ChangeView(this); });
781 $("#weekview").click(function() { ChangeView(this); });
782 $("#monthview").click(function() { ChangeView(this); });
783 //$("#yearview").click(function() { ChangeView(this); });
784 $(".tdDatePicker").click(function() { ChangeDate(this); });
785 $(".tdDatePicker").mouseover(function() { $(this).toggleClass("tdDatePickerHighlight"); });
786 $(".tdDatePicker").mouseout(function() { $(this).toggleClass("tdDatePickerHighlight"); });
787 $("#printview").click(function() { PrintView(this); });
788 $(".event").dblclick(function() { EditEvent(this); });
789 $(".event").mouseover(function() { $(this).toggleClass("event_highlight"); });
790 $(".event").mouseout(function() { $(this).toggleClass("event_highlight"); });
793 /* edit an existing event */
794 var EditEvent = function(eObj
) {
795 //alert ('editing '+eObj.id);
796 // split the object ID into date and event ID
798 var parts
= new Array();
799 parts
= objID
.split("-");
800 // call the oldEvt function to bring up the event editor
801 oldEvt(parts
[0], parts
[1], parts
[2]);
805 /* change the current date based upon what the user clicked in
808 var ChangeDate = function(eObj
) {
809 baseURL
= "[-php-]echo pnModURL(__POSTCALENDAR__,'user','view',
810 array('tplview'=>$template_view,
811 'viewtype'=>$viewtype,
812 'Date'=> '~REPLACEME~',
813 'pc_username'=>$pc_username,
814 'pc_category'=>$category,
815 'pc_topic'=>$topic));[-/php-]";
816 newURL
= baseURL
.replace(/~REPLACEME~/, eObj
.id
);
817 document
.location
.href
=newURL
;
820 /* pop up a window to print the current view
822 var PrintView = function (eventObject
) {
823 printURL
= "[-php-]echo pnModURL(__POSTCALENDAR__,'user','view',
824 array('tplview'=>$template_view,
825 'viewtype'=>$viewtype,
828 'pc_username'=>$pc_username,
829 'pc_category'=>$category,
830 'pc_topic'=>$topic));[-/php-]";
831 window
.open(printURL
,'printwindow','width=740,height=480,toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,copyhistory=no,resizable=yes');
835 /* change the provider(s)
837 var ChangeProviders = function (eventObject
) {
838 $('#theform').submit();
841 /* change the calendar view
843 var ChangeView = function (eventObject
) {
844 if (eventObject
.id
== "dayview") {
845 $("#viewtype").val('day');
847 else if (eventObject
.id
== "weekview") {
848 $("#viewtype").val('week');
850 else if (eventObject
.id
== "monthview") {
851 $("#viewtype").val('month');
853 else if (eventObject
.id
== "yearview") {
854 $("#viewtype").val('year');
856 $('#theform').submit();