Update. Hopefully approaching steady state.
[openemr.git] / interface / drugs / drug_inventory.php
blob56ceb5cbc4c7fe9c749a3a8f79ec280b1d07888b
1 <?php
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 require_once("../globals.php");
10 require_once("$srcdir/acl.inc");
11 require_once("drugs.inc.php");
13 // Check authorization.
14 $thisauth = acl_check('admin', 'drugs');
15 if (!$thisauth) die("Not authorized.");
17 // get drugs
18 $res = sqlStatement("SELECT d.*, " .
19 "di.lot_number, di.expiration, di.manufacturer, di.on_hand " .
20 "FROM drugs AS d " .
21 "LEFT OUTER JOIN drug_inventory AS di ON di.drug_id = d.drug_id " .
22 "AND di.on_hand != 0 " .
23 "ORDER BY d.name, d.drug_id, di.expiration, di.lot_number");
25 <html>
27 <head>
29 <link rel=stylesheet href='<? echo $css_header ?>' type='text/css'>
30 <title><? xl('Drug Inventory','e'); ?></title>
32 <style>
33 tr.head { font-size:10pt; background-color:#cccccc; text-align:center; }
34 tr.detail { font-size:10pt; }
35 </style>
37 <script type="text/javascript" src="../../library/dialog.js"></script>
39 <script language="JavaScript">
41 // callback from add_edit_drug.php or add_edit_drug_inventory.php:
42 function refreshme() {
43 location.reload();
46 // Process click on drug title.
47 function dodclick(id) {
48 dlgopen('add_edit_drug.php?drug=' + id, '_blank', 600, 475);
51 // Process click on drug QOO or lot.
52 function doiclick(id, lot) {
53 dlgopen('add_edit_lot.php?drug=' + id + '&lot=' + lot, '_blank', 600, 475);
56 </script>
58 </head>
60 <body <?echo $top_bg_line;?>>
61 <form method='post' action='drug_inventory.php'>
63 <table width='100%' cellpadding='1' cellspacing='2'>
64 <tr class='head'>
65 <td title='Click to edit'><? xl('Identifier','e'); ?></td>
66 <td><? xl('Name','e'); ?></td>
67 <td><? xl('NDC','e'); ?></td>
68 <td><? xl('Form','e'); ?></td>
69 <td><? xl('Size','e'); ?></td>
70 <td><? xl('Unit','e'); ?></td>
71 <td title='Click to receive (add) new lot'><? xl('Add','e'); ?></td>
72 <td title='Click to edit'><? xl('Lot','e'); ?></td>
73 <td><? xl('QOH','e'); ?></td>
74 <td><? xl('Expires','e'); ?></td>
75 </tr>
77 $lastid = "";
78 $encount = 0;
79 while ($row = sqlFetchArray($res)) {
80 if ($lastid != $row['drug_id']) {
81 ++$encount;
82 $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
83 $lastid = $row['drug_id'];
84 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
85 echo " <td onclick='dodclick($lastid)'>" .
86 "<a href='' onclick='return false'>" .
87 htmlentities($row['selector']) . "</a></td>\n";
88 echo " <td>" . htmlentities($row['name']) . "</td>\n";
89 echo " <td>" . htmlentities($row['ndc_number']) . "</td>\n";
90 echo " <td>" . $form_array[$row['form']] . "</td>\n";
91 echo " <td>" . $row['size'] . "</td>\n";
92 echo " <td>" . $unit_array[$row['unit']] . "</td>\n";
93 echo " <td onclick='doiclick($lastid,\"\")'>" .
94 "<a href='' onclick='return false'>Add</a></td>\n";
95 } else {
96 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
97 echo " <td colspan='7'>&nbsp;</td>\n";
99 if ($row['lot_number']) {
100 $lot_number = htmlentities($row['lot_number']);
101 echo " <td onclick='doiclick($lastid,\"$lot_number\")'>" .
102 "<a href='' onclick='return false'>$lot_number</a></td>\n";
103 echo " <td>" . $row['on_hand'] . "</td>\n";
104 echo " <td>" . $row['expiration'] . "</td>\n";
105 } else {
106 echo " <td colspan='3'>&nbsp;</td>\n";
108 echo " </tr>\n";
109 } // end while
111 </table>
113 <center><p>
114 <input type='button' value='<?xl('Add Drug','e'); ?>' onclick='dodclick(0)' style='background-color:transparent' />
115 </p></center>
117 </form>
118 </body>
119 </html>