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>;.
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"] == "" ) {
40 $query = "INSERT INTO amendments SET
48 $sqlBindArray = array(
49 DateToYYYYMMDD( $_POST['amendment_date']),
50 $_POST['form_amendment_by'],
51 $_POST['form_amendment_status'],
58 $amendment_id = sqlInsert($query,$sqlBindArray);
60 $amendment_id = $_POST['amendment_id'];
62 $query = "UPDATE amendments SET
69 WHERE amendment_id = ?";
70 $sqlBindArray = array(
71 DateToYYYYMMDD($_POST['amendment_date']),
72 $_POST['form_amendment_by'],
73 $_POST['form_amendment_status'],
77 $_POST['amendment_id']
79 sqlStatement($query,$sqlBindArray);
82 // Insert into amendments_history
83 $query = "INSERT INTO amendments_history SET
89 $sqlBindArray = array(
92 $_POST["form_amendment_status"],
96 sqlStatement($query,$sqlBindArray);
97 header("Location:add_edit_amendments.php?id=$amendment_id");
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));
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;
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
>
131 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
138 background
-color
: white
;
141 border
-collapse
: collapse
;
144 border
: 1px solid
#000;
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'); ?>");
160 } else if ( $
("#form_amendment_by").val() == "" ) {
161 alert("<?php echo xls('Select Requested By'); ?>");
165 var statusText
= $
("#form_amendment_status option:selected").text();
166 $
("#note").val($
("#note").val() +
' ' + statusText
);
168 $
("#add_edit_amendments").submit();
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()'>
181 <span
class="title"><?php
echo xlt('Amendments'); ?
></span
> 
;
183 <?php
if ( ! $onlyRead ) { ?
>
185 <a href
=# onclick="formValidation()" class="css_button_small"><span><?php echo xlt('Save');?></span></a>
189 <a href
="list_amendments.php" class="css_button_small"><span
><?php
echo xlt('Back');?
></span
></a
>
195 <table border
=0 cellpadding
=1 cellspacing
=1>
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"});
213 <td
><span
class=text
><?php
echo xlt('Requested By'); ?
></span
></td
>
215 <?php
echo generate_select_list("form_amendment_by", "amendment_from", $amendment_by,'Amendment Request By',' ','','','',$customAttributes); ?
>
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
>
226 <td
><span
class=text
><?php
echo xlt('Request Status'); ?
></span
></td
>
228 <?php
echo generate_select_list("form_amendment_status", "amendment_status", $amendment_status,'Amendment Status',' ','','','',$customAttributes); ?
>
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
>
239 <?php
if ( $amendment_id ) { ?
>
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
>
255 if (sqlNumRows($resultSet)) {
256 while ( $row = sqlFetchArray($resultSet) ) {
257 $created_date = date('Y-m-d', strtotime($row['created_time']));
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>";
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); ?>"/>