Highway to PSR2
[openemr.git] / interface / reports / destroyed_drugs_report.php
blob98aea8cada8b80b84435c767925a1575a17b1f89
1 <?php
2 // Copyright (C) 2006-2016 Rod Roark <rod@sunsetsystems.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 // This report lists destroyed drug lots within a specified date
10 // range.
12 require_once("../globals.php");
13 require_once("$srcdir/patient.inc");
14 require_once("../drugs/drugs.inc.php");
16 $form_from_date = fixDate($_POST['form_from_date'], date('Y-01-01'));
17 $form_to_date = fixDate($_POST['form_to_date'], date('Y-m-d'));
19 <html>
20 <head>
21 <?php html_header_show();?>
22 <title><?php xl('Destroyed Drugs', 'e'); ?></title>
23 <link rel='stylesheet' href='<?php echo $css_header ?>' type='text/css'>
25 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
27 <style>
28 table.mymaintable, table.mymaintable td, table.mymaintable th {
29 border: 1px solid #aaaaaa;
30 border-collapse: collapse;
32 table.mymaintable td, table.mymaintable th {
33 padding: 1pt 4pt 1pt 4pt;
35 </style>
37 <script type="text/javascript" src="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
38 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
39 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
40 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
41 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
42 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-9-1/index.js"></script>
43 <script type="text/javascript" src="../../library/js/report_helper.js?v=<?php echo $v_js_includes; ?>"></script>
45 <script language="JavaScript">
47 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
49 $(document).ready(function() {
50 oeFixedHeaderSetup(document.getElementById('mymaintable'));
51 var win = top.printLogSetup ? top : opener.top;
52 win.printLogSetup(document.getElementById('printbutton'));
53 });
55 </script>
56 </head>
58 <body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>
60 <center>
62 <h2><?php xl('Destroyed Drugs', 'e'); ?></h2>
64 <form name='theform' method='post' action='destroyed_drugs_report.php'>
66 <table border='0' cellpadding='3'>
68 <tr>
69 <td>
70 <?php xl('From', 'e'); ?>:
71 <input type='text' name='form_from_date' id='form_from_date'
72 size='10' value='<?php echo $form_from_date ?>'
73 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title=<?php xl('yyyy-mm-dd', 'e', '\'', '\''); ?>>
74 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
75 id='img_from_date' border='0' alt='[?]' style='cursor:pointer'
76 title=<?php xl('Click here to choose a date', 'e', '\'', '\''); ?>>
78 &nbsp;<?php xl('To', 'e'); ?>:
79 <input type='text' name='form_to_date' id='form_to_date'
80 size='10' value='<?php echo $form_to_date ?>'
81 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title=<?php xl('yyyy-mm-dd', 'e', '\'', '\''); ?>>
82 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
83 id='img_to_date' border='0' alt='[?]' style='cursor:pointer'
84 title=<?php xl('Click here to choose a date', 'e', '\'', '\''); ?>>
86 &nbsp;
87 <input type='submit' name='form_refresh' value=<?php xl('Refresh', 'e'); ?>>
88 &nbsp;
89 <input type='button' value='<?php echo xla('Print'); ?>' id='printbutton' />
90 </td>
91 </tr>
93 <tr>
94 <td height="1">
95 </td>
96 </tr>
98 </table>
100 <table width='98%' id='mymaintable' class='mymaintable'>
101 <thead>
102 <tr bgcolor="#dddddd">
103 <td class='dehead'>
104 <?php xl('Drug Name', 'e'); ?>
105 </td>
106 <td class='dehead'>
107 <?php xl('NDC', 'e'); ?>
108 </td>
109 <td class='dehead'>
110 <?php xl('Lot', 'e'); ?>
111 </td>
112 <td class='dehead'>
113 <?php xl('Qty', 'e'); ?>
114 </td>
115 <td class='dehead'>
116 <?php xl('Date Destroyed', 'e'); ?>
117 </td>
118 <td class='dehead'>
119 <?php xl('Method', 'e'); ?>
120 </td>
121 <td class='dehead'>
122 <?php xl('Witness', 'e'); ?>
123 </td>
124 <td class='dehead'>
125 <?php xl('Notes', 'e'); ?>
126 </td>
127 </tr>
128 </thead>
129 <tbody>
130 <?php
131 if ($_POST['form_refresh']) {
132 $where = "i.destroy_date >= '$form_from_date' AND " .
133 "i.destroy_date <= '$form_to_date'";
135 $query = "SELECT i.inventory_id, i.lot_number, i.on_hand, i.drug_id, " .
136 "i.destroy_date, i.destroy_method, i.destroy_witness, i.destroy_notes, " .
137 "d.name, d.ndc_number " .
138 "FROM drug_inventory AS i " .
139 "LEFT OUTER JOIN drugs AS d ON d.drug_id = i.drug_id " .
140 "WHERE $where " .
141 "ORDER BY d.name, i.drug_id, i.destroy_date, i.lot_number";
143 // echo "<!-- $query -->\n"; // debugging
144 $res = sqlStatement($query);
146 $last_drug_id = 0;
147 while ($row = sqlFetchArray($res)) {
148 $drug_name = $row['name'];
149 $ndc_number = $row['ndc_number'];
150 if ($row['drug_id'] == $last_drug_id) {
151 $drug_name = '&nbsp;';
152 $ndc_number = '&nbsp;';
155 <tr>
156 <td class='detail'>
157 <?php echo $drug_name ?>
158 </td>
159 <td class='detail'>
160 <?php echo $ndc_number ?>
161 </td>
162 <td class='detail'>
163 <a href='../drugs/destroy_lot.php?drug=<?php echo $row['drug_id'] ?>&lot=<?php echo $row['inventory_id'] ?>'
164 style='color:#0000ff' target='_blank'>
165 <?php echo $row['lot_number'] ?>
166 </a>
167 </td>
168 <td class='detail'>
169 <?php echo $row['on_hand'] ?>
170 </td>
171 <td class='detail'>
172 <?php echo oeFormatShortDate($row['destroy_date']) ?>
173 </td>
174 <td class='detail'>
175 <?php echo $row['destroy_method'] ?>
176 </td>
177 <td class='detail'>
178 <?php echo $row['destroy_witness'] ?>
179 </td>
180 <td class='detail'>
181 <?php echo $row['destroy_notes'] ?>
182 </td>
183 </tr>
184 <?php
185 $last_drug_id = $row['drug_id'];
186 } // end while
187 } // end if
190 </tbody>
191 </table>
192 </form>
193 </center>
194 <script language='JavaScript'>
195 Calendar.setup({inputField:"form_from_date", ifFormat:"%Y-%m-%d", button:"img_from_date"});
196 Calendar.setup({inputField:"form_to_date", ifFormat:"%Y-%m-%d", button:"img_to_date"});
197 </script>
198 </body>
199 </html>