5 * Copyright (C) 2014 Ensoftek
6 * Copyright (C) 2017 Brady Miller <brady.g.miller@gmail.com>
8 * LICENSE: This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 3
11 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
20 * @author Hema Bandaru <hemab@drcloudemr.com>
21 * @author Brady Miller <brady.g.miller@gmail.com>
22 * @link http://www.open-emr.org
25 //SANITIZE ALL ESCAPES
26 $sanitize_all_escapes=true;
29 //STOP FAKE REGISTER GLOBALS
30 $fake_register_globals=false;
33 include_once("../../globals.php");
34 include_once("$srcdir/options.inc.php");
36 if ( isset($_POST['mode'] )) {
37 $currentUser = $_SESSION['authUserID'];
38 $created_time = date('Y-m-d H:i');
39 if ( $_POST["amendment_id"] == "" ) {
41 $query = "INSERT INTO amendments SET
49 $sqlBindArray = array(
50 DateToYYYYMMDD( $_POST['amendment_date']),
51 $_POST['form_amendment_by'],
52 $_POST['form_amendment_status'],
59 $amendment_id = sqlInsert($query,$sqlBindArray);
61 $amendment_id = $_POST['amendment_id'];
63 $query = "UPDATE amendments SET
70 WHERE amendment_id = ?";
71 $sqlBindArray = array(
72 DateToYYYYMMDD($_POST['amendment_date']),
73 $_POST['form_amendment_by'],
74 $_POST['form_amendment_status'],
78 $_POST['amendment_id']
80 sqlStatement($query,$sqlBindArray);
83 // Insert into amendments_history
84 $query = "INSERT INTO amendments_history SET
90 $sqlBindArray = array(
93 $_POST["form_amendment_status"],
97 sqlStatement($query,$sqlBindArray);
98 header("Location:add_edit_amendments.php?id=$amendment_id");
102 $amendment_id = ( $amendment_id ) ?
$amendment_id : $_REQUEST['id'];
103 if ( $amendment_id ) {
104 $query = "SELECT * FROM amendments WHERE amendment_id = ? ";
105 $resultSet = sqlQuery($query,array($amendment_id));
106 $amendment_date = $resultSet['amendment_date'];
107 $amendment_status = $resultSet['amendment_status'];
108 $amendment_by = $resultSet['amendment_by'];
109 $amendment_desc = $resultSet['amendment_desc'];
111 $query = "SELECT * FROM amendments_history ah INNER JOIN users u ON ah.created_by = u.id WHERE amendment_id = ? ";
112 $resultSet = sqlStatement($query,array($amendment_id));
115 $haveAccess = acl_check('patients', 'trans');
116 $onlyRead = ( $haveAccess ) ?
0 : 1;
117 $onlyRead = ( $onlyRead ||
$amendment_status ) ?
1 : 0;
118 $customAttributes = ( $onlyRead ) ?
array("disabled" => "true") : null;
124 <?php
html_header_show();?
>
126 <!-- supporting javascript code
-->
127 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script
>
128 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js?v=<?php echo $v_js_includes; ?>"></script
>
129 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
130 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script
>
133 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
134 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
141 background
-color
: white
;
144 border
-collapse
: collapse
;
147 border
: 1px solid
#000;
151 <script type
="text/javascript">
153 function formValidation() {
154 if ( $
("#amendment_date").val() == "" ) {
155 alert("<?php echo xls('Select Amendment Date'); ?>");
157 } else if ( $
("#form_amendment_by").val() == "" ) {
158 alert("<?php echo xls('Select Requested By'); ?>");
162 var statusText
= $
("#form_amendment_status option:selected").text();
163 $
("#note").val($
("#note").val() +
' ' + statusText
);
165 $
("#add_edit_amendments").submit();
168 $
(document
).ready(function() {
169 $
('.datepicker').datetimepicker({
170 <?php
$datetimepicker_timepicker = false; ?
>
171 <?php
$datetimepicker_formatInput = true; ?
>
172 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
173 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
181 <body
class="body_top">
183 <form action
="add_edit_amendments.php" name
="add_edit_amendments" id
="add_edit_amendments" method
="post" onsubmit
='return top.restoreSession()'>
188 <span
class="title"><?php
echo xlt('Amendments'); ?
></span
> 
;
190 <?php
if ( ! $onlyRead ) { ?
>
192 <a href
=# onclick="formValidation()" class="css_button_small"><span><?php echo xlt('Save');?></span></a>
196 <a href
="list_amendments.php" class="css_button_small"><span
><?php
echo xlt('Back');?
></span
></a
>
202 <table border
=0 cellpadding
=1 cellspacing
=1>
204 <td
><span
class=text
><?php
echo xlt('Requested Date'); ?
></span
></td
>
206 <?php
if ( ! $onlyRead ) { ?
>
207 <input type
='text' size
='10' class='datepicker' name
="amendment_date" id
="amendment_date"
208 value
='<?php echo $amendment_date ? htmlspecialchars( oeFormatShortDate($amendment_date), ENT_QUOTES) : oeFormatShortDate(); ?>'
211 <input type
='text' size
='10' name
="amendment_date" id
="amendment_date" readonly
212 value
='<?php echo $amendment_date ? htmlspecialchars( oeFormatShortDate($amendment_date), ENT_QUOTES) : oeFormatShortDate(); ?>'
219 <td
><span
class=text
><?php
echo xlt('Requested By'); ?
></span
></td
>
221 <?php
echo generate_select_list("form_amendment_by", "amendment_from", $amendment_by,'Amendment Request By',' ','','','',$customAttributes); ?
>
226 <td
><span
class=text
><?php
echo xlt('Request Description'); ?
></span
></td
>
227 <td
><textarea
<?php
echo ( $onlyRead ) ?
"readonly" : ""; ?
> id
="desc" name
="desc" rows
="4" cols
="30"><?php
228 if($amendment_id) { echo text($amendment_desc); }else{ echo ""; } ?
></textarea
></td
>
232 <td
><span
class=text
><?php
echo xlt('Request Status'); ?
></span
></td
>
234 <?php
echo generate_select_list("form_amendment_status", "amendment_status", $amendment_status,'Amendment Status',' ','','','',$customAttributes); ?
>
239 <td
><span
class=text
><?php
echo xlt('Comments'); ?
></span
></td
>
240 <td
><textarea
<?php
echo ( $onlyRead ) ?
"readonly" : ""; ?
> id
="note" name
="note" rows
="4" cols
="30"><?php
241 if($amendment_id) echo ""; else echo xlt('New amendment request'); ?
></textarea
></td
>
245 <?php
if ( $amendment_id ) { ?
>
248 <span
class="title"><?php
echo xlt("History") ; ?
></span
>
250 <table border
="1" cellpadding
=3 cellspacing
=0 class="historytbl">
252 <!-- some columns are sortable
-->
253 <tr
class='text bold'>
254 <th align
="left" style
="width:15%"><?php
echo xlt('Date'); ?
></th
>
255 <th align
="left" style
="width:25%"><?php
echo xlt('By'); ?
></th
>
256 <th align
="left" style
="width:15%"><?php
echo xlt('Status'); ?
></th
>
257 <th align
="left"><?php
echo xlt('Comments'); ?
></th
>
261 if (sqlNumRows($resultSet)) {
262 while ( $row = sqlFetchArray($resultSet) ) {
263 $created_date = date('Y-m-d', strtotime($row['created_time']));
265 $userName = $row['lname'] . ", " . $row['fname'];
266 echo "<td align=left class=text>" . oeFormatShortDate($created_date) . "</td>";
267 echo "<td align=left class=text>" . text($userName) . "</td>";
268 echo "<td align=left class=text>" . ( ( $row['amendment_status'] ) ?
generate_display_field(array('data_type'=>'1','list_id'=>'amendment_status'), $row['amendment_status']) : '') . "</td>";
269 echo "<td align=left class=text>" . text($row['amendment_note']) . "</td>";
277 <input type
="hidden" id
="mode" name
="mode" value
=""/>
278 <input type
="hidden" id
="amendment_id" name
="amendment_id" value
="<?php echo attr($amendment_id); ?>"/>