Revert "Merge branch 'fmc-custom' of github.com:tmccormi/openemr"
[openemr.git] / interface / main / calendar / modules / PostCalendar / pntemplates / default / views / week / ajax_template.html
blobdea017398373d61f5942fffb0a4c8838fa976c38
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'])
51 echo " top.RTop.location = '../../patient_file/summary/demographics.php' " .
52 "+ '?set_pid=' + pid;\n";
54 } else {
55 echo " top.location = '../../patient_file/patient_file.php' " .
56 "+ '?set_pid=' + pid + '&pid=' + pid;\n";
58 [-/php-]
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();
66 top.restoreSession();
67 theForm.submit();
70 </script>
72 [-php-]
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
79 $DOWlist = array();
80 $tmpDOW = pnModGetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek');
81 // bound check and auto-correction
82 if ($tmpDOW <0 || $tmpDOW >6) {
83 pnModSetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek', '0');
84 $tmpDOW = 0;
86 while (count($DOWlist) < 7) {
87 array_push($DOWlist, $tmpDOW);
88 $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"-]
103 // [-/if-]
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']);
130 } else {
131 $provinfo = getProviderInfo();
133 //EOS FACILITY FILTERING (CHEMED)
134 //==================================
136 [-/php-]
138 <div id="functions">
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-]">
143 [-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";
147 [-/php-]
148 </div>
150 <div id="topToolbarRight"> <!-- this wraps some of the top toolbar items -->
152 <div id="dateNAV">
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>
157 &nbsp;
158 <input type='submit' name='bnsubmit' value='[-php-]echo xl ("Today")[-/php-]' onClick='GoToToday(theform);' />
159 </div>
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-]" />
163 &nbsp;
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-]" />
165 &nbsp;
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-]" />
167 &nbsp;
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-]" />
169 </div>
170 </div> <!-- end topToolbarRight -->
172 <div id="datePicker">
174 <table border="0" cellpadding="0" cellspacing="0">
175 <tr>
176 [-php-]
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
185 $pDay = $cDay;
186 $pMonth = $cMonth - 1;
187 $pYear = $cYear;
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
194 $nDay = $cDay;
195 $nMonth = $cMonth + 1;
196 $nYear = $cYear;
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);
200 [-/php-]
201 <td class="tdDOW-small tdDatePicker tdNav" id="[-php-]echo $prevMonth[-/php-]" title="[-php-]echo xl(date("F", strtotime($prevMonth)));[-/php-]">&lt;</td>
202 <td colspan="5" class="tdMonthName-small">
203 [-php-]
204 echo xl(date('F', $caldate));
205 [-/php-]
206 </td>
207 <td class="tdDOW-small tdDatePicker tdNav" id="[-php-]echo $nextMonth[-/php-]" title="[-php-]echo xl(date("F", strtotime($nextMonth)));[-/php-]">&gt;</td>
208 <tr>
209 [-php-]
210 foreach ($DOWlist as $dow) {
211 echo "<td class='tdDOW-small'>".$this->_tpl_vars['A_SHORT_DAY_NAMES'][$dow]."</td>";
213 [-/php-]
214 </tr>
215 [-php-]
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]) {
231 // start of week row
232 $tr = "<tr class='trDateRow'>";
233 echo $tr;
236 // set the TD class
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";
261 // output the TD
262 $td = "<td ";
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";
268 echo $td;
270 // end of week row
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;
276 [-/php-]
277 </table>
278 </div>
280 <div id="bigCalHeader">
281 [-php-]
282 $atmp = array_keys($A_EVENTS);
283 echo date('d M Y', strtotime($atmp[0]));
284 echo " - ";
285 echo date('d M Y', strtotime($atmp[count($atmp)-1]));
286 [-/php-]
287 </div>
289 <div id="providerPicker">
290 [-php-] xl('Providers','e'); [-/php-]
291 <div>
292 [-php-]
293 // ==============================
294 // FACILITY FILTERING (lemonsoftware)
295 // $facilities = getFacilities();
296 if ($_SESSION['authorizeduser'] == 1) {
297 $facilities = getFacilities();
298 } else {
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";
312 echo " </select>\n";
314 // EOS FF
315 // ==============================
316 echo "</div>";
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";
326 echo " </select>\n";
328 [-/php-]
329 </div>
331 </form>
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"-]
338 <div id="bigCal">
339 [-php-]
340 /* used in debugging
341 foreach ($A_EVENTS as $date => $events) {
342 echo $date." = ";
343 foreach ($events as $oneE) {
344 print_r($oneE);
345 echo "<br><br>";
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";
366 echo " <tr>\n";
367 echo " <td colspan='8' class='providerheader'>";
368 echo $provider['fname'] . " " . $provider['lname'];
369 echo "</td>\n";
370 echo " </tr>\n";
372 // output column (date) headers
373 $colWidth = 100/7; // intentionally '7' and not '8'
374 echo " <tr>\n";
375 echo " <td>&nbsp;</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,
382 'viewtype'=>'day',
383 'Date'=> $dateFmt,
384 'pc_username'=>$pc_username,
385 'pc_category'=>$category,
386 'pc_topic'=>$topic));
387 if ($defaultDate == "") $defaultDate = $dateFmt;
388 $currclass = "";
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));
393 echo "</a></td>";
395 echo " </tr>\n";
397 // output the TD with the times DIV
398 echo "<tr>";
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>";
413 echo "</td></tr>\n";
415 echo "</table></div></td>";
417 // For each day...
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']);
474 $leftpos = 0;
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
490 $leftpos += $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";
523 break;
524 case 2: // IN office
525 $evtClass = "event_in";
526 break;
527 case 3: // OUT of office
528 $evtClass = "event_out";
529 break;
530 case 4: // VACATION
531 case 8: // LUNCH
532 case 11: // RESERVED
533 $evtClass = "event_reserved";
534 break;
535 default: // some appointment
536 $evtClass = "event_appointment";
537 break;
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
547 $found = false;
548 $outMins = 0;
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
562 $found = 2;
563 break;
566 if ($outMins == 0) {
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
586 // of the time table
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
597 $divWidth = "";
598 $divLeft = "";
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)";
616 $content = "";
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");
630 $atitle = $catname;
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>";
640 else {
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']);
647 if ($patientid) {
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 $link_title .= "(" . xl('Click to view') . ")";
652 $content .= "<a href='javascript:goPid($patientid)' title='$link_title'>";
653 $content .= "<img src='$TPL_IMAGE_PATH/user-green.gif' border='0' title='$link_title' alt='View Patient' />";
654 $content .= "</a>";
656 else {
657 // no patient id, just output the category name
658 $content .= $catname;
660 $content .= "</span>";
663 $divTitle .= "\n(" . xl('double click to edit') . ")";
665 // output the DIV and content
666 echo "<div class='".$evtClass." event' style='top:".$evtTop."; height:".$evtHeight.
667 "; background-color:".$event["catcolor"].
668 "; $divWidth".
669 "; $divLeft".
670 "' title='".$divTitle."'".
671 " id='".$eventdate."-".$eventid."'".
672 ">";
673 echo $content;
674 echo "</div>\n";
675 } // end EVENT loop
677 echo "</div>";
678 echo "</td>\n";
680 } // end date
682 echo " </tr>\n";
684 echo "</table>\n";
685 echo "<P>";
686 } // end provider
688 // [-*footer*-]
689 // [-include file="$TPL_NAME/views/global/footer.html"-]
690 // [-include file="$TPL_NAME/views/footer.html"-]
692 [-/php-]
693 </div> <!-- end bigCal DIV -->
695 </body>
697 <script language='JavaScript'>
699 $(document).ready(function(){
700 $("#pc_username").change(function() { ChangeProviders(this); });
701 $("#pc_facility").change(function() { ChangeProviders(this); });
702 $("#dayview").click(function() { ChangeView(this); });
703 //$("#weekview").click(function() { ChangeView(this); });
704 $("#monthview").click(function() { ChangeView(this); });
705 //$("#yearview").click(function() { ChangeView(this); });
706 $(".tdDatePicker").click(function() { ChangeDate(this); });
707 $("#datePicker .trDateRow").mouseover(function() { $(this).children().toggleClass("tdDatePickerHighlight"); });
708 $("#datePicker .trDateRow").mouseout(function() { $(this).children().toggleClass("tdDatePickerHighlight"); });
709 $("#datePicker .tdNav").mouseover(function() { $(this).toggleClass("tdDatePickerHighlight"); });
710 $("#datePicker .tdNav").mouseout(function() { $(this).toggleClass("tdDatePickerHighlight"); });
711 $("#printview").click(function() { PrintView(this); });
712 $(".event").dblclick(function() { EditEvent(this); });
713 $(".event").mouseover(function() { $(this).toggleClass("event_highlight"); });
714 $(".event").mouseout(function() { $(this).toggleClass("event_highlight"); });
717 /* edit an existing event */
718 var EditEvent = function(eObj) {
719 //alert ('editing '+eObj.id);
720 // split the object ID into date and event ID
721 objID = eObj.id;
722 var parts = new Array();
723 parts = objID.split("-");
724 // call the oldEvt function to bring up the event editor
725 oldEvt(parts[0], parts[1]);
726 return true;
729 /* change the current date based upon what the user clicked in
730 * the datepicker DIV
732 var ChangeDate = function(eObj) {
733 baseURL = "[-php-]echo pnModURL(__POSTCALENDAR__,'user','view',
734 array('tplview'=>$template_view,
735 'viewtype'=>$viewtype,
736 'Date'=> '~REPLACEME~',
737 'pc_username'=>$pc_username,
738 'pc_category'=>$category,
739 'pc_topic'=>$topic));[-/php-]";
740 newURL = baseURL.replace(/~REPLACEME~/, eObj.id);
741 document.location.href=newURL;
744 /* pop up a window to print the current view
746 var PrintView = function (eventObject) {
747 printURL = "[-php-]echo pnModURL(__POSTCALENDAR__,'user','view',
748 array('tplview'=>$template_view,
749 'viewtype'=>$viewtype,
750 'Date'=> $Date,
751 'print'=> 1,
752 'pc_username'=>$pc_username,
753 'pc_category'=>$category,
754 'pc_topic'=>$topic));[-/php-]";
755 window.open(printURL,'printwindow','width=740,height=480,toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,copyhistory=no,resizable=yes');
756 return false;
759 /* change the provider(s)
761 var ChangeProviders = function (eventObject) {
762 $('#theform').submit();
765 /* change the calendar view
767 var ChangeView = function (eventObject) {
768 if (eventObject.id == "dayview") {
769 $("#viewtype").val('day');
771 else if (eventObject.id == "weekview") {
772 $("#viewtype").val('week');
774 else if (eventObject.id == "monthview") {
775 $("#viewtype").val('month');
777 else if (eventObject.id == "yearview") {
778 $("#viewtype").val('year');
780 $('#theform').submit();
783 </script>
786 </html>