[-*Smarty*-] [-*****************************************************************************-] [-* Copyright (C) 2005-2006 Rod Roark and others *-] [-* Copyright (C) 2019 Jerry Padgett *-] [-* *-] [-* 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']); // 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']; $A_EVENTS =& $this->_tpl_vars['A_EVENTS']; $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"; //================================== //FACILITY FILTERING (CHEMED) $facilities = getUserFacilities($_SESSION['authUserID']); // from users_facility if ( $_SESSION['pc_facility'] ) { $provinfo = getProviderInfo('%', true, $_SESSION['pc_facility']); } else { $provinfo = getProviderInfo(); } //EOS FACILITY FILTERING (CHEMED) //================================== $chevron_icon_left = $_SESSION['language_direction'] == 'ltr' ? 'fa-chevron-circle-left' : 'fa-chevron-circle-right'; $chevron_icon_right = $_SESSION['language_direction'] == 'ltr' ? 'fa-chevron-circle-right' : 'fa-chevron-circle-left'; [-/php-]
[-php-] echo "\n"; echo "\n"; if ($Date <> date('Ymd')) { [-/php-] [-xlt t='Today'-] [-php-] } [-/php-]
[-php-] echo " \n";; echo xlt(date('F', strtotime($Date))) . " " . text(date('Y', strtotime($Date))); echo " \n"; [-/php-]
[-php-] echo " \n"; echo " \n"; echo " " . xlt('Day') . "\n"; echo " " . xlt('Week') . "\n"; echo " " . xlt('Month') . "\n"; [-/php-]
[-php-] /* used in debugging foreach ($A_EVENTS as $date => $events) { echo $date." = "; foreach ($events as $oneE) { print_r($oneE); echo "

"; } echo "
"; } */ // This loops once for each provider to be displayed. // foreach ($providers as $provider) { $providerid = $provider['id']; echo "
"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; // output date headers echo " \n"; $defaultDate = ""; // used when creating link for a 'new' event $in_cat_id = 0; // used when creating link for a 'new' event $dowCount = 0; foreach ($A_EVENTS as $date => $events) { if ($defaultDate == "") $defaultDate = date("Ymd", strtotime($date)); echo ""; if ($dowCount++ == 6) { break; } } echo " \n"; // For each day... // output a TD with an inner containing DIV positioned 'relative' foreach ($A_EVENTS as $date => $events) { $eventdate = substr($date, 0, 4) . substr($date, 5, 2) . substr($date, 8, 2); $gotoURL = pnModURL(__POSTCALENDAR__,'user','view', array('tplview'=>($template_view ?? null), 'viewtype'=>'day', 'Date'=> date("Ymd", strtotime($date)), 'pc_username'=>($pc_username ?? null), 'pc_category'=>($category ?? null), 'pc_topic'=>($topic ?? null))); if (date("w", strtotime($date)) == $DOWlist[0]) { echo ""; } $classForWeekend = is_weekend_day(date('w', strtotime($date))) ? 'weekend-day' : 'work-day'; echo ""; if (date("w", strtotime($date)) == $DOWlist[6]) { echo ""; } } // end date echo "
"; echo text($provider['fname']) . " " . text($provider['lname']); echo "
"; echo xlt(date("D", strtotime($date))); echo "
"; echo "
\n"; echo ""; if (count($events) == 0) { echo " "; } //======================================================================================= //======================================================================================= foreach ($events as $event) { // skip events for other providers // yeah, we've got that sort of overhead here... it ain't perfect // $event['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 != $event['aid'] && $event['aid']!=0) { continue; } // Omit IN and OUT events to reduce clutter in this month view if (($event['catid'] == 2) || ($event['catid'] == 3)) { 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; $startDateTime = strtotime($date." ".$event['startTime']); // 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 hiddenevent"; break; case 8: // LUNCH $evtClass = "event_reserved"; break; case 11: // RESERVED $evtClass = "event_reserved"; break; default: // some appointment $evtClass = "event_appointment"; break; } // now, output the event DIV $eventid = $event['eid'] ?? null; $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 = oeFormatShortDate($event['patient_dob']); $patient_age = $event['patient_age']; $catid = $event['catid'] ?? null; $comment = $event['hometext']; $catname = $event['catname']; $title = "Age $patient_age ($patient_dob)"; //Variables for therapy groups $groupid = $event['gid']; if($groupid) $patientid = ''; $groupname = $event['group_name']; $grouptype = $event['group_type']; $groupstatus = $event['group_status']; $groupcounselors = ''; foreach($event['group_counselors'] as $counselor){ $groupcounselors .= getUserNameById($counselor) . " \n "; } // format the time specially $displayTime = date("g", $startDateTime); if (date("i", $startDateTime) == "00") { $displayTime .= (date("a", $startDateTime)); } else { $displayTime .= (date(":ia", $startDateTime)); } if ($comment && $GLOBALS['calendar_appt_style'] < 4) $title .= " " . $comment; // the divTitle is what appears when the user hovers the mouse over the DIV $divTitle = dateformat (strtotime($date),true); $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" . $row['name']; $content = ""; if ($catid == 4 || $catid == 8 || $catid == 11) { 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 .= text($displayTime); $content .= " " . text($catname); } else { // some sort of patient appointment if($groupid){ $divTitle .= "\n" . xl('Counselors') . ": \n" . $groupcounselors . " \n"; $divTitle .= "\r\n[" . $catname . ' ' . $comment . "]" . $groupname; } else $divTitle .= "\r\n[" . $catname . ' ' . $comment . "]" . $fname . " " . $lname; $content .= create_event_time_anchor($displayTime); if ($patientid) { // include patient name and link to their details $link_title = $fname . " " . $lname . " \n"; $link_title .= xl('Age') . ": " . $patient_age . "\n" . xl('DOB') . ": " . $patient_dob . $comment . "\n"; $link_title .= "(" . xl('Click to view') . ")"; $content .= ""; $content .= "View Patient"; if ($catid == 1) $content .= ""; $content .= text($lname); if ($GLOBALS['calendar_appt_style'] != 1) { $content .= "," . text($fname); if ($event['title'] && $GLOBALS['calendar_appt_style'] >= 3) { $content .= "(" . text($event['title']); if ($event['hometext'] && $GLOBALS['calendar_appt_style'] >= 4) $content .= ": " . text(trim($event['hometext'])) . ""; $content .= ")"; } } if ($catid == 1) $content .= ""; $content .= ""; } elseif($groupid){ $divTitle .= "\n" . getTypeName($grouptype) . "\n"; $link_title = ''; $link_title .= $divTitle ."\n"; $link_title .= "(" . xl('Click to view') . ")"; $content .= ""; $content .= "View Patient"; if ($catid == 1) $content .= ""; $content .= text($groupname); if ($GLOBALS['calendar_appt_style'] != 1) { if ($event['title'] && $GLOBALS['calendar_appt_style'] >= 3) { $content .= "(" . text($event['title']); if ($event['hometext'] && $GLOBALS['calendar_appt_style'] >= 4) $content .= ": " . text(trim($event['hometext'])) . ""; $content .= ")"; } } if ($catid == 1) $content .= ""; $content .= ""; //Add class to wrapping div so EditEvent js function can differentiate between click on group and patient $evtClass .= ' groups '; } 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)); } } } if ( $catid != 6){ $divTitle .= "\n(" . xl('double click to edit') . ")"; } if($_SESSION['pc_facility'] == 0){ echo "
"; echo $content; echo "
\n"; } elseif($_SESSION['pc_facility'] == $row['id']){ echo "
"; echo $content; echo "
\n"; } else{ echo "
"; echo "" . text($displayTime) . " " . text($row['name']).""; echo "
\n"; } } // end EVENT loop //======================================================================================= //======================================================================================= echo "
"; echo "
\n"; echo "
"; } // end provider [-/php-]