[-*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"-] [-* DO NOT INCLUDE the default header, * which includes a stylesheet to screw up * our styles below *-] [-*include file="$TPL_NAME/views/header.html"*-] [-*Values used in setting timeslot and event heights*-] [-php-]$timeslotHeightVal=20; $timeslotHeightUnit="px";[-/php-] [-headerTemplate assets='no_bootstrap|no_fontawesome|no_main-theme|no_dialog'-] [-php-] // 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. // $A_CATEGORY =& $this->_tpl_vars['A_CATEGORY']; $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']; $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); $MULTIDAY = count($A_EVENTS) > 1; [-/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-] // start out without adding a pagebreak $addPagebreak = false; // This loops once for each provider to be displayed. // foreach ($providers as $provider) { // output a pagebreak, if needed if ($addPagebreak) { echo "
\n"; } $addPagebreak = true; echo "
"; echo "
"; // output the provider name echo "" . text($provider['fname']) . " " . text($provider['lname']) . ""; echo "
"; // output the date range echo ""; $atmp = array_keys($A_EVENTS); echo xlt(date('F', strtotime($atmp[0]))) . " " . text(date('d', strtotime($atmp[0]))); echo " -
"; echo xlt(date('F', strtotime($atmp[count($atmp)-1]))) . " " . text(date('d', strtotime($atmp[count($atmp)-1]))); echo "
"; echo "
"; // output a calendar for the subsequent month list($nyear, $nmonth, $nday) = explode(" ", date("Y m d", strtotime($atmp[0]))); $nmonth++; if ($nmonth > 12) { $nyear++; $nmonth=1; } echo "
"; PrintDatePicker(strtotime($nyear."-".$nmonth."-1"), $DOWlist, $this->_tpl_vars['A_SHORT_DAY_NAMES']); echo "
"; // output a small calendar for the chosen month echo "
"; PrintDatePicker(strtotime($atmp[0]), $DOWlist, $this->_tpl_vars['A_SHORT_DAY_NAMES']); echo "
"; echo "
"; // end the bigCalHeader $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']; // For each day... // output a TD with an inner containing DIV positioned 'relative' echo ""; $loopcount = 0; foreach ($A_EVENTS as $date => $events) { echo ""; $eventdate = substr($date, 0, 4) . substr($date, 5, 2) . substr($date, 8, 2); // each date gets it's own header echo ""; // limit the times through this loop by the limit of four TRs if ($loopcount++ >= 3) break; } // end date echo "
". xlt(date("D",strtotime($eventdate))) . " " . text(date("m/d", strtotime($eventdate))) . "
"; // output the events for this date PrintEvents($events, $providerid, ($TPL_IMAGE_PATH ?? null)); // now output the events for this date+4, if they exist echo "
"; $dateplusfour = strtotime($eventdate) + (4 * 24 * 60 * 60); if (isset($A_EVENTS[date("Y-m-d", $dateplusfour)])) { echo "
". xlt(date("D",$dateplusfour)) . " " . text(date("m/d", $dateplusfour)) . "
"; $tmpEvents = $A_EVENTS[date("Y-m-d", $dateplusfour)]; PrintEvents($tmpEvents, $providerid, ($TPL_IMAGE_PATH ?? null)); } echo "
\n"; } // end provider /* print out the array of events */ function PrintEvents($events, $providerid, $TPL_IMAGE_PATH) { global $times, $calStartMin, $calEndMin, $timeslotHeightVal, $timeslotHeightUnit; // 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 (!empty($event['aid']) && ($providerid != $event['aid'])) { continue; } // skip events without an ID (why they are in the loop, I have no idea) if (empty($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; // 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; } // eventViewClass allows the event class to override the template (such as from a dispatched system event). $evtClass = $event['eventViewClass'] ?? $evtClass; // 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 (!empty($outevent['aid']) && ($providerid != $outevent['aid'])) { continue; } // skip events with blank IDs if (empty($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 if (empty($interval)) { $eStartInterval = 0; } else { $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); $eMinDiff = $eEndMin - $eStartMin; // diff divided by the time interval of the schedule if (empty($interval)) { $eEndInterval = 0; } else { $eEndInterval = $eMinDiff / $interval; } // times the interval height $eHeight = $eEndInterval * $timeslotHeightVal; $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']; $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 = $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 = date("D, d M Y", strtotime($date ?? null)); $eventdatetime = strtotime(($date ?? '')." ".$starth.":".$startm); 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"); $content .= text(date("h:i", $eventdatetime)); if ($event['recurrtype'] == 1) $content .= "Repeating event"; $content .= " " . text($catname); if ($comment) $content .= " " . text($comment); } else { // some sort of patient appointment $content .= ""; $content .= text(date("h:i", $eventdatetime)) . " "; if ($event['recurrtype'] == 1) $content .= "Repeating event"; if ($patientid) { 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 .= ""; } else { // no patient id, just output the category name $content .= text($catname); } $content .= ""; } $divTitle .= "\n(double click to edit)"; // output the DIV and content echo "
"; echo $content; echo "
"; } // end EVENT loop return; } /* output a small calendar, based on the date-picker code from the normal calendar */ function PrintDatePicker($caldate, $DOWlist, $daynames) { $cMonth = date("m", $caldate); $cYear = date("Y", $caldate); $cDay = date("d", $caldate); echo ''; echo ''; echo ''; echo ''; echo ''; foreach ($DOWlist as $dow) { echo ""; } echo ''; // 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"); while (date('w', $startdate) != $DOWlist[0]) { $startdate -= 60*60*24; } $enddate = strtotime($year.$month.date("t", $month)); while (date('w', $enddate) != $DOWlist[6]) { $enddate += 60*60*24; } $currdate = $startdate; while ($currdate <= $enddate) { if (date('w', $currdate) == $DOWlist[0]) { echo ""; } // we skip outputting some days $skipit = false; // set the TD class $tdClass = "tdMonthDay-small"; if (date('m', $currdate) != $month) { $tdClass = "tdOtherMonthDay-small"; $skipit = true; } if ((date('w', $currdate) == 0) || (date('w', $currdate) == 6)) { $tdClass = "tdWeekend-small"; } if (!empty($Date) && (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 = ""; } else { echo $td; } // end of week row if (date('w', $currdate) == $DOWlist[6]) echo "\n"; // time correction = plus 1000 seconds, for some unknown reason $currdate += (60*60*24)+1000; } echo "
'; echo text(date('F Y', $caldate)); echo '
" . text($daynames[$dow]) . "
\n"; if ($skipit == true) { echo "
"; } [-/php-]