Improvements mostly concerning inventory.
[openemr.git] / interface / drugs / destroy_lot.php
bloba59082637adeeb58fe634f7eb83c389e1388b082
1 <?php
3 /**
4 * destroy lot
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2006-2021 Rod Roark <rod@sunsetsystems.com>
11 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../globals.php");
16 require_once("drugs.inc.php");
18 use OpenEMR\Common\Acl\AclMain;
19 use OpenEMR\Common\Csrf\CsrfUtils;
20 use OpenEMR\Core\Header;
22 $drug_id = $_REQUEST['drug'];
23 $lot_id = $_REQUEST['lot'];
24 $info_msg = "";
26 if (!AclMain::aclCheckCore('admin', 'drugs')) {
27 die(xlt('Not authorized'));
30 if (!$drug_id) {
31 die(xlt('Drug ID missing!'));
34 if (!$lot_id) {
35 die(xlt('Lot ID missing!'));
38 <html>
39 <head>
40 <title><?php echo xlt('Destroy Lot') ?></title>
42 <?php Header::setupHeader(['datetime-picker', 'opener']); ?>
44 <style>
45 td {
46 font-size: 0.8125rem;
48 </style>
50 <script>
51 $(function () {
52 $('.datepicker').datetimepicker({
53 <?php $datetimepicker_timepicker = false; ?>
54 <?php $datetimepicker_showseconds = false; ?>
55 <?php $datetimepicker_formatInput = false; ?>
56 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
57 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
58 });
59 });
61 function validate(f) {
62 if (!confirm(<?php echo xlj('Really destroy this lot?'); ?>)) {
63 return false;
65 top.restoreSession();
66 return true;
69 </script>
71 </head>
73 <body class="body_top">
74 <?php
75 // If we are saving, then save and close the window.
77 if ($_POST['form_save']) {
78 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
79 CsrfUtils::csrfNotVerified();
82 sqlStatement(
83 "UPDATE drug_inventory SET " .
84 "destroy_date = ?, " .
85 "destroy_method = ?, " .
86 "destroy_witness = ?, " .
87 "destroy_notes = ? " .
88 "WHERE drug_id = ? AND inventory_id = ?",
89 array(
90 (empty($_POST['form_date']) ? "NULL" : $_POST['form_date']),
91 $_POST['form_method'],
92 $_POST['form_witness'],
93 $_POST['form_notes'],
94 $drug_id,
95 $lot_id
99 // Close this window and redisplay the updated list of drugs.
101 echo "<script>\n";
102 if ($info_msg) {
103 echo " alert('" . addslashes($info_msg) . "');\n";
106 echo " window.close();\n";
107 echo " if (opener.refreshme) opener.refreshme();\n";
108 echo "</script></body></html>\n";
109 exit();
112 $row = sqlQuery("SELECT * FROM drug_inventory WHERE drug_id = ? " .
113 "AND inventory_id = ?", array($drug_id,$lot_id));
116 <form method='post' name='theform' onsubmit='return validate(this);'
117 action='destroy_lot.php?drug=<?php echo attr_url($drug_id) ?>&lot=<?php echo attr_url($lot_id) ?>'>
119 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
121 <center>
123 <table class='table-borderless w-100'>
125 <tr>
126 <td class="text-nowrap align-top font-weight-bold" width='1%'><?php echo xlt('Lot Number'); ?>:</td>
127 <td>
128 <?php echo text($row['lot_number']) ?>
129 </td>
130 </tr>
132 <tr>
133 <td class="text-nowrap align-top font-weight-bold"><?php echo xlt('Manufacturer'); ?>:</td>
134 <td>
135 <?php echo text($row['manufacturer']) ?>
136 </td>
137 </tr>
139 <tr>
140 <td class="text-nowrap align-top font-weight-bold"><?php echo xlt('Quantity On Hand'); ?>:</td>
141 <td>
142 <?php echo text($row['on_hand']) ?>
143 </td>
144 </tr>
146 <tr>
147 <td class="text-nowrap align-top font-weight-bold"><?php echo xlt('Expiration Date'); ?>:</td>
148 <td>
149 <?php echo text($row['expiration']) ?>
150 </td>
151 </tr>
153 <tr>
154 <td class="text-nowrap align-top font-weight-bold"><?php echo xlt('Date Destroyed'); ?>:</td>
155 <td>
156 <input type='text' size='10' class='datepicker' name='form_date' id='form_date' value='<?php echo $row['destroy_date'] ? attr($row['destroy_date']) : date("Y-m-d"); ?>' title='<?php echo xla('yyyy-mm-dd date destroyed'); ?>' />
157 </td>
158 </tr>
160 <tr>
161 <td class="text-nowrap align-top font-weight-bold"><?php echo xlt('Method of Destruction'); ?>:</td>
162 <td>
163 <input type='text' class='w-100' size='40' name='form_method' maxlength='250'
164 value='<?php echo attr($row['destroy_method']) ?>' />
165 </td>
166 </tr>
168 <tr>
169 <td class="text-nowrap align-top font-weight-bold"><?php echo xlt('Witness'); ?>:</td>
170 <td>
171 <input type='text' class='w-100' size='40' name='form_witness' maxlength='250'
172 value='<?php echo attr($row['destroy_witness']) ?>' />
173 </td>
174 </tr>
176 <tr>
177 <td class="text-nowrap align-top font-weight-bold"><?php echo xlt('Notes'); ?>:</td>
178 <td>
179 <input type='text' class='w-100' size='40' name='form_notes' maxlength='250'
180 value='<?php echo attr($row['destroy_notes']) ?>' />
181 </td>
182 </tr>
184 </table>
186 <div class="btn-group">
187 <input type='submit' class="btn btn-primary" name='form_save' value='<?php echo xla('Submit') ;?>' />
188 <input type='button' class="btn btn-secondary" value='<?php echo xla('Cancel'); ?>' onclick='window.close()' />
189 </div>
191 </center>
192 </form>
193 </body>
194 </html>