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 person centric)
85 // 3 = Company Centric
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) {
97 // 1) Hide the person Name entries
98 // 2) Hide the Specialty entry
99 // 3) Show the director Name entries
100 document
.getElementById("nameRow").style
.display
= "none";
101 document
.getElementById("specialtyRow").style
.display
= "none";
102 document
.getElementById("nameDirectorRow").style
.display
= "";
106 // 1) Hide the director Name entries
107 // 2) Show the person Name entries
108 // 3) Show the Specialty entry
109 document
.getElementById("nameDirectorRow").style
.display
= "none";
110 document
.getElementById("nameRow").style
.display
= "";
111 document
.getElementById("specialtyRow").style
.display
= "";
118 <body
class="body_top">
120 // If we are saving, then save and close the window.
122 if ($_POST['form_save']) {
124 // Collect the form_abook_type option value
125 // (ie. patient vs company centric)
126 $type_sql_row = sqlQuery("SELECT `option_value` FROM `list_options` WHERE `list_id` = 'abook_type' AND `option_id` = " . invalue('form_abook_type') . "");
127 $option_abook_type = $type_sql_row['option_value'];
128 // Set up any abook_type specific settings
129 if ($option_abook_type == 3) {
131 $form_title = invalue('form_director_title');
132 $form_fname = invalue('form_director_fname');
133 $form_lname = invalue('form_director_lname');
134 $form_mname = invalue('form_director_mname');
138 $form_title = invalue('form_title');
139 $form_fname = invalue('form_fname');
140 $form_lname = invalue('form_lname');
141 $form_mname = invalue('form_mname');
146 $query = "UPDATE users SET " .
147 "abook_type = " . invalue('form_abook_type') . ", " .
148 "title = " . $form_title . ", " .
149 "fname = " . $form_fname . ", " .
150 "lname = " . $form_lname . ", " .
151 "mname = " . $form_mname . ", " .
152 "specialty = " . invalue('form_specialty') . ", " .
153 "organization = " . invalue('form_organization') . ", " .
154 "valedictory = " . invalue('form_valedictory') . ", " .
155 "assistant = " . invalue('form_assistant') . ", " .
156 "federaltaxid = " . invalue('form_federaltaxid') . ", " .
157 "upin = " . invalue('form_upin') . ", " .
158 "npi = " . invalue('form_npi') . ", " .
159 "taxonomy = " . invalue('form_taxonomy') . ", " .
160 "email = " . invalue('form_email') . ", " .
161 "url = " . invalue('form_url') . ", " .
162 "street = " . invalue('form_street') . ", " .
163 "streetb = " . invalue('form_streetb') . ", " .
164 "city = " . invalue('form_city') . ", " .
165 "state = " . invalue('form_state') . ", " .
166 "zip = " . invalue('form_zip') . ", " .
167 "street2 = " . invalue('form_street2') . ", " .
168 "streetb2 = " . invalue('form_streetb2') . ", " .
169 "city2 = " . invalue('form_city2') . ", " .
170 "state2 = " . invalue('form_state2') . ", " .
171 "zip2 = " . invalue('form_zip2') . ", " .
172 "phone = " . invalue('form_phone') . ", " .
173 "phonew1 = " . invalue('form_phonew1') . ", " .
174 "phonew2 = " . invalue('form_phonew2') . ", " .
175 "phonecell = " . invalue('form_phonecell') . ", " .
176 "fax = " . invalue('form_fax') . ", " .
177 "notes = " . invalue('form_notes') . " " .
178 "WHERE id = '$userid'";
179 sqlStatement($query);
183 $userid = sqlInsert("INSERT INTO users ( " .
184 "username, password, authorized, info, source, " .
185 "title, fname, lname, mname, " .
186 "federaltaxid, federaldrugid, upin, facility, see_auth, active, npi, taxonomy, " .
187 "specialty, organization, valedictory, assistant, billname, email, url, " .
188 "street, streetb, city, state, zip, " .
189 "street2, streetb2, city2, state2, zip2, " .
190 "phone, phonew1, phonew2, phonecell, fax, notes, abook_type " .
194 "0, " . // authorized
201 invalue('form_federaltaxid') . ", " .
202 "'', " . // federaldrugid
203 invalue('form_upin') . ", " .
207 invalue('form_npi') . ", " .
208 invalue('form_taxonomy') . ", " .
209 invalue('form_specialty') . ", " .
210 invalue('form_organization') . ", " .
211 invalue('form_valedictory') . ", " .
212 invalue('form_assistant') . ", " .
214 invalue('form_email') . ", " .
215 invalue('form_url') . ", " .
216 invalue('form_street') . ", " .
217 invalue('form_streetb') . ", " .
218 invalue('form_city') . ", " .
219 invalue('form_state') . ", " .
220 invalue('form_zip') . ", " .
221 invalue('form_street2') . ", " .
222 invalue('form_streetb2') . ", " .
223 invalue('form_city2') . ", " .
224 invalue('form_state2') . ", " .
225 invalue('form_zip2') . ", " .
226 invalue('form_phone') . ", " .
227 invalue('form_phonew1') . ", " .
228 invalue('form_phonew2') . ", " .
229 invalue('form_phonecell') . ", " .
230 invalue('form_fax') . ", " .
231 invalue('form_notes') . ", " .
232 invalue('form_abook_type') . " " .
238 else if ($_POST['form_delete']) {
241 // Be careful not to delete internal users.
242 sqlStatement("DELETE FROM users WHERE id = '$userid' AND username = ''");
247 if ($_POST['form_save'] ||
$_POST['form_delete']) {
248 // Close this window and redisplay the updated list.
249 echo "<script language='JavaScript'>\n";
250 if ($info_msg) echo " alert('$info_msg');\n";
251 echo " window.close();\n";
252 echo " if (opener.refreshme) opener.refreshme();\n";
253 echo "</script></body></html>\n";
258 $row = sqlQuery("SELECT * FROM users WHERE id = '$userid'");
261 if ($type) { // note this only happens when its new
263 $row['abook_type'] = strip_escape_custom($type);
268 <script language
="JavaScript">
269 $
(document
).ready(function() {
270 // customize the form via the type options
271 typeSelect("<?php echo $row['abook_type']; ?>");
275 <form method
='post' name
='theform' action
='addrbook_edit.php?userid=<?php echo $userid ?>'>
278 <table border
='0' width
='100%'>
280 <?php
if (acl_check('admin', 'practice' )) { // allow choose type option if have admin access ?>
282 <td width
='1%' nowrap
><b
><?php
xl('Type','e'); ?
>:</b
></td
>
285 echo generate_select_list('form_abook_type', 'abook_type', $row['abook_type'], '', 'Unassigned', '', 'typeSelect(this.value)');
289 <?php
} // end of if has admin access ?>
292 <td width
='1%' nowrap
><b
><?php
xl('Name','e'); ?
>:</b
></td
>
295 generate_form_field(array('data_type'=>1,'field_id'=>'title','list_id'=>'titles','empty_title'=>' '), $row['title']);
297 <b
><?php
xl('Last','e'); ?
>:</b
><input type
='text' size
='10' name
='form_lname' class='inputtext'
298 maxlength
='50' value
='<?php echo htmlspecialchars($row['lname
'], ENT_QUOTES); ?>'/> 
;
299 <b
><?php
xl('First','e'); ?
>:</b
> <input type
='text' size
='10' name
='form_fname' class='inputtext'
300 maxlength
='50' value
='<?php echo htmlspecialchars($row['fname
'], ENT_QUOTES); ?>' /> 
;
301 <b
><?php
xl('Middle','e'); ?
>:</b
> <input type
='text' size
='4' name
='form_mname' class='inputtext'
302 maxlength
='50' value
='<?php echo htmlspecialchars($row['mname
'], ENT_QUOTES); ?>' />
306 <tr id
="specialtyRow">
307 <td nowrap
><b
><?php
xl('Specialty','e'); ?
>:</b
></td
>
309 <input type
='text' size
='40' name
='form_specialty' maxlength
='250'
310 value
='<?php echo htmlspecialchars($row['specialty
'], ENT_QUOTES); ?>'
311 style
='width:100%' class='inputtext' />
316 <td nowrap
><b
><?php
xl('Organization','e'); ?
>:</b
></td
>
318 <input type
='text' size
='40' name
='form_organization' maxlength
='250'
319 value
='<?php echo htmlspecialchars($row['organization
'], ENT_QUOTES); ?>'
320 style
='width:100%' class='inputtext' />
324 <tr id
="nameDirectorRow">
325 <td width
='1%' nowrap
><b
><?php
xl('Director Name','e'); ?
>:</b
></td
>
328 generate_form_field(array('data_type'=>1,'field_id'=>'director_title','list_id'=>'titles','empty_title'=>' '), $row['title']);
330 <b
><?php
xl('Last','e'); ?
>:</b
><input type
='text' size
='10' name
='form_director_lname' class='inputtext'
331 maxlength
='50' value
='<?php echo htmlspecialchars($row['lname
'], ENT_QUOTES); ?>'/> 
;
332 <b
><?php
xl('First','e'); ?
>:</b
> <input type
='text' size
='10' name
='form_director_fname' class='inputtext'
333 maxlength
='50' value
='<?php echo htmlspecialchars($row['fname
'], ENT_QUOTES); ?>' /> 
;
334 <b
><?php
xl('Middle','e'); ?
>:</b
> <input type
='text' size
='4' name
='form_director_mname' class='inputtext'
335 maxlength
='50' value
='<?php echo htmlspecialchars($row['mname
'], ENT_QUOTES); ?>' />
340 <td nowrap
><b
><?php
xl('Valedictory','e'); ?
>:</b
></td
>
342 <input type
='text' size
='40' name
='form_valedictory' maxlength
='250'
343 value
='<?php echo htmlspecialchars($row['valedictory
'], ENT_QUOTES); ?>'
344 style
='width:100%' class='inputtext' />
349 <td nowrap
><b
><?php
xl('Home Phone','e'); ?
>:</b
></td
>
351 <input type
='text' size
='11' name
='form_phone' value
='<?php echo htmlspecialchars($row['phone
'], ENT_QUOTES); ?>'
352 maxlength
='30' class='inputtext' /> 
;
353 <b
><?php
xl('Mobile','e'); ?
>:</b
><input type
='text' size
='11' name
='form_phonecell'
354 maxlength
='30' value
='<?php echo htmlspecialchars($row['phonecell
'], ENT_QUOTES); ?>' class='inputtext' />
359 <td nowrap
><b
><?php
xl('Work Phone','e'); ?
>:</b
></td
>
361 <input type
='text' size
='11' name
='form_phonew1' value
='<?php echo htmlspecialchars($row['phonew1
'], ENT_QUOTES); ?>'
362 maxlength
='30' class='inputtext' /> 
;
363 <b
><?php
xl('2nd','e'); ?
>:</b
><input type
='text' size
='11' name
='form_phonew2' value
='<?php echo htmlspecialchars($row['phonew2
'], ENT_QUOTES); ?>'
364 maxlength
='30' class='inputtext' /> 
;
365 <b
><?php
xl('Fax','e'); ?
>:</b
> <input type
='text' size
='11' name
='form_fax' value
='<?php echo htmlspecialchars($row['fax
'], ENT_QUOTES); ?>'
366 maxlength
='30' class='inputtext' />
371 <td nowrap
><b
><?php
xl('Assistant','e'); ?
>:</b
></td
>
373 <input type
='text' size
='40' name
='form_assistant' maxlength
='250'
374 value
='<?php echo htmlspecialchars($row['assistant
'], ENT_QUOTES); ?>'
375 style
='width:100%' class='inputtext' />
380 <td nowrap
><b
><?php
xl('Email','e'); ?
>:</b
></td
>
382 <input type
='text' size
='40' name
='form_email' maxlength
='250'
383 value
='<?php echo htmlspecialchars($row['email
'], ENT_QUOTES); ?>'
384 style
='width:100%' class='inputtext' />
389 <td nowrap
><b
><?php
xl('Website','e'); ?
>:</b
></td
>
391 <input type
='text' size
='40' name
='form_url' maxlength
='250'
392 value
='<?php echo htmlspecialchars($row['url
'], ENT_QUOTES); ?>'
393 style
='width:100%' class='inputtext' />
398 <td nowrap
><b
><?php
xl('Main Address','e'); ?
>:</b
></td
>
400 <input type
='text' size
='40' name
='form_street' maxlength
='60'
401 value
='<?php echo htmlspecialchars($row['street
'], ENT_QUOTES); ?>'
402 style
='width:100%' class='inputtext' />
407 <td nowrap
> 
;</td
>
409 <input type
='text' size
='40' name
='form_streetb' maxlength
='60'
410 value
='<?php echo htmlspecialchars($row['streetb
'], ENT_QUOTES); ?>'
411 style
='width:100%' class='inputtext' />
416 <td nowrap
><b
><?php
xl('City','e'); ?
>:</b
></td
>
418 <input type
='text' size
='10' name
='form_city' maxlength
='30'
419 value
='<?php echo htmlspecialchars($row['city
'], ENT_QUOTES); ?>' class='inputtext' /> 
;
420 <b
><?php
echo xl('State')."/".xl('county'); ?
>:</b
> <input type
='text' size
='10' name
='form_state' maxlength
='30'
421 value
='<?php echo htmlspecialchars($row['state
'], ENT_QUOTES); ?>' class='inputtext' /> 
;
422 <b
><?php
xl('Postal code','e'); ?
>:</b
> <input type
='text' size
='10' name
='form_zip' maxlength
='20'
423 value
='<?php echo htmlspecialchars($row['zip
'], ENT_QUOTES); ?>' class='inputtext' />
428 <td nowrap
><b
><?php
xl('Alt Address','e'); ?
>:</b
></td
>
430 <input type
='text' size
='40' name
='form_street2' maxlength
='60'
431 value
='<?php echo htmlspecialchars($row['street2
'], ENT_QUOTES); ?>'
432 style
='width:100%' class='inputtext' />
437 <td nowrap
> 
;</td
>
439 <input type
='text' size
='40' name
='form_streetb2' maxlength
='60'
440 value
='<?php echo htmlspecialchars($row['streetb2
'], ENT_QUOTES); ?>'
441 style
='width:100%' class='inputtext' />
446 <td nowrap
><b
><?php
xl('City','e'); ?
>:</b
></td
>
448 <input type
='text' size
='10' name
='form_city2' maxlength
='30'
449 value
='<?php echo htmlspecialchars($row['city2
'], ENT_QUOTES); ?>' class='inputtext' /> 
;
450 <b
><?php
echo xl('State')."/".xl('county'); ?
>:</b
> <input type
='text' size
='10' name
='form_state2' maxlength
='30'
451 value
='<?php echo htmlspecialchars($row['state2
'], ENT_QUOTES); ?>' class='inputtext' /> 
;
452 <b
><?php
xl('Postal code','e'); ?
>:</b
> <input type
='text' size
='10' name
='form_zip2' maxlength
='20'
453 value
='<?php echo htmlspecialchars($row['zip2
'], ENT_QUOTES); ?>' class='inputtext' />
458 <td nowrap
><b
><?php
xl('UPIN','e'); ?
>:</b
></td
>
460 <input type
='text' size
='6' name
='form_upin' maxlength
='6'
461 value
='<?php echo htmlspecialchars($row['upin
'], ENT_QUOTES); ?>' class='inputtext' /> 
;
462 <b
><?php
xl('NPI','e'); ?
>:</b
> <input type
='text' size
='10' name
='form_npi' maxlength
='10'
463 value
='<?php echo htmlspecialchars($row['npi
'], ENT_QUOTES); ?>' class='inputtext' /> 
;
464 <b
><?php
xl('TIN','e'); ?
>:</b
> <input type
='text' size
='10' name
='form_federaltaxid' maxlength
='10'
465 value
='<?php echo htmlspecialchars($row['federaltaxid
'], ENT_QUOTES); ?>' class='inputtext' /> 
;
466 <b
><?php
xl('Taxonomy','e'); ?
>:</b
> <input type
='text' size
='10' name
='form_taxonomy' maxlength
='10'
467 value
='<?php echo htmlspecialchars($row['taxonomy
'], ENT_QUOTES); ?>' class='inputtext' />
472 <td nowrap
><b
><?php
xl('Notes','e'); ?
>:</b
></td
>
474 <textarea rows
='3' cols
='40' name
='form_notes' style
='width:100%'
475 wrap
='virtual' class='inputtext' /><?php
echo $row['notes'] ?
></textarea
>
483 <input type
='submit' name
='form_save' value
=<?php
xl('Save','e','\'','\''); ?
> />
485 <?php
if ($userid && !$row['username']) { ?
>
487 <input type
='submit' name
='form_delete' value
=<?php
xl('Delete','e','\'','\''); ?
> style
='color:red' />
491 <input type
='button' value
=<?php
xl('Cancel','e','\'','\''); ?
> onclick
='window.close()' />