simplify decrypt to return blank value when a empty value is sent (#2115)
[openemr.git] / interface / reports / destroyed_drugs_report.php
blob0aba23c73457252a5c13800e84efb8896a150530
1 <?php
2 /**
3 * This report lists destroyed drug lots within a specified date range.
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-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");
18 if (!empty($_POST)) {
19 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
20 csrfNotVerified();
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
27 <html>
28 <head>
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">
34 <style>
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;
42 </style>
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 ?>
63 });
64 });
66 </script>
67 </head>
69 <body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>
71 <center>
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'>
80 <tr>
81 <td>
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 &nbsp;<?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)); ?>'>
90 &nbsp;
91 <input type='submit' name='form_refresh' value='<?php echo xla('Refresh'); ?>'>
92 &nbsp;
93 <input type='button' value='<?php echo xla('Print'); ?>' id='printbutton' />
94 </td>
95 </tr>
97 <tr>
98 <td height="1">
99 </td>
100 </tr>
102 </table>
104 <table width='98%' id='mymaintable' class='mymaintable'>
105 <thead>
106 <tr bgcolor="#dddddd">
107 <td class='dehead'>
108 <?php echo xlt('Drug Name'); ?>
109 </td>
110 <td class='dehead'>
111 <?php echo xlt('NDC'); ?>
112 </td>
113 <td class='dehead'>
114 <?php echo xlt('Lot'); ?>
115 </td>
116 <td class='dehead'>
117 <?php echo xlt('Qty'); ?>
118 </td>
119 <td class='dehead'>
120 <?php echo xlt('Date Destroyed'); ?>
121 </td>
122 <td class='dehead'>
123 <?php echo xlt('Method'); ?>
124 </td>
125 <td class='dehead'>
126 <?php echo xlt('Witness'); ?>
127 </td>
128 <td class='dehead'>
129 <?php echo xlt('Notes'); ?>
130 </td>
131 </tr>
132 </thead>
133 <tbody>
134 <?php
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 " .
144 "WHERE $where " .
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));
150 $last_drug_id = 0;
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 = '&nbsp;';
156 $ndc_number = '&nbsp;';
159 <tr>
160 <td class='detail'>
161 <?php echo text($drug_name); ?>
162 </td>
163 <td class='detail'>
164 <?php echo text($ndc_number); ?>
165 </td>
166 <td class='detail'>
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']); ?>
170 </a>
171 </td>
172 <td class='detail'>
173 <?php echo text($row['on_hand']); ?>
174 </td>
175 <td class='detail'>
176 <?php echo text(oeFormatShortDate($row['destroy_date'])); ?>
177 </td>
178 <td class='detail'>
179 <?php echo text($row['destroy_method']); ?>
180 </td>
181 <td class='detail'>
182 <?php echo text($row['destroy_witness']); ?>
183 </td>
184 <td class='detail'>
185 <?php echo text($row['destroy_notes']); ?>
186 </td>
187 </tr>
188 <?php
189 $last_drug_id = $row['drug_id'];
190 } // end while
191 } // end if
194 </tbody>
195 </table>
196 </form>
197 </center>
198 </body>
199 </html>