migrated ubiquitous libraries to composer autoloader (#421)
[openemr.git] / interface / main / messages / messages.php
blob674fb4a81aedfff7b0be0ffe2852c4946017f3ac
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/classes/Document.class.php");
43 require_once("$srcdir/gprelations.inc.php");
44 require_once("$srcdir/formatting.inc.php");
46 <html>
47 <head>
49 <?php html_header_show();?>
50 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
51 <script type="text/javascript" src="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
52 <script type="text/javascript" src="../../../library/textformat.js"></script>
53 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-1/index.js"></script>
54 </head>
56 <body class="body_top">
58 <span class="title"><?php echo xlt('Message and Reminder Center'); ?></span>
59 <br /><br />
60 <span class="title"><?php echo xlt('Reminders'); ?></span>
62 <?php
64 // TajEmo Work by CB 2012/01/11 02:51:25 PM adding dated reminders
65 // I am asuming that at this point security checks have been performed
66 require_once '../dated_reminders/dated_reminders.php';
68 // Check to see if the user has Admin rights, and if so, allow access to See All.
69 $showall = isset($_GET['show_all']) ? $_GET['show_all'] : "" ;
70 if ($showall == "yes") {
71 $show_all = $showall;
73 else
75 $show_all= "no";
78 // Collect active variable and applicable html code for links
79 $form_active = (isset($_REQUEST['form_active']) ? $_REQUEST['form_active'] : FALSE);
80 $form_inactive = (isset($_REQUEST['form_inactive']) ? $_REQUEST['form_inactive'] : FALSE);
81 if ($form_active) {
82 $active = '1';
83 $activity_string_html = 'form_active=1';
85 else if ($form_inactive) {
86 $active = '0';
87 $activity_string_html = 'form_inactive=1';
89 else {
90 $active = 'all';
91 $activity_string_html = '';
94 //collect the task setting
95 $task= isset($_REQUEST['task']) ? $_REQUEST['task'] : "";
97 if (acl_check('admin', 'super' )) {
98 if ($show_all=='yes') {
99 $showall = "yes";
100 $lnkvar="'messages.php?show_all=no&$activity_string_html' name='Just Mine' onclick=\"top.restoreSession()\"> (".htmlspecialchars( xl('Just Mine'), ENT_NOQUOTES).")";
102 else {
103 $showall = "no";
104 $lnkvar="'messages.php?show_all=yes&$activity_string_html' name='See All' onclick=\"top.restoreSession()\"> (".htmlspecialchars( xl('See All'), ENT_NOQUOTES).")";
108 <br>
109 <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>
110 <?php
111 //show the activity links
112 if (empty($task) || $task=="add" || $task=="delete") { ?>
113 <?php if ($active == "all") { ?>
114 <span><?php echo xlt('Show All'); ?></span>
115 <?php } else { ?>
116 <a href="messages.php" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show All'); ?></span></a>
117 <?php } ?>
119 <?php if ($active == '1') { ?>
120 <span><?php echo xlt('Show Active'); ?></span>
121 <?php } else { ?>
122 <a href="messages.php?form_active=1" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show Active'); ?></span></a>
123 <?php } ?>
125 <?php if ($active == '0') { ?>
126 <span><?php echo xlt('Show Inactive'); ?></span>
127 <?php } else { ?>
128 <a href="messages.php?form_inactive=1" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show Inactive'); ?></span></a>
129 <?php } ?>
130 <?php } ?>
132 <?php
133 switch($task) {
134 case "add" :
136 // Add a new message for a specific patient; the message is documented in Patient Notes.
137 // Add a new message; it's treated as a new note in Patient Notes.
138 $note = $_POST['note'];
139 $noteid = $_POST['noteid'];
140 $form_note_type = $_POST['form_note_type'];
141 $form_message_status = $_POST['form_message_status'];
142 $reply_to = $_POST['reply_to'];
143 $assigned_to_list = explode(';', $_POST['assigned_to']);
144 foreach($assigned_to_list as $assigned_to){
145 if ($noteid && $assigned_to != '-patient-') {
146 updatePnote($noteid, $note, $form_note_type, $assigned_to, $form_message_status);
147 $noteid = '';
149 else {
150 if($noteid && $assigned_to == '-patient-'){
151 // When $assigned_to == '-patient-' we don't update the current note, but
152 // instead create a new one with the current note's body prepended and
153 // attributed to the patient. This seems to be all for the patient portal.
154 $row = getPnoteById($noteid);
155 if (! $row) die("getPnoteById() did not find id '".text($noteid)."'");
156 $pres = sqlQuery("SELECT lname, fname " .
157 "FROM patient_data WHERE pid = ?", array($reply_to) );
158 $patientname = $pres['lname'] . ", " . $pres['fname'];
159 $note .= "\n\n$patientname on ".$row['date']." wrote:\n\n";
160 $note .= $row['body'];
162 // There's no note ID, and/or it's assigned to the patient.
163 // In these cases a new note is created.
164 addPnote($reply_to, $note, $userauthorized, '1', $form_note_type, $assigned_to, '', $form_message_status);
167 } break;
168 case "savePatient":
169 case "save" : {
170 // Update alert.
171 $noteid = $_POST['noteid'];
172 $form_message_status = $_POST['form_message_status'];
173 $reply_to = $_POST['reply_to'];
174 if ($task=="save")
175 updatePnoteMessageStatus($noteid,$form_message_status);
176 else
177 updatePnotePatient($noteid,$reply_to);
178 $task = "edit";
179 $note = $_POST['note'];
180 $title = $_POST['form_note_type'];
181 $reply_to = $_POST['reply_to'];
183 case "edit" : {
184 if ($noteid == "") {
185 $noteid = $_GET['noteid'];
187 // Update the message if it already exists; it's appended to an existing note in Patient Notes.
188 $result = getPnoteById($noteid);
189 if ($result) {
190 if ($title == ""){
191 $title = $result['title'];
193 $body = $result['body'];
194 if ($reply_to == ""){
195 $reply_to = $result['pid'];
197 $form_message_status = $result['message_status'];
199 } break;
200 case "delete" : {
201 // Delete selected message(s) from the Messages box (only).
202 $delete_id = $_POST['delete_id'];
203 for($i = 0; $i < count($delete_id); $i++) {
204 deletePnote($delete_id[$i]);
205 newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "pnotes: id ".$delete_id[$i]);
207 } break;
210 if($task == "addnew" or $task == "edit") {
211 // Display the Messages page layout.
212 echo "
213 <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>
214 <input type=hidden name=noteid id=noteid value='".attr($noteid)."'>
215 <input type=hidden name=task id=task value=add>";
217 <div id="pnotes"><center>
218 <table border='0' cellspacing='8'>
219 <tr>
220 <td class='text'>
221 <b><?php echo htmlspecialchars( xl('Type'), ENT_NOQUOTES); ?>:</b>
222 <?php
223 if ($title == "") {
224 $title = "Unassigned";
226 // Added 6/2009 by BM to incorporate the patient notes into the list_options listings.
227 generate_form_field(array('data_type'=>1,'field_id'=>'note_type','list_id'=>'note_type','empty_title'=>'SKIP','order_by'=>'title'), $title);
229 &nbsp; &nbsp;
230 <?php if ($task != "addnew" && $result['pid'] != 0) { ?>
231 <a class="patLink" onclick="goPid('<?php echo attr($result['pid']);?>')"><?php echo htmlspecialchars( xl('Patient'), ENT_NOQUOTES); ?>:</a>
232 <?php } else { ?>
233 <b class='<?php echo ($task=="addnew"?"required":"") ?>'><?php echo htmlspecialchars( xl('Patient'), ENT_NOQUOTES); ?>:</b>
234 <?php
236 if ($reply_to) {
237 $prow = sqlQuery("SELECT lname, fname,pid, pubpid, DOB " .
238 "FROM patient_data WHERE pid = ?", array($reply_to) );
239 $patientname = $prow['lname'] . ", " . $prow['fname'];
241 if ($patientname == '') {
242 $patientname = xl('Click to select');
243 } ?>
244 <input type='text' size='10' name='form_patient' style='width:150px;<?php
245 echo ($task=="addnew"?"cursor:pointer;cursor:hand;":"") ?>' value='<?php
246 echo htmlspecialchars($patientname, ENT_QUOTES); ?>' <?php
247 echo (($task=="addnew" || $result['pid']==0) ? "onclick='sel_patient()' readonly":"disabled") ?> title='<?php
248 echo ($task=="addnew"?(htmlspecialchars( xl('Click to select patient'), ENT_QUOTES)):"") ?>' />
249 <input type='hidden' name='reply_to' id='reply_to' value='<?php echo htmlspecialchars( $reply_to, ENT_QUOTES) ?>' />
250 &nbsp; &nbsp;
251 <b><?php echo htmlspecialchars( xl('Status'), ENT_NOQUOTES); ?>:</b>
252 <?php
253 if ($form_message_status == "") {
254 $form_message_status = 'New';
256 generate_form_field(array('data_type'=>1,'field_id'=>'message_status','list_id'=>'message_status','empty_title'=>'SKIP','order_by'=>'title'), $form_message_status); ?>
257 </td>
258 </tr>
259 <tr>
260 <td class='text'>
261 <b><?php echo htmlspecialchars( xl('To'), ENT_QUOTES); ?>:</b>
262 <input type='textbox' name='assigned_to_text' id='assigned_to_text' size='40' readonly='readonly'
263 value='<?php echo htmlspecialchars(xl("Select Users From The Dropdown List"), ENT_QUOTES)?>' >
264 <input type='hidden' name='assigned_to' id='assigned_to' >
265 <select name='users' id='users' onchange='addtolist(this);' >
266 <?php
267 echo "<option value='" . htmlspecialchars( '--', ENT_QUOTES) . "'";
268 echo ">" . htmlspecialchars( xl('Select User'), ENT_NOQUOTES);
269 echo "</option>\n";
270 $ures = sqlStatement("SELECT username, fname, lname FROM users " .
271 "WHERE username != '' AND active = 1 AND " .
272 "( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
273 "ORDER BY lname, fname");
274 while ($urow = sqlFetchArray($ures)) {
275 echo " <option value='" . htmlspecialchars( $urow['username'], ENT_QUOTES) . "'";
276 echo ">" . htmlspecialchars( $urow['lname'], ENT_NOQUOTES);
277 if ($urow['fname']) echo ", " . htmlspecialchars( $urow['fname'], ENT_NOQUOTES);
278 echo "</option>\n";
280 echo "<option value='" . htmlspecialchars( '-patient-', ENT_QUOTES) . "'";
281 echo ">" . htmlspecialchars( '-Patient-', ENT_NOQUOTES);
282 echo "</option>\n";
284 </select>
285 </td>
286 </tr>
288 <?php
289 if ($noteid) {
290 // Get the related document IDs if any.
291 $tmp = sqlStatement("SELECT id1 FROM gprelations WHERE " .
292 "type1 = ? AND type2 = ? AND id2 = ?",
293 array('1', '6', $noteid));
294 if (sqlNumRows($tmp)) {
295 echo " <tr>\n";
296 echo " <td class='text'><b>";
297 echo xlt('Linked document') . ":</b>\n";
298 while ($gprow = sqlFetchArray($tmp)) {
299 $d = new Document($gprow['id1']);
300 $enc_list = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe ".
301 " 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']));
302 $str_dob = htmlspecialchars(xl("DOB") . ":" . $prow['DOB'] . " " . xl("Age") . ":" . getPatientAge($prow['DOB']));
303 $pname = $prow['fname']." ".$prow['lname'];
304 echo "<a href='javascript:void(0);' ";
305 echo "onClick=\"gotoReport(".addslashes(attr($d->get_id())).",'".addslashes(attr($pname))."',".addslashes(attr($prow['pid'])).",".addslashes(attr($prow['pubpid'])).",'".addslashes(attr($str_dob))."');\">";
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 function gotoReport(doc_id,pname,pid,pubpid,str_dob){
413 EncounterDateArray=new Array;
414 CalendarCategoryArray=new Array;
415 EncounterIdArray=new Array;
416 Count = 0;
417 <?php
418 if(isset($enc_list) && sqlNumRows($enc_list) >0 ){
419 while($row = sqlFetchArray($enc_list)){
421 EncounterIdArray[Count]='<?php echo attr($row['encounter']); ?>';
422 EncounterDateArray[Count]='<?php echo attr(oeFormatShortDate(date("Y-m-d", strtotime($row['date'])))); ?>';
423 CalendarCategoryArray[Count]='<?php echo attr(xl_appt_category($row['pc_catname'])); ?>';
424 Count++;
425 <?php
429 top.restoreSession();
430 $.ajax({
431 type:'get',
432 url:'<?php echo $GLOBALS['webroot']."/interface/patient_file/encounter/patient_encounter.php";?>',
433 data:{set_pid: pid},
434 async: false
436 parent.left_nav.setPatient(pname,pid,pubpid,'',str_dob);
437 parent.left_nav.setPatientEncounter(EncounterIdArray,EncounterDateArray,CalendarCategoryArray);
438 <?php if ($GLOBALS['new_tabs_layout']) { ?>
439 var docurl = '../controller.php?document&view' + "&patient_id=" + pid + "&document_id=" + doc_id + "&";
440 var paturl = 'patient_file/summary/demographics.php?pid=' + pid;
441 parent.left_nav.loadFrame('dem1', 'pat', paturl);
442 parent.left_nav.loadFrame('doc0', 'enc', docurl);
443 top.activateTabByName('enc',true);
444 <?php } else { ?>
445 var docurl = '<?php echo $GLOBALS['webroot'] . "/controller.php?document&view"; ?>' + "&patient_id=" + pid + "&document_id=" + doc_id + "&";
446 var paturl = '<?php echo $GLOBALS['webroot'] . "/interface/patient_file/summary/demographics.php?pid="; ?>' + pid;
447 var othername = (window.name == 'RTop') ? 'RBot' : 'RTop';
448 parent.frames[othername].location.href = paturl;
449 location.href = docurl;
450 <?php } ?>
452 // This is for callback by the find-patient popup.
453 function setpatient(pid, lname, fname, dob) {
454 var f = document.forms[0];
455 f.form_patient.value = lname + ', ' + fname;
456 f.reply_to.value = pid;
457 <?php if ($noteid) { ?>
458 //used when direct messaging service inserts a pnote with indeterminate patient
459 //to allow the user to assign the message to a patient.
460 top.restoreSession();
461 $("#task").val("savePatient");
462 $("#new_note").submit();
463 <?php } ?>
466 // This invokes the find-patient popup.
467 function sel_patient() {
468 dlgopen('../../main/calendar/find_patient_popup.php', '_blank', 500, 400);
471 function addtolist(sel){
472 var itemtext = document.getElementById('assigned_to_text');
473 var item = document.getElementById('assigned_to');
474 if(sel.value != '--'){
475 if(item.value){
476 if(item.value.indexOf(sel.value) == -1){
477 itemtext.value = itemtext.value +' ; '+ sel.options[sel.selectedIndex].text;
478 item.value = item.value +';'+ sel.value;
480 }else{
481 itemtext.value = sel.options[sel.selectedIndex].text;
482 item.value = sel.value;
487 </script><?php
489 else {
491 // This is for sorting the records.
492 $sort = array("users.lname", "patient_data.lname", "pnotes.title", "pnotes.date", "pnotes.message_status");
493 $sortby = (isset($_REQUEST['sortby']) && ($_REQUEST['sortby']!="")) ? $_REQUEST['sortby'] : $sort[0];
494 $sortorder = (isset($_REQUEST['sortorder']) && ($_REQUEST['sortorder']!="")) ? $_REQUEST['sortorder'] : "asc";
495 $begin = isset($_REQUEST['begin']) ? $_REQUEST['begin'] : 0;
497 for($i = 0; $i < count($sort); $i++) {
498 $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>";
500 for($i = 0; $i < count($sort); $i++) {
501 if($sortby == $sort[$i]) {
502 switch($sortorder) {
503 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;
504 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;
505 } break;
508 // Manage page numbering and display beneath the Messages table.
509 $listnumber = 25;
510 $total = getPnotesByUser($active,$show_all,$_SESSION['authUser'],true);
511 if($begin == "" or $begin == 0) {
512 $begin = 0;
514 $prev = $begin - $listnumber;
515 $next = $begin + $listnumber;
516 $start = $begin + 1;
517 $end = $listnumber + $start - 1;
518 if($end >= $total) {
519 $end = $total;
521 if($end < $start) {
522 $start = 0;
524 if($prev >= 0) {
525 $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>";
527 else {
528 $prevlink = "<<";
531 if($next < $total) {
532 $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>";
534 else {
535 $nextlink = ">>";
537 // Display the Messages table header.
538 echo "
539 <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;\">
540 <form name=MessageList action=\"messages.php?showall=".attr($showall)."&sortby=".attr($sortby)."&sortorder=".attr($sortorder)."&begin=".attr($begin)."&$activity_string_html\" method=post>
541 <input type=hidden name=task value=delete>
542 <tr height=\"24\" style=\"background:lightgrey\">
543 <td align=\"center\" width=\"25\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\"><input type=checkbox id=\"checkAll\" onclick=\"selectAll()\"></td>
544 <td width=\"20%\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
545 htmlspecialchars( xl('From'), ENT_NOQUOTES) . "</b> $sortlink[0]</td>
546 <td width=\"20%\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
547 htmlspecialchars( xl('Patient'), ENT_NOQUOTES) . "</b> $sortlink[1]</td>
548 <td style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
549 htmlspecialchars( xl('Type'), ENT_NOQUOTES) . "</b> $sortlink[2]</td>
550 <td width=\"15%\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
551 htmlspecialchars( xl('Date'), ENT_NOQUOTES) . "</b> $sortlink[3]</td>
552 <td width=\"15%\" style=\"border-bottom: 1px #000000 solid; \" class=bold>&nbsp;<b>" .
553 htmlspecialchars( xl('Status'), ENT_NOQUOTES) . "</b> $sortlink[4]</td>
554 </tr>";
555 // Display the Messages table body.
556 $count = 0;
557 $result = getPnotesByUser($active,$show_all,$_SESSION['authUser'],false,$sortby,$sortorder,$begin,$listnumber);
558 while ($myrow = sqlFetchArray($result)) {
559 $name = $myrow['user'];
560 $name = $myrow['users_lname'];
561 if ($myrow['users_fname']) {
562 $name .= ", " . $myrow['users_fname'];
564 $patient = $myrow['pid'];
565 if ($patient>0) {
566 $patient = $myrow['patient_data_lname'];
567 if ($myrow['patient_data_fname']) {
568 $patient .= ", " . $myrow['patient_data_fname'];
570 } else {
571 $patient = "* Patient must be set manually *";
573 $count++;
574 echo "
575 <tr id=\"row$count\" style=\"background:white\" height=\"24\">
576 <td align=\"center\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\"><input type=checkbox id=\"check$count\" name=\"delete_id[]\" value=\"" .
577 htmlspecialchars( $myrow['id'], ENT_QUOTES) . "\" onclick=\"if(this.checked==true){ selectRow('row$count'); }else{ deselectRow('row$count'); }\"></td>
578 <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\">" .
579 htmlspecialchars( $name, ENT_NOQUOTES) . "</td><td width=5></td></tr></table></td>
580 <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=" .
581 htmlspecialchars( $myrow['id'], ENT_QUOTES) . "&$activity_string_html\" onclick=\"top.restoreSession()\">" .
582 htmlspecialchars( $patient, ENT_NOQUOTES) . "</a></td><td width=5></td></tr></table></td>
583 <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\">" .
584 htmlspecialchars( $myrow['title'], ENT_NOQUOTES) . "</td><td width=5></td></tr></table></td>
585 <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\">" .
586 htmlspecialchars( oeFormatShortDate(substr($myrow['date'], 0, strpos($myrow['date'], " "))), ENT_NOQUOTES) . "</td><td width=5></td></tr></table></td>
587 <td style=\"border-bottom: 1px #000000 solid;\"><table cellspacing=0 cellpadding=0 width=100%><tr><td width=5></td><td class=\"text\">" .
588 htmlspecialchars( $myrow['message_status'], ENT_NOQUOTES) . "</td><td width=5></td></tr></table></td>
589 </tr>";
591 // Display the Messages table footer.
592 echo "
593 </form></table>
594 <table border=0 cellpadding=5 cellspacing=0 width=90%>
595 <tr>
596 <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()\">" .
597 htmlspecialchars( xl('Add New'), ENT_NOQUOTES) . "</a> &nbsp; <a href=\"javascript:confirmDeleteSelected()\" onclick=\"top.restoreSession()\">" .
598 htmlspecialchars( xl('Delete'), ENT_NOQUOTES) . "</a></td>
599 <td align=right class=\"text amount-msg\">$prevlink &nbsp; $end of $total &nbsp; $nextlink</td>
600 </tr>
601 </table></td></tr></table><br>";
603 <script language="javascript">
604 // This is to confirm delete action.
605 function confirmDeleteSelected() {
606 if(confirm("<?php echo htmlspecialchars( xl('Do you really want to delete the selection?'), ENT_QUOTES); ?>")) {
607 document.MessageList.submit();
610 // This is to allow selection of all items in Messages table for deletion.
611 function selectAll() {
612 if(document.getElementById("checkAll").checked==true) {
613 document.getElementById("checkAll").checked=true;<?php
614 for($i = 1; $i <= $count; $i++) {
615 echo "document.getElementById(\"check$i\").checked=true; document.getElementById(\"row$i\").style.background='#E7E7E7'; ";
616 } ?>
618 else {
619 document.getElementById("checkAll").checked=false;<?php
620 for($i = 1; $i <= $count; $i++) {
621 echo "document.getElementById(\"check$i\").checked=false; document.getElementById(\"row$i\").style.background='#F7F7F7'; ";
622 } ?>
625 // The two functions below are for managing row styles in Messages table.
626 function selectRow(row) {
627 document.getElementById(row).style.background = "#E7E7E7";
629 function deselectRow(row) {
630 document.getElementById(row).style.background = "#F7F7F7";
632 </script><?php
636 </body>
637 </html>