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;
49 background-color: lightblue;
52 font-family: Arial, Helvetica, sans-serif;
58 font-family: Arial, Helvetica, sans-serif;
65 page-break-after: always;
68 border-collapse: collapse;
71 /* these are for the small datepicker DIV */
73 border-collapse: collapse;
74 border:
3px solid lightblue;
76 #datePicker .tdDOW-small {
77 font-family: Arial, Helvetica, sans-serif;
80 background-color: lightblue;
83 padding:
2px
3px
2px
3px;
85 #datePicker .tdDatePicker {
89 #datePicker .tdWeekend-small {
90 font-family: Arial, Helvetica, sans-serif;
94 padding:
2px
3px
2px
3px;
95 background-color: #dddddd;
99 #datePicker .tdOtherMonthDay-small {
100 font-family: Arial, Helvetica, sans-serif;
104 padding:
2px
3px
2px
3px;
105 background-color: #ffffff;
109 #datePicker .tdMonthName-small {
111 font-family: Arial, Helvetica, sans-serif;
116 #datePicker .tdMonthDay-small {
117 font-family: Arial, Helvetica, sans-serif;
121 padding:
2px
3px
2px
3px;
122 background-color: #ffffff;
124 #datePicker .currentWeek {
125 border-top:
1px solid blue;
126 border-bottom:
1px solid blue;
127 background-color: lightblue;
129 #datePicker .currentDate {
130 border:
1px solid blue;
131 background-color: blue;
135 /* the DIV of times */
137 border-right:
1px solid #
999;
140 border-collapse: collapse;
147 border-top:
1px solid #
999;
153 height: [-php-]echo $timeslotHeightVal.$timeslotHeightUnit;[-/php-];
158 background-color: pink;
162 border-right:
1px solid black;
164 /* types of events */
167 background-color: white;
172 border-top:
1px dashed #ddd;
176 background-color: lightgray;
181 border-top:
1px dashed #ddd;
185 background-color: white;
188 border:
1px solid blue;
194 background-color: pink;
197 border:
1px solid blue;
203 background-color: pink;
206 border:
1px solid blue;
212 <script type=
"text/javascript" src=
"../../../library/textformat.js"></script>
216 // A_CATEGORY is an ordered array of associative-array categories.
217 // Keys of interest are: id, name, color, desc, event_duration.
220 $A_CATEGORY =& $this-
>_tpl_vars['A_CATEGORY'];
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);
241 <div id="datePicker">
243 <table border="0" cellpadding="0" cellspacing="0">
246 $atmp = array_keys($A_EVENTS);
247 $caldate = strtotime($atmp[0]);
248 $cMonth = date("m", $caldate);
249 $cYear = date("Y", $caldate);
250 $cDay = date("d", $caldate);
252 // compute the previous month date
253 // stay on the same day if possible
255 $pMonth = $cMonth - 1;
257 if ($pMonth < 1) { $pMonth = 12; $pYear = $cYear - 1; }
258 while (! checkdate($pMonth, $pDay, $pYear)) { $pDay = $pDay - 1; }
259 $prevMonth = sprintf("%d%02d%02d",$pYear,$pMonth,$pDay);
261 // compute the next month
262 // stay on the same day if possible
264 $nMonth = $cMonth + 1;
266 if ($nMonth > 12) { $nMonth = 1; $nYear = $cYear + 1; }
267 while (! checkdate($nMonth, $nDay, $nYear)) { $nDay = $nDay - 1; }
268 $nextMonth = sprintf("%d%02d%02d",$nYear,$nMonth,$nDay);
270 <td class="tdDOW-small tdDatePicker" id="[-php-]echo $prevMonth[-/php-]" title="[-php-]echo date("F", strtotime($prevMonth));[-/php-]"><</td>
271 <td colspan="5" class="tdMonthName-small">
273 echo date('F', $caldate);
276 <td class="tdDOW-small tdDatePicker" id="[-php-]echo $nextMonth[-/php-]" title="[-php-]echo date("F", strtotime($nextMonth));[-/php-]">></td>
278 <td class="tdDOW-small">S</td>
279 <td class="tdDOW-small">M</td>
280 <td class="tdDOW-small">T</td>
281 <td class="tdDOW-small">W</td>
282 <td class="tdDOW-small">T</td>
283 <td class="tdDOW-small">F</td>
284 <td class="tdDOW-small">S</td>
287 $atmp = array_keys($A_EVENTS);
288 $caldate = strtotime($atmp[0]);
289 $caldateEnd = strtotime($atmp[6]);
290 // to make a complete week row we need to compute the real
291 // start and end dates for the view
292 list ($year, $month, $day) = explode(" ", date('Y m d', $caldate));
293 $startdate = strtotime($year.$month."01");
294 while (date('w', $startdate) != 0) { $startdate -= 60*60*24; }
296 $enddate = strtotime($year.$month.date("t", $prevmonth)." 23:59");
297 while (date('w', $enddate) != 6) { $enddate += 60*60*24; }
299 $currdate = $startdate;
300 while ($currdate <= $enddate) {
301 if (date('w', $currdate) == 0) {
308 $tdClass = "tdMonthDay-small";
309 if (date('m', $currdate) != $month) {
310 $tdClass = "tdOtherMonthDay-small";
312 if ((date('w', $currdate) == 0) || (date('w', $currdate) == 6)) {
313 $tdClass = "tdWeekend-small";
316 if ((date('Ymd',$currdate) >= date('Ymd', $caldate)) &&
317 (date('Ymd',$currdate) <= date('Ymd', $caldateEnd)))
319 // add a class that highlights the 'current date'
320 $tdClass .= " currentWeek";
323 if (date('Ymd',$currdate) == $Date) {
324 // $Date is defined near the top of this file
325 // and is equal to whatever date the user has clicked
326 $tdClass .= " currentDate";
329 // add a class so that jQuery can grab these days for the 'click' event
330 $tdClass .= " tdDatePicker";
334 $td .= "class=\"".$tdClass."\" ";
335 //$td .= "id=\"".date("Ymd", $currdate)."\" ";
336 $td .= "id=\"".date("Ymd", $currdate)."\" ";
337 $td .= "title=\"Go to week of ".date('M d, Y', $currdate)."\" ";
338 $td .= "> ".date('d', $currdate)."</td>\n";
342 if (date('w', $currdate) == 6) echo "</tr>\n";
344 // time correction = plus 1000 seconds, for some unknown reason
345 $currdate += (60*60*24)+1000;
353 [-assign
var=
"dayname" value=$DATE|date_format:
"%w"-]
354 [-assign
var=
"day" value=$DATE|date_format:
"%d"|string_format:
"%1d"-]
355 [-assign
var=
"month" value=$DATE|date_format:
"%m"|string_format:
"%1d"-]
356 [-assign
var=
"year" value=$DATE|date_format:
"%Y"|string_format:
"%4d"-]
358 [-pc_sort_events
var=
"S_EVENTS" sort=
"time" order=
"asc" value=$A_EVENTS-]
363 foreach ($A_EVENTS as $date =
> $events) {
365 foreach ($events as $oneE) {
369 echo
"<hr width=100%>";
373 // start out without adding a pagebreak
374 $addPagebreak = false;
376 // This loops once for each provider to be displayed.
378 foreach ($providers as $provider) {
379 // output a pagebreak, if needed
380 if ($addPagebreak) { echo
"<div class='pagebreak'></div>"; }
381 $addPagebreak = true;
383 echo
"<div id='bigCal'>";
385 echo
"<div id='bigCalHeader'>";
386 $atmp = array_keys($A_EVENTS);
387 echo date('d M Y', strtotime($atmp[
0]));
389 echo date('d M Y', strtotime($atmp[count($atmp)-
1]));
392 $providerid = $provider['id'];
394 // to specially handle the IN/OUT events I'm doing something new here
395 // for each IN event it will have a duration lasting until the next
396 // OUT event or until the end of the day
397 $tmpTime = $times[
0];
398 $calStartMin = ($tmpTime['hour'] *
60) + $tmpTime['minute'];
399 $tmpTime = $times[count($times)-
1];
400 $calEndMin = ($tmpTime['hour'] *
60) + $tmpTime['minute'];
402 echo
"<table border='0' cellpadding='1' cellspacing='0' width='100%'>\n";
404 echo
" <td colspan='8' style='text-align: center; background-color:#ddd;'>";
405 echo $provider['fname'] .
" " . $provider['lname'];
409 // output column (date) headers
412 echo
" <td style='width:".$colWidth.
"%;'><div class=tiny></div></td>"; //
1x1 px content so the browser does not suppress borders
413 $defaultDate =
""; // used when creating link for a 'new' event
414 $in_cat_id =
0; // used when creating link for a 'new' event
415 foreach ($A_EVENTS as $date =
> $events) {
416 $dateFmt = date(
"Ymd", strtotime($date));
417 $gotoURL = pnModURL(__POSTCALENDAR__,'user','view',
418 array('tplview'=
>$template_view,
421 'pc_username'=
>$pc_username,
422 'pc_category'=
>$category,
423 'pc_topic'=
>$topic));
424 if ($defaultDate ==
"") $defaultDate = $dateFmt;
425 echo
"<td align='center' style='width:".$colWidth.
"%; border-left: 1px solid #999; border-right: 1px solid #999; font-size: 0.7em;";
426 if ($Date == $dateFmt) { echo
"background-color: #ddd;"; }
428 echo
"<a href='$gotoURL'>";
429 echo date(
"D m/d", strtotime($date));
434 // output the TD with the times DIV
436 echo
"<td id='times'><div><table>\n";
437 foreach ($times as $slottime) {
438 $startampm = ($slottime['mer']) ==
"pm" ?
2 :
1;
439 $starttimeh = $slottime['hour'];
440 $disptimeh = ($starttimeh
> 12) ? ($starttimeh -
12) : $starttimeh;
441 $starttimem = $slottime['minute'];
442 $slotendmins = $starttimeh *
60 + $starttimem + $interval;
444 echo
"<tr><td class='timeslot'>";
445 echo
"<a href='javascript:newEvt($startampm,$starttimeh,$starttimem,$defaultDate,$providerid,$in_cat_id)' title='New Appointment' alt='New Appointment'>";
446 //echo $slottime['hour'] *
60 + $slottime['minute'];
447 echo
"$disptimeh:$starttimem</a>";
450 echo
"</table></div></td>";
453 // output a TD with an inner containing DIV positioned 'relative'
454 // within that DIV we place our event DIVs using 'absolute' positioning
455 foreach ($A_EVENTS as $date =
> $events) {
456 $eventdate = substr($date,
0,
4) . substr($date,
5,
2) . substr($date,
8,
2);
458 // having a 'title' for the TD makes the date appear by the mouse pointer
459 // this is nice when all you see are times on the left side and no head
460 // row with the dates or day-of-week (DOW)
461 echo
"<td class='schedule' style='border: 1px solid #999;' title='".date(
"l, d M Y", strtotime($date)).
"'>";
462 echo
"<div style='position: relative; height: 100%; width: 100%;'>\n";
464 // determine if events overlap and adjust their width and left position as needed
465 //
26 Feb
2008 - This needs fine tuning or total replacement
466 // - it doesn't work as well as I'd like - JRM
467 $eventPositions = array();
468 foreach ($times as $slottime) {
469 $starttimeh = $slottime['hour'];
470 $starttimem = $slottime['minute'];
472 $slotstartmins = $starttimeh *
60 + $starttimem;
473 $slotendmins = $starttimeh *
60 + $starttimem + $interval;
475 $events_in_timeslot = array();
476 foreach ($events as $e1) {
477 // ignore IN and OUT events
478 if (($e1['catid'] ==
2) || ($e1['catid'] ==
3)) { continue; }
479 // skip events without an ID (why they are in the loop, I have no idea)
480 if ($e1['eid'] ==
"") { continue; }
481 // skip events for other providers
482 if ($providerid != $e1['aid']) { continue; }
484 // create a numeric start and end for comparison
485 $starth = substr($e1['startTime'],
0,
2);
486 $startm = substr($e1['startTime'],
3,
2);
487 $e1Start = ($starth *
60) + $startm;
488 $e1End = $e1Start + $e1['duration']/
60;
490 // three ways to overlap:
491 // start-in, end-in, span
492 if ((($e1Start
>= $slotstartmins) && ($e1Start < $slotendmins)) // start-in
493 || (($e1End
> $slotstartmins) && ($e1End <= $slotendmins)) // end-in
494 || (($e1Start < $slotstartmins) && ($e1End
> $slotendmins))) // span
496 array_push($events_in_timeslot, $e1['eid']);
501 $width =
100 / count($events_in_timeslot);
503 // loop over the events in this timeslot and adjust their width
504 foreach ($events_in_timeslot as $eid) {
505 // set the width if not already set or if the current width is smaller
506 // than was was previously set
507 if (! isset($eventPositions[$eid]-
>width)) { $eventPositions[$eid]-
>width = $width; }
508 else if ($eventPositions[$eid]-
>width
> $width) { $eventPositions[$eid]-
>width = $width; }
510 // set the left position if not already set or if the current left is
511 // greater than what was previously set
512 if (! isset($eventPositions[$eid]-
>leftpos)) { $eventPositions[$eid]-
>leftpos = $leftpos; }
513 else if ($eventPositions[$eid]-
>leftpos < $leftpos) { $eventPositions[$eid]-
>leftpos = $leftpos; }
515 // increment the leftpos by the width
518 } // end overlap detection
520 // now loop over the events for the day and output their DIVs
521 foreach ($events as $event) {
522 // skip events for other providers
523 // yeah, we've got that sort of overhead here... it ain't perfect
524 if ($providerid != $event['aid']) { continue; }
526 // skip events without an ID (why they are in the loop, I have no idea)
527 if ($event['eid'] ==
"") { continue; }
529 // figure the start time and minutes (from midnight)
530 $starth = substr($event['startTime'],
0,
2);
531 $startm = substr($event['startTime'],
3,
2);
532 $eStartMin = $starth *
60 + $startm;
534 // determine the class for the event DIV based on the event category
535 $evtClass =
"event_appointment";
536 switch ($event['catid']) {
537 case
1: // NO-SHOW appt
538 $evtClass =
"event_noshow";
541 $evtClass =
"event_in";
543 case
3: // OUT of office
544 $evtClass =
"event_out";
549 $evtClass =
"event_reserved";
551 default: // some appointment
552 $evtClass =
"event_appointment";
556 // if this is an IN or OUT event then we have some extra special
557 // processing to be done
558 // the IN event creates a DIV until the OUT event
559 // or, without an OUT DIV matching the IN event
560 // then the IN event runs until the end of the day
561 if ($event['catid'] ==
2) {
562 // locate a matching OUT for this specific IN
565 foreach ($events as $outevent) {
566 // skip events for other providers
567 if ($providerid != $outevent['aid']) { continue; }
568 // skip events with blank IDs
569 if ($outevent['eid'] ==
"") { continue; }
571 if ($outevent['eid'] == $event['eid']) { $found = true; continue; }
572 if (($found == true) && ($outevent['catid'] ==
3)) {
573 // calculate the duration from this event to the outevent
574 $outH = substr($outevent['startTime'],
0,
2);
575 $outM = substr($outevent['startTime'],
3,
2);
576 $outMins = ($outH *
60) + $outM;
577 $event['duration'] = ($outMins - $eStartMin) *
60; // duration is in seconds
583 // no OUT was found so this event's duration goes
584 // until the end of the day
585 $event['duration'] = ($calEndMin - $eStartMin) *
60; // duration is in seconds
589 // calculate the TOP value for the event DIV
590 // diff between event start and schedule start
591 $eMinDiff = $eStartMin - $calStartMin;
592 // diff divided by the time interval of the schedule
593 $eStartInterval = $eMinDiff / $interval;
594 // times the interval height
595 $eStartPos = $eStartInterval * $timeslotHeightVal;
596 $evtTop = $eStartPos.$timeslotHeightUnit;
598 // calculate the HEIGHT value for the event DIV
599 // diff between end and start of event
600 $eEndMin = $eStartMin + ($event['duration']/
60);
601 // prevent the overall height of the event from going beyond the bounds
603 if ($eEndMin
> $calEndMin) { $eEndMin = $calEndMin + $interval; }
604 $eMinDiff = $eEndMin - $eStartMin;
605 // diff divided by the time interval of the schedule
606 $eEndInterval = $eMinDiff / $interval;
607 // times the interval height
608 $eHeight = $eEndInterval * $timeslotHeightVal;
609 $evtHeight = $eHeight.$timeslotHeightUnit;
611 // determine the DIV width based on any overlapping events
612 // see further above for the overlapping calculation code
615 if (isset($eventPositions[$event['eid']])) {
616 $divWidth =
"width: ".$eventPositions[$event['eid']]-
>width.
"%";
617 $divLeft =
"left: ".$eventPositions[$event['eid']]-
>leftpos.
"%";
620 $eventid = $event['eid'];
621 $patientid = $event['pid'];
622 $commapos = strpos($event['patient_name'],
",");
623 $lname = substr($event['patient_name'],
0, $commapos);
624 $fname = substr($event['patient_name'], $commapos +
2);
625 $patient_dob = $event['patient_dob'];
626 $patient_age = $event['patient_age'];
627 $catid = $event['catid'];
628 $comment = addslashes($event['hometext']);
629 $catname = $event['catname'];
630 $title =
"Age $patient_age ($patient_dob)";
634 if ($comment && $GLOBALS['calendar_appt_style'] <
4) $title .=
" " . $comment;
636 // the divTitle is what appears when the user hovers the mouse over the DIV
637 $divTitle = date(
"D, d M Y", strtotime($date));
639 if ($catid ==
2 || $catid ==
3 || $catid ==
4 || $catid ==
8 || $catid ==
11) {
640 if ($catid ==
2) $catname =
"IN";
641 else if ($catid ==
3) $catname =
"OUT";
642 else if ($catid ==
4) $catname =
"VACATION";
643 else if ($catid ==
8) $catname =
"LUNCH";
644 else if ($catid ==
11) $catname =
"RESERVED";
647 if ($comment) $atitle .=
" $comment";
648 $content .= $catname;
649 if ($comment) $content .=
" $comment";
652 // some sort of patient appointment
653 $content .=
"<span class='appointment".$apptToggle.
"'>";
654 $content .= $starth . ':' . $startm . htmlspecialchars($event['apptstatus']);
655 if ($catid ==
1) $content .=
"<strike>";
656 $content .= htmlspecialchars($lname);
657 if ($GLOBALS['calendar_appt_style'] !=
1) {
658 $content .=
"," . htmlspecialchars($fname);
659 if ($event['title'] && $GLOBALS['calendar_appt_style']
>=
3) {
660 $content .=
"(" . $event['title'];
661 if ($event['hometext'] && $GLOBALS['calendar_appt_style']
>=
4)
662 $content .=
": <font color='green'>" . htmlspecialchars(trim($event['hometext'])) .
"</font>";
666 if ($catid ==
1) $content .=
"</strike>";
667 $content .=
"</span>";
670 $divTitle .=
"\n(double click to edit)";
672 // output the DIV and content
673 echo
"<div class='".$evtClass.
" event' style='top:".$evtTop.
"; height:".$evtHeight.
674 "; background-color:".$event[
"catcolor"].
678 " id='".$eventdate.
"-".$eventid.
"'".
696 // [-include
file=
"$TPL_NAME/views/global/footer.html"-]
697 // [-include
file=
"$TPL_NAME/views/footer.html"-]
700 </div> <!-- end bigCal DIV -->
704 <script type=
"text/javascript" src=
"../../../library/js/jquery-1.2.2.min.js"></script>
706 $(document
).ready(function(){
707 var win
= top
.printLogPrint
? top
: opener
.top
;
708 win
.printLogPrint(window
);