update to oldEvt javascript to pass date variable, removed ctrl-m characters
[openemr.git] / interface / main / calendar / modules / PostCalendar / pntemplates / default / views / day / orig_default.html
blob61fda77d666f69b3979f3f37023ae5c59f2a3844
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 <style>
19 a {
20 text-decoration:none;
22 td {
23 font-family: Arial, Helvetica, sans-serif;
25 .tacell {
26 font-size:10pt;
27 background-color:#ddffdd;
28 text-align:right;
30 .tucell {
31 font-size:10pt;
32 background-color:#ffbbbb;
33 text-align:right;
35 .eacell {
36 font-size:10pt;
37 background-color:#ffffff;
39 .eucell {
40 font-size:10pt;
41 background-color:#ffbbbb;
43 .bordyy {
45 .bordyn {
46 border-top-width:0px;
47 padding-top:0px;
49 .bordny {
50 border-bottom-width:0px;
51 padding-bottom:0px;
53 .bordnn {
54 border-top-width:0px;
55 border-bottom-width:0px;
56 padding-top:0px;
57 padding-bottom:0px;
59 div.tiny { width:1px; height:1px; font-size:1px; }
60 </style>
62 <style type="text/css">@import url(../../../library/dynarch_calendar.css);</style>
63 <script type="text/javascript" src="../../../library/dialog.js"></script>
64 <script type="text/javascript" src="../../../library/textformat.js"></script>
65 <script type="text/javascript" src="../../../library/dynarch_calendar.js"></script>
66 <script type="text/javascript" src="../../../library/dynarch_calendar_en.js"></script>
67 <script type="text/javascript" src="../../../library/dynarch_calendar_setup.js"></script>
69 <script language='JavaScript'>
71 var mypcc = '[-php-] echo $GLOBALS['phone_country_code'] [-/php-]';
73 // This is called from the event editor popup.
74 function refreshme() {
75 top.restoreSession();
76 document.forms[0].submit();
79 function newEvt(startampm, starttimeh, starttimem, eventdate, providerid, catid) {
80 dlgopen('add_edit_event.php?startampm=' + startampm +
81 '&starttimeh=' + starttimeh + '&starttimem=' + starttimem +
82 '&date=' + eventdate + '&userid=' + providerid + '&catid=' + catid,
83 '_blank', 550, 270);
86 function oldEvt(eventdate, eventid) {
87 dlgopen('add_edit_event.php?date='+eventdate+'&eid=' + eventid, '_blank', 550, 270);
90 function goPid(pid) {
91 top.restoreSession();
92 [-php-]
93 if ($GLOBALS['concurrent_layout'])
95 // larry :: dbc change
96 if( $GLOBALS['dutchpc'] )
98 echo " top.RTop.location = '../../patient_file/summary/demographics_dutch.php' " .
99 "+ '?set_pid=' + pid;\n";
100 } else
102 echo " top.RTop.location = '../../patient_file/summary/demographics.php' " .
103 "+ '?set_pid=' + pid;\n";
105 // larry :: end of dbc change
106 } else {
107 echo " top.location = '../../patient_file/patient_file.php' " .
108 "+ '?set_pid=' + pid + '&pid=' + pid;\n";
110 [-/php-]
113 function GoToToday(theForm){
114 var todays_date = new Date();
115 var theMonth = todays_date.getMonth() + 1;
116 theMonth = theMonth < 10 ? "0" + theMonth : theMonth;
117 theForm.jumpdate.value = todays_date.getFullYear() + "-" + theMonth + "-" + todays_date.getDate();
118 top.restoreSession();
119 theForm.submit();
122 </script>
124 <!-- Required for the popup date selectors -->
125 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
127 [-php-]
129 // A_CATEGORY is an ordered array of associative-array categories.
130 // Keys of interest are: id, name, color, desc, event_duration.
132 // echo "<!-- A_CATEGORY = "; print_r($this->_tpl_vars['A_CATEGORY']); echo " -->\n"; // debugging
133 // echo "<!-- A_EVENTS = "; print_r($this->_tpl_vars['A_EVENTS']); echo " -->\n"; // debugging
135 $A_CATEGORY =& $this->_tpl_vars['A_CATEGORY'];
137 // [-if $PRINT_VIEW != 1-]
138 // [-*Main Navigation*-]
139 // [-include file="$TPL_NAME/views/global/navigation.html"-]
140 // [-/if-]
142 $A_EVENTS =& $this->_tpl_vars['A_EVENTS'];
143 // $S_EVENTS =& $this->_tpl_vars['S_EVENTS']; // Deleted by Rod
144 $providers =& $this->_tpl_vars['providers'];
145 $times =& $this->_tpl_vars['times'];
146 $interval = $this->_tpl_vars['interval'];
147 $viewtype = $this->_tpl_vars['VIEW_TYPE'];
148 $PREV_WEEK_URL = $this->_tpl_vars['PREV_WEEK_URL'];
149 $NEXT_WEEK_URL = $this->_tpl_vars['NEXT_WEEK_URL'];
150 $PREV_DAY_URL = $this->_tpl_vars['PREV_DAY_URL'];
151 $NEXT_DAY_URL = $this->_tpl_vars['NEXT_DAY_URL'];
153 $Date = postcalendar_getDate();
154 if (!isset($y)) $y = substr($Date, 0, 4);
155 if (!isset($m)) $m = substr($Date, 4, 2);
156 if (!isset($d)) $d = substr($Date, 6, 2);
158 // echo "<!-- There are " . count($A_EVENTS) . " A_EVENTS days -->\n";
160 $MULTIDAY = count($A_EVENTS) > 1;
162 $provinfo = getProviderInfo();
164 echo "<form name='theform' action='index.php?module=PostCalendar&func=view" .
165 "&tplview=default&pc_category=&pc_topic=' " .
166 "method='post' onsubmit='return top.restoreSession()'>\n";
167 echo "<center>\n";
168 echo "<table border='0' cellpadding='0' cellspacing='0' width='99%'>\n";
169 echo " <tr><td colspan='3' height='5'></td></tr>\n";
170 echo " <tr>\n";
172 // Build the scrolling selection list of providers.
173 echo " <td rowspan='2' align='left' valign='top' width='33%' nowrap>\n";
174 echo " <select multiple size='3' name='pc_username[]'>\n";
175 echo " <option value='__PC_ALL__'>" .xl ("All Users"). "</option>\n";
176 foreach ($provinfo as $doc) {
177 $username = $doc['username'];
178 echo " <option value='$username'";
179 foreach ($providers as $provider)
180 if ($provider['username'] == $username) echo " selected";
181 echo ">" . $doc['fname'] . " " . $doc['lname'] . "</option>\n";
183 echo " </select>\n";
185 // ==============================
186 // FACILITY FILTERING (lemonsoftware)
187 $facilities = getFacilities();
188 echo " <select name='pc_facility'>\n";
189 if ( !$_SESSION['pc_facility'] ) $selected = "selected='selected'";
190 echo " <option value='0' $selected>" .xl('All Facilities'). "</option>\n";
191 foreach ($facilities as $fa) {
192 $selected = ( $_SESSION['pc_facility'] == $fa['id']) ? "selected='selected'" : "" ;
193 echo " <option value='" .$fa['id']. "' $selected>" .$fa['name']. "</option>\n";
195 echo " </select>\n";
196 // EOS FF
197 // ==============================
199 echo " </td>\n";
201 // Build the date and view type selectors and the Go button and the Today button.
202 echo " <td align='center' valign='top' width='34%' nowrap>\n";
204 echo " <input type='text' size='10' name='jumpdate' id='jumpdate'\n" .
205 " value='$y-$m-$d' title='yyyy-mm-dd date to go to'\n" .
206 " onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />\n" .
207 " <img src='../../pic/show_calendar.gif' id='img_jumpdate' align='absbottom'\n" .
208 " width='24' height='22' border='0' alt='[?]' style='cursor:pointer'\n" .
209 " title='" .xl ("Click here to choose a date"). "'>\n";
211 echo " &nbsp;<select name='viewtype'>\n";
212 foreach ( array ('day' => xl("Day View"), 'week' => xl("Week View"), 'month' => xl("Month View"), 'year' => xl("Year View"))
213 as $key => $value) {
214 echo " <option value='$key'";
215 if ($key == $viewtype) echo " selected";
216 echo ">$value</option>\n";
218 echo " </select>\n";
219 echo " &nbsp;<input type='submit' name='bnsubmit' value='" .xl ("Go"). "' />\n";
220 echo " &nbsp;<input type='submit' name='bnsubmit' value='" .xl ("Today"). "' onClick='GoToToday(theform);' />\n";
221 echo " </td>\n";
223 // Show the Add and Search buttons.
224 echo " <td align='right' valign='top' width='33%' nowrap>\n";
225 echo " <input type='button' value='" .xl ("Add"). "' onclick='newEvt(1, 9, 00, $Date, 0, 0)' />\n";
226 echo " <input type='button' value='" . xl ("Search") .
227 "' onclick='top.restoreSession();location=\"index.php?module=PostCalendar&func=search\"' />\n";
228 echo " </td>\n";
229 echo " </tr>\n";
231 // Show the date/range and its previous- and next-day/week selectors.
232 echo " <tr>\n";
233 echo " <td align='center' width='34%' nowrap>\n";
234 $atmp = array_keys($A_EVENTS);
236 if ($MULTIDAY) {
237 echo "<a href='$PREV_WEEK_URL' onclick='top.restoreSession()'>&lt;&lt;</a>&nbsp;\n";
238 echo dateformat(strtotime($atmp[0]));
239 echo " - ";
240 echo dateformat(strtotime($atmp[count($atmp)-1]));
241 echo "&nbsp;<a href='$NEXT_WEEK_URL' onclick='top.restoreSession()'>&gt;&gt;</a>\n";
242 } else {
243 echo "<a href='$PREV_DAY_URL' onclick='top.restoreSession()'>&lt;&lt;</a>&nbsp;\n";
244 echo dateformat(strtotime($atmp[0]), true);
245 echo "&nbsp;<a href='$NEXT_DAY_URL' onclick='top.restoreSession()'>&gt;&gt;</a>\n";
247 echo " </td>\n";
248 echo " <td align='right' width='33%' nowrap>\n";
249 echo " &nbsp;\n";
250 echo " </td>\n";
252 echo " </tr>\n";
253 echo "</table>\n";
254 echo "</center>\n";
255 echo "</form>\n";
257 [-/php-]
259 <script language='JavaScript'>
260 Calendar.setup({inputField:"jumpdate", ifFormat:"%Y-%m-%d", button:"img_jumpdate"});
261 </script>
263 [-assign var="dayname" value=$DATE|date_format:"%w"-]
264 [-assign var="day" value=$DATE|date_format:"%d"|string_format:"%1d"-]
265 [-assign var="month" value=$DATE|date_format:"%m"|string_format:"%1d"-]
266 [-assign var="year" value=$DATE|date_format:"%Y"|string_format:"%4d"-]
268 [-pc_sort_events var="S_EVENTS" sort="time" order="asc" value=$A_EVENTS-]
270 [-php-]
272 echo "<table width='100%' border='1' cellpadding='1' cellspacing='0' >\n";
273 $tdstylearr = array('bordyy', 'bordny', 'bordyn', 'bordnn');
275 // For each day...
276 foreach ($A_EVENTS as $date => $events) {
277 $need_headers = true;
278 $eventdate = substr($date, 0, 4) . substr($date, 5, 2) . substr($date, 8, 2);
280 // If multiple days then show a date header for each.
281 if ($MULTIDAY) {
282 echo " <tr>\n";
283 echo " <td colspan='" . (count($providers) * 2) . "' align='center'>" .
284 dateformat(strtotime($date), true) . "</td>";
285 echo " </tr>\n";
288 $arr_events = $S_EVENTS[$date];
289 list($slotkey, $slotevent) = each($arr_events);
291 // This is an array of provider status information for this day,
292 // used to properly assign table cell attributes.
293 $provstat = array();
295 $slotindex = 0;
296 $lastslotindex = count($times) - 1;
298 // For each time slot...
299 foreach ($times as $slottime) {
300 $startampm = ($slottime['mer']) == "pm" ? 2 : 1;
301 $starttimeh = $slottime['hour'];
302 $starttimem = $slottime['minute'];
303 $slotendmins = $starttimeh * 60 + $starttimem + $interval;
305 // Repeat doc names at 1PM. This is a kludge; omit it for released code.
306 // if ($starttimeh == 13 && $starttimem == 0) $need_headers = true;
308 // Get all events for all providers just for this time slot now, because we
309 // can pick up where we left off and because we don't want to re-scan all
310 // events for the day for each table cell.
312 $arr_slot = array();
313 for (; isset($slotkey); list($slotkey, $slotevent) = each($arr_events)) {
314 $starth = substr($slotevent['startTime'], 0, 2);
315 $startm = substr($slotevent['startTime'], 3, 2);
317 if (($starth * 60 + $startm) >= $slotendmins) break;
319 $arr_slot[$slotkey] = $slotevent;
321 $catid = $slotevent['catid'];
322 $providerid = $slotevent['aid'];
323 $durminutes = ceil($slotevent['duration'] / 60);
324 $durslots = ceil($durminutes / $interval);
326 // While we're here, collect information for cell cosmetics.
327 if ($catid == 2) { // in office
328 $provstat[$providerid]['in'] = true;
330 // Save preferred category info for this IN event.
331 $provstat[$providerid]['in_cat'] = -1;
332 $provstat[$providerid]['in_slot0'] = $slotindex;
333 $provstat[$providerid]['in_slots'] = 1;
334 if ($slotevent['prefcatid']) {
335 foreach ($A_CATEGORY as $catkey => $catval) {
336 if ($catval['id'] == $slotevent['prefcatid']) {
337 $provstat[$providerid]['in_cat'] = $catkey;
338 $provstat[$providerid]['in_slots'] =
339 ceil(ceil($catval['event_duration'] / 60) / $interval);
340 break;
343 // Debugging:
344 if ($provstat[$providerid]['in_cat'] < 0) {
345 echo "<!-- Unmatched prefcatid = " . $slotevent['prefcatid'] . " -->\n"; // debugging
350 else if ($catid == 3) { // out of office
351 $provstat[$providerid]['in'] = false;
353 else if ($catid == 4 || $catid == 8 || $catid == 11) { // unavailable types
354 // unavailable slots are marked 'res' for appropriate coloring.
355 $endindex = $slotindex + $durslots;
356 for ($i = $slotindex; $i < $endindex; ++$i) {
357 $provstat[$providerid][$i]['res'] = true;
360 // If duration > slot size then mark slots for border control. A slot
361 // marked 'ext' is not to have a border between itself and the slot below.
362 if ($durslots > 1) {
363 $endindex = $slotindex + $durslots - 1;
364 for ($i = $slotindex; $i < $endindex; ++$i) {
365 $provstat[$providerid][$i]['ext'] = true;
369 // Finished getting event information for this time slot.
371 // Write a header row with the provider names if appropriate.
372 if ($need_headers) {
373 $need_headers = false;
374 echo " <tr>\n";
375 foreach ($providers as $provider) {
376 echo " <td colspan='2' align='center'>";
377 echo $provider['fname'][0] . " " . $provider['lname'];
378 echo "</td>\n";
380 echo " </tr>\n";
383 echo " <tr>\n";
385 // We are now ready to write the table row for the current time slot.
386 // This loops once for each provider to be displayed.
388 foreach ($providers as $provider) {
389 $providerid = $provider['id'];
391 // Mark this as a no-bottom-border slot if the preferred category
392 // duration extends beyond it.
394 // echo "<!-- slotindex=$slotindex in=" . $provstat[$providerid]['in'] .
395 // " in_cat=" . $provstat[$providerid]['in_cat'] .
396 // " in_slot0=" . $provstat[$providerid]['in_slot0'] .
397 // " in_slots=" . $provstat[$providerid]['in_slots'] . " -->\n"; // debugging
399 if ($provstat[$providerid]['in']) {
400 if (($slotindex + 1 - $provstat[$providerid]['in_slot0']) % $provstat[$providerid]['in_slots'])
401 $provstat[$providerid][$slotindex]['ext'] = true;
404 $content = ""; // this will be the event cell content
406 $clsuffix = "acell";
407 if ($provstat[$providerid][$slotindex]['res'] || ! $provstat[$providerid]['in']) {
408 $clsuffix = "ucell";
411 // Remove top and/or bottom table cell borders using CSS when events span
412 // time slots or when the practitioner is not in-office. Using "rowspan"
413 // would be a difficult and inferior solution to this problem.
415 $tdstyleix = 0;
416 $timelabel = true;
417 if ($slotindex < $lastslotindex &&
418 ($provstat[$providerid][$slotindex]['ext'] || !$provstat[$providerid]['in'])) {
419 $tdstyleix += 1; // no bottom
421 if ($slotindex > 0 && ($provstat[$providerid][$slotindex-1]['ext'] ||
422 !($provstat[$providerid]['in'] || $provstat[$providerid]['wasin']))) {
423 $tdstyleix += 2; // no top
424 $timelabel = false;
426 $tdstyle = ' ' . $tdstylearr[$tdstyleix];
428 $disptimeh = ($starttimeh > 12) ? ($starttimeh - 12) : $starttimeh;
430 $in_cat_id = 0;
431 if ($provstat[$providerid]['in_cat'] >= 0) {
432 $category =& $A_CATEGORY[$provstat[$providerid]['in_cat']];
433 if ($category['id']) $in_cat_id = $category['id'];
436 // If a slot omits the top border, then we omit the TOD cell's top border
437 // and skip writing its time-of-day text. This way we can get some rows
438 // with no content at all, which should produce a more compact and readable
439 // calendar display.
441 echo " <td class='t$clsuffix$tdstyle'";
442 if ($slotindex == 0) echo " width='1%'";
443 echo ">";
444 if ($timelabel) {
445 echo "<a href='javascript:newEvt($startampm,$starttimeh,$starttimem,$eventdate,$providerid,$in_cat_id)'>";
446 echo "$disptimeh:$starttimem</a>";
447 } else {
448 echo "<div class=tiny></div>"; // 1x1 px content so the browser does not suppress borders
450 echo "</td>\n";
452 echo " <td class='e$clsuffix$tdstyle'";
453 if ($clsuffix == "acell" && $in_cat_id) {
454 echo " style='background-color:" . $category['color'] . "'";
455 echo " title='" . $category['name'] . "'";
457 echo ">";
459 // Scan all events for this time slot and generate the associated HTML for
460 // this doc. JavaScript is used in hrefs to reduce the volume of output.
462 reset($arr_slot);
463 while (list($eventkey, $event) = each($arr_slot)) {
464 if ($event['aid'] != $providerid) continue;
465 if ($content) $content .= " ";
466 $starth = substr($event['startTime'], 0, 2);
467 $startm = substr($event['startTime'], 3, 2);
468 $eventid = $event['eid'];
469 $patientid = $event['pid'];
470 $commapos = strpos($event['patient_name'], ",");
471 $lname = addslashes(ucfirst(strtolower(substr($event['patient_name'], 0, $commapos))));
472 $fname = addslashes(ucfirst(strtolower(substr($event['patient_name'], $commapos + 2))));
473 $patient_dob = $event['patient_dob'];
474 $patient_age = $event['patient_age'];
475 $catid = $event['catid'];
476 $comment = addslashes($event['hometext']);
477 $catname = $event['catname'];
478 $title = "Age $patient_age ($patient_dob)";
479 if ($comment && $GLOBALS['calendar_appt_style'] < 4)
480 $title .= " " . $comment;
481 if ($catid == 2 || $catid == 3 || $catid == 4 || $catid == 8 || $catid == 11) {
482 if ($catid == 2) $catname = "IN";
483 else if ($catid == 3) $catname = "OUT";
484 else if ($catid == 4) $catname = "VACATION";
485 else if ($catid == 8) $catname = "LUNCH";
486 else if ($catid == 11) $catname = "RESERVED";
487 // Omit lunch, vacation, etc. if the doc is not in-office.
488 if ($provstat[$providerid]['in'] || $catid < 4) {
489 $content .= "<a href='javascript:oldEvt($eventdate,$eventid)'>";
490 $content .= $catname;
491 if ($comment) $content .= " - $comment";
492 $content .= "</a>";
495 else { // some sort of patient appointment
496 $content .= "<a href='javascript:oldEvt($eventdate,$eventid)' title='$catname'>";
497 $content .= $starth . ':' . $startm . htmlspecialchars($event['apptstatus']) . "</a>";
498 $content .= "<a href='javascript:goPid($patientid)' title='$title'>";
499 if ($catid == 1) $content .= "<strike>";
500 $content .= $lname;
501 if ($GLOBALS['calendar_appt_style'] != 1) {
502 $content .= "," . $fname;
503 if ($event['title'] && $GLOBALS['calendar_appt_style'] >= 3) {
504 $content .= "(" . $event['title'];
505 if ($event['hometext'] && $GLOBALS['calendar_appt_style'] >= 4)
506 $content .= ": <font color='green'>" . htmlspecialchars(trim($event['hometext'])) . "</font>";
507 $content .= ")";
510 if ($catid == 1) $content .= "</strike>";
511 $content .= "</a>";
513 } // end while
515 if (! $content) $content = "<div class=tiny></div>"; // so the browser does not suppress borders
516 echo $content . "</td>\n";
518 // Keep track of whether the doc was in during the previous time slot.
519 $provstat[$providerid]['wasin'] = $provstat[$providerid]['in'];
521 } // end provider
523 echo " </tr>\n";
525 ++$slotindex;
526 } // end time slot
527 } // end day
529 echo "</table>\n";
531 // [-*footer*-]
532 // [-include file="$TPL_NAME/views/global/footer.html"-]
533 // [-include file="$TPL_NAME/views/footer.html"-]
535 [-/php-]
537 </body>
538 </html>