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 $sanitize_all_escapes = true;
10 $fake_register_globals = false;
12 require_once("../globals.php");
13 require_once("$srcdir/acl.inc");
14 require_once("drugs.inc.php");
15 require_once("$srcdir/options.inc.php");
16 require_once("$srcdir/formatting.inc.php");
17 require_once("$srcdir/htmlspecialchars.inc.php");
19 // Check authorization.
20 $thisauth = acl_check('admin', 'drugs');
21 if (!$thisauth) die(xlt('Not authorized'));
23 // For each sorting option, specify the ORDER BY argument.
26 'prod' => 'd.name, d.drug_id, di.expiration, di.lot_number',
27 'ndc' => 'd.ndc_number, d.name, d.drug_id, di.expiration, di.lot_number',
28 'form' => 'lof.title, d.name, d.drug_id, di.expiration, di.lot_number',
29 'lot' => 'di.lot_number, d.name, d.drug_id, di.expiration',
30 'wh' => 'lo.title, d.name, d.drug_id, di.expiration, di.lot_number',
31 'qoh' => 'di.on_hand, d.name, d.drug_id, di.expiration, di.lot_number',
32 'exp' => 'di.expiration, d.name, d.drug_id, di.lot_number',
35 // Get the order hash array value and key for this request.
36 $form_orderby = $ORDERHASH[$_REQUEST['form_orderby']] ?
$_REQUEST['form_orderby'] : 'prod';
37 $orderby = $ORDERHASH[$form_orderby];
40 $res = sqlStatement("SELECT d.*, " .
41 "di.inventory_id, di.lot_number, di.expiration, di.manufacturer, " .
42 "di.on_hand, lo.title " .
44 "LEFT JOIN drug_inventory AS di ON di.drug_id = d.drug_id " .
45 "AND di.destroy_date IS NULL " .
46 "LEFT JOIN list_options AS lo ON lo.list_id = 'warehouse' AND " .
47 "lo.option_id = di.warehouse_id " .
48 "LEFT JOIN list_options AS lof ON lof.list_id = 'drug_form' AND " .
49 "lof.option_id = d.form " .
55 <?php
html_header_show();?
>
57 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
58 <title
><?php
echo xlt('Drug Inventory'); ?
></title
>
61 tr
.head
{ font
-size
:10pt
; background
-color
:#cccccc; text-align:center; }
62 tr
.detail
{ font
-size
:10pt
; }
63 a
, a
:visited
, a
:hover
{ color
:#0000cc; }
66 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
68 <script language
="JavaScript">
70 // callback from add_edit_drug.php or add_edit_drug_inventory.php:
71 function refreshme() {
75 // Process click on drug title.
76 function dodclick(id
) {
77 dlgopen('add_edit_drug.php?drug=' + id
, '_blank', 725, 475);
80 // Process click on drug QOO or lot.
81 function doiclick(id
, lot
) {
82 dlgopen('add_edit_lot.php?drug=' + id +
'&lot=' + lot
, '_blank', 600, 475);
85 // Process click on a column header for sorting.
86 function dosort(orderby
) {
87 var f
= document
.forms
[0];
88 f
.form_orderby
.value
= orderby
;
98 <body
class="body_top">
99 <form method
='post' action
='drug_inventory.php'>
101 <table width
='100%' cellpadding
='1' cellspacing
='2'>
103 <td title
='<?php echo xla('Click to edit
'); ?>'>
104 <a href
="#" onclick
="return dosort('prod')"
105 <?php
if ($form_orderby == "prod") echo " style=\"color:#00cc00\""; ?
>>
106 <?php
echo xlt('Name'); ?
> </a
>
109 <?php
echo xlt('Act'); ?
>
112 <a href
="#" onclick
="return dosort('ndc')"
113 <?php
if ($form_orderby == "ndc") echo " style=\"color:#00cc00\""; ?
>>
114 <?php
echo xlt('NDC'); ?
> </a
>
117 <a href
="#" onclick
="return dosort('form')"
118 <?php
if ($form_orderby == "form") echo " style=\"color:#00cc00\""; ?
>>
119 <?php
echo xlt('Form'); ?
> </a
>
122 <?php
echo xlt('Size'); ?
>
125 <?php
echo xlt('Unit'); ?
>
127 <td title
='<?php echo xla('Click to
receive (add
) new lot
'); ?>'>
128 <?php
echo xlt('New'); ?
>
130 <td title
='<?php echo xla('Click to edit
'); ?>'>
131 <a href
="#" onclick
="return dosort('lot')"
132 <?php
if ($form_orderby == "lot") echo " style=\"color:#00cc00\""; ?
>>
133 <?php
echo xlt('Lot'); ?
> </a
>
136 <a href
="#" onclick
="return dosort('wh')"
137 <?php
if ($form_orderby == "wh") echo " style=\"color:#00cc00\""; ?
>>
138 <?php
echo xlt('Warehouse'); ?
> </a
>
141 <a href
="#" onclick
="return dosort('qoh')"
142 <?php
if ($form_orderby == "qoh") echo " style=\"color:#00cc00\""; ?
>>
143 <?php
echo xlt('QOH'); ?
> </a
>
146 <a href
="#" onclick
="return dosort('exp')"
147 <?php
if ($form_orderby == "exp") echo " style=\"color:#00cc00\""; ?
>>
148 <?php
echo xlt('Expires'); ?
> </a
>
154 while ($row = sqlFetchArray($res)) {
155 if ($lastid != $row['drug_id']) {
157 $bgcolor = "#" . (($encount & 1) ?
"ddddff" : "ffdddd");
158 $lastid = $row['drug_id'];
159 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
160 echo " <td onclick='dodclick(".attr($lastid).")'>" .
161 "<a href='' onclick='return false'>" .
162 text($row['name']) . "</a></td>\n";
163 echo " <td>" . ($row['active'] ?
xlt('Yes') : xlt('No')) . "</td>\n";
164 echo " <td>" . text($row['ndc_number']) . "</td>\n";
166 generate_display_field(array('data_type'=>'1','list_id'=>'drug_form'), $row['form']) .
168 echo " <td>" . text($row['size']) . "</td>\n";
170 generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'), $row['unit']) .
172 echo " <td onclick='doiclick(".attr($lastid).",0)' title='" . xla('Add new lot and transaction') . "'>" .
173 "<a href='' onclick='return false'>" . xlt('New') . "</a></td>\n";
175 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
176 echo " <td colspan='7'> </td>\n";
178 if (!empty($row['inventory_id'])) {
179 echo " <td onclick='doiclick(" . attr($lastid) . "," . attr($row['inventory_id']) . ")'>" .
180 "<a href='' onclick='return false'>" . text($row['lot_number']) . "</a></td>\n";
181 echo " <td>" . text($row['title']) . "</td>\n";
182 echo " <td>" . text($row['on_hand']) . "</td>\n";
183 echo " <td>" . text(oeFormatShortDate($row['expiration'])) . "</td>\n";
185 echo " <td colspan='4'> </td>\n";
193 <input type
='button' value
='<?php echo xla('Add Drug
'); ?>' onclick
='dodclick(0)' style
='background-color:transparent' />
196 <input type
="hidden" name
="form_orderby" value
="<?php echo attr($form_orderby) ?>" />