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