added cache clearing support for dialog.js (#411)
[openemr.git] / interface / main / messages / messages.php
blobc2e37e18fa2a2471a7b0a98b998c45be51343249
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?v=<?php echo $v_js_includes; ?>"></script>
53 <script type="text/javascript" src="../../../library/textformat.js"></script>
54 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-1/index.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,pid, pubpid, DOB " .
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 $enc_list = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe ".
302 " left join openemr_postcalendar_categories on fe.pc_catid=openemr_postcalendar_categories.pc_catid WHERE fe.pid = ? order by fe.date desc", array($prow['pid']));
303 $str_dob = htmlspecialchars(xl("DOB") . ":" . $prow['DOB'] . " " . xl("Age") . ":" . getPatientAge($prow['DOB']));
304 $pname = $prow['fname']." ".$prow['lname'];
305 echo "<a href='javascript:void(0);' ";
306 echo "onClick=\"gotoReport(".addslashes(attr($d->get_id())).",'".addslashes(attr($pname))."',".addslashes(attr($prow['pid'])).",".addslashes(attr($prow['pubpid'])).",'".addslashes(attr($str_dob))."');\">";
307 echo text($d->get_url_file());
308 echo "</a>\n";
310 echo " </td>\n";
311 echo " </tr>\n";
313 // Get the related procedure order IDs if any.
314 $tmp = sqlStatement("SELECT id1 FROM gprelations WHERE " .
315 "type1 = ? AND type2 = ? AND id2 = ?",
316 array('2', '6', $noteid));
317 if (sqlNumRows($tmp)) {
318 echo " <tr>\n";
319 echo " <td class='text'><b>";
320 echo xlt('Linked procedure order') . ":</b>\n";
321 while ($gprow = sqlFetchArray($tmp)) {
322 echo " <a href='";
323 echo $GLOBALS['webroot'] . "/interface/orders/single_order_results.php?orderid=";
324 echo $gprow['id1'];
325 echo "' target='_blank' onclick='top.restoreSession()'>";
326 echo $gprow['id1'];
327 echo "</a>\n";
329 echo " </td>\n";
330 echo " </tr>\n";
335 <tr>
336 <td>
338 <?php
340 if ($noteid) {
341 $body = preg_replace('/(:\d{2}\s\()'.$result['pid'].'(\sto\s)/','${1}'.$patientname.'${2}',$body);
342 $body = nl2br(htmlspecialchars( $body, ENT_NOQUOTES));
343 echo "<div class='text' style='background-color:white; color: gray; border:1px solid #999; padding: 5px; width: 640px;'>".$body."</div>";
347 <textarea name='note' id='note' rows='8' style="width: 660px; "><?php echo htmlspecialchars( $note, ENT_NOQUOTES) ?></textarea>
348 </td>
349 </tr>
350 </table>
352 <?php if ($noteid) { ?>
353 <!-- This is for displaying an existing note. -->
354 <input type="button" id="newnote" value="<?php echo htmlspecialchars( xl('Send message'), ENT_QUOTES); ?>">
355 <input type="button" id="printnote" value="<?php echo htmlspecialchars( xl('Print message'), ENT_QUOTES); ?>">
356 <input type="button" id="cancel" value="<?php echo htmlspecialchars( xl('Cancel'), ENT_QUOTES); ?>">
357 <?php } else { ?>
358 <!-- This is for displaying a new note. -->
359 <input type="button" id="newnote" value="<?php echo htmlspecialchars( xl('Send message'), ENT_QUOTES); ?>">
360 <input type="button" id="cancel" value="<?php echo htmlspecialchars( xl('Cancel'), ENT_QUOTES); ?>">
361 <?php }
364 <br>
365 </form></center></div>
366 <script language="javascript">
368 // jQuery stuff to make the page a little easier to use
370 $(document).ready(function(){
371 $("#newnote").click(function() { NewNote(); });
372 $("#printnote").click(function() { PrintNote(); });
373 obj = document.getElementById("form_message_status");
374 obj.onchange = function(){SaveNote();};
375 $("#cancel").click(function() { CancelNote(); });
376 $("#note").focus();
378 var NewNote = function () {
379 top.restoreSession();
380 if (document.forms[0].reply_to.value.length == 0 || document.forms[0].reply_to.value == '0') {
381 alert('<?php echo htmlspecialchars( xl('Please choose a patient'), ENT_QUOTES); ?>');
383 else if (document.forms[0].assigned_to.value.length == 0 &&
384 document.getElementById("form_message_status").value != 'Done')
386 alert('<?php echo addslashes(xl('Recipient required unless status is Done')); ?>');
388 else
390 $("#new_note").submit();
394 var PrintNote = function () {
395 top.restoreSession();
396 window.open('../../patient_file/summary/pnotes_print.php?noteid=<?php echo htmlspecialchars( $noteid, ENT_QUOTES); ?>', '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
399 var SaveNote = function () {
400 <?php if ($noteid) { ?>
401 top.restoreSession();
402 $("#task").val("save");
403 $("#new_note").submit();
404 <?php } ?>
407 var CancelNote = function () {
408 top.restoreSession();
409 $("#task").val("");
410 $("#new_note").submit();
413 function gotoReport(doc_id,pname,pid,pubpid,str_dob){
414 EncounterDateArray=new Array;
415 CalendarCategoryArray=new Array;
416 EncounterIdArray=new Array;
417 Count = 0;
418 <?php
419 if(isset($enc_list) && sqlNumRows($enc_list) >0 ){
420 while($row = sqlFetchArray($enc_list)){
422 EncounterIdArray[Count]='<?php echo attr($row['encounter']); ?>';
423 EncounterDateArray[Count]='<?php echo attr(oeFormatShortDate(date("Y-m-d", strtotime($row['date'])))); ?>';
424 CalendarCategoryArray[Count]='<?php echo attr(xl_appt_category($row['pc_catname'])); ?>';
425 Count++;
426 <?php
430 top.restoreSession();
431 $.ajax({
432 type:'get',
433 url:'<?php echo $GLOBALS['webroot']."/interface/patient_file/encounter/patient_encounter.php";?>',
434 data:{set_pid: pid},
435 async: false
437 parent.left_nav.setPatient(pname,pid,pubpid,'',str_dob);
438 parent.left_nav.setPatientEncounter(EncounterIdArray,EncounterDateArray,CalendarCategoryArray);
439 <?php if ($GLOBALS['new_tabs_layout']) { ?>
440 var docurl = '../controller.php?document&view' + "&patient_id=" + pid + "&document_id=" + doc_id + "&";
441 var paturl = 'patient_file/summary/demographics.php?pid=' + pid;
442 parent.left_nav.loadFrame('dem1', 'pat', paturl);
443 parent.left_nav.loadFrame('doc0', 'enc', docurl);
444 top.activateTabByName('enc',true);
445 <?php } else { ?>
446 var docurl = '<?php echo $GLOBALS['webroot'] . "/controller.php?document&view"; ?>' + "&patient_id=" + pid + "&document_id=" + doc_id + "&";
447 var paturl = '<?php echo $GLOBALS['webroot'] . "/interface/patient_file/summary/demographics.php?pid="; ?>' + pid;
448 var othername = (window.name == 'RTop') ? 'RBot' : 'RTop';
449 parent.frames[othername].location.href = paturl;
450 location.href = docurl;
451 <?php } ?>
453 // This is for callback by the find-patient popup.
454 function setpatient(pid, lname, fname, dob) {
455 var f = document.forms[0];
456 f.form_patient.value = lname + ', ' + fname;
457 f.reply_to.value = pid;
458 <?php if ($noteid) { ?>
459 //used when direct messaging service inserts a pnote with indeterminate patient
460 //to allow the user to assign the message to a patient.
461 top.restoreSession();
462 $("#task").val("savePatient");
463 $("#new_note").submit();
464 <?php } ?>
467 // This invokes the find-patient popup.
468 function sel_patient() {
469 dlgopen('../../main/calendar/find_patient_popup.php', '_blank', 500, 400);
472 function addtolist(sel){
473 var itemtext = document.getElementById('assigned_to_text');
474 var item = document.getElementById('assigned_to');
475 if(sel.value != '--'){
476 if(item.value){
477 if(item.value.indexOf(sel.value) == -1){
478 itemtext.value = itemtext.value +' ; '+ sel.options[sel.selectedIndex].text;
479 item.value = item.value +';'+ sel.value;
481 }else{
482 itemtext.value = sel.options[sel.selectedIndex].text;
483 item.value = sel.value;
488 </script><?php
490 else {
492 // This is for sorting the records.
493 $sort = array("users.lname", "patient_data.lname", "pnotes.title", "pnotes.date", "pnotes.message_status");
494 $sortby = (isset($_REQUEST['sortby']) && ($_REQUEST['sortby']!="")) ? $_REQUEST['sortby'] : $sort[0];
495 $sortorder = (isset($_REQUEST['sortorder']) && ($_REQUEST['sortorder']!="")) ? $_REQUEST['sortorder'] : "asc";
496 $begin = isset($_REQUEST['begin']) ? $_REQUEST['begin'] : 0;
498 for($i = 0; $i < count($sort); $i++) {
499 $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>";
501 for($i = 0; $i < count($sort); $i++) {
502 if($sortby == $sort[$i]) {
503 switch($sortorder) {
504 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;
505 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;
506 } break;
509 // Manage page numbering and display beneath the Messages table.
510 $listnumber = 25;
511 $total = getPnotesByUser($active,$show_all,$_SESSION['authUser'],true);
512 if($begin == "" or $begin == 0) {
513 $begin = 0;
515 $prev = $begin - $listnumber;
516 $next = $begin + $listnumber;
517 $start = $begin + 1;
518 $end = $listnumber + $start - 1;
519 if($end >= $total) {
520 $end = $total;
522 if($end < $start) {
523 $start = 0;
525 if($prev >= 0) {
526 $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>";
528 else {
529 $prevlink = "<<";
532 if($next < $total) {
533 $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>";
535 else {
536 $nextlink = ">>";
538 // Display the Messages table header.
539 echo "
540 <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;\">
541 <form name=MessageList action=\"messages.php?showall=".attr($showall)."&sortby=".attr($sortby)."&sortorder=".attr($sortorder)."&begin=".attr($begin)."&$activity_string_html\" method=post>
542 <input type=hidden name=task value=delete>
543 <tr height=\"24\" style=\"background:lightgrey\">
544 <td align=\"center\" width=\"25\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\"><input type=checkbox id=\"checkAll\" onclick=\"selectAll()\"></td>
545 <td width=\"20%\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
546 htmlspecialchars( xl('From'), ENT_NOQUOTES) . "</b> $sortlink[0]</td>
547 <td width=\"20%\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
548 htmlspecialchars( xl('Patient'), ENT_NOQUOTES) . "</b> $sortlink[1]</td>
549 <td style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
550 htmlspecialchars( xl('Type'), ENT_NOQUOTES) . "</b> $sortlink[2]</td>
551 <td width=\"15%\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
552 htmlspecialchars( xl('Date'), ENT_NOQUOTES) . "</b> $sortlink[3]</td>
553 <td width=\"15%\" style=\"border-bottom: 1px #000000 solid; \" class=bold>&nbsp;<b>" .
554 htmlspecialchars( xl('Status'), ENT_NOQUOTES) . "</b> $sortlink[4]</td>
555 </tr>";
556 // Display the Messages table body.
557 $count = 0;
558 $result = getPnotesByUser($active,$show_all,$_SESSION['authUser'],false,$sortby,$sortorder,$begin,$listnumber);
559 while ($myrow = sqlFetchArray($result)) {
560 $name = $myrow['user'];
561 $name = $myrow['users_lname'];
562 if ($myrow['users_fname']) {
563 $name .= ", " . $myrow['users_fname'];
565 $patient = $myrow['pid'];
566 if ($patient>0) {
567 $patient = $myrow['patient_data_lname'];
568 if ($myrow['patient_data_fname']) {
569 $patient .= ", " . $myrow['patient_data_fname'];
571 } else {
572 $patient = "* Patient must be set manually *";
574 $count++;
575 echo "
576 <tr id=\"row$count\" style=\"background:white\" height=\"24\">
577 <td align=\"center\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\"><input type=checkbox id=\"check$count\" name=\"delete_id[]\" value=\"" .
578 htmlspecialchars( $myrow['id'], ENT_QUOTES) . "\" onclick=\"if(this.checked==true){ selectRow('row$count'); }else{ deselectRow('row$count'); }\"></td>
579 <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\">" .
580 htmlspecialchars( $name, ENT_NOQUOTES) . "</td><td width=5></td></tr></table></td>
581 <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=" .
582 htmlspecialchars( $myrow['id'], ENT_QUOTES) . "&$activity_string_html\" onclick=\"top.restoreSession()\">" .
583 htmlspecialchars( $patient, ENT_NOQUOTES) . "</a></td><td width=5></td></tr></table></td>
584 <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\">" .
585 htmlspecialchars( $myrow['title'], ENT_NOQUOTES) . "</td><td width=5></td></tr></table></td>
586 <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\">" .
587 htmlspecialchars( oeFormatShortDate(substr($myrow['date'], 0, strpos($myrow['date'], " "))), ENT_NOQUOTES) . "</td><td width=5></td></tr></table></td>
588 <td style=\"border-bottom: 1px #000000 solid;\"><table cellspacing=0 cellpadding=0 width=100%><tr><td width=5></td><td class=\"text\">" .
589 htmlspecialchars( $myrow['message_status'], ENT_NOQUOTES) . "</td><td width=5></td></tr></table></td>
590 </tr>";
592 // Display the Messages table footer.
593 echo "
594 </form></table>
595 <table border=0 cellpadding=5 cellspacing=0 width=90%>
596 <tr>
597 <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()\">" .
598 htmlspecialchars( xl('Add New'), ENT_NOQUOTES) . "</a> &nbsp; <a href=\"javascript:confirmDeleteSelected()\" onclick=\"top.restoreSession()\">" .
599 htmlspecialchars( xl('Delete'), ENT_NOQUOTES) . "</a></td>
600 <td align=right class=\"text amount-msg\">$prevlink &nbsp; $end of $total &nbsp; $nextlink</td>
601 </tr>
602 </table></td></tr></table><br>";
604 <script language="javascript">
605 // This is to confirm delete action.
606 function confirmDeleteSelected() {
607 if(confirm("<?php echo htmlspecialchars( xl('Do you really want to delete the selection?'), ENT_QUOTES); ?>")) {
608 document.MessageList.submit();
611 // This is to allow selection of all items in Messages table for deletion.
612 function selectAll() {
613 if(document.getElementById("checkAll").checked==true) {
614 document.getElementById("checkAll").checked=true;<?php
615 for($i = 1; $i <= $count; $i++) {
616 echo "document.getElementById(\"check$i\").checked=true; document.getElementById(\"row$i\").style.background='#E7E7E7'; ";
617 } ?>
619 else {
620 document.getElementById("checkAll").checked=false;<?php
621 for($i = 1; $i <= $count; $i++) {
622 echo "document.getElementById(\"check$i\").checked=false; document.getElementById(\"row$i\").style.background='#F7F7F7'; ";
623 } ?>
626 // The two functions below are for managing row styles in Messages table.
627 function selectRow(row) {
628 document.getElementById(row).style.background = "#E7E7E7";
630 function deselectRow(row) {
631 document.getElementById(row).style.background = "#F7F7F7";
633 </script><?php
637 </body>
638 </html>