PageRenderTime 46ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/interface/usergroup/usergroup_admin_add.php

https://github.com/md-tech/openemr
PHP | 424 lines | 386 code | 32 blank | 6 comment | 71 complexity | 589ef65ab64ba92fd2b178de3680a705 MD5 | raw file
  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");
  10. $alertmsg = '';
  11. ?>
  12. <html>
  13. <head>
  14. <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
  15. <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
  16. <link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
  17. <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script>
  18. <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.1.3.2.js"></script>
  19. <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/common.js"></script>
  20. <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
  21. <script src="checkpwd_validation.js" type="text/javascript"></script>
  22. <script language="JavaScript">
  23. function trimAll(sString)
  24. {
  25. while (sString.substring(0,1) == ' ')
  26. {
  27. sString = sString.substring(1, sString.length);
  28. }
  29. while (sString.substring(sString.length-1, sString.length) == ' ')
  30. {
  31. sString = sString.substring(0,sString.length-1);
  32. }
  33. return sString;
  34. }
  35. function submitform() {
  36. 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) {
  37. top.restoreSession();
  38. //Checking if secure password is enabled or disabled.
  39. //If it is enabled and entered password is a weak password, alert the user to enter strong password.
  40. if(document.new_user.secure_pwd.value == 1){
  41. var password = trim(document.new_user.stiltskin.value);
  42. if(password != "") {
  43. var pwdresult = passwordvalidate(password);
  44. if(pwdresult == 0){
  45. 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'; ?>");
  46. return false;
  47. }
  48. }
  49. } //secure_pwd if ends here
  50. // ViCareplus : As per NIST standard, SHA1 encryption algorithm is used
  51. document.forms[0].newauthPass.value=SHA1(document.forms[0].stiltskin.value);
  52. document.forms[0].stiltskin.value='';
  53. <?php if($GLOBALS['erx_enable']){ ?>
  54. alertMsg='';
  55. f=document.forms[0];
  56. for(i=0;i<f.length;i++){
  57. if(f[i].type=='text' && f[i].value)
  58. {
  59. if(f[i].name == 'rumple')
  60. {
  61. alertMsg += checkLength(f[i].name,f[i].value,35);
  62. alertMsg += checkUsername(f[i].name,f[i].value);
  63. }
  64. else if(f[i].name == 'fname' || f[i].name == 'mname' || f[i].name == 'lname')
  65. {
  66. alertMsg += checkLength(f[i].name,f[i].value,35);
  67. alertMsg += checkUsername(f[i].name,f[i].value);
  68. }
  69. else if(f[i].name == 'federaltaxid')
  70. {
  71. alertMsg += checkLength(f[i].name,f[i].value,10);
  72. alertMsg += checkTaxNpiDea(f[i].name,f[i].value);
  73. }
  74. else if(f[i].name == 'state_license_number')
  75. {
  76. alertMsg += checkLength(f[i].name,f[i].value,10);
  77. alertMsg += checkTaxNpiDea(f[i].name,f[i].value);
  78. }
  79. else if(f[i].name == 'npi')
  80. {
  81. alertMsg += checkLength(f[i].name,f[i].value,35);
  82. alertMsg += checkTaxNpiDea(f[i].name,f[i].value);
  83. }
  84. else if(f[i].name == 'federaldrugid')
  85. {
  86. alertMsg += checkLength(f[i].name,f[i].value,30);
  87. alertMsg += checkAlphaNumeric(f[i].name,f[i].value);
  88. }
  89. }
  90. }
  91. if(alertMsg)
  92. {
  93. alert(alertMsg);
  94. return false;
  95. }
  96. <?php } ?>
  97. document.forms[0].submit();
  98. } else {
  99. if (document.forms[0].rumple.value.length<=0)
  100. {
  101. document.forms[0].rumple.style.backgroundColor="red";
  102. alert("<?php xl('Required field missing: Please enter the User Name','e');?>");
  103. document.forms[0].rumple.focus();
  104. return false;
  105. }
  106. if (document.forms[0].stiltskin.value.length<=0)
  107. {
  108. document.forms[0].stiltskin.style.backgroundColor="red";
  109. alert("<?php echo xl('Please enter the password'); ?>");
  110. document.forms[0].stiltskin.focus();
  111. return false;
  112. }
  113. if(trimAll(document.getElementById('fname').value) == ""){
  114. document.getElementById('fname').style.backgroundColor="red";
  115. alert("<?php xl('Required field missing: Please enter the First name','e');?>");
  116. document.getElementById('fname').focus();
  117. return false;
  118. }
  119. if(trimAll(document.getElementById('lname').value) == ""){
  120. document.getElementById('lname').style.backgroundColor="red";
  121. alert("<?php xl('Required field missing: Please enter the Last name','e');?>");
  122. document.getElementById('lname').focus();
  123. return false;
  124. }
  125. }
  126. }
  127. function authorized_clicked() {
  128. var f = document.forms[0];
  129. f.calendar.disabled = !f.authorized.checked;
  130. f.calendar.checked = f.authorized.checked;
  131. }
  132. </script>
  133. </head>
  134. <body class="body_top">
  135. <table><tr><td>
  136. <span class="title"><?php xl('Add User','e'); ?></span>&nbsp;</td>
  137. <td>
  138. <a class="css_button" name='form_save' id='form_save' href='#' onclick="return submitform()">
  139. <span><?php xl('Save','e');?></span></a>
  140. <a class="css_button large_button" id='cancel' href='#'>
  141. <span class='css_button_span large_button_span'><?php xl('Cancel','e');?></span>
  142. </a>
  143. </td></tr></table>
  144. <br><br>
  145. <table border=0>
  146. <tr><td valign=top>
  147. <form name='new_user' method='post' target="_parent" action="usergroup_admin.php"
  148. onsubmit='return top.restoreSession()'>
  149. <input type=hidden name=mode value=new_user>
  150. <input type=hidden name=secure_pwd value="<?php echo $GLOBALS['secure_password']; ?>">
  151. <span class="bold">&nbsp;</span>
  152. </td><td>
  153. <table border=0 cellpadding=0 cellspacing=0 style="width:600px;">
  154. <tr>
  155. <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>
  156. <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>
  157. </tr>
  158. <tr>
  159. <td><span class="text"<?php if ($GLOBALS['disable_non_default_groups']) echo " style='display:none'"; ?>><?php xl('Groupname','e'); ?>: </span></td>
  160. <td>
  161. <select name=groupname<?php if ($GLOBALS['disable_non_default_groups']) echo " style='display:none'"; ?>>
  162. <?php
  163. $res = sqlStatement("select distinct name from groups");
  164. $result2 = array();
  165. for ($iter = 0;$row = sqlFetchArray($res);$iter++)
  166. $result2[$iter] = $row;
  167. foreach ($result2 as $iter) {
  168. print "<option value='".$iter{"name"}."'>" . $iter{"name"} . "</option>\n";
  169. }
  170. ?>
  171. </select></td>
  172. <td><span class="text"><?php xl('Provider','e'); ?>: </span></td><td>
  173. <input type='checkbox' name='authorized' value='1' onclick='authorized_clicked()' />
  174. &nbsp;&nbsp;<span class='text'><?php xl('Calendar','e'); ?>:
  175. <input type='checkbox' name='calendar' disabled />
  176. </td>
  177. </tr>
  178. <tr>
  179. <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>
  180. <td><span class="text"><?php xl('Middle Name','e'); ?>: </span></td><td><input type=entry name='mname' style="width:120px;"></td>
  181. </tr>
  182. <tr>
  183. <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>
  184. <td><span class="text"><?php xl('Default Facility','e'); ?>: </span></td><td><select style="width:120px;" name=facility_id>
  185. <?php
  186. $fres = sqlStatement("select * from facility where service_location != 0 order by name");
  187. if ($fres) {
  188. for ($iter = 0;$frow = sqlFetchArray($fres);$iter++)
  189. $result[$iter] = $frow;
  190. foreach($result as $iter) {
  191. ?>
  192. <option value="<?php echo $iter{id};?>"><?php echo $iter{name};?></option>
  193. <?php
  194. }
  195. }
  196. ?>
  197. </select></td>
  198. </tr>
  199. <tr>
  200. <td><span class="text"><?php xl('Federal Tax ID','e'); ?>: </span></td><td><input type=entry name='federaltaxid' style="width:120px;"></td>
  201. <td><span class="text"><?php xl('Federal Drug ID','e'); ?>: </span></td><td><input type=entry name='federaldrugid' style="width:120px;"></td>
  202. </tr>
  203. <tr>
  204. <td><span class="text"><?php xl('UPIN','e'); ?>: </span></td><td><input type="entry" name="upin" style="width:120px;"></td>
  205. <td class='text'><?php xl('See Authorizations','e'); ?>: </td>
  206. <td><select name="see_auth" style="width:120px;">
  207. <?php
  208. foreach (array(1 => xl('None'), 2 => xl('Only Mine'), 3 => xl('All')) as $key => $value)
  209. {
  210. echo " <option value='$key'";
  211. echo ">$value</option>\n";
  212. }
  213. ?>
  214. </select></td>
  215. <tr>
  216. <td><span class="text"><?php xl('NPI','e'); ?>: </span></td><td><input type="entry" name="npi" style="width:120px;"></td>
  217. <td><span class="text"><?php xl('Job Description','e'); ?>: </span></td><td><input type="entry" name="specialty" style="width:120px;"></td>
  218. </tr>
  219. <!-- (CHEMED) Calendar UI preference -->
  220. <tr>
  221. <td><span class="text"><?php xl('Taxonomy','e'); ?>: </span></td>
  222. <td><input type="entry" name="taxonomy" style="width:120px;" value="207Q00000X"></td>
  223. <td><span class="text"><?php xl('Calendar UI','e'); ?>: </span></td><td><select name="cal_ui" style="width:120px;">
  224. <?php
  225. foreach (array(3 => xl('Outlook'), 1 => xl('Original'), 2 => xl('Fancy')) as $key => $value)
  226. {
  227. echo " <option value='$key'";
  228. if ($key == $iter['cal_ui']) echo " selected";
  229. echo ">$value</option>\n";
  230. }
  231. ?>
  232. </select></td>
  233. </tr>
  234. <!-- END (CHEMED) Calendar UI preference -->
  235. <tr>
  236. <td><span class="text"><?php xl('State License Number','e'); ?>: </span></td>
  237. <td><input type="text" name="state_license_number" style="width:120px;"></td>
  238. <td class='text'><?php xl('NewCrop eRX Role','e'); ?>:</td>
  239. <td>
  240. <?php echo generate_select_list("erxrole", "newcrop_erx_role", $iter['newcrop_user_role'],'','--Select Role--','','','',array('style'=>'width:120px')); ?>
  241. </td>
  242. </tr>
  243. <?php if ($GLOBALS['inhouse_pharmacy']) { ?>
  244. <tr>
  245. <td class="text"><?php xl('Default Warehouse','e'); ?>: </td>
  246. <td class='text'>
  247. <?php
  248. echo generate_select_list('default_warehouse', 'warehouse',
  249. '', '');
  250. ?>
  251. </td>
  252. <td class="text"><?php xl('Invoice Refno Pool','e'); ?>: </td>
  253. <td class='text'>
  254. <?php
  255. echo generate_select_list('irnpool', 'irnpool', '',
  256. xl('Invoice reference number pool, if used'));
  257. ?>
  258. </td>
  259. </tr>
  260. <?php } ?>
  261. <?php
  262. // List the access control groups if phpgacl installed
  263. if (isset($phpgacl_location) && acl_check('admin', 'acl')) {
  264. ?>
  265. <tr>
  266. <td class='text'><?php xl('Access Control','e'); ?>:</td>
  267. <td><select name="access_group[]" multiple style="width:120px;">
  268. <?php
  269. $list_acl_groups = acl_get_group_title_list();
  270. $default_acl_group = 'Administrators';
  271. foreach ($list_acl_groups as $value) {
  272. if ($default_acl_group == $value) {
  273. // Modified 6-2009 by BM - Translate group name if applicable
  274. echo " <option value='$value' selected>" . xl_gacl_group($value) . "</option>\n";
  275. }
  276. else {
  277. // Modified 6-2009 by BM - Translate group name if applicable
  278. echo " <option value='$value'>" . xl_gacl_group($value) . "</option>\n";
  279. }
  280. }
  281. ?>
  282. </select></td>
  283. <td><span class="text"><?php xl('Additional Info','e'); ?>: </span></td>
  284. <td><textarea name=info style="width:120px;" cols=27 rows=4 wrap=auto></textarea></td>
  285. </tr>
  286. <tr height="25"><td colspan="4">&nbsp;</td></tr>
  287. <?php
  288. }
  289. ?>
  290. </table>
  291. <br>
  292. <input type="hidden" name="newauthPass">
  293. </form>
  294. </td>
  295. </tr>
  296. <tr<?php if ($GLOBALS['disable_non_default_groups']) echo " style='display:none'"; ?>>
  297. <td valign=top>
  298. <form name='new_group' method='post' action="usergroup_admin.php"
  299. onsubmit='return top.restoreSession()'>
  300. <br>
  301. <input type=hidden name=mode value=new_group>
  302. <span class="bold"><?php xl('New Group','e'); ?>:</span>
  303. </td><td>
  304. <span class="text"><?php xl('Groupname','e'); ?>: </span><input type=entry name=groupname size=10>
  305. &nbsp;&nbsp;&nbsp;
  306. <span class="text"><?php xl('Initial User','e'); ?>: </span>
  307. <select name=rumple>
  308. <?php
  309. $res = sqlStatement("select distinct username from users where username != ''");
  310. for ($iter = 0;$row = sqlFetchArray($res);$iter++)
  311. $result[$iter] = $row;
  312. foreach ($result as $iter) {
  313. print "<option value='".$iter{"username"}."'>" . $iter{"username"} . "</option>\n";
  314. }
  315. ?>
  316. </select>
  317. &nbsp;&nbsp;&nbsp;
  318. <input type="submit" value=<?php xl('Save','e'); ?>>
  319. </form>
  320. </td>
  321. </tr>
  322. <tr <?php if ($GLOBALS['disable_non_default_groups']) echo " style='display:none'"; ?>>
  323. <td valign=top>
  324. <form name='new_group' method='post' action="usergroup_admin.php"
  325. onsubmit='return top.restoreSession()'>
  326. <input type=hidden name=mode value=new_group>
  327. <span class="bold"><?php xl('Add User To Group','e'); ?>:</span>
  328. </td><td>
  329. <span class="text">
  330. <?php xl('User','e'); ?>
  331. : </span>
  332. <select name=rumple>
  333. <?php
  334. $res = sqlStatement("select distinct username from users where username != ''");
  335. for ($iter = 0;$row = sqlFetchArray($res);$iter++)
  336. $result3[$iter] = $row;
  337. foreach ($result3 as $iter) {
  338. print "<option value='".$iter{"username"}."'>" . $iter{"username"} . "</option>\n";
  339. }
  340. ?>
  341. </select>
  342. &nbsp;&nbsp;&nbsp;
  343. <span class="text"><?php xl('Groupname','e'); ?>: </span>
  344. <select name=groupname>
  345. <?php
  346. $res = sqlStatement("select distinct name from groups");
  347. $result2 = array();
  348. for ($iter = 0;$row = sqlFetchArray($res);$iter++)
  349. $result2[$iter] = $row;
  350. foreach ($result2 as $iter) {
  351. print "<option value='".$iter{"name"}."'>" . $iter{"name"} . "</option>\n";
  352. }
  353. ?>
  354. </select>
  355. &nbsp;&nbsp;&nbsp;
  356. <input type="submit" value=<?php xl('Add User To Group','e'); ?>>
  357. </form>
  358. </td>
  359. </tr>
  360. </table>
  361. <?php
  362. if (empty($GLOBALS['disable_non_default_groups'])) {
  363. $res = sqlStatement("select * from groups order by name");
  364. for ($iter = 0;$row = sqlFetchArray($res);$iter++)
  365. $result5[$iter] = $row;
  366. foreach ($result5 as $iter) {
  367. $grouplist{$iter{"name"}} .= $iter{"user"} .
  368. "(<a class='link_submit' href='usergroup_admin.php?mode=delete_group&id=" .
  369. $iter{"id"} . "' onclick='top.restoreSession()'>Remove</a>), ";
  370. }
  371. foreach ($grouplist as $groupname => $list) {
  372. print "<span class='bold'>" . $groupname . "</span><br>\n<span class='text'>" .
  373. substr($list,0,strlen($list)-2) . "</span><br>\n";
  374. }
  375. }
  376. ?>
  377. <script language="JavaScript">
  378. <?php
  379. if ($alertmsg = trim($alertmsg)) {
  380. echo "alert('$alertmsg');\n";
  381. }
  382. ?>
  383. $(document).ready(function(){
  384. $("#cancel").click(function() {
  385. parent.$.fn.fancybox.close();
  386. });
  387. });
  388. </script>
  389. <table>
  390. </table>
  391. </body>
  392. </html>