Support for text insert embedded function, named 'replace' added.
[openemr.git] / interface / drugs / add_edit_lot.php
blob011e8dd719c3a41273b7976eab5a5c0443cb1760
1 <?php
2 // Copyright (C) 2006 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("drugs.inc.php");
13 function QuotedOrNull($fld) {
14 if ($fld) return "'$fld'";
15 return "NULL";
18 $drug_id = $_REQUEST['drug'];
19 $lot_id = $_REQUEST['lot'];
20 $info_msg = "";
22 if (!acl_check('admin', 'drugs')) die("Not authorized!");
23 if (!$drug_id) die("Drug ID missing!");
25 <html>
26 <head>
27 <title><? echo $lot_id ? "Edit" : "Add New" ?> Lot</title>
28 <link rel=stylesheet href='<? echo $css_header ?>' type='text/css'>
30 <style>
31 td { font-size:10pt; }
32 </style>
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'] ?>';
40 </script>
42 </head>
44 <body <?echo $top_bg_line;?>>
45 <?php
46 // If we are saving, then save and close the window.
48 if ($_POST['form_save'] || $_POST['form_delete']) {
49 if ($lot_id) {
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'");
57 } else {
58 sqlStatement("DELETE FROM drug_inventory WHERE drug_id = '$drug_id' AND lot_number = '$lot_id'");
60 } else {
61 $drug_id = sqlInsert("INSERT INTO drug_inventory ( " .
62 "drug_id, lot_number, manufacturer, expiration, on_hand " .
63 ") VALUES ( " .
64 "'$drug_id', " .
65 "'" . $_POST['form_lot_number'] . "', " .
66 "'" . $_POST['form_manufacturer'] . "', " .
67 QuotedOrNull($form_expiration) . ", " .
68 "'" . $_POST['form_on_hand'] . "' " .
69 ")");
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";
79 exit();
82 if ($lot_id) {
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 ?>'>
92 <center>
94 <table border='0' width='100%'>
96 <tr>
97 <td valign='top' width='1%' nowrap><b><? xl('Lot Number','e'); ?>:</b></td>
98 <td>
99 <input type='text' size='40' name='form_lot_number' maxlength='40' value='<? echo $lot_id ?>' style='width:100%' />
100 </td>
101 </tr>
103 <tr>
104 <td valign='top' nowrap><b><? xl('Manufacturer','e'); ?>:</b></td>
105 <td>
106 <input type='text' size='40' name='form_manufacturer' maxlength='250' value='<? echo $row['manufacturer'] ?>' style='width:100%' />
107 </td>
108 </tr>
110 <tr>
111 <td valign='top' nowrap><b><? xl('Expiration','e'); ?>:</b></td>
112 <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>
119 </td>
120 </tr>
122 <tr>
123 <td valign='top' nowrap><b><? xl('On Hand','e'); ?>:</b></td>
124 <td>
125 <input type='text' size='5' name='form_on_hand' maxlength='7' value='<? echo $row['on_hand'] ?>' />
126 </td>
127 </tr>
129 </table>
132 <input type='submit' name='form_save' value='Save' />
134 &nbsp;
135 <input type='button' value='Cancel' onclick='window.close()' />
136 </p>
138 </center>
139 </form>
140 </body>
141 </html>