Highway to PSR2
[openemr.git] / interface / drugs / destroy_lot.php
blob4f2389ee74c6493700aa7ce44e628ec8a857397b
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.
10 require_once("../globals.php");
11 require_once("$srcdir/acl.inc");
12 require_once("drugs.inc.php");
14 function QuotedOrNull($fld)
16 if ($fld) {
17 return "'".add_escape_custom($fld)."'";
20 return "NULL";
23 $drug_id = $_REQUEST['drug'];
24 $lot_id = $_REQUEST['lot'];
25 $info_msg = "";
27 if (!acl_check('admin', 'drugs')) {
28 die(xlt('Not authorized'));
31 if (!$drug_id) {
32 die(xlt('Drug ID missing!'));
35 if (!$lot_id) {
36 die(xlt('Lot ID missing!'));
39 <html>
40 <head>
41 <?php html_header_show();?>
42 <title><?php echo xlt('Destroy Lot') ?></title>
43 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
45 <style>
46 td { font-size:10pt; }
47 </style>
49 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
50 <script type="text/javascript" src="../../library/textformat.js"></script>
51 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
52 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
53 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
55 <script language="JavaScript">
56 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
57 </script>
59 </head>
61 <body class="body_top">
62 <?php
63 // If we are saving, then save and close the window.
65 if ($_POST['form_save']) {
66 sqlStatement("UPDATE drug_inventory SET " .
67 "destroy_date = " . QuotedOrNull($_POST['form_date']) . ", " .
68 "destroy_method = '" . add_escape_custom($_POST['form_method']) . "', " .
69 "destroy_witness = '" . add_escape_custom($_POST['form_witness']) . "', " .
70 "destroy_notes = '" . add_escape_custom($_POST['form_notes']) . "' " .
71 "WHERE drug_id = ? AND inventory_id = ?", array($drug_id,$lot_id));
73 // Close this window and redisplay the updated list of drugs.
75 echo "<script language='JavaScript'>\n";
76 if ($info_msg) {
77 echo " alert('".addslashes($info_msg)."');\n";
80 echo " window.close();\n";
81 echo " if (opener.refreshme) opener.refreshme();\n";
82 echo "</script></body></html>\n";
83 exit();
86 $row = sqlQuery("SELECT * FROM drug_inventory WHERE drug_id = ? " .
87 "AND inventory_id = ?", array($drug_id,$lot_id));
90 <form method='post' name='theform' action='destroy_lot.php?drug=<?php echo attr($drug_id) ?>&lot=<?php echo attr($lot_id) ?>'>
91 <center>
93 <table border='0' width='100%'>
95 <tr>
96 <td valign='top' width='1%' nowrap><b><?php echo xlt('Lot Number'); ?>:</b></td>
97 <td>
98 <?php echo text($row['lot_number']) ?>
99 </td>
100 </tr>
102 <tr>
103 <td valign='top' nowrap><b><?php echo xlt('Manufacturer'); ?>:</b></td>
104 <td>
105 <?php echo text($row['manufacturer']) ?>
106 </td>
107 </tr>
109 <tr>
110 <td valign='top' nowrap><b><?php echo xlt('Quantity On Hand'); ?>:</b></td>
111 <td>
112 <?php echo text($row['on_hand']) ?>
113 </td>
114 </tr>
116 <tr>
117 <td valign='top' nowrap><b><?php echo xlt('Expiration Date'); ?>:</b></td>
118 <td>
119 <?php echo text($row['expiration']) ?>
120 </td>
121 </tr>
123 <tr>
124 <td valign='top' nowrap><b><?php echo xlt('Date Destroyed'); ?>:</b></td>
125 <td>
126 <input type='text' size='10' name='form_date' id='form_date'
127 value='<?php echo $row['destroy_date'] ? attr($row['destroy_date']) : date("Y-m-d"); ?>'
128 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
129 title='<?php echo xla('yyyy-mm-dd date destroyed'); ?>' />
130 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
131 id='img_date' border='0' alt='[?]' style='cursor:pointer'
132 title='<?php echo xla('Click here to choose a date'); ?>'>
133 </td>
134 </tr>
136 <tr>
137 <td valign='top' nowrap><b><?php echo xlt('Method of Destruction'); ?>:</b></td>
138 <td>
139 <input type='text' size='40' name='form_method' maxlength='250'
140 value='<?php echo text($row['destroy_method']) ?>' style='width:100%' />
141 </td>
142 </tr>
144 <tr>
145 <td valign='top' nowrap><b><?php echo xlt('Witness'); ?>:</b></td>
146 <td>
147 <input type='text' size='40' name='form_witness' maxlength='250'
148 value='<?php echo text($row['destroy_witness']) ?>' style='width:100%' />
149 </td>
150 </tr>
152 <tr>
153 <td valign='top' nowrap><b><?php echo xlt('Notes'); ?>:</b></td>
154 <td>
155 <input type='text' size='40' name='form_notes' maxlength='250'
156 value='<?php echo text($row['destroy_notes']) ?>' style='width:100%' />
157 </td>
158 </tr>
160 </table>
163 <input type='submit' name='form_save' value='<?php echo xla('Submit') ;?>' />
165 &nbsp;
166 <input type='button' value='<?php echo xla('Cancel'); ?>' onclick='window.close()' />
167 </p>
169 </center>
170 </form>
171 <script language='JavaScript'>
172 Calendar.setup({inputField:"form_date", ifFormat:"%Y-%m-%d", button:"img_date"});
173 </script>
174 </body>
175 </html>