some optimization for IPPF forms
[openemr.git] / interface / reports / inventory_list.php
blob0049582ab360de68ffafc697f76e3dd3322f4f5d
1 <?php
2 // Copyright (C) 2008 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("$include_root/drugs/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.*, SUM(di.on_hand) AS on_hand " .
19 "FROM drugs AS d " .
20 "LEFT OUTER JOIN drug_inventory AS di ON di.drug_id = d.drug_id " .
21 "AND di.on_hand != 0 AND di.destroy_date IS NULL " .
22 "GROUP BY d.name, d.drug_id ORDER BY d.name, d.drug_id");
24 <html>
26 <head>
27 <?php html_header_show(); ?>
29 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
30 <title><?php xl('Inventory List','e'); ?></title>
32 <style>
33 tr.head { font-size:10pt; background-color:#cccccc; text-align:center; }
34 tr.detail { font-size:10pt; }
35 a, a:visited, a:hover { color:#0000cc; }
36 </style>
38 <script type="text/javascript" src="../../library/dialog.js"></script>
40 <script language="JavaScript">
41 </script>
43 </head>
45 <body>
46 <center>
48 <form method='post' action='inventory_list.php' name='theform'>
49 <table border='0' cellpadding='5' cellspacing='0' width='98%'>
50 <tr>
51 <td class='title'>
52 <?php xl('Inventory List','e'); ?>
53 </td>
54 <td class='text' align='right'>
55 <input type="button" value="Print" onclick="window.print()">
56 </td>
57 </tr>
58 </table>
59 </form>
61 <table width='98%' cellpadding='2' cellspacing='2'>
62 <thead style='display:table-header-group'>
63 <tr class='head'>
64 <th><?php xl('NDC','e'); ?></th>
65 <th><?php xl('Name','e'); ?></th>
66 <th><?php xl('Form','e'); ?></th>
67 <th align='right'><?php xl('QOH','e'); ?></th>
68 </tr>
69 </thead>
70 <tbody>
71 <?php
72 $encount = 0;
73 while ($row = sqlFetchArray($res)) {
74 ++$encount;
75 $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
76 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
77 echo " <td>" . htmlentities($row['ndc_number']) . "</td>\n";
78 echo " <td>" . htmlentities($row['name']) . "</td>\n";
79 echo " <td>" . $form_array[$row['form']] . "</td>\n";
80 echo " <td align='right'>" . $row['on_hand'] . "</td>\n";
81 echo " </tr>\n";
84 </tbody>
85 </table>
87 </center>
88 </body>
89 </html>