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