More session fixes
[openemr.git] / interface / main / onotes / office_comments_full.php
blob133d58644bbfa6cc3196390e2fc2de568ee6338e
1 <?php
2 /**
3 * Viewing and modification/creation of office notes.
5 * LICENSE: This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
16 * @package OpenEMR
17 * @author Brady Miller <brady@sparmy.com>
18 * @link http://www.open-emr.org
21 $fake_register_globals=false;
22 $sanitize_all_escapes=true;
24 include_once("../../globals.php");
25 include_once("$srcdir/onotes.inc");
27 //the number of records to display per screen
28 $N = 10;
30 $offset = (isset($_REQUEST['offset'])) ? $_REQUEST['offset'] : 0;
31 $active = (isset($_REQUEST['active'])) ? $_REQUEST['active'] : "all";
33 //this code handles changing the state of activity tags when the user updates them through the interface
34 if (isset($_POST['mode'])) {
35 if ($_POST['mode'] == "update") {
36 foreach ($_POST as $var => $val) {
37 if ($val == "true" || $val == "false") {
38 $id = str_replace("act","",$var);
39 if ($val == "true") {reappearOnote($id);}elseif($val=="false"){disappearOnote($id);};
42 } elseif ($_POST['mode'] == "new") {
43 addOnote($_POST["note"]);
47 <html>
48 <head>
50 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
52 </head>
53 <body class="body_top">
55 <div id="officenotes_edit">
57 <form method="post" name="new_note" action="office_comments_full.php" onsubmit='return top.restoreSession()'>
59 <?php
60 /* BACK should go to the main Office Notes screen */
61 if ($userauthorized) { $backurl="office_comments.php"; }
62 else { $backurl="../main_info.php"; }
65 <?php if ($GLOBALS['concurrent_layout']) { ?>
66 <a href="office_comments.php" onclick='top.restoreSession()'>
67 <?php } else { ?>
68 <a href="<?php echo $backurl; ?>" target="Main">
69 <?php } ?>
71 <span class="title"><?php echo xlt('Office Notes'); ?></span>
72 <span class="back"><?php echo text($tback); ?></span></a>
74 <br>
75 <input type="hidden" name="mode" value="new">
76 <input type="hidden" name="offset" value="<?php echo attr($offset); ?>">
77 <input type="hidden" name="active" value="<?php echo attr($active); ?>">
79 <textarea name="note" rows="6" cols="40" wrap="virtual"></textarea>
80 <br>
81 <a href="javascript:top.restoreSession();document.new_note.submit();" class="link_submit">[<?php echo xlt('Add New Note'); ?>]</a>
82 </form>
84 <br/>
86 <form method="post" name="update_activity" action="office_comments_full.php" onsubmit='return top.restoreSession()'>
88 <?php //change the view on the current mode, whether all, active, or inactive
89 $all_class="link"; $active_class="link"; $inactive_class="link";
90 if ($active=="all") { $all_class="link_selected"; }
91 elseif ($active==1) { $active_class="link_selected"; }
92 elseif ($active==0) { $inactive_class="link_selected"; }
95 <span class="text"><?php echo xlt('View:'); ?> </span>
96 <a href="office_comments_full.php?offset=0&active=all" class="<?php echo attr($all_class);?>" onclick='top.restoreSession()'>[<?php echo xlt('All'); ?>]</a>
97 <a href="office_comments_full.php?offset=0&active=1" class="<?php echo attr($active_class);?>" onclick='top.restoreSession()'>[<?php echo xlt('Only Active'); ?>]</a>
98 <a href="office_comments_full.php?offset=0&active=0" class="<?php echo attr($inactive_class);?>" onclick='top.restoreSession()'>[<?php echo xlt('Only Inactive'); ?>]</a>
100 <input type="hidden" name="mode" value="update">
101 <input type="hidden" name="offset" value="<?php echo attr($offset);?>">
102 <input type="hidden" name="active" value="<?php echo attr($active);?>">
103 <br/>
104 <a href="javascript:top.restoreSession();document.update_activity.submit();" class="link_submit">[<?php echo xlt('Change Activity'); ?>]</a>
106 <table border="0" class="existingnotes">
107 <?php
108 //display all of the notes for the day, as well as others that are active from previous dates, up to a certain number, $N
110 //retrieve all notes
111 if ($result = getOnoteByDate("", $active, "id,date,body,user,activity",$N,$offset)) {
112 $result_count = 0;
113 foreach ($result as $iter) {
114 $result_count++;
116 if (getdate() == strtotime($iter{"date"})) {
117 $date_string = "Today, " . date( "D F dS" ,strtotime($iter{"date"}));
118 } else {
119 $date_string = date( "D F dS" ,strtotime($iter{"date"}));
122 if ($iter{"activity"}) { $checked = "checked"; }
123 else { $checked = ""; }
125 print "<tr><td><input type=hidden value='' name='act".attr($iter{"id"})."' id='act".attr($iter{"id"})."'>";
126 print "<input name='box".attr($iter{"id"})."' id='box".attr($iter{"id"})."' onClick='javascript:document.update_activity.act".attr($iter{"id"}).".value=this.checked' type=checkbox $checked></td>";
127 print "<td><label for='box".attr($iter{"id"})."' class='bold'>".text($date_string) . "</label>";
128 print " <label for='box".attr($iter{"id"})."' class='bold'>(". text($iter{"user"}).")</label></td>";
129 print "<td><label for='box".attr($iter{"id"})."' class='text'>" . text($iter{"body"}) . "&nbsp;</label></td></tr>\n";
132 $notes_count++;
134 }else{
135 //no results
136 print "<tr><td></td><td></td><td></td></tr>\n";
140 </table>
142 <a href="javascript:top.restoreSession();document.update_activity.submit();" class="link_submit">[<?php echo xlt('Change Activity'); ?>]</a>
143 </form>
145 <hr>
146 <table width="400" border="0" cellpadding="0" cellspacing="0">
147 <tr><td>
148 <?php
149 if ($offset>($N-1)) {
150 echo "<a class='link' href=office_comments_full.php?active=".attr($active)."&offset=".attr($offset-$N)." onclick='top.restoreSession()'>[".xlt('Previous')."]</a>";
153 </td><td align=right>
154 <?php
155 if ($result_count == $N) {
156 echo "<a class='link' href=office_comments_full.php?active=".attr($active)."&offset=".attr($offset+$N)." onclick='top.restoreSession()'>[".xlt('Next')."]</a>";
159 </td></tr>
160 </table>
161 </div>
163 </body>
164 </html>