6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
12 require_once("../globals.php");
13 require_once("../../library/acl.inc");
14 require_once("$srcdir/calendar.inc");
15 require_once("$srcdir/options.inc.php");
16 require_once("$srcdir/erx_javascript.inc.php");
17 use OpenEMR\Menu\MainMenuRole
;
19 $facilityService = new \services\
FacilityService();
21 if (!$_GET["id"] ||
!acl_check('admin', 'users')) {
25 $res = sqlStatement("select * from users where id=?", array($_GET["id"]));
26 for ($iter = 0; $row = sqlFetchArray($res); $iter++
) {
27 $result[$iter] = $row;
37 <link rel
="stylesheet" href
="<?php echo $css_header; ?>" type
="text/css">
38 <script type
="text/javascript" src
="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
39 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative'] ?>/jquery-min-1-9-1/index.js"></script
>
40 <script type
="text/javascript" src
="../../library/js/common.js"></script
>
42 <script src
="checkpwd_validation.js" type
="text/javascript"></script
>
44 <!-- validation library
-->
45 <!--//Not lbf forms use the new validation, please make sure you have the corresponding values in the list Page validation-->
46 <?php
$use_validate_js = 1;?
>
47 <?php
require_once($GLOBALS['srcdir'] . "/validation/validation_script.js.php"); ?
>
49 //Gets validation rules from Page Validation list.
50 //Note that for technical reasons, we are bypassing the standard validateUsingPageRules() call.
51 $collectthis = collectValidationPageRules("/interface/usergroup/user_admin.php");
52 if (empty($collectthis)) {
53 $collectthis = "undefined";
55 $collectthis = $collectthis["user_form"]["rules"];
59 <script language
="JavaScript">
62 * validation on the form with new client side validation (using validate.js).
63 * this enable to add new rules for this form in the pageValidation list.
65 var collectvalidation
= <?php
echo($collectthis); ?
>;
67 function checkChange()
69 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.'));?>");
71 function submitform() {
73 var valid
= submitme(1, undefined
, 'user_form', collectvalidation
);
78 <?php
if (!$GLOBALS['use_active_directory']) { ?
>
79 if(document
.forms
[0].clearPass
.value
!="")
81 //Checking for the strong password if the 'secure password' feature is enabled
82 if(document
.forms
[0].secure_pwd
.value
== 1)
84 var pwdresult
= passwordvalidate(document
.forms
[0].clearPass
.value
);
87 alert("<?php echo xl('The password must be at least eight characters, and should');
89 echo xl('contain at least three of the four following items:');
93 echo xl('A lowercase letter');
95 echo xl('An uppercase letter');
97 echo xl('A special character');
99 echo xl('not a letter or number');
102 echo xl('For example:');
103 echo ' healthCare@09'; ?>");
108 }//If pwd null ends here
110 //Request to reset the user password if the user was deactived once the password expired.
111 if((document
.forms
[0].pwd_expires
.value
!= 0) && (document
.forms
[0].clearPass
.value
== "")) {
112 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
))
115 document
.getElementById('error_message').innerHTML
="<?php xl('Please reset the password.', 'e') ?>";
119 if (document
.forms
[0].access_group_id
) {
120 var sel
= getSelected(document
.forms
[0].access_group_id
.options
);
121 for (var item in sel
) {
122 if (sel
[item
].value
== "Emergency Login") {
123 document
.forms
[0].check_acl
.value
= 1;
128 <?php
if ($GLOBALS['erx_enable']) { ?
>
131 for(i
=0;i
<f
.length
;i++
){
132 if(f
[i
].type
=='text' && f
[i
].value
)
134 if(f
[i
].name
== 'fname' || f
[i
].name
== 'mname' || f
[i
].name
== 'lname')
136 alertMsg +
= checkLength(f
[i
].name
,f
[i
].value
,35);
137 alertMsg +
= checkUsername(f
[i
].name
,f
[i
].value
);
139 else if(f
[i
].name
== 'taxid')
141 alertMsg +
= checkLength(f
[i
].name
,f
[i
].value
,10);
142 alertMsg +
= checkFederalEin(f
[i
].name
,f
[i
].value
);
144 else if(f
[i
].name
== 'state_license_number')
146 alertMsg +
= checkLength(f
[i
].name
,f
[i
].value
,10);
147 alertMsg +
= checkStateLicenseNumber(f
[i
].name
,f
[i
].value
);
149 else if(f
[i
].name
== 'npi')
151 alertMsg +
= checkLength(f
[i
].name
,f
[i
].value
,10);
152 alertMsg +
= checkTaxNpiDea(f
[i
].name
,f
[i
].value
);
154 else if(f
[i
].name
== 'drugid')
156 alertMsg +
= checkLength(f
[i
].name
,f
[i
].value
,30);
157 alertMsg +
= checkAlphaNumeric(f
[i
].name
,f
[i
].value
);
168 document
.forms
[0].submit();
169 parent
.$
.fn
.fancybox
.close();
172 //Getting the list of selected item in ACL
173 function getSelected(opt
) {
174 var selected
= new Array();
176 for (var intLoop
= 0; intLoop
< opt
.length
; intLoop++
) {
177 if ((opt
[intLoop
].selected
) ||
178 (opt
[intLoop
].checked
)) {
179 index
= selected
.length
;
180 selected
[index
] = new Object;
181 selected
[index
].value
= opt
[intLoop
].value
;
182 selected
[index
].index
= intLoop
;
188 function authorized_clicked() {
189 var f
= document
.forms
[0];
190 f
.calendar
.disabled
= !f
.authorized
.checked
;
191 f
.calendar
.checked
= f
.authorized
.checked
;
195 <style type
="text/css">
196 .physician_type_class
{
197 width
: 150px
!important
;
201 <body
class="body_top">
203 <span
class="title"><?php
xl('Edit User', 'e'); ?
></span
> 
;
205 <a
class="css_button" name
='form_save' id
='form_save' href
='#' onclick
='return submitform()'> <span
><?php
xl('Save', 'e');?
></span
> </a
>
206 <a
class="css_button" id
='cancel' href
='#'><span
><?php
xl('Cancel', 'e');?
></span
></a
>
210 <FORM NAME
="user_form" id
="user_form" METHOD
="POST" ACTION
="usergroup_admin.php" target
="_parent" onsubmit
='return top.restoreSession()'>
212 <input type
=hidden name
="pwd_expires" value
="<?php echo $GLOBALS['password_expiration_days']; ?>" >
213 <input type
=hidden name
="pre_active" value
="<?php echo $iter["active
"]; ?>" >
214 <input type
=hidden name
="exp_date" value
="<?php echo $iter["pwd_expiration_date
"]; ?>" >
215 <input type
=hidden name
="get_admin_id" value
="<?php echo $GLOBALS['Emergency_Login_email']; ?>" >
216 <input type
=hidden name
="admin_id" value
="<?php echo $GLOBALS['Emergency_Login_email_id']; ?>" >
217 <input type
=hidden name
="check_acl" value
="">
219 //Calculating the grace time
220 $current_date = date("Y-m-d");
221 $password_exp=$iter["pwd_expiration_date"];
222 if ($password_exp != "0000-00-00") {
223 $grace_time1 = date("Y-m-d", strtotime($password_exp . "+".$GLOBALS['password_grace_time'] ."days"));
226 <input type
=hidden name
="current_date" value
="<?php echo strtotime($current_date); ?>" >
227 <input type
=hidden name
="grace_time" value
="<?php echo strtotime($grace_time1); ?>" >
228 <!-- Get the
list ACL
for the user
-->
230 $acl_name=acl_get_group_titles($iter["username"]);
232 $bg_count=count($acl_name);
233 for ($i=0; $i<$bg_count; $i++
) {
234 if ($acl_name[$i] == "Emergency Login") {
235 $bg_name=$acl_name[$i];
239 <input type
=hidden name
="user_type" value
="<?php echo $bg_name; ?>" >
241 <TABLE border
=0 cellpadding
=0 cellspacing
=0>
243 <TD style
="width:180px;"><span
class=text
><?php
xl('Username', 'e'); ?
>: </span
></TD
>
244 <TD style
="width:270px;"><input type
=entry name
=username style
="width:150px;" value
="<?php echo $iter["username
"]; ?>" disabled
></td
>
245 <?php
if (!$GLOBALS['use_active_directory']) { ?
>
246 <TD style
="width:200px;"><span
class=text
><?php
xl('Your Password', 'e'); ?
>: </span
></TD
>
247 <TD
class='text' style
="width:280px;"><input type
='password' name
=adminPass style
="width:150px;" value
="" autocomplete
='off'><font
class="mandatory">*</font
></TD
>
250 <?php
if (!$GLOBALS['use_active_directory']) { ?
>
252 <TD style
="width:180px;"><span
class=text
></span
></TD
>
253 <TD style
="width:270px;"></td
>
254 <TD style
="width:200px;"><span
class=text
><?php
xl('User\'s New Password', 'e'); ?
>: </span
></TD
>
255 <TD
class='text' style
="width:280px;"> <input type
=text name
=clearPass style
="width:150px;" value
=""><font
class="mandatory">*</font
></td
>
259 <TR height
="30" style
="valign:middle;">
260 <td
><span
class="text"> 
;</span
></td
><td
> 
;</td
>
261 <td colspan
="2"><span
class=text
><?php
xl('Provider', 'e'); ?
>:
262 <input type
="checkbox" name
="authorized" onclick
="authorized_clicked()"<?php
263 if ($iter["authorized"]) {
266  
; 
;<span
class='text'><?php
xl('Calendar', 'e'); ?
>:
267 <input type
="checkbox" name
="calendar"<?php
268 if ($iter["calendar"]) {
272 if (!$iter["authorized"]) {
275  
; 
;<span
class='text'><?php
xl('Active', 'e'); ?
>:
276 <input type
="checkbox" name
="active"<?php
if ($iter["active"]) {
283 <TD
><span
class=text
><?php
xl('First Name', 'e'); ?
>: </span
></TD
>
284 <TD
><input type
=entry name
=fname id
=fname style
="width:150px;" value
="<?php echo $iter["fname
"]; ?>"><span
class="mandatory"> 
;*</span
></td
>
285 <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
>
289 <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
>
290 <td
><span
class=text
><?php
xl('Default Facility', 'e'); ?
>: </span
></td
><td
><select name
=facility_id style
="width:150px;" >
292 $fres = $facilityService->getAllBillingLocations();
294 for ($iter2 = 0; $iter2 < sizeof($fres); $iter2++
) {
295 $result[$iter2] = $fres[$iter2];
298 foreach ($result as $iter2) {
300 <option value
="<?php echo $iter2['id']; ?>" <?php
if ($iter['facility_id'] == $iter2['id']) {
302 } ?
>><?php
echo htmlspecialchars($iter2['name']); ?
></option
>
310 <?php
if ($GLOBALS['restrict_user_facility']) { ?
>
312 <td colspan
=2> 
;</td
>
313 <td
><span
class=text
><?php
xl('Schedule Facilities:', 'e');?
></td
>
315 <select name
="schedule_facility[]" multiple style
="width:150px;" >
317 $userFacilities = getUserFacilities($_GET['id']);
319 foreach ($userFacilities as $uf) {
323 $fres = $facilityService->getAllServiceLocations();
325 foreach ($fres as $frow) :
327 <option
<?php
echo in_array($frow['id'], $ufid) ||
$frow['id'] == $iter['facility_id'] ?
"selected" : null ?
>
328 value
="<?php echo $frow['id'] ?>"><?php
echo htmlspecialchars($frow['name']) ?
></option
>
339 <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
>
340 <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
>
344 <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
>
345 <td
class='text'><?php
xl('See Authorizations', 'e'); ?
>: </td
>
346 <td
><select name
="see_auth" style
="width:150px;" >
348 foreach (array(1 => xl('None'), 2 => xl('Only Mine'), 3 => xl('All')) as $key => $value) {
349 echo " <option value='$key'";
350 if ($key == $iter['see_auth']) {
354 echo ">$value</option>\n";
361 <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
>
362 <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
>
366 <td
><span
class="text"><?php
xl('Taxonomy', 'e'); ?
>: </span
></td
>
367 <td
><input type
="text" name
="taxonomy" style
="width:150px;" value
="<?php echo $iter["taxonomy
"]?>"></td
>
368 <td
> 
;</td
><td
> 
;</td
></tr
>
371 <td
><span
class="text"><?php
xl('State License Number', 'e'); ?
>: </span
></td
>
372 <td
><input type
="text" name
="state_license_number" style
="width:150px;" value
="<?php echo $iter["state_license_number
"]?>"></td
>
373 <td
class='text'><?php
xl('NewCrop eRX Role', 'e'); ?
>:</td
>
375 <?php
echo generate_select_list("erxrole", "newcrop_erx_role", $iter['newcrop_user_role'], '', xl('Select Role'), '', '', '', array('style'=>'width:150px')); ?
>
380 <td
><span
class="text"><?php
xl('Provider Type', 'e'); ?
>: </span
></td
>
381 <td
><?php
echo generate_select_list("physician_type", "physician_type", $iter['physician_type'], '', xl('Select Type'), 'physician_type_class', '', '', ''); ?
></td
>
383 <span
class="text"><?php
echo xlt('Main Menu Role'); ?
>: </span
>
386 <?php
echo MainMenuRole
::displayMainMenuRoleSelector($iter["main_menu_role"]); ?
>
389 <?php
if ($GLOBALS['inhouse_pharmacy']) { ?
>
391 <td
class="text"><?php
xl('Default Warehouse', 'e'); ?
>: </td
>
394 echo generate_select_list(
397 $iter['default_warehouse'],
402 <td
class="text"><?php
xl('Invoice Refno Pool', 'e'); ?
>: </td
>
405 echo generate_select_list(
409 xl('Invoice reference number pool, if used')
417 // Collect the access control group of user
418 if (isset($phpgacl_location) && acl_check('admin', 'acl')) {
421 <td
class='text'><?php
xl('Access Control', 'e'); ?
>:</td
>
422 <td
><select id
="access_group_id" name
="access_group[]" multiple style
="width:150px;" >
424 $list_acl_groups = acl_get_group_title_list();
425 $username_acl_groups = acl_get_group_titles($iter["username"]);
426 foreach ($list_acl_groups as $value) {
427 if (($username_acl_groups) && in_array($value, $username_acl_groups)) {
428 // Modified 6-2009 by BM - Translate group name if applicable
429 echo " <option value='$value' selected>" . xl_gacl_group($value) . "</option>\n";
431 // Modified 6-2009 by BM - Translate group name if applicable
432 echo " <option value='$value'>" . xl_gacl_group($value) . "</option>\n";
437 <td
><span
class=text
><?php
xl('Additional Info', 'e'); ?
>:</span
></td
>
438 <td
><textarea style
="width:150px;" name
="comments" wrap
=auto rows
=4 cols
=25><?php
echo $iter["info"];?
></textarea
></td
>
441 <tr height
="20" valign
="bottom">
442 <td colspan
="4" class="text">
443 <font
class="mandatory">*</font
> <?php
xl('You must enter your own password to change user passwords. Leave blank to keep password unchanged.', 'e'); ?
>
445 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
447 <div
class="redtext" id
="error_message"> 
;</div
>
455 <INPUT TYPE
="HIDDEN" NAME
="id" VALUE
="<?php echo attr($_GET["id
"]); ?>">
456 <INPUT TYPE
="HIDDEN" NAME
="mode" VALUE
="update">
457 <INPUT TYPE
="HIDDEN" NAME
="privatemode" VALUE
="user_admin">
459 <INPUT TYPE
="HIDDEN" NAME
="secure_pwd" VALUE
="<?php echo $GLOBALS['secure_password']; ?>">
461 <script language
="JavaScript">
462 $
(document
).ready(function(){
463 $
("#cancel").click(function() {
464 parent
.$
.fn
.fancybox
.close();
474 // d41d8cd98f00b204e9800998ecf8427e == blank