Some fixes in phpgacl to work with php 5.4
[openemr.git] / interface / usergroup / usergroup_admin_add.php
blob6974db604890ce3b155810d95d9cb193fc7e2b5a
1 <?php
2 require_once("../globals.php");
3 require_once("../../library/acl.inc");
4 require_once("$srcdir/sha1.js");
5 require_once("$srcdir/sql.inc");
6 require_once("$srcdir/formdata.inc.php");
7 require_once("$srcdir/options.inc.php");
8 require_once(dirname(__FILE__) . "/../../library/classes/WSProvider.class.php");
9 require_once("$srcdir/erx_javascript.inc.php");
11 $alertmsg = '';
14 <html>
15 <head>
17 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
18 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
19 <link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
20 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script>
21 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.1.3.2.js"></script>
22 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/common.js"></script>
23 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
25 <script src="checkpwd_validation.js" type="text/javascript"></script>
27 <script language="JavaScript">
28 function trimAll(sString)
30 while (sString.substring(0,1) == ' ')
32 sString = sString.substring(1, sString.length);
34 while (sString.substring(sString.length-1, sString.length) == ' ')
36 sString = sString.substring(0,sString.length-1);
38 return sString;
41 function submitform() {
42 if (document.forms[0].rumple.value.length>0 && document.forms[0].stiltskin.value.length>0 && document.getElementById('fname').value.length >0 && document.getElementById('lname').value.length >0) {
43 top.restoreSession();
45 //Checking if secure password is enabled or disabled.
46 //If it is enabled and entered password is a weak password, alert the user to enter strong password.
47 if(document.new_user.secure_pwd.value == 1){
48 var password = trim(document.new_user.stiltskin.value);
49 if(password != "") {
50 var pwdresult = passwordvalidate(password);
51 if(pwdresult == 0){
52 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'; ?>");
53 return false;
56 } //secure_pwd if ends here
58 <?php if($GLOBALS['erx_enable']){ ?>
59 alertMsg='';
60 f=document.forms[0];
61 for(i=0;i<f.length;i++){
62 if(f[i].type=='text' && f[i].value)
64 if(f[i].name == 'rumple')
66 alertMsg += checkLength(f[i].name,f[i].value,35);
67 alertMsg += checkUsername(f[i].name,f[i].value);
69 else if(f[i].name == 'fname' || f[i].name == 'mname' || f[i].name == 'lname')
71 alertMsg += checkLength(f[i].name,f[i].value,35);
72 alertMsg += checkUsername(f[i].name,f[i].value);
74 else if(f[i].name == 'federaltaxid')
76 alertMsg += checkLength(f[i].name,f[i].value,10);
77 alertMsg += checkFederalEin(f[i].name,f[i].value);
79 else if(f[i].name == 'state_license_number')
81 alertMsg += checkLength(f[i].name,f[i].value,10);
82 alertMsg += checkStateLicenseNumber(f[i].name,f[i].value);
84 else if(f[i].name == 'npi')
86 alertMsg += checkLength(f[i].name,f[i].value,35);
87 alertMsg += checkTaxNpiDea(f[i].name,f[i].value);
89 else if(f[i].name == 'federaldrugid')
91 alertMsg += checkLength(f[i].name,f[i].value,30);
92 alertMsg += checkAlphaNumeric(f[i].name,f[i].value);
96 if(alertMsg)
98 alert(alertMsg);
99 return false;
101 <?php } // End erx_enable only include block?>
103 document.forms[0].submit();
104 parent.$.fn.fancybox.close();
106 } else {
107 if (document.forms[0].rumple.value.length<=0)
109 document.forms[0].rumple.style.backgroundColor="red";
110 alert("<?php xl('Required field missing: Please enter the User Name','e');?>");
111 document.forms[0].rumple.focus();
112 return false;
114 if (document.forms[0].stiltskin.value.length<=0)
116 document.forms[0].stiltskin.style.backgroundColor="red";
117 alert("<?php echo xl('Please enter the password'); ?>");
118 document.forms[0].stiltskin.focus();
119 return false;
121 if(trimAll(document.getElementById('fname').value) == ""){
122 document.getElementById('fname').style.backgroundColor="red";
123 alert("<?php xl('Required field missing: Please enter the First name','e');?>");
124 document.getElementById('fname').focus();
125 return false;
127 if(trimAll(document.getElementById('lname').value) == ""){
128 document.getElementById('lname').style.backgroundColor="red";
129 alert("<?php xl('Required field missing: Please enter the Last name','e');?>");
130 document.getElementById('lname').focus();
131 return false;
135 function authorized_clicked() {
136 var f = document.forms[0];
137 f.calendar.disabled = !f.authorized.checked;
138 f.calendar.checked = f.authorized.checked;
141 </script>
142 <style type="text/css">
143 .physician_type_class{
144 width: 120px !important;
146 </style>
147 </head>
148 <body class="body_top">
149 <table><tr><td>
150 <span class="title"><?php xl('Add User','e'); ?></span>&nbsp;</td>
151 <td>
152 <a class="css_button" name='form_save' id='form_save' href='#' onclick="return submitform()">
153 <span><?php xl('Save','e');?></span></a>
154 <a class="css_button large_button" id='cancel' href='#'>
155 <span class='css_button_span large_button_span'><?php xl('Cancel','e');?></span>
156 </a>
157 </td></tr></table>
158 <br><br>
160 <table border=0>
162 <tr><td valign=top>
163 <form name='new_user' method='post' target="_parent" action="usergroup_admin.php"
164 onsubmit='return top.restoreSession()'>
165 <input type='hidden' name='mode' value='new_user'>
166 <input type='hidden' name='secure_pwd' value="<?php echo $GLOBALS['secure_password']; ?>">
168 <span class="bold">&nbsp;</span>
169 </td><td>
170 <table border=0 cellpadding=0 cellspacing=0 style="width:600px;">
171 <tr>
172 <td style="width:150px;"><span class="text"><?php xl('Username','e'); ?>: </span></td><td style="width:220px;"><input type=entry name=rumple style="width:120px;"> <span class="mandatory">&nbsp;*</span></td>
173 <td style="width:150px;"><span class="text"><?php xl('Password','e'); ?>: </span></td><td style="width:250px;"><input type="entry" style="width:120px;" name=stiltskin><span class="mandatory">&nbsp;*</span></td>
174 </tr>
175 <tr>
176 <td style="width:150px;"></td><td style="width:220px;"></span></td>
177 <TD style="width:200px;"><span class=text><?php xl('Your Password','e'); ?>: </span></TD>
178 <TD class='text' style="width:280px;"><input type='password' name=adminPass style="width:120px;" value="" autocomplete='off'><font class="mandatory">*</font></TD>
180 </tr>
181 <tr>
182 <td><span class="text"<?php if ($GLOBALS['disable_non_default_groups']) echo " style='display:none'"; ?>><?php xl('Groupname','e'); ?>: </span></td>
183 <td>
184 <select name=groupname<?php if ($GLOBALS['disable_non_default_groups']) echo " style='display:none'"; ?>>
185 <?php
186 $res = sqlStatement("select distinct name from groups");
187 $result2 = array();
188 for ($iter = 0;$row = sqlFetchArray($res);$iter++)
189 $result2[$iter] = $row;
190 foreach ($result2 as $iter) {
191 print "<option value='".$iter{"name"}."'>" . $iter{"name"} . "</option>\n";
194 </select></td>
195 <td><span class="text"><?php xl('Provider','e'); ?>: </span></td><td>
196 <input type='checkbox' name='authorized' value='1' onclick='authorized_clicked()' />
197 &nbsp;&nbsp;<span class='text'><?php xl('Calendar','e'); ?>:
198 <input type='checkbox' name='calendar' disabled />
199 </td>
200 </tr>
201 <tr>
202 <td><span class="text"><?php xl('First Name','e'); ?>: </span></td><td><input type=entry name='fname' id='fname' style="width:120px;"><span class="mandatory">&nbsp;*</span></td>
203 <td><span class="text"><?php xl('Middle Name','e'); ?>: </span></td><td><input type=entry name='mname' style="width:120px;"></td>
204 </tr>
205 <tr>
206 <td><span class="text"><?php xl('Last Name','e'); ?>: </span></td><td><input type=entry name='lname' id='lname' style="width:120px;"><span class="mandatory">&nbsp;*</span></td>
207 <td><span class="text"><?php xl('Default Facility','e'); ?>: </span></td><td><select style="width:120px;" name=facility_id>
208 <?php
209 $fres = sqlStatement("select * from facility where service_location != 0 order by name");
210 if ($fres) {
211 for ($iter = 0;$frow = sqlFetchArray($fres);$iter++)
212 $result[$iter] = $frow;
213 foreach($result as $iter) {
215 <option value="<?php echo $iter{'id'};?>"><?php echo $iter{'name'};?></option>
216 <?php
220 </select></td>
221 </tr>
222 <tr>
223 <td><span class="text"><?php xl('Federal Tax ID','e'); ?>: </span></td><td><input type=entry name='federaltaxid' style="width:120px;"></td>
224 <td><span class="text"><?php xl('Federal Drug ID','e'); ?>: </span></td><td><input type=entry name='federaldrugid' style="width:120px;"></td>
225 </tr>
226 <tr>
227 <td><span class="text"><?php xl('UPIN','e'); ?>: </span></td><td><input type="entry" name="upin" style="width:120px;"></td>
228 <td class='text'><?php xl('See Authorizations','e'); ?>: </td>
229 <td><select name="see_auth" style="width:120px;">
230 <?php
231 foreach (array(1 => xl('None'), 2 => xl('Only Mine'), 3 => xl('All')) as $key => $value)
233 echo " <option value='$key'";
234 echo ">$value</option>\n";
237 </select></td>
239 <tr>
240 <td><span class="text"><?php xl('NPI','e'); ?>: </span></td><td><input type="entry" name="npi" style="width:120px;"></td>
241 <td><span class="text"><?php xl('Job Description','e'); ?>: </span></td><td><input type="entry" name="specialty" style="width:120px;"></td>
242 </tr>
244 <tr>
245 <td>
246 <span class="text"><?php xl('Provider Type','e'); ?>: </span>
247 </td>
248 <td>
249 <?php echo generate_select_list("physician_type", "physician_type", '','',xl('Select Type'),'physician_type_class','','',''); ?>
250 </td>
251 </tr>
253 <!-- (CHEMED) Calendar UI preference -->
254 <tr>
255 <td><span class="text"><?php xl('Taxonomy','e'); ?>: </span></td>
256 <td><input type="entry" name="taxonomy" style="width:120px;" value="207Q00000X"></td>
257 <td><span class="text"><?php xl('Calendar UI','e'); ?>: </span></td><td><select name="cal_ui" style="width:120px;">
258 <?php
259 foreach (array(3 => xl('Outlook'), 1 => xl('Original'), 2 => xl('Fancy')) as $key => $value)
261 echo " <option value='$key'>$value</option>\n";
264 </select></td>
265 </tr>
266 <!-- END (CHEMED) Calendar UI preference -->
268 <tr>
269 <td><span class="text"><?php xl('State License Number','e'); ?>: </span></td>
270 <td><input type="text" name="state_license_number" style="width:120px;"></td>
271 <td class='text'><?php xl('NewCrop eRX Role','e'); ?>:</td>
272 <td>
273 <?php echo generate_select_list("erxrole", "newcrop_erx_role", '','','--Select Role--','','','',array('style'=>'width:120px')); ?>
274 </td>
275 </tr>
277 <?php if ($GLOBALS['inhouse_pharmacy']) { ?>
278 <tr>
279 <td class="text"><?php xl('Default Warehouse','e'); ?>: </td>
280 <td class='text'>
281 <?php
282 echo generate_select_list('default_warehouse', 'warehouse',
283 '', '');
285 </td>
286 <td class="text"><?php xl('Invoice Refno Pool','e'); ?>: </td>
287 <td class='text'>
288 <?php
289 echo generate_select_list('irnpool', 'irnpool', '',
290 xl('Invoice reference number pool, if used'));
292 </td>
293 </tr>
294 <?php } ?>
296 <?php
297 // List the access control groups if phpgacl installed
298 if (isset($phpgacl_location) && acl_check('admin', 'acl')) {
300 <tr>
301 <td class='text'><?php xl('Access Control','e'); ?>:</td>
302 <td><select name="access_group[]" multiple style="width:120px;">
303 <?php
304 $list_acl_groups = acl_get_group_title_list();
305 $default_acl_group = 'Administrators';
306 foreach ($list_acl_groups as $value) {
307 if ($default_acl_group == $value) {
308 // Modified 6-2009 by BM - Translate group name if applicable
309 echo " <option value='$value' selected>" . xl_gacl_group($value) . "</option>\n";
311 else {
312 // Modified 6-2009 by BM - Translate group name if applicable
313 echo " <option value='$value'>" . xl_gacl_group($value) . "</option>\n";
317 </select></td>
318 <td><span class="text"><?php xl('Additional Info','e'); ?>: </span></td>
319 <td><textarea name=info style="width:120px;" cols=27 rows=4 wrap=auto></textarea></td>
321 </tr>
322 <tr height="25"><td colspan="4">&nbsp;</td></tr>
323 <?php
327 </table>
329 <br>
330 <input type="hidden" name="newauthPass">
331 </form>
332 </td>
334 </tr>
336 <tr<?php if ($GLOBALS['disable_non_default_groups']) echo " style='display:none'"; ?>>
338 <td valign=top>
339 <form name='new_group' method='post' action="usergroup_admin.php"
340 onsubmit='return top.restoreSession()'>
341 <br>
342 <input type=hidden name=mode value=new_group>
343 <span class="bold"><?php xl('New Group','e'); ?>:</span>
344 </td><td>
345 <span class="text"><?php xl('Groupname','e'); ?>: </span><input type=entry name=groupname size=10>
346 &nbsp;&nbsp;&nbsp;
347 <span class="text"><?php xl('Initial User','e'); ?>: </span>
348 <select name=rumple>
349 <?php
350 $res = sqlStatement("select distinct username from users where username != ''");
351 for ($iter = 0;$row = sqlFetchArray($res);$iter++)
352 $result[$iter] = $row;
353 foreach ($result as $iter) {
354 print "<option value='".$iter{"username"}."'>" . $iter{"username"} . "</option>\n";
357 </select>
358 &nbsp;&nbsp;&nbsp;
359 <input type="submit" value=<?php xl('Save','e'); ?>>
360 </form>
361 </td>
363 </tr>
365 <tr <?php if ($GLOBALS['disable_non_default_groups']) echo " style='display:none'"; ?>>
367 <td valign=top>
368 <form name='new_group' method='post' action="usergroup_admin.php"
369 onsubmit='return top.restoreSession()'>
370 <input type=hidden name=mode value=new_group>
371 <span class="bold"><?php xl('Add User To Group','e'); ?>:</span>
372 </td><td>
373 <span class="text">
374 <?php xl('User','e'); ?>
375 : </span>
376 <select name=rumple>
377 <?php
378 $res = sqlStatement("select distinct username from users where username != ''");
379 for ($iter = 0;$row = sqlFetchArray($res);$iter++)
380 $result3[$iter] = $row;
381 foreach ($result3 as $iter) {
382 print "<option value='".$iter{"username"}."'>" . $iter{"username"} . "</option>\n";
385 </select>
386 &nbsp;&nbsp;&nbsp;
387 <span class="text"><?php xl('Groupname','e'); ?>: </span>
388 <select name=groupname>
389 <?php
390 $res = sqlStatement("select distinct name from groups");
391 $result2 = array();
392 for ($iter = 0;$row = sqlFetchArray($res);$iter++)
393 $result2[$iter] = $row;
394 foreach ($result2 as $iter) {
395 print "<option value='".$iter{"name"}."'>" . $iter{"name"} . "</option>\n";
398 </select>
399 &nbsp;&nbsp;&nbsp;
400 <input type="submit" value=<?php xl('Add User To Group','e'); ?>>
401 </form>
402 </td>
403 </tr>
405 </table>
407 <?php
408 if (empty($GLOBALS['disable_non_default_groups'])) {
409 $res = sqlStatement("select * from groups order by name");
410 for ($iter = 0;$row = sqlFetchArray($res);$iter++)
411 $result5[$iter] = $row;
413 foreach ($result5 as $iter) {
414 $grouplist{$iter{"name"}} .= $iter{"user"} .
415 "(<a class='link_submit' href='usergroup_admin.php?mode=delete_group&id=" .
416 $iter{"id"} . "' onclick='top.restoreSession()'>Remove</a>), ";
419 foreach ($grouplist as $groupname => $list) {
420 print "<span class='bold'>" . $groupname . "</span><br>\n<span class='text'>" .
421 substr($list,0,strlen($list)-2) . "</span><br>\n";
426 <script language="JavaScript">
427 <?php
428 if ($alertmsg = trim($alertmsg)) {
429 echo "alert('$alertmsg');\n";
432 $(document).ready(function(){
433 $("#cancel").click(function() {
434 parent.$.fn.fancybox.close();
438 </script>
439 <table>
441 </table>
443 </body>
444 </html>