2 // Copyright (C) 2006-2010 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 // Collect user id if editing entry
15 $userid = $_REQUEST['userid'];
17 // Collect type if creating a new entry
18 $type = $_REQUEST['type'];
22 function QuotedOrNull($fld) {
23 $fld = formDataCore($fld,true);
24 if ($fld) return "'$fld'";
28 function invalue($name) {
29 $fld = formData($name,"P",true);
33 function rbinput($name, $value, $desc, $colname) {
35 $ret = "<input type='radio' name='$name' value='$value'";
36 if ($row[$colname] == $value) $ret .= " checked";
41 function rbvalue($rbname) {
42 $tmp = $_POST[$rbname];
43 if (! $tmp) $tmp = '0';
50 <title
><?php
echo $userid ?
xl('Edit') : xl('Add New') ?
> <?php
xl('Person','e'); ?
></title
>
51 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
52 <script type
="text/javascript" src
="../../library/js/jquery.1.3.2.js"></script
>
55 td
{ font
-size
:10pt
; }
59 font-family:monospace;
64 border-color: #000000;
65 background-color:transparent;
72 font
-family
:sans
-serif
;
78 <script language
="JavaScript">
80 var type_options_js
= Array();
82 // Collect the type options. Possible values are:
83 // 1 = Unassigned (default to patient centric)
85 // 3 = Company Centric (Basically, do not show the Name fields)
86 $sql = sqlStatement("SELECT option_id, option_value FROM list_options WHERE " .
87 "list_id = 'abook_type'");
88 while ($row_query = sqlFetchArray($sql)) {
89 echo "type_options_js"."['" . htmlspecialchars($row_query['option_id'],ENT_QUOTES
) . "']=" . htmlspecialchars($row_query['option_value'],ENT_QUOTES
) . ";\n";
93 // Process to customize the form by type
94 function typeSelect(a
) {
95 if (type_options_js
[a
] == 3) {
96 // Company centric, so hide the Name entries
97 document
.getElementById("nameRow").style
.display
= "none";
101 document
.getElementById("nameRow").style
.display
= "";
108 <body
class="body_top">
110 // If we are saving, then save and close the window.
112 if ($_POST['form_save']) {
116 $query = "UPDATE users SET " .
117 "abook_type = " . invalue('form_abook_type') . ", " .
118 "title = " . invalue('form_title') . ", " .
119 "fname = " . invalue('form_fname') . ", " .
120 "lname = " . invalue('form_lname') . ", " .
121 "mname = " . invalue('form_mname') . ", " .
122 "specialty = " . invalue('form_specialty') . ", " .
123 "organization = " . invalue('form_organization') . ", " .
124 "valedictory = " . invalue('form_valedictory') . ", " .
125 "assistant = " . invalue('form_assistant') . ", " .
126 "federaltaxid = " . invalue('form_federaltaxid') . ", " .
127 "upin = " . invalue('form_upin') . ", " .
128 "npi = " . invalue('form_npi') . ", " .
129 "taxonomy = " . invalue('form_taxonomy') . ", " .
130 "email = " . invalue('form_email') . ", " .
131 "url = " . invalue('form_url') . ", " .
132 "street = " . invalue('form_street') . ", " .
133 "streetb = " . invalue('form_streetb') . ", " .
134 "city = " . invalue('form_city') . ", " .
135 "state = " . invalue('form_state') . ", " .
136 "zip = " . invalue('form_zip') . ", " .
137 "street2 = " . invalue('form_street2') . ", " .
138 "streetb2 = " . invalue('form_streetb2') . ", " .
139 "city2 = " . invalue('form_city2') . ", " .
140 "state2 = " . invalue('form_state2') . ", " .
141 "zip2 = " . invalue('form_zip2') . ", " .
142 "phone = " . invalue('form_phone') . ", " .
143 "phonew1 = " . invalue('form_phonew1') . ", " .
144 "phonew2 = " . invalue('form_phonew2') . ", " .
145 "phonecell = " . invalue('form_phonecell') . ", " .
146 "fax = " . invalue('form_fax') . ", " .
147 "notes = " . invalue('form_notes') . " " .
148 "WHERE id = '$userid'";
149 sqlStatement($query);
153 $userid = sqlInsert("INSERT INTO users ( " .
154 "username, password, authorized, info, source, " .
155 "title, fname, lname, mname, " .
156 "federaltaxid, federaldrugid, upin, facility, see_auth, active, npi, taxonomy, " .
157 "specialty, organization, valedictory, assistant, billname, email, url, " .
158 "street, streetb, city, state, zip, " .
159 "street2, streetb2, city2, state2, zip2, " .
160 "phone, phonew1, phonew2, phonecell, fax, notes, abook_type " .
164 "0, " . // authorized
167 invalue('form_title') . ", " .
168 invalue('form_fname') . ", " .
169 invalue('form_lname') . ", " .
170 invalue('form_mname') . ", " .
171 invalue('form_federaltaxid') . ", " .
172 "'', " . // federaldrugid
173 invalue('form_upin') . ", " .
177 invalue('form_npi') . ", " .
178 invalue('form_taxonomy') . ", " .
179 invalue('form_specialty') . ", " .
180 invalue('form_organization') . ", " .
181 invalue('form_valedictory') . ", " .
182 invalue('form_assistant') . ", " .
184 invalue('form_email') . ", " .
185 invalue('form_url') . ", " .
186 invalue('form_street') . ", " .
187 invalue('form_streetb') . ", " .
188 invalue('form_city') . ", " .
189 invalue('form_state') . ", " .
190 invalue('form_zip') . ", " .
191 invalue('form_street2') . ", " .
192 invalue('form_streetb2') . ", " .
193 invalue('form_city2') . ", " .
194 invalue('form_state2') . ", " .
195 invalue('form_zip2') . ", " .
196 invalue('form_phone') . ", " .
197 invalue('form_phonew1') . ", " .
198 invalue('form_phonew2') . ", " .
199 invalue('form_phonecell') . ", " .
200 invalue('form_fax') . ", " .
201 invalue('form_notes') . ", " .
202 invalue('form_abook_type') . " " .
208 else if ($_POST['form_delete']) {
211 // Be careful not to delete internal users.
212 sqlStatement("DELETE FROM users WHERE id = '$userid' AND username = ''");
217 if ($_POST['form_save'] ||
$_POST['form_delete']) {
218 // Close this window and redisplay the updated list.
219 echo "<script language='JavaScript'>\n";
220 if ($info_msg) echo " alert('$info_msg');\n";
221 echo " window.close();\n";
222 echo " if (opener.refreshme) opener.refreshme();\n";
223 echo "</script></body></html>\n";
228 $row = sqlQuery("SELECT * FROM users WHERE id = '$userid'");
231 if ($type) { // note this only happens when its new
233 $row['abook_type'] = strip_escape_custom($type);
238 <script language
="JavaScript">
239 $
(document
).ready(function() {
240 // customize the form via the type options
241 typeSelect("<?php echo $row['abook_type']; ?>");
245 <form method
='post' name
='theform' action
='addrbook_edit.php?userid=<?php echo $userid ?>'>
248 <table border
='0' width
='100%'>
250 <?php
if (acl_check('admin', 'practice' )) { // allow choose type option if have admin access ?>
252 <td width
='1%' nowrap
><b
><?php
xl('Type','e'); ?
>:</b
></td
>
255 echo generate_select_list('form_abook_type', 'abook_type', $row['abook_type'], '', 'Unassigned', '', 'typeSelect(this.value)');
259 <?php
} // end of if has admin access ?>
262 <td width
='1%' nowrap
><b
><?php
xl('Name','e'); ?
>:</b
></td
>
265 generate_form_field(array('data_type'=>1,'field_id'=>'title','list_id'=>'titles','empty_title'=>' '), $row['title']);
267 <b
><?php
xl('Last','e'); ?
>:</b
><input type
='text' size
='10' name
='form_lname' class='inputtext'
268 maxlength
='50' value
='<?php echo htmlspecialchars($row['lname
'], ENT_QUOTES); ?>'/> 
;
269 <b
><?php
xl('First','e'); ?
>:</b
> <input type
='text' size
='10' name
='form_fname' class='inputtext'
270 maxlength
='50' value
='<?php echo htmlspecialchars($row['fname
'], ENT_QUOTES); ?>' /> 
;
271 <b
><?php
xl('Middle','e'); ?
>:</b
> <input type
='text' size
='4' name
='form_mname' class='inputtext'
272 maxlength
='50' value
='<?php echo htmlspecialchars($row['mname
'], ENT_QUOTES); ?>' />
277 <td nowrap
><b
><?php
xl('Specialty','e'); ?
>:</b
></td
>
279 <input type
='text' size
='40' name
='form_specialty' maxlength
='250'
280 value
='<?php echo htmlspecialchars($row['specialty
'], ENT_QUOTES); ?>'
281 style
='width:100%' class='inputtext' />
286 <td nowrap
><b
><?php
xl('Organization','e'); ?
>:</b
></td
>
288 <input type
='text' size
='40' name
='form_organization' maxlength
='250'
289 value
='<?php echo htmlspecialchars($row['organization
'], ENT_QUOTES); ?>'
290 style
='width:100%' class='inputtext' />
295 <td nowrap
><b
><?php
xl('Valedictory','e'); ?
>:</b
></td
>
297 <input type
='text' size
='40' name
='form_valedictory' maxlength
='250'
298 value
='<?php echo htmlspecialchars($row['valedictory
'], ENT_QUOTES); ?>'
299 style
='width:100%' class='inputtext' />
304 <td nowrap
><b
><?php
xl('Home Phone','e'); ?
>:</b
></td
>
306 <input type
='text' size
='11' name
='form_phone' value
='<?php echo htmlspecialchars($row['phone
'], ENT_QUOTES); ?>'
307 maxlength
='30' class='inputtext' /> 
;
308 <b
><?php
xl('Mobile','e'); ?
>:</b
><input type
='text' size
='11' name
='form_phonecell'
309 maxlength
='30' value
='<?php echo htmlspecialchars($row['phonecell
'], ENT_QUOTES); ?>' class='inputtext' />
314 <td nowrap
><b
><?php
xl('Work Phone','e'); ?
>:</b
></td
>
316 <input type
='text' size
='11' name
='form_phonew1' value
='<?php echo htmlspecialchars($row['phonew1
'], ENT_QUOTES); ?>'
317 maxlength
='30' class='inputtext' /> 
;
318 <b
><?php
xl('2nd','e'); ?
>:</b
><input type
='text' size
='11' name
='form_phonew2' value
='<?php echo htmlspecialchars($row['phonew2
'], ENT_QUOTES); ?>'
319 maxlength
='30' class='inputtext' /> 
;
320 <b
><?php
xl('Fax','e'); ?
>:</b
> <input type
='text' size
='11' name
='form_fax' value
='<?php echo htmlspecialchars($row['fax
'], ENT_QUOTES); ?>'
321 maxlength
='30' class='inputtext' />
326 <td nowrap
><b
><?php
xl('Assistant','e'); ?
>:</b
></td
>
328 <input type
='text' size
='40' name
='form_assistant' maxlength
='250'
329 value
='<?php echo htmlspecialchars($row['assistant
'], ENT_QUOTES); ?>'
330 style
='width:100%' class='inputtext' />
335 <td nowrap
><b
><?php
xl('Email','e'); ?
>:</b
></td
>
337 <input type
='text' size
='40' name
='form_email' maxlength
='250'
338 value
='<?php echo htmlspecialchars($row['email
'], ENT_QUOTES); ?>'
339 style
='width:100%' class='inputtext' />
344 <td nowrap
><b
><?php
xl('Website','e'); ?
>:</b
></td
>
346 <input type
='text' size
='40' name
='form_url' maxlength
='250'
347 value
='<?php echo htmlspecialchars($row['url
'], ENT_QUOTES); ?>'
348 style
='width:100%' class='inputtext' />
353 <td nowrap
><b
><?php
xl('Main Address','e'); ?
>:</b
></td
>
355 <input type
='text' size
='40' name
='form_street' maxlength
='60'
356 value
='<?php echo htmlspecialchars($row['street
'], ENT_QUOTES); ?>'
357 style
='width:100%' class='inputtext' />
362 <td nowrap
> 
;</td
>
364 <input type
='text' size
='40' name
='form_streetb' maxlength
='60'
365 value
='<?php echo htmlspecialchars($row['streetb
'], ENT_QUOTES); ?>'
366 style
='width:100%' class='inputtext' />
371 <td nowrap
><b
><?php
xl('City','e'); ?
>:</b
></td
>
373 <input type
='text' size
='10' name
='form_city' maxlength
='30'
374 value
='<?php echo htmlspecialchars($row['city
'], ENT_QUOTES); ?>' class='inputtext' /> 
;
375 <b
><?php
echo xl('State')."/".xl('county'); ?
>:</b
> <input type
='text' size
='10' name
='form_state' maxlength
='30'
376 value
='<?php echo htmlspecialchars($row['state
'], ENT_QUOTES); ?>' class='inputtext' /> 
;
377 <b
><?php
xl('Postal code','e'); ?
>:</b
> <input type
='text' size
='10' name
='form_zip' maxlength
='20'
378 value
='<?php echo htmlspecialchars($row['zip
'], ENT_QUOTES); ?>' class='inputtext' />
383 <td nowrap
><b
><?php
xl('Alt Address','e'); ?
>:</b
></td
>
385 <input type
='text' size
='40' name
='form_street2' maxlength
='60'
386 value
='<?php echo htmlspecialchars($row['street2
'], ENT_QUOTES); ?>'
387 style
='width:100%' class='inputtext' />
392 <td nowrap
> 
;</td
>
394 <input type
='text' size
='40' name
='form_streetb2' maxlength
='60'
395 value
='<?php echo htmlspecialchars($row['streetb2
'], ENT_QUOTES); ?>'
396 style
='width:100%' class='inputtext' />
401 <td nowrap
><b
><?php
xl('City','e'); ?
>:</b
></td
>
403 <input type
='text' size
='10' name
='form_city2' maxlength
='30'
404 value
='<?php echo htmlspecialchars($row['city2
'], ENT_QUOTES); ?>' class='inputtext' /> 
;
405 <b
><?php
echo xl('State')."/".xl('county'); ?
>:</b
> <input type
='text' size
='10' name
='form_state2' maxlength
='30'
406 value
='<?php echo htmlspecialchars($row['state2
'], ENT_QUOTES); ?>' class='inputtext' /> 
;
407 <b
><?php
xl('Postal code','e'); ?
>:</b
> <input type
='text' size
='10' name
='form_zip2' maxlength
='20'
408 value
='<?php echo htmlspecialchars($row['zip2
'], ENT_QUOTES); ?>' class='inputtext' />
413 <td nowrap
><b
><?php
xl('UPIN','e'); ?
>:</b
></td
>
415 <input type
='text' size
='6' name
='form_upin' maxlength
='6'
416 value
='<?php echo htmlspecialchars($row['upin
'], ENT_QUOTES); ?>' class='inputtext' /> 
;
417 <b
><?php
xl('NPI','e'); ?
>:</b
> <input type
='text' size
='10' name
='form_npi' maxlength
='10'
418 value
='<?php echo htmlspecialchars($row['npi
'], ENT_QUOTES); ?>' class='inputtext' /> 
;
419 <b
><?php
xl('TIN','e'); ?
>:</b
> <input type
='text' size
='10' name
='form_federaltaxid' maxlength
='10'
420 value
='<?php echo htmlspecialchars($row['federaltaxid
'], ENT_QUOTES); ?>' class='inputtext' /> 
;
421 <b
><?php
xl('Taxonomy','e'); ?
>:</b
> <input type
='text' size
='10' name
='form_taxonomy' maxlength
='10'
422 value
='<?php echo htmlspecialchars($row['taxonomy
'], ENT_QUOTES); ?>' class='inputtext' />
427 <td nowrap
><b
><?php
xl('Notes','e'); ?
>:</b
></td
>
429 <textarea rows
='3' cols
='40' name
='form_notes' style
='width:100%'
430 wrap
='virtual' class='inputtext' /><?php
echo $row['notes'] ?
></textarea
>
438 <input type
='submit' name
='form_save' value
=<?php
xl('Save','e','\'','\''); ?
> />
440 <?php
if ($userid && !$row['username']) { ?
>
442 <input type
='submit' name
='form_delete' value
=<?php
xl('Delete','e','\'','\''); ?
> style
='color:red' />
446 <input type
='button' value
=<?php
xl('Cancel','e','\'','\''); ?
> onclick
='window.close()' />