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
[-php
-]
38 if(isset($_SESSION
[pid
]))
42 echo
"+'&patientid=$_SESSION[pid]'";
49 function oldEvt(eventdate
, eventid
, pccattype
) {
50 dlgopen('add_edit_event.php?date='+eventdate
+'&eid=' + eventid
+'&prov=' + pccattype
, '_blank', 575, 375);
56 if ($GLOBALS
['concurrent_layout'])
59 echo
" top.RTop.location = '../../patient_file/summary/demographics.php' " .
60 "+ '?set_pid=' + pid;\n";
64 echo
" top.location = '../../patient_file/patient_file.php' " .
65 "+ '?set_pid=' + pid + '&pid=' + pid;\n";
70 function GoToToday(theForm
){
71 var todays_date
= new Date();
72 var theMonth
= todays_date
.getMonth() + 1;
73 theMonth
= theMonth
< 10 ? "0" + theMonth
: theMonth
;
74 theForm
.jumpdate
.value
= todays_date
.getFullYear() + "-" + theMonth
+ "-" + todays_date
.getDate();
83 // this is my proposed setting in the globals config file so we don't
84 // need to mess with altering the pn database AND the config file
85 //pnModSetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek', $GLOBALS['schedule_dow_start']);
87 // build a day-of-week (DOW) list so we may properly build the calendars later in this code
89 $tmpDOW = pnModGetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek');
90 // bound check and auto-correction
91 if ($tmpDOW
<0 || $tmpDOW
>6) {
92 pnModSetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek', '
0');
95 while (count($DOWlist) <
7) {
96 array_push($DOWlist, $tmpDOW);
98 if ($tmpDOW
> 6) $tmpDOW =
0;
101 // A_CATEGORY is an ordered array of associative-array categories.
102 // Keys of interest are: id, name, color, desc, event_duration.
104 // echo
"<!-- A_CATEGORY = "; print_r($this-
>_tpl_vars['A_CATEGORY']); echo
" -->\n"; // debugging
105 // echo
"<!-- A_EVENTS = "; print_r($this-
>_tpl_vars['A_EVENTS']); echo
" -->\n"; // debugging
107 $A_CATEGORY =& $this-
>_tpl_vars['A_CATEGORY'];
109 // [-if $PRINT_VIEW !=
1-]
110 // [-*Main Navigation*-]
111 // [-include
file=
"$TPL_NAME/views/global/navigation.html"-]
114 $A_EVENTS =& $this-
>_tpl_vars['A_EVENTS'];
115 // $S_EVENTS =& $this-
>_tpl_vars['S_EVENTS']; // Deleted by Rod
116 $providers =& $this-
>_tpl_vars['providers'];
117 $times =& $this-
>_tpl_vars['times'];
118 $interval = $this-
>_tpl_vars['interval'];
119 $viewtype = $this-
>_tpl_vars['VIEW_TYPE'];
120 $PREV_WEEK_URL = $this-
>_tpl_vars['PREV_WEEK_URL'];
121 $NEXT_WEEK_URL = $this-
>_tpl_vars['NEXT_WEEK_URL'];
122 $PREV_DAY_URL = $this-
>_tpl_vars['PREV_DAY_URL'];
123 $NEXT_DAY_URL = $this-
>_tpl_vars['NEXT_DAY_URL'];
125 $Date = postcalendar_getDate();
126 if (!isset($y)) $y = substr($Date,
0,
4);
127 if (!isset($m)) $m = substr($Date,
4,
2);
128 if (!isset($d)) $d = substr($Date,
6,
2);
130 // echo
"<!-- There are " . count($A_EVENTS) .
" A_EVENTS days -->\n";
132 $MULTIDAY = count($A_EVENTS)
> 1;
134 //==================================
135 //FACILITY FILTERING (CHEMED)
136 $facilities = getUserFacilities($_SESSION['authId']); // from users_facility
137 if ( $_SESSION['pc_facility'] ) {
138 $provinfo = getProviderInfo('%', true, $_SESSION['pc_facility']);
140 $provinfo = getProviderInfo();
142 //EOS FACILITY FILTERING (CHEMED)
143 //==================================
146 <div id=
"topToolbarRight"> <!-- this wraps some of the top toolbar items -->
148 <!-- stuff form element here to avoid the margin padding it introduces into the page in some browsers -->
149 <form name='theform' id='theform' action='index.php?module=PostCalendar&func=view&tplview=default&pc_category=&pc_topic=' method='post' onsubmit='return top.restoreSession()'
>
150 <input type=
"hidden" name=
"jumpdate" id=
"jumpdate" value=
"">
151 <input type=
"hidden" name=
"viewtype" id=
"viewtype" value=
"[-php-]echo $viewtype;[-/php-]">
153 echo
" <a href='#' value='" .xl (
"Add").
"' onclick='newEvt(1, 9, 00, $Date, 0, 0)' class='css_button'/><span>".xl(
"Add").
"</span></a>\n";
154 echo
" <a href='#' value='" . xl (
"Search") .
155 "' onclick='top.restoreSession();location=\"index.php?module=PostCalendar&func=search\
"' class='css_button'/><span>".xl(
"Search").
"</span></a>\n";
161 <a href='#' name='bnsubmit' value='[-php-]echo xl ("Today
")[-/php-]' onClick='GoToToday(theform);' class='css_button'/><span>[-php-] echo xl("Today
")[-/php-]</span></a>
162 <a href='[-php-]echo $PREV_DAY_URL[-/php-]' onclick='top.restoreSession()'>
163 <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>
164 <a href='[-php-]echo $NEXT_DAY_URL[-/php-]' onclick='top.restoreSession()'>
165 <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>
168 $atmp = array_keys($A_EVENTS);
169 echo dateformat (strtotime($atmp[0]),true);
173 <div id="viewPicker
">
175 echo " <a href='#' type='button' id='printview' title='
" .xl ("Print View
"). "' class='css_button'
/><span>" . xlt("View Printable Version
") . "</span></a>\n
";
176 echo " <a href='#' type='button' value='
" .xl ("Refresh
"). "' onclick='javascript:refreshme()' class='css_button'
/><span>".xl("Refresh
")."</span></a>\n
";
177 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
";
178 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
";
179 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
";
182 </div> <!-- end topToolbarRight -->
184 <div id="bottomLeft
">
185 <div id="datePicker
">
187 $atmp = array_keys($A_EVENTS);
188 $caldate = strtotime($atmp[0]);
189 $cMonth = date("m
", $caldate);
190 $cYear = date("Y
", $caldate);
191 $cDay = date("d
", $caldate);
193 include_once($GLOBALS['webserver_root'].'/interface/main/calendar/modules/PostCalendar/pntemplates/default/views/monthSelector.php');
195 <table border="0" cellpadding="0" cellspacing="0">
199 // compute the previous month date
200 // stay on the same day if possible
202 $pMonth = $cMonth - 1;
204 if ($pMonth < 1) { $pMonth = 12; $pYear = $cYear - 1; }
205 while (! checkdate($pMonth, $pDay, $pYear)) { $pDay = $pDay - 1; }
206 $prevMonth = sprintf("%d%
02d%
02d
",$pYear,$pMonth,$pDay);
208 // compute the next month
209 // stay on the same day if possible
211 $nMonth = $cMonth + 1;
213 if ($nMonth > 12) { $nMonth = 1; $nYear = $cYear + 1; }
214 while (! checkdate($nMonth, $nDay, $nYear)) { $nDay = $nDay - 1; }
215 $nextMonth = sprintf("%d%
02d%
02d
",$nYear,$nMonth,$nDay);
217 <td class="tdDOW-small tdDatePicker
" id="[-php-]echo $prevMonth[-/php-]
" title="[-php-]echo xl(date(
"F", strtotime($prevMonth)));[-/php-]
"><</td>
218 <td colspan="5" class="tdMonthName-small
">
220 echo xl(date('F', $caldate));
223 <td class="tdDOW-small tdDatePicker
" id="[-php-]echo $nextMonth[-/php-]
" title="[-php-]echo xl(date(
"F", strtotime($nextMonth)));[-/php-]
">></td>
226 foreach ($DOWlist as $dow) {
227 echo "<td class='tdDOW-small'
>".$this->_tpl_vars['A_SHORT_DAY_NAMES'][$dow]."</td>";
232 $atmp = array_keys($A_EVENTS);
233 $caldate = strtotime($atmp[0]);
234 $caldateEnd = strtotime($atmp[6]);
236 // to make a complete week row we need to compute the real
237 // start and end dates for the view
238 list ($year, $month, $day) = explode(" ", date('Y m d', $caldate));
239 $startdate = strtotime($year.$month."01");
240 $enddate = strtotime($year.$month.date("t
", $startdate)." 23:
59");
241 while (date('w', $startdate) != $DOWlist[0]) { $startdate -= 60*60*24; }
242 while (date('w', $enddate) != $DOWlist[6]) { $enddate += 60*60*24; }
244 $currdate = $startdate;
245 while ($currdate <= $enddate) {
246 if (date('w', $currdate) == $DOWlist[0]) {
253 $tdClass = "tdMonthDay-small
";
254 if (date('m', $currdate) != $month) {
255 $tdClass = "tdOtherMonthDay-small
";
257 if ((date('w', $currdate) == 0) || (date('w', $currdate) == 6)) {
258 $tdClass = "tdWeekend-small
";
261 if (date('Ymd',$currdate) == $Date) {
262 // $Date is defined near the top of this file
263 // and is equal to whatever date the user has clicked
264 $tdClass .= " currentDate
";
267 // add a class so that jQuery can grab these days for the 'click' event
268 $tdClass .= " tdDatePicker
";
272 $td .= "class=\
"".$tdClass.
"\" ";
273 //$td .= "id=\
"".date(
"Ymd", $currdate).
"\" ";
274 $td .= "id=\
"".date(
"Ymd", $currdate).
"\" ";
275 $td .= "title=\
"" . xl('Go to') .
" ".date('M d, Y', $currdate).
"\" ";
276 $td .= "> ".date('d', $currdate)."</td>\n
";
280 if (date('w', $currdate) == $DOWlist[6]) echo "</tr>\n
";
282 // time correction = plus 1000 seconds, for some unknown reason
283 //$currdate += (60*60*24)+1000;
286 $currdate = strtotime("+
1 day
", $currdate);
293 <div id="bigCalHeader
">
296 <div id="providerPicker
">
297 [-php-] xl('Providers','e'); [-/php-]
300 // ==============================
301 // FACILITY FILTERING (lemonsoftware)
302 /*********************************************************************
303 $facilities = getFacilities();
304 *********************************************************************/
305 if ($_SESSION['authorizeduser'] == 1) {
306 $facilities = getFacilities();
308 $facilities = getUserFacilities($_SESSION['authId']); // from users_facility
309 if (count($facilities) == 1)
310 $_SESSION['pc_facility'] = key($facilities);
312 /********************************************************************/
313 if (count($facilities) > 1) {
314 echo " <select name='pc_facility' id='pc_facility' class='view1'
>\n
";
315 if ( !$_SESSION['pc_facility'] ) $selected = "selected='selected'
";
316 // echo " <option value='
0' $selected
>" .xl('All Facilities'). "</option>\n
";
317 if (!$GLOBALS['restrict_user_facility']) echo " <option value='
0' $selected
>" . xl('All Facilities') . "</option>\n
";
318 foreach ($facilities as $fa) {
319 $selected = ( $_SESSION['pc_facility'] == $fa['id']) ? "selected='selected'
" : "" ;
320 echo " <option style=background-color:
".htmlspecialchars($fa['color'],ENT_QUOTES)." value='
" .htmlspecialchars($fa['id'],ENT_QUOTES). "' $selected
>" .htmlspecialchars($fa['name'],ENT_QUOTES). "</option>\n
";
325 // ==============================
327 echo " <select multiple size='
5' name='pc_username[]' id='pc_username' class='view2'
>\n
";
328 echo " <option value='__PC_ALL__'
>" .xl ("All Users
"). "</option>\n
";
329 foreach ($provinfo as $doc) {
330 $username = $doc['username'];
331 echo " <option value='$username'
";
332 foreach ($providers as $provider)
333 if ($provider['username'] == $username) echo " selected
";
334 echo ">" . htmlspecialchars($doc['lname'],ENT_QUOTES) . ",
" . htmlspecialchars($doc['fname'],ENT_QUOTES) . "</option>\n
";
341 if($_SESSION['pc_facility'] == 0){
343 <div id="facilityColor
">
346 foreach ($facilities as $f){
347 echo " <tr><td><div class='view1' style=background-color:
".$f['color'].";font-weight:bold
>".htmlspecialchars($f['name'],ENT_QUOTES)."</div></td></tr>";
358 [-assign var="dayname
" value=$DATE|date_format:"%w
"-]
359 [-assign var="day
" value=$DATE|date_format:"%d
"|string_format:"%
1d
"-]
360 [-assign var="month
" value=$DATE|date_format:"%m
"|string_format:"%
1d
"-]
361 [-assign var="year
" value=$DATE|date_format:"%Y
"|string_format:"%
4d
"-]
363 [-pc_sort_events var="S_EVENTS
" sort="time
" order="asc
" value=$A_EVENTS-]
364 </div> <!-- end bottomLeft -->
368 echo "<table border='
0' cellpadding='
1' cellspacing='
0' width='
100%'
>\n
";
370 // output the TD with the times DIV
372 echo "<td id='times'
><div><table>\n
";
373 echo "<td class='timeslot'
> </td>";
374 //============================================================================================================================
375 foreach ($times as $slottime) {
376 $startampm = ($slottime['mer']) == "pm
" ? 2 : 1;
377 $starttimeh = $slottime['hour'];
378 $disptimeh = ($starttimeh > 12) ? ($starttimeh - 12) : $starttimeh;
379 $starttimem = $slottime['minute'];
380 $slotendmins = $starttimeh * 60 + $starttimem + $interval;
382 // default to the first displayed provider
383 $providerid = $providers[0]['id'];
385 echo "<tr><td class='timeslot'
>";
386 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). "'
>";
387 echo "$disptimeh:$starttimem
";
391 echo "</table></div></td>";
394 // This loops once for each provider to be displayed.
396 foreach ($providers as $provider) {
397 $providerid = $provider['id'];
399 // to specially handle the IN/OUT events I'm doing something new here
400 // for each IN event it will have a duration lasting until the next
401 // OUT event or until the end of the day
402 $tmpTime = $times[0];
403 $calStartMin = ($tmpTime['hour'] * 60) + $tmpTime['minute'];
404 $tmpTime = $times[count($times)-1];
405 $calEndMin = ($tmpTime['hour'] * 60) + $tmpTime['minute'];
407 // having a 'title' for the TD makes the date appear by the mouse pointer
408 // this is nice when all you see are times on the left side and no head
409 // row with the dates or day-of-week (DOW)
410 echo "<td class='schedule' title='
".htmlspecialchars($provider["fname
"],ENT_QUOTES)." ".htmlspecialchars($provider["lname
"],ENT_QUOTES)."' date='
".date("Ymd
",$caldate )."' provider='$providerid'
>";
411 echo "<div class='providerheader'
>";
412 echo htmlspecialchars($provider['fname'],ENT_QUOTES)." ".htmlspecialchars($provider['lname'],ENT_QUOTES)."</div>";
413 echo "<div class='calendar_day'
>";
416 // output a TD with an inner containing DIV positioned 'relative'
417 // within that DIV we place our event DIVs using 'absolute' positioning
418 foreach ($A_EVENTS as $date => $events) {
419 $eventdate = substr($date, 0, 4) . substr($date, 5, 2) . substr($date, 8, 2);
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) {
435 if (($e1['catid'] == 2)) { continue; }
437 // skip events without an ID (why they are in the loop, I have no idea)
438 if ($e1['eid'] == "") { continue; }
440 // skip events for other providers
441 if ($providerid != $e1['aid']) { continue; }
443 // specially handle all-day events
444 if ($e1['alldayevent'] == 1) {
445 $tmpTime = $times[0];
446 if (strlen($tmpTime['hour']) < 2) { $tmpTime['hour'] = "0".$tmpTime['hour']; }
447 if (strlen($tmpTime['minute']) < 2) { $tmpTime['minute'] = "0".$tmpTime['minute']; }
448 $e1['startTime'] = $tmpTime['hour'].":
".$tmpTime['minute'].":
00";
449 $e1['duration'] = ($calEndMin - $calStartMin) * 60; // measured in seconds
452 // create a numeric start and end for comparison
453 $starth = substr($e1['startTime'], 0, 2);
454 $startm = substr($e1['startTime'], 3, 2);
455 $e1Start = ($starth * 60) + $startm;
456 $e1End = $e1Start + $e1['duration']/60;
458 // three ways to overlap:
459 // start-in, end-in, span
460 if ((($e1Start >= $slotstartmins) && ($e1Start < $slotendmins)) // start-in
461 || (($e1End > $slotstartmins) && ($e1End <= $slotendmins)) // end-in
462 || (($e1Start < $slotstartmins) && ($e1End > $slotendmins))) // span
464 array_push($events_in_timeslot, $e1['eid']);
465 if($e1['catid'] == 3)
467 array_pop($events_in_timeslot);
468 array_unshift($events_in_timeslot, $e1['eid']);
474 $width = 100 / count($events_in_timeslot);
476 // loop over the events in this timeslot and adjust their width
477 foreach ($events_in_timeslot as $eid) {
478 // set the width if not already set or if the current width is smaller
479 // than was was previously set
480 if (!isset($eventPositions[$eid]->width))
482 $eventPositions[$eid]->width = $width;
483 } else if ($eventPositions[$eid]->width > $width)
485 $eventPositions[$eid]->width = $width;
488 // set the left position if not already set or if the current left is
489 // greater than what was previously set
490 if (!isset($eventPositions[$eid]->leftpos))
492 $eventPositions[$eid]->leftpos = $leftpos;
493 } else if ($eventPositions[$eid]->leftpos < $leftpos)
495 $eventPositions[$eid]->leftpos = $leftpos;
498 // increment the leftpos by the width
501 } // end overlap detection
503 // now loop over the events for the day and output their DIVs
504 foreach ($events as $event) {
505 // skip events for other providers
506 // yeah, we've got that sort of overhead here... it ain't perfect
507 if ($providerid != $event['aid']) { continue; }
509 // skip events without an ID (why they are in the loop, I have no idea)
510 if ($event['eid'] == "") { continue; }
512 // specially handle all-day events
513 if ($event['alldayevent'] == 1) {
514 $tmpTime = $times[0];
515 if (strlen($tmpTime['hour']) < 2) { $tmpTime['hour'] = "0".$tmpTime['hour']; }
516 if (strlen($tmpTime['minute']) < 2) { $tmpTime['minute'] = "0".$tmpTime['minute']; }
517 $event['startTime'] = $tmpTime['hour'].":
".$tmpTime['minute'].":
00";
518 $event['duration'] = ($calEndMin - $calStartMin) * 60; // measured in seconds
521 // figure the start time and minutes (from midnight)
522 $starth = substr($event['startTime'], 0, 2);
523 $startm = substr($event['startTime'], 3, 2);
524 $eStartMin = $starth * 60 + $startm;
525 $dispstarth = ($starth > 12) ? ($starth - 12) : $starth; // used to display the hour
527 // determine the class for the event DIV based on the event category
528 $evtClass = "event_appointment
";
529 switch ($event['catid']) {
530 case 1: // NO-SHOW appt
531 $evtClass = "event_noshow
";
534 $evtClass = "event_in
";
536 case 3: // OUT of office
537 $evtClass = "event_out
";
542 $evtClass = "event_reserved
";
544 default: // some appointment
545 $evtClass = "event_appointment
";
549 // if this is an IN or OUT event then we have some extra special
550 // processing to be done
551 // the IN event creates a DIV until the OUT event
552 // or, without an OUT DIV matching the IN event
553 // then the IN event runs until the end of the day
554 if ($event['catid'] == 2) {
555 // locate a matching OUT for this specific IN
558 foreach ($events as $outevent) {
559 // skip events for other providers
560 if ($providerid != $outevent['aid']) { continue; }
561 // skip events with blank IDs
562 if ($outevent['eid'] == "") { continue; }
564 if ($outevent['eid'] == $event['eid']) { $found = true; continue; }
565 if (($found == true) && ($outevent['catid'] == 3)) {
566 // calculate the duration from this event to the outevent
567 $outH = substr($outevent['startTime'], 0, 2);
568 $outM = substr($outevent['startTime'], 3, 2);
569 $outMins = ($outH * 60) + $outM;
570 $event['duration'] = ($outMins - $eStartMin) * 60; // duration is in seconds
576 // no OUT was found so this event's duration goes
577 // until the end of the day
578 $event['duration'] = ($calEndMin - $eStartMin) * 60; // duration is in seconds
582 // calculate the TOP value for the event DIV
583 // diff between event start and schedule start
584 $eMinDiff = $eStartMin - $calStartMin;
585 // diff divided by the time interval of the schedule
586 $eStartInterval = $eMinDiff / $interval;
587 // times the interval height
588 $eStartPos = $eStartInterval * $timeslotHeightVal;
589 $evtTop = $eStartPos.$timeslotHeightUnit;
591 // calculate the HEIGHT value for the event DIV
592 // diff between end and start of event
593 $eEndMin = $eStartMin + ($event['duration']/60);
594 // prevent the overall height of the event from going beyond the bounds
596 if ($eEndMin > $calEndMin) { $eEndMin = $calEndMin + $interval; }
597 $eMinDiff = $eEndMin - $eStartMin;
598 // diff divided by the time interval of the schedule
599 $eEndInterval = $eMinDiff / $interval;
600 // times the interval height
601 $eHeight = $eEndInterval * $timeslotHeightVal;
602 if($event['catid']==3)
604 // An "OUT
" that is "zero duration
" still needs height so we can click it.
605 $eHeight = $eEndInterval==0 ? $timeslotHeightVal : $eHeight ;
607 $evtHeight = $eHeight.$timeslotHeightUnit;
609 // determine the DIV width based on any overlapping events
610 // see further above for the overlapping calculation code
613 if (isset($eventPositions[$event['eid']])) {
614 $divWidth = "width:
".$eventPositions[$event['eid']]->width."%
";
615 $divLeft = "left:
".$eventPositions[$event['eid']]->leftpos."%
";
618 $eventid = $event['eid'];
619 $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."'
");
621 if($eventtype['pc_cattype']==1)
623 $patientid = $event['pid'];
624 $commapos = strpos($event['patient_name'], ",
");
625 $lname = substr($event['patient_name'], 0, $commapos);
626 $fname = substr($event['patient_name'], $commapos + 2);
627 $patient_dob = $event['patient_dob'];
628 $patient_age = $event['patient_age'];
629 $catid = $event['catid'];
630 $comment = addslashes($event['hometext']);
631 $catname = $event['catname'];
632 $title = "Age $patient_age ($patient_dob)
";
636 if ($comment && $GLOBALS['calendar_appt_style'] < 4) $title .= " " . $comment;
638 // the divTitle is what appears when the user hovers the mouse over the DIV
639 $divTitle = htmlspecialchars($provider["fname
"],ENT_QUOTES)." ".htmlspecialchars($provider["lname
"],ENT_QUOTES);
640 $result = sqlStatement("SELECT name,id,color FROM facility WHERE id=(SELECT pc_facility FROM openemr_postcalendar_events WHERE
pc_eid=
".$eventid.")
");
641 $row = sqlFetchArray($result);
642 $color=$event["catcolor
"];
643 if($GLOBALS['event_color']==2)
644 $color=$row['color'];
645 $divTitle .= "\n
" .htmlspecialchars($row['name'],ENT_QUOTES);
647 if ($catid == 2 || $catid == 3 || $catid == 4 || $catid == 8 || $catid == 11) {
648 if ($catid == 2) $catname = xl("IN
");
649 else if ($catid == 3) $catname = xl("OUT
");
650 else if ($catid == 4) $catname = xl("VACATION
");
651 else if ($catid == 8) $catname = xl("LUNCH
");
652 else if ($catid == 11) $catname = xl("RESERVED
");
655 if ($comment) $atitle .= " $comment
";
656 $divTitle .= "\n[
".$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='
".htmlspecialchars(xl("Repeating event
"),ENT_QUOTES)."' alt='
".htmlspecialchars(xl("Repeating event
"),ENT_QUOTES)."'
>";
659 if ($comment) $content .= " $comment
";
662 // some sort of patient appointment
663 $divTitle .= "\r\n[
".$catname.' '.htmlspecialchars($comment, ENT_QUOTES) ."]
".htmlspecialchars($fname, ENT_QUOTES)." ".htmlspecialchars($lname, ENT_QUOTES);
664 $content .= "<span class='appointment'
>";
665 $content .= create_event_time_anchor($dispstarth.":
".$startm);
666 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)."'
>";
667 // $content .= htmlspecialchars($event['apptstatus']);
668 $content .= ' '.htmlspecialchars($event['apptstatus']);
670 $link_title = htmlspecialchars($fname,ENT_QUOTES)." ".htmlspecialchars($lname,ENT_QUOTES). " \n
";
671 $link_title .= xl('Age') . ":
".$patient_age."\n
" . xl('DOB') . ":
".$patient_dob.htmlspecialchars($comment, ENT_QUOTES)."\n
";
672 $link_title .= "(
" . xl('Click to view') . ")
";
673 $content .= "<a href='javascript:goPid($patientid)' title='$link_title'
>";
674 $content .= "<img src='$TPL_IMAGE_PATH/user-green.gif' border='
0' title='$link_title' alt='View Patient'
/>";
675 if ($catid == 1) $content .= "<strike>";
676 $content .= htmlspecialchars($lname);
677 if ($GLOBALS['calendar_appt_style'] != 1) {
678 $content .= ",
" . htmlspecialchars($fname);
679 if ($event['title'] && $GLOBALS['calendar_appt_style'] >= 3) {
680 $content .= "(
" . $event['title'];
681 if ($event['hometext'] && $GLOBALS['calendar_appt_style'] >= 4)
682 $content .= ":
<font color='green'
>" . htmlspecialchars(trim($event['hometext'])) . "</font>";
686 if ($catid == 1) $content .= "</strike>";
690 // no patient id, just output the category name
691 $content .= $catname;
693 $content .= "</span>";
696 $divTitle .= "\n(
" . xl('double click to edit') . ")
";
698 if($_SESSION['pc_facility'] == 0){
699 // a special case for the 'IN' event this puts the time ABOVE
700 // the normal DIV so it doesn't overlap another event DIV and include the time
701 if ($event['catid'] == 2) {
702 $inTop = ($eStartPos - $timeslotHeightVal).$timeslotHeightUnit;
703 echo "<div class='
".$evtClass." event in_start' style='top:
".$inTop.
704 "; height:
".$timeslotHeightVal.$timeslotHeightUnit.
708 "' title='
".$divTitle."'
".
709 " id='
".$eventdate."-
".$eventid."-
".$pccattype."'
".
711 $content = $dispstarth . ':' . $startm . " " . $content;
716 // output the DIV and content
717 // For "OUT
" events, applying the background color in CSS.
718 $background_string= ($event['catid'] == 3) ? "" : "; background-color:
".$color;
719 echo "<div class='
".$evtClass." event' style='top:
".$evtTop."; height:
".$evtHeight.
723 "' title='
".$divTitle."'
".
724 " id='
".$eventdate."-
".$eventid."-
".$pccattype."'
".
726 // second part for the special IN event
727 if ($event['catid'] != 2) { echo $content; }
730 elseif($_SESSION['pc_facility'] == $row['id']){
731 if ($event['catid'] == 2) {
732 $inTop = ($eStartPos - $timeslotHeightVal).$timeslotHeightUnit;
733 echo "<div class='
".$evtClass." event in_start' style='top:
".$inTop.
734 "; height:
".$timeslotHeightVal.$timeslotHeightUnit.
738 "' title='
".$divTitle."'
".
739 " id='
".$eventdate."-
".$eventid."-
".$pccattype."'
".
741 $content = $dispstarth . ':' . $startm . " " . $content;
746 // output the DIV and content
747 // For "OUT
" events, applying the background color in CSS.
748 $background_string= ($event['catid'] == 3) ? "" : "; background-color:
".$event["catcolor
"];
749 echo "<div class='
".$evtClass." event' style='top:
".$evtTop."; height:
".$evtHeight.
753 "' title='
".$divTitle."'
".
754 " id='
".$eventdate."-
".$eventid."-
".$pccattype."'
".
756 // second part for the special IN event
757 if ($event['catid'] != 2) { echo $content; }
762 if ($event['catid'] == 2) {
763 $inTop = ($eStartPos - $timeslotHeightVal).$timeslotHeightUnit;
764 echo "<div class='
".$evtClass." event in_start' style='top:
".$inTop.
765 "; height:
".$timeslotHeightVal.$timeslotHeightUnit.
768 "; background:#DDDDDD
".
770 "' title='
".$divTitle."'
".
771 " id='
".$eventdate."-
".$eventid."-
".$pccattype."'
".
773 $content = "<span style='color:red;text-align:center;font-weight:bold'
>".htmlspecialchars($row['name'],ENT_QUOTES)."</span>";
778 // output the DIV and content
779 echo "<div class='
".$evtClass." event' style='top:
".$evtTop."; height:
".$evtHeight.
780 "; background-color:#DDDDDD
".
783 "' title='
".$divTitle."'
".
784 " id='
".$eventdate."-
".$eventid."-
".$pccattype."'
".
786 // second part for the special IN event
787 if ($event['catid'] != 2) { echo "<span style='color:red;text-align:center;font-weight:bold'
>".htmlspecialchars($row['name'],ENT_QUOTES)."</span>"; }
798 } // end provider loop
799 //============================================================================================================================
805 // [-include file="$TPL_NAME/views/global/footer.html
"-]
806 // [-include file="$TPL_NAME/views/footer.html
"-]
809 </div> <!-- end bigCal DIV -->
810 </div> <!-- end bottom DIV -->
813 <script language='JavaScript'>
814 var tsHeight='[-php-] echo $timeslotHeightVal.$timeslotHeightUnit; [-/php-]';
815 var tsHeightNum=[-php-] echo $timeslotHeightVal; [-/php-];
817 $(document).ready(function(){
819 $("#pc_username
").change(function() { ChangeProviders(this); });
820 $("#pc_facility
").change(function() { ChangeProviders(this); });
821 //$("#dayview
").click(function() { ChangeView(this); });
822 $("#weekview
").click(function() { ChangeView(this); });
823 $("#monthview
").click(function() { ChangeView(this); });
824 //$("#yearview
").click(function() { ChangeView(this); });
825 $(".tdDatePicker
").click(function() { ChangeDate(this); });
826 $(".tdDatePicker
").mouseover(function() { $(this).toggleClass("tdDatePickerHighlight
"); });
827 $(".tdDatePicker
").mouseout(function() { $(this).toggleClass("tdDatePickerHighlight
"); });
828 $("#printview
").click(function() { PrintView(this); });
829 $(".event
").dblclick(function() { EditEvent(this); });
830 $(".event
").mouseover(function() { $(this).toggleClass("event_highlight
"); });
831 $(".event
").mouseout(function() { $(this).toggleClass("event_highlight
"); });
832 $(".tdMonthName
-small
").click(function() {
834 dpCal=$("#datePicker
>table
");
835 mp = $("#monthPicker
"); mp.width(dpCal.width()); mp.toggle();});
838 /* edit an existing event */
839 var EditEvent = function(eObj) {
840 //alert ('editing '+eObj.id);
841 // split the object ID into date and event ID
843 var parts = new Array();
844 parts = objID.split("-");
845 // call the oldEvt function to bring up the event editor
846 oldEvt(parts[0], parts[1], parts[2]);
850 /* change the current date based upon what the user clicked in
853 var ChangeDate = function(eObj) {
854 baseURL = "[-php
-]echo
pnModURL(__POSTCALENDAR__
,'user','view',
855 array('tplview'=>$template_view
,
856 'viewtype'=>$viewtype
,
857 'Date'=> '~REPLACEME~',
858 'pc_username'=>$pc_username
,
859 'pc_category'=>$category
,
860 'pc_topic'=>$topic
));[-/php
-]";
861 newURL = baseURL.replace(/~REPLACEME~/, eObj.id);
862 document.location.href=newURL;
865 /* pop up a window to print the current view
867 var PrintView = function (eventObject) {
868 printURL = "[-php
-]echo
pnModURL(__POSTCALENDAR__
,'user','view',
869 array('tplview'=>$template_view
,
870 'viewtype'=>$viewtype
,
873 'pc_username'=>$pc_username
,
874 'pc_category'=>$category
,
875 'pc_topic'=>$topic
));[-/php
-]";
876 window.open(printURL,'printwindow','width=740,height=480,toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,copyhistory=no,resizable=yes');
880 /* change the provider(s)
882 var ChangeProviders = function (eventObject) {
883 $('#theform').submit();
886 /* change the calendar view
888 var ChangeView = function (eventObject) {
889 if (eventObject.id == "dayview
") {
890 $("#viewtype
").val('day');
892 else if (eventObject.id == "weekview
") {
893 $("#viewtype
").val('week');
895 else if (eventObject.id == "monthview
") {
896 $("#viewtype
").val('month');
898 else if (eventObject.id == "yearview
") {
899 $("#viewtype
").val('year');
901 $('#theform').submit();