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'];
27 if (!AclMain
::aclCheckCore('admin', 'drugs')) {
28 echo (new TwigContainer(null, $GLOBALS['kernel']))->getTwig()->render('core/unauthorized.html.twig', ['pageTitle' => xl("Destroy Lot")]);
33 die(xlt('Drug ID missing!'));
37 die(xlt('Lot ID missing!'));
42 <title
><?php
echo xlt('Destroy Lot') ?
></title
>
44 <?php Header
::setupHeader(['datetime-picker', 'opener']); ?
>
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 ?>
63 function validate(f
) {
64 if (!confirm(<?php
echo xlj('Really destroy this lot?'); ?
>)) {
75 <body
class="body_top">
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();
85 "UPDATE drug_inventory SET " .
86 "destroy_date = ?, " .
87 "destroy_method = ?, " .
88 "destroy_witness = ?, " .
89 "destroy_notes = ? " .
90 "WHERE drug_id = ? AND inventory_id = ?",
92 (empty($_POST['form_date']) ?
"NULL" : $_POST['form_date']),
93 $_POST['form_method'],
94 $_POST['form_witness'],
101 // Close this window and redisplay the updated list of drugs.
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";
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()); ?>" />
125 <table
class='table-borderless w-100'>
128 <td
class="text-nowrap align-top" width
='1%'><?php
echo xlt('Lot Number'); ?
>:</td
>
130 <?php
echo text($row['lot_number']) ?
>
135 <td
class="text-nowrap align-top"><?php
echo xlt('Manufacturer'); ?
>:</td
>
137 <?php
echo text($row['manufacturer']) ?
>
142 <td
class="text-nowrap align-top"><?php
echo xlt('Quantity On Hand'); ?
>:</td
>
144 <?php
echo text($row['on_hand']) ?
>
149 <td
class="text-nowrap align-top"><?php
echo xlt('Expiration Date'); ?
>:</td
>
151 <?php
echo text($row['expiration']) ?
>
156 <td
class="text-nowrap align-top"><?php
echo xlt('Date Destroyed'); ?
>:</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
'); ?>' />
163 <td
class="text-nowrap align-top"><?php
echo xlt('Method of Destruction'); ?
>:</td
>
165 <input type
='text' class='w-100' size
='40' name
='form_method' maxlength
='250'
166 value
='<?php echo attr($row['destroy_method
']) ?>' />
171 <td
class="text-nowrap align-top"><?php
echo xlt('Witness'); ?
>:</td
>
173 <input type
='text' class='w-100' size
='40' name
='form_witness' maxlength
='250'
174 value
='<?php echo attr($row['destroy_witness
']) ?>' />
179 <td
class="text-nowrap align-top"><?php
echo xlt('Notes'); ?
>:</td
>
181 <input type
='text' class='w-100' size
='40' name
='form_notes' maxlength
='250'
182 value
='<?php echo attr($row['destroy_notes
']) ?>' />
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()' />