separating facility from user maintenance, improved support for multiple facilities...
[openemr.git] / interface / main / calendar / modules / PostCalendar / pntemplates / default / views / day / ajax_template.html
blobf06d2cb87a80f9c8da3bf9e1a5fa7022894af82c
1 [-*Smarty*-]
2 [-*****************************************************************************-]
3 [-* Copyright (C) 2005-2006 Rod Roark <rod@sunsetsystems.com> and others *-]
4 [-* *-]
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*-]
16 [-php-]
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";
22 [-/php-]
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() {
30 top.restoreSession();
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,
38 '_blank', 550, 270);
41 function oldEvt(eventdate, eventid) {
42 dlgopen('add_edit_event.php?date='+eventdate+'&eid=' + eventid, '_blank', 550, 270);
45 function goPid(pid) {
46 top.restoreSession();
47 [-php-]
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";
54 } else
56 echo " top.RTop.location = '../../patient_file/summary/demographics.php' " .
57 "+ '?set_pid=' + pid;\n";
61 } else
63 echo " top.location = '../../patient_file/patient_file.php' " .
64 "+ '?set_pid=' + pid + '&pid=' + pid;\n";
66 [-/php-]
69 function GoToToday(theForm){
70 var todays_date = new Date();
71 var theMonth = todays_date.getMonth() + 1;
72 theMonth = theMonth < 10 ? "0" + theMonth : theMonth;
73 theForm.jumpdate.value = todays_date.getFullYear() + "-" + theMonth + "-" + todays_date.getDate();
74 top.restoreSession();
75 theForm.submit();
78 </script>
80 [-php-]
82 // this is my proposed setting in the globals config file so we don't
83 // need to mess with altering the pn database AND the config file
84 //pnModSetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek', $GLOBALS['schedule_dow_start']);
86 // build a day-of-week (DOW) list so we may properly build the calendars later in this code
87 $DOWlist = array();
88 $tmpDOW = pnModGetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek');
89 // bound check and auto-correction
90 if ($tmpDOW <0 || $tmpDOW >6) {
91 pnModSetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek', '0');
92 $tmpDOW = 0;
94 while (count($DOWlist) < 7) {
95 array_push($DOWlist, $tmpDOW);
96 $tmpDOW++;
97 if ($tmpDOW > 6) $tmpDOW = 0;
100 // A_CATEGORY is an ordered array of associative-array categories.
101 // Keys of interest are: id, name, color, desc, event_duration.
103 // echo "<!-- A_CATEGORY = "; print_r($this->_tpl_vars['A_CATEGORY']); echo " -->\n"; // debugging
104 // echo "<!-- A_EVENTS = "; print_r($this->_tpl_vars['A_EVENTS']); echo " -->\n"; // debugging
106 $A_CATEGORY =& $this->_tpl_vars['A_CATEGORY'];
108 // [-if $PRINT_VIEW != 1-]
109 // [-*Main Navigation*-]
110 // [-include file="$TPL_NAME/views/global/navigation.html"-]
111 // [-/if-]
113 $A_EVENTS =& $this->_tpl_vars['A_EVENTS'];
114 // $S_EVENTS =& $this->_tpl_vars['S_EVENTS']; // Deleted by Rod
115 $providers =& $this->_tpl_vars['providers'];
116 $times =& $this->_tpl_vars['times'];
117 $interval = $this->_tpl_vars['interval'];
118 $viewtype = $this->_tpl_vars['VIEW_TYPE'];
119 $PREV_WEEK_URL = $this->_tpl_vars['PREV_WEEK_URL'];
120 $NEXT_WEEK_URL = $this->_tpl_vars['NEXT_WEEK_URL'];
121 $PREV_DAY_URL = $this->_tpl_vars['PREV_DAY_URL'];
122 $NEXT_DAY_URL = $this->_tpl_vars['NEXT_DAY_URL'];
124 $Date = postcalendar_getDate();
125 if (!isset($y)) $y = substr($Date, 0, 4);
126 if (!isset($m)) $m = substr($Date, 4, 2);
127 if (!isset($d)) $d = substr($Date, 6, 2);
129 // echo "<!-- There are " . count($A_EVENTS) . " A_EVENTS days -->\n";
131 $MULTIDAY = count($A_EVENTS) > 1;
133 //==================================
134 //FACILITY FILTERING (CHEMED)
135 $facilities = getUserFacilities($_SESSION['authId']); // from users_facility
136 if (count($facilities) == 1 || !$_SESSION['pc_facility']) {
137 $_SESSION['pc_facility'] = $facilities[0]['id'];
139 if ( $_SESSION['pc_facility'] ) {
140 $provinfo = getProviderInfo('%', true, $_SESSION['pc_facility']);
141 } else {
142 $provinfo = getProviderInfo();
144 //EOS FACILITY FILTERING (CHEMED)
145 //==================================
147 [-/php-]
149 <div id="functions">
150 <!-- stuff form element here to avoid the margin padding it introduces into the page in some browsers -->
151 <form name='theform' id='theform' action='index.php?module=PostCalendar&func=view&tplview=default&pc_category=&pc_topic=' method='post' onsubmit='return top.restoreSession()'>
152 <input type="hidden" name="jumpdate" id="jumpdate" value="">
153 <input type="hidden" name="viewtype" id="viewtype" value="[-php-]echo $viewtype;[-/php-]">
154 [-php-]
155 echo " <input type='button' value='" .xl ("Add"). "' onclick='newEvt(1, 9, 00, $Date, 0, 0)' />\n";
156 echo " <input type='button' value='" . xl ("Search") .
157 "' onclick='top.restoreSession();location=\"index.php?module=PostCalendar&func=search\"' />\n";
158 [-/php-]
159 </div>
161 <div id="topToolbarRight"> <!-- this wraps some of the top toolbar items -->
163 <div id="dateNAV">
164 <a href='[-php-]echo $PREV_DAY_URL[-/php-]' onclick='top.restoreSession()'>
165 <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-]" /></a>
166 <a href='[-php-]echo $NEXT_DAY_URL[-/php-]' onclick='top.restoreSession()'>
167 <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 &nbsp;
169 <input type='submit' name='bnsubmit' value='[-php-]echo xl ("Today")[-/php-]' onClick='GoToToday(theform);' />
170 </div>
172 <div id="viewPicker">
173 <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-]" />
174 &nbsp;
175 <img id="dayview" class="currentview" src="[-$TPL_IMAGE_PATH-]/day.gif" border="0" title="[-php-]echo xl("Day View")[-/php-]" alt="[-php-]echo xl ("Day View")[-/php-]" />
176 &nbsp;
177 <img id="weekview" src="[-$TPL_IMAGE_PATH-]/week.gif" border="0" title="[-php-]echo xl ("Week View")[-/php-]" alt="[-php-]echo xl ("Week View")[-/php-]" />
178 &nbsp;
179 <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-]" />
180 </div>
181 </div> <!-- end topToolbarRight -->
183 <div id="datePicker">
185 <table border="0" cellpadding="0" cellspacing="0">
186 <tr>
187 [-php-]
188 $atmp = array_keys($A_EVENTS);
189 $caldate = strtotime($atmp[0]);
190 $cMonth = date("m", $caldate);
191 $cYear = date("Y", $caldate);
192 $cDay = date("d", $caldate);
194 // compute the previous month date
195 // stay on the same day if possible
196 $pDay = $cDay;
197 $pMonth = $cMonth - 1;
198 $pYear = $cYear;
199 if ($pMonth < 1) { $pMonth = 12; $pYear = $cYear - 1; }
200 while (! checkdate($pMonth, $pDay, $pYear)) { $pDay = $pDay - 1; }
201 $prevMonth = sprintf("%d%02d%02d",$pYear,$pMonth,$pDay);
203 // compute the next month
204 // stay on the same day if possible
205 $nDay = $cDay;
206 $nMonth = $cMonth + 1;
207 $nYear = $cYear;
208 if ($nMonth > 12) { $nMonth = 1; $nYear = $cYear + 1; }
209 while (! checkdate($nMonth, $nDay, $nYear)) { $nDay = $nDay - 1; }
210 $nextMonth = sprintf("%d%02d%02d",$nYear,$nMonth,$nDay);
211 [-/php-]
212 <td class="tdDOW-small tdDatePicker" id="[-php-]echo $prevMonth[-/php-]" title="[-php-]echo date("F", strtotime($prevMonth));[-/php-]">&lt;</td>
213 <td colspan="5" class="tdMonthName-small">
214 [-php-]
215 echo date('F', $caldate);
216 [-/php-]
217 </td>
218 <td class="tdDOW-small tdDatePicker" id="[-php-]echo $nextMonth[-/php-]" title="[-php-]echo date("F", strtotime($nextMonth));[-/php-]">&gt;</td>
219 <tr>
220 [-php-]
221 foreach ($DOWlist as $dow) {
222 echo "<td class='tdDOW-small'>".$this->_tpl_vars['A_SHORT_DAY_NAMES'][$dow]."</td>";
224 [-/php-]
225 </tr>
226 [-php-]
227 $atmp = array_keys($A_EVENTS);
228 $caldate = strtotime($atmp[0]);
229 $caldateEnd = strtotime($atmp[6]);
231 // to make a complete week row we need to compute the real
232 // start and end dates for the view
233 list ($year, $month, $day) = explode(" ", date('Y m d', $caldate));
234 $startdate = strtotime($year.$month."01");
235 $enddate = strtotime($year.$month.date("t", $startdate)." 23:59");
236 while (date('w', $startdate) != $DOWlist[0]) { $startdate -= 60*60*24; }
237 while (date('w', $enddate) != $DOWlist[6]) { $enddate += 60*60*24; }
239 $currdate = $startdate;
240 while ($currdate <= $enddate) {
241 if (date('w', $currdate) == $DOWlist[0]) {
242 // start of week row
243 $tr = "<tr>";
244 echo $tr;
247 // set the TD class
248 $tdClass = "tdMonthDay-small";
249 if (date('m', $currdate) != $month) {
250 $tdClass = "tdOtherMonthDay-small";
252 if ((date('w', $currdate) == 0) || (date('w', $currdate) == 6)) {
253 $tdClass = "tdWeekend-small";
256 if (date('Ymd',$currdate) == $Date) {
257 // $Date is defined near the top of this file
258 // and is equal to whatever date the user has clicked
259 $tdClass .= " currentDate";
262 // add a class so that jQuery can grab these days for the 'click' event
263 $tdClass .= " tdDatePicker";
265 // output the TD
266 $td = "<td ";
267 $td .= "class=\"".$tdClass."\" ";
268 //$td .= "id=\"".date("Ymd", $currdate)."\" ";
269 $td .= "id=\"".date("Ymd", $currdate)."\" ";
270 $td .= "title=\"Go to ".date('M d, Y', $currdate)."\" ";
271 $td .= "> ".date('d', $currdate)."</td>\n";
272 echo $td;
274 // end of week row
275 if (date('w', $currdate) == $DOWlist[6]) echo "</tr>\n";
277 // time correction = plus 1000 seconds, for some unknown reason
278 $currdate += (60*60*24)+1000;
280 [-/php-]
281 </table>
282 </div>
284 <div id="bigCalHeader">
285 [-php-]
286 $atmp = array_keys($A_EVENTS);
287 echo date('d M Y', strtotime($atmp[0]));
288 [-/php-]
289 </div>
291 <div id="providerPicker">
292 Providers
293 <div>
294 [-php-]
295 // ==============================
296 // FACILITY FILTERING (lemonsoftware)
297 /*********************************************************************
298 $facilities = getFacilities();
299 *********************************************************************/
300 if ($_SESSION['authorizeduser'] == 1) {
301 $facilities = getFacilities();
302 } else {
303 $facilities = getUserFacilities($_SESSION['authId']); // from users_facility
304 if (count($facilities) == 1)
305 $_SESSION['pc_facility'] = key($facilities);
307 /********************************************************************/
308 if (count($facilities) > 1) {
309 echo " <select name='pc_facility' id='pc_facility'>\n";
310 if ( !$_SESSION['pc_facility'] ) $selected = "selected='selected'";
311 // echo " <option value='0' $selected>" .xl('All Facilities'). "</option>\n";
312 if (!$GLOBALS['restrict_user_facility']) echo " <option value='0' $selected>" . xl('All Facilities') . "</option>\n";
313 foreach ($facilities as $fa) {
314 $selected = ( $_SESSION['pc_facility'] == $fa['id']) ? "selected='selected'" : "" ;
315 echo " <option value='" .$fa['id']. "' $selected>" .$fa['name']. "</option>\n";
317 echo " </select>\n";
319 // EOS FF
320 // ==============================
321 echo "</div>";
322 echo " <select multiple size='5' name='pc_username[]' id='pc_username'>\n";
323 echo " <option value='__PC_ALL__'>" .xl ("All Users"). "</option>\n";
324 foreach ($provinfo as $doc) {
325 $username = $doc['username'];
326 echo " <option value='$username'";
327 foreach ($providers as $provider)
328 if ($provider['username'] == $username) echo " selected";
329 echo ">" . $doc['lname'] . ", " . $doc['fname'] . "</option>\n";
331 echo " </select>\n";
333 [-/php-]
334 </div>
336 </form>
338 [-assign var="dayname" value=$DATE|date_format:"%w"-]
339 [-assign var="day" value=$DATE|date_format:"%d"|string_format:"%1d"-]
340 [-assign var="month" value=$DATE|date_format:"%m"|string_format:"%1d"-]
341 [-assign var="year" value=$DATE|date_format:"%Y"|string_format:"%4d"-]
343 [-pc_sort_events var="S_EVENTS" sort="time" order="asc" value=$A_EVENTS-]
345 <div id="bigCal">
346 [-php-]
348 echo "<table border='0' cellpadding='1' cellspacing='0' width='100%'>\n";
350 // output the TD with the times DIV
351 echo "<tr>";
352 echo "<td id='times'><div><table>\n";
353 echo "<td class='timeslot'>&nbsp;</td>";
354 foreach ($times as $slottime) {
355 $startampm = ($slottime['mer']) == "pm" ? 2 : 1;
356 $starttimeh = $slottime['hour'];
357 $disptimeh = ($starttimeh > 12) ? ($starttimeh - 12) : $starttimeh;
358 $starttimem = $slottime['minute'];
359 $slotendmins = $starttimeh * 60 + $starttimem + $interval;
361 echo "<tr><td class='timeslot'>";
363 /*****************************************************************
364 $providerid = 0;
365 if (count($providers) == 1) {
366 $providerid = $providers[0]['id'];
368 echo "<a href='javascript:newEvt($startampm,$starttimeh,$starttimem,$Date,$providerid,0)' title='New Appointment' alt='New Appointment'>";
369 *****************************************************************/
370 // can't have a link to new appts since we may have multiple providers displayed
371 //echo "<a href='javascript:newEvt($startampm,$starttimeh,$starttimem,$defaultDate,$providerid,$in_cat_id)' title='New Appointment' alt='New Appointment'>";
372 /****************************************************************/
374 echo "$disptimeh:$starttimem";
375 // echo "</a>";
377 echo "</td></tr>\n";
379 echo "</table></div></td>";
382 // This loops once for each provider to be displayed.
384 foreach ($providers as $provider) {
385 $providerid = $provider['id'];
387 // to specially handle the IN/OUT events I'm doing something new here
388 // for each IN event it will have a duration lasting until the next
389 // OUT event or until the end of the day
390 $tmpTime = $times[0];
391 $calStartMin = ($tmpTime['hour'] * 60) + $tmpTime['minute'];
392 $tmpTime = $times[count($times)-1];
393 $calEndMin = ($tmpTime['hour'] * 60) + $tmpTime['minute'];
395 // having a 'title' for the TD makes the date appear by the mouse pointer
396 // this is nice when all you see are times on the left side and no head
397 // row with the dates or day-of-week (DOW)
398 echo "<td class='schedule' title='".$provider['fname']." ".$provider['lname']."'>";
399 echo "<div class='providerheader'>";
400 echo $provider['fname']." ".$provider['lname']."</div>";
401 echo "<div class='calendar_day'>";
403 // For each event...
404 // output a TD with an inner containing DIV positioned 'relative'
405 // within that DIV we place our event DIVs using 'absolute' positioning
406 foreach ($A_EVENTS as $date => $events) {
407 $eventdate = substr($date, 0, 4) . substr($date, 5, 2) . substr($date, 8, 2);
409 // determine if events overlap and adjust their width and left position as needed
410 // 26 Feb 2008 - This needs fine tuning or total replacement
411 // - it doesn't work as well as I'd like - JRM
412 $eventPositions = array();
413 foreach ($times as $slottime) {
414 $starttimeh = $slottime['hour'];
415 $starttimem = $slottime['minute'];
417 $slotstartmins = $starttimeh * 60 + $starttimem;
418 $slotendmins = $starttimeh * 60 + $starttimem + $interval;
420 $events_in_timeslot = array();
421 foreach ($events as $e1) {
422 // ignore IN and OUT events
423 if (($e1['catid'] == 2) || ($e1['catid'] == 3)) { continue; }
424 // skip events without an ID (why they are in the loop, I have no idea)
425 if ($e1['eid'] == "") { continue; }
426 // skip events for other providers
427 if ($providerid != $e1['aid']) { continue; }
429 // specially handle all-day events
430 if ($e1['alldayevent'] == 1) {
431 $tmpTime = $times[0];
432 if (strlen($tmpTime['hour']) < 2) { $tmpTime['hour'] = "0".$tmpTime['hour']; }
433 if (strlen($tmpTime['minute']) < 2) { $tmpTime['minute'] = "0".$tmpTime['minute']; }
434 $e1['startTime'] = $tmpTime['hour'].":".$tmpTime['minute'].":00";
435 $e1['duration'] = ($calEndMin - $calStartMin) * 60; // measured in seconds
438 // create a numeric start and end for comparison
439 $starth = substr($e1['startTime'], 0, 2);
440 $startm = substr($e1['startTime'], 3, 2);
441 $e1Start = ($starth * 60) + $startm;
442 $e1End = $e1Start + $e1['duration']/60;
444 // three ways to overlap:
445 // start-in, end-in, span
446 if ((($e1Start >= $slotstartmins) && ($e1Start < $slotendmins)) // start-in
447 || (($e1End > $slotstartmins) && ($e1End <= $slotendmins)) // end-in
448 || (($e1Start < $slotstartmins) && ($e1End > $slotendmins))) // span
450 array_push($events_in_timeslot, $e1['eid']);
453 $leftpos = 0;
454 $width = 100 / count($events_in_timeslot);
456 // loop over the events in this timeslot and adjust their width
457 foreach ($events_in_timeslot as $eid) {
458 // set the width if not already set or if the current width is smaller
459 // than was was previously set
460 if (! isset($eventPositions[$eid]->width)) { $eventPositions[$eid]->width = $width; }
461 else if ($eventPositions[$eid]->width > $width) { $eventPositions[$eid]->width = $width; }
463 // set the left position if not already set or if the current left is
464 // greater than what was previously set
465 if (! isset($eventPositions[$eid]->leftpos)) { $eventPositions[$eid]->leftpos = $leftpos; }
466 else if ($eventPositions[$eid]->leftpos < $leftpos) { $eventPositions[$eid]->leftpos = $leftpos; }
468 // increment the leftpos by the width
469 $leftpos += $width;
471 } // end overlap detection
473 // now loop over the events for the day and output their DIVs
474 foreach ($events as $event) {
475 // skip events for other providers
476 // yeah, we've got that sort of overhead here... it ain't perfect
477 if ($providerid != $event['aid']) { continue; }
479 // skip events without an ID (why they are in the loop, I have no idea)
480 if ($event['eid'] == "") { continue; }
482 // specially handle all-day events
483 if ($event['alldayevent'] == 1) {
484 $tmpTime = $times[0];
485 if (strlen($tmpTime['hour']) < 2) { $tmpTime['hour'] = "0".$tmpTime['hour']; }
486 if (strlen($tmpTime['minute']) < 2) { $tmpTime['minute'] = "0".$tmpTime['minute']; }
487 $event['startTime'] = $tmpTime['hour'].":".$tmpTime['minute'].":00";
488 $event['duration'] = ($calEndMin - $calStartMin) * 60; // measured in seconds
491 // figure the start time and minutes (from midnight)
492 $starth = substr($event['startTime'], 0, 2);
493 $startm = substr($event['startTime'], 3, 2);
494 $eStartMin = $starth * 60 + $startm;
495 $dispstarth = ($starth > 12) ? ($starth - 12) : $starth; // used to display the hour
497 // determine the class for the event DIV based on the event category
498 $evtClass = "event_appointment";
499 switch ($event['catid']) {
500 case 1: // NO-SHOW appt
501 $evtClass = "event_noshow";
502 break;
503 case 2: // IN office
504 $evtClass = "event_in";
505 break;
506 case 3: // OUT of office
507 $evtClass = "event_out";
508 break;
509 case 4: // VACATION
510 case 8: // LUNCH
511 case 11: // RESERVED
512 $evtClass = "event_reserved";
513 break;
514 default: // some appointment
515 $evtClass = "event_appointment";
516 break;
519 // if this is an IN or OUT event then we have some extra special
520 // processing to be done
521 // the IN event creates a DIV until the OUT event
522 // or, without an OUT DIV matching the IN event
523 // then the IN event runs until the end of the day
524 if ($event['catid'] == 2) {
525 // locate a matching OUT for this specific IN
526 $found = false;
527 $outMins = 0;
528 foreach ($events as $outevent) {
529 // skip events for other providers
530 if ($providerid != $outevent['aid']) { continue; }
531 // skip events with blank IDs
532 if ($outevent['eid'] == "") { continue; }
534 if ($outevent['eid'] == $event['eid']) { $found = true; continue; }
535 if (($found == true) && ($outevent['catid'] == 3)) {
536 // calculate the duration from this event to the outevent
537 $outH = substr($outevent['startTime'], 0, 2);
538 $outM = substr($outevent['startTime'], 3, 2);
539 $outMins = ($outH * 60) + $outM;
540 $event['duration'] = ($outMins - $eStartMin) * 60; // duration is in seconds
541 $found = 2;
542 break;
545 if ($outMins == 0) {
546 // no OUT was found so this event's duration goes
547 // until the end of the day
548 $event['duration'] = ($calEndMin - $eStartMin) * 60; // duration is in seconds
552 // calculate the TOP value for the event DIV
553 // diff between event start and schedule start
554 $eMinDiff = $eStartMin - $calStartMin;
555 // diff divided by the time interval of the schedule
556 $eStartInterval = $eMinDiff / $interval;
557 // times the interval height
558 $eStartPos = $eStartInterval * $timeslotHeightVal;
559 $evtTop = $eStartPos.$timeslotHeightUnit;
561 // calculate the HEIGHT value for the event DIV
562 // diff between end and start of event
563 $eEndMin = $eStartMin + ($event['duration']/60);
564 // prevent the overall height of the event from going beyond the bounds
565 // of the time table
566 if ($eEndMin > $calEndMin) { $eEndMin = $calEndMin + $interval; }
567 $eMinDiff = $eEndMin - $eStartMin;
568 // diff divided by the time interval of the schedule
569 $eEndInterval = $eMinDiff / $interval;
570 // times the interval height
571 $eHeight = $eEndInterval * $timeslotHeightVal;
572 $evtHeight = $eHeight.$timeslotHeightUnit;
574 // determine the DIV width based on any overlapping events
575 // see further above for the overlapping calculation code
576 $divWidth = "";
577 $divLeft = "";
578 if (isset($eventPositions[$event['eid']])) {
579 $divWidth = "width: ".$eventPositions[$event['eid']]->width."%";
580 $divLeft = "left: ".$eventPositions[$event['eid']]->leftpos."%";
583 $eventid = $event['eid'];
584 $patientid = $event['pid'];
585 $commapos = strpos($event['patient_name'], ",");
586 $lname = addslashes(ucfirst(strtolower(substr($event['patient_name'], 0, $commapos))));
587 $fname = addslashes(ucfirst(strtolower(substr($event['patient_name'], $commapos + 2))));
588 $patient_dob = $event['patient_dob'];
589 $patient_age = $event['patient_age'];
590 $catid = $event['catid'];
591 $comment = addslashes($event['hometext']);
592 $catname = $event['catname'];
593 $title = "Age $patient_age ($patient_dob)";
595 $content = "";
597 if ($comment && $GLOBALS['calendar_appt_style'] < 4) $title .= " " . $comment;
599 // the divTitle is what appears when the user hovers the mouse over the DIV
600 $divTitle = $provider['fname']." ".$provider['lname'];
602 if ($catid == 2 || $catid == 3 || $catid == 4 || $catid == 8 || $catid == 11) {
603 if ($catid == 2) $catname = "IN";
604 else if ($catid == 3) $catname = "OUT";
605 else if ($catid == 4) $catname = "VACATION";
606 else if ($catid == 8) $catname = "LUNCH";
607 else if ($catid == 11) $catname = "RESERVED";
609 $atitle = $catname;
610 if ($comment) $atitle .= " $comment";
611 $divTitle .= "\n[".$atitle ."]";
612 $content .= $catname;
613 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'>";
614 if ($comment) $content .= " $comment";
616 else {
617 // some sort of patient appointment
618 $divTitle .= "\r\n[".$catname ."] ".$fname." ".$lname;
619 $content .= "<span class='appointment'>";
620 $content .= $dispstarth . ':' . $startm;
621 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'>";
622 // $content .= htmlspecialchars($event['apptstatus']);
623 $content .= '&nbsp;'.htmlspecialchars($event['apptstatus']);
624 if ($patientid) {
625 $link_title = "Age: ".$patient_age."\nDOB: ".$patient_dob."\n";
626 $link_title .= "(Click to view)";
627 $content .= "<a href='javascript:goPid($patientid)' title='$link_title'>";
628 $content .= "<img src='$TPL_IMAGE_PATH/user-green.gif' border='0' title='$link_title' alt='View Patient' />";
629 if ($catid == 1) $content .= "<strike>";
630 $content .= $lname;
631 if ($GLOBALS['calendar_appt_style'] != 1) {
632 $content .= "," . $fname;
633 if ($event['title'] && $GLOBALS['calendar_appt_style'] >= 3) {
634 $content .= "(" . $event['title'];
635 if ($event['hometext'] && $GLOBALS['calendar_appt_style'] >= 4)
636 $content .= ": <font color='green'>" . htmlspecialchars(trim($event['hometext'])) . "</font>";
637 $content .= ")";
640 if ($catid == 1) $content .= "</strike>";
641 $content .= "</a>";
643 else {
644 // no patient id, just output the category name
645 $content .= $catname;
647 $content .= "</span>";
650 $divTitle .= "\n(double click to edit)";
652 // a special case for the 'IN' event this puts the time ABOVE
653 // the normal DIV so it doesn't overlap another event DIV and include the time
654 if ($event['catid'] == 2) {
655 $inTop = ($eStartPos - $timeslotHeightVal).$timeslotHeightUnit;
656 echo "<div class='".$evtClass." event' style='top:".$inTop.
657 "; height:".$timeslotHeightVal.$timeslotHeightUnit.
658 "; $divWidth".
659 "; $divLeft".
660 "; background:transparent".
661 "; border: none".
662 "' title='".$divTitle."'".
663 " id='".$eventdate."-".$eventid."'".
664 ">";
665 $content = $dispstarth . ':' . $startm . " " . $content;
666 echo $content;
667 echo "</div>\n";
670 // output the DIV and content
671 echo "<div class='".$evtClass." event' style='top:".$evtTop."; height:".$evtHeight.
672 "; background-color:".$event["catcolor"].
673 "; $divWidth".
674 "; $divLeft".
675 "' title='".$divTitle."'".
676 " id='".$eventdate."-".$eventid."'".
677 ">";
678 // second part for the special IN event
679 if ($event['catid'] != 2) { echo $content; }
680 echo "</div>\n";
681 } // end EVENT loop
683 echo "</div>";
685 } // end date
687 echo "</td>\n";
689 } // end provider loop
691 echo " </tr>\n";
692 echo "</table>\n";
693 echo "<P>";
695 // [-*footer*-]
696 // [-include file="$TPL_NAME/views/global/footer.html"-]
697 // [-include file="$TPL_NAME/views/footer.html"-]
699 [-/php-]
700 </div> <!-- end bigCal DIV -->
702 </body>
704 <script language='JavaScript'>
706 $(document).ready(function(){
707 $("#pc_username").change(function() { ChangeProviders(this); });
708 $("#pc_facility").change(function() { ChangeProviders(this); });
709 //$("#dayview").click(function() { ChangeView(this); });
710 $("#weekview").click(function() { ChangeView(this); });
711 $("#monthview").click(function() { ChangeView(this); });
712 //$("#yearview").click(function() { ChangeView(this); });
713 $(".tdDatePicker").click(function() { ChangeDate(this); });
714 $(".tdDatePicker").mouseover(function() { $(this).toggleClass("tdDatePickerHighlight"); });
715 $(".tdDatePicker").mouseout(function() { $(this).toggleClass("tdDatePickerHighlight"); });
716 $("#printview").click(function() { PrintView(this); });
717 $(".event").dblclick(function() { EditEvent(this); });
718 $(".event").mouseover(function() { $(this).toggleClass("event_highlight"); });
719 $(".event").mouseout(function() { $(this).toggleClass("event_highlight"); });
722 /* edit an existing event */
723 var EditEvent = function(eObj) {
724 //alert ('editing '+eObj.id);
725 // split the object ID into date and event ID
726 objID = eObj.id;
727 var parts = new Array();
728 parts = objID.split("-");
729 // call the oldEvt function to bring up the event editor
730 oldEvt(parts[0], parts[1]);
731 return true;
734 /* change the current date based upon what the user clicked in
735 * the datepicker DIV
737 var ChangeDate = function(eObj) {
738 baseURL = "[-php-]echo pnModURL(__POSTCALENDAR__,'user','view',
739 array('tplview'=>$template_view,
740 'viewtype'=>$viewtype,
741 'Date'=> '~REPLACEME~',
742 'pc_username'=>$pc_username,
743 'pc_category'=>$category,
744 'pc_topic'=>$topic));[-/php-]";
745 newURL = baseURL.replace(/~REPLACEME~/, eObj.id);
746 document.location.href=newURL;
749 /* pop up a window to print the current view
751 var PrintView = function (eventObject) {
752 printURL = "[-php-]echo pnModURL(__POSTCALENDAR__,'user','view',
753 array('tplview'=>$template_view,
754 'viewtype'=>$viewtype,
755 'Date'=> $Date,
756 'print'=> 1,
757 'pc_username'=>$pc_username,
758 'pc_category'=>$category,
759 'pc_topic'=>$topic));[-/php-]";
760 window.open(printURL,'printwindow','width=740,height=480,toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,copyhistory=no,resizable=yes');
761 return false;
764 /* change the provider(s)
766 var ChangeProviders = function (eventObject) {
767 $('#theform').submit();
770 /* change the calendar view
772 var ChangeView = function (eventObject) {
773 if (eventObject.id == "dayview") {
774 $("#viewtype").val('day');
776 else if (eventObject.id == "weekview") {
777 $("#viewtype").val('week');
779 else if (eventObject.id == "monthview") {
780 $("#viewtype").val('month');
782 else if (eventObject.id == "yearview") {
783 $("#viewtype").val('year');
785 $('#theform').submit();
788 </script>
791 </html>