Support for optional logging of print actions.
[openemr.git] / interface / main / calendar / modules / PostCalendar / pntemplates / default / views / day_print / ajax_template.html
blob1289017458cc117ecf5b8a64e17571554018ff13
1 [-*Smarty*-]
2 [-*****************************************************************************-]
3 [-* Copyright (C) 2005-2006 Rod Roark <rod@sunsetsystems.com> and others *-]
4 [-* *-]
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"-]
16 [-eval var=$css-]
18 [-*Values used in setting timeslot and event heights*-]
19 [-php-]$timeslotHeightVal=20; $timeslotHeightUnit="px";[-/php-]
21 <style>
22 a {
23 text-decoration:none;
25 td {
26 font-family: Arial, Helvetica, sans-serif;
28 div.tiny { width:1px; height:1px; font-size:1px; }
29 #dateNAV {
30 float: left;
32 #dateDisplay {
33 float: left;
34 padding-left: 10px;
35 font-family: Arial, Helvetica, sans-serif;
37 #datePicker {
38 width: 25%;
39 float: left;
40 position: absolute;
41 display: inline;
42 top: 50px;
43 left: 0px;
44 padding: 5px;
45 text-align: center;
46 background-color: lightblue;
48 #datePicker td {
49 font-family: Arial, Helvetica, sans-serif;
50 font-size: 0.7em;
51 /* font-size: 9pt; */
53 #bigCalHeader {
54 text-align:center;
55 font-family: Arial, Helvetica, sans-serif;
56 font-size: 14pt;
58 #bigCal {
59 background-color: lightblue;
60 position: relative;
62 #bigCal table {
63 border-collapse: collapse;
66 /* these are for the small datepicker DIV */
67 #datePicker table {
68 border-collapse: collapse;
69 border: 3px solid lightblue;
71 #datePicker .tdDOW-small {
72 font-family: Arial, Helvetica, sans-serif;
73 font-size: 10px;
74 vertical-align: top;
75 background-color: lightblue;
76 text-align: center;
77 border: none;
78 padding: 2px 3px 2px 3px;
80 #datePicker .tdDatePicker {
81 cursor: pointer;
82 cursor: hand;
84 #datePicker .tdWeekend-small {
85 font-family: Arial, Helvetica, sans-serif;
86 font-size: 10px;
87 vertical-align: top;
88 border: none;
89 padding: 2px 3px 2px 3px;
90 background-color: #dddddd;
91 color: #999999;
94 #datePicker .tdOtherMonthDay-small {
95 font-family: Arial, Helvetica, sans-serif;
96 font-size: 10px;
97 vertical-align: top;
98 border: none;
99 padding: 2px 3px 2px 3px;
100 background-color: #ffffff;
101 color: #999999;
104 #datePicker .tdMonthName-small {
105 text-align: center;
106 font-family: Arial, Helvetica, sans-serif;
107 font-size: 12px;
108 font-style: normal
111 #datePicker .tdMonthDay-small {
112 font-family: Arial, Helvetica, sans-serif;
113 font-size: 10px;
114 vertical-align: top;
115 border: none;
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;
127 color: lightblue;
130 /* the DIV of times */
131 #times {
132 border-right: 1px solid #999;
134 #times table {
135 border-collapse: collapse;
136 width: 100%;
137 margin: 0px;
138 padding: 0px;
140 #times table td {
141 border: 0px;
142 border-top: 1px solid #999;
143 margin: 0px;
144 padding: 0px;
145 font-size: 10pt;
147 .timeslot {
148 height: [-php-]echo $timeslotHeightVal.$timeslotHeightUnit;[-/php-];
149 margin: 0px;
150 padding: 0px;
152 .schedule {
153 background-color: pink;
154 vertical-align: top;
155 padding: 0px;
156 margin: 0px;
157 border-right: 1px solid black;
159 /* types of events */
160 .event_in {
161 position: absolute;
162 background-color: white;
163 width: 100%;
164 z-index:1;
165 font-size: 0.8em;
166 color: #ddd;
167 border-top: 1px dashed #ddd;
169 .event_out {
170 position: absolute;
171 background-color: lightgray;
172 width: 100%;
173 z-index:1;
174 font-size: 0.8em;
175 color: #ddd;
176 border-top: 1px dashed #ddd;
178 .event_appointment {
179 position: absolute;
180 background-color: white;
181 z-index:2;
182 overflow: hidden;
183 border: 1px solid blue;
184 width: 100%;
185 font-size: 0.8em;
187 .event_noshow {
188 position: absolute;
189 background-color: pink;
190 z-index:2;
191 overflow: hidden;
192 border: 1px solid blue;
193 width: 100%;
194 font-size: 0.8em;
196 .event_reserved {
197 position: absolute;
198 background-color: pink;
199 z-index:2;
200 overflow: hidden;
201 border: 1px solid blue;
202 width: 100%;
203 font-size: 0.8em;
205 </style>
207 <script type="text/javascript" src="../../../library/textformat.js"></script>
209 [-php-]
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"-]
220 // [-/if-]
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);
238 [-/php-]
240 <div id="bigCalHeader">
241 [-php-]
242 $atmp = array_keys($A_EVENTS);
243 echo date('d M Y', strtotime($atmp[0]));
244 [-/php-]
245 </div>
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-]
254 <div id="bigCal">
255 [-php-]
257 echo "<table border='0' cellpadding='1' cellspacing='0' width='100%'>\n";
259 // output the TD with the times DIV
260 echo "<tr>";
261 echo "<td id='times' style='width:2em;'><div><table>\n";
262 echo "<td class='timeslot' style='text-align: center; background-color:#ddd;'>&nbsp;</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";
272 echo "</td></tr>\n";
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";
298 // For each event...
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']);
340 $leftpos = 0;
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
356 $leftpos += $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";
379 break;
380 case 2: // IN office
381 $evtClass = "event_in";
382 break;
383 case 3: // OUT of office
384 $evtClass = "event_out";
385 break;
386 case 4: // VACATION
387 case 8: // LUNCH
388 case 11: // RESERVED
389 $evtClass = "event_reserved";
390 break;
391 default: // some appointment
392 $evtClass = "event_appointment";
393 break;
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
403 $found = false;
404 $outMins = 0;
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
418 $found = 2;
419 break;
422 if ($outMins == 0) {
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
442 // of the time table
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
453 $divWidth = "";
454 $divLeft = "";
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)";
472 $content = "";
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";
483 $atitle = $catname;
484 if ($comment) $atitle .= " $comment";
485 $content .= "<a href='javascript:oldEvt($eventdate,$eventid)' title='$atitle'>";
486 $content .= $catname;
487 if ($comment) $content .= " $comment";
488 $content .= "</a>";
490 else {
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>";
502 $content .= ")";
505 if ($catid == 1) $content .= "</strike>";
506 $content .= "</a>";
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"].
515 "; $divWidth".
516 "; $divLeft".
517 "'".
518 " id='".$eventdate."-".$eventid."'".
519 ">";
520 echo $content;
521 echo "</div>\n";
522 } // end EVENT loop
524 echo "</div>";
526 } // end date
528 echo "</td>\n";
530 } // end provider loop
532 echo " </tr>\n";
533 echo "</table>\n";
534 echo "<P>";
536 // [-*footer*-]
537 // [-include file="$TPL_NAME/views/global/footer.html"-]
538 // [-include file="$TPL_NAME/views/footer.html"-]
540 [-/php-]
541 </div> <!-- end bigCal DIV -->
543 </body>
545 <script type="text/javascript" src="../../../library/js/jquery-1.2.2.min.js"></script>
546 <script>
547 $(document).ready(function(){
548 var win = top.printLogPrint ? top : opener.top;
549 win.printLogPrint(window);
550 window.close();
552 </script>
554 </html>