Support for optional logging of print actions.
[openemr.git] / interface / reports / destroyed_drugs_report.php
blob096d8a03032e85bf7fec350bcac1a72bd8e49248
1 <?php
2 // Copyright (C) 2006-2015 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");
15 require_once("$srcdir/formatting.inc.php");
17 $form_from_date = fixDate($_POST['form_from_date'], date('Y-01-01'));
18 $form_to_date = fixDate($_POST['form_to_date'] , date('Y-m-d'));
20 <html>
21 <head>
22 <?php html_header_show();?>
23 <title><?php xl('Destroyed Drugs','e'); ?></title>
24 <link rel='stylesheet' href='<?php echo $css_header ?>' type='text/css'>
26 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
27 <script type="text/javascript" src="../../library/textformat.js"></script>
28 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
29 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
30 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
31 <script type="text/javascript" src="../../library/dialog.js"></script>
32 <script language="JavaScript">
33 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
35 $(document).ready(function() {
36 var win = top.printLogSetup ? top : opener.top;
37 win.printLogSetup(document.getElementById('printbutton'));
38 });
39 </script>
40 </head>
42 <body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>
44 <center>
46 <h2><?php xl('Destroyed Drugs','e'); ?></h2>
48 <form name='theform' method='post' action='destroyed_drugs_report.php'>
50 <table border='0' cellpadding='3'>
52 <tr>
53 <td>
54 <?php xl('From','e'); ?>:
55 <input type='text' name='form_from_date' id='form_from_date'
56 size='10' value='<?php echo $form_from_date ?>'
57 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title=<?php xl('yyyy-mm-dd','e','\'','\''); ?>>
58 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
59 id='img_from_date' border='0' alt='[?]' style='cursor:pointer'
60 title=<?php xl('Click here to choose a date','e','\'','\''); ?>>
62 &nbsp;<?php xl('To','e'); ?>:
63 <input type='text' name='form_to_date' id='form_to_date'
64 size='10' value='<?php echo $form_to_date ?>'
65 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title=<?php xl('yyyy-mm-dd','e','\'','\''); ?>>
66 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
67 id='img_to_date' border='0' alt='[?]' style='cursor:pointer'
68 title=<?php xl('Click here to choose a date','e','\'','\''); ?>>
70 &nbsp;
71 <input type='submit' name='form_refresh' value=<?php xl('Refresh','e'); ?>>
72 &nbsp;
73 <input type='button' value='<?php echo xla('Print'); ?>' id='printbutton' />
74 </td>
75 </tr>
77 <tr>
78 <td height="1">
79 </td>
80 </tr>
82 </table>
84 <table border='0' cellpadding='1' cellspacing='2' width='98%'>
85 <tr bgcolor="#dddddd">
86 <td class='dehead'>
87 <?php xl('Drug Name','e'); ?>
88 </td>
89 <td class='dehead'>
90 <?php xl('NDC','e'); ?>
91 </td>
92 <td class='dehead'>
93 <?php xl('Lot','e'); ?>
94 </td>
95 <td class='dehead'>
96 <?php xl('Qty','e'); ?>
97 </td>
98 <td class='dehead'>
99 <?php xl('Date Destroyed','e'); ?>
100 </td>
101 <td class='dehead'>
102 <?php xl('Method','e'); ?>
103 </td>
104 <td class='dehead'>
105 <?php xl('Witness','e'); ?>
106 </td>
107 <td class='dehead'>
108 <?php xl('Notes','e'); ?>
109 </td>
110 </tr>
111 <?php
113 if ($_POST['form_refresh']) {
114 $where = "i.destroy_date >= '$form_from_date' AND " .
115 "i.destroy_date <= '$form_to_date'";
117 $query = "SELECT i.inventory_id, i.lot_number, i.on_hand, i.drug_id, " .
118 "i.destroy_date, i.destroy_method, i.destroy_witness, i.destroy_notes, " .
119 "d.name, d.ndc_number " .
120 "FROM drug_inventory AS i " .
121 "LEFT OUTER JOIN drugs AS d ON d.drug_id = i.drug_id " .
122 "WHERE $where " .
123 "ORDER BY d.name, i.drug_id, i.destroy_date, i.lot_number";
125 // echo "<!-- $query -->\n"; // debugging
126 $res = sqlStatement($query);
128 $last_drug_id = 0;
129 while ($row = sqlFetchArray($res)) {
130 $drug_name = $row['name'];
131 $ndc_number = $row['ndc_number'];
132 if ($row['drug_id'] == $last_drug_id) {
133 $drug_name = '&nbsp;';
134 $ndc_number = '&nbsp;';
137 <tr>
138 <td class='detail'>
139 <?php echo $drug_name ?>
140 </td>
141 <td class='detail'>
142 <?php echo $ndc_number ?>
143 </td>
144 <td class='detail'>
145 <a href='../drugs/destroy_lot.php?drug=<?php echo $row['drug_id'] ?>&lot=<?php echo $row['inventory_id'] ?>'
146 style='color:#0000ff' target='_blank'>
147 <?php echo $row['lot_number'] ?>
148 </a>
149 </td>
150 <td class='detail'>
151 <?php echo $row['on_hand'] ?>
152 </td>
153 <td class='detail'>
154 <?php echo oeFormatShortDate($row['destroy_date']) ?>
155 </td>
156 <td class='detail'>
157 <?php echo $row['destroy_method'] ?>
158 </td>
159 <td class='detail'>
160 <?php echo $row['destroy_witness'] ?>
161 </td>
162 <td class='detail'>
163 <?php echo $row['destroy_notes'] ?>
164 </td>
165 </tr>
166 <?php
167 $last_drug_id = $row['drug_id'];
168 } // end while
169 } // end if
172 </table>
173 </form>
174 </center>
175 <script language='JavaScript'>
176 Calendar.setup({inputField:"form_from_date", ifFormat:"%Y-%m-%d", button:"img_from_date"});
177 Calendar.setup({inputField:"form_to_date", ifFormat:"%Y-%m-%d", button:"img_to_date"});
178 </script>
179 </body>
180 </html>