more organization of autoloaded files (#424)
[openemr.git] / interface / patient_file / summary / add_edit_amendments.php
blob55442f417f9bd233171e7247c21906db5ebeb949
1 <?php
2 /**
3 * Add/Edit Amendments
5 * Copyright (C) 2014 Ensoftek
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
18 * @package OpenEMR
19 * @author Hema Bandaru <hemab@drcloudemr.com>
20 * @link http://www.open-emr.org
23 //SANITIZE ALL ESCAPES
24 $sanitize_all_escapes=true;
27 //STOP FAKE REGISTER GLOBALS
28 $fake_register_globals=false;
31 include_once("../../globals.php");
32 include_once("$srcdir/options.inc.php");
34 $DateFormat=DateFormatRead();
35 if ( isset($_POST['mode'] )) {
36 $currentUser = $_SESSION['authUserID'];
37 $created_time = date('Y-m-d H:i');
38 if ( $_POST["amendment_id"] == "" ) {
39 // New. Insert
40 $query = "INSERT INTO amendments SET
41 amendment_date = ?,
42 amendment_by = ?,
43 amendment_status = ?,
44 pid = ?,
45 amendment_desc = ?,
46 created_by = ?,
47 created_time = ?";
48 $sqlBindArray = array(
49 DateToYYYYMMDD( $_POST['amendment_date']),
50 $_POST['form_amendment_by'],
51 $_POST['form_amendment_status'],
52 $pid,
53 $_POST['desc'],
54 $currentUser,
55 $created_time
58 $amendment_id = sqlInsert($query,$sqlBindArray);
59 } else {
60 $amendment_id = $_POST['amendment_id'];
61 // Existing. Update
62 $query = "UPDATE amendments SET
63 amendment_date = ?,
64 amendment_by = ?,
65 amendment_status = ?,
66 amendment_desc = ?,
67 modified_by = ?,
68 modified_time = ?
69 WHERE amendment_id = ?";
70 $sqlBindArray = array(
71 DateToYYYYMMDD($_POST['amendment_date']),
72 $_POST['form_amendment_by'],
73 $_POST['form_amendment_status'],
74 $_POST['desc'],
75 $currentUser,
76 $created_time,
77 $_POST['amendment_id']
79 sqlStatement($query,$sqlBindArray);
82 // Insert into amendments_history
83 $query = "INSERT INTO amendments_history SET
84 amendment_id = ? ,
85 amendment_note = ?,
86 amendment_status = ?,
87 created_by = ?,
88 created_time = ?";
89 $sqlBindArray = array(
90 $amendment_id,
91 $_POST['note'],
92 $_POST["form_amendment_status"],
93 $currentUser,
94 $created_time
96 sqlStatement($query,$sqlBindArray);
97 header("Location:add_edit_amendments.php?id=$amendment_id");
98 exit;
101 $amendment_id = ( $amendment_id ) ? $amendment_id : $_REQUEST['id'];
102 if ( $amendment_id ) {
103 $query = "SELECT * FROM amendments WHERE amendment_id = ? ";
104 $resultSet = sqlQuery($query,array($amendment_id));
105 $amendment_date = $resultSet['amendment_date'];
106 $amendment_status = $resultSet['amendment_status'];
107 $amendment_by = $resultSet['amendment_by'];
108 $amendment_desc = $resultSet['amendment_desc'];
110 $query = "SELECT * FROM amendments_history ah INNER JOIN users u ON ah.created_by = u.id WHERE amendment_id = ? ";
111 $resultSet = sqlStatement($query,array($amendment_id));
113 // Check the ACL
114 $haveAccess = acl_check('patients', 'trans');
115 $onlyRead = ( $haveAccess ) ? 0 : 1;
116 $onlyRead = ( $onlyRead || $amendment_status ) ? 1 : 0;
117 $customAttributes = ( $onlyRead ) ? array("disabled" => "true") : null;
121 <html>
122 <head>
123 <?php html_header_show();?>
125 <!-- supporting javascript code -->
126 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-1/index.js"></script>
127 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js"></script>
128 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
130 <!-- page styles -->
131 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
133 <style>
134 .highlight {
135 color: green;
137 tr.selected {
138 background-color: white;
140 .historytbl {
141 border-collapse: collapse;
143 .historytbl td th{
144 border: 1px solid #000;
146 </style>
148 <!-- pop up calendar -->
149 <style type="text/css">@import url(<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.css);</style>
150 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.js"></script>
151 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
152 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar_setup.js"></script>
154 <script type="text/javascript">
156 function formValidation() {
157 if ( $("#amendment_date").val() == "" ) {
158 alert("<?php echo xls('Select Amendment Date'); ?>");
159 return;
160 } else if ( $("#form_amendment_by").val() == "" ) {
161 alert("<?php echo xls('Select Requested By'); ?>");
162 return;
165 var statusText = $("#form_amendment_status option:selected").text();
166 $("#note").val($("#note").val() + ' ' + statusText);
168 $("#add_edit_amendments").submit();
170 </script>
172 </head>
174 <body class="body_top">
176 <form action="add_edit_amendments.php" name="add_edit_amendments" id="add_edit_amendments" method="post" onsubmit='return top.restoreSession()'>
178 <table>
179 <tr>
180 <td>
181 <span class="title"><?php echo xlt('Amendments'); ?></span>&nbsp;
182 </td>
183 <?php if ( ! $onlyRead ) { ?>
184 <td>
185 <a href=# onclick="formValidation()" class="css_button_small"><span><?php echo xlt('Save');?></span></a>
186 </td>
187 <?php } ?>
188 <td>
189 <a href="list_amendments.php" class="css_button_small"><span><?php echo xlt('Back');?></span></a>
190 </td>
191 </tr>
192 </table>
194 <br>
195 <table border=0 cellpadding=1 cellspacing=1>
196 <tr>
197 <td><span class=text ><?php echo xlt('Requested Date'); ?></span></td>
198 <td ><input type='text' size='10' name="amendment_date" id="amendment_date" readonly
199 value='<?php echo $amendment_date ? htmlspecialchars( oeFormatShortDate($amendment_date), ENT_QUOTES) : oeFormatShortDate(); ?>'
201 <?php if ( ! $onlyRead ) { ?>
202 <img src='<?php echo $rootdir; ?>/pic/show_calendar.gif' width='24' height='22'
203 id='img_amendment_date' valign="middle" border='0' alt='[?]' style='cursor:pointer;cursor:hand'
204 title='<?php echo xlt('Click here to choose a date'); ?>'>
205 <script type="text/javascript">
206 Calendar.setup({inputField:"amendment_date", ifFormat:"<?php echo $DateFormat ?>", button:"img_amendment_date"});
207 </script>
208 <?php } ?>
209 </td>
210 </tr>
212 <tr>
213 <td><span class=text ><?php echo xlt('Requested By'); ?></span></td>
214 <td>
215 <?php echo generate_select_list("form_amendment_by", "amendment_from", $amendment_by,'Amendment Request By',' ','','','',$customAttributes); ?>
216 </td>
217 </tr>
219 <tr>
220 <td><span class=text ><?php echo xlt('Request Description'); ?></span></td>
221 <td><textarea <?php echo ( $onlyRead ) ? "readonly" : ""; ?> id="desc" name="desc" rows="4" cols="30"><?php
222 if($amendment_id) { echo text($amendment_desc); }else{ echo ""; } ?></textarea></td>
223 </tr>
225 <tr>
226 <td><span class=text ><?php echo xlt('Request Status'); ?></span></td>
227 <td>
228 <?php echo generate_select_list("form_amendment_status", "amendment_status", $amendment_status,'Amendment Status',' ','','','',$customAttributes); ?>
229 </td>
230 </tr>
232 <tr>
233 <td><span class=text ><?php echo xlt('Comments'); ?></span></td>
234 <td><textarea <?php echo ( $onlyRead ) ? "readonly" : ""; ?> id="note" name="note" rows="4" cols="30"><?php
235 if($amendment_id) echo ""; else echo xlt('New amendment request'); ?></textarea></td>
236 </tr>
237 </table>
239 <?php if ( $amendment_id ) { ?>
240 <hr>
242 <span class="title"><?php echo xlt("History") ; ?></span>
244 <table border="1" cellpadding=3 cellspacing=0 class="historytbl">
246 <!-- some columns are sortable -->
247 <tr class='text bold'>
248 <th align="left" style="width:15%"><?php echo xlt('Date'); ?></th>
249 <th align="left" style="width:25%"><?php echo xlt('By'); ?></th>
250 <th align="left" style="width:15%"><?php echo xlt('Status'); ?></th>
251 <th align="left"><?php echo xlt('Comments'); ?></th>
252 </tr>
254 <?php
255 if (sqlNumRows($resultSet)) {
256 while ( $row = sqlFetchArray($resultSet) ) {
257 $created_date = date('Y-m-d', strtotime($row['created_time']));
258 echo "<tr>";
259 $userName = $row['lname'] . ", " . $row['fname'];
260 echo "<td align=left class=text>" . oeFormatShortDate($created_date) . "</td>";
261 echo "<td align=left class=text>" . text($userName) . "</td>";
262 echo "<td align=left class=text>" . ( ( $row['amendment_status'] ) ? generate_display_field(array('data_type'=>'1','list_id'=>'amendment_status'), $row['amendment_status']) : '') . "</td>";
263 echo "<td align=left class=text>" . text($row['amendment_note']) . "</td>";
264 echo "<tr>";
268 </table>
269 <?php } ?>
271 <input type="hidden" id="mode" name="mode" value=""/>
272 <input type="hidden" id="amendment_id" name="amendment_id" value="<?php echo attr($amendment_id); ?>"/>
273 </form>
274 </body>
275 </html>