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 <?php
html_header_show();?
>
28 <title
><?php
echo $lot_id ?
xl("Edit") : xl("Add New"); xl(' Lot', 'e'); ?
></title
>
29 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
32 td
{ font
-size
:10pt
; }
35 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
36 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
37 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
38 <script type
="text/javascript" src
="../../library/dynarch_calendar_en.js"></script
>
39 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
41 <script language
="JavaScript">
43 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
46 var f
= document
.forms
[0];
47 if (f
.form_lot_number
.value
.search(/\S
/) < 0) {
48 alert('<?php xl('A lot number is required
!','e
'); ?>');
58 <body
class="body_top">
60 // If we are saving, then save and close the window.
62 if ($_POST['form_save'] ||
$_POST['form_delete']) {
64 if ($_POST['form_save']) {
65 sqlStatement("UPDATE drug_inventory SET " .
66 "lot_number = '" . $_POST['form_lot_number'] . "', " .
67 "manufacturer = '" . $_POST['form_manufacturer'] . "', " .
68 "expiration = " . QuotedOrNull($form_expiration) . ", " .
69 "on_hand = '" . $_POST['form_on_hand'] . "' " .
70 "WHERE drug_id = '$drug_id' AND inventory_id = '$lot_id'");
72 sqlStatement("DELETE FROM drug_inventory WHERE drug_id = '$drug_id' AND inventory_id = '$lot_id'");
75 $lot_id = sqlInsert("INSERT INTO drug_inventory ( " .
76 "drug_id, lot_number, manufacturer, expiration, on_hand " .
79 "'" . $_POST['form_lot_number'] . "', " .
80 "'" . $_POST['form_manufacturer'] . "', " .
81 QuotedOrNull($form_expiration) . ", " .
82 "'" . $_POST['form_on_hand'] . "' " .
86 // Close this window and redisplay the updated list of drugs.
88 echo "<script language='JavaScript'>\n";
89 if ($info_msg) echo " alert('$info_msg');\n";
90 echo " window.close();\n";
91 echo " if (opener.refreshme) opener.refreshme();\n";
92 echo "</script></body></html>\n";
97 $row = sqlQuery("SELECT * FROM drug_inventory WHERE drug_id = '$drug_id' " .
98 "AND inventory_id = '$lot_id'");
102 <form method
='post' name
='theform' action
='add_edit_lot.php?drug=<?php echo $drug_id ?>&lot=<?php echo $lot_id ?>'
103 onsubmit
='return validate()'>
106 <table border
='0' width
='100%'>
109 <td valign
='top' width
='1%' nowrap
><b
><?php
xl('Lot Number','e'); ?
>:</b
></td
>
111 <input type
='text' size
='40' name
='form_lot_number' maxlength
='40' value
='<?php echo $row['lot_number
'] ?>' style
='width:100%' />
116 <td valign
='top' nowrap
><b
><?php
xl('Manufacturer','e'); ?
>:</b
></td
>
118 <input type
='text' size
='40' name
='form_manufacturer' maxlength
='250' value
='<?php echo $row['manufacturer
'] ?>' style
='width:100%' />
123 <td valign
='top' nowrap
><b
><?php
xl('Expiration','e'); ?
>:</b
></td
>
125 <input type
='text' size
='10' name
='form_expiration' id
='form_expiration'
126 value
='<?php echo $row['expiration
'] ?>'
127 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)'
128 title
='yyyy-mm-dd date of expiration' />
129 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
130 id
='img_expiration' border
='0' alt
='[?]' style
='cursor:pointer'
131 title
='Click here to choose a date'>
136 <td valign
='top' nowrap
><b
><?php
xl('On Hand','e'); ?
>:</b
></td
>
138 <input type
='text' size
='5' name
='form_on_hand' maxlength
='7' value
='<?php echo $row['on_hand
'] ?>' />
145 <input type
='submit' name
='form_save' value
='<?php xl('Save
','e
'); ?>' />
148 <input type
='button' value
='<?php xl('Destroy
...','e
'); ?>'
149 onclick
="window.location.href='destroy_lot.php?drug=<?php echo $drug_id ?>&lot=<?php echo $lot_id ?>'" />
152 <input type
='button' value
='<?php xl('Cancel
','e
'); ?>' onclick
='window.close()' />
157 <script language
='JavaScript'>
158 Calendar
.setup({inputField
:"form_expiration", ifFormat
:"%Y-%m-%d", button
:"img_expiration"});