2 [-*****************************************************************************-]
3 [-* Copyright (C)
2005-
2006 Rod Roark
<rod@sunsetsystems.com
> and others *-]
5 [-* This program is free software; you can redistribute it and/or *-]
6 [-* modify it under the terms of the GNU General Public License *-]
7 [-* as published by the Free Software Foundation; either version
2 *-]
8 [-* of the License, or (at your option) any later version. *-]
9 [-*****************************************************************************-]
10 [-config_load
file=
"default.conf"-]
11 [-*Load the Language Definitions*-]
12 [-config_load
file=
"lang.$USER_LANG"-]
13 [-include
file=
"$TPL_NAME/views/header.html"-]
15 [-*Values used in setting timeslot and event heights*-]
17 /* if you change these be sure to change their matching values in
18 * the CSS for the calendar, found in interface/themes/ajax_calendar.css
20 $timeslotHeightVal=
20;
21 $
timeslotHeightUnit=
"px";
24 <script language='JavaScript'
>
26 var mypcc
= '[-php-] echo $GLOBALS['phone_country_code
'] [-/php-]';
28 // This is called from the event editor popup.
29 function refreshme() {
31 document
.forms
[0].submit();
34 function newEvt(startampm
, starttimeh
, starttimem
, eventdate
, providerid
, catid
) {
35 dlgopen('add_edit_event.php?startampm=' + startampm
+
36 '&starttimeh=' + starttimeh
+ '&starttimem=' + starttimem
+
37 '&date=' + eventdate
+ '&userid=' + providerid
+ '&catid=' + catid
,
41 function oldEvt(eventdate
, eventid
) {
42 dlgopen('add_edit_event.php?date='+eventdate
+'&eid=' + eventid
, '_blank', 550, 270);
48 if ($GLOBALS
['concurrent_layout'])
50 if( $GLOBALS
['dutchpc'] )
52 echo
" top.RTop.location = '../../patient_file/summary/demographics_dutch.php' " .
53 "+ '?set_pid=' + pid;\n";
56 echo
" top.RTop.location = '../../patient_file/summary/demographics.php' " .
57 "+ '?set_pid=' + pid;\n";
61 echo
" top.location = '../../patient_file/patient_file.php' " .
62 "+ '?set_pid=' + pid + '&pid=' + pid;\n";
67 function GoToToday(theForm
){
68 var todays_date
= new Date();
69 var theMonth
= todays_date
.getMonth() + 1;
70 theMonth
= theMonth
< 10 ? "0" + theMonth
: theMonth
;
71 theForm
.jumpdate
.value
= todays_date
.getFullYear() + "-" + theMonth
+ "-" + todays_date
.getDate();
80 // this is my proposed setting in the globals config file so we don't
81 // need to mess with altering the pn database AND the config file
82 //pnModSetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek', $GLOBALS['schedule_dow_start']);
84 // build a day-of-week (DOW) list so we may properly build the calendars later in this code
86 $tmpDOW = pnModGetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek');
87 // bound check and auto-correction
88 if ($tmpDOW
<0 || $tmpDOW
>6) {
89 pnModSetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek', '
0');
92 while (count($DOWlist) <
7) {
93 array_push($DOWlist, $tmpDOW);
95 if ($tmpDOW
> 6) $tmpDOW =
0;
98 // A_CATEGORY is an ordered array of associative-array categories.
99 // Keys of interest are: id, name, color, desc, event_duration.
101 // echo
"<!-- A_CATEGORY = "; print_r($this-
>_tpl_vars['A_CATEGORY']); echo
" -->\n"; // debugging
102 // echo
"<!-- A_EVENTS = "; print_r($this-
>_tpl_vars['A_EVENTS']); echo
" -->\n"; // debugging
104 $A_CATEGORY =& $this-
>_tpl_vars['A_CATEGORY'];
106 // [-if $PRINT_VIEW !=
1-]
107 // [-*Main Navigation*-]
108 // [-include
file=
"$TPL_NAME/views/global/navigation.html"-]
111 $A_EVENTS =& $this-
>_tpl_vars['A_EVENTS'];
112 $providers =& $this-
>_tpl_vars['providers'];
113 $times =& $this-
>_tpl_vars['times'];
114 $interval = $this-
>_tpl_vars['interval'];
115 $viewtype = $this-
>_tpl_vars['VIEW_TYPE'];
116 $PREV_WEEK_URL = $this-
>_tpl_vars['PREV_WEEK_URL'];
117 $NEXT_WEEK_URL = $this-
>_tpl_vars['NEXT_WEEK_URL'];
118 $PREV_DAY_URL = $this-
>_tpl_vars['PREV_DAY_URL'];
119 $NEXT_DAY_URL = $this-
>_tpl_vars['NEXT_DAY_URL'];
121 $Date = postcalendar_getDate();
122 if (!isset($y)) $y = substr($Date,
0,
4);
123 if (!isset($m)) $m = substr($Date,
4,
2);
124 if (!isset($d)) $d = substr($Date,
6,
2);
126 // echo
"<!-- There are " . count($A_EVENTS) .
" A_EVENTS days -->\n";
128 //==================================
129 //FACILITY FILTERING (CHEMED)
130 if ( $_SESSION['pc_facility'] ) {
131 $provinfo = getProviderInfo('%', true, $_SESSION['pc_facility']);
133 $provinfo = getProviderInfo();
135 //EOS FACILITY FILTERING (CHEMED)
136 //==================================
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
" <input type='button' value='" .xl (
"Add").
"' onclick='newEvt(1, 9, 00, $Date, 0, 0)' />\n";
147 echo
" <input type='button' value='" . xl (
"Search") .
148 "' onclick='top.restoreSession();location=\"index.php?module=PostCalendar&func=search\
"' />\n";
152 <div id=
"topToolbarRight"> <!-- this wraps some of the top toolbar items -->
155 <a href='[-php-]echo $PREV_WEEK_URL[-/php-]' onclick='top.restoreSession()'
>
156 <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>
157 <a href='[-php-]echo $NEXT_WEEK_URL[-/php-]' onclick='top.restoreSession()'
>
158 <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>
160 <input type='submit' name='bnsubmit' value='[-php-]echo xl (
"Today")[-/php-]' onClick='GoToToday(theform);'
/>
163 <div id=
"viewPicker">
164 <img id=
"printview" src=
"[-$TPL_IMAGE_PATH-]/print.gif" border=
"0" title=
"[-php-]echo xl("Print View
")[-/php-]" alt=
"[-php-]echo xl ("Print View
")[-/php-]" />
166 <img id=
"dayview" src=
"[-$TPL_IMAGE_PATH-]/day.gif" border=
"0" title=
"[-php-]echo xl("Day View
")[-/php-]" alt=
"[-php-]echo xl ("Day View
")[-/php-]" />
168 <img id=
"weekview" class=
"currentview" src=
"[-$TPL_IMAGE_PATH-]/week.gif" border=
"0" title=
"[-php-]echo xl ("Week View
")[-/php-]" alt=
"[-php-]echo xl ("Week View
")[-/php-]" />
170 <img id=
"monthview" src=
"[-$TPL_IMAGE_PATH-]/month.gif" border=
"0" title=
"[-php-]echo xl ("Month View
")[-/php-]" alt=
"[-php-]echo xl ("Month View
")[-/php-]" />
172 </div> <!-- end topToolbarRight -->
174 <div id=
"datePicker">
176 <table border=
"0" cellpadding=
"0" cellspacing=
"0">
179 $atmp = array_keys($A_EVENTS);
180 $caldate = strtotime($atmp[
0]);
181 $cMonth = date(
"m", $caldate);
182 $cYear = date(
"Y", $caldate);
183 $cDay = date(
"d", $caldate);
185 // compute the previous month date
186 // stay on the same day if possible
188 $pMonth = $cMonth -
1;
190 if ($pMonth <
1) { $pMonth =
12; $pYear = $cYear -
1; }
191 while (! checkdate($pMonth, $pDay, $pYear)) { $pDay = $pDay -
1; }
192 $prevMonth = sprintf(
"%d%02d%02d",$pYear,$pMonth,$pDay);
194 // compute the next month
195 // stay on the same day if possible
197 $nMonth = $cMonth +
1;
199 if ($nMonth
> 12) { $nMonth =
1; $nYear = $cYear +
1; }
200 while (! checkdate($nMonth, $nDay, $nYear)) { $nDay = $nDay -
1; }
201 $nextMonth = sprintf(
"%d%02d%02d",$nYear,$nMonth,$nDay);
203 <td class=
"tdDOW-small tdDatePicker tdNav" id=
"[-php-]echo $prevMonth[-/php-]" title=
"[-php-]echo date("F
", strtotime($prevMonth));[-/php-]"><</td>
204 <td colspan=
"5" class=
"tdMonthName-small">
206 echo date('F', $caldate);
209 <td class=
"tdDOW-small tdDatePicker tdNav" id=
"[-php-]echo $nextMonth[-/php-]" title=
"[-php-]echo date("F
", strtotime($nextMonth));[-/php-]">></td>
212 foreach ($DOWlist as $dow) {
213 echo
"<td class='tdDOW-small'>".$this-
>_tpl_vars['A_SHORT_DAY_NAMES'][$dow].
"</td>";
218 $atmp = array_keys($A_EVENTS);
219 $caldate = strtotime($atmp[
0]);
220 $caldateEnd = strtotime($atmp[
6]);
221 // to make a complete week row we need to compute the real
222 // start and end dates for the view
223 list ($year, $month, $day) = explode(
" ", date('Y m d', $caldate));
224 $startdate = strtotime($year.$month.
"01");
225 while (date('w', $startdate) != $DOWlist[
0]) { $startdate -=
60*
60*
24; }
227 $enddate = strtotime($year.$month.date(
"t", $prevmonth).
" 23:59");
228 while (date('w', $enddate) != $DOWlist[
6]) { $enddate +=
60*
60*
24; }
230 $currdate = $startdate;
231 while ($currdate <= $enddate) {
232 if (date('w', $currdate) == $DOWlist[
0]) {
234 $tr =
"<tr class='trDateRow'>";
239 $tdClass =
"tdMonthDay-small";
240 if (date('m', $currdate) != $month) {
241 $tdClass =
"tdOtherMonthDay-small";
243 if ((date('w', $currdate) ==
0) || (date('w', $currdate) ==
6)) {
244 $tdClass =
"tdWeekend-small";
247 if ((date('Ymd',$currdate)
>= date('Ymd', $caldate)) &&
248 (date('Ymd',$currdate) <= date('Ymd', $caldateEnd)))
250 // add a class that highlights the 'current date'
251 $tdClass .=
" currentWeek";
254 if (date('Ymd',$currdate) == $Date) {
255 // $Date is defined near the top of this file
256 // and is equal to whatever date the user has clicked
257 $tdClass .=
" currentDate";
260 // add a class so that jQuery can grab these days for the 'click' event
261 $tdClass .=
" tdDatePicker";
265 $td .=
"class=\"".$tdClass."\
" ";
266 //$td .=
"id=\"".date("Ymd
", $currdate)."\
" ";
267 $td .=
"id=\"".date("Ymd
", $currdate)."\
" ";
268 $td .=
"title=\"Go to week of
".date('M d, Y', $currdate)."\
" ";
269 $td .=
"> ".date('d', $currdate).
"</td>\n";
273 if (date('w', $currdate) == $DOWlist[
6]) echo
"</tr>\n";
275 // time correction = plus
1000 seconds, for some unknown reason
276 $currdate += (
60*
60*
24)+
1000;
282 <div id=
"bigCalHeader">
284 $atmp = array_keys($A_EVENTS);
285 echo date('d M Y', strtotime($atmp[
0]));
287 echo date('d M Y', strtotime($atmp[count($atmp)-
1]));
291 <div id=
"providerPicker">
295 // ==============================
296 // FACILITY FILTERING (lemonsoftware)
297 $facilities = getFacilities();
298 if (count($facilities)
> 1) {
299 echo
" <select name='pc_facility' id='pc_facility'>\n";
300 if ( !$_SESSION['pc_facility'] ) $selected =
"selected='selected'";
301 echo
" <option value='0' $selected>" .xl('All Facilities').
"</option>\n";
302 foreach ($facilities as $fa) {
303 $selected = ( $_SESSION['pc_facility'] == $fa['id']) ?
"selected='selected'" :
"" ;
304 echo
" <option value='" .$fa['id'].
"' $selected>" .$fa['name'].
"</option>\n";
309 // ==============================
311 echo
" <select multiple size='5' name='pc_username[]' id='pc_username'>\n";
312 echo
" <option value='__PC_ALL__'>" .xl (
"All Users").
"</option>\n";
313 foreach ($provinfo as $doc) {
314 $username = $doc['username'];
315 echo
" <option value='$username'";
316 foreach ($providers as $provider)
317 if ($provider['username'] == $username) echo
" selected";
318 echo
">" . $doc['lname'] .
", " . $doc['fname'] .
"</option>\n";
327 [-assign
var=
"dayname" value=$DATE|date_format:
"%w"-]
328 [-assign
var=
"day" value=$DATE|date_format:
"%d"|string_format:
"%1d"-]
329 [-assign
var=
"month" value=$DATE|date_format:
"%m"|string_format:
"%1d"-]
330 [-assign
var=
"year" value=$DATE|date_format:
"%Y"|string_format:
"%4d"-]
335 foreach ($A_EVENTS as $date =
> $events) {
337 foreach ($events as $oneE) {
341 echo
"<hr width=100%>";
346 // This loops once for each provider to be displayed.
348 foreach ($providers as $provider) {
349 $providerid = $provider['id'];
351 // to specially handle the IN/OUT events I'm doing something new here
352 // for each IN event it will have a duration lasting until the next
353 // OUT event or until the end of the day
354 $tmpTime = $times[
0];
355 $calStartMin = ($tmpTime['hour'] *
60) + $tmpTime['minute'];
356 $tmpTime = $times[count($times)-
1];
357 $calEndMin = ($tmpTime['hour'] *
60) + $tmpTime['minute'];
359 echo
"<table border='0' cellpadding='1' cellspacing='0' width='100%'>\n";
361 echo
" <td colspan='8' class='providerheader'>";
362 echo $provider['fname'] .
" " . $provider['lname'];
366 // output column (date) headers
367 $colWidth =
100/
7; // intentionally '
7' and not '
8'
369 echo
" <td> </td>"; // blank TD for the header above the Times column
370 $defaultDate =
""; // used when creating link for a 'new' event
371 $in_cat_id =
0; // used when creating link for a 'new' event
372 foreach ($A_EVENTS as $date =
> $events) {
373 $dateFmt = date(
"Ymd", strtotime($date));
374 $gotoURL = pnModURL(__POSTCALENDAR__,'user','view',
375 array('tplview'=
>$template_view,
378 'pc_username'=
>$pc_username,
379 'pc_category'=
>$category,
380 'pc_topic'=
>$topic));
381 if ($defaultDate ==
"") $defaultDate = $dateFmt;
383 if ($Date == $dateFmt) { $currclass=
"week_currday"; }
384 echo
"<td align='center' class='week_dateheader $currclass' style='width:".$colWidth.
"%;' >";
385 echo
"<a href='$gotoURL'>";
386 echo date(
"D m/d", strtotime($date));
391 // output the TD with the times DIV
393 echo
"<td id='times'><div><table>\n";
394 foreach ($times as $slottime) {
395 $startampm = ($slottime['mer']) ==
"pm" ?
2 :
1;
396 $starttimeh = $slottime['hour'];
397 $disptimeh = ($starttimeh
> 12) ? ($starttimeh -
12) : $starttimeh;
398 $starttimem = $slottime['minute'];
399 $slotendmins = $starttimeh *
60 + $starttimem + $interval;
401 echo
"<tr><td class='timeslot'>";
402 echo
"<a href='javascript:newEvt($startampm,$starttimeh,$starttimem,$Date,$providerid,$in_cat_id)' title='New Appointment' alt='New Appointment'>";
403 //echo $slottime['hour'] *
60 + $slottime['minute'];
404 echo
"$disptimeh:$starttimem</a>";
407 echo
"</table></div></td>";
410 // output a TD with an inner containing DIV positioned 'relative'
411 // within that DIV we place our event DIVs using 'absolute' positioning
412 foreach ($A_EVENTS as $date =
> $events) {
413 $eventdate = substr($date,
0,
4) . substr($date,
5,
2) . substr($date,
8,
2);
415 // having a 'title' for the TD makes the date appear by the mouse pointer
416 // this is nice when all you see are times on the left side and no head
417 // row with the dates or day-of-week (DOW)
418 echo
"<td class='schedule' title='".date(
"l, d M Y", strtotime($date)).
"'>";
419 echo
"<div class='calendar_day'>";
421 // determine if events overlap and adjust their width and left position as needed
422 //
26 Feb
2008 - This needs fine tuning or total replacement
423 // - it doesn't work as well as I'd like - JRM
424 $eventPositions = array();
425 foreach ($times as $slottime) {
426 $starttimeh = $slottime['hour'];
427 $starttimem = $slottime['minute'];
429 $slotstartmins = $starttimeh *
60 + $starttimem;
430 $slotendmins = $starttimeh *
60 + $starttimem + $interval;
432 $events_in_timeslot = array();
433 foreach ($events as $e1) {
434 // ignore IN and OUT events
435 if (($e1['catid'] ==
2) || ($e1['catid'] ==
3)) { continue; }
436 // skip events without an ID (why they are in the loop, I have no idea)
437 if ($e1['eid'] ==
"") { continue; }
438 // skip events for other providers
439 if ($providerid != $e1['aid']) { continue; }
441 // specially handle all-day events
442 if ($e1['alldayevent'] ==
1) {
443 $tmpTime = $times[
0];
444 if (strlen($tmpTime['hour']) <
2) { $tmpTime['hour'] =
"0".$tmpTime['hour']; }
445 if (strlen($tmpTime['minute']) <
2) { $tmpTime['minute'] =
"0".$tmpTime['minute']; }
446 $e1['startTime'] = $tmpTime['hour'].
":".$tmpTime['minute'].
":00";
447 $e1['duration'] = ($calEndMin - $calStartMin) *
60; // measured in seconds
450 // create a numeric start and end for comparison
451 $starth = substr($e1['startTime'],
0,
2);
452 $startm = substr($e1['startTime'],
3,
2);
453 $e1Start = ($starth *
60) + $startm;
454 $e1End = $e1Start + $e1['duration']/
60;
456 // three ways to overlap:
457 // start-in, end-in, span
458 if ((($e1Start
>= $slotstartmins) && ($e1Start < $slotendmins)) // start-in
459 || (($e1End
> $slotstartmins) && ($e1End <= $slotendmins)) // end-in
460 || (($e1Start < $slotstartmins) && ($e1End
> $slotendmins))) // span
462 array_push($events_in_timeslot, $e1['eid']);
467 $width =
100 / count($events_in_timeslot);
469 // loop over the events in this timeslot and adjust their width
470 foreach ($events_in_timeslot as $eid) {
471 // set the width if not already set or if the current width is smaller
472 // than was was previously set
473 if (! isset($eventPositions[$eid]-
>width)) { $eventPositions[$eid]-
>width = $width; }
474 else if ($eventPositions[$eid]-
>width
> $width) { $eventPositions[$eid]-
>width = $width; }
476 // set the left position if not already set or if the current left is
477 // greater than what was previously set
478 if (! isset($eventPositions[$eid]-
>leftpos)) { $eventPositions[$eid]-
>leftpos = $leftpos; }
479 else if ($eventPositions[$eid]-
>leftpos < $leftpos) { $eventPositions[$eid]-
>leftpos = $leftpos; }
481 // increment the leftpos by the width
484 } // end overlap detection
486 // now loop over the events for the day and output their DIVs
487 foreach ($events as $event) {
488 // skip events for other providers
489 // yeah, we've got that sort of overhead here... it ain't perfect
490 if ($providerid != $event['aid']) { continue; }
492 // skip events without an ID (why they are in the loop, I have no idea)
493 if ($event['eid'] ==
"") { continue; }
495 // specially handle all-day events
496 if ($event['alldayevent'] ==
1) {
497 $tmpTime = $times[
0];
498 if (strlen($tmpTime['hour']) <
2) { $tmpTime['hour'] =
"0".$tmpTime['hour']; }
499 if (strlen($tmpTime['minute']) <
2) { $tmpTime['minute'] =
"0".$tmpTime['minute']; }
500 $event['startTime'] = $tmpTime['hour'].
":".$tmpTime['minute'].
":00";
501 $event['duration'] = ($calEndMin - $calStartMin) *
60; // measured in seconds
504 // figure the start time and minutes (from midnight)
505 $starth = substr($event['startTime'],
0,
2);
506 $startm = substr($event['startTime'],
3,
2);
507 $eStartMin = $starth *
60 + $startm;
508 $dispstarth = ($starth
> 12) ? ($starth -
12) : $starth;
510 // determine the class for the event DIV based on the event category
511 $evtClass =
"event_appointment";
512 switch ($event['catid']) {
513 case
1: // NO-SHOW appt
514 $evtClass =
"event_noshow";
517 $evtClass =
"event_in";
519 case
3: // OUT of office
520 $evtClass =
"event_out";
525 $evtClass =
"event_reserved";
527 default: // some appointment
528 $evtClass =
"event_appointment";
532 // if this is an IN or OUT event then we have some extra special
533 // processing to be done
534 // the IN event creates a DIV until the OUT event
535 // or, without an OUT DIV matching the IN event
536 // then the IN event runs until the end of the day
537 if ($event['catid'] ==
2) {
538 // locate a matching OUT for this specific IN
541 foreach ($events as $outevent) {
542 // skip events for other providers
543 if ($providerid != $outevent['aid']) { continue; }
544 // skip events with blank IDs
545 if ($outevent['eid'] ==
"") { continue; }
547 if ($outevent['eid'] == $event['eid']) { $found = true; continue; }
548 if (($found == true) && ($outevent['catid'] ==
3)) {
549 // calculate the duration from this event to the outevent
550 $outH = substr($outevent['startTime'],
0,
2);
551 $outM = substr($outevent['startTime'],
3,
2);
552 $outMins = ($outH *
60) + $outM;
553 $event['duration'] = ($outMins - $eStartMin) *
60; // duration is in seconds
559 // no OUT was found so this event's duration goes
560 // until the end of the day
561 $event['duration'] = ($calEndMin - $eStartMin) *
60; // duration is in seconds
565 // calculate the TOP value for the event DIV
566 // diff between event start and schedule start
567 $eMinDiff = $eStartMin - $calStartMin;
568 // diff divided by the time interval of the schedule
569 $eStartInterval = $eMinDiff / $interval;
570 // times the interval height
571 $eStartPos = $eStartInterval * $timeslotHeightVal;
572 $evtTop = $eStartPos.$timeslotHeightUnit;
574 // calculate the HEIGHT value for the event DIV
575 // diff between end and start of event
576 $eEndMin = $eStartMin + ($event['duration']/
60);
577 // prevent the overall height of the event from going beyond the bounds
579 if ($eEndMin
> $calEndMin) { $eEndMin = $calEndMin + $interval; }
580 $eMinDiff = $eEndMin - $eStartMin;
581 // diff divided by the time interval of the schedule
582 $eEndInterval = $eMinDiff / $interval;
583 // times the interval height
584 $eHeight = $eEndInterval * $timeslotHeightVal;
585 $evtHeight = $eHeight.$timeslotHeightUnit;
587 // determine the DIV width based on any overlapping events
588 // see further above for the overlapping calculation code
591 if (isset($eventPositions[$event['eid']])) {
592 $divWidth =
"width: ".$eventPositions[$event['eid']]-
>width.
"%";
593 $divLeft =
"left: ".$eventPositions[$event['eid']]-
>leftpos.
"%";
596 $eventid = $event['eid'];
597 $patientid = $event['pid'];
598 $commapos = strpos($event['patient_name'],
",");
599 $lname = addslashes(ucfirst(strtolower(substr($event['patient_name'],
0, $commapos))));
600 $fname = addslashes(ucfirst(strtolower(substr($event['patient_name'], $commapos +
2))));
601 $patient_dob = $event['patient_dob'];
602 $patient_age = $event['patient_age'];
603 $catid = $event['catid'];
604 $comment = addslashes($event['hometext']);
605 $catname = $event['catname'];
606 $title =
"Age $patient_age ($patient_dob)";
610 if ($comment && $GLOBALS['calendar_appt_style'] <
4) $title .=
" " . $comment;
612 // the divTitle is what appears when the user hovers the mouse over the DIV
613 $divTitle = date(
"D, d M Y", strtotime($date));
615 if ($catid ==
2 || $catid ==
3 || $catid ==
4 || $catid ==
8 || $catid ==
11) {
616 if ($catid ==
2) $catname =
"IN";
617 else if ($catid ==
3) $catname =
"OUT";
618 else if ($catid ==
4) $catname =
"VACATION";
619 else if ($catid ==
8) $catname =
"LUNCH";
620 else if ($catid ==
11) $catname =
"RESERVED";
623 if ($comment) $atitle .=
" $comment";
624 //$divTitle .=
"\n[".$atitle .
"] ".$divTitle;
625 $divTitle .=
"\n[".$atitle .
"]";
626 //$content .=
"<a href='javascript:oldEvt($eventdate,$eventid)' title='$atitle'>";
627 $content .= $catname;
628 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'>";
629 if ($comment) $content .=
" $comment";
630 //$content .=
"</a>";
633 // some sort of patient appointment
634 $divTitle .=
"\r\n[".$catname .
"] ".$fname.
" ".$lname;
635 $content .=
"<span class='appointment".$apptToggle.
"'>";
636 //$content .=
"<a href='javascript:oldEvt($eventdate,$eventid)' title='$catname'>";
637 $content .= $dispstarth . ':' . $startm;
638 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'>";
639 $content .= htmlspecialchars($event['apptstatus']);
640 //$content .=
"</a>";
642 // include patient name and link to their details
643 $content .=
"<a href='javascript:goPid($patientid)' title='$title'>";
644 $iTitle =
"View Patient [".$fname.
" ".$lname.
"]";
645 $content .=
"<img src='$TPL_IMAGE_PATH/user-green.gif' border='0' title='".$iTitle.
"' alt='".$iTitle.
"' />";
647 if ($catid ==
1) $content .=
"<strike>";
649 if ($GLOBALS['calendar_appt_style'] !=
1) {
650 $content .=
"," . $fname;
651 if ($event['title'] && $GLOBALS['calendar_appt_style']
>=
3) {
652 $content .=
"(" . $event['title'];
653 if ($event['hometext'] && $GLOBALS['calendar_appt_style']
>=
4)
654 $content .=
": <font color='green'>" . htmlspecialchars(trim($event['hometext'])) .
"</font>";
658 if ($catid ==
1) $content .=
"</strike>";
663 // no patient id, just output the category name
664 $content .= $catname;
666 $content .=
"</span>";
669 $divTitle .=
"\n(double click to edit)";
671 // output the DIV and content
672 echo
"<div class='".$evtClass.
" event' style='top:".$evtTop.
"; height:".$evtHeight.
673 "; background-color:".$event[
"catcolor"].
676 "' title='".$divTitle.
"'".
677 " id='".$eventdate.
"-".$eventid.
"'".
695 // [-include
file=
"$TPL_NAME/views/global/footer.html"-]
696 // [-include
file=
"$TPL_NAME/views/footer.html"-]
699 </div> <!-- end bigCal DIV -->
703 <script language='JavaScript'
>
705 $(document
).ready(function(){
706 $("#pc_username").change(function() { ChangeProviders(this); });
707 $("#pc_facility").change(function() { ChangeProviders(this); });
708 $("#dayview").click(function() { ChangeView(this); });
709 //$("#weekview").click(function() { ChangeView(this); });
710 $("#monthview").click(function() { ChangeView(this); });
711 //$("#yearview").click(function() { ChangeView(this); });
712 $(".tdDatePicker").click(function() { ChangeDate(this); });
713 $("#datePicker .trDateRow").mouseover(function() { $(this).children().toggleClass("tdDatePickerHighlight"); });
714 $("#datePicker .trDateRow").mouseout(function() { $(this).children().toggleClass("tdDatePickerHighlight"); });
715 $("#datePicker .tdNav").mouseover(function() { $(this).toggleClass("tdDatePickerHighlight"); });
716 $("#datePicker .tdNav").mouseout(function() { $(this).toggleClass("tdDatePickerHighlight"); });
717 $("#printview").click(function() { PrintView(this); });
718 $(".event").dblclick(function() { EditEvent(this); });
719 $(".event").mouseover(function() { $(this).toggleClass("event_highlight"); });
720 $(".event").mouseout(function() { $(this).toggleClass("event_highlight"); });
723 /* edit an existing event */
724 var EditEvent = function(eObj
) {
725 //alert ('editing '+eObj.id);
726 // split the object ID into date and event ID
728 var parts
= new Array();
729 parts
= objID
.split("-");
730 // call the oldEvt function to bring up the event editor
731 oldEvt(parts
[0], parts
[1]);
735 /* change the current date based upon what the user clicked in
738 var ChangeDate = function(eObj
) {
739 baseURL
= "[-php-]echo pnModURL(__POSTCALENDAR__,'user','view',
740 array('tplview'=>$template_view,
741 'viewtype'=>$viewtype,
742 'Date'=> '~REPLACEME~',
743 'pc_username'=>$pc_username,
744 'pc_category'=>$category,
745 'pc_topic'=>$topic));[-/php-]";
746 newURL
= baseURL
.replace(/~REPLACEME~/, eObj
.id
);
747 document
.location
.href
=newURL
;
750 /* pop up a window to print the current view
752 var PrintView = function (eventObject
) {
753 printURL
= "[-php-]echo pnModURL(__POSTCALENDAR__,'user','view',
754 array('tplview'=>$template_view,
755 'viewtype'=>$viewtype,
758 'pc_username'=>$pc_username,
759 'pc_category'=>$category,
760 'pc_topic'=>$topic));[-/php-]";
761 window
.open(printURL
,'printwindow','width=740,height=480,toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,copyhistory=no,resizable=yes');
765 /* change the provider(s)
767 var ChangeProviders = function (eventObject
) {
768 $('#theform').submit();
771 /* change the calendar view
773 var ChangeView = function (eventObject
) {
774 if (eventObject
.id
== "dayview") {
775 $("#viewtype").val('day');
777 else if (eventObject
.id
== "weekview") {
778 $("#viewtype").val('week');
780 else if (eventObject
.id
== "monthview") {
781 $("#viewtype").val('month');
783 else if (eventObject
.id
== "yearview") {
784 $("#viewtype").val('year');
786 $('#theform').submit();