2 // Copyright (C) 2006-2010, 2016 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.
10 $sanitize_all_escapes=true;
13 //STOP FAKE REGISTER GLOBALS
14 $fake_register_globals=false;
17 include_once("../globals.php");
18 include_once("$srcdir/acl.inc");
19 require_once("$srcdir/options.inc.php");
20 require_once("$srcdir/formdata.inc.php");
21 require_once("$srcdir/htmlspecialchars.inc.php");
23 // Collect user id if editing entry
24 $userid = $_REQUEST['userid'];
26 // Collect type if creating a new entry
27 $type = $_REQUEST['type'];
31 function invalue($name) {
32 if (!$_POST[$name]) return "''";
33 $fld = add_escape_custom(trim($_POST[$name]));
40 <title
><?php
echo $userid ?
xlt('Edit') : xlt('Add New') ?
> <?php
echo xlt('Person'); ?
></title
>
41 <script type
="text/javascript" src
="<?php echo $webroot ?>/interface/main/tabs/js/include_opener.js"></script
>
42 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
43 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-9-1/index.js"></script
>
46 td
{ font
-size
:10pt
; }
54 font
-family
:sans
-serif
;
60 <script language
="JavaScript">
62 var type_options_js
= Array();
64 // Collect the type options. Possible values are:
65 // 1 = Unassigned (default to person centric)
67 // 3 = Company Centric
68 $sql = sqlStatement("SELECT option_id, option_value FROM list_options WHERE " .
69 "list_id = 'abook_type' AND activity = 1");
70 while ($row_query = sqlFetchArray($sql)) {
71 echo "type_options_js"."['" . attr($row_query['option_id']) . "']=" . attr($row_query['option_value']) . ";\n";
75 // Process to customize the form by type
76 function typeSelect(a
) {
78 $
('#cpoe_span').css('display','inline');
80 $
('#cpoe_span').css('display','none');
81 $
('#form_cpoe').removeAttr('checked');
83 if (type_options_js
[a
] == 3) {
85 // 1) Hide the person Name entries
86 // 2) Hide the Specialty entry
87 // 3) Show the director Name entries
88 document
.getElementById("nameRow").style
.display
= "none";
89 document
.getElementById("specialtyRow").style
.display
= "none";
90 document
.getElementById("nameDirectorRow").style
.display
= "";
94 // 1) Hide the director Name entries
95 // 2) Show the person Name entries
96 // 3) Show the Specialty entry
97 document
.getElementById("nameDirectorRow").style
.display
= "none";
98 document
.getElementById("nameRow").style
.display
= "";
99 document
.getElementById("specialtyRow").style
.display
= "";
106 <body
class="body_top">
108 // If we are saving, then save and close the window.
110 if ($_POST['form_save']) {
112 // Collect the form_abook_type option value
113 // (ie. patient vs company centric)
114 $type_sql_row = sqlQuery("SELECT `option_value` FROM `list_options` WHERE `list_id` = 'abook_type' AND `option_id` = ? AND activity = 1", array(trim($_POST['form_abook_type'])));
115 $option_abook_type = $type_sql_row['option_value'];
116 // Set up any abook_type specific settings
117 if ($option_abook_type == 3) {
119 $form_title = invalue('form_director_title');
120 $form_fname = invalue('form_director_fname');
121 $form_lname = invalue('form_director_lname');
122 $form_mname = invalue('form_director_mname');
123 $form_suffix = invalue('form_director_suffix');
127 $form_title = invalue('form_title');
128 $form_fname = invalue('form_fname');
129 $form_lname = invalue('form_lname');
130 $form_mname = invalue('form_mname');
131 $form_suffix = invalue('form_suffix');
136 $query = "UPDATE users SET " .
137 "abook_type = " . invalue('form_abook_type') . ", " .
138 "title = " . $form_title . ", " .
139 "fname = " . $form_fname . ", " .
140 "lname = " . $form_lname . ", " .
141 "mname = " . $form_mname . ", " .
142 "suffix = " . $form_suffix . ", " .
143 "specialty = " . invalue('form_specialty') . ", " .
144 "organization = " . invalue('form_organization') . ", " .
145 "valedictory = " . invalue('form_valedictory') . ", " .
146 "assistant = " . invalue('form_assistant') . ", " .
147 "federaltaxid = " . invalue('form_federaltaxid') . ", " .
148 "upin = " . invalue('form_upin') . ", " .
149 "npi = " . invalue('form_npi') . ", " .
150 "taxonomy = " . invalue('form_taxonomy') . ", " .
151 "cpoe = " . invalue('form_cpoe') . ", " .
152 "email = " . invalue('form_email') . ", " .
153 "email_direct = " . invalue('form_email_direct') . ", " .
154 "url = " . invalue('form_url') . ", " .
155 "street = " . invalue('form_street') . ", " .
156 "streetb = " . invalue('form_streetb') . ", " .
157 "city = " . invalue('form_city') . ", " .
158 "state = " . invalue('form_state') . ", " .
159 "zip = " . invalue('form_zip') . ", " .
160 "street2 = " . invalue('form_street2') . ", " .
161 "streetb2 = " . invalue('form_streetb2') . ", " .
162 "city2 = " . invalue('form_city2') . ", " .
163 "state2 = " . invalue('form_state2') . ", " .
164 "zip2 = " . invalue('form_zip2') . ", " .
165 "phone = " . invalue('form_phone') . ", " .
166 "phonew1 = " . invalue('form_phonew1') . ", " .
167 "phonew2 = " . invalue('form_phonew2') . ", " .
168 "phonecell = " . invalue('form_phonecell') . ", " .
169 "fax = " . invalue('form_fax') . ", " .
170 "notes = " . invalue('form_notes') . " " .
171 "WHERE id = '" . add_escape_custom($userid) . "'";
172 sqlStatement($query);
176 $userid = sqlInsert("INSERT INTO users ( " .
177 "username, password, authorized, info, source, " .
178 "title, fname, lname, mname, suffix, " .
179 "federaltaxid, federaldrugid, upin, facility, see_auth, active, npi, taxonomy, cpoe, " .
180 "specialty, organization, valedictory, assistant, billname, email, email_direct, url, " .
181 "street, streetb, city, state, zip, " .
182 "street2, streetb2, city2, state2, zip2, " .
183 "phone, phonew1, phonew2, phonecell, fax, notes, abook_type " .
187 "0, " . // authorized
194 $form_suffix . ", " .
195 invalue('form_federaltaxid') . ", " .
196 "'', " . // federaldrugid
197 invalue('form_upin') . ", " .
201 invalue('form_npi') . ", " .
202 invalue('form_taxonomy') . ", " .
203 invalue('form_cpoe') . ", " .
204 invalue('form_specialty') . ", " .
205 invalue('form_organization') . ", " .
206 invalue('form_valedictory') . ", " .
207 invalue('form_assistant') . ", " .
209 invalue('form_email') . ", " .
210 invalue('form_email_direct') . ", " .
211 invalue('form_url') . ", " .
212 invalue('form_street') . ", " .
213 invalue('form_streetb') . ", " .
214 invalue('form_city') . ", " .
215 invalue('form_state') . ", " .
216 invalue('form_zip') . ", " .
217 invalue('form_street2') . ", " .
218 invalue('form_streetb2') . ", " .
219 invalue('form_city2') . ", " .
220 invalue('form_state2') . ", " .
221 invalue('form_zip2') . ", " .
222 invalue('form_phone') . ", " .
223 invalue('form_phonew1') . ", " .
224 invalue('form_phonew2') . ", " .
225 invalue('form_phonecell') . ", " .
226 invalue('form_fax') . ", " .
227 invalue('form_notes') . ", " .
228 invalue('form_abook_type') . " " .
234 else if ($_POST['form_delete']) {
237 // Be careful not to delete internal users.
238 sqlStatement("DELETE FROM users WHERE id = ? AND username = ''", array($userid));
243 if ($_POST['form_save'] ||
$_POST['form_delete']) {
244 // Close this window and redisplay the updated list.
245 echo "<script language='JavaScript'>\n";
246 if ($info_msg) echo " alert('".addslashes($info_msg)."');\n";
247 echo " window.close();\n";
248 echo " if (opener.refreshme) opener.refreshme();\n";
249 echo "</script></body></html>\n";
254 $row = sqlQuery("SELECT * FROM users WHERE id = ?", array($userid));
257 if ($type) { // note this only happens when its new
259 $row['abook_type'] = $type;
264 <script language
="JavaScript">
265 $
(document
).ready(function() {
266 // customize the form via the type options
267 typeSelect("<?php echo attr($row['abook_type']); ?>");
268 if(typeof abook_type
!= 'undefined' && abook_type
== 'ord_lab') {
269 $
('#cpoe_span').css('display','inline');
274 <form method
='post' name
='theform' id
="theform" action
='addrbook_edit.php?userid=<?php echo attr($userid) ?>'>
277 <table border
='0' width
='100%'>
279 <?php
if (acl_check('admin', 'practice' )) { // allow choose type option if have admin access ?>
281 <td width
='1%' nowrap
><b
><?php
echo xlt('Type'); ?
>:</b
></td
>
284 echo generate_select_list('form_abook_type', 'abook_type', $row['abook_type'], '', 'Unassigned', '', 'typeSelect(this.value)');
288 <?php
} // end of if has admin access ?>
291 <td width
='1%' nowrap
><b
><?php
echo xlt('Name'); ?
>:</b
></td
>
294 generate_form_field(array('data_type'=>1,'field_id'=>'title','list_id'=>'titles','empty_title'=>' '), $row['title']);
296 <b
><?php
echo xlt('Last'); ?
>:</b
><input type
='text' size
='10' name
='form_lname' class='inputtext'
297 maxlength
='50' value
='<?php echo attr($row['lname
']); ?>'/> 
;
298 <b
><?php
echo xlt('First'); ?
>:</b
> <input type
='text' size
='10' name
='form_fname' class='inputtext'
299 maxlength
='50' value
='<?php echo attr($row['fname
']); ?>' /> 
;
300 <b
><?php
echo xlt('Middle'); ?
>:</b
> <input type
='text' size
='4' name
='form_mname' class='inputtext'
301 maxlength
='50' value
='<?php echo attr($row['mname
']); ?>' />
302 <b
><?php
echo xlt('Suffix'); ?
>:</b
> <input type
='text' size
='4' name
='form_suffix' class='inputtext'
303 maxlength
='50' value
='<?php echo attr($row['suffix
']); ?>' />
307 <tr id
="specialtyRow">
308 <td nowrap
><b
><?php
echo xlt('Specialty'); ?
>:</b
></td
>
310 <input type
='text' size
='40' name
='form_specialty' maxlength
='250'
311 value
='<?php echo attr($row['specialty
']); ?>'
312 style
='width:100%' class='inputtext' />
317 <td nowrap
><b
><?php
echo xlt('Organization'); ?
>:</b
></td
>
319 <input type
='text' size
='40' name
='form_organization' maxlength
='250'
320 value
='<?php echo attr($row['organization
']); ?>'
321 style
='width:100%' class='inputtext' />
322 <span id
='cpoe_span' style
="display:none;">
323 <input type
='checkbox' title
="<?php echo xla('CPOE'); ?>" name
='form_cpoe' id
='form_cpoe' value
='1' <?php
if($row['cpoe']=='1') echo "CHECKED"; ?
>/>
324 <label
for='form_cpoe'><b
><?php
echo xlt('CPOE'); ?
></b
></label
>
329 <tr id
="nameDirectorRow">
330 <td width
='1%' nowrap
><b
><?php
echo xlt('Director Name'); ?
>:</b
></td
>
333 generate_form_field(array('data_type'=>1,'field_id'=>'director_title','list_id'=>'titles','empty_title'=>' '), $row['title']);
335 <b
><?php
echo xlt('Last'); ?
>:</b
><input type
='text' size
='10' name
='form_director_lname' class='inputtext'
336 maxlength
='50' value
='<?php echo attr($row['lname
']); ?>'/> 
;
337 <b
><?php
echo xlt('First'); ?
>:</b
> <input type
='text' size
='10' name
='form_director_fname' class='inputtext'
338 maxlength
='50' value
='<?php echo attr($row['fname
']); ?>' /> 
;
339 <b
><?php
echo xlt('Middle'); ?
>:</b
> <input type
='text' size
='4' name
='form_director_mname' class='inputtext'
340 maxlength
='50' value
='<?php echo attr($row['mname
']); ?>' />
341 <b
><?php
echo xlt('Suffix'); ?
>:</b
> <input type
='text' size
='4' name
='form_director_suffix' class='inputtext'
342 maxlength
='50' value
='<?php echo attr($row['suffix
']); ?>' />
347 <td nowrap
><b
><?php
echo xlt('Valedictory'); ?
>:</b
></td
>
349 <input type
='text' size
='40' name
='form_valedictory' maxlength
='250'
350 value
='<?php echo attr($row['valedictory
']); ?>'
351 style
='width:100%' class='inputtext' />
356 <td nowrap
><b
><?php
echo xlt('Home Phone'); ?
>:</b
></td
>
358 <input type
='text' size
='11' name
='form_phone' value
='<?php echo attr($row['phone
']); ?>'
359 maxlength
='30' class='inputtext' /> 
;
360 <b
><?php
echo xlt('Mobile'); ?
>:</b
><input type
='text' size
='11' name
='form_phonecell'
361 maxlength
='30' value
='<?php echo attr($row['phonecell
']); ?>' class='inputtext' />
366 <td nowrap
><b
><?php
echo xlt('Work Phone'); ?
>:</b
></td
>
368 <input type
='text' size
='11' name
='form_phonew1' value
='<?php echo attr($row['phonew1
']); ?>'
369 maxlength
='30' class='inputtext' /> 
;
370 <b
><?php
echo xlt('2nd'); ?
>:</b
><input type
='text' size
='11' name
='form_phonew2' value
='<?php echo attr($row['phonew2
']); ?>'
371 maxlength
='30' class='inputtext' /> 
;
372 <b
><?php
echo xlt('Fax'); ?
>:</b
> <input type
='text' size
='11' name
='form_fax' value
='<?php echo attr($row['fax
']); ?>'
373 maxlength
='30' class='inputtext' />
378 <td nowrap
><b
><?php
echo xlt('Assistant'); ?
>:</b
></td
>
380 <input type
='text' size
='40' name
='form_assistant' maxlength
='250'
381 value
='<?php echo attr($row['assistant
']); ?>'
382 style
='width:100%' class='inputtext' />
387 <td nowrap
><b
><?php
echo xlt('Email'); ?
>:</b
></td
>
389 <input type
='text' size
='40' name
='form_email' maxlength
='250'
390 value
='<?php echo attr($row['email
']); ?>'
391 style
='width:100%' class='inputtext' />
396 <td nowrap
><b
><?php
echo xlt('Trusted Email'); ?
>:</b
></td
>
398 <input type
='text' size
='40' name
='form_email_direct' maxlength
='250'
399 value
='<?php echo attr($row['email_direct
']); ?>'
400 style
='width:100%' class='inputtext' />
405 <td nowrap
><b
><?php
echo xlt('Website'); ?
>:</b
></td
>
407 <input type
='text' size
='40' name
='form_url' maxlength
='250'
408 value
='<?php echo attr($row['url
']); ?>'
409 style
='width:100%' class='inputtext' />
414 <td nowrap
><b
><?php
echo xlt('Main Address'); ?
>:</b
></td
>
416 <input type
='text' size
='40' name
='form_street' maxlength
='60'
417 value
='<?php echo attr($row['street
']); ?>'
418 style
='width:100%' class='inputtext' />
423 <td nowrap
> 
;</td
>
425 <input type
='text' size
='40' name
='form_streetb' maxlength
='60'
426 value
='<?php echo attr($row['streetb
']); ?>'
427 style
='width:100%' class='inputtext' />
432 <td nowrap
><b
><?php
echo xlt('City'); ?
>:</b
></td
>
434 <input type
='text' size
='10' name
='form_city' maxlength
='30'
435 value
='<?php echo attr($row['city
']); ?>' class='inputtext' /> 
;
436 <b
><?php
echo xlt('State')."/".xlt('county'); ?
>:</b
> <input type
='text' size
='10' name
='form_state' maxlength
='30'
437 value
='<?php echo attr($row['state
']); ?>' class='inputtext' /> 
;
438 <b
><?php
echo xlt('Postal code'); ?
>:</b
> <input type
='text' size
='10' name
='form_zip' maxlength
='20'
439 value
='<?php echo attr($row['zip
']); ?>' class='inputtext' />
444 <td nowrap
><b
><?php
echo xlt('Alt Address'); ?
>:</b
></td
>
446 <input type
='text' size
='40' name
='form_street2' maxlength
='60'
447 value
='<?php echo attr($row['street2
']); ?>'
448 style
='width:100%' class='inputtext' />
453 <td nowrap
> 
;</td
>
455 <input type
='text' size
='40' name
='form_streetb2' maxlength
='60'
456 value
='<?php echo attr($row['streetb2
']); ?>'
457 style
='width:100%' class='inputtext' />
462 <td nowrap
><b
><?php
echo xlt('City'); ?
>:</b
></td
>
464 <input type
='text' size
='10' name
='form_city2' maxlength
='30'
465 value
='<?php echo attr($row['city2
']); ?>' class='inputtext' /> 
;
466 <b
><?php
echo xlt('State')."/".xlt('county'); ?
>:</b
> <input type
='text' size
='10' name
='form_state2' maxlength
='30'
467 value
='<?php echo attr($row['state2
']); ?>' class='inputtext' /> 
;
468 <b
><?php
echo xlt('Postal code'); ?
>:</b
> <input type
='text' size
='10' name
='form_zip2' maxlength
='20'
469 value
='<?php echo attr($row['zip2
']); ?>' class='inputtext' />
474 <td nowrap
><b
><?php
echo xlt('UPIN'); ?
>:</b
></td
>
476 <input type
='text' size
='6' name
='form_upin' maxlength
='6'
477 value
='<?php echo attr($row['upin
']); ?>' class='inputtext' /> 
;
478 <b
><?php
echo xlt('NPI'); ?
>:</b
> <input type
='text' size
='10' name
='form_npi' maxlength
='10'
479 value
='<?php echo attr($row['npi
']); ?>' class='inputtext' /> 
;
480 <b
><?php
echo xlt('TIN'); ?
>:</b
> <input type
='text' size
='10' name
='form_federaltaxid' maxlength
='10'
481 value
='<?php echo attr($row['federaltaxid
']); ?>' class='inputtext' /> 
;
482 <b
><?php
echo xlt('Taxonomy'); ?
>:</b
> <input type
='text' size
='10' name
='form_taxonomy' maxlength
='10'
483 value
='<?php echo attr($row['taxonomy
']); ?>' class='inputtext' />
488 <td nowrap
><b
><?php
echo xlt('Notes'); ?
>:</b
></td
>
490 <textarea rows
='3' cols
='40' name
='form_notes' style
='width:100%'
491 wrap
='virtual' class='inputtext' /><?php
echo text($row['notes']) ?
></textarea
>
499 <input type
='submit' name
='form_save' value
='<?php echo xla('Save
'); ?>' />
501 <?php
if ($userid && !$row['username']) { ?
>
503 <input type
='submit' name
='form_delete' value
='<?php echo xla('Delete
'); ?>' style
='color:red' />
507 <input type
='button' value
='<?php echo xla('Cancel
'); ?>' onclick
='window.close()' />
511 <?php
$use_validate_js = 1;?
>
512 <?php
validateUsingPageRules($_SERVER['PHP_SELF']);?
>