2 // Copyright (C) 2006 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");
13 function QuotedOrNull($fld) {
14 if ($fld) return "'$fld'";
18 $drug_id = $_REQUEST['drug'];
19 $lot_id = $_REQUEST['lot'];
22 if (!acl_check('admin', 'drugs')) die("Not authorized!");
23 if (!$drug_id) die("Drug ID missing!");
27 <title
><?
echo $lot_id ?
"Edit" : "Add New" ?
> Lot
</title
>
28 <link rel
=stylesheet href
='<? echo $css_header ?>' type
='text/css'>
31 td
{ font
-size
:10pt
; }
34 <script type
="text/javascript" src
="../../library/overlib_mini.js"></script
>
35 <script type
="text/javascript" src
="../../library/calendar.js"></script
>
36 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
38 <script language
="JavaScript">
39 var mypcc
= '<? echo $GLOBALS['phone_country_code
'] ?>';
44 <body
<?
echo $top_bg_line;?
>>
46 // If we are saving, then save and close the window.
48 if ($_POST['form_save'] ||
$_POST['form_delete']) {
50 if ($_POST['form_save']) {
51 sqlStatement("UPDATE drug_inventory SET " .
52 "lot_number = '" . $_POST['form_lot_number'] . "', " .
53 "manufacturer = '" . $_POST['form_manufacturer'] . "', " .
54 "expiration = " . QuotedOrNull($form_expiration) . ", " .
55 "on_hand = '" . $_POST['form_on_hand'] . "' " .
56 "WHERE drug_id = '$drug_id' AND lot_number = '$lot_id'");
58 sqlStatement("DELETE FROM drug_inventory WHERE drug_id = '$drug_id' AND lot_number = '$lot_id'");
61 $drug_id = sqlInsert("INSERT INTO drug_inventory ( " .
62 "drug_id, lot_number, manufacturer, expiration, on_hand " .
65 "'" . $_POST['form_lot_number'] . "', " .
66 "'" . $_POST['form_manufacturer'] . "', " .
67 QuotedOrNull($form_expiration) . ", " .
68 "'" . $_POST['form_on_hand'] . "' " .
72 // Close this window and redisplay the updated list of drugs.
74 echo "<script language='JavaScript'>\n";
75 if ($info_msg) echo " alert('$info_msg');\n";
76 echo " window.close();\n";
77 echo " if (opener.refreshme) opener.refreshme();\n";
78 echo "</script></body></html>\n";
83 $row = sqlQuery("SELECT * FROM drug_inventory WHERE drug_id = '$drug_id' " .
84 "AND lot_number = '$lot_id'");
88 <!-- Required
for the popup date selectors
-->
89 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
91 <form method
='post' name
='theform' action
='add_edit_lot.php?drug=<?php echo $drug_id ?>&lot=<?php echo $lot_id ?>'>
94 <table border
='0' width
='100%'>
97 <td valign
='top' width
='1%' nowrap
><b
><?
xl('Lot Number','e'); ?
>:</b
></td
>
99 <input type
='text' size
='40' name
='form_lot_number' maxlength
='40' value
='<? echo $lot_id ?>' style
='width:100%' />
104 <td valign
='top' nowrap
><b
><?
xl('Manufacturer','e'); ?
>:</b
></td
>
106 <input type
='text' size
='40' name
='form_manufacturer' maxlength
='250' value
='<? echo $row['manufacturer
'] ?>' style
='width:100%' />
111 <td valign
='top' nowrap
><b
><?
xl('Expiration','e'); ?
>:</b
></td
>
113 <input type
='text' size
='10' name
='form_expiration' value
='<? echo $row['expiration
'] ?>'
114 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)'
115 title
='yyyy-mm-dd date of expiration' />
116 <a href
="javascript:show_calendar('theform.form_expiration')"
117 title
="Click here to choose a date"
118 ><img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22' border
='0'></a
>
123 <td valign
='top' nowrap
><b
><?
xl('On Hand','e'); ?
>:</b
></td
>
125 <input type
='text' size
='5' name
='form_on_hand' maxlength
='7' value
='<? echo $row['on_hand
'] ?>' />
132 <input type
='submit' name
='form_save' value
='Save' />
135 <input type
='button' value
='Cancel' onclick
='window.close()' />