PHP7 Project. Commit 20. Fixes in calendar module.
[openemr.git] / interface / main / messages / messages.php
blobec1e94f373cef6ee1a55a41d49f201c385b1b90a
1 <?php
2 /**
3 * Message and Reminder Center UI
5 * 2013/02/08 Minor tweaks by EMR Direct to allow integration with Direct messaging
6 * 2013-03-27 by sunsetsystems: Fixed some weirdness with assigning a message recipient,
7 * and allowing a message to be closed with a new note appended and no recipient.
9 * Copyright (c) 2010 OpenEMR Support LLC
11 * LICENSE: This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 3
14 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
22 * @package OpenEMR
23 * @author OpenEMR Support LLC
24 * @author Roberto Vasquez <robertogagliotta@gmail.com>
25 * @author Rod Roark <rod@sunsetsystems.com>
26 * @author Brady Miller <brady@sparmy.com>
27 * @link http://www.open-emr.org
30 //SANITIZE ALL ESCAPES
31 $sanitize_all_escapes=true;
33 //STOP FAKE REGISTER GLOBALS
34 $fake_register_globals=false;
36 require_once("../../globals.php");
37 require_once("$srcdir/pnotes.inc");
38 require_once("$srcdir/patient.inc");
39 require_once("$srcdir/acl.inc");
40 require_once("$srcdir/log.inc");
41 require_once("$srcdir/options.inc.php");
42 require_once("$srcdir/formdata.inc.php");
43 require_once("$srcdir/classes/Document.class.php");
44 require_once("$srcdir/gprelations.inc.php");
45 require_once("$srcdir/formatting.inc.php");
47 <html>
48 <head>
50 <?php html_header_show();?>
51 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
52 <script type="text/javascript" src="../../../library/dialog.js"></script>
53 <script type="text/javascript" src="../../../library/textformat.js"></script>
54 <script type="text/javascript" src="<?php echo $GLOBALS['webroot']; ?>/library/js/jquery.js"></script>
55 </head>
57 <body class="body_top">
59 <span class="title"><?php echo xlt('Message and Reminder Center'); ?></span>
60 <br /><br />
61 <span class="title"><?php echo xlt('Reminders'); ?></span>
63 <?php
65 // TajEmo Work by CB 2012/01/11 02:51:25 PM adding dated reminders
66 // I am asuming that at this point security checks have been performed
67 require_once '../dated_reminders/dated_reminders.php';
69 // Check to see if the user has Admin rights, and if so, allow access to See All.
70 $showall = isset($_GET['show_all']) ? $_GET['show_all'] : "" ;
71 if ($showall == "yes") {
72 $show_all = $showall;
74 else
76 $show_all= "no";
79 // Collect active variable and applicable html code for links
80 $form_active = (isset($_REQUEST['form_active']) ? $_REQUEST['form_active'] : FALSE);
81 $form_inactive = (isset($_REQUEST['form_inactive']) ? $_REQUEST['form_inactive'] : FALSE);
82 if ($form_active) {
83 $active = '1';
84 $activity_string_html = 'form_active=1';
86 else if ($form_inactive) {
87 $active = '0';
88 $activity_string_html = 'form_inactive=1';
90 else {
91 $active = 'all';
92 $activity_string_html = '';
95 //collect the task setting
96 $task= isset($_REQUEST['task']) ? $_REQUEST['task'] : "";
98 if (acl_check('admin', 'super' )) {
99 if ($show_all=='yes') {
100 $showall = "yes";
101 $lnkvar="'messages.php?show_all=no&$activity_string_html' name='Just Mine' onclick=\"top.restoreSession()\"> (".htmlspecialchars( xl('Just Mine'), ENT_NOQUOTES).")";
103 else {
104 $showall = "no";
105 $lnkvar="'messages.php?show_all=yes&$activity_string_html' name='See All' onclick=\"top.restoreSession()\"> (".htmlspecialchars( xl('See All'), ENT_NOQUOTES).")";
109 <br>
110 <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>
111 <?php
112 //show the activity links
113 if (empty($task) || $task=="add" || $task=="delete") { ?>
114 <?php if ($active == "all") { ?>
115 <span><?php echo xlt('Show All'); ?></span>
116 <?php } else { ?>
117 <a href="messages.php" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show All'); ?></span></a>
118 <?php } ?>
120 <?php if ($active == '1') { ?>
121 <span><?php echo xlt('Show Active'); ?></span>
122 <?php } else { ?>
123 <a href="messages.php?form_active=1" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show Active'); ?></span></a>
124 <?php } ?>
126 <?php if ($active == '0') { ?>
127 <span><?php echo xlt('Show Inactive'); ?></span>
128 <?php } else { ?>
129 <a href="messages.php?form_inactive=1" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show Inactive'); ?></span></a>
130 <?php } ?>
131 <?php } ?>
133 <?php
134 switch($task) {
135 case "add" :
137 // Add a new message for a specific patient; the message is documented in Patient Notes.
138 // Add a new message; it's treated as a new note in Patient Notes.
139 $note = $_POST['note'];
140 $noteid = $_POST['noteid'];
141 $form_note_type = $_POST['form_note_type'];
142 $form_message_status = $_POST['form_message_status'];
143 $reply_to = $_POST['reply_to'];
144 $assigned_to_list = explode(';', $_POST['assigned_to']);
145 foreach($assigned_to_list as $assigned_to){
146 if ($noteid && $assigned_to != '-patient-') {
147 updatePnote($noteid, $note, $form_note_type, $assigned_to, $form_message_status);
148 $noteid = '';
150 else {
151 if($noteid && $assigned_to == '-patient-'){
152 // When $assigned_to == '-patient-' we don't update the current note, but
153 // instead create a new one with the current note's body prepended and
154 // attributed to the patient. This seems to be all for the patient portal.
155 $row = getPnoteById($noteid);
156 if (! $row) die("getPnoteById() did not find id '".text($noteid)."'");
157 $pres = sqlQuery("SELECT lname, fname " .
158 "FROM patient_data WHERE pid = ?", array($reply_to) );
159 $patientname = $pres['lname'] . ", " . $pres['fname'];
160 $note .= "\n\n$patientname on ".$row['date']." wrote:\n\n";
161 $note .= $row['body'];
163 // There's no note ID, and/or it's assigned to the patient.
164 // In these cases a new note is created.
165 addPnote($reply_to, $note, $userauthorized, '1', $form_note_type, $assigned_to, '', $form_message_status);
168 } break;
169 case "savePatient":
170 case "save" : {
171 // Update alert.
172 $noteid = $_POST['noteid'];
173 $form_message_status = $_POST['form_message_status'];
174 $reply_to = $_POST['reply_to'];
175 if ($task=="save")
176 updatePnoteMessageStatus($noteid,$form_message_status);
177 else
178 updatePnotePatient($noteid,$reply_to);
179 $task = "edit";
180 $note = $_POST['note'];
181 $title = $_POST['form_note_type'];
182 $reply_to = $_POST['reply_to'];
184 case "edit" : {
185 if ($noteid == "") {
186 $noteid = $_GET['noteid'];
188 // Update the message if it already exists; it's appended to an existing note in Patient Notes.
189 $result = getPnoteById($noteid);
190 if ($result) {
191 if ($title == ""){
192 $title = $result['title'];
194 $body = $result['body'];
195 if ($reply_to == ""){
196 $reply_to = $result['pid'];
198 $form_message_status = $result['message_status'];
200 } break;
201 case "delete" : {
202 // Delete selected message(s) from the Messages box (only).
203 $delete_id = $_POST['delete_id'];
204 for($i = 0; $i < count($delete_id); $i++) {
205 deletePnote($delete_id[$i]);
206 newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "pnotes: id ".$delete_id[$i]);
208 } break;
211 if($task == "addnew" or $task == "edit") {
212 // Display the Messages page layout.
213 echo "
214 <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>
215 <input type=hidden name=noteid id=noteid value='".attr($noteid)."'>
216 <input type=hidden name=task id=task value=add>";
218 <div id="pnotes"><center>
219 <table border='0' cellspacing='8'>
220 <tr>
221 <td class='text'>
222 <b><?php echo htmlspecialchars( xl('Type'), ENT_NOQUOTES); ?>:</b>
223 <?php
224 if ($title == "") {
225 $title = "Unassigned";
227 // Added 6/2009 by BM to incorporate the patient notes into the list_options listings.
228 generate_form_field(array('data_type'=>1,'field_id'=>'note_type','list_id'=>'note_type','empty_title'=>'SKIP','order_by'=>'title'), $title);
230 &nbsp; &nbsp;
231 <?php if ($task != "addnew" && $result['pid'] != 0) { ?>
232 <a class="patLink" onclick="goPid('<?php echo attr($result['pid']);?>')"><?php echo htmlspecialchars( xl('Patient'), ENT_NOQUOTES); ?>:</a>
233 <?php } else { ?>
234 <b class='<?php echo ($task=="addnew"?"required":"") ?>'><?php echo htmlspecialchars( xl('Patient'), ENT_NOQUOTES); ?>:</b>
235 <?php
237 if ($reply_to) {
238 $prow = sqlQuery("SELECT lname, fname " .
239 "FROM patient_data WHERE pid = ?", array($reply_to) );
240 $patientname = $prow['lname'] . ", " . $prow['fname'];
242 if ($patientname == '') {
243 $patientname = xl('Click to select');
244 } ?>
245 <input type='text' size='10' name='form_patient' style='width:150px;<?php
246 echo ($task=="addnew"?"cursor:pointer;cursor:hand;":"") ?>' value='<?php
247 echo htmlspecialchars($patientname, ENT_QUOTES); ?>' <?php
248 echo (($task=="addnew" || $result['pid']==0) ? "onclick='sel_patient()' readonly":"disabled") ?> title='<?php
249 echo ($task=="addnew"?(htmlspecialchars( xl('Click to select patient'), ENT_QUOTES)):"") ?>' />
250 <input type='hidden' name='reply_to' id='reply_to' value='<?php echo htmlspecialchars( $reply_to, ENT_QUOTES) ?>' />
251 &nbsp; &nbsp;
252 <b><?php echo htmlspecialchars( xl('Status'), ENT_NOQUOTES); ?>:</b>
253 <?php
254 if ($form_message_status == "") {
255 $form_message_status = 'New';
257 generate_form_field(array('data_type'=>1,'field_id'=>'message_status','list_id'=>'message_status','empty_title'=>'SKIP','order_by'=>'title'), $form_message_status); ?>
258 </td>
259 </tr>
260 <tr>
261 <td class='text'>
262 <b><?php echo htmlspecialchars( xl('To'), ENT_QUOTES); ?>:</b>
263 <input type='textbox' name='assigned_to_text' id='assigned_to_text' size='40' readonly='readonly'
264 value='<?php echo htmlspecialchars(xl("Select Users From The Dropdown List"), ENT_QUOTES)?>' >
265 <input type='hidden' name='assigned_to' id='assigned_to' >
266 <select name='users' id='users' onchange='addtolist(this);' >
267 <?php
268 echo "<option value='" . htmlspecialchars( '--', ENT_QUOTES) . "'";
269 echo ">" . htmlspecialchars( xl('Select User'), ENT_NOQUOTES);
270 echo "</option>\n";
271 $ures = sqlStatement("SELECT username, fname, lname FROM users " .
272 "WHERE username != '' AND active = 1 AND " .
273 "( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
274 "ORDER BY lname, fname");
275 while ($urow = sqlFetchArray($ures)) {
276 echo " <option value='" . htmlspecialchars( $urow['username'], ENT_QUOTES) . "'";
277 echo ">" . htmlspecialchars( $urow['lname'], ENT_NOQUOTES);
278 if ($urow['fname']) echo ", " . htmlspecialchars( $urow['fname'], ENT_NOQUOTES);
279 echo "</option>\n";
281 echo "<option value='" . htmlspecialchars( '-patient-', ENT_QUOTES) . "'";
282 echo ">" . htmlspecialchars( '-Patient-', ENT_NOQUOTES);
283 echo "</option>\n";
285 </select>
286 </td>
287 </tr>
289 <?php
290 if ($noteid) {
291 // Get the related document IDs if any.
292 $tmp = sqlStatement("SELECT id1 FROM gprelations WHERE " .
293 "type1 = ? AND type2 = ? AND id2 = ?",
294 array('1', '6', $noteid));
295 if (sqlNumRows($tmp)) {
296 echo " <tr>\n";
297 echo " <td class='text'><b>";
298 echo xlt('Linked document') . ":</b>\n";
299 while ($gprow = sqlFetchArray($tmp)) {
300 $d = new Document($gprow['id1']);
301 echo " <a href='";
302 echo $GLOBALS['webroot'] . "/controller.php?document&retrieve";
303 echo "&patient_id=" . $d->get_foreign_id();
304 echo "&document_id=" . $d->get_id();
305 echo "&as_file=true' target='_blank' onclick='top.restoreSession()'>";
306 echo text($d->get_url_file());
307 echo "</a>\n";
309 echo " </td>\n";
310 echo " </tr>\n";
312 // Get the related procedure order IDs if any.
313 $tmp = sqlStatement("SELECT id1 FROM gprelations WHERE " .
314 "type1 = ? AND type2 = ? AND id2 = ?",
315 array('2', '6', $noteid));
316 if (sqlNumRows($tmp)) {
317 echo " <tr>\n";
318 echo " <td class='text'><b>";
319 echo xlt('Linked procedure order') . ":</b>\n";
320 while ($gprow = sqlFetchArray($tmp)) {
321 echo " <a href='";
322 echo $GLOBALS['webroot'] . "/interface/orders/single_order_results.php?orderid=";
323 echo $gprow['id1'];
324 echo "' target='_blank' onclick='top.restoreSession()'>";
325 echo $gprow['id1'];
326 echo "</a>\n";
328 echo " </td>\n";
329 echo " </tr>\n";
334 <tr>
335 <td>
337 <?php
339 if ($noteid) {
340 $body = preg_replace('/(:\d{2}\s\()'.$result['pid'].'(\sto\s)/','${1}'.$patientname.'${2}',$body);
341 $body = nl2br(htmlspecialchars( $body, ENT_NOQUOTES));
342 echo "<div class='text' style='background-color:white; color: gray; border:1px solid #999; padding: 5px; width: 640px;'>".$body."</div>";
346 <textarea name='note' id='note' rows='8' style="width: 660px; "><?php echo htmlspecialchars( $note, ENT_NOQUOTES) ?></textarea>
347 </td>
348 </tr>
349 </table>
351 <?php if ($noteid) { ?>
352 <!-- This is for displaying an existing note. -->
353 <input type="button" id="newnote" value="<?php echo htmlspecialchars( xl('Send message'), ENT_QUOTES); ?>">
354 <input type="button" id="printnote" value="<?php echo htmlspecialchars( xl('Print message'), ENT_QUOTES); ?>">
355 <input type="button" id="cancel" value="<?php echo htmlspecialchars( xl('Cancel'), ENT_QUOTES); ?>">
356 <?php } else { ?>
357 <!-- This is for displaying a new note. -->
358 <input type="button" id="newnote" value="<?php echo htmlspecialchars( xl('Send message'), ENT_QUOTES); ?>">
359 <input type="button" id="cancel" value="<?php echo htmlspecialchars( xl('Cancel'), ENT_QUOTES); ?>">
360 <?php }
363 <br>
364 </form></center></div>
365 <script language="javascript">
367 // jQuery stuff to make the page a little easier to use
369 $(document).ready(function(){
370 $("#newnote").click(function() { NewNote(); });
371 $("#printnote").click(function() { PrintNote(); });
372 obj = document.getElementById("form_message_status");
373 obj.onchange = function(){SaveNote();};
374 $("#cancel").click(function() { CancelNote(); });
375 $("#note").focus();
377 var NewNote = function () {
378 top.restoreSession();
379 if (document.forms[0].reply_to.value.length == 0 || document.forms[0].reply_to.value == '0') {
380 alert('<?php echo htmlspecialchars( xl('Please choose a patient'), ENT_QUOTES); ?>');
382 else if (document.forms[0].assigned_to.value.length == 0 &&
383 document.getElementById("form_message_status").value != 'Done')
385 alert('<?php echo addslashes(xl('Recipient required unless status is Done')); ?>');
387 else
389 $("#new_note").submit();
393 var PrintNote = function () {
394 top.restoreSession();
395 window.open('../../patient_file/summary/pnotes_print.php?noteid=<?php echo htmlspecialchars( $noteid, ENT_QUOTES); ?>', '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
398 var SaveNote = function () {
399 <?php if ($noteid) { ?>
400 top.restoreSession();
401 $("#task").val("save");
402 $("#new_note").submit();
403 <?php } ?>
406 var CancelNote = function () {
407 top.restoreSession();
408 $("#task").val("");
409 $("#new_note").submit();
412 // This is for callback by the find-patient popup.
413 function setpatient(pid, lname, fname, dob) {
414 var f = document.forms[0];
415 f.form_patient.value = lname + ', ' + fname;
416 f.reply_to.value = pid;
417 <?php if ($noteid) { ?>
418 //used when direct messaging service inserts a pnote with indeterminate patient
419 //to allow the user to assign the message to a patient.
420 top.restoreSession();
421 $("#task").val("savePatient");
422 $("#new_note").submit();
423 <?php } ?>
426 // This invokes the find-patient popup.
427 function sel_patient() {
428 dlgopen('../../main/calendar/find_patient_popup.php', '_blank', 500, 400);
431 function addtolist(sel){
432 var itemtext = document.getElementById('assigned_to_text');
433 var item = document.getElementById('assigned_to');
434 if(sel.value != '--'){
435 if(item.value){
436 if(item.value.indexOf(sel.value) == -1){
437 itemtext.value = itemtext.value +' ; '+ sel.options[sel.selectedIndex].text;
438 item.value = item.value +';'+ sel.value;
440 }else{
441 itemtext.value = sel.options[sel.selectedIndex].text;
442 item.value = sel.value;
447 </script><?php
449 else {
451 // This is for sorting the records.
452 $sort = array("users.lname", "patient_data.lname", "pnotes.title", "pnotes.date", "pnotes.message_status");
453 $sortby = (isset($_REQUEST['sortby']) && ($_REQUEST['sortby']!="")) ? $_REQUEST['sortby'] : $sort[0];
454 $sortorder = (isset($_REQUEST['sortorder']) && ($_REQUEST['sortorder']!="")) ? $_REQUEST['sortorder'] : "asc";
455 $begin = isset($_REQUEST['begin']) ? $_REQUEST['begin'] : 0;
457 for($i = 0; $i < count($sort); $i++) {
458 $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>";
460 for($i = 0; $i < count($sort); $i++) {
461 if($sortby == $sort[$i]) {
462 switch($sortorder) {
463 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;
464 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;
465 } break;
468 // Manage page numbering and display beneath the Messages table.
469 $listnumber = 25;
470 $total = getPnotesByUser($active,$show_all,$_SESSION['authUser'],true);
471 if($begin == "" or $begin == 0) {
472 $begin = 0;
474 $prev = $begin - $listnumber;
475 $next = $begin + $listnumber;
476 $start = $begin + 1;
477 $end = $listnumber + $start - 1;
478 if($end >= $total) {
479 $end = $total;
481 if($end < $start) {
482 $start = 0;
484 if($prev >= 0) {
485 $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>";
487 else {
488 $prevlink = "<<";
491 if($next < $total) {
492 $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>";
494 else {
495 $nextlink = ">>";
497 // Display the Messages table header.
498 echo "
499 <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;\">
500 <form name=MessageList action=\"messages.php?showall=".attr($showall)."&sortby=".attr($sortby)."&sortorder=".attr($sortorder)."&begin=".attr($begin)."&$activity_string_html\" method=post>
501 <input type=hidden name=task value=delete>
502 <tr height=\"24\" style=\"background:lightgrey\">
503 <td align=\"center\" width=\"25\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\"><input type=checkbox id=\"checkAll\" onclick=\"selectAll()\"></td>
504 <td width=\"20%\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
505 htmlspecialchars( xl('From'), ENT_NOQUOTES) . "</b> $sortlink[0]</td>
506 <td width=\"20%\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
507 htmlspecialchars( xl('Patient'), ENT_NOQUOTES) . "</b> $sortlink[1]</td>
508 <td style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
509 htmlspecialchars( xl('Type'), ENT_NOQUOTES) . "</b> $sortlink[2]</td>
510 <td width=\"15%\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
511 htmlspecialchars( xl('Date'), ENT_NOQUOTES) . "</b> $sortlink[3]</td>
512 <td width=\"15%\" style=\"border-bottom: 1px #000000 solid; \" class=bold>&nbsp;<b>" .
513 htmlspecialchars( xl('Status'), ENT_NOQUOTES) . "</b> $sortlink[4]</td>
514 </tr>";
515 // Display the Messages table body.
516 $count = 0;
517 $result = getPnotesByUser($active,$show_all,$_SESSION['authUser'],false,$sortby,$sortorder,$begin,$listnumber);
518 while ($myrow = sqlFetchArray($result)) {
519 $name = $myrow['user'];
520 $name = $myrow['users_lname'];
521 if ($myrow['users_fname']) {
522 $name .= ", " . $myrow['users_fname'];
524 $patient = $myrow['pid'];
525 if ($patient>0) {
526 $patient = $myrow['patient_data_lname'];
527 if ($myrow['patient_data_fname']) {
528 $patient .= ", " . $myrow['patient_data_fname'];
530 } else {
531 $patient = "* Patient must be set manually *";
533 $count++;
534 echo "
535 <tr id=\"row$count\" style=\"background:white\" height=\"24\">
536 <td align=\"center\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\"><input type=checkbox id=\"check$count\" name=\"delete_id[]\" value=\"" .
537 htmlspecialchars( $myrow['id'], ENT_QUOTES) . "\" onclick=\"if(this.checked==true){ selectRow('row$count'); }else{ deselectRow('row$count'); }\"></td>
538 <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\">" .
539 htmlspecialchars( $name, ENT_NOQUOTES) . "</td><td width=5></td></tr></table></td>
540 <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=" .
541 htmlspecialchars( $myrow['id'], ENT_QUOTES) . "&$activity_string_html\" onclick=\"top.restoreSession()\">" .
542 htmlspecialchars( $patient, ENT_NOQUOTES) . "</a></td><td width=5></td></tr></table></td>
543 <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\">" .
544 htmlspecialchars( $myrow['title'], ENT_NOQUOTES) . "</td><td width=5></td></tr></table></td>
545 <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\">" .
546 htmlspecialchars( oeFormatShortDate(substr($myrow['date'], 0, strpos($myrow['date'], " "))), ENT_NOQUOTES) . "</td><td width=5></td></tr></table></td>
547 <td style=\"border-bottom: 1px #000000 solid;\"><table cellspacing=0 cellpadding=0 width=100%><tr><td width=5></td><td class=\"text\">" .
548 htmlspecialchars( $myrow['message_status'], ENT_NOQUOTES) . "</td><td width=5></td></tr></table></td>
549 </tr>";
551 // Display the Messages table footer.
552 echo "
553 </form></table>
554 <table border=0 cellpadding=5 cellspacing=0 width=90%>
555 <tr>
556 <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()\">" .
557 htmlspecialchars( xl('Add New'), ENT_NOQUOTES) . "</a> &nbsp; <a href=\"javascript:confirmDeleteSelected()\" onclick=\"top.restoreSession()\">" .
558 htmlspecialchars( xl('Delete'), ENT_NOQUOTES) . "</a></td>
559 <td align=right class=\"text\">$prevlink &nbsp; $end of $total &nbsp; $nextlink</td>
560 </tr>
561 </table></td></tr></table><br>";
563 <script language="javascript">
564 // This is to confirm delete action.
565 function confirmDeleteSelected() {
566 if(confirm("<?php echo htmlspecialchars( xl('Do you really want to delete the selection?'), ENT_QUOTES); ?>")) {
567 document.MessageList.submit();
570 // This is to allow selection of all items in Messages table for deletion.
571 function selectAll() {
572 if(document.getElementById("checkAll").checked==true) {
573 document.getElementById("checkAll").checked=true;<?php
574 for($i = 1; $i <= $count; $i++) {
575 echo "document.getElementById(\"check$i\").checked=true; document.getElementById(\"row$i\").style.background='#E7E7E7'; ";
576 } ?>
578 else {
579 document.getElementById("checkAll").checked=false;<?php
580 for($i = 1; $i <= $count; $i++) {
581 echo "document.getElementById(\"check$i\").checked=false; document.getElementById(\"row$i\").style.background='#F7F7F7'; ";
582 } ?>
585 // The two functions below are for managing row styles in Messages table.
586 function selectRow(row) {
587 document.getElementById(row).style.background = "#E7E7E7";
589 function deselectRow(row) {
590 document.getElementById(row).style.background = "#F7F7F7";
592 </script><?php
596 </body>
597 </html>