2 // Copyright (C) 2006, 2010 Rod Roark <rod@sunsetsystems.com>
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
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'));
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
'] ?>';
37 <body leftmargin
='0' topmargin
='0' marginwidth
='0' marginheight
='0'>
41 <h2
><?php
xl('Destroyed Drugs','e'); ?
></h2
>
43 <form name
='theform' method
='post' action
='destroyed_drugs_report.php'>
45 <table border
='0' cellpadding
='3'>
49 <?php
xl('From','e'); ?
>:
50 <input type
='text' name
='form_from_date' id
='form_from_date'
51 size
='10' value
='<?php 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  
;<?php
xl('To','e'); ?
>:
58 <input type
='text' name
='form_to_date' id
='form_to_date'
59 size
='10' value
='<?php 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','\'','\''); ?
>>
66 <input type
='submit' name
='form_refresh' value
=<?php
xl('Refresh','e'); ?
>>
68 <input type
='button' value
='<?php xl('Print','e
'); ?>' onclick
='window.print()' />
79 <table border
='0' cellpadding
='1' cellspacing
='2' width
='98%'>
80 <tr bgcolor
="#dddddd">
82 <?php
xl('Drug Name','e'); ?
>
85 <?php
xl('NDC','e'); ?
>
88 <?php
xl('Lot','e'); ?
>
91 <?php
xl('Qty','e'); ?
>
94 <?php
xl('Date Destroyed','e'); ?
>
97 <?php
xl('Method','e'); ?
>
100 <?php
xl('Witness','e'); ?
>
103 <?php
xl('Notes','e'); ?
>
108 if ($_POST['form_refresh']) {
109 $where = "i.destroy_date >= '$form_from_date' AND " .
110 "i.destroy_date <= '$form_to_date'";
112 $query = "SELECT i.inventory_id, i.lot_number, i.on_hand, i.drug_id, " .
113 "i.destroy_date, i.destroy_method, i.destroy_witness, i.destroy_notes, " .
114 "d.name, d.ndc_number " .
115 "FROM drug_inventory AS i " .
116 "LEFT OUTER JOIN drugs AS d ON d.drug_id = i.drug_id " .
118 "ORDER BY d.name, i.drug_id, i.destroy_date, i.lot_number";
120 // echo "<!-- $query -->\n"; // debugging
121 $res = sqlStatement($query);
124 while ($row = sqlFetchArray($res)) {
125 $drug_name = $row['name'];
126 $ndc_number = $row['ndc_number'];
127 if ($row['drug_id'] == $last_drug_id) {
128 $drug_name = ' ';
129 $ndc_number = ' ';
134 <?php
echo $drug_name ?
>
137 <?php
echo $ndc_number ?
>
140 <a href
='../drugs/destroy_lot.php?drug=<?php echo $row['drug_id
'] ?>&lot=<?php echo $row['inventory_id
'] ?>'
141 style
='color:#0000ff' target
='_blank'>
142 <?php
echo $row['lot_number'] ?
>
146 <?php
echo $row['on_hand'] ?
>
149 <?php
echo oeFormatShortDate($row['destroy_date']) ?
>
152 <?php
echo $row['destroy_method'] ?
>
155 <?php
echo $row['destroy_witness'] ?
>
158 <?php
echo $row['destroy_notes'] ?
>
162 $last_drug_id = $row['drug_id'];
170 <script language
='JavaScript'>
171 Calendar
.setup({inputField
:"form_from_date", ifFormat
:"%Y-%m-%d", button
:"img_from_date"});
172 Calendar
.setup({inputField
:"form_to_date", ifFormat
:"%Y-%m-%d", button
:"img_to_date"});