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 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 // For each sorting option, specify the ORDER BY argument.
22 'prod' => 'd.name, d.drug_id, di.expiration, di.lot_number',
23 'ndc' => 'd.ndc_number, d.name, d.drug_id, di.expiration, di.lot_number',
24 'form' => 'lof.title, d.name, d.drug_id, di.expiration, di.lot_number',
25 'lot' => 'di.lot_number, d.name, d.drug_id, di.expiration',
26 'wh' => 'lo.title, d.name, d.drug_id, di.expiration, di.lot_number',
27 'qoh' => 'di.on_hand, d.name, d.drug_id, di.expiration, di.lot_number',
28 'exp' => 'di.expiration, d.name, d.drug_id, di.lot_number',
31 // Get the order hash array value and key for this request.
32 $form_orderby = $ORDERHASH[$_REQUEST['form_orderby']] ?
$_REQUEST['form_orderby'] : 'prod';
33 $orderby = $ORDERHASH[$form_orderby];
36 $res = sqlStatement("SELECT d.*, " .
37 "di.inventory_id, di.lot_number, di.expiration, di.manufacturer, " .
38 "di.on_hand, lo.title " .
40 "LEFT JOIN drug_inventory AS di ON di.drug_id = d.drug_id " .
41 "AND di.destroy_date IS NULL " .
42 "LEFT JOIN list_options AS lo ON lo.list_id = 'warehouse' AND " .
43 "lo.option_id = di.warehouse_id " .
44 "LEFT JOIN list_options AS lof ON lof.list_id = 'drug_form' AND " .
45 "lof.option_id = d.form " .
51 <?php
html_header_show();?
>
53 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
54 <title
><?php
xl('Drug Inventory','e'); ?
></title
>
57 tr
.head
{ font
-size
:10pt
; background
-color
:#cccccc; text-align:center; }
58 tr
.detail
{ font
-size
:10pt
; }
59 a
, a
:visited
, a
:hover
{ color
:#0000cc; }
62 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
64 <script language
="JavaScript">
66 // callback from add_edit_drug.php or add_edit_drug_inventory.php:
67 function refreshme() {
71 // Process click on drug title.
72 function dodclick(id
) {
73 dlgopen('add_edit_drug.php?drug=' + id
, '_blank', 725, 475);
76 // Process click on drug QOO or lot.
77 function doiclick(id
, lot
) {
78 dlgopen('add_edit_lot.php?drug=' + id +
'&lot=' + lot
, '_blank', 600, 475);
81 // Process click on a column header for sorting.
82 function dosort(orderby
) {
83 var f
= document
.forms
[0];
84 f
.form_orderby
.value
= orderby
;
94 <body
class="body_top">
95 <form method
='post' action
='drug_inventory.php'>
97 <table width
='100%' cellpadding
='1' cellspacing
='2'>
99 <td title
='<?php echo htmlspecialchars(xl('Click to edit
'), ENT_QUOTES); ?>'>
100 <a href
="#" onclick
="return dosort('prod')"
101 <?php
if ($form_orderby == "prod") echo " style=\"color:#00cc00\""; ?
>>
102 <?php
echo htmlspecialchars(xl('Name')); ?
> </a
>
105 <?php
echo htmlspecialchars(xl('Act')); ?
>
108 <a href
="#" onclick
="return dosort('ndc')"
109 <?php
if ($form_orderby == "ndc") echo " style=\"color:#00cc00\""; ?
>>
110 <?php
echo htmlspecialchars(xl('NDC')); ?
> </a
>
113 <a href
="#" onclick
="return dosort('form')"
114 <?php
if ($form_orderby == "form") echo " style=\"color:#00cc00\""; ?
>>
115 <?php
echo htmlspecialchars(xl('Form')); ?
> </a
>
118 <?php
echo htmlspecialchars(xl('Size')); ?
>
121 <?php
echo htmlspecialchars(xl('Unit')); ?
>
123 <td title
='<?php echo htmlspecialchars(xl('Click to
receive (add
) new lot
'), ENT_QUOTES); ?>'>
124 <?php
echo htmlspecialchars(xl('New')); ?
>
126 <td title
='<?php echo htmlspecialchars(xl('Click to edit
'), ENT_QUOTES); ?>'>
127 <a href
="#" onclick
="return dosort('lot')"
128 <?php
if ($form_orderby == "lot") echo " style=\"color:#00cc00\""; ?
>>
129 <?php
echo htmlspecialchars(xl('Lot')); ?
> </a
>
132 <a href
="#" onclick
="return dosort('wh')"
133 <?php
if ($form_orderby == "wh") echo " style=\"color:#00cc00\""; ?
>>
134 <?php
echo htmlspecialchars(xl('Warehouse')); ?
> </a
>
137 <a href
="#" onclick
="return dosort('qoh')"
138 <?php
if ($form_orderby == "qoh") echo " style=\"color:#00cc00\""; ?
>>
139 <?php
echo htmlspecialchars(xl('QOH')); ?
> </a
>
142 <a href
="#" onclick
="return dosort('exp')"
143 <?php
if ($form_orderby == "exp") echo " style=\"color:#00cc00\""; ?
>>
144 <?php
echo htmlspecialchars(xl('Expires')); ?
> </a
>
150 while ($row = sqlFetchArray($res)) {
151 if ($lastid != $row['drug_id']) {
153 $bgcolor = "#" . (($encount & 1) ?
"ddddff" : "ffdddd");
154 $lastid = $row['drug_id'];
155 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
156 echo " <td onclick='dodclick($lastid)'>" .
157 "<a href='' onclick='return false'>" .
158 htmlentities($row['name']) . "</a></td>\n";
159 echo " <td>" . ($row['active'] ?
xl('Yes') : xl('No')) . "</td>\n";
160 echo " <td>" . htmlentities($row['ndc_number']) . "</td>\n";
162 generate_display_field(array('data_type'=>'1','list_id'=>'drug_form'), $row['form']) .
164 echo " <td>" . $row['size'] . "</td>\n";
166 generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'), $row['unit']) .
168 echo " <td onclick='doiclick($lastid,0)' title='" . xl('Add new lot and transaction') . "'>" .
169 "<a href='' onclick='return false'>" . xl('New') . "</a></td>\n";
171 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
172 echo " <td colspan='7'> </td>\n";
174 if (!empty($row['inventory_id'])) {
175 $lot_number = htmlentities($row['lot_number']);
176 echo " <td onclick='doiclick($lastid," . $row['inventory_id'] . ")'>" .
177 "<a href='' onclick='return false'>$lot_number</a></td>\n";
178 echo " <td>" . $row['title'] . "</td>\n";
179 echo " <td>" . $row['on_hand'] . "</td>\n";
180 echo " <td>" . oeFormatShortDate($row['expiration']) . "</td>\n";
182 echo " <td colspan='4'> </td>\n";
190 <input type
='button' value
='<?php echo htmlspecialchars(xl('Add Drug
')); ?>' onclick
='dodclick(0)' style
='background-color:transparent' />
193 <input type
="hidden" name
="form_orderby" value
="<?php echo $form_orderby ?>" />