Changed version to 3.0 to match new OpenEMR release.
[openemr.git] / interface / usergroup / addrbook_edit.php
blobf912a8099f01bd37b34e856735da87584ef026cb
1 <?php
2 // Copyright (C) 2006-2007 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 class="body_top">
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 "organization = " . invalue('form_organization') . ", " .
93 "valedictory = " . invalue('form_valedictory') . ", " .
94 "assistant = " . invalue('form_assistant') . ", " .
95 "federaltaxid = " . invalue('form_federaltaxid') . ", " .
96 "upin = " . invalue('form_upin') . ", " .
97 "npi = " . invalue('form_npi') . ", " .
98 "taxonomy = " . invalue('form_taxonomy') . ", " .
99 "email = " . invalue('form_email') . ", " .
100 "url = " . invalue('form_url') . ", " .
101 "street = " . invalue('form_street') . ", " .
102 "streetb = " . invalue('form_streetb') . ", " .
103 "city = " . invalue('form_city') . ", " .
104 "state = " . invalue('form_state') . ", " .
105 "zip = " . invalue('form_zip') . ", " .
106 "street2 = " . invalue('form_street2') . ", " .
107 "streetb2 = " . invalue('form_streetb2') . ", " .
108 "city2 = " . invalue('form_city2') . ", " .
109 "state2 = " . invalue('form_state2') . ", " .
110 "zip2 = " . invalue('form_zip2') . ", " .
111 "phone = " . invalue('form_phone') . ", " .
112 "phonew1 = " . invalue('form_phonew1') . ", " .
113 "phonew2 = " . invalue('form_phonew2') . ", " .
114 "phonecell = " . invalue('form_phonecell') . ", " .
115 "fax = " . invalue('form_fax') . ", " .
116 "notes = " . invalue('form_notes') . " " .
117 "WHERE id = '$userid'";
118 sqlStatement($query);
120 } else {
122 $userid = sqlInsert("INSERT INTO users ( " .
123 "username, password, authorized, info, source, " .
124 "title, fname, lname, mname, " .
125 "federaltaxid, federaldrugid, upin, facility, see_auth, active, npi, taxonomy, " .
126 "specialty, organization, valedictory, assistant, billname, email, url, " .
127 "street, streetb, city, state, zip, " .
128 "street2, streetb2, city2, state2, zip2, " .
129 "phone, phonew1, phonew2, phonecell, fax, notes " .
130 ") VALUES ( " .
131 "'', " . // username
132 "'', " . // password
133 "0, " . // authorized
134 "'', " . // info
135 "NULL, " . // source
136 invalue('form_title') . ", " .
137 invalue('form_fname') . ", " .
138 invalue('form_lname') . ", " .
139 invalue('form_mname') . ", " .
140 invalue('form_federaltaxid') . ", " .
141 "'', " . // federaldrugid
142 invalue('form_upin') . ", " .
143 "'', " . // facility
144 "0, " . // see_auth
145 "1, " . // active
146 invalue('form_npi') . ", " .
147 invalue('form_taxonomy') . ", " .
148 invalue('form_specialty') . ", " .
149 invalue('form_organization') . ", " .
150 invalue('form_valedictory') . ", " .
151 invalue('form_assistant') . ", " .
152 "'', " . // billname
153 invalue('form_email') . ", " .
154 invalue('form_url') . ", " .
155 invalue('form_street') . ", " .
156 invalue('form_streetb') . ", " .
157 invalue('form_city') . ", " .
158 invalue('form_state') . ", " .
159 invalue('form_zip') . ", " .
160 invalue('form_street2') . ", " .
161 invalue('form_streetb2') . ", " .
162 invalue('form_city2') . ", " .
163 invalue('form_state2') . ", " .
164 invalue('form_zip2') . ", " .
165 invalue('form_phone') . ", " .
166 invalue('form_phonew1') . ", " .
167 invalue('form_phonew2') . ", " .
168 invalue('form_phonecell') . ", " .
169 invalue('form_fax') . ", " .
170 invalue('form_notes') . " " .
171 ")");
176 else if ($_POST['form_delete']) {
178 if ($userid) {
179 // Be careful not to delete internal users.
180 sqlStatement("DELETE FROM users WHERE id = '$userid' AND username = ''");
185 if ($_POST['form_save'] || $_POST['form_delete']) {
186 // Close this window and redisplay the updated list.
187 echo "<script language='JavaScript'>\n";
188 if ($info_msg) echo " alert('$info_msg');\n";
189 echo " window.close();\n";
190 echo " if (opener.refreshme) opener.refreshme();\n";
191 echo "</script></body></html>\n";
192 exit();
195 if ($userid) {
196 $row = sqlQuery("SELECT * FROM users WHERE id = '$userid'");
199 <form method='post' name='theform' action='addrbook_edit.php?userid=<?php echo $userid ?>'>
200 <center>
202 <table border='0' width='100%'>
204 <tr>
205 <td width='1%' nowrap><b><?php xl('Name','e'); ?>:</b></td>
206 <td>
207 <select name='form_title'>
208 <option value=''></option>
209 <?php
210 foreach (array('Mr.', 'Mrs.', 'Ms.', 'Dr.', 'Prof.') as $value) {
211 echo " <option value='$value'";
212 if ($value == $row['title']) echo " selected";
213 echo ">$value</option>\n";
216 </select>
217 <b>Last:</b><input type='text' size='10' name='form_lname' class='inputtext'
218 maxlength='50' value='<?php echo $row['lname'] ?>'/>&nbsp;
219 <b>First:</b> <input type='text' size='10' name='form_fname' class='inputtext'
220 maxlength='50' value='<?php echo $row['fname'] ?>' />&nbsp;
221 <b>Middle:</b> <input type='text' size='4' name='form_mname' class='inputtext'
222 maxlength='50' value='<?php echo $row['mname'] ?>' />
223 </td>
224 </tr>
226 <tr>
227 <td nowrap><b><?php xl('Specialty','e'); ?>:</b></td>
228 <td>
229 <input type='text' size='40' name='form_specialty' maxlength='250'
230 value='<?php echo $row['specialty'] ?>'
231 style='width:100%' class='inputtext' />
232 </td>
233 </tr>
235 <tr>
236 <td nowrap><b><?php xl('Organization','e'); ?>:</b></td>
237 <td>
238 <input type='text' size='40' name='form_organization' maxlength='250'
239 value='<?php echo $row['organization'] ?>'
240 style='width:100%' class='inputtext' />
241 </td>
242 </tr>
244 <tr>
245 <td nowrap><b><?php xl('Valedictory','e'); ?>:</b></td>
246 <td>
247 <input type='text' size='40' name='form_valedictory' maxlength='250'
248 value='<?php echo $row['valedictory'] ?>'
249 style='width:100%' class='inputtext' />
250 </td>
251 </tr>
253 <tr>
254 <td nowrap><b><?php xl('Home Phone','e'); ?>:</b></td>
255 <td>
256 <input type='text' size='11' name='form_phone' value='<?php echo $row['phone'] ?>'
257 maxlength='30' class='inputtext' />&nbsp;
258 <b>Mobile:</b><input type='text' size='11' name='form_phonecell'
259 maxlength='30' value='<?php echo $row['phonecell'] ?>' class='inputtext' />
260 </td>
261 </tr>
263 <tr>
264 <td nowrap><b><?php xl('Work Phone','e'); ?>:</b></td>
265 <td>
266 <input type='text' size='11' name='form_phonew1' value='<?php echo $row['phonew1'] ?>'
267 maxlength='30' class='inputtext' />&nbsp;
268 <b>2nd:</b><input type='text' size='11' name='form_phonew2' value='<?php echo $row['phonew2'] ?>'
269 maxlength='30' class='inputtext' />&nbsp;
270 <b>Fax:</b> <input type='text' size='11' name='form_fax' value='<?php echo $row['fax'] ?>'
271 maxlength='30' class='inputtext' />
272 </td>
273 </tr>
275 <tr>
276 <td nowrap><b><?php xl('Assistant','e'); ?>:</b></td>
277 <td>
278 <input type='text' size='40' name='form_assistant' maxlength='250'
279 value='<?php echo $row['assistant'] ?>'
280 style='width:100%' class='inputtext' />
281 </td>
282 </tr>
284 <tr>
285 <td nowrap><b><?php xl('Email','e'); ?>:</b></td>
286 <td>
287 <input type='text' size='40' name='form_email' maxlength='250'
288 value='<?php echo $row['email'] ?>'
289 style='width:100%' class='inputtext' />
290 </td>
291 </tr>
293 <tr>
294 <td nowrap><b><?php xl('Website','e'); ?>:</b></td>
295 <td>
296 <input type='text' size='40' name='form_url' maxlength='250'
297 value='<?php echo $row['url'] ?>'
298 style='width:100%' class='inputtext' />
299 </td>
300 </tr>
302 <tr>
303 <td nowrap><b><?php xl('Main Address','e'); ?>:</b></td>
304 <td>
305 <input type='text' size='40' name='form_street' maxlength='60'
306 value='<?php echo $row['street'] ?>'
307 style='width:100%' class='inputtext' />
308 </td>
309 </tr>
311 <tr>
312 <td nowrap>&nbsp;</td>
313 <td>
314 <input type='text' size='40' name='form_streetb' maxlength='60'
315 value='<?php echo $row['streetb'] ?>'
316 style='width:100%' class='inputtext' />
317 </td>
318 </tr>
320 <tr>
321 <td nowrap><b><?php xl('City','e'); ?>:</b></td>
322 <td>
323 <input type='text' size='10' name='form_city' maxlength='30'
324 value='<?php echo $row['city'] ?>' class='inputtext' />&nbsp;
325 <b>State/county:</b> <input type='text' size='10' name='form_state' maxlength='30'
326 value='<?php echo $row['state'] ?>' class='inputtext' />&nbsp;
327 <b>Postal code:</b> <input type='text' size='10' name='form_zip' maxlength='20'
328 value='<?php echo $row['zip'] ?>' class='inputtext' />
329 </td>
330 </tr>
332 <tr>
333 <td nowrap><b><?php xl('Alt Address','e'); ?>:</b></td>
334 <td>
335 <input type='text' size='40' name='form_street2' maxlength='60'
336 value='<?php echo $row['street2'] ?>'
337 style='width:100%' class='inputtext' />
338 </td>
339 </tr>
341 <tr>
342 <td nowrap>&nbsp;</td>
343 <td>
344 <input type='text' size='40' name='form_streetb2' maxlength='60'
345 value='<?php echo $row['streetb2'] ?>'
346 style='width:100%' class='inputtext' />
347 </td>
348 </tr>
350 <tr>
351 <td nowrap><b><?php xl('City','e'); ?>:</b></td>
352 <td>
353 <input type='text' size='10' name='form_city2' maxlength='30'
354 value='<?php echo $row['city2'] ?>' class='inputtext' />&nbsp;
355 <b>State/county:</b> <input type='text' size='10' name='form_state2' maxlength='30'
356 value='<?php echo $row['state2'] ?>' class='inputtext' />&nbsp;
357 <b>Postal code:</b> <input type='text' size='10' name='form_zip2' maxlength='20'
358 value='<?php echo $row['zip2'] ?>' class='inputtext' />
359 </td>
360 </tr>
362 <tr>
363 <td nowrap><b><?php xl('UPIN','e'); ?>:</b></td>
364 <td>
365 <input type='text' size='6' name='form_upin' maxlength='6'
366 value='<?php echo $row['upin'] ?>' class='inputtext' />&nbsp;
367 <b>NPI:</b> <input type='text' size='10' name='form_npi' maxlength='10'
368 value='<?php echo $row['npi'] ?>' class='inputtext' />&nbsp;
369 <b>TIN:</b> <input type='text' size='10' name='form_federaltaxid' maxlength='10'
370 value='<?php echo $row['federaltaxid'] ?>' class='inputtext' />&nbsp;
371 <b>Taxonomy:</b> <input type='text' size='10' name='form_taxonomy' maxlength='10'
372 value='<?php echo $row['taxonomy'] ?>' class='inputtext' />
373 </td>
374 </tr>
376 <tr>
377 <td nowrap><b><?php xl('Notes','e'); ?>:</b></td>
378 <td>
379 <textarea rows='3' cols='40' name='form_notes' style='width:100%'
380 wrap='virtual' class='inputtext' /><?php echo $row['notes'] ?></textarea>
381 </td>
382 </tr>
384 </table>
386 <br />
388 <input type='submit' name='form_save' value='Save' />
390 <?php if ($userid && !$row['username']) { ?>
391 &nbsp;
392 <input type='submit' name='form_delete' value='Delete' style='color:red' />
393 <?php } ?>
395 &nbsp;
396 <input type='button' value='Cancel' onclick='window.close()' />
397 </p>
399 </center>
400 </form>
401 </body>
402 </html>