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");
11 require_once("$srcdir/options.inc.php");
12 require_once("$srcdir/formdata.inc.php");
14 $userid = $_REQUEST['userid'];
18 function QuotedOrNull($fld) {
19 $fld = formDataCore($fld,true);
20 if ($fld) return "'$fld'";
24 function invalue($name) {
25 $fld = formData($name,"P",true);
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 ?
xl('Edit') : xl('Add New') ?
> <?php
xl('Person','e'); ?
></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
>
208 generate_form_field(array('data_type'=>1,'field_id'=>'title','list_id'=>'titles','empty_title'=>''), $row['title']);
211 <b
><?php
xl('Last','e'); ?
>:</b
><input type
='text' size
='10' name
='form_lname' class='inputtext'
212 maxlength
='50' value
='<?php echo htmlspecialchars($row['lname
'], ENT_QUOTES); ?>'/> 
;
213 <b
><?php
xl('First','e'); ?
>:</b
> <input type
='text' size
='10' name
='form_fname' class='inputtext'
214 maxlength
='50' value
='<?php echo htmlspecialchars($row['fname
'], ENT_QUOTES); ?>' /> 
;
215 <b
><?php
xl('Middle','e'); ?
>:</b
> <input type
='text' size
='4' name
='form_mname' class='inputtext'
216 maxlength
='50' value
='<?php echo htmlspecialchars($row['mname
'], ENT_QUOTES); ?>' />
221 <td nowrap
><b
><?php
xl('Specialty','e'); ?
>:</b
></td
>
223 <input type
='text' size
='40' name
='form_specialty' maxlength
='250'
224 value
='<?php echo htmlspecialchars($row['specialty
'], ENT_QUOTES); ?>'
225 style
='width:100%' class='inputtext' />
230 <td nowrap
><b
><?php
xl('Organization','e'); ?
>:</b
></td
>
232 <input type
='text' size
='40' name
='form_organization' maxlength
='250'
233 value
='<?php echo htmlspecialchars($row['organization
'], ENT_QUOTES); ?>'
234 style
='width:100%' class='inputtext' />
239 <td nowrap
><b
><?php
xl('Valedictory','e'); ?
>:</b
></td
>
241 <input type
='text' size
='40' name
='form_valedictory' maxlength
='250'
242 value
='<?php echo htmlspecialchars($row['valedictory
'], ENT_QUOTES); ?>'
243 style
='width:100%' class='inputtext' />
248 <td nowrap
><b
><?php
xl('Home Phone','e'); ?
>:</b
></td
>
250 <input type
='text' size
='11' name
='form_phone' value
='<?php echo htmlspecialchars($row['phone
'], ENT_QUOTES); ?>'
251 maxlength
='30' class='inputtext' /> 
;
252 <b
><?php
xl('Mobile','e'); ?
>:</b
><input type
='text' size
='11' name
='form_phonecell'
253 maxlength
='30' value
='<?php echo htmlspecialchars($row['phonecell
'], ENT_QUOTES); ?>' class='inputtext' />
258 <td nowrap
><b
><?php
xl('Work Phone','e'); ?
>:</b
></td
>
260 <input type
='text' size
='11' name
='form_phonew1' value
='<?php echo htmlspecialchars($row['phonew1
'], ENT_QUOTES); ?>'
261 maxlength
='30' class='inputtext' /> 
;
262 <b
><?php
xl('2nd','e'); ?
>:</b
><input type
='text' size
='11' name
='form_phonew2' value
='<?php echo htmlspecialchars($row['phonew2
'], ENT_QUOTES); ?>'
263 maxlength
='30' class='inputtext' /> 
;
264 <b
><?php
xl('Fax','e'); ?
>:</b
> <input type
='text' size
='11' name
='form_fax' value
='<?php echo htmlspecialchars($row['fax
'], ENT_QUOTES); ?>'
265 maxlength
='30' class='inputtext' />
270 <td nowrap
><b
><?php
xl('Assistant','e'); ?
>:</b
></td
>
272 <input type
='text' size
='40' name
='form_assistant' maxlength
='250'
273 value
='<?php echo htmlspecialchars($row['assistant
'], ENT_QUOTES); ?>'
274 style
='width:100%' class='inputtext' />
279 <td nowrap
><b
><?php
xl('Email','e'); ?
>:</b
></td
>
281 <input type
='text' size
='40' name
='form_email' maxlength
='250'
282 value
='<?php echo htmlspecialchars($row['email
'], ENT_QUOTES); ?>'
283 style
='width:100%' class='inputtext' />
288 <td nowrap
><b
><?php
xl('Website','e'); ?
>:</b
></td
>
290 <input type
='text' size
='40' name
='form_url' maxlength
='250'
291 value
='<?php echo htmlspecialchars($row['url
'], ENT_QUOTES); ?>'
292 style
='width:100%' class='inputtext' />
297 <td nowrap
><b
><?php
xl('Main Address','e'); ?
>:</b
></td
>
299 <input type
='text' size
='40' name
='form_street' maxlength
='60'
300 value
='<?php echo htmlspecialchars($row['street
'], ENT_QUOTES); ?>'
301 style
='width:100%' class='inputtext' />
306 <td nowrap
> 
;</td
>
308 <input type
='text' size
='40' name
='form_streetb' maxlength
='60'
309 value
='<?php echo htmlspecialchars($row['streetb
'], ENT_QUOTES); ?>'
310 style
='width:100%' class='inputtext' />
315 <td nowrap
><b
><?php
xl('City','e'); ?
>:</b
></td
>
317 <input type
='text' size
='10' name
='form_city' maxlength
='30'
318 value
='<?php echo htmlspecialchars($row['city
'], ENT_QUOTES); ?>' class='inputtext' /> 
;
319 <b
><?php
echo xl('State')."/".xl('county'); ?
>:</b
> <input type
='text' size
='10' name
='form_state' maxlength
='30'
320 value
='<?php echo htmlspecialchars($row['state
'], ENT_QUOTES); ?>' class='inputtext' /> 
;
321 <b
><?php
xl('Postal code','e'); ?
>:</b
> <input type
='text' size
='10' name
='form_zip' maxlength
='20'
322 value
='<?php echo htmlspecialchars($row['zip
'], ENT_QUOTES); ?>' class='inputtext' />
327 <td nowrap
><b
><?php
xl('Alt Address','e'); ?
>:</b
></td
>
329 <input type
='text' size
='40' name
='form_street2' maxlength
='60'
330 value
='<?php echo htmlspecialchars($row['street2
'], ENT_QUOTES); ?>'
331 style
='width:100%' class='inputtext' />
336 <td nowrap
> 
;</td
>
338 <input type
='text' size
='40' name
='form_streetb2' maxlength
='60'
339 value
='<?php echo htmlspecialchars($row['streetb2
'], ENT_QUOTES); ?>'
340 style
='width:100%' class='inputtext' />
345 <td nowrap
><b
><?php
xl('City','e'); ?
>:</b
></td
>
347 <input type
='text' size
='10' name
='form_city2' maxlength
='30'
348 value
='<?php echo htmlspecialchars($row['city2
'], ENT_QUOTES); ?>' class='inputtext' /> 
;
349 <b
><?php
echo xl('State')."/".xl('county'); ?
>:</b
> <input type
='text' size
='10' name
='form_state2' maxlength
='30'
350 value
='<?php echo htmlspecialchars($row['state2
'], ENT_QUOTES); ?>' class='inputtext' /> 
;
351 <b
><?php
xl('Postal code','e'); ?
>:</b
> <input type
='text' size
='10' name
='form_zip2' maxlength
='20'
352 value
='<?php echo htmlspecialchars($row['zip2
'], ENT_QUOTES); ?>' class='inputtext' />
357 <td nowrap
><b
><?php
xl('UPIN','e'); ?
>:</b
></td
>
359 <input type
='text' size
='6' name
='form_upin' maxlength
='6'
360 value
='<?php echo htmlspecialchars($row['upin
'], ENT_QUOTES); ?>' class='inputtext' /> 
;
361 <b
><?php
xl('NPI','e'); ?
>:</b
> <input type
='text' size
='10' name
='form_npi' maxlength
='10'
362 value
='<?php echo htmlspecialchars($row['npi
'], ENT_QUOTES); ?>' class='inputtext' /> 
;
363 <b
><?php
xl('TIN','e'); ?
>:</b
> <input type
='text' size
='10' name
='form_federaltaxid' maxlength
='10'
364 value
='<?php echo htmlspecialchars($row['federaltaxid
'], ENT_QUOTES); ?>' class='inputtext' /> 
;
365 <b
><?php
xl('Taxonomy','e'); ?
>:</b
> <input type
='text' size
='10' name
='form_taxonomy' maxlength
='10'
366 value
='<?php echo htmlspecialchars($row['taxonomy
'], ENT_QUOTES); ?>' class='inputtext' />
371 <td nowrap
><b
><?php
xl('Notes','e'); ?
>:</b
></td
>
373 <textarea rows
='3' cols
='40' name
='form_notes' style
='width:100%'
374 wrap
='virtual' class='inputtext' /><?php
echo $row['notes'] ?
></textarea
>
382 <input type
='submit' name
='form_save' value
=<?php
xl('Save','e','\'','\''); ?
> />
384 <?php
if ($userid && !$row['username']) { ?
>
386 <input type
='submit' name
='form_delete' value
=<?php
xl('Delete','e','\'','\''); ?
> style
='color:red' />
390 <input type
='button' value
=<?php
xl('Cancel','e','\'','\''); ?
> onclick
='window.close()' />