2 // Copyright (C) 2006-2007 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 include_once("../globals.php");
10 include_once("$srcdir/acl.inc");
12 $userid = $_REQUEST['userid'];
16 function QuotedOrNull($fld) {
18 if (!get_magic_quotes_gpc()) $fld = addslashes($fld);
19 if ($fld) return "'$fld'";
23 function invalue($name) {
24 $fld = trim($_POST[$name]);
25 if (!get_magic_quotes_gpc()) $fld = addslashes($fld);
29 function rbinput($name, $value, $desc, $colname) {
31 $ret = "<input type='radio' name='$name' value='$value'";
32 if ($row[$colname] == $value) $ret .= " checked";
37 function rbvalue($rbname) {
38 $tmp = $_POST[$rbname];
39 if (! $tmp) $tmp = '0';
46 <title
><?php
echo $userid ?
"Edit" : "Add New" ?
> Person
</title
>
47 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
50 td
{ font
-size
:10pt
; }
54 font-family:monospace;
59 border-color: #000000;
60 background-color:transparent;
67 font
-family
:sans
-serif
;
73 <script language
="JavaScript">
78 <body
class="body_top">
80 // If we are saving, then save and close the window.
82 if ($_POST['form_save']) {
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);
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 " .
133 "0, " . // authorized
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') . ", " .
146 invalue('form_npi') . ", " .
147 invalue('form_taxonomy') . ", " .
148 invalue('form_specialty') . ", " .
149 invalue('form_organization') . ", " .
150 invalue('form_valedictory') . ", " .
151 invalue('form_assistant') . ", " .
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') . " " .
176 else if ($_POST['form_delete']) {
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";
196 $row = sqlQuery("SELECT * FROM users WHERE id = '$userid'");
199 <form method
='post' name
='theform' action
='addrbook_edit.php?userid=<?php echo $userid ?>'>
202 <table border
='0' width
='100%'>
205 <td width
='1%' nowrap
><b
><?php
xl('Name','e'); ?
>:</b
></td
>
207 <select name
='form_title'>
208 <option value
=''></option
>
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";
217 <b
>Last
:</b
><input type
='text' size
='10' name
='form_lname' class='inputtext'
218 maxlength
='50' value
='<?php echo $row['lname
'] ?>'/> 
;
219 <b
>First
:</b
> <input type
='text' size
='10' name
='form_fname' class='inputtext'
220 maxlength
='50' value
='<?php echo $row['fname
'] ?>' /> 
;
221 <b
>Middle
:</b
> <input type
='text' size
='4' name
='form_mname' class='inputtext'
222 maxlength
='50' value
='<?php echo $row['mname
'] ?>' />
227 <td nowrap
><b
><?php
xl('Specialty','e'); ?
>:</b
></td
>
229 <input type
='text' size
='40' name
='form_specialty' maxlength
='250'
230 value
='<?php echo $row['specialty
'] ?>'
231 style
='width:100%' class='inputtext' />
236 <td nowrap
><b
><?php
xl('Organization','e'); ?
>:</b
></td
>
238 <input type
='text' size
='40' name
='form_organization' maxlength
='250'
239 value
='<?php echo $row['organization
'] ?>'
240 style
='width:100%' class='inputtext' />
245 <td nowrap
><b
><?php
xl('Valedictory','e'); ?
>:</b
></td
>
247 <input type
='text' size
='40' name
='form_valedictory' maxlength
='250'
248 value
='<?php echo $row['valedictory
'] ?>'
249 style
='width:100%' class='inputtext' />
254 <td nowrap
><b
><?php
xl('Home Phone','e'); ?
>:</b
></td
>
256 <input type
='text' size
='11' name
='form_phone' value
='<?php echo $row['phone
'] ?>'
257 maxlength
='30' class='inputtext' /> 
;
258 <b
>Mobile
:</b
><input type
='text' size
='11' name
='form_phonecell'
259 maxlength
='30' value
='<?php echo $row['phonecell
'] ?>' class='inputtext' />
264 <td nowrap
><b
><?php
xl('Work Phone','e'); ?
>:</b
></td
>
266 <input type
='text' size
='11' name
='form_phonew1' value
='<?php echo $row['phonew1
'] ?>'
267 maxlength
='30' class='inputtext' /> 
;
268 <b
>2nd
:</b
><input type
='text' size
='11' name
='form_phonew2' value
='<?php echo $row['phonew2
'] ?>'
269 maxlength
='30' class='inputtext' /> 
;
270 <b
>Fax
:</b
> <input type
='text' size
='11' name
='form_fax' value
='<?php echo $row['fax
'] ?>'
271 maxlength
='30' class='inputtext' />
276 <td nowrap
><b
><?php
xl('Assistant','e'); ?
>:</b
></td
>
278 <input type
='text' size
='40' name
='form_assistant' maxlength
='250'
279 value
='<?php echo $row['assistant
'] ?>'
280 style
='width:100%' class='inputtext' />
285 <td nowrap
><b
><?php
xl('Email','e'); ?
>:</b
></td
>
287 <input type
='text' size
='40' name
='form_email' maxlength
='250'
288 value
='<?php echo $row['email
'] ?>'
289 style
='width:100%' class='inputtext' />
294 <td nowrap
><b
><?php
xl('Website','e'); ?
>:</b
></td
>
296 <input type
='text' size
='40' name
='form_url' maxlength
='250'
297 value
='<?php echo $row['url
'] ?>'
298 style
='width:100%' class='inputtext' />
303 <td nowrap
><b
><?php
xl('Main Address','e'); ?
>:</b
></td
>
305 <input type
='text' size
='40' name
='form_street' maxlength
='60'
306 value
='<?php echo $row['street
'] ?>'
307 style
='width:100%' class='inputtext' />
312 <td nowrap
> 
;</td
>
314 <input type
='text' size
='40' name
='form_streetb' maxlength
='60'
315 value
='<?php echo $row['streetb
'] ?>'
316 style
='width:100%' class='inputtext' />
321 <td nowrap
><b
><?php
xl('City','e'); ?
>:</b
></td
>
323 <input type
='text' size
='10' name
='form_city' maxlength
='30'
324 value
='<?php echo $row['city
'] ?>' class='inputtext' /> 
;
325 <b
>State
/county
:</b
> <input type
='text' size
='10' name
='form_state' maxlength
='30'
326 value
='<?php echo $row['state
'] ?>' class='inputtext' /> 
;
327 <b
>Postal code
:</b
> <input type
='text' size
='10' name
='form_zip' maxlength
='20'
328 value
='<?php echo $row['zip
'] ?>' class='inputtext' />
333 <td nowrap
><b
><?php
xl('Alt Address','e'); ?
>:</b
></td
>
335 <input type
='text' size
='40' name
='form_street2' maxlength
='60'
336 value
='<?php echo $row['street2
'] ?>'
337 style
='width:100%' class='inputtext' />
342 <td nowrap
> 
;</td
>
344 <input type
='text' size
='40' name
='form_streetb2' maxlength
='60'
345 value
='<?php echo $row['streetb2
'] ?>'
346 style
='width:100%' class='inputtext' />
351 <td nowrap
><b
><?php
xl('City','e'); ?
>:</b
></td
>
353 <input type
='text' size
='10' name
='form_city2' maxlength
='30'
354 value
='<?php echo $row['city2
'] ?>' class='inputtext' /> 
;
355 <b
>State
/county
:</b
> <input type
='text' size
='10' name
='form_state2' maxlength
='30'
356 value
='<?php echo $row['state2
'] ?>' class='inputtext' /> 
;
357 <b
>Postal code
:</b
> <input type
='text' size
='10' name
='form_zip2' maxlength
='20'
358 value
='<?php echo $row['zip2
'] ?>' class='inputtext' />
363 <td nowrap
><b
><?php
xl('UPIN','e'); ?
>:</b
></td
>
365 <input type
='text' size
='6' name
='form_upin' maxlength
='6'
366 value
='<?php echo $row['upin
'] ?>' class='inputtext' /> 
;
367 <b
>NPI
:</b
> <input type
='text' size
='10' name
='form_npi' maxlength
='10'
368 value
='<?php echo $row['npi
'] ?>' class='inputtext' /> 
;
369 <b
>TIN
:</b
> <input type
='text' size
='10' name
='form_federaltaxid' maxlength
='10'
370 value
='<?php echo $row['federaltaxid
'] ?>' class='inputtext' /> 
;
371 <b
>Taxonomy
:</b
> <input type
='text' size
='10' name
='form_taxonomy' maxlength
='10'
372 value
='<?php echo $row['taxonomy
'] ?>' class='inputtext' />
377 <td nowrap
><b
><?php
xl('Notes','e'); ?
>:</b
></td
>
379 <textarea rows
='3' cols
='40' name
='form_notes' style
='width:100%'
380 wrap
='virtual' class='inputtext' /><?php
echo $row['notes'] ?
></textarea
>
388 <input type
='submit' name
='form_save' value
='Save' />
390 <?php
if ($userid && !$row['username']) { ?
>
392 <input type
='submit' name
='form_delete' value
='Delete' style
='color:red' />
396 <input type
='button' value
='Cancel' onclick
='window.close()' />