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 //==================================
139 <!-- stuff form element here to avoid the margin padding it introduces into the page in some browsers -->
140 <form name='theform' id='theform' action='index.php?module=PostCalendar&func=view&tplview=default&pc_category=&pc_topic=' method='post' onsubmit='return top.restoreSession()'
>
141 <input type=
"hidden" name=
"jumpdate" id=
"jumpdate" value=
"">
142 <input type=
"hidden" name=
"viewtype" id=
"viewtype" value=
"[-php-]echo $viewtype;[-/php-]">
144 echo
" <input type='button' value='" .xl (
"Add").
"' onclick='newEvt(1, 9, 00, $Date, 0, 0)' />\n";
145 echo
" <input type='button' value='" . xl (
"Search") .
146 "' onclick='top.restoreSession();location=\"index.php?module=PostCalendar&func=search\
"' />\n";
150 <div id=
"topToolbarRight"> <!-- this wraps some of the top toolbar items -->
153 <a href='[-php-]echo $PREV_WEEK_URL[-/php-]' onclick='top.restoreSession()'
>
154 <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-]" /></a>
155 <a href='[-php-]echo $NEXT_WEEK_URL[-/php-]' onclick='top.restoreSession()'
>
156 <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>
158 <input type='submit' name='bnsubmit' value='[-php-]echo xl (
"Today")[-/php-]' onClick='GoToToday(theform);'
/>
161 <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" class=
"currentview" 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" 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">
174 <table border=
"0" cellpadding=
"0" cellspacing=
"0">
177 $atmp = array_keys($A_EVENTS);
178 $caldate = strtotime($atmp[
0]);
179 $cMonth = date(
"m", $caldate);
180 $cYear = date(
"Y", $caldate);
181 $cDay = date(
"d", $caldate);
183 // compute the previous month date
184 // stay on the same day if possible
186 $pMonth = $cMonth -
1;
188 if ($pMonth <
1) { $pMonth =
12; $pYear = $cYear -
1; }
189 while (! checkdate($pMonth, $pDay, $pYear)) { $pDay = $pDay -
1; }
190 $prevMonth = sprintf(
"%d%02d%02d",$pYear,$pMonth,$pDay);
192 // compute the next month
193 // stay on the same day if possible
195 $nMonth = $cMonth +
1;
197 if ($nMonth
> 12) { $nMonth =
1; $nYear = $cYear +
1; }
198 while (! checkdate($nMonth, $nDay, $nYear)) { $nDay = $nDay -
1; }
199 $nextMonth = sprintf(
"%d%02d%02d",$nYear,$nMonth,$nDay);
201 <td class=
"tdDOW-small tdDatePicker tdNav" id=
"[-php-]echo $prevMonth[-/php-]" title=
"[-php-]echo xl(date("F
", strtotime($prevMonth)));[-/php-]"><</td>
202 <td colspan=
"5" class=
"tdMonthName-small">
204 echo xl(date('F', $caldate));
207 <td class=
"tdDOW-small tdDatePicker tdNav" id=
"[-php-]echo $nextMonth[-/php-]" title=
"[-php-]echo xl(date("F
", strtotime($nextMonth)));[-/php-]">></td>
210 foreach ($DOWlist as $dow) {
211 echo
"<td class='tdDOW-small'>".$this-
>_tpl_vars['A_SHORT_DAY_NAMES'][$dow].
"</td>";
216 $atmp = array_keys($A_EVENTS);
217 $caldate = strtotime($atmp[
0]);
218 $caldateEnd = strtotime($atmp[
6]);
220 // to make a complete week row we need to compute the real
221 // start and end dates for the view
222 list ($year, $month, $day) = explode(
" ", date('Y m d', $caldate));
223 $startdate = strtotime($year.$month.
"01");
224 $enddate = strtotime($year.$month.date(
"t", $startdate).
" 23:59");
225 while (date('w', $startdate) != $DOWlist[
0]) { $startdate -=
60*
60*
24; }
226 while (date('w', $enddate) != $DOWlist[
6]) { $enddate +=
60*
60*
24; }
228 $currdate = $startdate;
229 while ($currdate <= $enddate) {
230 if (date('w', $currdate) == $DOWlist[
0]) {
232 $tr =
"<tr class='trDateRow'>";
237 $tdClass =
"tdMonthDay-small";
238 if (date('m', $currdate) != $month) {
239 $tdClass =
"tdOtherMonthDay-small";
241 if ((date('w', $currdate) ==
0) || (date('w', $currdate) ==
6)) {
242 $tdClass =
"tdWeekend-small";
245 if ((date('Ymd',$currdate)
>= date('Ymd', $caldate)) &&
246 (date('Ymd',$currdate) <= date('Ymd', $caldateEnd)))
248 // add a class that highlights the 'current date'
249 $tdClass .=
" currentWeek";
252 if (date('Ymd',$currdate) == $Date) {
253 // $Date is defined near the top of this file
254 // and is equal to whatever date the user has clicked
255 $tdClass .=
" currentDate";
258 // add a class so that jQuery can grab these days for the 'click' event
259 $tdClass .=
" tdDatePicker";
263 $td .=
"class=\"".$tdClass."\
" ";
264 //$td .=
"id=\"".date("Ymd
", $currdate)."\
" ";
265 $td .=
"id=\"".date("Ymd
", $currdate)."\
" ";
266 $td .=
"title=\"" . xl('Go to week of') . " ".date('M d, Y', $currdate)."\
" ";
267 $td .=
"> ".date('d', $currdate).
"</td>\n";
271 if (date('w', $currdate) == $DOWlist[
6]) echo
"</tr>\n";
273 // time correction = plus
1000 seconds, for some unknown reason
274 $currdate += (
60*
60*
24)+
1000;
280 <div id=
"bigCalHeader">
282 $atmp = array_keys($A_EVENTS);
283 echo date('d M Y', strtotime($atmp[
0]));
285 echo date('d M Y', strtotime($atmp[count($atmp)-
1]));
289 <div id=
"providerPicker">
290 [-php-] xl('Providers','e'); [-/php-]
293 // ==============================
294 // FACILITY FILTERING (lemonsoftware)
295 // $facilities = getFacilities();
296 if ($_SESSION['authorizeduser'] ==
1) {
297 $facilities = getFacilities();
299 $facilities = getUserFacilities($_SESSION['authId']); // from users_facility
300 if (count($facilities) ==
1)
301 $_SESSION['pc_facility'] = key($facilities);
303 if (count($facilities)
> 1) {
304 echo
" <select name='pc_facility' id='pc_facility'>\n";
305 if ( !$_SESSION['pc_facility'] ) $selected =
"selected='selected'";
306 // echo
" <option value='0' $selected>" .xl('All Facilities').
"</option>\n";
307 if (!$GLOBALS['restrict_user_facility']) echo
" <option value='0' $selected>" . xl('All Facilities') .
"</option>\n";
308 foreach ($facilities as $fa) {
309 $selected = ( $_SESSION['pc_facility'] == $fa['id']) ?
"selected='selected'" :
"" ;
310 echo
" <option value='" .$fa['id'].
"' $selected>" .$fa['name'].
"</option>\n";
315 // ==============================
317 echo
" <select multiple size='5' name='pc_username[]' id='pc_username'>\n";
318 echo
" <option value='__PC_ALL__'>" .xl (
"All Users").
"</option>\n";
319 foreach ($provinfo as $doc) {
320 $username = $doc['username'];
321 echo
" <option value='$username'";
322 foreach ($providers as $provider)
323 if ($provider['username'] == $username) echo
" selected";
324 echo
">" . $doc['lname'] .
", " . $doc['fname'] .
"</option>\n";
333 [-assign
var=
"dayname" value=$DATE|date_format:
"%w"-]
334 [-assign
var=
"day" value=$DATE|date_format:
"%d"|string_format:
"%1d"-]
335 [-assign
var=
"month" value=$DATE|date_format:
"%m"|string_format:
"%1d"-]
336 [-assign
var=
"year" value=$DATE|date_format:
"%Y"|string_format:
"%4d"-]
341 foreach ($A_EVENTS as $date =
> $events) {
343 foreach ($events as $oneE) {
347 echo
"<hr width=100%>";
352 // This loops once for each provider to be displayed.
354 foreach ($providers as $provider) {
355 $providerid = $provider['id'];
357 // to specially handle the IN/OUT events I'm doing something new here
358 // for each IN event it will have a duration lasting until the next
359 // OUT event or until the end of the day
360 $tmpTime = $times[
0];
361 $calStartMin = ($tmpTime['hour'] *
60) + $tmpTime['minute'];
362 $tmpTime = $times[count($times)-
1];
363 $calEndMin = ($tmpTime['hour'] *
60) + $tmpTime['minute'];
365 echo
"<table border='0' cellpadding='1' cellspacing='0' width='100%'>\n";
367 echo
" <td colspan='8' class='providerheader'>";
368 echo $provider['fname'] .
" " . $provider['lname'];
372 // output column (date) headers
373 $colWidth =
100/
7; // intentionally '
7' and not '
8'
375 echo
" <td> </td>"; // blank TD for the header above the Times column
376 $defaultDate =
""; // used when creating link for a 'new' event
377 $in_cat_id =
0; // used when creating link for a 'new' event
378 foreach ($A_EVENTS as $date =
> $events) {
379 $dateFmt = date(
"Ymd", strtotime($date));
380 $gotoURL = pnModURL(__POSTCALENDAR__,'user','view',
381 array('tplview'=
>$template_view,
384 'pc_username'=
>$pc_username,
385 'pc_category'=
>$category,
386 'pc_topic'=
>$topic));
387 if ($defaultDate ==
"") $defaultDate = $dateFmt;
389 if ($Date == $dateFmt) { $currclass=
"week_currday"; }
390 echo
"<td align='center' class='week_dateheader $currclass' style='width:".$colWidth.
"%;' >";
391 echo
"<a href='$gotoURL'>";
392 echo xl(date(
"D", strtotime($date))) .
" " . date(
"m/d", strtotime($date));
397 // output the TD with the times DIV
399 echo
"<td id='times'><div><table>\n";
400 foreach ($times as $slottime) {
401 $startampm = ($slottime['mer']) ==
"pm" ?
2 :
1;
402 $starttimeh = $slottime['hour'];
403 $disptimeh = ($starttimeh
> 12) ? ($starttimeh -
12) : $starttimeh;
404 $starttimem = $slottime['minute'];
405 $slotendmins = $starttimeh *
60 + $starttimem + $interval;
407 echo
"<tr><td class='timeslot'>";
408 // echo
"<a href='javascript:newEvt($startampm,$starttimeh,$starttimem,$Date,$providerid,$in_cat_id)' title='New Appointment' alt='New Appointment'>";
409 echo
"<a href='javascript:newEvt($startampm,$starttimeh,$starttimem,$defaultDate,$providerid,$in_cat_id)' title='" . xl('New Appointment') .
"' alt='New Appointment'>";
411 //echo $slottime['hour'] *
60 + $slottime['minute'];
412 echo
"$disptimeh:$starttimem</a>";
415 echo
"</table></div></td>";
418 // output a TD with an inner containing DIV positioned 'relative'
419 // within that DIV we place our event DIVs using 'absolute' positioning
420 foreach ($A_EVENTS as $date =
> $events) {
421 $eventdate = substr($date,
0,
4) . substr($date,
5,
2) . substr($date,
8,
2);
423 // having a 'title' for the TD makes the date appear by the mouse pointer
424 // this is nice when all you see are times on the left side and no head
425 // row with the dates or day-of-week (DOW)
426 echo
"<td class='schedule' title='".date(
"l, d M Y", strtotime($date)).
"'>";
427 echo
"<div class='calendar_day'>";
429 // determine if events overlap and adjust their width and left position as needed
430 //
26 Feb
2008 - This needs fine tuning or total replacement
431 // - it doesn't work as well as I'd like - JRM
432 $eventPositions = array();
433 foreach ($times as $slottime) {
434 $starttimeh = $slottime['hour'];
435 $starttimem = $slottime['minute'];
437 $slotstartmins = $starttimeh *
60 + $starttimem;
438 $slotendmins = $starttimeh *
60 + $starttimem + $interval;
440 $events_in_timeslot = array();
441 foreach ($events as $e1) {
442 // ignore IN and OUT events
443 if (($e1['catid'] ==
2) || ($e1['catid'] ==
3)) { continue; }
444 // skip events without an ID (why they are in the loop, I have no idea)
445 if ($e1['eid'] ==
"") { continue; }
446 // skip events for other providers
447 if ($providerid != $e1['aid']) { continue; }
449 // specially handle all-day events
450 if ($e1['alldayevent'] ==
1) {
451 $tmpTime = $times[
0];
452 if (strlen($tmpTime['hour']) <
2) { $tmpTime['hour'] =
"0".$tmpTime['hour']; }
453 if (strlen($tmpTime['minute']) <
2) { $tmpTime['minute'] =
"0".$tmpTime['minute']; }
454 $e1['startTime'] = $tmpTime['hour'].
":".$tmpTime['minute'].
":00";
455 $e1['duration'] = ($calEndMin - $calStartMin) *
60; // measured in seconds
458 // create a numeric start and end for comparison
459 $starth = substr($e1['startTime'],
0,
2);
460 $startm = substr($e1['startTime'],
3,
2);
461 $e1Start = ($starth *
60) + $startm;
462 $e1End = $e1Start + $e1['duration']/
60;
464 // three ways to overlap:
465 // start-in, end-in, span
466 if ((($e1Start
>= $slotstartmins) && ($e1Start < $slotendmins)) // start-in
467 || (($e1End
> $slotstartmins) && ($e1End <= $slotendmins)) // end-in
468 || (($e1Start < $slotstartmins) && ($e1End
> $slotendmins))) // span
470 array_push($events_in_timeslot, $e1['eid']);
475 $width =
100 / count($events_in_timeslot);
477 // loop over the events in this timeslot and adjust their width
478 foreach ($events_in_timeslot as $eid) {
479 // set the width if not already set or if the current width is smaller
480 // than was was previously set
481 if (! isset($eventPositions[$eid]-
>width)) { $eventPositions[$eid]-
>width = $width; }
482 else if ($eventPositions[$eid]-
>width
> $width) { $eventPositions[$eid]-
>width = $width; }
484 // set the left position if not already set or if the current left is
485 // greater than what was previously set
486 if (! isset($eventPositions[$eid]-
>leftpos)) { $eventPositions[$eid]-
>leftpos = $leftpos; }
487 else if ($eventPositions[$eid]-
>leftpos < $leftpos) { $eventPositions[$eid]-
>leftpos = $leftpos; }
489 // increment the leftpos by the width
492 } // end overlap detection
494 // now loop over the events for the day and output their DIVs
495 foreach ($events as $event) {
496 // skip events for other providers
497 // yeah, we've got that sort of overhead here... it ain't perfect
498 if ($providerid != $event['aid']) { continue; }
500 // skip events without an ID (why they are in the loop, I have no idea)
501 if ($event['eid'] ==
"") { continue; }
503 // specially handle all-day events
504 if ($event['alldayevent'] ==
1) {
505 $tmpTime = $times[
0];
506 if (strlen($tmpTime['hour']) <
2) { $tmpTime['hour'] =
"0".$tmpTime['hour']; }
507 if (strlen($tmpTime['minute']) <
2) { $tmpTime['minute'] =
"0".$tmpTime['minute']; }
508 $event['startTime'] = $tmpTime['hour'].
":".$tmpTime['minute'].
":00";
509 $event['duration'] = ($calEndMin - $calStartMin) *
60; // measured in seconds
512 // figure the start time and minutes (from midnight)
513 $starth = substr($event['startTime'],
0,
2);
514 $startm = substr($event['startTime'],
3,
2);
515 $eStartMin = $starth *
60 + $startm;
516 $dispstarth = ($starth
> 12) ? ($starth -
12) : $starth;
518 // determine the class for the event DIV based on the event category
519 $evtClass =
"event_appointment";
520 switch ($event['catid']) {
521 case
1: // NO-SHOW appt
522 $evtClass =
"event_noshow";
525 $evtClass =
"event_in";
527 case
3: // OUT of office
528 $evtClass =
"event_out";
533 $evtClass =
"event_reserved";
535 default: // some appointment
536 $evtClass =
"event_appointment";
540 // if this is an IN or OUT event then we have some extra special
541 // processing to be done
542 // the IN event creates a DIV until the OUT event
543 // or, without an OUT DIV matching the IN event
544 // then the IN event runs until the end of the day
545 if ($event['catid'] ==
2) {
546 // locate a matching OUT for this specific IN
549 foreach ($events as $outevent) {
550 // skip events for other providers
551 if ($providerid != $outevent['aid']) { continue; }
552 // skip events with blank IDs
553 if ($outevent['eid'] ==
"") { continue; }
555 if ($outevent['eid'] == $event['eid']) { $found = true; continue; }
556 if (($found == true) && ($outevent['catid'] ==
3)) {
557 // calculate the duration from this event to the outevent
558 $outH = substr($outevent['startTime'],
0,
2);
559 $outM = substr($outevent['startTime'],
3,
2);
560 $outMins = ($outH *
60) + $outM;
561 $event['duration'] = ($outMins - $eStartMin) *
60; // duration is in seconds
567 // no OUT was found so this event's duration goes
568 // until the end of the day
569 $event['duration'] = ($calEndMin - $eStartMin) *
60; // duration is in seconds
573 // calculate the TOP value for the event DIV
574 // diff between event start and schedule start
575 $eMinDiff = $eStartMin - $calStartMin;
576 // diff divided by the time interval of the schedule
577 $eStartInterval = $eMinDiff / $interval;
578 // times the interval height
579 $eStartPos = $eStartInterval * $timeslotHeightVal;
580 $evtTop = $eStartPos.$timeslotHeightUnit;
582 // calculate the HEIGHT value for the event DIV
583 // diff between end and start of event
584 $eEndMin = $eStartMin + ($event['duration']/
60);
585 // prevent the overall height of the event from going beyond the bounds
587 if ($eEndMin
> $calEndMin) { $eEndMin = $calEndMin + $interval; }
588 $eMinDiff = $eEndMin - $eStartMin;
589 // diff divided by the time interval of the schedule
590 $eEndInterval = $eMinDiff / $interval;
591 // times the interval height
592 $eHeight = $eEndInterval * $timeslotHeightVal;
593 $evtHeight = $eHeight.$timeslotHeightUnit;
595 // determine the DIV width based on any overlapping events
596 // see further above for the overlapping calculation code
599 if (isset($eventPositions[$event['eid']])) {
600 $divWidth =
"width: ".$eventPositions[$event['eid']]-
>width.
"%";
601 $divLeft =
"left: ".$eventPositions[$event['eid']]-
>leftpos.
"%";
604 $eventid = $event['eid'];
605 $patientid = $event['pid'];
606 $commapos = strpos($event['patient_name'],
",");
607 $lname = substr($event['patient_name'],
0, $commapos);
608 $fname = substr($event['patient_name'], $commapos +
2);
609 $patient_dob = $event['patient_dob'];
610 $patient_age = $event['patient_age'];
611 $catid = $event['catid'];
612 $comment = addslashes($event['hometext']);
613 $catname = $event['catname'];
614 $title =
"Age $patient_age ($patient_dob)";
618 if ($comment && $GLOBALS['calendar_appt_style'] <
4) $title .=
" " . $comment;
620 // the divTitle is what appears when the user hovers the mouse over the DIV
621 $divTitle = date(
"D, d M Y", strtotime($date));
623 if ($catid ==
2 || $catid ==
3 || $catid ==
4 || $catid ==
8 || $catid ==
11) {
624 if ($catid ==
2) $catname = xl(
"IN");
625 else if ($catid ==
3) $catname = xl(
"OUT");
626 else if ($catid ==
4) $catname = xl(
"VACATION");
627 else if ($catid ==
8) $catname = xl(
"LUNCH");
628 else if ($catid ==
11) $catname = xl(
"RESERVED");
631 if ($comment) $atitle .=
" $comment";
632 //$divTitle .=
"\n[".$atitle .
"] ".$divTitle;
633 $divTitle .=
"\n[".$atitle .
"]";
634 //$content .=
"<a href='javascript:oldEvt($eventdate,$eventid)' title='$atitle'>";
635 $content .= $catname;
636 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'>";
637 if ($comment) $content .=
" $comment";
638 //$content .=
"</a>";
641 // some sort of patient appointment
642 $divTitle .=
"\r\n[".$catname .
"] ".htmlspecialchars($fname,ENT_QUOTES).
" ".htmlspecialchars($lname,ENT_QUOTES);
643 $content .=
"<span class='appointment".$apptToggle.
"'>";
644 $content .= $dispstarth . ':' . $startm;
645 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'>";
646 $content .= htmlspecialchars($event['apptstatus']);
648 // include patient name and link to their details
649 $link_title = htmlspecialchars($fname,ENT_QUOTES) .
" " . htmlspecialchars($lname,ENT_QUOTES) .
" \n";
650 $link_title .= xl('Age') .
": ".$patient_age.
"\n" . xl('DOB') .
": ".$patient_dob.
"\n";
651 if ($comment) $link_title .=
"$comment";
652 $link_title .=
"(" . xl('Click to view') .
")";
653 $content .=
"<a href='javascript:goPid($patientid)' title='$link_title'>";
654 $content .=
"<img src='$TPL_IMAGE_PATH/user-green.gif' border='0' title='$link_title' alt='View Patient' />";
658 // no patient id, just output the category name
659 $content .= $catname;
661 $content .=
"</span>";
664 $divTitle .=
"\n(" . xl('double click to edit') .
")";
666 // output the DIV and content
667 echo
"<div class='".$evtClass.
" event' style='top:".$evtTop.
"; height:".$evtHeight.
668 "; background-color:".$event[
"catcolor"].
671 "' title='".$divTitle.
"'".
672 " id='".$eventdate.
"-".$eventid.
"'".
690 // [-include
file=
"$TPL_NAME/views/global/footer.html"-]
691 // [-include
file=
"$TPL_NAME/views/footer.html"-]
694 </div> <!-- end bigCal DIV -->
698 <script language='JavaScript'
>
700 $(document
).ready(function(){
701 $("#pc_username").change(function() { ChangeProviders(this); });
702 $("#pc_facility").change(function() { ChangeProviders(this); });
703 $("#dayview").click(function() { ChangeView(this); });
704 //$("#weekview").click(function() { ChangeView(this); });
705 $("#monthview").click(function() { ChangeView(this); });
706 //$("#yearview").click(function() { ChangeView(this); });
707 $(".tdDatePicker").click(function() { ChangeDate(this); });
708 $("#datePicker .trDateRow").mouseover(function() { $(this).children().toggleClass("tdDatePickerHighlight"); });
709 $("#datePicker .trDateRow").mouseout(function() { $(this).children().toggleClass("tdDatePickerHighlight"); });
710 $("#datePicker .tdNav").mouseover(function() { $(this).toggleClass("tdDatePickerHighlight"); });
711 $("#datePicker .tdNav").mouseout(function() { $(this).toggleClass("tdDatePickerHighlight"); });
712 $("#printview").click(function() { PrintView(this); });
713 $(".event").dblclick(function() { EditEvent(this); });
714 $(".event").mouseover(function() { $(this).toggleClass("event_highlight"); });
715 $(".event").mouseout(function() { $(this).toggleClass("event_highlight"); });
718 /* edit an existing event */
719 var EditEvent = function(eObj
) {
720 //alert ('editing '+eObj.id);
721 // split the object ID into date and event ID
723 var parts
= new Array();
724 parts
= objID
.split("-");
725 // call the oldEvt function to bring up the event editor
726 oldEvt(parts
[0], parts
[1]);
730 /* change the current date based upon what the user clicked in
733 var ChangeDate = function(eObj
) {
734 baseURL
= "[-php-]echo pnModURL(__POSTCALENDAR__,'user','view',
735 array('tplview'=>$template_view,
736 'viewtype'=>$viewtype,
737 'Date'=> '~REPLACEME~',
738 'pc_username'=>$pc_username,
739 'pc_category'=>$category,
740 'pc_topic'=>$topic));[-/php-]";
741 newURL
= baseURL
.replace(/~REPLACEME~/, eObj
.id
);
742 document
.location
.href
=newURL
;
745 /* pop up a window to print the current view
747 var PrintView = function (eventObject
) {
748 printURL
= "[-php-]echo pnModURL(__POSTCALENDAR__,'user','view',
749 array('tplview'=>$template_view,
750 'viewtype'=>$viewtype,
753 'pc_username'=>$pc_username,
754 'pc_category'=>$category,
755 'pc_topic'=>$topic));[-/php-]";
756 window
.open(printURL
,'printwindow','width=740,height=480,toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,copyhistory=no,resizable=yes');
760 /* change the provider(s)
762 var ChangeProviders = function (eventObject
) {
763 $('#theform').submit();
766 /* change the calendar view
768 var ChangeView = function (eventObject
) {
769 if (eventObject
.id
== "dayview") {
770 $("#viewtype").val('day');
772 else if (eventObject
.id
== "weekview") {
773 $("#viewtype").val('week');
775 else if (eventObject
.id
== "monthview") {
776 $("#viewtype").val('month');
778 else if (eventObject
.id
== "yearview") {
779 $("#viewtype").val('year');
781 $('#theform').submit();