new datepicker in encounter
[openemr.git] / interface / reports / destroyed_drugs_report.php
blob55d52de9a1b59a7c94e54a4bb6e5aebe8f700d34
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");
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>
28 <style>
29 table.mymaintable, table.mymaintable td, table.mymaintable th {
30 border: 1px solid #aaaaaa;
31 border-collapse: collapse;
33 table.mymaintable td, table.mymaintable th {
34 padding: 1pt 4pt 1pt 4pt;
36 </style>
38 <script type="text/javascript" src="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
39 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
40 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
41 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
42 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
43 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-9-1/index.js"></script>
44 <script type="text/javascript" src="../../library/js/report_helper.js?v=<?php echo $v_js_includes; ?>"></script>
46 <script language="JavaScript">
48 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
50 $(document).ready(function() {
51 oeFixedHeaderSetup(document.getElementById('mymaintable'));
52 var win = top.printLogSetup ? top : opener.top;
53 win.printLogSetup(document.getElementById('printbutton'));
54 });
56 </script>
57 </head>
59 <body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>
61 <center>
63 <h2><?php xl('Destroyed Drugs','e'); ?></h2>
65 <form name='theform' method='post' action='destroyed_drugs_report.php'>
67 <table border='0' cellpadding='3'>
69 <tr>
70 <td>
71 <?php xl('From','e'); ?>:
72 <input type='text' name='form_from_date' id='form_from_date'
73 size='10' value='<?php echo $form_from_date ?>'
74 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title=<?php xl('yyyy-mm-dd','e','\'','\''); ?>>
75 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
76 id='img_from_date' border='0' alt='[?]' style='cursor:pointer'
77 title=<?php xl('Click here to choose a date','e','\'','\''); ?>>
79 &nbsp;<?php xl('To','e'); ?>:
80 <input type='text' name='form_to_date' id='form_to_date'
81 size='10' value='<?php echo $form_to_date ?>'
82 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title=<?php xl('yyyy-mm-dd','e','\'','\''); ?>>
83 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
84 id='img_to_date' border='0' alt='[?]' style='cursor:pointer'
85 title=<?php xl('Click here to choose a date','e','\'','\''); ?>>
87 &nbsp;
88 <input type='submit' name='form_refresh' value=<?php xl('Refresh','e'); ?>>
89 &nbsp;
90 <input type='button' value='<?php echo xla('Print'); ?>' id='printbutton' />
91 </td>
92 </tr>
94 <tr>
95 <td height="1">
96 </td>
97 </tr>
99 </table>
101 <table width='98%' id='mymaintable' class='mymaintable'>
102 <thead>
103 <tr bgcolor="#dddddd">
104 <td class='dehead'>
105 <?php xl('Drug Name','e'); ?>
106 </td>
107 <td class='dehead'>
108 <?php xl('NDC','e'); ?>
109 </td>
110 <td class='dehead'>
111 <?php xl('Lot','e'); ?>
112 </td>
113 <td class='dehead'>
114 <?php xl('Qty','e'); ?>
115 </td>
116 <td class='dehead'>
117 <?php xl('Date Destroyed','e'); ?>
118 </td>
119 <td class='dehead'>
120 <?php xl('Method','e'); ?>
121 </td>
122 <td class='dehead'>
123 <?php xl('Witness','e'); ?>
124 </td>
125 <td class='dehead'>
126 <?php xl('Notes','e'); ?>
127 </td>
128 </tr>
129 </thead>
130 <tbody>
131 <?php
132 if ($_POST['form_refresh']) {
133 $where = "i.destroy_date >= '$form_from_date' AND " .
134 "i.destroy_date <= '$form_to_date'";
136 $query = "SELECT i.inventory_id, i.lot_number, i.on_hand, i.drug_id, " .
137 "i.destroy_date, i.destroy_method, i.destroy_witness, i.destroy_notes, " .
138 "d.name, d.ndc_number " .
139 "FROM drug_inventory AS i " .
140 "LEFT OUTER JOIN drugs AS d ON d.drug_id = i.drug_id " .
141 "WHERE $where " .
142 "ORDER BY d.name, i.drug_id, i.destroy_date, i.lot_number";
144 // echo "<!-- $query -->\n"; // debugging
145 $res = sqlStatement($query);
147 $last_drug_id = 0;
148 while ($row = sqlFetchArray($res)) {
149 $drug_name = $row['name'];
150 $ndc_number = $row['ndc_number'];
151 if ($row['drug_id'] == $last_drug_id) {
152 $drug_name = '&nbsp;';
153 $ndc_number = '&nbsp;';
156 <tr>
157 <td class='detail'>
158 <?php echo $drug_name ?>
159 </td>
160 <td class='detail'>
161 <?php echo $ndc_number ?>
162 </td>
163 <td class='detail'>
164 <a href='../drugs/destroy_lot.php?drug=<?php echo $row['drug_id'] ?>&lot=<?php echo $row['inventory_id'] ?>'
165 style='color:#0000ff' target='_blank'>
166 <?php echo $row['lot_number'] ?>
167 </a>
168 </td>
169 <td class='detail'>
170 <?php echo $row['on_hand'] ?>
171 </td>
172 <td class='detail'>
173 <?php echo oeFormatShortDate($row['destroy_date']) ?>
174 </td>
175 <td class='detail'>
176 <?php echo $row['destroy_method'] ?>
177 </td>
178 <td class='detail'>
179 <?php echo $row['destroy_witness'] ?>
180 </td>
181 <td class='detail'>
182 <?php echo $row['destroy_notes'] ?>
183 </td>
184 </tr>
185 <?php
186 $last_drug_id = $row['drug_id'];
187 } // end while
188 } // end if
191 </tbody>
192 </table>
193 </form>
194 </center>
195 <script language='JavaScript'>
196 Calendar.setup({inputField:"form_from_date", ifFormat:"%Y-%m-%d", button:"img_from_date"});
197 Calendar.setup({inputField:"form_to_date", ifFormat:"%Y-%m-%d", button:"img_to_date"});
198 </script>
199 </body>
200 </html>