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
27 include_once("../../globals.php");
28 include_once("$srcdir/options.inc.php");
30 if (isset($_POST['mode'])) {
31 $currentUser = $_SESSION['authUserID'];
32 $created_time = date('Y-m-d H:i');
33 if ($_POST["amendment_id"] == "") {
35 $query = "INSERT INTO amendments SET
43 $sqlBindArray = array(
44 DateToYYYYMMDD($_POST['amendment_date']),
45 $_POST['form_amendment_by'],
46 $_POST['form_amendment_status'],
53 $amendment_id = sqlInsert($query, $sqlBindArray);
55 $amendment_id = $_POST['amendment_id'];
57 $query = "UPDATE amendments SET
64 WHERE amendment_id = ?";
65 $sqlBindArray = array(
66 DateToYYYYMMDD($_POST['amendment_date']),
67 $_POST['form_amendment_by'],
68 $_POST['form_amendment_status'],
72 $_POST['amendment_id']
74 sqlStatement($query, $sqlBindArray);
77 // Insert into amendments_history
78 $query = "INSERT INTO amendments_history SET
84 $sqlBindArray = array(
87 $_POST["form_amendment_status"],
91 sqlStatement($query, $sqlBindArray);
92 header("Location:add_edit_amendments.php?id=$amendment_id");
96 $amendment_id = ( $amendment_id ) ?
$amendment_id : $_REQUEST['id'];
98 $query = "SELECT * FROM amendments WHERE amendment_id = ? ";
99 $resultSet = sqlQuery($query, array($amendment_id));
100 $amendment_date = $resultSet['amendment_date'];
101 $amendment_status = $resultSet['amendment_status'];
102 $amendment_by = $resultSet['amendment_by'];
103 $amendment_desc = $resultSet['amendment_desc'];
105 $query = "SELECT * FROM amendments_history ah INNER JOIN users u ON ah.created_by = u.id WHERE amendment_id = ? ";
106 $resultSet = sqlStatement($query, array($amendment_id));
110 $haveAccess = acl_check('patients', 'trans');
111 $onlyRead = ( $haveAccess ) ?
0 : 1;
112 $onlyRead = ( $onlyRead ||
$amendment_status ) ?
1 : 0;
113 $customAttributes = ( $onlyRead ) ?
array("disabled" => "true") : null;
119 <?php
html_header_show();?
>
121 <!-- supporting javascript code
-->
122 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery/dist/jquery.min.js"></script
>
123 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js?v=<?php echo $v_js_includes; ?>"></script
>
124 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
125 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker/build/jquery.datetimepicker.full.min.js"></script
>
128 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
129 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker/build/jquery.datetimepicker.min.css">
136 background
-color
: white
;
139 border
-collapse
: collapse
;
142 border
: 1px solid
#000;
146 <script type
="text/javascript">
148 function formValidation() {
149 if ( $
("#amendment_date").val() == "" ) {
150 alert("<?php echo xls('Select Amendment Date'); ?>");
152 } else if ( $
("#form_amendment_by").val() == "" ) {
153 alert("<?php echo xls('Select Requested By'); ?>");
157 var statusText
= $
("#form_amendment_status option:selected").text();
158 $
("#note").val($
("#note").val() +
' ' + statusText
);
160 $
("#add_edit_amendments").submit();
163 $
(document
).ready(function() {
164 $
('.datepicker').datetimepicker({
165 <?php
$datetimepicker_timepicker = false; ?
>
166 <?php
$datetimepicker_showseconds = false; ?
>
167 <?php
$datetimepicker_formatInput = true; ?
>
168 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
169 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
177 <body
class="body_top">
179 <form action
="add_edit_amendments.php" name
="add_edit_amendments" id
="add_edit_amendments" method
="post" onsubmit
='return top.restoreSession()'>
184 <span
class="title"><?php
echo xlt('Amendments'); ?
></span
> 
;
186 <?php
if (! $onlyRead) { ?
>
188 <a href
=# onclick="formValidation()" class="css_button_small"><span><?php echo xlt('Save');?></span></a>
192 <a href
="list_amendments.php" class="css_button_small"><span
><?php
echo xlt('Back');?
></span
></a
>
198 <table border
=0 cellpadding
=1 cellspacing
=1>
200 <td
><span
class=text
><?php
echo xlt('Requested Date'); ?
></span
></td
>
202 <?php
if (! $onlyRead) { ?
>
203 <input type
='text' size
='10' class='datepicker' name
="amendment_date" id
="amendment_date"
204 value
='<?php echo $amendment_date ? htmlspecialchars(oeFormatShortDate($amendment_date), ENT_QUOTES) : oeFormatShortDate(); ?>'
207 <input type
='text' size
='10' name
="amendment_date" id
="amendment_date" readonly
208 value
='<?php echo $amendment_date ? htmlspecialchars(oeFormatShortDate($amendment_date), ENT_QUOTES) : oeFormatShortDate(); ?>'
215 <td
><span
class=text
><?php
echo xlt('Requested By'); ?
></span
></td
>
217 <?php
echo generate_select_list("form_amendment_by", "amendment_from", $amendment_by, 'Amendment Request By', ' ', '', '', '', $customAttributes); ?
>
222 <td
><span
class=text
><?php
echo xlt('Request Description'); ?
></span
></td
>
223 <td
><textarea
<?php
echo ( $onlyRead ) ?
"readonly" : ""; ?
> id
="desc" name
="desc" rows
="4" cols
="30"><?php
225 echo text($amendment_desc);
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
244 echo xlt('New amendment request');
249 <?php
if ($amendment_id) { ?
>
252 <span
class="title"><?php
echo xlt("History") ; ?
></span
>
254 <table border
="1" cellpadding
=3 cellspacing
=0 class="historytbl">
256 <!-- some columns are sortable
-->
257 <tr
class='text bold'>
258 <th align
="left" style
="width:15%"><?php
echo xlt('Date'); ?
></th
>
259 <th align
="left" style
="width:25%"><?php
echo xlt('By'); ?
></th
>
260 <th align
="left" style
="width:15%"><?php
echo xlt('Status'); ?
></th
>
261 <th align
="left"><?php
echo xlt('Comments'); ?
></th
>
265 if (sqlNumRows($resultSet)) {
266 while ($row = sqlFetchArray($resultSet)) {
267 $created_date = date('Y-m-d', strtotime($row['created_time']));
269 $userName = $row['lname'] . ", " . $row['fname'];
270 echo "<td align=left class=text>" . text(oeFormatShortDate($created_date)) . "</td>";
271 echo "<td align=left class=text>" . text($userName) . "</td>";
272 echo "<td align=left class=text>" . ( ( $row['amendment_status'] ) ?
generate_display_field(array('data_type'=>'1','list_id'=>'amendment_status'), $row['amendment_status']) : '') . "</td>";
273 echo "<td align=left class=text>" . text($row['amendment_note']) . "</td>";
281 <input type
="hidden" id
="mode" name
="mode" value
=""/>
282 <input type
="hidden" id
="amendment_id" name
="amendment_id" value
="<?php echo attr($amendment_id); ?>"/>