option to show event description in calendar
[openemr.git] / interface / main / calendar / modules / PostCalendar / pntemplates / default / views / week / default.html
blob11a7fcf3cd4b7baae7b5231f887871dffbd39749
1 [-*Smarty*-]
2 [-*****************************************************************************-]
3 [-* This is the source code for both day/default.html and week/default.html. *-]
4 [-* They should always be identical. If you change one, copy to the other! *-]
5 [-*****************************************************************************-]
6 [-* Copyright (C) 2005 Rod Roark <rod@sunsetsystems.com> and others *-]
7 [-* *-]
8 [-* This program is free software; you can redistribute it and/or *-]
9 [-* modify it under the terms of the GNU General Public License *-]
10 [-* as published by the Free Software Foundation; either version 2 *-]
11 [-* of the License, or (at your option) any later version. *-]
12 [-*****************************************************************************-]
13 [-config_load file="default.conf"-]
14 [-*Load the Language Definitions*-]
15 [-config_load file="lang.$USER_LANG"-]
16 [-include file="$TPL_NAME/views/header.html"-]
17 [-* we want to include out stylesheet for this view*-]
18 [-fetch file="$TPL_STYLE_PATH/day.css" assign="css"-]
19 [-eval var=$css-]
21 <style>
22 a { text-decoration:none; }
23 .tacell { font-size:10pt; background-color:#ddffdd; text-align:right; }
24 .tucell { font-size:10pt; background-color:#ffbbbb; text-align:right; }
25 .eacell { font-size:10pt; background-color:#ffffff; }
26 .eucell { font-size:10pt; background-color:#ffbbbb; }
27 .nobot { border-bottom-width:0px; }
28 .notop { border-top-width:0px; }
29 </style>
31 <script type="text/javascript" src="../../../library/dialog.js"></script>
32 <script type="text/javascript" src="../../../library/overlib_mini.js"></script>
33 <script type="text/javascript" src="../../../library/calendar.js"></script>
34 <script type="text/javascript" src="../../../library/textformat.js"></script>
36 <script language='JavaScript'>
38 var mypcc = '[-php-] echo $GLOBALS['phone_country_code'] [-/php-]';
40 // This is called from the event editor popup.
41 function refreshme() {
42 document.forms[0].submit();
45 function newEvt(startampm, starttimeh, starttimem, eventdate, providerid) {
46 dlgopen('add_edit_event.php?startampm=' + startampm +
47 '&starttimeh=' + starttimeh + '&starttimem=' + starttimem +
48 '&date=' + eventdate + '&userid=' + providerid,
49 '_blank', 550, 270);
52 function oldEvt(eventdate, eventid) {
53 dlgopen('add_edit_event.php?eid=' + eventid, '_blank', 550, 270);
56 function goPid(pid) {
57 top.location = '../../patient_file/patient_file.php' +
58 '?set_pid=' + pid + '&pid=' + pid;
61 </script>
63 <!-- Required for the popup date selectors -->
64 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
66 [-php-]
68 // [-if $PRINT_VIEW != 1-]
69 // [-*Main Navigation*-]
70 // [-include file="$TPL_NAME/views/global/navigation.html"-]
71 // [-/if-]
73 $A_EVENTS =& $this->_tpl_vars['A_EVENTS'];
74 $S_EVENTS =& $this->_tpl_vars['S_EVENTS'];
75 $providers =& $this->_tpl_vars['providers'];
76 $times =& $this->_tpl_vars['times'];
77 $interval = $this->_tpl_vars['interval'];
78 $viewtype = $this->_tpl_vars['VIEW_TYPE'];
79 $PREV_WEEK_URL = $this->_tpl_vars['PREV_WEEK_URL'];
80 $NEXT_WEEK_URL = $this->_tpl_vars['NEXT_WEEK_URL'];
81 $PREV_DAY_URL = $this->_tpl_vars['PREV_DAY_URL'];
82 $NEXT_DAY_URL = $this->_tpl_vars['NEXT_DAY_URL'];
84 $Date = postcalendar_getDate();
85 if (!isset($y)) $y = substr($Date, 0, 4);
86 if (!isset($m)) $m = substr($Date, 4, 2);
87 if (!isset($d)) $d = substr($Date, 6, 2);
89 // echo "<!-- There are " . count($A_EVENTS) . " A_EVENTS days -->\n";
91 $MULTIDAY = count($A_EVENTS) > 1;
93 $provinfo = getProviderInfo();
95 echo "<form name='theform' action='index.php?module=PostCalendar&func=view' method='post'>\n";
96 echo "<center>\n";
97 echo "<table border='0' cellpadding='0' cellspacing='0' width='99%'>\n";
98 echo " <tr><td colspan='3' height='5'></td></tr>\n";
99 echo " <tr>\n";
101 // Build the scrolling selection list of providers.
102 echo " <td rowspan='2' align='left' valign='top' width='33%' nowrap>\n";
103 echo " <select multiple size='3' name='pc_username[]'>\n";
104 echo " <option value='__PC_ALL__'>All Users</option>\n";
105 foreach ($provinfo as $doc) {
106 $username = $doc['username'];
107 echo " <option value='$username'";
108 foreach ($providers as $provider)
109 if ($provider['username'] == $username) echo " selected";
110 echo ">" . $doc['fname'] . " " . $doc['lname'] . "</option>\n";
112 echo " </select>\n";
113 echo " </td>\n";
115 // Build the date and view type selectors and the Go button.
116 echo " <td align='center' valign='top' width='34%' nowrap>\n";
118 echo " <input type='text' size='10' name='jumpdate'\n" .
119 " value='$y-$m-$d'\n" .
120 " title='yyyy-mm-dd date to go to'\n" .
121 " onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />\n" .
122 " <a href=\"javascript:show_calendar('theform.jumpdate')\"\n" .
123 " title='Click here to choose a date'\n" .
124 " ><img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22' border='0' alt='[?]'></a>\n";
126 echo " &nbsp;<select name='viewtype'>\n";
127 foreach (array('day' => 'Day View', 'week' => 'Week View', 'month' => 'Month View', 'year' => 'Year View')
128 as $key => $value) {
129 echo " <option value='$key'";
130 if ($key == $viewtype) echo " selected";
131 echo ">$value</option>\n";
133 echo " </select>\n";
134 echo " &nbsp;<input type='submit' name='bnsubmit' value='Go' />\n";
135 echo " </td>\n";
137 // Show the Add and Search buttons.
138 echo " <td align='right' valign='top' width='33%' nowrap>\n";
139 echo " <input type='button' value='Add' onclick='newEvt(1, 9, 00, $Date, 0)' />\n";
140 echo " <input type='button' value='Search' onclick='location=\"index.php?module=PostCalendar&func=search\"' />\n";
141 echo " </td>\n";
142 echo " </tr>\n";
144 // Show the date/range and its previous- and next-day/week selectors.
145 echo " <tr>\n";
146 echo " <td align='center' width='34%' nowrap>\n";
147 $atmp = array_keys($A_EVENTS);
148 if ($MULTIDAY) {
149 echo "<a href='$PREV_WEEK_URL'>&lt;&lt;</a>&nbsp;\n";
150 echo date("F j Y", strtotime($atmp[0]));
151 echo " - ";
152 echo date("F j Y", strtotime($atmp[count($atmp)-1]));
153 echo "&nbsp;<a href='$NEXT_WEEK_URL'>&gt;&gt;</a>\n";
154 } else {
155 echo "<a href='$PREV_DAY_URL'>&lt;&lt;</a>&nbsp;\n";
156 echo date("l, F j, Y", strtotime($atmp[0]));
157 echo "&nbsp;<a href='$NEXT_DAY_URL'>&gt;&gt;</a>\n";
159 echo " </td>\n";
160 echo " <td align='right' width='33%' nowrap>\n";
161 echo " &nbsp;\n";
162 echo " </td>\n";
164 echo " </tr>\n";
165 echo "</table>\n";
166 echo "</center>\n";
167 echo "</form>\n";
169 [-/php-]
171 [-assign var="dayname" value=$DATE|date_format:"%w"-]
172 [-assign var="day" value=$DATE|date_format:"%d"|string_format:"%1d"-]
173 [-assign var="month" value=$DATE|date_format:"%m"|string_format:"%1d"-]
174 [-assign var="year" value=$DATE|date_format:"%Y"|string_format:"%4d"-]
176 [-pc_sort_events var="S_EVENTS" sort="time" order="asc" value=$A_EVENTS-]
178 [-php-]
180 echo "<table width='100%' border='1' cellpadding='1' cellspacing='0' >\n";
182 // For each day...
183 foreach ($A_EVENTS as $date => $events) {
184 $need_headers = true;
185 $eventdate = substr($date, 0, 4) . substr($date, 5, 2) . substr($date, 8, 2);
187 // If multiple days then show a date header for each.
188 if ($MULTIDAY) {
189 echo " <tr>\n";
190 echo " <td colspan='" . (count($providers) * 2) . "' align='center'>" .
191 date("l, F j, Y", strtotime($date)) . "</td>";
192 echo " </tr>\n";
195 $arr_events = $S_EVENTS[$date];
196 list($slotkey, $slotevent) = each($arr_events);
198 // This is an array of provider status information for this day,
199 // used to properly assign table cell attributes.
200 $provstat = array();
202 $slotindex = 0;
203 $lastslotindex = count($times) - 1;
205 // For each time slot...
206 foreach ($times as $slottime) {
207 $startampm = ($slottime['mer']) == "pm" ? 2 : 1;
208 $starttimeh = $slottime['hour'];
209 $starttimem = $slottime['minute'];
210 $slotendmins = $starttimeh * 60 + $starttimem + $interval;
212 // Repeat doc names at 1PM. This is a kludge; omit it for released code.
213 // if ($starttimeh == 13 && $starttimem == 0) $need_headers = true;
215 // Get all events just for this time slot now, because we can pick up where
216 // we left off and because we don't want to re-scan all events for the day
217 // for each table cell.
219 $arr_slot = array();
220 for (; isset($slotkey); list($slotkey, $slotevent) = each($arr_events)) {
221 $starth = substr($slotevent['startTime'], 0, 2);
222 $startm = substr($slotevent['startTime'], 3, 2);
224 if (($starth * 60 + $startm) >= $slotendmins) break;
226 $arr_slot[$slotkey] = $slotevent;
228 $catid = $slotevent['catid'];
229 $providerid = $slotevent['aid'];
230 $durminutes = ceil($slotevent['duration'] / 60);
231 $durslots = ceil($durminutes / $interval);
233 // While we're here, collect information for setting cell colors.
234 if ($catid == 2) { // in office
235 $provstat[$providerid]['in'] = true;
237 else if ($catid == 3) { // out of office
238 $provstat[$providerid]['in'] = false;
240 else if ($catid == 4 || $catid == 8 || $catid == 11) { // unavailable types
241 $endindex = $slotindex + $durslots;
242 for ($i = $slotindex; $i < $endindex; ++$i) {
243 $provstat[$providerid][$i]['res'] = true;
246 // if duration > slot size then mark slots for border control.
247 if ($durslots > 1) {
248 $endindex = $slotindex + $durslots - 1;
249 for ($i = $slotindex; $i < $endindex; ++$i) {
250 $provstat[$providerid][$i]['ext'] = true;
255 // Write a header row with the provider names if appropriate.
256 if ($need_headers) {
257 $need_headers = false;
258 echo " <tr>\n";
259 foreach ($providers as $provider) {
260 echo " <td colspan='2' align='center'>";
261 echo $provider['fname'][0] . " " . $provider['lname'];
262 echo "</td>\n";
264 echo " </tr>\n";
267 echo " <tr>\n";
269 // We are now ready to write the table row for the current time slot.
270 // This loops once for each provider to be displayed.
272 foreach ($providers as $provider) {
273 $providerid = $provider['id'];
275 $content = ""; // this will be the event cell content
277 $clsuffix = "acell";
278 if ($provstat[$providerid][$slotindex]['res'] || ! $provstat[$providerid]['in']) {
279 $clsuffix = "ucell";
282 // Remove top and/or bottom table cell borders using CSS when events span
283 // time slots or when the practitioner is not in-office. Using "rowspan"
284 // would be a difficult and inferior solution to this problem.
286 $tdstyle="";
287 if ($slotindex < $lastslotindex &&
288 ($provstat[$providerid][$slotindex]['ext'] || !$provstat[$providerid]['in'])) {
289 $tdstyle .= " nobot";
291 if ($slotindex > 0 && ($provstat[$providerid][$slotindex-1]['ext'] ||
292 !($provstat[$providerid]['in'] || $provstat[$providerid]['wasin']))) {
293 $tdstyle .= " notop";
296 $disptimeh = ($starttimeh > 12) ? ($starttimeh - 12) : $starttimeh;
298 echo " <td class='t$clsuffix'";
299 if ($slotindex == 0) echo " width='1%'";
300 echo ">";
301 echo "<a href='javascript:newEvt($startampm,$starttimeh,$starttimem,$eventdate,$providerid)'>";
302 echo "$disptimeh:$starttimem";
303 echo "</a></td>\n";
305 echo " <td class='e$clsuffix$tdstyle'>";
307 // Scan all events for this time slot and generate the associated HTML for
308 // this doc. JavaScript is used in hrefs to reduce the volume of output.
310 reset($arr_slot);
311 while (list($eventkey, $event) = each($arr_slot)) {
312 if ($event['aid'] != $providerid) continue;
313 if ($content) $content .= " ";
314 $starth = substr($event['startTime'], 0, 2);
315 $startm = substr($event['startTime'], 3, 2);
316 $eventid = $event['eid'];
317 $patientid = $event['pid'];
318 $commapos = strpos($event['patient_name'], ",");
319 $lname = addslashes(ucfirst(strtolower(substr($event['patient_name'], 0, $commapos))));
320 $fname = addslashes(ucfirst(strtolower(substr($event['patient_name'], $commapos + 2))));
321 $patient_dob = $event['patient_dob'];
322 $patient_age = $event['patient_age'];
323 $catid = $event['catid'];
324 $catname = $event['catname'];
325 $title = "Age $patient_age ($patient_dob)";
326 if ($event['hometext'] && $GLOBALS['calendar_appt_style'] < 4)
327 $title .= " " . addslashes($event['hometext']);
328 if ($catid == 2 || $catid == 3 || $catid == 4 || $catid == 8 || $catid == 11) {
329 if ($catid == 2) $catname = "IN";
330 else if ($catid == 3) $catname = "OUT";
331 else if ($catid == 4) $catname = "VACATION";
332 else if ($catid == 8) $catname = "LUNCH";
333 else if ($catid == 11) $catname = "RESERVED";
334 // Omit lunch, vacation, etc. if the doc is not in-office.
335 if ($provstat[$providerid]['in'] || $catid < 4) {
336 $content .= "<a href='javascript:oldEvt($eventdate,$eventid)'>";
337 $content .= $catname . "</a>";
340 else { // some sort of patient appointment
341 $content .= "<a href='javascript:oldEvt($eventdate,$eventid)' title='$catname'>";
342 $content .= $startm . htmlspecialchars($event['apptstatus']) . "</a>";
343 $content .= "<a href='javascript:goPid($patientid)' title='$title'>";
344 if ($catid == 1) $content .= "<strike>";
345 $content .= $lname;
346 if ($GLOBALS['calendar_appt_style'] != 1) {
347 $content .= "," . $fname;
348 if ($event['title'] && $GLOBALS['calendar_appt_style'] >= 3) {
349 $content .= "(" . $event['title'];
350 if ($event['hometext'] && $GLOBALS['calendar_appt_style'] >= 4)
351 $content .= ": <font color='green'>" . htmlspecialchars(trim($event['hometext'])) . "</font>";
352 $content .= ")";
355 if ($catid == 1) $content .= "</strike>";
356 $content .= "</a>";
358 } // end while
360 if (! $content) $content = "&nbsp;";
361 echo $content . "</td>\n";
363 // Keep track of whether the doc was in during the previous time slot.
364 $provstat[$providerid]['wasin'] = $provstat[$providerid]['in'];
366 } // end provider
368 echo " </tr>\n";
370 ++$slotindex;
371 } // end time slot
372 } // end day
374 echo "</table>\n";
376 // [-*footer*-]
377 // [-include file="$TPL_NAME/views/global/footer.html"-]
378 // [-include file="$TPL_NAME/views/footer.html"-]
380 [-/php-]
382 </body>
383 </html>