consolidate attr_url function (#2143)
[openemr.git] / interface / drugs / destroy_lot.php
blob7ebf41661b9db71c94a64c1a5051d939c120620a
1 <?php
2 /**
3 * destroy lot
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Rod Roark <rod@sunsetsystems.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2006 Rod Roark <rod@sunsetsystems.com>
10 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../globals.php");
16 require_once("$srcdir/acl.inc");
17 require_once("drugs.inc.php");
20 $drug_id = $_REQUEST['drug'];
21 $lot_id = $_REQUEST['lot'];
22 $info_msg = "";
24 if (!acl_check('admin', 'drugs')) {
25 die(xlt('Not authorized'));
28 if (!$drug_id) {
29 die(xlt('Drug ID missing!'));
32 if (!$lot_id) {
33 die(xlt('Lot ID missing!'));
36 <html>
37 <head>
38 <?php html_header_show();?>
39 <title><?php echo xlt('Destroy Lot') ?></title>
40 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
41 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker/build/jquery.datetimepicker.min.css">
43 <style>
44 td { font-size:10pt; }
45 </style>
47 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery/dist/jquery.min.js"></script>
48 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker/build/jquery.datetimepicker.full.min.js"></script>
49 <script type="text/javascript" src="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
52 <script language="JavaScript">
53 $(document).ready(function(){
54 $('.datepicker').datetimepicker({
55 <?php $datetimepicker_timepicker = false; ?>
56 <?php $datetimepicker_showseconds = false; ?>
57 <?php $datetimepicker_formatInput = false; ?>
58 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
59 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
60 });
61 });
62 </script>
64 </head>
66 <body class="body_top">
67 <?php
68 // If we are saving, then save and close the window.
70 if ($_POST['form_save']) {
71 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
72 csrfNotVerified();
75 sqlStatement(
76 "UPDATE drug_inventory SET " .
77 "destroy_date = ?, " .
78 "destroy_method = ?, " .
79 "destroy_witness = ?, " .
80 "destroy_notes = ? " .
81 "WHERE drug_id = ? AND inventory_id = ?",
82 array(
83 (empty($_POST['form_date']) ? "NULL" : $_POST['form_date']),
84 $_POST['form_method'],
85 $_POST['form_witness'],
86 $_POST['form_notes'],
87 $drug_id,
88 $lot_id
92 // Close this window and redisplay the updated list of drugs.
94 echo "<script language='JavaScript'>\n";
95 if ($info_msg) {
96 echo " alert('".addslashes($info_msg)."');\n";
99 echo " window.close();\n";
100 echo " if (opener.refreshme) opener.refreshme();\n";
101 echo "</script></body></html>\n";
102 exit();
105 $row = sqlQuery("SELECT * FROM drug_inventory WHERE drug_id = ? " .
106 "AND inventory_id = ?", array($drug_id,$lot_id));
109 <form method='post' name='theform' action='destroy_lot.php?drug=<?php echo attr_url($drug_id); ?>&lot=<?php echo attr_url($lot_id); ?>'>
110 <input type="hidden" name="csrf_token_form" value="<?php echo attr(collectCsrfToken()); ?>" />
112 <center>
114 <table border='0' width='100%'>
116 <tr>
117 <td valign='top' width='1%' nowrap><b><?php echo xlt('Lot Number'); ?>:</b></td>
118 <td>
119 <?php echo text($row['lot_number']) ?>
120 </td>
121 </tr>
123 <tr>
124 <td valign='top' nowrap><b><?php echo xlt('Manufacturer'); ?>:</b></td>
125 <td>
126 <?php echo text($row['manufacturer']) ?>
127 </td>
128 </tr>
130 <tr>
131 <td valign='top' nowrap><b><?php echo xlt('Quantity On Hand'); ?>:</b></td>
132 <td>
133 <?php echo text($row['on_hand']) ?>
134 </td>
135 </tr>
137 <tr>
138 <td valign='top' nowrap><b><?php echo xlt('Expiration Date'); ?>:</b></td>
139 <td>
140 <?php echo text($row['expiration']) ?>
141 </td>
142 </tr>
144 <tr>
145 <td valign='top' nowrap><b><?php echo xlt('Date Destroyed'); ?>:</b></td>
146 <td>
147 <input type='text' size='10' class='datepicker' name='form_date' id='form_date'
148 value='<?php echo $row['destroy_date'] ? attr($row['destroy_date']) : date("Y-m-d"); ?>'
149 title='<?php echo xla('yyyy-mm-dd date destroyed'); ?>' />
150 </td>
151 </tr>
153 <tr>
154 <td valign='top' nowrap><b><?php echo xlt('Method of Destruction'); ?>:</b></td>
155 <td>
156 <input type='text' size='40' name='form_method' maxlength='250'
157 value='<?php echo attr($row['destroy_method']) ?>' style='width:100%' />
158 </td>
159 </tr>
161 <tr>
162 <td valign='top' nowrap><b><?php echo xlt('Witness'); ?>:</b></td>
163 <td>
164 <input type='text' size='40' name='form_witness' maxlength='250'
165 value='<?php echo attr($row['destroy_witness']) ?>' style='width:100%' />
166 </td>
167 </tr>
169 <tr>
170 <td valign='top' nowrap><b><?php echo xlt('Notes'); ?>:</b></td>
171 <td>
172 <input type='text' size='40' name='form_notes' maxlength='250'
173 value='<?php echo attr($row['destroy_notes']) ?>' style='width:100%' />
174 </td>
175 </tr>
177 </table>
180 <input type='submit' name='form_save' value='<?php echo xla('Submit') ;?>' />
182 &nbsp;
183 <input type='button' value='<?php echo xla('Cancel'); ?>' onclick='window.close()' />
184 </p>
186 </center>
187 </form>
188 </body>
189 </html>