Merge branch 'master' of git://github.com/openemr/openemr
[openemr.git] / interface / drugs / drug_inventory.php
blob92e5784a61c7009e65604e3020d4d8ae8e323e4f
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 require_once("../globals.php");
10 require_once("$srcdir/acl.inc");
11 require_once("drugs.inc.php");
12 require_once("$srcdir/options.inc.php");
13 require_once("$srcdir/formatting.inc.php");
15 // Check authorization.
16 $thisauth = acl_check('admin', 'drugs');
17 if (!$thisauth) die(xl('Not authorized'));
19 // get drugs
20 $res = sqlStatement("SELECT d.*, " .
21 "di.inventory_id, di.lot_number, di.expiration, di.manufacturer, di.on_hand " .
22 "FROM drugs AS d " .
23 "LEFT OUTER JOIN drug_inventory AS di ON di.drug_id = d.drug_id " .
24 "AND di.destroy_date IS NULL " .
25 "ORDER BY d.name, d.drug_id, di.expiration, di.lot_number");
27 <html>
29 <head>
30 <?php html_header_show();?>
32 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
33 <title><?php xl('Drug Inventory','e'); ?></title>
35 <style>
36 tr.head { font-size:10pt; background-color:#cccccc; text-align:center; }
37 tr.detail { font-size:10pt; }
38 a, a:visited, a:hover { color:#0000cc; }
39 </style>
41 <script type="text/javascript" src="../../library/dialog.js"></script>
43 <script language="JavaScript">
45 // callback from add_edit_drug.php or add_edit_drug_inventory.php:
46 function refreshme() {
47 location.reload();
50 // Process click on drug title.
51 function dodclick(id) {
52 dlgopen('add_edit_drug.php?drug=' + id, '_blank', 725, 475);
55 // Process click on drug QOO or lot.
56 function doiclick(id, lot) {
57 dlgopen('add_edit_lot.php?drug=' + id + '&lot=' + lot, '_blank', 600, 475);
60 </script>
62 </head>
64 <body class="body_top">
65 <form method='post' action='drug_inventory.php'>
67 <table width='100%' cellpadding='1' cellspacing='2'>
68 <tr class='head'>
69 <td title=<?php xl('Click to edit','e','\'','\''); ?>><?php xl('Name','e'); ?></td>
70 <td><?php xl('Act','e'); ?></td>
71 <td><?php xl('NDC','e'); ?></td>
72 <td><?php xl('Form','e'); ?></td>
73 <td><?php xl('Size','e'); ?></td>
74 <td><?php xl('Unit','e'); ?></td>
75 <td title=<?php xl('Click to receive (add) new lot','e','\'','\''); ?>><?php xl('New','e'); ?></td>
76 <td title=<?php xl('Click to edit','e','\'','\''); ?>><?php xl('Lot','e'); ?></td>
77 <td><?php xl('QOH','e'); ?></td>
78 <td><?php xl('Expires','e'); ?></td>
79 </tr>
80 <?php
81 $lastid = "";
82 $encount = 0;
83 while ($row = sqlFetchArray($res)) {
84 if ($lastid != $row['drug_id']) {
85 ++$encount;
86 $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
87 $lastid = $row['drug_id'];
88 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
89 echo " <td onclick='dodclick($lastid)'>" .
90 "<a href='' onclick='return false'>" .
91 htmlentities($row['name']) . "</a></td>\n";
92 echo " <td>" . ($row['active'] ? xl('Yes') : xl('No')) . "</td>\n";
93 echo " <td>" . htmlentities($row['ndc_number']) . "</td>\n";
94 echo " <td>" .
95 generate_display_field(array('data_type'=>'1','list_id'=>'drug_form'), $row['form']) .
96 "</td>\n";
97 echo " <td>" . $row['size'] . "</td>\n";
98 echo " <td>" .
99 generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'), $row['unit']) .
100 "</td>\n";
101 echo " <td onclick='doiclick($lastid,0)' title='" . xl('Add new lot and transaction') . "'>" .
102 "<a href='' onclick='return false'>" . xl('New') . "</a></td>\n";
103 } else {
104 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
105 echo " <td colspan='7'>&nbsp;</td>\n";
107 if (!empty($row['inventory_id'])) {
108 $lot_number = htmlentities($row['lot_number']);
109 echo " <td onclick='doiclick($lastid," . $row['inventory_id'] . ")'>" .
110 "<a href='' onclick='return false'>$lot_number</a></td>\n";
111 echo " <td>" . $row['on_hand'] . "</td>\n";
112 echo " <td>" . oeFormatShortDate($row['expiration']) . "</td>\n";
113 } else {
114 echo " <td colspan='3'>&nbsp;</td>\n";
116 echo " </tr>\n";
117 } // end while
119 </table>
121 <center><p>
122 <input type='button' value='<?php xl('Add Drug','e'); ?>' onclick='dodclick(0)' style='background-color:transparent' />
123 </p></center>
125 </form>
126 </body>
127 </html>