Calendar layout improvements.
[openemr.git] / interface / main / calendar / modules / PostCalendar / pntemplates / default / views / day / ajax_template.html
blob838df441e07ade7366940475affcce89014f55cf
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 + '&userid=' + providerid + '&starttimem=' + starttimem +
37 '&date=' + eventdate + '&catid=' + catid,
38 '_blank', 575, 375);
41 function oldEvt(eventdate, eventid, pccattype) {
42 dlgopen('add_edit_event.php?date='+eventdate+'&eid=' + eventid+'&prov=' + pccattype, '_blank', 575, 375);
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
56 echo " top.location = '../../patient_file/patient_file.php' " .
57 "+ '?set_pid=' + pid + '&pid=' + pid;\n";
59 [-/php-]
62 function GoToToday(theForm){
63 var todays_date = new Date();
64 var theMonth = todays_date.getMonth() + 1;
65 theMonth = theMonth < 10 ? "0" + theMonth : theMonth;
66 theForm.jumpdate.value = todays_date.getFullYear() + "-" + theMonth + "-" + todays_date.getDate();
67 top.restoreSession();
68 theForm.submit();
71 </script>
73 [-php-]
75 // this is my proposed setting in the globals config file so we don't
76 // need to mess with altering the pn database AND the config file
77 //pnModSetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek', $GLOBALS['schedule_dow_start']);
79 // build a day-of-week (DOW) list so we may properly build the calendars later in this code
80 $DOWlist = array();
81 $tmpDOW = pnModGetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek');
82 // bound check and auto-correction
83 if ($tmpDOW <0 || $tmpDOW >6) {
84 pnModSetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek', '0');
85 $tmpDOW = 0;
87 while (count($DOWlist) < 7) {
88 array_push($DOWlist, $tmpDOW);
89 $tmpDOW++;
90 if ($tmpDOW > 6) $tmpDOW = 0;
93 // A_CATEGORY is an ordered array of associative-array categories.
94 // Keys of interest are: id, name, color, desc, event_duration.
96 // echo "<!-- A_CATEGORY = "; print_r($this->_tpl_vars['A_CATEGORY']); echo " -->\n"; // debugging
97 // echo "<!-- A_EVENTS = "; print_r($this->_tpl_vars['A_EVENTS']); echo " -->\n"; // debugging
99 $A_CATEGORY =& $this->_tpl_vars['A_CATEGORY'];
101 // [-if $PRINT_VIEW != 1-]
102 // [-*Main Navigation*-]
103 // [-include file="$TPL_NAME/views/global/navigation.html"-]
104 // [-/if-]
106 $A_EVENTS =& $this->_tpl_vars['A_EVENTS'];
107 // $S_EVENTS =& $this->_tpl_vars['S_EVENTS']; // Deleted by Rod
108 $providers =& $this->_tpl_vars['providers'];
109 $times =& $this->_tpl_vars['times'];
110 $interval = $this->_tpl_vars['interval'];
111 $viewtype = $this->_tpl_vars['VIEW_TYPE'];
112 $PREV_WEEK_URL = $this->_tpl_vars['PREV_WEEK_URL'];
113 $NEXT_WEEK_URL = $this->_tpl_vars['NEXT_WEEK_URL'];
114 $PREV_DAY_URL = $this->_tpl_vars['PREV_DAY_URL'];
115 $NEXT_DAY_URL = $this->_tpl_vars['NEXT_DAY_URL'];
117 $Date = postcalendar_getDate();
118 if (!isset($y)) $y = substr($Date, 0, 4);
119 if (!isset($m)) $m = substr($Date, 4, 2);
120 if (!isset($d)) $d = substr($Date, 6, 2);
122 // echo "<!-- There are " . count($A_EVENTS) . " A_EVENTS days -->\n";
124 $MULTIDAY = count($A_EVENTS) > 1;
126 //==================================
127 //FACILITY FILTERING (CHEMED)
128 $facilities = getUserFacilities($_SESSION['authId']); // from users_facility
129 if ( $_SESSION['pc_facility'] ) {
130 $provinfo = getProviderInfo('%', true, $_SESSION['pc_facility']);
131 } else {
132 $provinfo = getProviderInfo();
134 //EOS FACILITY FILTERING (CHEMED)
135 //==================================
137 [-/php-]
138 <div id="topToolbarRight"> <!-- this wraps some of the top toolbar items -->
139 <div id="functions">
140 <!-- stuff form element here to avoid the margin padding it introduces into the page in some browsers -->
141 <form name='theform' id='theform' action='index.php?module=PostCalendar&func=view&tplview=default&pc_category=&pc_topic=' method='post' onsubmit='return top.restoreSession()'>
142 <input type="hidden" name="jumpdate" id="jumpdate" value="">
143 <input type="hidden" name="viewtype" id="viewtype" value="[-php-]echo $viewtype;[-/php-]">
144 [-php-]
145 echo " <a href='#' value='" .xl ("Add"). "' onclick='newEvt(1, 9, 00, $Date, 0, 0)' class='css_button'/><span>".xl("Add")."</span></a>\n";
146 echo " <a href='#' value='" . xl ("Search") .
147 "' onclick='top.restoreSession();location=\"index.php?module=PostCalendar&func=search\"' class='css_button'/><span>".xl("Search")."</span></a>\n";
148 [-/php-]
149 </div>
152 <div id="dateNAV" style="width:33%;">
153 <a href='#' name='bnsubmit' value='[-php-]echo xl ("Today")[-/php-]' onClick='GoToToday(theform);' class='css_button'/><span>[-php-] echo xl("Today")[-/php-]</span></a>
154 <a href='[-php-]echo $PREV_DAY_URL[-/php-]' onclick='top.restoreSession()'>
155 <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>
156 <a href='[-php-]echo $NEXT_DAY_URL[-/php-]' onclick='top.restoreSession()'>
157 <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>
158 &nbsp;
159 [-php-]
160 $atmp = array_keys($A_EVENTS);
161 echo dateformat (strtotime($atmp[0]),true);
162 [-/php-]
163 </div>
165 <div id="viewPicker">
166 [-php-]
167 echo " <a href='#' type='button' id='printview' title='" .xl ("Print View"). "' class='css_button'/><span>".xl("Print")."</span></a>\n";
168 echo " <a href='#' type='button' value='" .xl ("Refresh"). "' onclick='javascript:refreshme()' class='css_button'/><span>".xl("Refresh")."</span></a>\n";
169 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";
170 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";
171 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";
172 [-/php-]
173 </div>
174 </div> <!-- end topToolbarRight -->
175 <div id="bottom">
176 <div id="bottomLeft">
177 <div id="datePicker">
179 <table border="0" cellpadding="0" cellspacing="0">
180 <tr>
181 [-php-]
182 $atmp = array_keys($A_EVENTS);
183 $caldate = strtotime($atmp[0]);
184 $cMonth = date("m", $caldate);
185 $cYear = date("Y", $caldate);
186 $cDay = date("d", $caldate);
188 // compute the previous month date
189 // stay on the same day if possible
190 $pDay = $cDay;
191 $pMonth = $cMonth - 1;
192 $pYear = $cYear;
193 if ($pMonth < 1) { $pMonth = 12; $pYear = $cYear - 1; }
194 while (! checkdate($pMonth, $pDay, $pYear)) { $pDay = $pDay - 1; }
195 $prevMonth = sprintf("%d%02d%02d",$pYear,$pMonth,$pDay);
197 // compute the next month
198 // stay on the same day if possible
199 $nDay = $cDay;
200 $nMonth = $cMonth + 1;
201 $nYear = $cYear;
202 if ($nMonth > 12) { $nMonth = 1; $nYear = $cYear + 1; }
203 while (! checkdate($nMonth, $nDay, $nYear)) { $nDay = $nDay - 1; }
204 $nextMonth = sprintf("%d%02d%02d",$nYear,$nMonth,$nDay);
205 [-/php-]
206 <td class="tdDOW-small tdDatePicker" id="[-php-]echo $prevMonth[-/php-]" title="[-php-]echo xl(date("F", strtotime($prevMonth)));[-/php-]">&lt;</td>
207 <td colspan="5" class="tdMonthName-small">
208 [-php-]
209 echo xl(date('F', $caldate));
210 [-/php-]
211 </td>
212 <td class="tdDOW-small tdDatePicker" id="[-php-]echo $nextMonth[-/php-]" title="[-php-]echo xl(date("F", strtotime($nextMonth)));[-/php-]">&gt;</td>
213 <tr>
214 [-php-]
215 foreach ($DOWlist as $dow) {
216 echo "<td class='tdDOW-small'>".$this->_tpl_vars['A_SHORT_DAY_NAMES'][$dow]."</td>";
218 [-/php-]
219 </tr>
220 [-php-]
221 $atmp = array_keys($A_EVENTS);
222 $caldate = strtotime($atmp[0]);
223 $caldateEnd = strtotime($atmp[6]);
225 // to make a complete week row we need to compute the real
226 // start and end dates for the view
227 list ($year, $month, $day) = explode(" ", date('Y m d', $caldate));
228 $startdate = strtotime($year.$month."01");
229 $enddate = strtotime($year.$month.date("t", $startdate)." 23:59");
230 while (date('w', $startdate) != $DOWlist[0]) { $startdate -= 60*60*24; }
231 while (date('w', $enddate) != $DOWlist[6]) { $enddate += 60*60*24; }
233 $currdate = $startdate;
234 while ($currdate <= $enddate) {
235 if (date('w', $currdate) == $DOWlist[0]) {
236 // start of week row
237 $tr = "<tr>";
238 echo $tr;
241 // set the TD class
242 $tdClass = "tdMonthDay-small";
243 if (date('m', $currdate) != $month) {
244 $tdClass = "tdOtherMonthDay-small";
246 if ((date('w', $currdate) == 0) || (date('w', $currdate) == 6)) {
247 $tdClass = "tdWeekend-small";
250 if (date('Ymd',$currdate) == $Date) {
251 // $Date is defined near the top of this file
252 // and is equal to whatever date the user has clicked
253 $tdClass .= " currentDate";
256 // add a class so that jQuery can grab these days for the 'click' event
257 $tdClass .= " tdDatePicker";
259 // output the TD
260 $td = "<td ";
261 $td .= "class=\"".$tdClass."\" ";
262 //$td .= "id=\"".date("Ymd", $currdate)."\" ";
263 $td .= "id=\"".date("Ymd", $currdate)."\" ";
264 $td .= "title=\"" . xl('Go to') . " ".date('M d, Y', $currdate)."\" ";
265 $td .= "> ".date('d', $currdate)."</td>\n";
266 echo $td;
268 // end of week row
269 if (date('w', $currdate) == $DOWlist[6]) echo "</tr>\n";
271 // time correction = plus 1000 seconds, for some unknown reason
272 $currdate += (60*60*24)+1000;
274 [-/php-]
275 </table>
276 </div>
278 <div id="bigCalHeader">
279 </div>
281 <div id="providerPicker">
282 [-php-] xl('Providers','e'); [-/php-]
283 <div>
284 [-php-]
285 // ==============================
286 // FACILITY FILTERING (lemonsoftware)
287 /*********************************************************************
288 $facilities = getFacilities();
289 *********************************************************************/
290 if ($_SESSION['authorizeduser'] == 1) {
291 $facilities = getFacilities();
292 } else {
293 $facilities = getUserFacilities($_SESSION['authId']); // from users_facility
294 if (count($facilities) == 1)
295 $_SESSION['pc_facility'] = key($facilities);
297 /********************************************************************/
298 if (count($facilities) > 1) {
299 echo " <select name='pc_facility' id='pc_facility' class='view1' >\n";
300 if ( !$_SESSION['pc_facility'] ) $selected = "selected='selected'";
301 // echo " <option value='0' $selected>" .xl('All Facilities'). "</option>\n";
302 if (!$GLOBALS['restrict_user_facility']) echo " <option value='0' $selected>" . xl('All Facilities') . "</option>\n";
303 foreach ($facilities as $fa) {
304 $selected = ( $_SESSION['pc_facility'] == $fa['id']) ? "selected='selected'" : "" ;
305 echo " <option style=background-color:".htmlspecialchars($fa['color'],ENT_QUOTES)." value='" .htmlspecialchars($fa['id'],ENT_QUOTES). "' $selected>" .htmlspecialchars($fa['name'],ENT_QUOTES). "</option>\n";
307 echo " </select>\n";
309 // EOS FF
310 // ==============================
311 echo "</div>";
312 echo " <select multiple size='5' name='pc_username[]' id='pc_username' class='view2'>\n";
313 echo " <option value='__PC_ALL__'>" .xl ("All Users"). "</option>\n";
314 foreach ($provinfo as $doc) {
315 $username = $doc['username'];
316 echo " <option value='$username'";
317 foreach ($providers as $provider)
318 if ($provider['username'] == $username) echo " selected";
319 echo ">" . htmlspecialchars($doc['lname'],ENT_QUOTES) . ", " . htmlspecialchars($doc['fname'],ENT_QUOTES) . "</option>\n";
321 echo " </select>\n";
323 [-/php-]
324 </div>
325 [-php-]
326 if($_SESSION['pc_facility'] == 0){
327 [-/php-]
328 <div id="facilityColor">
329 <table>
330 [-php-]
331 foreach ($facilities as $f){
332 echo " <tr><td><div class='view1' style=background-color:".$f['color'].";font-weight:bold>".htmlspecialchars($f['name'],ENT_QUOTES)."</div></td></tr>";
334 [-/php-]
335 </table>
336 </div>
337 [-php-]
339 [-/php-]
341 </form>
343 [-assign var="dayname" value=$DATE|date_format:"%w"-]
344 [-assign var="day" value=$DATE|date_format:"%d"|string_format:"%1d"-]
345 [-assign var="month" value=$DATE|date_format:"%m"|string_format:"%1d"-]
346 [-assign var="year" value=$DATE|date_format:"%Y"|string_format:"%4d"-]
348 [-pc_sort_events var="S_EVENTS" sort="time" order="asc" value=$A_EVENTS-]
349 </div> <!-- end bottomLeft -->
350 <div id="bigCal">
351 [-php-]
353 echo "<table border='0' cellpadding='1' cellspacing='0' width='100%'>\n";
355 // output the TD with the times DIV
356 echo "<tr>";
357 echo "<td id='times'><div><table>\n";
358 echo "<td class='timeslot'>&nbsp;</td>";
359 //============================================================================================================================
360 foreach ($times as $slottime) {
361 $startampm = ($slottime['mer']) == "pm" ? 2 : 1;
362 $starttimeh = $slottime['hour'];
363 $disptimeh = ($starttimeh > 12) ? ($starttimeh - 12) : $starttimeh;
364 $starttimem = $slottime['minute'];
365 $slotendmins = $starttimeh * 60 + $starttimem + $interval;
367 // default to the first displayed provider
368 $providerid = $providers[0]['id'];
370 echo "<tr><td class='timeslot'>";
371 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). "'>";
372 echo "$disptimeh:$starttimem";
373 echo "</a>";
374 echo "</td></tr>\n";
376 echo "</table></div></td>";
379 // This loops once for each provider to be displayed.
381 foreach ($providers as $provider) {
382 $providerid = $provider['id'];
384 // to specially handle the IN/OUT events I'm doing something new here
385 // for each IN event it will have a duration lasting until the next
386 // OUT event or until the end of the day
387 $tmpTime = $times[0];
388 $calStartMin = ($tmpTime['hour'] * 60) + $tmpTime['minute'];
389 $tmpTime = $times[count($times)-1];
390 $calEndMin = ($tmpTime['hour'] * 60) + $tmpTime['minute'];
392 // having a 'title' for the TD makes the date appear by the mouse pointer
393 // this is nice when all you see are times on the left side and no head
394 // row with the dates or day-of-week (DOW)
395 echo "<td class='schedule' title='".htmlspecialchars($provider["fname"],ENT_QUOTES)." ".htmlspecialchars($provider["lname"],ENT_QUOTES)."'>";
396 echo "<div class='providerheader'>";
397 echo htmlspecialchars($provider['fname'],ENT_QUOTES)." ".htmlspecialchars($provider['lname'],ENT_QUOTES)."</div>";
398 echo "<div class='calendar_day'>";
400 // For each event...
401 // output a TD with an inner containing DIV positioned 'relative'
402 // within that DIV we place our event DIVs using 'absolute' positioning
403 foreach ($A_EVENTS as $date => $events) {
404 $eventdate = substr($date, 0, 4) . substr($date, 5, 2) . substr($date, 8, 2);
406 // determine if events overlap and adjust their width and left position as needed
407 // 26 Feb 2008 - This needs fine tuning or total replacement
408 // - it doesn't work as well as I'd like - JRM
409 $eventPositions = array();
410 foreach ($times as $slottime) {
411 $starttimeh = $slottime['hour'];
412 $starttimem = $slottime['minute'];
414 $slotstartmins = $starttimeh * 60 + $starttimem;
415 $slotendmins = $starttimeh * 60 + $starttimem + $interval;
417 $events_in_timeslot = array();
418 foreach ($events as $e1) {
419 // ignore IN and OUT events
420 if (($e1['catid'] == 2) || ($e1['catid'] == 3)) { continue; }
421 // skip events without an ID (why they are in the loop, I have no idea)
422 if ($e1['eid'] == "") { continue; }
423 // skip events for other providers
424 if ($providerid != $e1['aid']) { continue; }
426 // specially handle all-day events
427 if ($e1['alldayevent'] == 1) {
428 $tmpTime = $times[0];
429 if (strlen($tmpTime['hour']) < 2) { $tmpTime['hour'] = "0".$tmpTime['hour']; }
430 if (strlen($tmpTime['minute']) < 2) { $tmpTime['minute'] = "0".$tmpTime['minute']; }
431 $e1['startTime'] = $tmpTime['hour'].":".$tmpTime['minute'].":00";
432 $e1['duration'] = ($calEndMin - $calStartMin) * 60; // measured in seconds
435 // create a numeric start and end for comparison
436 $starth = substr($e1['startTime'], 0, 2);
437 $startm = substr($e1['startTime'], 3, 2);
438 $e1Start = ($starth * 60) + $startm;
439 $e1End = $e1Start + $e1['duration']/60;
441 // three ways to overlap:
442 // start-in, end-in, span
443 if ((($e1Start >= $slotstartmins) && ($e1Start < $slotendmins)) // start-in
444 || (($e1End > $slotstartmins) && ($e1End <= $slotendmins)) // end-in
445 || (($e1Start < $slotstartmins) && ($e1End > $slotendmins))) // span
447 array_push($events_in_timeslot, $e1['eid']);
450 $leftpos = 0;
451 $width = 100 / count($events_in_timeslot);
453 // loop over the events in this timeslot and adjust their width
454 foreach ($events_in_timeslot as $eid) {
455 // set the width if not already set or if the current width is smaller
456 // than was was previously set
457 if (! isset($eventPositions[$eid]->width)) { $eventPositions[$eid]->width = $width; }
458 else if ($eventPositions[$eid]->width > $width) { $eventPositions[$eid]->width = $width; }
460 // set the left position if not already set or if the current left is
461 // greater than what was previously set
462 if (! isset($eventPositions[$eid]->leftpos)) { $eventPositions[$eid]->leftpos = $leftpos; }
463 else if ($eventPositions[$eid]->leftpos < $leftpos) { $eventPositions[$eid]->leftpos = $leftpos; }
465 // increment the leftpos by the width
466 $leftpos += $width;
468 } // end overlap detection
470 // now loop over the events for the day and output their DIVs
471 foreach ($events as $event) {
472 // skip events for other providers
473 // yeah, we've got that sort of overhead here... it ain't perfect
474 if ($providerid != $event['aid']) { continue; }
476 // skip events without an ID (why they are in the loop, I have no idea)
477 if ($event['eid'] == "") { continue; }
479 // specially handle all-day events
480 if ($event['alldayevent'] == 1) {
481 $tmpTime = $times[0];
482 if (strlen($tmpTime['hour']) < 2) { $tmpTime['hour'] = "0".$tmpTime['hour']; }
483 if (strlen($tmpTime['minute']) < 2) { $tmpTime['minute'] = "0".$tmpTime['minute']; }
484 $event['startTime'] = $tmpTime['hour'].":".$tmpTime['minute'].":00";
485 $event['duration'] = ($calEndMin - $calStartMin) * 60; // measured in seconds
488 // figure the start time and minutes (from midnight)
489 $starth = substr($event['startTime'], 0, 2);
490 $startm = substr($event['startTime'], 3, 2);
491 $eStartMin = $starth * 60 + $startm;
492 $dispstarth = ($starth > 12) ? ($starth - 12) : $starth; // used to display the hour
494 // determine the class for the event DIV based on the event category
495 $evtClass = "event_appointment";
496 switch ($event['catid']) {
497 case 1: // NO-SHOW appt
498 $evtClass = "event_noshow";
499 break;
500 case 2: // IN office
501 $evtClass = "event_in";
502 break;
503 case 3: // OUT of office
504 $evtClass = "event_out";
505 break;
506 case 4: // VACATION
507 case 8: // LUNCH
508 case 11: // RESERVED
509 $evtClass = "event_reserved";
510 break;
511 default: // some appointment
512 $evtClass = "event_appointment";
513 break;
516 // if this is an IN or OUT event then we have some extra special
517 // processing to be done
518 // the IN event creates a DIV until the OUT event
519 // or, without an OUT DIV matching the IN event
520 // then the IN event runs until the end of the day
521 if ($event['catid'] == 2) {
522 // locate a matching OUT for this specific IN
523 $found = false;
524 $outMins = 0;
525 foreach ($events as $outevent) {
526 // skip events for other providers
527 if ($providerid != $outevent['aid']) { continue; }
528 // skip events with blank IDs
529 if ($outevent['eid'] == "") { continue; }
531 if ($outevent['eid'] == $event['eid']) { $found = true; continue; }
532 if (($found == true) && ($outevent['catid'] == 3)) {
533 // calculate the duration from this event to the outevent
534 $outH = substr($outevent['startTime'], 0, 2);
535 $outM = substr($outevent['startTime'], 3, 2);
536 $outMins = ($outH * 60) + $outM;
537 $event['duration'] = ($outMins - $eStartMin) * 60; // duration is in seconds
538 $found = 2;
539 break;
542 if ($outMins == 0) {
543 // no OUT was found so this event's duration goes
544 // until the end of the day
545 $event['duration'] = ($calEndMin - $eStartMin) * 60; // duration is in seconds
549 // calculate the TOP value for the event DIV
550 // diff between event start and schedule start
551 $eMinDiff = $eStartMin - $calStartMin;
552 // diff divided by the time interval of the schedule
553 $eStartInterval = $eMinDiff / $interval;
554 // times the interval height
555 $eStartPos = $eStartInterval * $timeslotHeightVal;
556 $evtTop = $eStartPos.$timeslotHeightUnit;
558 // calculate the HEIGHT value for the event DIV
559 // diff between end and start of event
560 $eEndMin = $eStartMin + ($event['duration']/60);
561 // prevent the overall height of the event from going beyond the bounds
562 // of the time table
563 if ($eEndMin > $calEndMin) { $eEndMin = $calEndMin + $interval; }
564 $eMinDiff = $eEndMin - $eStartMin;
565 // diff divided by the time interval of the schedule
566 $eEndInterval = $eMinDiff / $interval;
567 // times the interval height
568 $eHeight = $eEndInterval * $timeslotHeightVal;
569 $evtHeight = $eHeight.$timeslotHeightUnit;
571 // determine the DIV width based on any overlapping events
572 // see further above for the overlapping calculation code
573 $divWidth = "";
574 $divLeft = "";
575 if (isset($eventPositions[$event['eid']])) {
576 $divWidth = "width: ".$eventPositions[$event['eid']]->width."%";
577 $divLeft = "left: ".$eventPositions[$event['eid']]->leftpos."%";
580 $eventid = $event['eid'];
581 $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."'");
582 $pccattype = '';
583 if($eventtype['pc_cattype']==1)
584 $pccattype = 'true';
585 $patientid = $event['pid'];
586 $commapos = strpos($event['patient_name'], ",");
587 $lname = substr($event['patient_name'], 0, $commapos);
588 $fname = substr($event['patient_name'], $commapos + 2);
589 $patient_dob = $event['patient_dob'];
590 $patient_age = $event['patient_age'];
591 $catid = $event['catid'];
592 $comment = addslashes($event['hometext']);
593 $catname = $event['catname'];
594 $title = "Age $patient_age ($patient_dob)";
596 $content = "";
598 if ($comment && $GLOBALS['calendar_appt_style'] < 4) $title .= " " . $comment;
600 // the divTitle is what appears when the user hovers the mouse over the DIV
601 $divTitle = htmlspecialchars($provider["fname"],ENT_QUOTES)." ".htmlspecialchars($provider["lname"],ENT_QUOTES);
602 $result = sqlStatement("SELECT name,id,color FROM facility WHERE id=(SELECT pc_facility FROM openemr_postcalendar_events WHERE pc_eid=".$eventid.")");
603 $row = sqlFetchArray($result);
604 $color=$event["catcolor"];
605 if($GLOBALS['event_color']==2)
606 $color=$row['color'];
607 $divTitle .= "\n" .htmlspecialchars($row['name'],ENT_QUOTES);
609 if ($catid == 2 || $catid == 3 || $catid == 4 || $catid == 8 || $catid == 11) {
610 if ($catid == 2) $catname = xl("IN");
611 else if ($catid == 3) $catname = xl("OUT");
612 else if ($catid == 4) $catname = xl("VACATION");
613 else if ($catid == 8) $catname = xl("LUNCH");
614 else if ($catid == 11) $catname = xl("RESERVED");
616 $atitle = $catname;
617 if ($comment) $atitle .= " $comment";
618 $divTitle .= "\n[".$atitle ."]";
619 $content .= $catname;
620 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)."'>";
621 if ($comment) $content .= " $comment";
623 else {
624 // some sort of patient appointment
625 $divTitle .= "\r\n[".$catname.' '.htmlspecialchars($comment, ENT_QUOTES) ."]".htmlspecialchars($fname, ENT_QUOTES)." ".htmlspecialchars($lname, ENT_QUOTES);
626 $content .= "<span class='appointment'>";
627 $content .= $dispstarth . ':' . $startm;
628 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)."'>";
629 // $content .= htmlspecialchars($event['apptstatus']);
630 $content .= '&nbsp;'.htmlspecialchars($event['apptstatus']);
631 if ($patientid) {
632 $link_title = htmlspecialchars($fname,ENT_QUOTES)." ".htmlspecialchars($lname,ENT_QUOTES). " \n";
633 $link_title .= xl('Age') . ": " . $patient_age . " \n" . xl('DOB') . ": " . $patient_dob . " \n";
634 $link_title .= xl('Age') . ": ".$patient_age."\n" . xl('DOB') . ": ".$patient_dob.htmlspecialchars($comment, ENT_QUOTES)."\n";
635 $link_title .= "(" . xl('Click to view') . ")";
636 $content .= "<a href='javascript:goPid($patientid)' title='$link_title'>";
637 $content .= "<img src='$TPL_IMAGE_PATH/user-green.gif' border='0' title='$link_title' alt='View Patient' />";
638 if ($catid == 1) $content .= "<strike>";
639 $content .= htmlspecialchars($lname);
640 if ($GLOBALS['calendar_appt_style'] != 1) {
641 $content .= "," . htmlspecialchars($fname);
642 if ($event['title'] && $GLOBALS['calendar_appt_style'] >= 3) {
643 $content .= "(" . $event['title'];
644 if ($event['hometext'] && $GLOBALS['calendar_appt_style'] >= 4)
645 $content .= ": <font color='green'>" . htmlspecialchars(trim($event['hometext'])) . "</font>";
646 $content .= ")";
649 if ($catid == 1) $content .= "</strike>";
650 $content .= "</a>";
652 else {
653 // no patient id, just output the category name
654 $content .= $catname;
656 $content .= "</span>";
659 $divTitle .= "\n(" . xl('double click to edit') . ")";
661 if($_SESSION['pc_facility'] == 0){
662 // a special case for the 'IN' event this puts the time ABOVE
663 // the normal DIV so it doesn't overlap another event DIV and include the time
664 if ($event['catid'] == 2) {
665 $inTop = ($eStartPos - $timeslotHeightVal).$timeslotHeightUnit;
666 echo "<div class='".$evtClass." event' style='top:".$inTop.
667 "; height:".$timeslotHeightVal.$timeslotHeightUnit.
668 "; $divWidth".
669 "; $divLeft".
670 "; background:transparent".
671 "; border: none".
672 "' title='".$divTitle."'".
673 " id='".$eventdate."-".$eventid."-".$pccattype."'".
674 ">";
675 $content = $dispstarth . ':' . $startm . " " . $content;
676 echo $content;
677 echo "</div>\n";
680 // output the DIV and content
681 echo "<div class='".$evtClass." event' style='top:".$evtTop."; height:".$evtHeight.
682 "; background-color:".$color.
683 "; $divWidth".
684 "; $divLeft".
685 "' title='".$divTitle."'".
686 " id='".$eventdate."-".$eventid."-".$pccattype."'".
687 ">";
688 // second part for the special IN event
689 if ($event['catid'] != 2) { echo $content; }
690 echo "</div>\n";
692 elseif($_SESSION['pc_facility'] == $row['id']){
693 if ($event['catid'] == 2) {
694 $inTop = ($eStartPos - $timeslotHeightVal).$timeslotHeightUnit;
695 echo "<div class='".$evtClass." event' style='top:".$inTop.
696 "; height:".$timeslotHeightVal.$timeslotHeightUnit.
697 "; $divWidth".
698 "; $divLeft".
699 "; background:transparent".
700 "; border: none".
701 "' title='".$divTitle."'".
702 " id='".$eventdate."-".$eventid."-".$pccattype."'".
703 ">";
704 $content = $dispstarth . ':' . $startm . " " . $content;
705 echo $content;
706 echo "</div>\n";
709 // output the DIV and content
710 echo "<div class='".$evtClass." event' style='top:".$evtTop."; height:".$evtHeight.
711 "; background-color:".$event["catcolor"].
712 "; $divWidth".
713 "; $divLeft".
714 "' title='".$divTitle."'".
715 " id='".$eventdate."-".$eventid."-".$pccattype."'".
716 ">";
717 // second part for the special IN event
718 if ($event['catid'] != 2) { echo $content; }
719 echo "</div>\n";
721 else{
723 if ($event['catid'] == 2) {
724 $inTop = ($eStartPos - $timeslotHeightVal).$timeslotHeightUnit;
725 echo "<div class='".$evtClass." event' style='top:".$inTop.
726 "; height:".$timeslotHeightVal.$timeslotHeightUnit.
727 "; $divWidth".
728 "; $divLeft".
729 "; background:#DDDDDD".
730 "; border: none".
731 "' title='".$divTitle."'".
732 " id='".$eventdate."-".$eventid."-".$pccattype."'".
733 ">";
734 $content = "<span style='color:red;text-align:center;font-weight:bold'>".htmlspecialchars($row['name'],ENT_QUOTES)."</span>";
735 echo $content;
736 echo "</div>\n";
739 // output the DIV and content
740 echo "<div class='".$evtClass." event' style='top:".$evtTop."; height:".$evtHeight.
741 "; background-color:#DDDDDD".
742 "; $divWidth".
743 "; $divLeft".
744 "' title='".$divTitle."'".
745 " id='".$eventdate."-".$eventid."-".$pccattype."'".
746 ">";
747 // second part for the special IN event
748 if ($event['catid'] != 2) { echo "<span style='color:red;text-align:center;font-weight:bold'>".htmlspecialchars($row['name'],ENT_QUOTES)."</span>"; }
749 echo "</div>\n";
751 } // end EVENT loop
753 echo "</div>";
755 } // end date
757 echo "</td>\n";
759 } // end provider loop
760 //============================================================================================================================
761 echo " </tr>\n";
762 echo "</table>\n";
763 echo "<P>";
765 // [-*footer*-]
766 // [-include file="$TPL_NAME/views/global/footer.html"-]
767 // [-include file="$TPL_NAME/views/footer.html"-]
769 [-/php-]
770 </div> <!-- end bigCal DIV -->
771 </div> <!-- end bottom DIV -->
772 </body>
774 <script language='JavaScript'>
776 $(document).ready(function(){
777 $("#pc_username").change(function() { ChangeProviders(this); });
778 $("#pc_facility").change(function() { ChangeProviders(this); });
779 //$("#dayview").click(function() { ChangeView(this); });
780 $("#weekview").click(function() { ChangeView(this); });
781 $("#monthview").click(function() { ChangeView(this); });
782 //$("#yearview").click(function() { ChangeView(this); });
783 $(".tdDatePicker").click(function() { ChangeDate(this); });
784 $(".tdDatePicker").mouseover(function() { $(this).toggleClass("tdDatePickerHighlight"); });
785 $(".tdDatePicker").mouseout(function() { $(this).toggleClass("tdDatePickerHighlight"); });
786 $("#printview").click(function() { PrintView(this); });
787 $(".event").dblclick(function() { EditEvent(this); });
788 $(".event").mouseover(function() { $(this).toggleClass("event_highlight"); });
789 $(".event").mouseout(function() { $(this).toggleClass("event_highlight"); });
792 /* edit an existing event */
793 var EditEvent = function(eObj) {
794 //alert ('editing '+eObj.id);
795 // split the object ID into date and event ID
796 objID = eObj.id;
797 var parts = new Array();
798 parts = objID.split("-");
799 // call the oldEvt function to bring up the event editor
800 oldEvt(parts[0], parts[1], parts[2]);
801 return true;
804 /* change the current date based upon what the user clicked in
805 * the datepicker DIV
807 var ChangeDate = function(eObj) {
808 baseURL = "[-php-]echo pnModURL(__POSTCALENDAR__,'user','view',
809 array('tplview'=>$template_view,
810 'viewtype'=>$viewtype,
811 'Date'=> '~REPLACEME~',
812 'pc_username'=>$pc_username,
813 'pc_category'=>$category,
814 'pc_topic'=>$topic));[-/php-]";
815 newURL = baseURL.replace(/~REPLACEME~/, eObj.id);
816 document.location.href=newURL;
819 /* pop up a window to print the current view
821 var PrintView = function (eventObject) {
822 printURL = "[-php-]echo pnModURL(__POSTCALENDAR__,'user','view',
823 array('tplview'=>$template_view,
824 'viewtype'=>$viewtype,
825 'Date'=> $Date,
826 'print'=> 1,
827 'pc_username'=>$pc_username,
828 'pc_category'=>$category,
829 'pc_topic'=>$topic));[-/php-]";
830 window.open(printURL,'printwindow','width=740,height=480,toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,copyhistory=no,resizable=yes');
831 return false;
834 /* change the provider(s)
836 var ChangeProviders = function (eventObject) {
837 $('#theform').submit();
840 /* change the calendar view
842 var ChangeView = function (eventObject) {
843 if (eventObject.id == "dayview") {
844 $("#viewtype").val('day');
846 else if (eventObject.id == "weekview") {
847 $("#viewtype").val('week');
849 else if (eventObject.id == "monthview") {
850 $("#viewtype").val('month');
852 else if (eventObject.id == "yearview") {
853 $("#viewtype").val('year');
855 $('#theform').submit();
858 </script>
861 </html>