2 [-*****************************************************************************-]
3 [-* Copyright (C)
2005-
2006 Rod Roark
<rod@sunsetsystems.com
> and others *-]
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"-]
14 [-* we want to include out stylesheet for this view*-]
15 [-fetch
file=
"$TPL_STYLE_PATH/day.css" assign=
"css"-]
18 [-*Values used in setting timeslot and event heights*-]
19 [-php-]$timeslotHeightVal=
20; $
timeslotHeightUnit=
"px";[-/php-]
26 font-family: Arial, Helvetica, sans-serif;
28 div.tiny { width:
1px; height:
1px; font-size:
1px; }
35 font-family: Arial, Helvetica, sans-serif;
46 background-color: lightblue;
49 font-family: Arial, Helvetica, sans-serif;
55 font-family: Arial, Helvetica, sans-serif;
59 background-color: lightblue;
63 border-collapse: collapse;
66 /* these are for the small datepicker DIV */
68 border-collapse: collapse;
69 border:
3px solid lightblue;
71 #datePicker .tdDOW-small {
72 font-family: Arial, Helvetica, sans-serif;
75 background-color: lightblue;
78 padding:
2px
3px
2px
3px;
80 #datePicker .tdDatePicker {
84 #datePicker .tdWeekend-small {
85 font-family: Arial, Helvetica, sans-serif;
89 padding:
2px
3px
2px
3px;
90 background-color: #dddddd;
94 #datePicker .tdOtherMonthDay-small {
95 font-family: Arial, Helvetica, sans-serif;
99 padding:
2px
3px
2px
3px;
100 background-color: #ffffff;
104 #datePicker .tdMonthName-small {
106 font-family: Arial, Helvetica, sans-serif;
111 #datePicker .tdMonthDay-small {
112 font-family: Arial, Helvetica, sans-serif;
116 padding:
2px
3px
2px
3px;
117 background-color: #ffffff;
119 #datePicker .currentWeek {
120 border-top:
1px solid blue;
121 border-bottom:
1px solid blue;
122 background-color: lightblue;
124 #datePicker .currentDate {
125 border:
1px solid blue;
126 background-color: blue;
130 /* the DIV of times */
132 border-right:
1px solid #
999;
135 border-collapse: collapse;
142 border-top:
1px solid #
999;
148 height: [-php-]echo $timeslotHeightVal.$timeslotHeightUnit;[-/php-];
153 background-color: pink;
157 border-right:
1px solid black;
159 /* types of events */
162 background-color: white;
167 border-top:
1px dashed #ddd;
171 background-color: lightgray;
176 border-top:
1px dashed #ddd;
180 background-color: white;
183 border:
1px solid blue;
189 background-color: pink;
192 border:
1px solid blue;
198 background-color: pink;
201 border:
1px solid blue;
207 <script type=
"text/javascript" src=
"../../../library/textformat.js"></script>
211 // A_CATEGORY is an ordered array of associative-array categories.
212 // Keys of interest are: id, name, color, desc, event_duration.
215 $A_CATEGORY =& $this-
>_tpl_vars['A_CATEGORY'];
217 // [-if $PRINT_VIEW !=
1-]
218 // [-*Main Navigation*-]
219 // [-include
file=
"$TPL_NAME/views/global/navigation.html"-]
222 $A_EVENTS =& $this-
>_tpl_vars['A_EVENTS'];
223 // $S_EVENTS =& $this-
>_tpl_vars['S_EVENTS']; // Deleted by Rod
224 $providers =& $this-
>_tpl_vars['providers'];
225 $times =& $this-
>_tpl_vars['times'];
226 $interval = $this-
>_tpl_vars['interval'];
227 $viewtype = $this-
>_tpl_vars['VIEW_TYPE'];
228 $PREV_WEEK_URL = $this-
>_tpl_vars['PREV_WEEK_URL'];
229 $NEXT_WEEK_URL = $this-
>_tpl_vars['NEXT_WEEK_URL'];
230 $PREV_DAY_URL = $this-
>_tpl_vars['PREV_DAY_URL'];
231 $NEXT_DAY_URL = $this-
>_tpl_vars['NEXT_DAY_URL'];
233 $Date = postcalendar_getDate();
234 if (!isset($y)) $y = substr($Date,
0,
4);
235 if (!isset($m)) $m = substr($Date,
4,
2);
236 if (!isset($d)) $d = substr($Date,
6,
2);
240 <div id=
"bigCalHeader">
242 $atmp = array_keys($A_EVENTS);
243 echo date('d M Y', strtotime($atmp[
0]));
247 [-assign
var=
"dayname" value=$DATE|date_format:
"%w"-]
248 [-assign
var=
"day" value=$DATE|date_format:
"%d"|string_format:
"%1d"-]
249 [-assign
var=
"month" value=$DATE|date_format:
"%m"|string_format:
"%1d"-]
250 [-assign
var=
"year" value=$DATE|date_format:
"%Y"|string_format:
"%4d"-]
252 [-pc_sort_events
var=
"S_EVENTS" sort=
"time" order=
"asc" value=$A_EVENTS-]
257 echo
"<table border='0' cellpadding='1' cellspacing='0' width='100%'>\n";
259 // output the TD with the times DIV
261 echo
"<td id='times' style='width:2em;'><div><table>\n";
262 echo
"<td class='timeslot' style='text-align: center; background-color:#ddd;'> </td>";
263 foreach ($times as $slottime) {
264 $startampm = ($slottime['mer']) ==
"pm" ?
2 :
1;
265 $starttimeh = $slottime['hour'];
266 $disptimeh = ($starttimeh
> 12) ? ($starttimeh -
12) : $starttimeh;
267 $starttimem = $slottime['minute'];
268 $slotendmins = $starttimeh *
60 + $starttimem + $interval;
270 echo
"<tr><td class='timeslot'>";
271 echo
"$disptimeh:$starttimem";
274 echo
"</table></div></td>";
277 // This loops once for each provider to be displayed.
279 foreach ($providers as $provider) {
280 $providerid = $provider['id'];
282 // to specially handle the IN/OUT events I'm doing something new here
283 // for each IN event it will have a duration lasting until the next
284 // OUT event or until the end of the day
285 $tmpTime = $times[
0];
286 $calStartMin = ($tmpTime['hour'] *
60) + $tmpTime['minute'];
287 $tmpTime = $times[count($times)-
1];
288 $calEndMin = ($tmpTime['hour'] *
60) + $tmpTime['minute'];
290 // having a 'title' for the TD makes the date appear by the mouse pointer
291 // this is nice when all you see are times on the left side and no head
292 // row with the dates or day-of-week (DOW)
293 echo
"<td class='schedule' style='border: 1px solid #999;' title='".$provider['fname'].
" ".$provider['lname'].
"'>";
294 echo
"<div class='timeslot' style='font-size: 0.8em; text-align: center; background-color:#ddd; width: 100%; overflow: hidden; border-bottom: 1px solid lightgray;'>";
295 echo $provider['fname'].
" ".$provider['lname'].
"</div>";
296 echo
"<div style='position: relative; height: 100%; width: 100%;'>\n";
299 // output a TD with an inner containing DIV positioned 'relative'
300 // within that DIV we place our event DIVs using 'absolute' positioning
301 foreach ($A_EVENTS as $date =
> $events) {
302 $eventdate = substr($date,
0,
4) . substr($date,
5,
2) . substr($date,
8,
2);
304 // determine if events overlap and adjust their width and left position as needed
305 //
26 Feb
2008 - This needs fine tuning or total replacement
306 // - it doesn't work as well as I'd like - JRM
307 $eventPositions = array();
308 foreach ($times as $slottime) {
309 $starttimeh = $slottime['hour'];
310 $starttimem = $slottime['minute'];
312 $slotstartmins = $starttimeh *
60 + $starttimem;
313 $slotendmins = $starttimeh *
60 + $starttimem + $interval;
315 $events_in_timeslot = array();
316 foreach ($events as $e1) {
317 // ignore IN and OUT events
318 if (($e1['catid'] ==
2) || ($e1['catid'] ==
3)) { continue; }
319 // skip events without an ID (why they are in the loop, I have no idea)
320 if ($e1['eid'] ==
"") { continue; }
321 // skip events for other providers
322 if ($providerid != $e1['aid']) { continue; }
324 // create a numeric start and end for comparison
325 $starth = substr($e1['startTime'],
0,
2);
326 $startm = substr($e1['startTime'],
3,
2);
327 $e1Start = ($starth *
60) + $startm;
328 $e1End = $e1Start + $e1['duration']/
60;
330 // three ways to overlap:
331 // start-in, end-in, span
332 if ((($e1Start
>= $slotstartmins) && ($e1Start < $slotendmins)) // start-in
333 || (($e1End
> $slotstartmins) && ($e1End <= $slotendmins)) // end-in
334 || (($e1Start < $slotstartmins) && ($e1End
> $slotendmins))) // span
336 array_push($events_in_timeslot, $e1['eid']);
341 $width =
100 / count($events_in_timeslot);
343 // loop over the events in this timeslot and adjust their width
344 foreach ($events_in_timeslot as $eid) {
345 // set the width if not already set or if the current width is smaller
346 // than was was previously set
347 if (! isset($eventPositions[$eid]-
>width)) { $eventPositions[$eid]-
>width = $width; }
348 else if ($eventPositions[$eid]-
>width
> $width) { $eventPositions[$eid]-
>width = $width; }
350 // set the left position if not already set or if the current left is
351 // greater than what was previously set
352 if (! isset($eventPositions[$eid]-
>leftpos)) { $eventPositions[$eid]-
>leftpos = $leftpos; }
353 else if ($eventPositions[$eid]-
>leftpos < $leftpos) { $eventPositions[$eid]-
>leftpos = $leftpos; }
355 // increment the leftpos by the width
358 } // end overlap detection
360 // now loop over the events for the day and output their DIVs
361 foreach ($events as $event) {
362 // skip events for other providers
363 // yeah, we've got that sort of overhead here... it ain't perfect
364 if ($providerid != $event['aid']) { continue; }
366 // skip events without an ID (why they are in the loop, I have no idea)
367 if ($event['eid'] ==
"") { continue; }
369 // figure the start time and minutes (from midnight)
370 $starth = substr($event['startTime'],
0,
2);
371 $startm = substr($event['startTime'],
3,
2);
372 $eStartMin = $starth *
60 + $startm;
374 // determine the class for the event DIV based on the event category
375 $evtClass =
"event_appointment";
376 switch ($event['catid']) {
377 case
1: // NO-SHOW appt
378 $evtClass =
"event_noshow";
381 $evtClass =
"event_in";
383 case
3: // OUT of office
384 $evtClass =
"event_out";
389 $evtClass =
"event_reserved";
391 default: // some appointment
392 $evtClass =
"event_appointment";
396 // if this is an IN or OUT event then we have some extra special
397 // processing to be done
398 // the IN event creates a DIV until the OUT event
399 // or, without an OUT DIV matching the IN event
400 // then the IN event runs until the end of the day
401 if ($event['catid'] ==
2) {
402 // locate a matching OUT for this specific IN
405 foreach ($events as $outevent) {
406 // skip events for other providers
407 if ($providerid != $outevent['aid']) { continue; }
408 // skip events with blank IDs
409 if ($outevent['eid'] ==
"") { continue; }
411 if ($outevent['eid'] == $event['eid']) { $found = true; continue; }
412 if (($found == true) && ($outevent['catid'] ==
3)) {
413 // calculate the duration from this event to the outevent
414 $outH = substr($outevent['startTime'],
0,
2);
415 $outM = substr($outevent['startTime'],
3,
2);
416 $outMins = ($outH *
60) + $outM;
417 $event['duration'] = ($outMins - $eStartMin) *
60; // duration is in seconds
423 // no OUT was found so this event's duration goes
424 // until the end of the day
425 $event['duration'] = ($calEndMin - $eStartMin) *
60; // duration is in seconds
429 // calculate the TOP value for the event DIV
430 // diff between event start and schedule start
431 $eMinDiff = $eStartMin - $calStartMin;
432 // diff divided by the time interval of the schedule
433 $eStartInterval = $eMinDiff / $interval;
434 // times the interval height
435 $eStartPos = $eStartInterval * $timeslotHeightVal;
436 $evtTop = $eStartPos.$timeslotHeightUnit;
438 // calculate the HEIGHT value for the event DIV
439 // diff between end and start of event
440 $eEndMin = $eStartMin + ($event['duration']/
60);
441 // prevent the overall height of the event from going beyond the bounds
443 if ($eEndMin
> $calEndMin) { $eEndMin = $calEndMin; }
444 $eMinDiff = $eEndMin - $eStartMin;
445 // diff divided by the time interval of the schedule
446 $eEndInterval = $eMinDiff / $interval;
447 // times the interval height
448 $eHeight = $eEndInterval * $timeslotHeightVal;
449 $evtHeight = $eHeight.$timeslotHeightUnit;
451 // determine the DIV width based on any overlapping events
452 // see further above for the overlapping calculation code
455 if (isset($eventPositions[$event['eid']])) {
456 $divWidth =
"width: ".$eventPositions[$event['eid']]-
>width.
"%";
457 $divLeft =
"left: ".$eventPositions[$event['eid']]-
>leftpos.
"%";
460 $eventid = $event['eid'];
461 $patientid = $event['pid'];
462 $commapos = strpos($event['patient_name'],
",");
463 $lname = substr($event['patient_name'],
0, $commapos);
464 $fname = substr($event['patient_name'], $commapos +
2);
465 $patient_dob = $event['patient_dob'];
466 $patient_age = $event['patient_age'];
467 $catid = $event['catid'];
468 $comment = addslashes($event['hometext']);
469 $catname = $event['catname'];
470 $title =
"Age $patient_age ($patient_dob)";
474 if ($comment && $GLOBALS['calendar_appt_style'] <
4) $title .=
" " . $comment;
476 if ($catid ==
2 || $catid ==
3 || $catid ==
4 || $catid ==
8 || $catid ==
11) {
477 if ($catid ==
2) $catname =
"IN";
478 else if ($catid ==
3) $catname =
"OUT";
479 else if ($catid ==
4) $catname =
"VACATION";
480 else if ($catid ==
8) $catname =
"LUNCH";
481 else if ($catid ==
11) $catname =
"RESERVED";
484 if ($comment) $atitle .=
" $comment";
485 $content .=
"<a href='javascript:oldEvt($eventdate,$eventid)' title='$atitle'>";
486 $content .= $catname;
487 if ($comment) $content .=
" $comment";
491 // some sort of patient appointment
492 $content .=
"<span class='appointment".$apptToggle.
"'>";
493 $content .= $starth . ':' . $startm . htmlspecialchars($event['apptstatus']);
494 if ($catid ==
1) $content .=
"<strike>";
495 $content .= htmlspecialchars($lname);
496 if ($GLOBALS['calendar_appt_style'] !=
1) {
497 $content .=
"," . htmlspecialchars($fname);
498 if ($event['title'] && $GLOBALS['calendar_appt_style']
>=
3) {
499 $content .=
"(" . $event['title'];
500 if ($event['hometext'] && $GLOBALS['calendar_appt_style']
>=
4)
501 $content .=
": <font color='green'>" . htmlspecialchars(trim($event['hometext'])) .
"</font>";
505 if ($catid ==
1) $content .=
"</strike>";
507 $content .=
"</span>";
510 $divTitle .=
"\n(double click to edit)";
512 // output the DIV and content
513 echo
"<div class='".$evtClass.
" event' style='top:".$evtTop.
"; height:".$evtHeight.
514 "; background-color:".$event[
"catcolor"].
518 " id='".$eventdate.
"-".$eventid.
"'".
530 } // end provider loop
537 // [-include
file=
"$TPL_NAME/views/global/footer.html"-]
538 // [-include
file=
"$TPL_NAME/views/footer.html"-]
541 </div> <!-- end bigCal DIV -->
545 <script type=
"text/javascript" src=
"../../../library/js/jquery-1.2.2.min.js"></script>
547 $(document
).ready(function(){
548 var win
= top
.printLogPrint
? top
: opener
.top
;
549 win
.printLogPrint(window
);