[-*Smarty*-] [-*****************************************************************************-] [-* Copyright (C) 2005-2006 Rod Roark and others *-] [-* *-] [-* This program is free software; you can redistribute it and/or *-] [-* modify it under the terms of the GNU General Public License *-] [-* as published by the Free Software Foundation; either version 2 *-] [-* of the License, or (at your option) any later version. *-] [-*****************************************************************************-] [-config_load file="default.conf"-] [-*Load the Language Definitions*-] [-config_load file="lang.$USER_LANG"-] [-include file="$TPL_NAME/views/header.html"-] [-*Values used in setting timeslot and event heights*-] [-php-] /* if you change these be sure to change their matching values in * the CSS for the calendar, found in interface/themes/ajax_calendar.css */ $timeslotHeightVal=20; $timeslotHeightUnit="px"; [-/php-] [-php-] // this is my proposed setting in the globals config file so we don't // need to mess with altering the pn database AND the config file //pnModSetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek', $GLOBALS['schedule_dow_start']); $openhour= $GLOBALS['schedule_start']; $closehour= $GLOBALS['schedule_end']; // build a day-of-week (DOW) list so we may properly build the calendars later in this code $DOWlist = array(); $tmpDOW = pnModGetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek'); // bound check and auto-correction if ($tmpDOW <0 || $tmpDOW >6) { pnModSetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek', '0'); $tmpDOW = 0; } while (count($DOWlist) < 7) { array_push($DOWlist, $tmpDOW); $tmpDOW++; if ($tmpDOW > 6) $tmpDOW = 0; } // A_CATEGORY is an ordered array of associative-array categories. // Keys of interest are: id, name, color, desc, event_duration. // // echo "\n"; // debugging // echo "\n"; // debugging $A_CATEGORY =& $this->_tpl_vars['A_CATEGORY']; // [-if $PRINT_VIEW != 1-] // [-*Main Navigation*-] // [-include file="$TPL_NAME/views/global/navigation.html"-] // [-/if-] $A_EVENTS =& $this->_tpl_vars['A_EVENTS']; // $S_EVENTS =& $this->_tpl_vars['S_EVENTS']; // Deleted by Rod $providers =& $this->_tpl_vars['providers']; $times =& $this->_tpl_vars['times']; $interval = $this->_tpl_vars['interval']; $viewtype = $this->_tpl_vars['VIEW_TYPE']; $PREV_WEEK_URL = $this->_tpl_vars['PREV_WEEK_URL']; $NEXT_WEEK_URL = $this->_tpl_vars['NEXT_WEEK_URL']; $PREV_DAY_URL = $this->_tpl_vars['PREV_DAY_URL']; $NEXT_DAY_URL = $this->_tpl_vars['NEXT_DAY_URL']; $PREV_MONTH_URL = $this->_tpl_vars['PREV_MONTH_URL']; $NEXT_MONTH_URL = $this->_tpl_vars['NEXT_MONTH_URL']; $Date = postcalendar_getDate(); if (!isset($y)) $y = substr($Date, 0, 4); if (!isset($m)) $m = substr($Date, 4, 2); if (!isset($d)) $d = substr($Date, 6, 2); // echo "\n"; $MULTIDAY = count($A_EVENTS) > 1; //================================== //FACILITY FILTERING (CHEMED) $facilities = getUserFacilities($_SESSION['authId']); // from users_facility if ( $_SESSION['pc_facility'] ) { $provinfo = getProviderInfo('%', true, $_SESSION['pc_facility']); } else { $provinfo = getProviderInfo(); } //EOS FACILITY FILTERING (CHEMED) //================================== [-/php-]
[-php-] echo " \n"; echo " \n"; [-/php-]
[-php-] if ($Date <> date('Ymd')) { [-/php-] [-php-] echo xl("Today")[-/php-] [-php-] } echo " \n"; $atmp = array_keys($A_EVENTS); echo dateformat (strtotime($atmp[0]),true); echo " \n"; [-/php-]
[-php-] $atmp = array_keys($A_EVENTS); $caldate = strtotime($atmp[0]); $cMonth = date("m", $caldate); $cYear = date("Y", $caldate); $cDay = date("d", $caldate); include_once($GLOBALS['webserver_root'].'/interface/main/calendar/modules/PostCalendar/pntemplates/default/views/monthSelector.php'); [-/php-] [-php-] // compute the previous month date // stay on the same day if possible $pDay = $cDay; $pMonth = $cMonth - 1; $pYear = $cYear; if ($pMonth < 1) { $pMonth = 12; $pYear = $cYear - 1; } while (! checkdate($pMonth, $pDay, $pYear)) { $pDay = $pDay - 1; } $prevMonth = sprintf("%d%02d%02d",$pYear,$pMonth,$pDay); // compute the next month // stay on the same day if possible $nDay = $cDay; $nMonth = $cMonth + 1; $nYear = $cYear; if ($nMonth > 12) { $nMonth = 1; $nYear = $cYear + 1; } while (! checkdate($nMonth, $nDay, $nYear)) { $nDay = $nDay - 1; } $nextMonth = sprintf("%d%02d%02d",$nYear,$nMonth,$nDay); [-/php-] [-php-] foreach ($DOWlist as $dow) { echo ""; } [-/php-] [-php-] $atmp = array_keys($A_EVENTS); $caldate = strtotime($atmp[0]); $caldateEnd = strtotime($atmp[6]); // to make a complete week row we need to compute the real // start and end dates for the view list ($year, $month, $day) = explode(" ", date('Y m d', $caldate)); $startdate = strtotime($year.$month."01"); $enddate = strtotime($year.$month.date("t", $startdate)." 23:59"); while (date('w', $startdate) != $DOWlist[0]) { $startdate -= 60*60*24; } while (date('w', $enddate) != $DOWlist[6]) { $enddate += 60*60*24; } $currdate = $startdate; while ($currdate <= $enddate) { if (date('w', $currdate) == $DOWlist[0]) { // start of week row $tr = ""; echo $tr; } // set the TD class $tdClass = "tdMonthDay-small"; if (date('m', $currdate) != $month) { $tdClass = "tdOtherMonthDay-small"; } if (is_weekend_day(date('w', $currdate))) { $tdClass = "tdWeekend-small"; } if (is_holiday(date('Y-m-d', $currdate))) { $tdClass = "tdHoliday-small"; } if (date('Ymd',$currdate) == $Date) { // $Date is defined near the top of this file // and is equal to whatever date the user has clicked $tdClass .= " currentDate"; } // add a class so that jQuery can grab these days for the 'click' event $tdClass .= " tdDatePicker"; // output the TD $td = "\n"; // time correction = plus 1000 seconds, for some unknown reason //$currdate += (60*60*24)+1000; //////// $currdate = strtotime("+1 day", $currdate); //////// } [-/php-]
< [-php-] echo xl(date('F', $caldate)); [-/php-] >
".$this->_tpl_vars['A_SHORT_DAY_NAMES'][$dow]."
\n"; echo $td; // end of week row if (date('w', $currdate) == $DOWlist[6]) echo "
[-php-] xl('Providers','e'); [-/php-]
[-php-] // ============================== // FACILITY FILTERING (lemonsoftware) /********************************************************************* $facilities = getFacilities(); *********************************************************************/ if ($_SESSION['authorizeduser'] == 1) { $facilities = getFacilities(); } else { $facilities = getUserFacilities($_SESSION['authId']); // from users_facility if (count($facilities) == 1) $_SESSION['pc_facility'] = key($facilities); } /********************************************************************/ if (count($facilities) > 1) { echo " \n"; } // EOS FF // ============================== echo "
"; echo " \n"; [-/php-]
[-php-] if($_SESSION['pc_facility'] == 0){ [-/php-]
[-php-] foreach ($facilities as $f){ echo " "; } [-/php-]
".htmlspecialchars($f['name'],ENT_QUOTES)."
[-php-] } [-/php-] [-assign var="dayname" value=$DATE|date_format:"%w"-] [-assign var="day" value=$DATE|date_format:"%d"|string_format:"%1d"-] [-assign var="month" value=$DATE|date_format:"%m"|string_format:"%1d"-] [-assign var="year" value=$DATE|date_format:"%Y"|string_format:"%4d"-] [-pc_sort_events var="S_EVENTS" sort="time" order="asc" value=$A_EVENTS-]
[-php-] /* used in debugging foreach ($A_EVENTS as $date => $events) { echo $date." = "; foreach ($events as $oneE) { print_r($oneE); echo "

"; } echo "
"; } */ echo "\n"; // output the TD with the times DIV echo ""; echo ""; // This loops once for each provider to be displayed. // foreach ($providers as $provider) { $providerid = $provider['id']; // to specially handle the IN/OUT events I'm doing something new here // for each IN event it will have a duration lasting until the next // OUT event or until the end of the day $tmpTime = $times[0]; $calStartMin = ($tmpTime['hour'] * 60) + $tmpTime['minute']; $tmpTime = $times[count($times)-1]; $calEndMin = ($tmpTime['hour'] * 60) + $tmpTime['minute']; // having a 'title' for the TD makes the date appear by the mouse pointer // this is nice when all you see are times on the left side and no head // row with the dates or day-of-week (DOW) $classForWeekend = is_weekend_day(date('w', $caldate)) ? 'weekend-day' : 'work-day'; echo "\n"; } // end provider loop //============================================================================================================================ echo " \n"; echo "
\n"; echo ""; //============================================================================================================================ foreach ($times as $slottime) { $startampm = ($slottime['mer']) == "pm" ? 2 : 1; $starttimeh = $slottime['hour']; $disptimeh = ($starttimeh > 12) ? ($starttimeh - 12) : $starttimeh; $starttimem = $slottime['minute']; $slotendmins = $starttimeh * 60 + $starttimem + $interval; // default to the first displayed provider $providerid = $providers[0]['id']; echo "\n"; } echo "
 
"; echo ""; echo "$disptimeh:$starttimem"; echo ""; echo "
"; echo "
"; echo htmlspecialchars($provider['fname'],ENT_QUOTES)." ".htmlspecialchars($provider['lname'],ENT_QUOTES)."
"; echo "
"; // For each event... // output a TD with an inner containing DIV positioned 'relative' // within that DIV we place our event DIVs using 'absolute' positioning foreach ($A_EVENTS as $date => $events) { $eventdate = substr($date, 0, 4) . substr($date, 5, 2) . substr($date, 8, 2); // determine if events overlap and adjust their width and left position as needed // 26 Feb 2008 - This needs fine tuning or total replacement // - it doesn't work as well as I'd like - JRM $eventPositions = array(); foreach ($times as $slottime) { $starttimeh = $slottime['hour']; $starttimem = $slottime['minute']; $slotstartmins = $starttimeh * 60 + $starttimem; $slotendmins = $starttimeh * 60 + $starttimem + $interval; $events_in_timeslot = array(); foreach ($events as $e1) { // ignore IN event if (($e1['catid'] == 2)) { continue; } // skip events without an ID (why they are in the loop, I have no idea) if ($e1['eid'] == "") { continue; } // skip events for other providers // $e1['aid']!=0 :With the holidays we included clinic events, they have provider id =0 // we dont want to exclude those events from being displayed if ($providerid != $e1['aid'] && $e1['aid'] != 0) { continue; } // specially handle all-day events if ($e1['alldayevent'] == 1) { $tmpTime = $times[0]; if (strlen($tmpTime['hour']) < 2) { $tmpTime['hour'] = "0".$tmpTime['hour']; } if (strlen($tmpTime['minute']) < 2) { $tmpTime['minute'] = "0".$tmpTime['minute']; } $e1['startTime'] = $tmpTime['hour'].":".$tmpTime['minute'].":00"; $e1['duration'] = ($calEndMin - $calStartMin) * 60; // measured in seconds } // create a numeric start and end for comparison $starth = substr($e1['startTime'], 0, 2); $startm = substr($e1['startTime'], 3, 2); $e1Start = ($starth * 60) + $startm; $e1End = $e1Start + $e1['duration']/60; // three ways to overlap: // start-in, end-in, span if ((($e1Start >= $slotstartmins) && ($e1Start < $slotendmins)) // start-in || (($e1End > $slotstartmins) && ($e1End <= $slotendmins)) // end-in || (($e1Start < $slotstartmins) && ($e1End > $slotendmins))) // span { array_push($events_in_timeslot, $e1['eid']); if($e1['catid'] == 3) { array_pop($events_in_timeslot); array_unshift($events_in_timeslot, $e1['eid']); } } } $leftpos = 0; $width = 100 / count($events_in_timeslot); // loop over the events in this timeslot and adjust their width foreach ($events_in_timeslot as $eid) { // set the width if not already set or if the current width is smaller // than was was previously set if (!isset($eventPositions[$eid]->width)) { $eventPositions[$eid]->width = $width; } else if ($eventPositions[$eid]->width > $width) { $eventPositions[$eid]->width = $width; } // set the left position if not already set or if the current left is // greater than what was previously set if (!isset($eventPositions[$eid]->leftpos)) { $eventPositions[$eid]->leftpos = $leftpos; } else if ($eventPositions[$eid]->leftpos < $leftpos) { $eventPositions[$eid]->leftpos = $leftpos; } // increment the leftpos by the width $leftpos += $width; } } // end overlap detection // now loop over the events for the day and output their DIVs foreach ($events as $event) { // skip events for other providers // yeah, we've got that sort of overhead here... it ain't perfect if ($providerid != $event['aid'] && $event['aid']!=0) { continue; } // skip events without an ID (why they are in the loop, I have no idea) if ($event['eid'] == "") { continue; } // specially handle all-day events if ($event['alldayevent'] == 1) { $tmpTime = $times[0]; if (strlen($tmpTime['hour']) < 2) { $tmpTime['hour'] = "0".$tmpTime['hour']; } if (strlen($tmpTime['minute']) < 2) { $tmpTime['minute'] = "0".$tmpTime['minute']; } $event['startTime'] = $tmpTime['hour'].":".$tmpTime['minute'].":00"; $event['duration'] = ($calEndMin - $calStartMin) * 60; // measured in seconds } // figure the start time and minutes (from midnight) $starth = substr($event['startTime'], 0, 2); $startm = substr($event['startTime'], 3, 2); $eStartMin = $starth * 60 + $startm; $dispstarth = ($starth > 12) ? ($starth - 12) : $starth; // used to display the hour //fix bug 456 and 455 //check to see if the event is in the clinic hours range, if not it will not be displayed if ( (int)$starth < (int)$openhour || (int)$starth > (int)$closehour ){ continue; } // determine the class for the event DIV based on the event category $evtClass = "event_appointment"; switch ($event['catid']) { case 1: // NO-SHOW appt $evtClass = "event_noshow"; break; case 2: // IN office $evtClass = "event_in"; break; case 3: // OUT of office $evtClass = "event_out"; break; case 4: // VACATION $evtClass = "event_reserved"; break; case 6: // HOLIDAY $evtClass = "event_holiday"; break; case 8: // LUNCH $evtClass = "event_reserved"; break; case 11: // RESERVED $evtClass = "event_reserved"; break; default: // some appointment $evtClass = "event_appointment"; break; } // if this is an IN or OUT event then we have some extra special // processing to be done // the IN event creates a DIV until the OUT event // or, without an OUT DIV matching the IN event // then the IN event runs until the end of the day if ($event['catid'] == 2) { // locate a matching OUT for this specific IN $found = false; $outMins = 0; foreach ($events as $outevent) { // skip events for other providers if ($providerid != $outevent['aid']) { continue; } // skip events with blank IDs if ($outevent['eid'] == "") { continue; } if ($outevent['eid'] == $event['eid']) { $found = true; continue; } if (($found == true) && ($outevent['catid'] == 3)) { // calculate the duration from this event to the outevent $outH = substr($outevent['startTime'], 0, 2); $outM = substr($outevent['startTime'], 3, 2); $outMins = ($outH * 60) + $outM; $event['duration'] = ($outMins - $eStartMin) * 60; // duration is in seconds $found = 2; break; } } if ($outMins == 0) { // no OUT was found so this event's duration goes // until the end of the day $event['duration'] = ($calEndMin - $eStartMin) * 60; // duration is in seconds } } // calculate the TOP value for the event DIV // diff between event start and schedule start $eMinDiff = $eStartMin - $calStartMin; // diff divided by the time interval of the schedule $eStartInterval = $eMinDiff / $interval; // times the interval height $eStartPos = $eStartInterval * $timeslotHeightVal; $evtTop = $eStartPos.$timeslotHeightUnit; // calculate the HEIGHT value for the event DIV // diff between end and start of event $eEndMin = $eStartMin + ($event['duration']/60); // prevent the overall height of the event from going beyond the bounds // of the time table if ($eEndMin > $calEndMin) { $eEndMin = $calEndMin + $interval; } $eMinDiff = $eEndMin - $eStartMin; // diff divided by the time interval of the schedule $eEndInterval = $eMinDiff / $interval; // times the interval height $eHeight = $eEndInterval * $timeslotHeightVal; if($event['catid']==3) { // An "OUT" that is "zero duration" still needs height so we can click it. $eHeight = $eEndInterval==0 ? $timeslotHeightVal : $eHeight ; } $evtHeight = $eHeight.$timeslotHeightUnit; // determine the DIV width based on any overlapping events // see further above for the overlapping calculation code $divWidth = ""; $divLeft = ""; if (isset($eventPositions[$event['eid']])) { $divWidth = "width: ".$eventPositions[$event['eid']]->width."%"; $divLeft = "left: ".$eventPositions[$event['eid']]->leftpos."%"; } $eventid = $event['eid']; $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."'"); $pccattype = ''; if($eventtype['pc_cattype']==1) $pccattype = 'true'; $patientid = $event['pid']; $commapos = strpos($event['patient_name'], ","); $lname = substr($event['patient_name'], 0, $commapos); $fname = substr($event['patient_name'], $commapos + 2); $patient_dob = $event['patient_dob']; $patient_age = $event['patient_age']; $catid = $event['catid']; $comment = addslashes($event['hometext']); $catname = $event['catname']; $title = "Age $patient_age ($patient_dob)"; $content = ""; if ($comment && $GLOBALS['calendar_appt_style'] < 4) $title .= " " . $comment; // the divTitle is what appears when the user hovers the mouse over the DIV $divTitle = htmlspecialchars($provider["fname"],ENT_QUOTES)." ".htmlspecialchars($provider["lname"],ENT_QUOTES); $result = sqlStatement("SELECT name,id,color FROM facility WHERE id=(SELECT pc_facility FROM openemr_postcalendar_events WHERE pc_eid=".$eventid.")"); $row = sqlFetchArray($result); $color=$event["catcolor"]; if($GLOBALS['event_color']==2) $color=$row['color']; $divTitle .= "\n" .htmlspecialchars($row['name'],ENT_QUOTES); if ($catid == 2 || $catid == 3 || $catid == 4 || $catid == 8 || $catid == 11) { if ($catid == 2) $catname = xl("IN"); else if ($catid == 3) $catname = xl("OUT"); else if ($catid == 4) $catname = xl("VACATION"); else if ($catid == 8) $catname = xl("LUNCH"); else if ($catid == 11) $catname = xl("RESERVED"); $atitle = $catname; if ($comment) $atitle .= " $comment"; $divTitle .= "\n[".$atitle ."]"; $content .= $catname; if ($event['recurrtype'] > 0) $content .= "".htmlspecialchars(xl("Repeating event"),ENT_QUOTES).""; if ($comment) $content .= " $comment"; } else { // some sort of patient appointment $divTitle .= "\r\n[".$catname.' '.htmlspecialchars($comment, ENT_QUOTES) ."]".htmlspecialchars($fname, ENT_QUOTES)." ".htmlspecialchars($lname, ENT_QUOTES); $content .= ""; $content .= create_event_time_anchor($dispstarth.":".$startm); if ($event['recurrtype'] > 0) $content .= "".htmlspecialchars(xl("Repeating event"),ENT_QUOTES).""; // $content .= htmlspecialchars($event['apptstatus']); $content .= ' '.htmlspecialchars($event['apptstatus']); if ($patientid) { $link_title = htmlspecialchars($fname,ENT_QUOTES)." ".htmlspecialchars($lname,ENT_QUOTES). " \n"; $link_title .= xl('Age') . ": ".$patient_age."\n" . xl('DOB') . ": ".$patient_dob.htmlspecialchars($comment, ENT_QUOTES)."\n"; $link_title .= "(" . xl('Click to view') . ")"; $content .= ""; $content .= "View Patient"; if ($catid == 1) $content .= ""; $content .= htmlspecialchars($lname); if ($GLOBALS['calendar_appt_style'] != 1) { $content .= "," . htmlspecialchars($fname); if ($event['title'] && $GLOBALS['calendar_appt_style'] >= 3) { $content .= "(" . $event['title']; if ($event['hometext'] && $GLOBALS['calendar_appt_style'] >= 4) $content .= ": " . htmlspecialchars(trim($event['hometext'])) . ""; $content .= ")"; } } if ($catid == 1) $content .= ""; $content .= ""; } else { //Category Clinic closaed or holiday take the event title if ( $catid ==6 || $catid == 7){ $content = xlt($event['title']); }else{ // no patient id, just output the category name $content .= text(xl_appt_category($catname)); } } $content .= ""; } $divTitle .= "\n(" . xl('double click to edit') . ")"; if($_SESSION['pc_facility'] == 0){ // a special case for the 'IN' event this puts the time ABOVE // the normal DIV so it doesn't overlap another event DIV and include the time if ($event['catid'] == 2) { $inTop = 20+($eStartPos - $timeslotHeightVal).$timeslotHeightUnit; echo "
"; $content = $dispstarth . ':' . $startm . " " . $content; echo $content; echo "
\n"; } // output the DIV and content // For "OUT" events, applying the background color in CSS. if ($event['catid']!="6" && $event['catid']!="4" ){ $background_string= ($event['catid'] == 3) ? "" : ";background-color:".$color; echo "
"; } else{ $background_string= ";background-color:".$color; echo "
"; } // second part for the special IN event if ($event['catid'] != 2) { echo $content; } echo "
\n"; } elseif($_SESSION['pc_facility'] == $row['id']){ if ($event['catid'] == 2) { $inTop = 20+($eStartPos - $timeslotHeightVal).$timeslotHeightUnit; echo "
"; $content = $dispstarth . ':' . $startm . " " . $content; echo $content; echo "
\n"; } // output the DIV and content // For "OUT" events, applying the background color in CSS. $background_string= ($event['catid'] == 3) ? "" : "; background-color:".$event["catcolor"]; echo "
"; // second part for the special IN event if ($event['catid'] != 2) { echo $content; } echo "
\n"; } else{ if ($event['catid'] == 2) { $inTop = 20+($eStartPos - $timeslotHeightVal).$timeslotHeightUnit; echo "
"; $content = "".htmlspecialchars($row['name'],ENT_QUOTES).""; echo $content; echo "
\n"; } // output the DIV and content echo "
"; // second part for the special IN event if ($event['catid'] != 2) { echo "".htmlspecialchars($row['name'],ENT_QUOTES).""; } echo "
\n"; } } // end EVENT loop echo "
"; } // end date echo "
\n"; echo "

"; // [-*footer*-] // [-include file="$TPL_NAME/views/global/footer.html"-] // [-include file="$TPL_NAME/views/footer.html"-] [-/php-]