2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
6 require_once("../globals.php");
7 require_once("../../library/acl.inc");
8 require_once("$srcdir/sql.inc");
9 require_once("$srcdir/formdata.inc.php");
10 require_once("$srcdir/calendar.inc");
11 require_once("$srcdir/options.inc.php");
12 require_once(dirname(__FILE__
) . "/../../library/classes/WSProvider.class.php");
13 require_once("$srcdir/erx_javascript.inc.php");
15 if (!$_GET["id"] ||
!acl_check('admin', 'users'))
18 if ($_GET["mode"] == "update") {
19 if ($_GET["username"]) {
20 // $tqvar = addslashes(trim($_GET["username"]));
21 $tqvar = trim(formData('username','G'));
22 $user_data = mysql_fetch_array(sqlStatement("select * from users where id={$_GET["id
"]}"));
23 sqlStatement("update users set username='$tqvar' where id={$_GET["id
"]}");
24 sqlStatement("update groups set user='$tqvar' where user='". $user_data["username"] ."'");
25 //echo "query was: " ."update groups set user='$tqvar' where user='". $user_data["username"] ."'" ;
28 $tqvar = formData('taxid','G');
29 sqlStatement("update users set federaltaxid='$tqvar' where id={$_GET["id
"]}");
31 if ($_GET["drugid"]) {
32 $tqvar = formData('drugid','G');
33 sqlStatement("update users set federaldrugid='$tqvar' where id={$_GET["id
"]}");
36 $tqvar = formData('upin','G');
37 sqlStatement("update users set upin='$tqvar' where id={$_GET["id
"]}");
40 $tqvar = formData('npi','G');
41 sqlStatement("update users set npi='$tqvar' where id={$_GET["id
"]}");
43 if ($_GET["taxonomy"]) {
44 $tqvar = formData('taxonomy','G');
45 sqlStatement("update users set taxonomy = '$tqvar' where id= {$_GET["id
"]}");
48 $tqvar = formData('lname','G');
49 sqlStatement("update users set lname='$tqvar' where id={$_GET["id
"]}");
52 $tqvar = formData('job','G');
53 sqlStatement("update users set specialty='$tqvar' where id={$_GET["id
"]}");
56 $tqvar = formData('mname','G');
57 sqlStatement("update users set mname='$tqvar' where id={$_GET["id
"]}");
59 if ($_GET["facility_id"]) {
60 $tqvar = formData('facility_id','G');
61 sqlStatement("update users set facility_id = '$tqvar' where id = {$_GET["id
"]}");
62 //(CHEMED) Update facility name when changing the id
63 sqlStatement("UPDATE users, facility SET users.facility = facility.name WHERE facility.id = '$tqvar' AND users.id = {$_GET["id
"]}");
66 if ($GLOBALS['restrict_user_facility'] && $_GET["schedule_facility"]) {
67 sqlStatement("delete from users_facility
68 where tablename='users'
69 and table_id={$_GET["id
"]}
70 and facility_id not in (" . implode(",", $_GET['schedule_facility']) . ")");
71 foreach($_GET["schedule_facility"] as $tqvar) {
72 sqlStatement("replace into users_facility set
73 facility_id = '$tqvar',
75 table_id = {$_GET["id
"]}");
79 $tqvar = formData('fname','G');
80 sqlStatement("update users set fname='$tqvar' where id={$_GET["id
"]}");
82 //(CHEMED) Calendar UI preference
83 if ($_GET["cal_ui"]) {
84 $tqvar = formData('cal_ui','G');
85 sqlStatement("update users set cal_ui = '$tqvar' where id = {$_GET["id
"]}");
87 // added by bgm to set this session variable if the current user has edited
89 if ($_SESSION['authId'] == $_GET["id"]) {
90 $_SESSION['cal_ui'] = $tqvar;
93 //END (CHEMED) Calendar UI preference
95 if (isset($_GET['default_warehouse'])) {
96 sqlStatement("UPDATE users SET default_warehouse = '" .
97 formData('default_warehouse','G') .
98 "' WHERE id = '" . formData('id','G') . "'");
101 if (isset($_GET['irnpool'])) {
102 sqlStatement("UPDATE users SET irnpool = '" .
103 formData('irnpool','G') .
104 "' WHERE id = '" . formData('id','G') . "'");
107 if ($_GET["newauthPass"] && $_GET["newauthPass"] != "d41d8cd98f00b204e9800998ecf8427e") { // account for empty
108 $tqvar = formData('newauthPass','G');
109 sqlStatement("update users set password='$tqvar' where id={$_GET["id
"]}");
112 // for relay health single sign-on
113 if ($_GET["ssi_relayhealth"]) {
114 $tqvar = formData('ssi_relayhealth','G');
115 sqlStatement("update users set ssi_relayhealth = '$tqvar' where id = {$_GET["id
"]}");
118 $tqvar = $_GET["authorized"] ?
1 : 0;
119 $actvar = $_GET["active"] ?
1 : 0;
120 $calvar = $_GET["calendar"] ?
1 : 0;
122 sqlStatement("UPDATE users SET authorized = $tqvar, active = $actvar, " .
123 "calendar = $calvar, see_auth = '" . $_GET['see_auth'] . "' WHERE " .
124 "id = {$_GET["id
"]}");
126 if ($_GET["comments"]) {
127 $tqvar = formData('comments','G');
128 sqlStatement("update users set info = '$tqvar' where id = {$_GET["id
"]}");
131 if (isset($phpgacl_location) && acl_check('admin', 'acl')) {
132 // Set the access control group of user
133 $user_data = mysql_fetch_array(sqlStatement("select username from users where id={$_GET["id
"]}"));
134 set_user_aro($_GET['access_group'], $user_data["username"],
135 formData('fname','G'), formData('mname','G'), formData('lname','G'));
138 $ws = new WSProvider($_GET['id']);
140 /*Dont move usergroup_admin (1).php just close window
141 // On a successful update, return to the users list.
142 include("usergroup_admin.php");
145 <script type="text/javascript">
147 parent.$.fn.fancybox.close();
154 $res = sqlStatement("select * from users where id=?",array($_GET["id"]));
155 for ($iter = 0;$row = sqlFetchArray($res);$iter++
)
156 $result[$iter] = $row;
160 if (isset($_POST["mode"])) {
162 <script type="text/javascript">
164 parent.$.fn.fancybox.close();
177 <link rel
="stylesheet" href
="<?php echo $css_header; ?>" type
="text/css">
178 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
179 <script type
="text/javascript" src
="../../library/js/jquery.1.3.2.js"></script
>
180 <script type
="text/javascript" src
="../../library/js/common.js"></script
>
182 <script src
="checkpwd_validation.js" type
="text/javascript"></script
>
184 <script language
="JavaScript">
185 function checkChange()
187 alert("<?php echo addslashes(xl('If you change e-RX Role for ePrescription, it may affect the ePrescription workflow. If you face any difficulty, contact your ePrescription vendor.'));?>");
189 function submitform() {
190 top
.restoreSession();
192 function trimAll(sString
)
194 while (sString
.substring(0,1) == ' ')
196 sString
= sString
.substring(1, sString
.length
);
198 while (sString
.substring(sString
.length
-1, sString
.length
) == ' ')
200 sString
= sString
.substring(0,sString
.length
-1);
204 if(trimAll(document
.getElementById('fname').value
) == ""){
205 alert("<?php xl('Required field missing: Please enter the First name','e');?>");
206 document
.getElementById('fname').style
.backgroundColor
="red";
207 document
.getElementById('fname').focus();
210 if(trimAll(document
.getElementById('lname').value
) == ""){
211 alert("<?php xl('Required field missing: Please enter the Last name','e');?>");
212 document
.getElementById('lname').style
.backgroundColor
="red";
213 document
.getElementById('lname').focus();
216 if(document
.forms
[0].clearPass
.value
!="")
218 //Checking for the strong password if the 'secure password' feature is enabled
219 if(document
.forms
[0].secure_pwd
.value
== 1)
221 var pwdresult
= passwordvalidate(document
.forms
[0].clearPass
.value
);
224 alert("<?php echo xl('The password must be at least eight characters, and should'); echo '\n'; echo xl('contain at least three of the four following items:'); echo '\n'; echo xl('A number'); echo '\n'; echo xl('A lowercase letter'); echo '\n'; echo xl('An uppercase letter'); echo '\n'; echo xl('A special character');echo '('; echo xl('not a letter or number'); echo ').'; echo '\n'; echo xl('For example:'); echo ' healthCare@09'; ?>");
229 }//If pwd null ends here
230 //Request to reset the user password if the user was deactived once the password expired.
231 if((document
.forms
[0].pwd_expires
.value
!= 0) && (document
.forms
[0].clearPass
.value
== "")) {
232 if((document
.forms
[0].user_type
.value
!= "Emergency Login") && (document
.forms
[0].pre_active
.value
== 0) && (document
.forms
[0].active
.checked
== 1) && (document
.forms
[0].grace_time
.value
!= "") && (document
.forms
[0].current_date
.value
) > (document
.forms
[0].grace_time
.value
))
235 document
.getElementById('error_message').innerHTML
="<?php xl('Please reset the password.','e') ?>";
239 if (document
.forms
[0].access_group_id
) {
240 var sel
= getSelected(document
.forms
[0].access_group_id
.options
);
241 for (var item in sel
) {
242 if (sel
[item
].value
== "Emergency Login") {
243 document
.forms
[0].check_acl
.value
= 1;
248 <?php
if($GLOBALS['erx_enable']){ ?
>
251 for(i
=0;i
<f
.length
;i++
){
252 if(f
[i
].type
=='text' && f
[i
].value
)
254 if(f
[i
].name
== 'fname' || f
[i
].name
== 'mname' || f
[i
].name
== 'lname')
256 alertMsg +
= checkLength(f
[i
].name
,f
[i
].value
,35);
257 alertMsg +
= checkUsername(f
[i
].name
,f
[i
].value
);
259 else if(f
[i
].name
== 'taxid')
261 alertMsg +
= checkLength(f
[i
].name
,f
[i
].value
,10);
262 alertMsg +
= checkFederalEin(f
[i
].name
,f
[i
].value
);
264 else if(f
[i
].name
== 'state_license_number')
266 alertMsg +
= checkLength(f
[i
].name
,f
[i
].value
,10);
267 alertMsg +
= checkStateLicenseNumber(f
[i
].name
,f
[i
].value
);
269 else if(f
[i
].name
== 'npi')
271 alertMsg +
= checkLength(f
[i
].name
,f
[i
].value
,10);
272 alertMsg +
= checkTaxNpiDea(f
[i
].name
,f
[i
].value
);
274 else if(f
[i
].name
== 'drugid')
276 alertMsg +
= checkLength(f
[i
].name
,f
[i
].value
,30);
277 alertMsg +
= checkAlphaNumeric(f
[i
].name
,f
[i
].value
);
288 document
.forms
[0].submit();
289 parent
.$
.fn
.fancybox
.close();
292 //Getting the list of selected item in ACL
293 function getSelected(opt
) {
294 var selected
= new Array();
296 for (var intLoop
= 0; intLoop
< opt
.length
; intLoop++
) {
297 if ((opt
[intLoop
].selected
) ||
298 (opt
[intLoop
].checked
)) {
299 index
= selected
.length
;
300 selected
[index
] = new Object;
301 selected
[index
].value
= opt
[intLoop
].value
;
302 selected
[index
].index
= intLoop
;
308 function authorized_clicked() {
309 var f
= document
.forms
[0];
310 f
.calendar
.disabled
= !f
.authorized
.checked
;
311 f
.calendar
.checked
= f
.authorized
.checked
;
315 <style type
="text/css">
316 .physician_type_class
{
317 width
: 150px
!important
;
321 <body
class="body_top">
323 <span
class="title"><?php
xl('Edit User','e'); ?
></span
> 
;
325 <a
class="css_button" name
='form_save' id
='form_save' href
='#' onclick
='return submitform()'> <span
><?php
xl('Save','e');?
></span
> </a
>
326 <a
class="css_button" id
='cancel' href
='#'><span
><?php
xl('Cancel','e');?
></span
></a
>
330 <FORM NAME
="user_form" METHOD
="POST" ACTION
="usergroup_admin.php" target
="_parent" onsubmit
='return top.restoreSession()'>
332 <input type
=hidden name
="pwd_expires" value
="<?php echo $GLOBALS['password_expiration_days']; ?>" >
333 <input type
=hidden name
="pre_active" value
="<?php echo $iter["active
"]; ?>" >
334 <input type
=hidden name
="exp_date" value
="<?php echo $iter["pwd_expiration_date
"]; ?>" >
335 <input type
=hidden name
="get_admin_id" value
="<?php echo $GLOBALS['Emergency_Login_email']; ?>" >
336 <input type
=hidden name
="admin_id" value
="<?php echo $GLOBALS['Emergency_Login_email_id']; ?>" >
337 <input type
=hidden name
="check_acl" value
="">
339 //Calculating the grace time
340 $current_date = date("Y-m-d");
341 $password_exp=$iter["pwd_expiration_date"];
342 if($password_exp != "0000-00-00")
344 $grace_time1 = date("Y-m-d", strtotime($password_exp . "+".$GLOBALS['password_grace_time'] ."days"));
347 <input type
=hidden name
="current_date" value
="<?php echo strtotime($current_date); ?>" >
348 <input type
=hidden name
="grace_time" value
="<?php echo strtotime($grace_time1); ?>" >
349 <!-- Get the
list ACL
for the user
-->
351 $acl_name=acl_get_group_titles($iter["username"]);
353 $bg_count=count($acl_name);
354 for($i=0;$i<$bg_count;$i++
){
355 if($acl_name[$i] == "Emergency Login")
356 $bg_name=$acl_name[$i];
359 <input type
=hidden name
="user_type" value
="<?php echo $bg_name; ?>" >
361 <TABLE border
=0 cellpadding
=0 cellspacing
=0>
363 <TD style
="width:180px;"><span
class=text
><?php
xl('Username','e'); ?
>: </span
></TD
>
364 <TD style
="width:270px;"><input type
=entry name
=username style
="width:150px;" value
="<?php echo $iter["username
"]; ?>" disabled
></td
>
365 <TD style
="width:200px;"><span
class=text
><?php
xl('Your Password','e'); ?
>: </span
></TD
>
366 <TD
class='text' style
="width:280px;"><input type
='password' name
=adminPass style
="width:150px;" value
="" autocomplete
='off'><font
class="mandatory">*</font
></TD
>
369 <TD style
="width:180px;"><span
class=text
></span
></TD
>
370 <TD style
="width:270px;"></td
>
371 <TD style
="width:200px;"><span
class=text
><?php
xl('User\'s New Password','e'); ?
>: </span
></TD
>
372 <TD
class='text' style
="width:280px;"> <input type
=text name
=clearPass style
="width:150px;" value
=""><font
class="mandatory">*</font
></td
>
376 <TR height
="30" style
="valign:middle;">
377 <td
><span
class="text"> 
;</span
></td
><td
> 
;</td
>
378 <td colspan
="2"><span
class=text
><?php
xl('Provider','e'); ?
>:
379 <input type
="checkbox" name
="authorized" onclick
="authorized_clicked()"<?php
380 if ($iter["authorized"]) echo " checked"; ?
> />
381  
; 
;<span
class='text'><?php
xl('Calendar','e'); ?
>:
382 <input type
="checkbox" name
="calendar"<?php
383 if ($iter["calendar"]) echo " checked";
384 if (!$iter["authorized"]) echo " disabled"; ?
> />
385  
; 
;<span
class='text'><?php
xl('Active','e'); ?
>:
386 <input type
="checkbox" name
="active"<?php
if ($iter["active"]) echo " checked"; ?
> />
391 <TD
><span
class=text
><?php
xl('First Name','e'); ?
>: </span
></TD
>
392 <TD
><input type
=entry name
=fname id
=fname style
="width:150px;" value
="<?php echo $iter["fname
"]; ?>"><span
class="mandatory"> 
;*</span
></td
>
393 <td
><span
class=text
><?php
xl('Middle Name','e'); ?
>: </span
></TD
><td
><input type
=entry name
=mname style
="width:150px;" value
="<?php echo $iter["mname
"]; ?>"></td
>
397 <td
><span
class=text
><?php
xl('Last Name','e'); ?
>: </span
></td
><td
><input type
=entry name
=lname id
=lname style
="width:150px;" value
="<?php echo $iter["lname
"]; ?>"><span
class="mandatory"> 
;*</span
></td
>
398 <td
><span
class=text
><?php
xl('Default Facility','e'); ?
>: </span
></td
><td
><select name
=facility_id style
="width:150px;" >
400 $fres = sqlStatement("select * from facility where service_location != 0 order by name");
402 for ($iter2 = 0; $frow = sqlFetchArray($fres); $iter2++
)
403 $result[$iter2] = $frow;
404 foreach($result as $iter2) {
406 <option value
="<?php echo $iter2['id']; ?>" <?php
if ($iter['facility_id'] == $iter2['id']) echo "selected"; ?
>><?php
echo htmlspecialchars($iter2['name']); ?
></option
>
414 <?php
if ($GLOBALS['restrict_user_facility']) { ?
>
416 <td colspan
=2> 
;</td
>
417 <td
><span
class=text
><?php
xl('Schedule Facilities:', 'e');?
></td
>
419 <select name
="schedule_facility[]" multiple style
="width:150px;" >
421 $userFacilities = getUserFacilities($_GET['id']);
423 foreach($userFacilities as $uf)
425 $fres = sqlStatement("select * from facility where service_location != 0 order by name");
427 while($frow = sqlFetchArray($fres)):
429 <option
<?php
echo in_array($frow['id'], $ufid) ||
$frow['id'] == $iter['facility_id'] ?
"selected" : null ?
>
430 value
="<?php echo $frow['id'] ?>"><?php
echo htmlspecialchars($frow['name']) ?
></option
>
441 <TD
><span
class=text
><?php
xl('Federal Tax ID','e'); ?
>: </span
></TD
><TD
><input type
=text name
=taxid style
="width:150px;" value
="<?php echo $iter["federaltaxid
"]?>"></td
>
442 <TD
><span
class=text
><?php
xl('Federal Drug ID','e'); ?
>: </span
></TD
><TD
><input type
=text name
=drugid style
="width:150px;" value
="<?php echo $iter["federaldrugid
"]?>"></td
>
446 <td
><span
class="text"><?php
xl('UPIN','e'); ?
>: </span
></td
><td
><input type
="text" name
="upin" style
="width:150px;" value
="<?php echo $iter["upin
"]?>"></td
>
447 <td
class='text'><?php
xl('See Authorizations','e'); ?
>: </td
>
448 <td
><select name
="see_auth" style
="width:150px;" >
450 foreach (array(1 => xl('None'), 2 => xl('Only Mine'), 3 => xl('All')) as $key => $value)
452 echo " <option value='$key'";
453 if ($key == $iter['see_auth']) echo " selected";
454 echo ">$value</option>\n";
461 <td
><span
class="text"><?php
xl('NPI','e'); ?
>: </span
></td
><td
><input type
="text" name
="npi" style
="width:150px;" value
="<?php echo $iter["npi
"]?>"></td
>
462 <td
><span
class="text"><?php
xl('Job Description','e'); ?
>: </span
></td
><td
><input type
="text" name
="job" style
="width:150px;" value
="<?php echo $iter["specialty
"]?>"></td
>
465 <?php
if (!empty($GLOBALS['ssi']['rh'])) { ?
>
467 <td
><span
class="text"><?php
xl('Relay Health ID', 'e'); ?
>: </span
></td
>
468 <td
><input type
="password" name
="ssi_relayhealth" style
="width:150px;" value
="<?php echo $iter["ssi_relayhealth
"]; ?>"></td
>
472 <!-- (CHEMED
) Calendar UI preference
-->
474 <td
><span
class="text"><?php
xl('Taxonomy','e'); ?
>: </span
></td
>
475 <td
><input type
="text" name
="taxonomy" style
="width:150px;" value
="<?php echo $iter["taxonomy
"]?>"></td
>
476 <td
><span
class="text"><?php
xl('Calendar UI','e'); ?
>: </span
></td
><td
><select name
="cal_ui" style
="width:150px;" >
478 foreach (array(3 => xl('Outlook'), 1 => xl('Original'), 2 => xl('Fancy')) as $key => $value)
480 echo " <option value='$key'";
481 if ($key == $iter['cal_ui']) echo " selected";
482 echo ">$value</option>\n";
487 <!-- END (CHEMED
) Calendar UI preference
-->
490 <td
><span
class="text"><?php
xl('State License Number','e'); ?
>: </span
></td
>
491 <td
><input type
="text" name
="state_license_number" style
="width:150px;" value
="<?php echo $iter["state_license_number
"]?>"></td
>
492 <td
class='text'><?php
xl('NewCrop eRX Role','e'); ?
>:</td
>
494 <?php
echo generate_select_list("erxrole", "newcrop_erx_role", $iter['newcrop_user_role'],'',xl('Select Role'),'','','',array('style'=>'width:150px')); ?
>
499 <td
><span
class="text"><?php
xl('Provider Type','e'); ?
>: </span
></td
>
500 <td
><?php
echo generate_select_list("physician_type", "physician_type", $iter['physician_type'],'',xl('Select Type'),'physician_type_class','','',''); ?
></td
>
502 <?php
if ($GLOBALS['inhouse_pharmacy']) { ?
>
504 <td
class="text"><?php
xl('Default Warehouse','e'); ?
>: </td
>
507 echo generate_select_list('default_warehouse', 'warehouse',
508 $iter['default_warehouse'], '');
511 <td
class="text"><?php
xl('Invoice Refno Pool','e'); ?
>: </td
>
514 echo generate_select_list('irnpool', 'irnpool', $iter['irnpool'],
515 xl('Invoice reference number pool, if used'));
522 // Collect the access control group of user
523 if (isset($phpgacl_location) && acl_check('admin', 'acl')) {
526 <td
class='text'><?php
xl('Access Control','e'); ?
>:</td
>
527 <td
><select id
="access_group_id" name
="access_group[]" multiple style
="width:150px;" >
529 $list_acl_groups = acl_get_group_title_list();
530 $username_acl_groups = acl_get_group_titles($iter["username"]);
531 foreach ($list_acl_groups as $value) {
532 if (($username_acl_groups) && in_array($value,$username_acl_groups)) {
533 // Modified 6-2009 by BM - Translate group name if applicable
534 echo " <option value='$value' selected>" . xl_gacl_group($value) . "</option>\n";
537 // Modified 6-2009 by BM - Translate group name if applicable
538 echo " <option value='$value'>" . xl_gacl_group($value) . "</option>\n";
543 <td
><span
class=text
><?php
xl('Additional Info','e'); ?
>:</span
></td
>
544 <td
><textarea style
="width:150px;" name
="comments" wrap
=auto rows
=4 cols
=25><?php
echo $iter["info"];?
></textarea
></td
>
547 <tr height
="20" valign
="bottom">
548 <td colspan
="4" class="text">
549 <font
class="mandatory">*</font
> <?php
xl('You must enter your own password to change user passwords. Leave blank to keep password unchanged.','e'); ?
>
551 Display red alert
if entered password matched one of last three passwords
/Display red alert
if user password was expired
and the user was inactivated previously
553 <div
class="redtext" id
="error_message"> 
;</div
>
561 <INPUT TYPE
="HIDDEN" NAME
="id" VALUE
="<?php echo attr($_GET["id
"]); ?>">
562 <INPUT TYPE
="HIDDEN" NAME
="mode" VALUE
="update">
563 <INPUT TYPE
="HIDDEN" NAME
="privatemode" VALUE
="user_admin">
565 <INPUT TYPE
="HIDDEN" NAME
="secure_pwd" VALUE
="<?php echo $GLOBALS['secure_password']; ?>">
567 <script language
="JavaScript">
568 $
(document
).ready(function(){
569 $
("#cancel").click(function() {
570 parent
.$
.fn
.fancybox
.close();
580 // d41d8cd98f00b204e9800998ecf8427e == blank