Fixed some weirdness with assigning a message recipient, and allowing a message to...
[openemr.git] / interface / main / messages / messages.php
blob4862cc0efb61f0d52e38f039b3048acabde5ad8e
1 <?php
2 /**
3 * Copyright (C) 2010 OpenEMR Support LLC
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * 2013/02/08 Minor tweaks by EMR Direct to allow integration with Direct messaging
10 * 2013-03-27 by sunsetsystems: Fixed some weirdness with assigning a message recipient,
11 * and allowing a message to be closed with a new note appended and no recipient.
14 //SANITIZE ALL ESCAPES
15 $sanitize_all_escapes=true;
17 //STOP FAKE REGISTER GLOBALS
18 $fake_register_globals=false;
20 require_once("../../globals.php");
21 require_once("$srcdir/pnotes.inc");
22 require_once("$srcdir/patient.inc");
23 require_once("$srcdir/acl.inc");
24 require_once("$srcdir/log.inc");
25 require_once("$srcdir/options.inc.php");
26 require_once("$srcdir/formdata.inc.php");
27 require_once("$srcdir/classes/Document.class.php");
28 require_once("$srcdir/gprelations.inc.php");
29 require_once("$srcdir/formatting.inc.php");
31 <html>
32 <head>
34 <?php html_header_show();?>
35 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
36 <script type="text/javascript" src="../../../library/dialog.js"></script>
37 <script type="text/javascript" src="../../../library/textformat.js"></script>
38 <script type="text/javascript" src="<?php echo $GLOBALS['webroot']; ?>/library/js/jquery.js"></script>
39 </head>
41 <body class="body_top">
43 <span class="title"><?php echo xlt('Message and Reminder Center'); ?></span>
44 <br /><br />
45 <span class="title"><?php echo xlt('Reminders'); ?></span>
47 <?php
49 // TajEmo Work by CB 2012/01/11 02:51:25 PM adding dated reminders
50 // I am asuming that at this point security checks have been performed
51 require_once '../dated_reminders/dated_reminders.php';
53 // Check to see if the user has Admin rights, and if so, allow access to See All.
54 $showall = isset($_GET['show_all']) ? $_GET['show_all'] : "" ;
55 if ($showall == "yes") {
56 $show_all = $showall;
58 else
60 $show_all= "no";
63 // Collect active variable and applicable html code for links
64 $form_active = $_REQUEST['form_active'];
65 $form_inactive = $_REQUEST['form_inactive'];
66 if ($form_active) {
67 $active = '1';
68 $activity_string_html = 'form_active=1';
70 else if ($form_inactive) {
71 $active = '0';
72 $activity_string_html = 'form_inactive=1';
74 else {
75 $active = 'all';
76 $activity_string_html = '';
79 //collect the task setting
80 $task= isset($_REQUEST['task']) ? $_REQUEST['task'] : "";
82 if (acl_check('admin', 'super' )) {
83 if ($show_all=='yes') {
84 $showall = "yes";
85 $lnkvar="'messages.php?show_all=no&$activity_string_html' name='Just Mine' onclick=\"top.restoreSession()\"> (".htmlspecialchars( xl('Just Mine'), ENT_NOQUOTES).")";
87 else {
88 $showall = "no";
89 $lnkvar="'messages.php?show_all=yes&$activity_string_html' name='See All' onclick=\"top.restoreSession()\"> (".htmlspecialchars( xl('See All'), ENT_NOQUOTES).")";
93 <br>
94 <table><tr><td><span class="title"><?php echo htmlspecialchars( xl('Messages'), ENT_NOQUOTES); ?></span> <a class='more' href=<?php echo $lnkvar; ?></a></td></tr></table>
95 <?php
96 //show the activity links
97 if (empty($task) || $task=="add" || $task=="delete") { ?>
98 <?php if ($active == "all") { ?>
99 <span><?php echo xlt('Show All'); ?></span>
100 <?php } else { ?>
101 <a href="messages.php" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show All'); ?></span></a>
102 <?php } ?>
104 <?php if ($active == '1') { ?>
105 <span><?php echo xlt('Show Active'); ?></span>
106 <?php } else { ?>
107 <a href="messages.php?form_active=1" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show Active'); ?></span></a>
108 <?php } ?>
110 <?php if ($active == '0') { ?>
111 <span><?php echo xlt('Show Inactive'); ?></span>
112 <?php } else { ?>
113 <a href="messages.php?form_inactive=1" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show Inactive'); ?></span></a>
114 <?php } ?>
115 <?php } ?>
117 <?php
118 switch($task) {
119 case "add" :
121 // Add a new message for a specific patient; the message is documented in Patient Notes.
122 // Add a new message; it's treated as a new note in Patient Notes.
123 $note = $_POST['note'];
124 $noteid = $_POST['noteid'];
125 $form_note_type = $_POST['form_note_type'];
126 $form_message_status = $_POST['form_message_status'];
127 $reply_to = $_POST['reply_to'];
128 $assigned_to_list = explode(';', $_POST['assigned_to']);
129 foreach($assigned_to_list as $assigned_to){
130 if ($noteid && $assigned_to != '-patient-') {
131 updatePnote($noteid, $note, $form_note_type, $assigned_to, $form_message_status);
132 $noteid = '';
134 else {
135 if($noteid && $assigned_to == '-patient-'){
136 // When $assigned_to == '-patient-' we don't update the current note, but
137 // instead create a new one with the current note's body prepended and
138 // attributed to the patient. This seems to be all for the patient portal.
139 $row = getPnoteById($noteid);
140 if (! $row) die("getPnoteById() did not find id '".text($noteid)."'");
141 $pres = sqlQuery("SELECT lname, fname " .
142 "FROM patient_data WHERE pid = ?", array($reply_to) );
143 $patientname = $pres['lname'] . ", " . $pres['fname'];
144 $note .= "\n\n$patientname on ".$row['date']." wrote:\n\n";
145 $note .= $row['body'];
147 // There's no note ID, and/or it's assigned to the patient.
148 // In these cases a new note is created.
149 addPnote($reply_to, $note, $userauthorized, '1', $form_note_type, $assigned_to, '', $form_message_status);
152 } break;
153 case "savePatient":
154 case "save" : {
155 // Update alert.
156 $noteid = $_POST['noteid'];
157 $form_message_status = $_POST['form_message_status'];
158 $reply_to = $_POST['reply_to'];
159 if ($task=="save")
160 updatePnoteMessageStatus($noteid,$form_message_status);
161 else
162 updatePnotePatient($noteid,$reply_to);
163 $task = "edit";
164 $note = $_POST['note'];
165 $title = $_POST['form_note_type'];
166 $reply_to = $_POST['reply_to'];
168 case "edit" : {
169 if ($noteid == "") {
170 $noteid = $_GET['noteid'];
172 // Update the message if it already exists; it's appended to an existing note in Patient Notes.
173 $result = getPnoteById($noteid);
174 if ($result) {
175 if ($title == ""){
176 $title = $result['title'];
178 $body = $result['body'];
179 if ($reply_to == ""){
180 $reply_to = $result['pid'];
182 $form_message_status = $result['message_status'];
184 } break;
185 case "delete" : {
186 // Delete selected message(s) from the Messages box (only).
187 $delete_id = $_POST['delete_id'];
188 for($i = 0; $i < count($delete_id); $i++) {
189 deletePnote($delete_id[$i]);
190 newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "pnotes: id ".$delete_id[$i]);
192 } break;
195 if($task == "addnew" or $task == "edit") {
196 // Display the Messages page layout.
197 echo "
198 <form name=new_note id=new_note action=\"messages.php?showall=".attr($showall)."&sortby=".attr($sortby)."&sortorder=".attr($sortorder)."&begin=".attr($begin)."&$activity_string_html\" method=post>
199 <input type=hidden name=noteid id=noteid value=".htmlspecialchars( $noteid, ENT_QUOTES).">
200 <input type=hidden name=task id=task value=add>";
202 <div id="pnotes"><center>
203 <table border='0' cellspacing='8'>
204 <tr>
205 <td class='text'>
206 <b><?php echo htmlspecialchars( xl('Type'), ENT_NOQUOTES); ?>:</b>
207 <?php
208 if ($title == "") {
209 $title = "Unassigned";
211 // Added 6/2009 by BM to incorporate the patient notes into the list_options listings.
212 generate_form_field(array('data_type'=>1,'field_id'=>'note_type','list_id'=>'note_type','empty_title'=>'SKIP','order_by'=>'title'), $title);
214 &nbsp; &nbsp;
215 <?php if ($task != "addnew" && $result['pid'] != 0) { ?>
216 <a class="patLink" onclick="goPid('<?php echo attr($result['pid']);?>')"><?php echo htmlspecialchars( xl('Patient'), ENT_NOQUOTES); ?>:</a>
217 <?php } else { ?>
218 <b class='<?php echo ($task=="addnew"?"required":"") ?>'><?php echo htmlspecialchars( xl('Patient'), ENT_NOQUOTES); ?>:</b>
219 <?php
221 if ($reply_to) {
222 $prow = sqlQuery("SELECT lname, fname " .
223 "FROM patient_data WHERE pid = ?", array($reply_to) );
224 $patientname = $prow['lname'] . ", " . $prow['fname'];
226 if ($patientname == '') {
227 $patientname = xl('Click to select');
228 } ?>
229 <input type='text' size='10' name='form_patient' style='width:150px;<?php
230 echo ($task=="addnew"?"cursor:pointer;cursor:hand;":"") ?>' value='<?php
231 echo htmlspecialchars($patientname, ENT_QUOTES); ?>' <?php
232 echo (($task=="addnew" || $result['pid']==0) ? "onclick='sel_patient()' readonly":"disabled") ?> title='<?php
233 echo ($task=="addnew"?(htmlspecialchars( xl('Click to select patient'), ENT_QUOTES)):"") ?>' />
234 <input type='hidden' name='reply_to' id='reply_to' value='<?php echo htmlspecialchars( $reply_to, ENT_QUOTES) ?>' />
235 &nbsp; &nbsp;
236 <b><?php echo htmlspecialchars( xl('Status'), ENT_NOQUOTES); ?>:</b>
237 <?php
238 if ($form_message_status == "") {
239 $form_message_status = 'New';
241 generate_form_field(array('data_type'=>1,'field_id'=>'message_status','list_id'=>'message_status','empty_title'=>'SKIP','order_by'=>'title'), $form_message_status); ?>
242 </td>
243 </tr>
244 <tr>
245 <td class='text'>
246 <b><?php echo htmlspecialchars( xl('To'), ENT_QUOTES); ?>:</b>
247 <input type='textbox' name='assigned_to_text' id='assigned_to_text' size='40' readonly='readonly'
248 value='<?php echo htmlspecialchars(xl("Select Users From The Dropdown List"), ENT_QUOTES)?>' >
249 <input type='hidden' name='assigned_to' id='assigned_to' >
250 <select name='users' id='users' onchange='addtolist(this);' >
251 <?php
252 echo "<option value='" . htmlspecialchars( '--', ENT_QUOTES) . "'";
253 echo ">" . htmlspecialchars( xl('Select User'), ENT_NOQUOTES);
254 echo "</option>\n";
255 $ures = sqlStatement("SELECT username, fname, lname FROM users " .
256 "WHERE username != '' AND active = 1 AND " .
257 "( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
258 "ORDER BY lname, fname");
259 while ($urow = sqlFetchArray($ures)) {
260 echo " <option value='" . htmlspecialchars( $urow['username'], ENT_QUOTES) . "'";
261 echo ">" . htmlspecialchars( $urow['lname'], ENT_NOQUOTES);
262 if ($urow['fname']) echo ", " . htmlspecialchars( $urow['fname'], ENT_NOQUOTES);
263 echo "</option>\n";
265 echo "<option value='" . htmlspecialchars( '-patient-', ENT_QUOTES) . "'";
266 echo ">" . htmlspecialchars( '-Patient-', ENT_NOQUOTES);
267 echo "</option>\n";
269 </select>
270 </td>
271 </tr>
273 <?php
274 if ($noteid) {
275 // Get the related document IDs if any.
276 $tmp = sqlStatement("SELECT id1 FROM gprelations WHERE " .
277 "type1 = ? AND type2 = ? AND id2 = ?",
278 array('1', '6', $noteid));
279 if (sqlNumRows($tmp)) {
280 echo " <tr>\n";
281 echo " <td class='text'><b>";
282 echo xlt('Linked document') . ":</b>\n";
283 while ($gprow = sqlFetchArray($tmp)) {
284 $d = new Document($gprow['id1']);
285 echo " <a href='";
286 echo $GLOBALS['webroot'] . "/controller.php?document&retrieve";
287 echo "&patient_id=" . $d->get_foreign_id();
288 echo "&document_id=" . $d->get_id();
289 echo "&as_file=true' target='_blank' onclick='top.restoreSession()'>";
290 echo text($d->get_url_file());
291 echo "</a>\n";
293 echo " </td>\n";
294 echo " </tr>\n";
299 <tr>
300 <td>
302 <?php
304 if ($noteid) {
305 $body = preg_replace('/(:\d{2}\s\()'.$result['pid'].'(\sto\s)/','${1}'.$patientname.'${2}',$body);
306 $body = nl2br(htmlspecialchars( $body, ENT_NOQUOTES));
307 echo "<div class='text' style='background-color:white; color: gray; border:1px solid #999; padding: 5px; width: 640px;'>".$body."</div>";
311 <textarea name='note' id='note' rows='8' style="width: 660px; "><?php echo htmlspecialchars( $note, ENT_NOQUOTES) ?></textarea>
312 </td>
313 </tr>
314 </table>
316 <?php if ($noteid) { ?>
317 <!-- This is for displaying an existing note. -->
318 <input type="button" id="newnote" value="<?php echo htmlspecialchars( xl('Send message'), ENT_QUOTES); ?>">
319 <input type="button" id="printnote" value="<?php echo htmlspecialchars( xl('Print message'), ENT_QUOTES); ?>">
320 <input type="button" id="cancel" value="<?php echo htmlspecialchars( xl('Cancel'), ENT_QUOTES); ?>">
321 <?php } else { ?>
322 <!-- This is for displaying a new note. -->
323 <input type="button" id="newnote" value="<?php echo htmlspecialchars( xl('Send message'), ENT_QUOTES); ?>">
324 <input type="button" id="cancel" value="<?php echo htmlspecialchars( xl('Cancel'), ENT_QUOTES); ?>">
325 <?php }
328 <br>
329 </form></center></div>
330 <script language="javascript">
332 // jQuery stuff to make the page a little easier to use
334 $(document).ready(function(){
335 $("#newnote").click(function() { NewNote(); });
336 $("#printnote").click(function() { PrintNote(); });
337 obj = document.getElementById("form_message_status");
338 obj.onchange = function(){SaveNote();};
339 $("#cancel").click(function() { CancelNote(); });
340 $("#note").focus();
342 var NewNote = function () {
343 top.restoreSession();
344 if (document.forms[0].reply_to.value.length == 0 || document.forms[0].reply_to.value == '0') {
345 alert('<?php echo htmlspecialchars( xl('Please choose a patient'), ENT_QUOTES); ?>');
347 else if (document.forms[0].assigned_to.value.length == 0 &&
348 document.getElementById("form_message_status").value != 'Done')
350 alert('<?php echo addslashes(xl('Recipient required unless status is Done')); ?>');
352 else
354 $("#new_note").submit();
358 var PrintNote = function () {
359 top.restoreSession();
360 window.open('../../patient_file/summary/pnotes_print.php?noteid=<?php echo htmlspecialchars( $noteid, ENT_QUOTES); ?>', '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
363 var SaveNote = function () {
364 <?php if ($noteid) { ?>
365 top.restoreSession();
366 $("#task").val("save");
367 $("#new_note").submit();
368 <?php } ?>
371 var CancelNote = function () {
372 top.restoreSession();
373 $("#task").val("");
374 $("#new_note").submit();
377 // This is for callback by the find-patient popup.
378 function setpatient(pid, lname, fname, dob) {
379 var f = document.forms[0];
380 f.form_patient.value = lname + ', ' + fname;
381 f.reply_to.value = pid;
382 <?php if ($noteid) { ?>
383 //used when direct messaging service inserts a pnote with indeterminate patient
384 //to allow the user to assign the message to a patient.
385 top.restoreSession();
386 $("#task").val("savePatient");
387 $("#new_note").submit();
388 <?php } ?>
391 // This invokes the find-patient popup.
392 function sel_patient() {
393 dlgopen('../../main/calendar/find_patient_popup.php', '_blank', 500, 400);
396 function addtolist(sel){
397 var itemtext = document.getElementById('assigned_to_text');
398 var item = document.getElementById('assigned_to');
399 if(sel.value != '--'){
400 if(item.value){
401 if(item.value.indexOf(sel.value) == -1){
402 itemtext.value = itemtext.value +' ; '+ sel.options[sel.selectedIndex].text;
403 item.value = item.value +';'+ sel.value;
405 }else{
406 itemtext.value = sel.options[sel.selectedIndex].text;
407 item.value = sel.value;
412 </script><?php
414 else {
416 // This is for sorting the records.
417 $sort = array("users.lname", "patient_data.lname", "pnotes.title", "pnotes.date", "pnotes.message_status");
418 $sortby = (isset($_REQUEST['sortby']) && ($_REQUEST['sortby']!="")) ? $_REQUEST['sortby'] : $sort[0];
419 $sortorder = (isset($_REQUEST['sortorder']) && ($_REQUEST['sortorder']!="")) ? $_REQUEST['sortorder'] : "asc";
420 $begin = isset($_REQUEST['begin']) ? $_REQUEST['begin'] : 0;
422 for($i = 0; $i < count($sort); $i++) {
423 $sortlink[$i] = "<a href=\"messages.php?show_all=".attr($showall)."&sortby=".attr($sort[$i])."&sortorder=asc&$activity_string_html\" onclick=\"top.restoreSession()\"><img src=\"../../../images/sortdown.gif\" border=0 alt=\"".htmlspecialchars( xl('Sort Up'), ENT_QUOTES)."\"></a>";
425 for($i = 0; $i < count($sort); $i++) {
426 if($sortby == $sort[$i]) {
427 switch($sortorder) {
428 case "asc" : $sortlink[$i] = "<a href=\"messages.php?show_all=".attr($showall)."&sortby=".attr($sortby)."&sortorder=desc&$activity_string_html\" onclick=\"top.restoreSession()\"><img src=\"../../../images/sortup.gif\" border=0 alt=\"".htmlspecialchars( xl('Sort Up'), ENT_QUOTES)."\"></a>"; break;
429 case "desc" : $sortlink[$i] = "<a href=\"messages.php?show_all=".attr($showall)."&sortby=".attr($sortby)."&sortorder=asc&$activity_string_html\" onclick=\"top.restoreSession()\"><img src=\"../../../images/sortdown.gif\" border=0 alt=\"".htmlspecialchars( xl('Sort Down'), ENT_QUOTES)."\"></a>"; break;
430 } break;
433 // Manage page numbering and display beneath the Messages table.
434 $listnumber = 25;
435 $total = getPnotesByUser($active,$show_all,$_SESSION['authUser'],true);
436 if($begin == "" or $begin == 0) {
437 $begin = 0;
439 $prev = $begin - $listnumber;
440 $next = $begin + $listnumber;
441 $start = $begin + 1;
442 $end = $listnumber + $start - 1;
443 if($end >= $total) {
444 $end = $total;
446 if($end < $start) {
447 $start = 0;
449 if($prev >= 0) {
450 $prevlink = "<a href=\"messages.php?show_all=".attr($showall)."&sortby=".attr($sortby)."&sortorder=".attr($sortorder)."&begin=".attr($prev)."&$activity_string_html\" onclick=\"top.restoreSession()\"><<</a>";
452 else {
453 $prevlink = "<<";
456 if($next < $total) {
457 $nextlink = "<a href=\"messages.php?show_all=".attr($showall)."&sortby=".attr($sortby)."&sortorder=".attr($sortorder)."&begin=".attr($next)."&$activity_string_html\" onclick=\"top.restoreSession()\">>></a>";
459 else {
460 $nextlink = ">>";
462 // Display the Messages table header.
463 echo "
464 <table width=100%><tr><td><table border=0 cellpadding=1 cellspacing=0 width=90% style=\"border-left: 1px #000000 solid; border-right: 1px #000000 solid; border-top: 1px #000000 solid;\">
465 <form name=MessageList action=\"messages.php?showall=".attr($showall)."&sortby=".attr($sortby)."&sortorder=".attr($sortorder)."&begin=".attr($begin)."&$activity_string_html\" method=post>
466 <input type=hidden name=task value=delete>
467 <tr height=\"24\" style=\"background:lightgrey\">
468 <td align=\"center\" width=\"25\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\"><input type=checkbox id=\"checkAll\" onclick=\"selectAll()\"></td>
469 <td width=\"20%\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
470 htmlspecialchars( xl('From'), ENT_NOQUOTES) . "</b> $sortlink[0]</td>
471 <td width=\"20%\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
472 htmlspecialchars( xl('Patient'), ENT_NOQUOTES) . "</b> $sortlink[1]</td>
473 <td style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
474 htmlspecialchars( xl('Type'), ENT_NOQUOTES) . "</b> $sortlink[2]</td>
475 <td width=\"15%\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
476 htmlspecialchars( xl('Date'), ENT_NOQUOTES) . "</b> $sortlink[3]</td>
477 <td width=\"15%\" style=\"border-bottom: 1px #000000 solid; \" class=bold>&nbsp;<b>" .
478 htmlspecialchars( xl('Status'), ENT_NOQUOTES) . "</b> $sortlink[4]</td>
479 </tr>";
480 // Display the Messages table body.
481 $count = 0;
482 $result = getPnotesByUser($active,$show_all,$_SESSION['authUser'],false,$sortby,$sortorder,$begin,$listnumber);
483 while ($myrow = sqlFetchArray($result)) {
484 $name = $myrow['user'];
485 $name = $myrow['users_lname'];
486 if ($myrow['users_fname']) {
487 $name .= ", " . $myrow['users_fname'];
489 $patient = $myrow['pid'];
490 if ($patient>0) {
491 $patient = $myrow['patient_data_lname'];
492 if ($myrow['patient_data_fname']) {
493 $patient .= ", " . $myrow['patient_data_fname'];
495 } else {
496 $patient = "* Patient must be set manually *";
498 $count++;
499 echo "
500 <tr id=\"row$count\" style=\"background:white\" height=\"24\">
501 <td align=\"center\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\"><input type=checkbox id=\"check$count\" name=\"delete_id[]\" value=\"" .
502 htmlspecialchars( $myrow['id'], ENT_QUOTES) . "\" onclick=\"if(this.checked==true){ selectRow('row$count'); }else{ deselectRow('row$count'); }\"></td>
503 <td style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\"><table cellspacing=0 cellpadding=0 width=100%><tr><td width=5></td><td class=\"text\">" .
504 htmlspecialchars( $name, ENT_NOQUOTES) . "</td><td width=5></td></tr></table></td>
505 <td style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\"><table cellspacing=0 cellpadding=0 width=100%><tr><td width=5></td><td class=\"text\"><a href=\"messages.php?showall=".attr($showall)."&sortby=".attr($sortby)."&sortorder=".attr($sortorder)."&begin=".attr($begin)."&task=edit&noteid=" .
506 htmlspecialchars( $myrow['id'], ENT_QUOTES) . "&$activity_string_html\" onclick=\"top.restoreSession()\">" .
507 htmlspecialchars( $patient, ENT_NOQUOTES) . "</a></td><td width=5></td></tr></table></td>
508 <td style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\"><table cellspacing=0 cellpadding=0 width=100%><tr><td width=5></td><td class=\"text\">" .
509 htmlspecialchars( $myrow['title'], ENT_NOQUOTES) . "</td><td width=5></td></tr></table></td>
510 <td style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\"><table cellspacing=0 cellpadding=0 width=100%><tr><td width=5></td><td class=\"text\">" .
511 htmlspecialchars( oeFormatShortDate(substr($myrow['date'], 0, strpos($myrow['date'], " "))), ENT_NOQUOTES) . "</td><td width=5></td></tr></table></td>
512 <td style=\"border-bottom: 1px #000000 solid;\"><table cellspacing=0 cellpadding=0 width=100%><tr><td width=5></td><td class=\"text\">" .
513 htmlspecialchars( $myrow['message_status'], ENT_NOQUOTES) . "</td><td width=5></td></tr></table></td>
514 </tr>";
516 // Display the Messages table footer.
517 echo "
518 </form></table>
519 <table border=0 cellpadding=5 cellspacing=0 width=90%>
520 <tr>
521 <td class=\"text\"><a href=\"messages.php?showall=".attr($showall)."&sortby=".attr($sortby)."&sortorder=".attr($sortorder)."&begin=".attr($begin)."&task=addnew&$activity_string_html\" onclick=\"top.restoreSession()\">" .
522 htmlspecialchars( xl('Add New'), ENT_NOQUOTES) . "</a> &nbsp; <a href=\"javascript:confirmDeleteSelected()\" onclick=\"top.restoreSession()\">" .
523 htmlspecialchars( xl('Delete'), ENT_NOQUOTES) . "</a></td>
524 <td align=right class=\"text\">$prevlink &nbsp; $end of $total &nbsp; $nextlink</td>
525 </tr>
526 </table></td></tr></table><br>";
528 <script language="javascript">
529 // This is to confirm delete action.
530 function confirmDeleteSelected() {
531 if(confirm("<?php echo htmlspecialchars( xl('Do you really want to delete the selection?'), ENT_QUOTES); ?>")) {
532 document.MessageList.submit();
535 // This is to allow selection of all items in Messages table for deletion.
536 function selectAll() {
537 if(document.getElementById("checkAll").checked==true) {
538 document.getElementById("checkAll").checked=true;<?php
539 for($i = 1; $i <= $count; $i++) {
540 echo "document.getElementById(\"check$i\").checked=true; document.getElementById(\"row$i\").style.background='#E7E7E7'; ";
541 } ?>
543 else {
544 document.getElementById("checkAll").checked=false;<?php
545 for($i = 1; $i <= $count; $i++) {
546 echo "document.getElementById(\"check$i\").checked=false; document.getElementById(\"row$i\").style.background='#F7F7F7'; ";
547 } ?>
550 // The two functions below are for managing row styles in Messages table.
551 function selectRow(row) {
552 document.getElementById(row).style.background = "#E7E7E7";
554 function deselectRow(row) {
555 document.getElementById(row).style.background = "#F7F7F7";
557 </script><?php
561 </body>
562 </html>