added gacl config files to upgrade instructions
[openemr.git] / interface / reports / destroyed_drugs_report.php
blob60db33309e16c867df0733911d28c8262b1ceb59
1 <?
2 // Copyright (C) 2006 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 <? html_header_show();?>
22 <title><? 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>
26 <script type="text/javascript" src="../../library/textformat.js"></script>
27 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
28 <script type="text/javascript" src="../../library/dynarch_calendar_en.js"></script>
29 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
30 <script type="text/javascript" src="../../library/dialog.js"></script>
31 <script language="JavaScript">
32 var mypcc = '<? echo $GLOBALS['phone_country_code'] ?>';
33 </script>
34 </head>
36 <body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>
38 <center>
40 <h2><? xl('Destroyed Drugs','e'); ?></h2>
42 <form name='theform' method='post' action='destroyed_drugs_report.php'>
44 <table border='0' cellpadding='3'>
46 <tr>
47 <td>
48 <? xl('From','e'); ?>:
49 <input type='text' name='form_from_date' id='form_from_date'
50 size='10' value='<? echo $form_from_date ?>'
51 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title='yyyy-mm-dd'>
52 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
53 id='img_from_date' border='0' alt='[?]' style='cursor:pointer'
54 title='Click here to choose a date'>
56 &nbsp;<? xl('To','e'); ?>:
57 <input type='text' name='form_to_date' id='form_to_date'
58 size='10' value='<? echo $form_to_date ?>'
59 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title='yyyy-mm-dd'>
60 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
61 id='img_to_date' border='0' alt='[?]' style='cursor:pointer'
62 title='Click here to choose a date'>
64 &nbsp;
65 <input type='submit' name='form_refresh' value=<? xl('Refresh','e'); ?>>
66 &nbsp;
67 <input type='button' value='<?php xl('Print','e'); ?>' onclick='window.print()' />
68 </td>
69 </tr>
71 <tr>
72 <td height="1">
73 </td>
74 </tr>
76 </table>
78 <table border='0' cellpadding='1' cellspacing='2' width='98%'>
79 <tr bgcolor="#dddddd">
80 <td class='dehead'>
81 <? xl('Drug Name','e'); ?>
82 </td>
83 <td class='dehead'>
84 <? xl('NDC','e'); ?>
85 </td>
86 <td class='dehead'>
87 <? xl('Lot','e'); ?>
88 </td>
89 <td class='dehead'>
90 <? xl('Qty','e'); ?>
91 </td>
92 <td class='dehead'>
93 <? xl('Date Destroyed','e'); ?>
94 </td>
95 <td class='dehead'>
96 <? xl('Method','e'); ?>
97 </td>
98 <td class='dehead'>
99 <? xl('Witness','e'); ?>
100 </td>
101 <td class='dehead'>
102 <? xl('Notes','e'); ?>
103 </td>
104 </tr>
106 if ($_POST['form_refresh']) {
107 $where = "i.destroy_date >= '$form_from_date' AND " .
108 "i.destroy_date <= '$form_to_date'";
110 $query = "SELECT i.inventory_id, i.lot_number, i.on_hand, i.drug_id, " .
111 "i.destroy_date, i.destroy_method, i.destroy_witness, i.destroy_notes, " .
112 "d.name, d.ndc_number " .
113 "FROM drug_inventory AS i " .
114 "LEFT OUTER JOIN drugs AS d ON d.drug_id = i.drug_id " .
115 "WHERE $where " .
116 "ORDER BY d.name, i.drug_id, i.destroy_date, i.lot_number";
118 // echo "<!-- $query -->\n"; // debugging
119 $res = sqlStatement($query);
121 $last_drug_id = 0;
122 while ($row = sqlFetchArray($res)) {
123 $drug_name = $row['name'];
124 $ndc_number = $row['ndc_number'];
125 if ($row['drug_id'] == $last_drug_id) {
126 $drug_name = '&nbsp;';
127 $ndc_number = '&nbsp;';
130 <tr>
131 <td class='detail'>
132 <?php echo $drug_name ?>
133 </td>
134 <td class='detail'>
135 <?php echo $ndc_number ?>
136 </td>
137 <td class='detail'>
138 <a href='../drugs/destroy_lot.php?drug=<?php echo $row['drug_id'] ?>&lot=<?php echo $row['inventory_id'] ?>'
139 style='color:#0000ff' target='_blank'>
140 <?php echo $row['lot_number'] ?>
141 </a>
142 </td>
143 <td class='detail'>
144 <?php echo $row['on_hand'] ?>
145 </td>
146 <td class='detail'>
147 <?php echo $row['destroy_date'] ?>
148 </td>
149 <td class='detail'>
150 <?php echo $row['destroy_method'] ?>
151 </td>
152 <td class='detail'>
153 <?php echo $row['destroy_witness'] ?>
154 </td>
155 <td class='detail'>
156 <?php echo $row['destroy_notes'] ?>
157 </td>
158 </tr>
159 <?php
160 $last_drug_id = $row['drug_id'];
161 } // end while
162 } // end if
165 </table>
166 </form>
167 </center>
168 <script language='JavaScript'>
169 Calendar.setup({inputField:"form_from_date", ifFormat:"%Y-%m-%d", button:"img_from_date"});
170 Calendar.setup({inputField:"form_to_date", ifFormat:"%Y-%m-%d", button:"img_to_date"});
171 </script>
172 </body>
173 </html>