3 * This report lists destroyed drug lots within a specified date range.
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-2016 Rod Roark <rod@sunsetsystems.com>
10 * @copyright Copyright (c) 2017-2018 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
14 require_once("../globals.php");
15 require_once("$srcdir/patient.inc");
16 require_once("../drugs/drugs.inc.php");
19 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
24 $form_from_date = isset($_POST['form_from_date']) ?
DateToYYYYMMDD($_POST['form_from_date']) : date('Y-01-01'); // From date filter
25 $form_to_date = isset($_POST['form_to_date']) ?
DateToYYYYMMDD($_POST['form_to_date']) : date('Y-m-d'); // To date filter
29 <?php
html_header_show();?
>
30 <title
><?php
echo xlt('Destroyed Drugs'); ?
></title
>
31 <link rel
='stylesheet' href
='<?php echo $css_header ?>' type
='text/css'>
32 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker/build/jquery.datetimepicker.min.css">
35 table
.mymaintable
, table
.mymaintable td
, table
.mymaintable th
{
36 border
: 1px solid
#aaaaaa;
37 border
-collapse
: collapse
;
39 table
.mymaintable td
, table
.mymaintable th
{
40 padding
: 1pt
4pt
1pt
4pt
;
44 <script type
="text/javascript" src
="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script
>
45 <script type
="text/javascript" src
="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
46 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-1-9-1/jquery.min.js"></script
>
47 <script type
="text/javascript" src
="../../library/js/report_helper.js?v=<?php echo $v_js_includes; ?>"></script
>
48 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker/build/jquery.datetimepicker.full.min.js"></script
>
50 <script language
="JavaScript">
52 $
(document
).ready(function() {
53 oeFixedHeaderSetup(document
.getElementById('mymaintable'));
54 var win
= top
.printLogSetup ? top
: opener
.top
;
55 win
.printLogSetup(document
.getElementById('printbutton'));
57 $
('.datepicker').datetimepicker({
58 <?php
$datetimepicker_timepicker = false; ?
>
59 <?php
$datetimepicker_showseconds = false; ?
>
60 <?php
$datetimepicker_formatInput = true; ?
>
61 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
62 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
69 <body leftmargin
='0' topmargin
='0' marginwidth
='0' marginheight
='0'>
73 <h2
><?php
echo xlt('Destroyed Drugs'); ?
></h2
>
75 <form name
='theform' method
='post' action
='destroyed_drugs_report.php' onsubmit
='return top.restoreSession()'>
76 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(collectCsrfToken()); ?>" />
78 <table border
='0' cellpadding
='3'>
82 <?php
echo xlt('From'); ?
>:
83 <input type
='text' class='datepicker' name
='form_from_date' id
='form_from_date'
84 size
='10' value
='<?php echo attr(oeFormatShortDate($form_from_date)); ?>'>
86  
;<?php
echo xlt('To'); ?
>:
87 <input type
='text' class='datepicker' name
='form_to_date' id
='form_to_date'
88 size
='10' value
='<?php echo attr(oeFormatShortDate($form_to_date)); ?>'>
91 <input type
='submit' name
='form_refresh' value
='<?php echo xla('Refresh
'); ?>'>
93 <input type
='button' value
='<?php echo xla('Print'); ?>' id
='printbutton' />
104 <table width
='98%' id
='mymaintable' class='mymaintable'>
106 <tr bgcolor
="#dddddd">
108 <?php
echo xlt('Drug Name'); ?
>
111 <?php
echo xlt('NDC'); ?
>
114 <?php
echo xlt('Lot'); ?
>
117 <?php
echo xlt('Qty'); ?
>
120 <?php
echo xlt('Date Destroyed'); ?
>
123 <?php
echo xlt('Method'); ?
>
126 <?php
echo xlt('Witness'); ?
>
129 <?php
echo xlt('Notes'); ?
>
135 if ($_POST['form_refresh']) {
136 $where = "i.destroy_date >= ? AND " .
137 "i.destroy_date <= ?";
139 $query = "SELECT i.inventory_id, i.lot_number, i.on_hand, i.drug_id, " .
140 "i.destroy_date, i.destroy_method, i.destroy_witness, i.destroy_notes, " .
141 "d.name, d.ndc_number " .
142 "FROM drug_inventory AS i " .
143 "LEFT OUTER JOIN drugs AS d ON d.drug_id = i.drug_id " .
145 "ORDER BY d.name, i.drug_id, i.destroy_date, i.lot_number";
147 // echo "<!-- $query -->\n"; // debugging
148 $res = sqlStatement($query, array($form_from_date, $form_to_date));
151 while ($row = sqlFetchArray($res)) {
152 $drug_name = $row['name'];
153 $ndc_number = $row['ndc_number'];
154 if ($row['drug_id'] == $last_drug_id) {
155 $drug_name = ' ';
156 $ndc_number = ' ';
161 <?php
echo text($drug_name); ?
>
164 <?php
echo text($ndc_number); ?
>
167 <a href
='../drugs/destroy_lot.php?drug=<?php echo attr_url($row['drug_id
']); ?>&lot=<?php echo attr_url($row['inventory_id
']); ?>'
168 style
='color:#0000ff' target
='_blank'>
169 <?php
echo text($row['lot_number']); ?
>
173 <?php
echo text($row['on_hand']); ?
>
176 <?php
echo text(oeFormatShortDate($row['destroy_date'])); ?
>
179 <?php
echo text($row['destroy_method']); ?
>
182 <?php
echo text($row['destroy_witness']); ?
>
185 <?php
echo text($row['destroy_notes']); ?
>
189 $last_drug_id = $row['drug_id'];