fix: faxsms psr7 vendor fix (#7794)
[openemr.git] / interface / drugs / destroy_lot.php
blob0f9d5e2db7a252695a98abf5bf65b7684b29c55e
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\Common\Twig\TwigContainer;
21 use OpenEMR\Core\Header;
23 $drug_id = $_REQUEST['drug'];
24 $lot_id = $_REQUEST['lot'];
25 $info_msg = "";
27 if (!AclMain::aclCheckCore('admin', 'drugs')) {
28 echo (new TwigContainer(null, $GLOBALS['kernel']))->getTwig()->render('core/unauthorized.html.twig', ['pageTitle' => xl("Destroy Lot")]);
29 exit;
32 if (!$drug_id) {
33 die(xlt('Drug ID missing!'));
36 if (!$lot_id) {
37 die(xlt('Lot ID missing!'));
40 <html>
41 <head>
42 <title><?php echo xlt('Destroy Lot') ?></title>
44 <?php Header::setupHeader(['datetime-picker', 'opener']); ?>
46 <style>
47 td {
48 font-size: 0.8125rem;
50 </style>
52 <script>
53 $(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 });
63 function validate(f) {
64 if (!confirm(<?php echo xlj('Really destroy this lot?'); ?>)) {
65 return false;
67 top.restoreSession();
68 return true;
71 </script>
73 </head>
75 <body class="body_top">
76 <?php
77 // If we are saving, then save and close the window.
79 if ($_POST['form_save']) {
80 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
81 CsrfUtils::csrfNotVerified();
84 sqlStatement(
85 "UPDATE drug_inventory SET " .
86 "destroy_date = ?, " .
87 "destroy_method = ?, " .
88 "destroy_witness = ?, " .
89 "destroy_notes = ? " .
90 "WHERE drug_id = ? AND inventory_id = ?",
91 array(
92 (empty($_POST['form_date']) ? "NULL" : $_POST['form_date']),
93 $_POST['form_method'],
94 $_POST['form_witness'],
95 $_POST['form_notes'],
96 $drug_id,
97 $lot_id
101 // Close this window and redisplay the updated list of drugs.
103 echo "<script>\n";
104 if ($info_msg) {
105 echo " alert('" . addslashes($info_msg) . "');\n";
108 echo " window.close();\n";
109 echo " if (opener.refreshme) opener.refreshme();\n";
110 echo "</script></body></html>\n";
111 exit();
114 $row = sqlQuery("SELECT * FROM drug_inventory WHERE drug_id = ? " .
115 "AND inventory_id = ?", array($drug_id,$lot_id));
118 <form method='post' name='theform' onsubmit='return validate(this);'
119 action='destroy_lot.php?drug=<?php echo attr_url($drug_id) ?>&lot=<?php echo attr_url($lot_id) ?>'>
121 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
123 <center>
125 <table class='table-borderless w-100'>
127 <tr>
128 <td class="text-nowrap align-top" width='1%'><?php echo xlt('Lot Number'); ?>:</td>
129 <td>
130 <?php echo text($row['lot_number']) ?>
131 </td>
132 </tr>
134 <tr>
135 <td class="text-nowrap align-top"><?php echo xlt('Manufacturer'); ?>:</td>
136 <td>
137 <?php echo text($row['manufacturer']) ?>
138 </td>
139 </tr>
141 <tr>
142 <td class="text-nowrap align-top"><?php echo xlt('Quantity On Hand'); ?>:</td>
143 <td>
144 <?php echo text($row['on_hand']) ?>
145 </td>
146 </tr>
148 <tr>
149 <td class="text-nowrap align-top"><?php echo xlt('Expiration Date'); ?>:</td>
150 <td>
151 <?php echo text($row['expiration']) ?>
152 </td>
153 </tr>
155 <tr>
156 <td class="text-nowrap align-top"><?php echo xlt('Date Destroyed'); ?>:</td>
157 <td>
158 <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'); ?>' />
159 </td>
160 </tr>
162 <tr>
163 <td class="text-nowrap align-top"><?php echo xlt('Method of Destruction'); ?>:</td>
164 <td>
165 <input type='text' class='w-100' size='40' name='form_method' maxlength='250'
166 value='<?php echo attr($row['destroy_method']) ?>' />
167 </td>
168 </tr>
170 <tr>
171 <td class="text-nowrap align-top"><?php echo xlt('Witness'); ?>:</td>
172 <td>
173 <input type='text' class='w-100' size='40' name='form_witness' maxlength='250'
174 value='<?php echo attr($row['destroy_witness']) ?>' />
175 </td>
176 </tr>
178 <tr>
179 <td class="text-nowrap align-top"><?php echo xlt('Notes'); ?>:</td>
180 <td>
181 <input type='text' class='w-100' size='40' name='form_notes' maxlength='250'
182 value='<?php echo attr($row['destroy_notes']) ?>' />
183 </td>
184 </tr>
186 </table>
188 <div class="btn-group">
189 <input type='submit' class="btn btn-primary" name='form_save' value='<?php echo xla('Submit') ;?>' />
190 <input type='button' class="btn btn-secondary" value='<?php echo xla('Cancel'); ?>' onclick='window.close()' />
191 </div>
193 </center>
194 </form>
195 </body>
196 </html>