Translation fixes (#836)
[openemr.git] / interface / main / messages / messages.php
blob9c8eb4150c371bee8c103f1de18a5333ec55702e
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.g.miller@gmail.com>
27 * @link http://www.open-emr.org
32 require_once("../../globals.php");
33 require_once("$srcdir/pnotes.inc");
34 require_once("$srcdir/patient.inc");
35 require_once("$srcdir/acl.inc");
36 require_once("$srcdir/log.inc");
37 require_once("$srcdir/options.inc.php");
38 require_once("$srcdir/gprelations.inc.php");
40 <html>
41 <head>
43 <?php html_header_show();?>
44 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
45 <script type="text/javascript" src="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
46 <script type="text/javascript" src="../../../library/textformat.js"></script>
47 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js"></script>
48 </head>
50 <body class="body_top">
52 <span class="title"><?php echo xlt('Message and Reminder Center'); ?></span>
53 <br /><br />
54 <span class="title"><?php echo xlt('Reminders'); ?></span>
56 <?php
58 // TajEmo Work by CB 2012/01/11 02:51:25 PM adding dated reminders
59 // I am asuming that at this point security checks have been performed
60 require_once '../dated_reminders/dated_reminders.php';
62 // Check to see if the user has Admin rights, and if so, allow access to See All.
63 $showall = isset($_GET['show_all']) ? $_GET['show_all'] : "" ;
64 if ($showall == "yes") {
65 $show_all = $showall;
67 else
69 $show_all= "no";
72 // Collect active variable and applicable html code for links
73 $form_active = (isset($_REQUEST['form_active']) ? $_REQUEST['form_active'] : FALSE);
74 $form_inactive = (isset($_REQUEST['form_inactive']) ? $_REQUEST['form_inactive'] : FALSE);
75 if ($form_active) {
76 $active = '1';
77 $activity_string_html = 'form_active=1';
79 else if ($form_inactive) {
80 $active = '0';
81 $activity_string_html = 'form_inactive=1';
83 else {
84 $active = 'all';
85 $activity_string_html = '';
88 //collect the task setting
89 $task= isset($_REQUEST['task']) ? $_REQUEST['task'] : "";
91 if (acl_check('admin', 'super' )) {
92 if ($show_all=='yes') {
93 $showall = "yes";
94 $lnkvar="\"messages.php?show_all=no&$activity_string_html\" name='Just Mine' onclick=\"top.restoreSession()\"> (".htmlspecialchars( xl('Just Mine'), ENT_NOQUOTES).")";
96 else {
97 $showall = "no";
98 $lnkvar="\"messages.php?show_all=yes&$activity_string_html\" name='See All' onclick=\"top.restoreSession()\">(".htmlspecialchars( xl('See All'), ENT_NOQUOTES).")";
102 <br>
103 <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>
104 <?php
105 //show the activity links
106 if (empty($task) || $task=="add" || $task=="delete") { ?>
107 <?php if ($active == "all") { ?>
108 <span><?php echo xlt('Show All'); ?></span>
109 <?php } else { ?>
110 <a href="messages.php" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show All'); ?></span></a>
111 <?php } ?>
113 <?php if ($active == '1') { ?>
114 <span><?php echo xlt('Show Active'); ?></span>
115 <?php } else { ?>
116 <a href="messages.php?form_active=1" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show Active'); ?></span></a>
117 <?php } ?>
119 <?php if ($active == '0') { ?>
120 <span><?php echo xlt('Show Inactive'); ?></span>
121 <?php } else { ?>
122 <a href="messages.php?form_inactive=1" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show Inactive'); ?></span></a>
123 <?php } ?>
124 <?php } ?>
126 <?php
127 switch($task) {
128 case "add" :
130 // Add a new message for a specific patient; the message is documented in Patient Notes.
131 // Add a new message; it's treated as a new note in Patient Notes.
132 $note = $_POST['note'];
133 $noteid = $_POST['noteid'];
134 $form_note_type = $_POST['form_note_type'];
135 $form_message_status = $_POST['form_message_status'];
136 $reply_to = $_POST['reply_to'];
137 $assigned_to_list = explode(';', $_POST['assigned_to']);
138 foreach($assigned_to_list as $assigned_to){
139 if ($noteid && $assigned_to != '-patient-') {
140 updatePnote($noteid, $note, $form_note_type, $assigned_to, $form_message_status);
141 $noteid = '';
143 else {
144 if($noteid && $assigned_to == '-patient-'){
145 // When $assigned_to == '-patient-' we don't update the current note, but
146 // instead create a new one with the current note's body prepended and
147 // attributed to the patient. This seems to be all for the patient portal.
148 $row = getPnoteById($noteid);
149 if (! $row) die("getPnoteById() did not find id '".text($noteid)."'");
150 $pres = sqlQuery("SELECT lname, fname " .
151 "FROM patient_data WHERE pid = ?", array($reply_to) );
152 $patientname = $pres['lname'] . ", " . $pres['fname'];
153 $note .= "\n\n$patientname on ".$row['date']." wrote:\n\n";
154 $note .= $row['body'];
156 // There's no note ID, and/or it's assigned to the patient.
157 // In these cases a new note is created.
158 addPnote($reply_to, $note, $userauthorized, '1', $form_note_type, $assigned_to, '', $form_message_status);
161 } break;
162 case "savePatient":
163 case "save" : {
164 // Update alert.
165 $noteid = $_POST['noteid'];
166 $form_message_status = $_POST['form_message_status'];
167 $reply_to = $_POST['reply_to'];
168 if ($task=="save")
169 updatePnoteMessageStatus($noteid,$form_message_status);
170 else
171 updatePnotePatient($noteid,$reply_to);
172 $task = "edit";
173 $note = $_POST['note'];
174 $title = $_POST['form_note_type'];
175 $reply_to = $_POST['reply_to'];
177 case "edit" : {
178 if ($noteid == "") {
179 $noteid = $_GET['noteid'];
181 // Update the message if it already exists; it's appended to an existing note in Patient Notes.
182 $result = getPnoteById($noteid);
183 if ($result) {
184 if ($title == ""){
185 $title = $result['title'];
187 $body = $result['body'];
188 if ($reply_to == ""){
189 $reply_to = $result['pid'];
191 $form_message_status = $result['message_status'];
193 } break;
194 case "delete" : {
195 // Delete selected message(s) from the Messages box (only).
196 $delete_id = $_POST['delete_id'];
197 for($i = 0; $i < count($delete_id); $i++) {
198 deletePnote($delete_id[$i]);
199 newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "pnotes: id ".$delete_id[$i]);
201 } break;
204 if($task == "addnew" or $task == "edit") {
205 // Display the Messages page layout.
206 echo "
207 <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>
208 <input type=hidden name=noteid id=noteid value='".attr($noteid)."'>
209 <input type=hidden name=task id=task value=add>";
211 <div id="pnotes"><center>
212 <table border='0' cellspacing='8'>
213 <tr>
214 <td class='text'>
215 <b><?php echo htmlspecialchars( xl('Type'), ENT_NOQUOTES); ?>:</b>
216 <?php
217 if ($title == "") {
218 $title = "Unassigned";
220 // Added 6/2009 by BM to incorporate the patient notes into the list_options listings.
221 generate_form_field(array('data_type'=>1,'field_id'=>'note_type','list_id'=>'note_type','empty_title'=>'SKIP','order_by'=>'title'), $title);
223 &nbsp; &nbsp;
224 <?php if ($task != "addnew" && $result['pid'] != 0) { ?>
225 <a class="patLink" onclick="goPid('<?php echo attr($result['pid']);?>')"><?php echo htmlspecialchars( xl('Patient'), ENT_NOQUOTES); ?>:</a>
226 <?php } else { ?>
227 <b class='<?php echo ($task=="addnew"?"required":"") ?>'><?php echo htmlspecialchars( xl('Patient'), ENT_NOQUOTES); ?>:</b>
228 <?php
230 if ($reply_to) {
231 $prow = sqlQuery("SELECT lname, fname,pid, pubpid, DOB " .
232 "FROM patient_data WHERE pid = ?", array($reply_to) );
233 $patientname = $prow['lname'] . ", " . $prow['fname'];
235 if ($patientname == '') {
236 $patientname = xl('Click to select');
237 } ?>
238 <input type='text' size='10' name='form_patient' style='width:150px;<?php
239 echo ($task=="addnew"?"cursor:pointer;cursor:hand;":"") ?>' value='<?php
240 echo htmlspecialchars($patientname, ENT_QUOTES); ?>' <?php
241 echo (($task=="addnew" || $result['pid']==0) ? "onclick='sel_patient()' readonly":"disabled") ?> title='<?php
242 echo ($task=="addnew"?(htmlspecialchars( xl('Click to select patient'), ENT_QUOTES)):"") ?>' />
243 <input type='hidden' name='reply_to' id='reply_to' value='<?php echo htmlspecialchars( $reply_to, ENT_QUOTES) ?>' />
244 &nbsp; &nbsp;
245 <b><?php echo htmlspecialchars( xl('Status'), ENT_NOQUOTES); ?>:</b>
246 <?php
247 if ($form_message_status == "") {
248 $form_message_status = 'New';
250 generate_form_field(array('data_type'=>1,'field_id'=>'message_status','list_id'=>'message_status','empty_title'=>'SKIP','order_by'=>'title'), $form_message_status); ?>
251 </td>
252 </tr>
253 <tr>
254 <td class='text'>
255 <b><?php echo htmlspecialchars( xl('To'), ENT_QUOTES); ?>:</b>
256 <input type='textbox' name='assigned_to_text' id='assigned_to_text' size='40' readonly='readonly'
257 value='<?php echo htmlspecialchars(xl("Select Users From The Dropdown List"), ENT_QUOTES)?>' >
258 <input type='hidden' name='assigned_to' id='assigned_to' >
259 <select name='users' id='users' onchange='addtolist(this);' >
260 <?php
261 echo "<option value='" . htmlspecialchars( '--', ENT_QUOTES) . "'";
262 echo ">" . htmlspecialchars( xl('Select User'), ENT_NOQUOTES);
263 echo "</option>\n";
264 $ures = sqlStatement("SELECT username, fname, lname FROM users " .
265 "WHERE username != '' AND active = 1 AND " .
266 "( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
267 "ORDER BY lname, fname");
268 while ($urow = sqlFetchArray($ures)) {
269 echo " <option value='" . htmlspecialchars( $urow['username'], ENT_QUOTES) . "'";
270 echo ">" . htmlspecialchars( $urow['lname'], ENT_NOQUOTES);
271 if ($urow['fname']) echo ", " . htmlspecialchars( $urow['fname'], ENT_NOQUOTES);
272 echo "</option>\n";
274 if($GLOBALS['portal_offsite_enable']){
275 echo "<option value='" . htmlspecialchars( '-patient-', ENT_QUOTES) . "'";
276 echo ">" . htmlspecialchars( '-Patient-', ENT_NOQUOTES);
277 echo "</option>\n";
280 </select>
281 </td>
282 </tr>
284 <?php
285 if ($noteid) {
286 // Get the related document IDs if any.
287 $tmp = sqlStatement("SELECT id1 FROM gprelations WHERE " .
288 "type1 = ? AND type2 = ? AND id2 = ?",
289 array('1', '6', $noteid));
290 if (sqlNumRows($tmp)) {
291 echo " <tr>\n";
292 echo " <td class='text'><b>";
293 echo xlt('Linked document') . ":</b>\n";
294 while ($gprow = sqlFetchArray($tmp)) {
295 $d = new Document($gprow['id1']);
296 $enc_list = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe ".
297 " 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']));
298 $str_dob = htmlspecialchars(xl("DOB") . ":" . $prow['DOB'] . " " . xl("Age") . ":" . getPatientAge($prow['DOB']));
299 $pname = $prow['fname']." ".$prow['lname'];
300 echo "<a href='javascript:void(0);' ";
301 echo "onClick=\"gotoReport(".addslashes(attr($d->get_id())).",'".addslashes(attr($pname))."',".addslashes(attr($prow['pid'])).",".addslashes(attr($prow['pubpid'])).",'".addslashes(attr($str_dob))."');\">";
302 echo text($d->get_url_file());
303 echo "</a>\n";
305 echo " </td>\n";
306 echo " </tr>\n";
308 // Get the related procedure order IDs if any.
309 $tmp = sqlStatement("SELECT id1 FROM gprelations WHERE " .
310 "type1 = ? AND type2 = ? AND id2 = ?",
311 array('2', '6', $noteid));
312 if (sqlNumRows($tmp)) {
313 echo " <tr>\n";
314 echo " <td class='text'><b>";
315 echo xlt('Linked procedure order') . ":</b>\n";
316 while ($gprow = sqlFetchArray($tmp)) {
317 echo " <a href='";
318 echo $GLOBALS['webroot'] . "/interface/orders/single_order_results.php?orderid=";
319 echo $gprow['id1'];
320 echo "' target='_blank' onclick='top.restoreSession()'>";
321 echo $gprow['id1'];
322 echo "</a>\n";
324 echo " </td>\n";
325 echo " </tr>\n";
330 <tr>
331 <td>
333 <?php
335 if ($noteid) {
336 $body = preg_replace('/(:\d{2}\s\()'.$result['pid'].'(\sto\s)/','${1}'.$patientname.'${2}',$body);
337 $body = preg_replace('/(\d{4}-\d{2}-\d{2} \d{2}:\d{2}\s\([^)(]+\s)(to)(\s[^)(]+\))/','${1}'.xl('to').'${3}', $body);
338 $body = nl2br(htmlspecialchars( $body, ENT_NOQUOTES));
339 echo "<div class='text' style='background-color:white; color: gray; border:1px solid #999; padding: 5px; width: 640px;'>".$body."</div>";
343 <textarea name='note' id='note' rows='8' style="width: 660px; "><?php echo htmlspecialchars( $note, ENT_NOQUOTES) ?></textarea>
344 </td>
345 </tr>
346 </table>
348 <?php if ($noteid) { ?>
349 <!-- This is for displaying an existing note. -->
350 <input type="button" id="newnote" value="<?php echo htmlspecialchars( xl('Send message'), ENT_QUOTES); ?>">
351 <input type="button" id="printnote" value="<?php echo htmlspecialchars( xl('Print message'), ENT_QUOTES); ?>">
352 <input type="button" id="cancel" value="<?php echo htmlspecialchars( xl('Cancel'), ENT_QUOTES); ?>">
353 <?php } else { ?>
354 <!-- This is for displaying a new note. -->
355 <input type="button" id="newnote" value="<?php echo htmlspecialchars( xl('Send message'), ENT_QUOTES); ?>">
356 <input type="button" id="cancel" value="<?php echo htmlspecialchars( xl('Cancel'), ENT_QUOTES); ?>">
357 <?php }
360 <br>
361 </form></center></div>
362 <script language="javascript">
364 // jQuery stuff to make the page a little easier to use
366 $(document).ready(function(){
367 $("#newnote").click(function() { NewNote(); });
368 $("#printnote").click(function() { PrintNote(); });
369 obj = document.getElementById("form_message_status");
370 obj.onchange = function(){SaveNote();};
371 $("#cancel").click(function() { CancelNote(); });
372 $("#note").focus();
374 var NewNote = function () {
375 top.restoreSession();
376 if (document.forms[0].reply_to.value.length == 0 || document.forms[0].reply_to.value == '0') {
377 alert('<?php echo htmlspecialchars( xl('Please choose a patient'), ENT_QUOTES); ?>');
379 else if (document.forms[0].assigned_to.value.length == 0 &&
380 document.getElementById("form_message_status").value != 'Done')
382 alert('<?php echo addslashes(xl('Recipient required unless status is Done')); ?>');
384 else
386 $("#new_note").submit();
390 var PrintNote = function () {
391 top.restoreSession();
392 window.open('../../patient_file/summary/pnotes_print.php?noteid=<?php echo htmlspecialchars( $noteid, ENT_QUOTES); ?>', '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
395 var SaveNote = function () {
396 <?php if ($noteid) { ?>
397 top.restoreSession();
398 $("#task").val("save");
399 $("#new_note").submit();
400 <?php } ?>
403 var CancelNote = function () {
404 top.restoreSession();
405 $("#task").val("");
406 $("#new_note").submit();
409 function gotoReport(doc_id,pname,pid,pubpid,str_dob){
410 EncounterDateArray=new Array;
411 CalendarCategoryArray=new Array;
412 EncounterIdArray=new Array;
413 Count = 0;
414 <?php
415 if(isset($enc_list) && sqlNumRows($enc_list) >0 ){
416 while($row = sqlFetchArray($enc_list)){
418 EncounterIdArray[Count]='<?php echo attr($row['encounter']); ?>';
419 EncounterDateArray[Count]='<?php echo attr(oeFormatShortDate(date("Y-m-d", strtotime($row['date'])))); ?>';
420 CalendarCategoryArray[Count]='<?php echo attr(xl_appt_category($row['pc_catname'])); ?>';
421 Count++;
422 <?php
426 top.restoreSession();
427 $.ajax({
428 type:'get',
429 url:'<?php echo $GLOBALS['webroot']."/library/ajax/set_pt.php";?>',
430 data:{set_pid: pid},
431 async: false
433 parent.left_nav.setPatient(pname,pid,pubpid,'',str_dob);
434 parent.left_nav.setPatientEncounter(EncounterIdArray,EncounterDateArray,CalendarCategoryArray);
435 <?php if ($GLOBALS['new_tabs_layout']) { ?>
436 var docurl = '../controller.php?document&view' + "&patient_id=" + pid + "&document_id=" + doc_id + "&";
437 var paturl = 'patient_file/summary/demographics.php?pid=' + pid;
438 parent.left_nav.loadFrame('dem1', 'pat', paturl);
439 parent.left_nav.loadFrame('doc0', 'enc', docurl);
440 top.activateTabByName('enc',true);
441 <?php } else { ?>
442 var docurl = '<?php echo $GLOBALS['webroot'] . "/controller.php?document&view"; ?>' + "&patient_id=" + pid + "&document_id=" + doc_id + "&";
443 var paturl = '<?php echo $GLOBALS['webroot'] . "/interface/patient_file/summary/demographics.php?pid="; ?>' + pid;
444 var othername = (window.name == 'RTop') ? 'RBot' : 'RTop';
445 parent.frames[othername].location.href = paturl;
446 location.href = docurl;
447 <?php } ?>
449 // This is for callback by the find-patient popup.
450 function setpatient(pid, lname, fname, dob) {
451 var f = document.forms[0];
452 f.form_patient.value = lname + ', ' + fname;
453 f.reply_to.value = pid;
454 <?php if ($noteid) { ?>
455 //used when direct messaging service inserts a pnote with indeterminate patient
456 //to allow the user to assign the message to a patient.
457 top.restoreSession();
458 $("#task").val("savePatient");
459 $("#new_note").submit();
460 <?php } ?>
463 // This invokes the find-patient popup.
464 function sel_patient() {
465 dlgopen('../../main/calendar/find_patient_popup.php', '_blank', 500, 400);
468 function addtolist(sel){
469 var itemtext = document.getElementById('assigned_to_text');
470 var item = document.getElementById('assigned_to');
471 if(sel.value != '--'){
472 if(item.value){
473 if(item.value.indexOf(sel.value) == -1){
474 itemtext.value = itemtext.value +' ; '+ sel.options[sel.selectedIndex].text;
475 item.value = item.value +';'+ sel.value;
477 }else{
478 itemtext.value = sel.options[sel.selectedIndex].text;
479 item.value = sel.value;
484 </script><?php
486 else {
488 // This is for sorting the records.
489 $sort = array("users.lname", "patient_data.lname", "pnotes.title", "pnotes.date", "pnotes.message_status");
490 $sortby = (isset($_REQUEST['sortby']) && ($_REQUEST['sortby']!="")) ? $_REQUEST['sortby'] : $sort[0];
491 $sortorder = (isset($_REQUEST['sortorder']) && ($_REQUEST['sortorder']!="")) ? $_REQUEST['sortorder'] : "asc";
492 $begin = isset($_REQUEST['begin']) ? $_REQUEST['begin'] : 0;
494 for($i = 0; $i < count($sort); $i++) {
495 $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>";
497 for($i = 0; $i < count($sort); $i++) {
498 if($sortby == $sort[$i]) {
499 switch($sortorder) {
500 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;
501 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;
502 } break;
505 // Manage page numbering and display beneath the Messages table.
506 $listnumber = 25;
507 $total = getPnotesByUser($active,$show_all,$_SESSION['authUser'],true);
508 if($begin == "" or $begin == 0) {
509 $begin = 0;
511 $prev = $begin - $listnumber;
512 $next = $begin + $listnumber;
513 $start = $begin + 1;
514 $end = $listnumber + $start - 1;
515 if($end >= $total) {
516 $end = $total;
518 if($end < $start) {
519 $start = 0;
521 if($prev >= 0) {
522 $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>";
524 else {
525 $prevlink = "<<";
528 if($next < $total) {
529 $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>";
531 else {
532 $nextlink = ">>";
534 // Display the Messages table header.
535 echo "
536 <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;\">
537 <form name=MessageList action=\"messages.php?showall=".attr($showall)."&sortby=".attr($sortby)."&sortorder=".attr($sortorder)."&begin=".attr($begin)."&$activity_string_html\" method=post>
538 <input type=hidden name=task value=delete>
539 <tr height=\"24\" style=\"background:lightgrey\">
540 <td align=\"center\" width=\"25\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\"><input type=checkbox id=\"checkAll\" onclick=\"selectAll()\"></td>
541 <td width=\"20%\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
542 htmlspecialchars( xl('From'), ENT_NOQUOTES) . "</b> $sortlink[0]</td>
543 <td width=\"20%\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
544 htmlspecialchars( xl('Patient'), ENT_NOQUOTES) . "</b> $sortlink[1]</td>
545 <td style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
546 htmlspecialchars( xl('Type'), ENT_NOQUOTES) . "</b> $sortlink[2]</td>
547 <td width=\"15%\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
548 htmlspecialchars( xl('Date'), ENT_NOQUOTES) . "</b> $sortlink[3]</td>
549 <td width=\"15%\" style=\"border-bottom: 1px #000000 solid; \" class=bold>&nbsp;<b>" .
550 htmlspecialchars( xl('Status'), ENT_NOQUOTES) . "</b> $sortlink[4]</td>
551 </tr>";
552 // Display the Messages table body.
553 $count = 0;
554 $result = getPnotesByUser($active,$show_all,$_SESSION['authUser'],false,$sortby,$sortorder,$begin,$listnumber);
555 while ($myrow = sqlFetchArray($result)) {
556 $name = $myrow['user'];
557 $name = $myrow['users_lname'];
558 if ($myrow['users_fname']) {
559 $name .= ", " . $myrow['users_fname'];
561 $patient = $myrow['pid'];
562 if ($patient>0) {
563 $patient = $myrow['patient_data_lname'];
564 if ($myrow['patient_data_fname']) {
565 $patient .= ", " . $myrow['patient_data_fname'];
567 } else {
568 $patient = "* Patient must be set manually *";
570 $count++;
571 echo "
572 <tr id=\"row$count\" style=\"background:white\" height=\"24\">
573 <td align=\"center\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\"><input type=checkbox id=\"check$count\" name=\"delete_id[]\" value=\"" .
574 attr( $myrow['id']) . "\" onclick=\"if(this.checked==true){ selectRow('row$count'); }else{ deselectRow('row$count'); }\"></td>
575 <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\">" .
576 text( $name) . "</td><td width=5></td></tr></table></td>
577 <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=" .
578 attr( $myrow['id']) . "&$activity_string_html\" onclick=\"top.restoreSession()\">" .
579 text( $patient) . "</a></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\">" .
581 xlt( $myrow['title']) . "</td><td width=5></td></tr></table></td>
582 <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\">" .
583 text( oeFormatShortDate(substr($myrow['date'], 0, strpos($myrow['date'], " ")))) . "</td><td width=5></td></tr></table></td>
584 <td style=\"border-bottom: 1px #000000 solid;\"><table cellspacing=0 cellpadding=0 width=100%><tr><td width=5></td><td class=\"text\">" .
585 xlt( $myrow['message_status']) . "</td><td width=5></td></tr></table></td>
586 </tr>";
588 // Display the Messages table footer.
589 echo "
590 </form></table>
591 <table border=0 cellpadding=5 cellspacing=0 width=90%>
592 <tr>
593 <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()\">" .
594 htmlspecialchars( xl('Add New'), ENT_NOQUOTES) . "</a> &nbsp; <a href=\"javascript:confirmDeleteSelected()\" onclick=\"top.restoreSession()\">" .
595 htmlspecialchars( xl('Delete'), ENT_NOQUOTES) . "</a></td>
596 <td align=right class=\"text amount-msg\">$prevlink &nbsp; $end of $total &nbsp; $nextlink</td>
597 </tr>
598 </table></td></tr></table><br>";
600 <script language="javascript">
601 // This is to confirm delete action.
602 function confirmDeleteSelected() {
603 if(confirm("<?php echo htmlspecialchars( xl('Do you really want to delete the selection?'), ENT_QUOTES); ?>")) {
604 document.MessageList.submit();
607 // This is to allow selection of all items in Messages table for deletion.
608 function selectAll() {
609 if(document.getElementById("checkAll").checked==true) {
610 document.getElementById("checkAll").checked=true;<?php
611 for($i = 1; $i <= $count; $i++) {
612 echo "document.getElementById(\"check$i\").checked=true; document.getElementById(\"row$i\").style.background='#E7E7E7'; ";
613 } ?>
615 else {
616 document.getElementById("checkAll").checked=false;<?php
617 for($i = 1; $i <= $count; $i++) {
618 echo "document.getElementById(\"check$i\").checked=false; document.getElementById(\"row$i\").style.background='#F7F7F7'; ";
619 } ?>
622 // The two functions below are for managing row styles in Messages table.
623 function selectRow(row) {
624 document.getElementById(row).style.background = "#E7E7E7";
626 function deselectRow(row) {
627 document.getElementById(row).style.background = "#F7F7F7";
629 </script><?php
633 </body>
634 </html>