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
, 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";
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 ( $_SESSION['pc_facility'] ) {
126 $provinfo = getProviderInfo('%', true, $_SESSION['pc_facility']);
128 $provinfo = getProviderInfo();
130 //EOS FACILITY FILTERING (CHEMED)
131 //==================================
134 <div id=
"topheader"> </div>
135 <div id=
"topToolbarRight"> <!-- this wraps some of the top toolbar items -->
137 <!-- stuff form element here to avoid the margin padding it introduces into the page in some browsers -->
138 <form name='theform' id='theform' action='index.php?module=PostCalendar&func=view&tplview=default&pc_category=&pc_topic=' method='post' onsubmit='return top.restoreSession()'
>
139 <input type=
"hidden" name=
"jumpdate" id=
"jumpdate" value=
"">
140 <input type=
"hidden" name=
"viewtype" id=
"viewtype" value=
"[-php-]echo $viewtype;[-/php-]">
142 echo
" <a href='#' value='" .xl (
"Add").
"' onclick='newEvt(1, 9, 00, $Date, 0, 0)' class='css_button'/><span>".xl(
"Add").
"</span></a>\n";
143 echo
" <a href='#' value='" . xl (
"Search") .
144 "' onclick='top.restoreSession();location=\"index.php?module=PostCalendar&func=search\
"' class='css_button'/><span>".xl(
"Search").
"</span></a>\n";
149 <div id=
"dateNAV" style=
"width:34%">
150 <a href='#' name='bnsubmit' value='[-php-]echo xl (
"Today")[-/php-]' onClick='GoToToday(theform);' class='css_button'
/><span>[-php-] echo xl(
"Today")[-/php-]
</span></a>
151 <a href='[-php-]echo $PREV_WEEK_URL[-/php-]' onclick='top.restoreSession()'
>
152 <img id=
"prevweek" src=
"[-$TPL_IMAGE_PATH-]/leftbtn.gif" border=
"0" title=
"[-php-]echo xl("Previous Week
")[-/php-]" alt=
"[-php-]echo xl ("Previous Week
")[-/php-]" style=
"padding-top:5px"/></a>
153 <a href='[-php-]echo $NEXT_WEEK_URL[-/php-]' onclick='top.restoreSession()'
>
154 <img id=
"nextweek" src=
"[-$TPL_IMAGE_PATH-]/rightbtn.gif" border=
"0" title=
"[-php-]echo xl("Next Week
")[-/php-]" alt=
"[-php-]echo xl ("Next Week
")[-/php-]" /></a>
157 $atmp = array_keys($A_EVENTS);
158 echo date('d M Y', strtotime($atmp[
0]));
160 echo date('d M Y', strtotime($atmp[count($atmp)-
1]));
164 <div id=
"viewPicker">
166 echo
" <a href='#' type='button' id='printview' title='" .xl (
"Print View").
"' class='css_button'/><span>".xl(
"Print").
"</span></a>\n";
167 echo
" <a href='#' type='button' value='" .xl (
"Refresh").
"' onclick='javascript:refreshme()' class='css_button'/><span>".xl(
"Refresh").
"</span></a>\n";
168 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";
169 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";
170 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";
173 </div> <!-- end topToolbarRight -->
174 <div id=
"bottomLeft">
175 <div id=
"datePicker">
177 <table border=
"0" cellpadding=
"0" cellspacing=
"0">
180 $atmp = array_keys($A_EVENTS);
181 $caldate = strtotime($atmp[
0]);
182 $cMonth = date(
"m", $caldate);
183 $cYear = date(
"Y", $caldate);
184 $cDay = date(
"d", $caldate);
186 // compute the previous month date
187 // stay on the same day if possible
189 $pMonth = $cMonth -
1;
191 if ($pMonth <
1) { $pMonth =
12; $pYear = $cYear -
1; }
192 while (! checkdate($pMonth, $pDay, $pYear)) { $pDay = $pDay -
1; }
193 $prevMonth = sprintf(
"%d%02d%02d",$pYear,$pMonth,$pDay);
195 // compute the next month
196 // stay on the same day if possible
198 $nMonth = $cMonth +
1;
200 if ($nMonth
> 12) { $nMonth =
1; $nYear = $cYear +
1; }
201 while (! checkdate($nMonth, $nDay, $nYear)) { $nDay = $nDay -
1; }
202 $nextMonth = sprintf(
"%d%02d%02d",$nYear,$nMonth,$nDay);
204 <td class=
"tdDOW-small tdDatePicker tdNav" id=
"[-php-]echo $prevMonth[-/php-]" title=
"[-php-]echo xl(date("F
", strtotime($prevMonth)));[-/php-]"><</td>
205 <td colspan=
"5" class=
"tdMonthName-small">
207 echo xl(date('F', $caldate));
210 <td class=
"tdDOW-small tdDatePicker tdNav" id=
"[-php-]echo $nextMonth[-/php-]" title=
"[-php-]echo xl(date("F
", strtotime($nextMonth)));[-/php-]">></td>
213 foreach ($DOWlist as $dow) {
214 echo
"<td class='tdDOW-small'>".$this-
>_tpl_vars['A_SHORT_DAY_NAMES'][$dow].
"</td>";
219 $atmp = array_keys($A_EVENTS);
220 $caldate = strtotime($atmp[
0]);
221 $caldateEnd = strtotime($atmp[
6]);
223 // to make a complete week row we need to compute the real
224 // start and end dates for the view
225 list ($year, $month, $day) = explode(
" ", date('Y m d', $caldate));
226 $startdate = strtotime($year.$month.
"01");
227 $enddate = strtotime($year.$month.date(
"t", $startdate).
" 23:59");
228 while (date('w', $startdate) != $DOWlist[
0]) { $startdate -=
60*
60*
24; }
229 while (date('w', $enddate) != $DOWlist[
6]) { $enddate +=
60*
60*
24; }
231 $currdate = $startdate;
232 while ($currdate <= $enddate) {
233 if (date('w', $currdate) == $DOWlist[
0]) {
235 $tr =
"<tr class='trDateRow'>";
240 $tdClass =
"tdMonthDay-small";
241 if (date('m', $currdate) != $month) {
242 $tdClass =
"tdOtherMonthDay-small";
244 if ((date('w', $currdate) ==
0) || (date('w', $currdate) ==
6)) {
245 $tdClass =
"tdWeekend-small";
248 if ((date('Ymd',$currdate)
>= date('Ymd', $caldate)) &&
249 (date('Ymd',$currdate) <= date('Ymd', $caldateEnd)))
251 // add a class that highlights the 'current date'
252 $tdClass .=
" currentWeek";
255 if (date('Ymd',$currdate) == $Date) {
256 // $Date is defined near the top of this file
257 // and is equal to whatever date the user has clicked
258 $tdClass .=
" currentDate";
261 // add a class so that jQuery can grab these days for the 'click' event
262 $tdClass .=
" tdDatePicker";
266 $td .=
"class=\"".$tdClass."\
" ";
267 //$td .=
"id=\"".date("Ymd
", $currdate)."\
" ";
268 $td .=
"id=\"".date("Ymd
", $currdate)."\
" ";
269 $td .=
"title=\"" . xl('Go to week of') . " ".date('M d, Y', $currdate)."\
" ";
270 $td .=
"> ".date('d', $currdate).
"</td>\n";
274 if (date('w', $currdate) == $DOWlist[
6]) echo
"</tr>\n";
276 // time correction = plus
1000 seconds, for some unknown reason
277 $currdate += (
60*
60*
24)+
1000;
283 <div id=
"bigCalHeader">
286 <div id=
"providerPicker">
287 [-php-] xl('Providers','e'); [-/php-]
290 // ==============================
291 // FACILITY FILTERING (lemonsoftware)
292 // $facilities = getFacilities();
293 if ($_SESSION['authorizeduser'] ==
1) {
294 $facilities = getFacilities();
296 $facilities = getUserFacilities($_SESSION['authId']); // from users_facility
297 if (count($facilities) ==
1)
298 $_SESSION['pc_facility'] = key($facilities);
300 if (count($facilities)
> 1) {
301 echo
" <select name='pc_facility' id='pc_facility' class='view1' >\n";
302 if ( !$_SESSION['pc_facility'] ) $selected =
"selected='selected'";
303 // echo
" <option value='0' $selected>" .xl('All Facilities').
"</option>\n";
304 if (!$GLOBALS['restrict_user_facility']) echo
" <option value='0' $selected>" . xl('All Facilities') .
"</option>\n";
305 foreach ($facilities as $fa) {
306 $selected = ( $_SESSION['pc_facility'] == $fa['id']) ?
"selected='selected'" :
"" ;
307 echo
" <option style=background-color:".htmlspecialchars($fa['color'],ENT_QUOTES).
" value='" .htmlspecialchars($fa['id'],ENT_QUOTES).
"' $selected>" .htmlspecialchars($fa['name'],ENT_QUOTES).
"</option>\n";
312 // ==============================
314 echo
" <select multiple size='5' name='pc_username[]' id='pc_username' class='view2'>\n";
315 echo
" <option value='__PC_ALL__'>" .xl (
"All Users").
"</option>\n";
316 foreach ($provinfo as $doc) {
317 $username = $doc['username'];
318 echo
" <option value='$username'";
319 foreach ($providers as $provider)
320 if ($provider['username'] == $username) echo
" selected";
321 echo
">" . htmlspecialchars($doc['lname'],ENT_QUOTES) .
", " . htmlspecialchars($doc['fname'],ENT_QUOTES) .
"</option>\n";
328 if($_SESSION['pc_facility'] ==
0){
330 <div id=
"facilityColor">
333 foreach ($facilities as $f){
334 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 </div> <!-- end bottomLeft -->
353 foreach ($A_EVENTS as $date =
> $events) {
355 foreach ($events as $oneE) {
359 echo
"<hr width=100%>";
364 // This loops once for each provider to be displayed.
366 foreach ($providers as $provider) {
367 $providerid = $provider['id'];
369 // to specially handle the IN/OUT events I'm doing something new here
370 // for each IN event it will have a duration lasting until the next
371 // OUT event or until the end of the day
372 $tmpTime = $times[
0];
373 $calStartMin = ($tmpTime['hour'] *
60) + $tmpTime['minute'];
374 $tmpTime = $times[count($times)-
1];
375 $calEndMin = ($tmpTime['hour'] *
60) + $tmpTime['minute'];
377 echo
"<table border='0' cellpadding='1' cellspacing='0' width='100%'>\n";
379 echo
" <td colspan='8' class='providerheader'>";
380 echo htmlspecialchars($provider['fname'],ENT_QUOTES) .
" " . htmlspecialchars($provider['lname'],ENT_QUOTES);
384 // output column (date) headers
385 $colWidth =
100/
7; // intentionally '
7' and not '
8'
387 echo
" <td> </td>"; // blank TD for the header above the Times column
388 $defaultDate =
""; // used when creating link for a 'new' event
389 $in_cat_id =
0; // used when creating link for a 'new' event
390 foreach ($A_EVENTS as $date =
> $events) {
391 $dateFmt = date(
"Ymd", strtotime($date));
392 $gotoURL = pnModURL(__POSTCALENDAR__,'user','view',
393 array('tplview'=
>$template_view,
396 'pc_username'=
>$pc_username,
397 'pc_category'=
>$category,
398 'pc_topic'=
>$topic));
399 if ($defaultDate ==
"") $defaultDate = $dateFmt;
401 if ($Date == $dateFmt) { $currclass=
"week_currday"; }
402 echo
"<td align='center' class='week_dateheader $currclass' style='width:".$colWidth.
"%;' >";
403 echo
"<a href='$gotoURL'>";
404 echo xl(date(
"D", strtotime($date))) .
" " . date(
"m/d", strtotime($date));
409 // output the TD with the times DIV
411 echo
"<td id='times'><div><table>\n";
412 //==================================================================================================================
413 foreach ($times as $slottime) {
414 $startampm = ($slottime['mer']) ==
"pm" ?
2 :
1;
415 $starttimeh = $slottime['hour'];
416 $disptimeh = ($starttimeh
> 12) ? ($starttimeh -
12) : $starttimeh;
417 $starttimem = $slottime['minute'];
418 $slotendmins = $starttimeh *
60 + $starttimem + $interval;
420 echo
"<tr><td class='timeslot'>";
421 // echo
"<a href='javascript:newEvt($startampm,$starttimeh,$starttimem,$Date,$providerid,$in_cat_id)' title='New Appointment' alt='New Appointment'>";
422 echo
"<a href='javascript:newEvt($startampm,$starttimeh,$starttimem,$defaultDate,$providerid,$in_cat_id)' title='" . htmlspecialchars(xl(
"New Appointment"),ENT_QUOTES) .
"' alt='".htmlspecialchars(xl(
"New Appointment"),ENT_QUOTES).
"'>";
424 //echo $slottime['hour'] *
60 + $slottime['minute'];
425 echo
"$disptimeh:$starttimem</a>";
428 echo
"</table></div></td>";
431 // output a TD with an inner containing DIV positioned 'relative'
432 // within that DIV we place our event DIVs using 'absolute' positioning
433 foreach ($A_EVENTS as $date =
> $events) {
434 $eventdate = substr($date,
0,
4) . substr($date,
5,
2) . substr($date,
8,
2);
436 // having a 'title' for the TD makes the date appear by the mouse pointer
437 // this is nice when all you see are times on the left side and no head
438 // row with the dates or day-of-week (DOW)
439 echo
"<td class='schedule' title='".date(
"l, d M Y", strtotime($date)).
"'>";
440 echo
"<div class='calendar_day'>";
442 // determine if events overlap and adjust their width and left position as needed
443 //
26 Feb
2008 - This needs fine tuning or total replacement
444 // - it doesn't work as well as I'd like - JRM
445 $eventPositions = array();
446 foreach ($times as $slottime) {
447 $starttimeh = $slottime['hour'];
448 $starttimem = $slottime['minute'];
450 $slotstartmins = $starttimeh *
60 + $starttimem;
451 $slotendmins = $starttimeh *
60 + $starttimem + $interval;
453 $events_in_timeslot = array();
454 foreach ($events as $e1) {
455 // ignore IN and OUT events
456 if (($e1['catid'] ==
2) || ($e1['catid'] ==
3)) { continue; }
457 // skip events without an ID (why they are in the loop, I have no idea)
458 if ($e1['eid'] ==
"") { continue; }
459 // skip events for other providers
460 if ($providerid != $e1['aid']) { continue; }
462 // specially handle all-day events
463 if ($e1['alldayevent'] ==
1) {
464 $tmpTime = $times[
0];
465 if (strlen($tmpTime['hour']) <
2) { $tmpTime['hour'] =
"0".$tmpTime['hour']; }
466 if (strlen($tmpTime['minute']) <
2) { $tmpTime['minute'] =
"0".$tmpTime['minute']; }
467 $e1['startTime'] = $tmpTime['hour'].
":".$tmpTime['minute'].
":00";
468 $e1['duration'] = ($calEndMin - $calStartMin) *
60; // measured in seconds
471 // create a numeric start and end for comparison
472 $starth = substr($e1['startTime'],
0,
2);
473 $startm = substr($e1['startTime'],
3,
2);
474 $e1Start = ($starth *
60) + $startm;
475 $e1End = $e1Start + $e1['duration']/
60;
477 // three ways to overlap:
478 // start-in, end-in, span
479 if ((($e1Start
>= $slotstartmins) && ($e1Start < $slotendmins)) // start-in
480 || (($e1End
> $slotstartmins) && ($e1End <= $slotendmins)) // end-in
481 || (($e1Start < $slotstartmins) && ($e1End
> $slotendmins))) // span
483 array_push($events_in_timeslot, $e1['eid']);
488 $width =
100 / count($events_in_timeslot);
490 // loop over the events in this timeslot and adjust their width
491 foreach ($events_in_timeslot as $eid) {
492 // set the width if not already set or if the current width is smaller
493 // than was was previously set
494 if (! isset($eventPositions[$eid]-
>width)) { $eventPositions[$eid]-
>width = $width; }
495 else if ($eventPositions[$eid]-
>width
> $width) { $eventPositions[$eid]-
>width = $width; }
497 // set the left position if not already set or if the current left is
498 // greater than what was previously set
499 if (! isset($eventPositions[$eid]-
>leftpos)) { $eventPositions[$eid]-
>leftpos = $leftpos; }
500 else if ($eventPositions[$eid]-
>leftpos < $leftpos) { $eventPositions[$eid]-
>leftpos = $leftpos; }
502 // increment the leftpos by the width
505 } // end overlap detection
507 // now loop over the events for the day and output their DIVs
508 foreach ($events as $event) {
509 // skip events for other providers
510 // yeah, we've got that sort of overhead here... it ain't perfect
511 if ($providerid != $event['aid']) { continue; }
513 // skip events without an ID (why they are in the loop, I have no idea)
514 if ($event['eid'] ==
"") { continue; }
516 // specially handle all-day events
517 if ($event['alldayevent'] ==
1) {
518 $tmpTime = $times[
0];
519 if (strlen($tmpTime['hour']) <
2) { $tmpTime['hour'] =
"0".$tmpTime['hour']; }
520 if (strlen($tmpTime['minute']) <
2) { $tmpTime['minute'] =
"0".$tmpTime['minute']; }
521 $event['startTime'] = $tmpTime['hour'].
":".$tmpTime['minute'].
":00";
522 $event['duration'] = ($calEndMin - $calStartMin) *
60; // measured in seconds
525 // figure the start time and minutes (from midnight)
526 $starth = substr($event['startTime'],
0,
2);
527 $startm = substr($event['startTime'],
3,
2);
528 $eStartMin = $starth *
60 + $startm;
529 $dispstarth = ($starth
> 12) ? ($starth -
12) : $starth;
531 // determine the class for the event DIV based on the event category
532 $evtClass =
"event_appointment";
533 switch ($event['catid']) {
534 case
1: // NO-SHOW appt
535 $evtClass =
"event_noshow";
538 $evtClass =
"event_in";
540 case
3: // OUT of office
541 $evtClass =
"event_out";
546 $evtClass =
"event_reserved";
548 default: // some appointment
549 $evtClass =
"event_appointment";
553 // if this is an IN or OUT event then we have some extra special
554 // processing to be done
555 // the IN event creates a DIV until the OUT event
556 // or, without an OUT DIV matching the IN event
557 // then the IN event runs until the end of the day
558 if ($event['catid'] ==
2) {
559 // locate a matching OUT for this specific IN
562 foreach ($events as $outevent) {
563 // skip events for other providers
564 if ($providerid != $outevent['aid']) { continue; }
565 // skip events with blank IDs
566 if ($outevent['eid'] ==
"") { continue; }
568 if ($outevent['eid'] == $event['eid']) { $found = true; continue; }
569 if (($found == true) && ($outevent['catid'] ==
3)) {
570 // calculate the duration from this event to the outevent
571 $outH = substr($outevent['startTime'],
0,
2);
572 $outM = substr($outevent['startTime'],
3,
2);
573 $outMins = ($outH *
60) + $outM;
574 $event['duration'] = ($outMins - $eStartMin) *
60; // duration is in seconds
580 // no OUT was found so this event's duration goes
581 // until the end of the day
582 $event['duration'] = ($calEndMin - $eStartMin) *
60; // duration is in seconds
586 // calculate the TOP value for the event DIV
587 // diff between event start and schedule start
588 $eMinDiff = $eStartMin - $calStartMin;
589 // diff divided by the time interval of the schedule
590 $eStartInterval = $eMinDiff / $interval;
591 // times the interval height
592 $eStartPos = $eStartInterval * $timeslotHeightVal;
593 $evtTop = $eStartPos.$timeslotHeightUnit;
595 // calculate the HEIGHT value for the event DIV
596 // diff between end and start of event
597 $eEndMin = $eStartMin + ($event['duration']/
60);
598 // prevent the overall height of the event from going beyond the bounds
600 if ($eEndMin
> $calEndMin) { $eEndMin = $calEndMin + $interval; }
601 $eMinDiff = $eEndMin - $eStartMin;
602 // diff divided by the time interval of the schedule
603 $eEndInterval = $eMinDiff / $interval;
604 // times the interval height
605 $eHeight = $eEndInterval * $timeslotHeightVal;
606 $evtHeight = $eHeight.$timeslotHeightUnit;
608 // determine the DIV width based on any overlapping events
609 // see further above for the overlapping calculation code
612 if (isset($eventPositions[$event['eid']])) {
613 $divWidth =
"width: ".$eventPositions[$event['eid']]-
>width.
"%";
614 $divLeft =
"left: ".$eventPositions[$event['eid']]-
>leftpos.
"%";
617 $eventid = $event['eid'];
618 $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.
"'");
620 if($eventtype['pc_cattype']==
1)
622 $patientid = $event['pid'];
623 $commapos = strpos($event['patient_name'],
",");
624 $lname = substr($event['patient_name'],
0, $commapos);
625 $fname = substr($event['patient_name'], $commapos +
2);
626 $patient_dob = $event['patient_dob'];
627 $patient_age = $event['patient_age'];
628 $catid = $event['catid'];
629 $comment = addslashes($event['hometext']);
630 $catname = $event['catname'];
631 $title =
"Age $patient_age ($patient_dob)";
635 if ($comment && $GLOBALS['calendar_appt_style'] <
4) $title .=
" " . $comment;
637 // the divTitle is what appears when the user hovers the mouse over the DIV
638 $divTitle = date(
"D, d M Y", strtotime($date));
639 $result = sqlStatement(
"SELECT name,id,color FROM facility WHERE id=(SELECT pc_facility FROM openemr_postcalendar_events WHERE pc_eid=".$eventid.
")");
640 $row = sqlFetchArray($result);
641 $color=$event[
"catcolor"];
642 if($GLOBALS['event_color']==
2)
643 $color=$row['color'];
644 $divTitle .=
"\n" .htmlspecialchars($row['name'],ENT_QUOTES);
645 if ($catid ==
2 || $catid ==
3 || $catid ==
4 || $catid ==
8 || $catid ==
11) {
646 if ($catid ==
2) $catname = xl(
"IN");
647 else if ($catid ==
3) $catname = xl(
"OUT");
648 else if ($catid ==
4) $catname = xl(
"VACATION");
649 else if ($catid ==
8) $catname = xl(
"LUNCH");
650 else if ($catid ==
11) $catname = xl(
"RESERVED");
653 if ($comment) $atitle .=
" $comment";
654 //$divTitle .=
"\n[".$atitle .
"] ".$divTitle;
655 $divTitle .=
"\n[".$atitle .
"]";
656 //$content .=
"<a href='javascript:oldEvt($eventdate,$eventid)' title='$atitle'>";
657 $content .= $catname;
658 if ($event['recurrtype'] ==
1) $content .=
"<img src='$TPL_IMAGE_PATH/repeating8.png' border='0' style='margin:0px 2px 0px 2px;' title='Repeating event' alt='Repeating event'>";
659 if ($comment) $content .=
" $comment";
660 //$content .=
"</a>";
663 // some sort of patient appointment
664 $divTitle .=
"\r\n[".$catname.' '.htmlspecialchars($comment, ENT_QUOTES) .
"] ".htmlspecialchars($fname,ENT_QUOTES).
" ".htmlspecialchars($lname,ENT_QUOTES);
665 $content .=
"<span class='appointment".$apptToggle.
"'>";
666 $content .= $dispstarth . ':' . $startm;
667 if ($event['recurrtype'] ==
1) $content .=
"<img src='$TPL_IMAGE_PATH/repeating8.png' border='0' style='margin:0px 2px 0px 2px;' title='Repeating event' alt='Repeating event'>";
668 $content .= htmlspecialchars($event['apptstatus']);
670 // include patient name and link to their details
671 $link_title = htmlspecialchars($fname,ENT_QUOTES).
" ".htmlspecialchars($lname,ENT_QUOTES).
" \n";
672 $link_title .= xl('Age') .
": ".$patient_age.
"\n" . xl('DOB') .
": ".$patient_dob.htmlspecialchars($comment, ENT_QUOTES).
"\n";
673 $link_title .=
"(" . xl('Click to view') .
")";
674 $content .=
"<a href='javascript:goPid($patientid)' title='$link_title'>";
675 $content .=
"<img src='$TPL_IMAGE_PATH/user-green.gif' border='0' title='$link_title' alt='View Patient' />";
679 // no patient id, just output the category name
680 $content .= $catname;
682 $content .=
"</span>";
685 $divTitle .=
"\n(" . xl('double click to edit') .
")";
687 // output the DIV and content
688 if($_SESSION['pc_facility'] ==
0){
689 // output the DIV and content
690 echo
"<div class='".$evtClass.
" event' style='top:".$evtTop.
"; height:".$evtHeight.
691 "; background-color:".$color.
694 "' title='".$divTitle.
"'".
695 " id='".$eventdate.
"-".$eventid.
"-".$pccattype.
"'".
700 elseif($_SESSION['pc_facility'] == $row['id']){
701 echo
"<div class='".$evtClass.
" event' style='top:".$evtTop.
"; height:".$evtHeight.
702 "; background-color:".$event[
"catcolor"].
705 "' title='".$divTitle.
"'".
706 " id='".$eventdate.
"-".$eventid.
"-".$pccattype.
"'".
712 echo
"<div class='".$evtClass.
" event' style='top:".$evtTop.
"; height:".$evtHeight.
713 "; background-color:#DDDDDD".
716 "' title='".$divTitle.
"'".
717 " id='".$eventdate.
"-".$eventid.
"-".$pccattype.
"'".
719 echo
"<span style='color:red;text-align:center;font-weight:bold'>".htmlspecialchars($row['name'],ENT_QUOTES).
"</span>";
728 //==================================================================================================================
736 // [-include
file=
"$TPL_NAME/views/global/footer.html"-]
737 // [-include
file=
"$TPL_NAME/views/footer.html"-]
740 </div> <!-- end bigCal DIV -->
744 <script language='JavaScript'
>
746 $(document
).ready(function(){
747 $("#pc_username").change(function() { ChangeProviders(this); });
748 $("#pc_facility").change(function() { ChangeProviders(this); });
749 $("#dayview").click(function() { ChangeView(this); });
750 //$("#weekview").click(function() { ChangeView(this); });
751 $("#monthview").click(function() { ChangeView(this); });
752 //$("#yearview").click(function() { ChangeView(this); });
753 $(".tdDatePicker").click(function() { ChangeDate(this); });
754 $("#datePicker .trDateRow").mouseover(function() { $(this).children().toggleClass("tdDatePickerHighlight"); });
755 $("#datePicker .trDateRow").mouseout(function() { $(this).children().toggleClass("tdDatePickerHighlight"); });
756 $("#datePicker .tdNav").mouseover(function() { $(this).toggleClass("tdDatePickerHighlight"); });
757 $("#datePicker .tdNav").mouseout(function() { $(this).toggleClass("tdDatePickerHighlight"); });
758 $("#printview").click(function() { PrintView(this); });
759 $(".event").dblclick(function() { EditEvent(this); });
760 $(".event").mouseover(function() { $(this).toggleClass("event_highlight"); });
761 $(".event").mouseout(function() { $(this).toggleClass("event_highlight"); });
764 /* edit an existing event */
765 var EditEvent = function(eObj
) {
766 //alert ('editing '+eObj.id);
767 // split the object ID into date and event ID
769 var parts
= new Array();
770 parts
= objID
.split("-");
771 // call the oldEvt function to bring up the event editor
772 oldEvt(parts
[0], parts
[1], parts
[2]);
776 /* change the current date based upon what the user clicked in
779 var ChangeDate = function(eObj
) {
780 baseURL
= "[-php-]echo pnModURL(__POSTCALENDAR__,'user','view',
781 array('tplview'=>$template_view,
782 'viewtype'=>$viewtype,
783 'Date'=> '~REPLACEME~',
784 'pc_username'=>$pc_username,
785 'pc_category'=>$category,
786 'pc_topic'=>$topic));[-/php-]";
787 newURL
= baseURL
.replace(/~REPLACEME~/, eObj
.id
);
788 document
.location
.href
=newURL
;
791 /* pop up a window to print the current view
793 var PrintView = function (eventObject
) {
794 printURL
= "[-php-]echo pnModURL(__POSTCALENDAR__,'user','view',
795 array('tplview'=>$template_view,
796 'viewtype'=>$viewtype,
799 'pc_username'=>$pc_username,
800 'pc_category'=>$category,
801 'pc_topic'=>$topic));[-/php-]";
802 window
.open(printURL
,'printwindow','width=740,height=480,toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,copyhistory=no,resizable=yes');
806 /* change the provider(s)
808 var ChangeProviders = function (eventObject
) {
809 $('#theform').submit();
812 /* change the calendar view
814 var ChangeView = function (eventObject
) {
815 if (eventObject
.id
== "dayview") {
816 $("#viewtype").val('day');
818 else if (eventObject
.id
== "weekview") {
819 $("#viewtype").val('week');
821 else if (eventObject
.id
== "monthview") {
822 $("#viewtype").val('month');
824 else if (eventObject
.id
== "yearview") {
825 $("#viewtype").val('year');
827 $('#theform').submit();