address book based on users table
[openemr.git] / interface / usergroup / addrbook_edit.php
bloba8300d0bc55519fcc1568c77ce6ec20ca210c97b
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 include_once("../globals.php");
10 include_once("$srcdir/acl.inc");
12 $userid = $_REQUEST['userid'];
14 $info_msg = "";
16 function QuotedOrNull($fld) {
17 $fld = trim($fld);
18 if (!get_magic_quotes_gpc()) $fld = addslashes($fld);
19 if ($fld) return "'$fld'";
20 return "NULL";
23 function invalue($name) {
24 $fld = trim($_POST[$name]);
25 if (!get_magic_quotes_gpc()) $fld = addslashes($fld);
26 return "'$fld'";
29 function rbinput($name, $value, $desc, $colname) {
30 global $row;
31 $ret = "<input type='radio' name='$name' value='$value'";
32 if ($row[$colname] == $value) $ret .= " checked";
33 $ret .= " />$desc";
34 return $ret;
37 function rbvalue($rbname) {
38 $tmp = $_POST[$rbname];
39 if (! $tmp) $tmp = '0';
40 return "'$tmp'";
44 <html>
45 <head>
46 <title><?php echo $userid ? "Edit" : "Add New" ?> Person</title>
47 <link rel=stylesheet href='<?php echo $css_header ?>' type='text/css'>
49 <style>
50 td { font-size:10pt; }
52 .inputtext {
54 font-family:monospace;
55 font-size:10pt;
56 font-weight:normal;
57 border-style:solid;
58 border-width:1px;
59 border-color: #000000;
60 background-color:transparent;
62 padding-left:2px;
63 padding-right:2px;
66 .button {
67 font-family:sans-serif;
68 font-size:9pt;
69 font-weight:bold;
71 </style>
73 <script language="JavaScript">
74 </script>
76 </head>
78 <body <?echo $top_bg_line;?>>
79 <?php
80 // If we are saving, then save and close the window.
82 if ($_POST['form_save']) {
84 if ($userid) {
86 $query = "UPDATE users SET " .
87 "title = " . invalue('form_title') . ", " .
88 "fname = " . invalue('form_fname') . ", " .
89 "lname = " . invalue('form_lname') . ", " .
90 "mname = " . invalue('form_mname') . ", " .
91 "specialty = " . invalue('form_specialty') . ", " .
92 "assistant = " . invalue('form_assistant') . ", " .
93 "federaltaxid = " . invalue('form_federaltaxid') . ", " .
94 "upin = " . invalue('form_upin') . ", " .
95 "npi = " . invalue('form_npi') . ", " .
96 "email = " . invalue('form_email') . ", " .
97 "url = " . invalue('form_url') . ", " .
98 "street = " . invalue('form_street') . ", " .
99 "city = " . invalue('form_city') . ", " .
100 "state = " . invalue('form_state') . ", " .
101 "zip = " . invalue('form_zip') . ", " .
102 "street2 = " . invalue('form_street2') . ", " .
103 "city2 = " . invalue('form_city2') . ", " .
104 "state2 = " . invalue('form_state2') . ", " .
105 "zip2 = " . invalue('form_zip2') . ", " .
106 "phone = " . invalue('form_phone') . ", " .
107 "phonew1 = " . invalue('form_phonew1') . ", " .
108 "phonew2 = " . invalue('form_phonew2') . ", " .
109 "phonecell = " . invalue('form_phonecell') . ", " .
110 "fax = " . invalue('form_fax') . " " .
111 "WHERE id = '$userid'";
112 sqlStatement($query);
114 } else {
116 $userid = sqlInsert("INSERT INTO users ( " .
117 "username, password, authorized, info, source, " .
118 "title, fname, lname, mname, " .
119 "federaltaxid, federaldrugid, upin, facility, see_auth, active, " .
120 "npi, specialty, assistant, billname, email, url, " .
121 "street, city, state, zip, " .
122 "street2, city2, state2, zip2, " .
123 "phone, phonew1, phonew2, phonecell, fax " .
124 ") VALUES ( " .
125 "'', " . // username
126 "'', " . // password
127 "0, " . // authorized
128 "'', " . // info
129 "NULL, " . // source
130 invalue('form_title') . ", " .
131 invalue('form_fname') . ", " .
132 invalue('form_lname') . ", " .
133 invalue('form_mname') . ", " .
134 invalue('form_federaltaxid') . ", " .
135 "'', " . // federaldrugid
136 invalue('form_upin') . ", " .
137 "'', " . // facility
138 "0, " . // see_auth
139 "1, " . // active
140 invalue('form_npi') . ", " .
141 invalue('form_specialty') . ", " .
142 invalue('form_assistant') . ", " .
143 "'', " . // billname
144 invalue('form_email') . ", " .
145 invalue('form_url') . ", " .
146 invalue('form_street') . ", " .
147 invalue('form_city') . ", " .
148 invalue('form_state') . ", " .
149 invalue('form_zip') . ", " .
150 invalue('form_street2') . ", " .
151 invalue('form_city2') . ", " .
152 invalue('form_state2') . ", " .
153 invalue('form_zip2') . ", " .
154 invalue('form_phone') . ", " .
155 invalue('form_phonew1') . ", " .
156 invalue('form_phonew2') . ", " .
157 invalue('form_phonecell') . ", " .
158 invalue('form_fax') . " " .
159 ")");
164 else if ($_POST['form_delete']) {
166 if ($userid) {
167 // Be careful not to delete internal users.
168 sqlStatement("DELETE FROM users WHERE id = '$userid' AND username = ''");
173 if ($_POST['form_save'] || $_POST['form_delete']) {
174 // Close this window and redisplay the updated list.
175 echo "<script language='JavaScript'>\n";
176 if ($info_msg) echo " alert('$info_msg');\n";
177 echo " window.close();\n";
178 echo " if (opener.refreshme) opener.refreshme();\n";
179 echo "</script></body></html>\n";
180 exit();
183 if ($userid) {
184 $row = sqlQuery("SELECT * FROM users WHERE id = '$userid'");
187 <form method='post' name='theform' action='addrbook_edit.php?userid=<?php echo $userid ?>'>
188 <center>
190 <table border='0' width='100%'>
192 <tr>
193 <td width='1%' nowrap><b><?php xl('Name','e'); ?>:</b></td>
194 <td>
195 <select name='form_title'>
196 <option value=''></option>
197 <?php
198 foreach (array('Mr.', 'Mrs.', 'Ms.', 'Dr.') as $value) {
199 echo " <option value='$value'";
200 if ($value == $row['title']) echo " selected";
201 echo ">$value</option>\n";
204 </select>
205 <b>Last:</b><input type='text' size='10' name='form_lname' class='inputtext'
206 maxlength='50' value='<?php echo $row['lname'] ?>'/>&nbsp;
207 <b>First:</b> <input type='text' size='10' name='form_fname' class='inputtext'
208 maxlength='50' value='<?php echo $row['fname'] ?>' />&nbsp;
209 <b>Middle:</b> <input type='text' size='4' name='form_mname' class='inputtext'
210 maxlength='50' value='<?php echo $row['mname'] ?>' />
211 </td>
212 </tr>
214 <tr>
215 <td nowrap><b><?php xl('Specialty','e'); ?>:</b></td>
216 <td>
217 <input type='text' size='40' name='form_specialty' maxlength='250'
218 value='<?php echo $row['specialty'] ?>'
219 style='width:100%' class='inputtext' />
220 </td>
221 </tr>
223 <tr>
224 <td nowrap><b><?php xl('Home Phone','e'); ?>:</b></td>
225 <td>
226 <input type='text' size='11' name='form_phone' value='<?php echo $row['phone'] ?>'
227 maxlength='30' class='inputtext' />&nbsp;
228 <b>Mobile:</b><input type='text' size='11' name='form_phonecell'
229 maxlength='30' value='<?php echo $row['phonecell'] ?>' class='inputtext' />
230 </td>
231 </tr>
233 <tr>
234 <td nowrap><b><?php xl('Work Phone','e'); ?>:</b></td>
235 <td>
236 <input type='text' size='11' name='form_phonew1' value='<?php echo $row['phonew1'] ?>'
237 maxlength='30' class='inputtext' />&nbsp;
238 <b>2nd:</b><input type='text' size='11' name='form_phonew2' value='<?php echo $row['phonew2'] ?>'
239 maxlength='30' class='inputtext' />&nbsp;
240 <b>Fax:</b> <input type='text' size='11' name='form_fax' value='<?php echo $row['fax'] ?>'
241 maxlength='30' class='inputtext' />
242 </td>
243 </tr>
245 <tr>
246 <td nowrap><b><?php xl('Assistant','e'); ?>:</b></td>
247 <td>
248 <input type='text' size='40' name='form_assistant' maxlength='250'
249 value='<?php echo $row['assistant'] ?>'
250 style='width:100%' class='inputtext' />
251 </td>
252 </tr>
254 <tr>
255 <td nowrap><b><?php xl('Email','e'); ?>:</b></td>
256 <td>
257 <input type='text' size='40' name='form_email' maxlength='250'
258 value='<?php echo $row['email'] ?>'
259 style='width:100%' class='inputtext' />
260 </td>
261 </tr>
263 <tr>
264 <td nowrap><b><?php xl('Website','e'); ?>:</b></td>
265 <td>
266 <input type='text' size='40' name='form_url' maxlength='250'
267 value='<?php echo $row['url'] ?>'
268 style='width:100%' class='inputtext' />
269 </td>
270 </tr>
272 <tr>
273 <td nowrap><b><?php xl('Main Address','e'); ?>:</b></td>
274 <td>
275 <input type='text' size='40' name='form_street' maxlength='60'
276 value='<?php echo $row['street'] ?>'
277 style='width:100%' class='inputtext' />
278 </td>
279 </tr>
281 <tr>
282 <td nowrap><b><?php xl('City','e'); ?>:</b></td>
283 <td>
284 <input type='text' size='10' name='form_city' maxlength='30'
285 value='<?php echo $row['city'] ?>' class='inputtext' />&nbsp;
286 <b>State/county:</b> <input type='text' size='10' name='form_state' maxlength='30'
287 value='<?php echo $row['state'] ?>' class='inputtext' />&nbsp;
288 <b>Postal code:</b> <input type='text' size='10' name='form_zip' maxlength='20'
289 value='<?php echo $row['zip'] ?>' class='inputtext' />
290 </td>
291 </tr>
293 <tr>
294 <td nowrap><b><?php xl('Alt Address','e'); ?>:</b></td>
295 <td>
296 <input type='text' size='40' name='form_street2' maxlength='60'
297 value='<?php echo $row['street2'] ?>'
298 style='width:100%' class='inputtext' />
299 </td>
300 </tr>
302 <tr>
303 <td nowrap><b><?php xl('City','e'); ?>:</b></td>
304 <td>
305 <input type='text' size='10' name='form_city2' maxlength='30'
306 value='<?php echo $row['city2'] ?>' class='inputtext' />&nbsp;
307 <b>State/county:</b> <input type='text' size='10' name='form_state2' maxlength='30'
308 value='<?php echo $row['state2'] ?>' class='inputtext' />&nbsp;
309 <b>Postal code:</b> <input type='text' size='10' name='form_zip2' maxlength='20'
310 value='<?php echo $row['zip2'] ?>' class='inputtext' />
311 </td>
312 </tr>
314 <tr>
315 <td nowrap><b><?php xl('UPIN','e'); ?>:</b></td>
316 <td>
317 <input type='text' size='6' name='form_upin' maxlength='6'
318 value='<?php echo $row['upin'] ?>' class='inputtext' />&nbsp;
319 <b>NPI:</b> <input type='text' size='10' name='form_npi' maxlength='10'
320 value='<?php echo $row['npi'] ?>' class='inputtext' />&nbsp;
321 <b>TIN:</b> <input type='text' size='10' name='form_federaltaxid' maxlength='10'
322 value='<?php echo $row['federaltaxid'] ?>' class='inputtext' />
323 </td>
324 </tr>
326 </table>
328 <br />
330 <input type='submit' name='form_save' value='Save' />
332 <?php if ($userid && !$row['username']) { ?>
333 &nbsp;
334 <input type='submit' name='form_delete' value='Delete' style='color:red' />
335 <?php } ?>
337 &nbsp;
338 <input type='button' value='Cancel' onclick='window.close()' />
339 </p>
341 </center>
342 </form>
343 </body>
344 </html>