Focus the search term on load
[openemr.git] / interface / usergroup / facility_user.php
blob08f8d4969910ebe6bc7250c25bd0c69661b936e9
1 <?php
2 // +-----------------------------------------------------------------------------+
3 // Copyright (C) 2012 NP Clinics <info@npclinics.com.au>
4 //
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
18 // A copy of the GNU General Public License is included along with this program:
19 // openemr/interface/login/GnuGPL.html
20 // For more information write to the Free Software
21 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 // Author: Scott Wakefield <scott@npclinics.com.au>
25 // +------------------------------------------------------------------------------+
27 //SANITIZE ALL ESCAPES
28 $sanitize_all_escapes=true;
31 //STOP FAKE REGISTER GLOBALS
32 $fake_register_globals=false;
35 require_once("../globals.php");
36 require_once("$srcdir/sql.inc");
37 require_once("$srcdir/formdata.inc.php");
38 require_once("$srcdir/options.inc.php");
39 require_once("$srcdir/acl.inc");
41 // Ensure authorized
42 if (!acl_check('admin', 'users')) {
43 die(xlt("Unauthorized"));
46 $alertmsg = '';
48 if ( isset($_POST["mode"]) && $_POST["mode"] == "facility_user_id" && isset($_POST["user_id"]) && isset($_POST["fac_id"]) ) {
49 // Inserting/Updating new facility specific user information
50 $fres = sqlStatement("SELECT * FROM `layout_options` " .
51 "WHERE `form_id` = 'FACUSR' AND `uor` > 0 AND `field_id` != '' " .
52 "ORDER BY `group_name`, `seq`");
53 while ($frow = sqlFetchArray($fres)) {
54 $value = get_layout_form_value($frow);
55 $entry_id = sqlQuery("SELECT `id` FROM `facility_user_ids` WHERE `uid` = ? AND `facility_id` = ? AND `field_id` =?", array($_POST["user_id"],$_POST["fac_id"],$frow['field_id']) );
56 if (empty($entry_id)) {
57 // Insert new entry
58 sqlInsert("INSERT INTO `facility_user_ids` (`uid`, `facility_id`, `field_id`, `field_value`) VALUES (?,?,?,?)", array($_POST["user_id"],$_POST["fac_id"],$frow['field_id'], $value) );
60 else {
61 // Update existing entry
62 sqlStatement("UPDATE `facility_user_ids` SET `field_value` = ? WHERE `id` = ?", array($value,$entry_id['id']) );
68 <html>
69 <head>
70 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
71 <link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
72 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script>
73 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.1.3.2.js"></script>
74 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/common.js"></script>
75 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
76 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-ui.js"></script>
77 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.easydrag.handler.beta2.js"></script>
79 <script type="text/javascript">
81 $(document).ready(function(){
83 // fancy box
84 enable_modals();
86 // special size for
87 $(".iframe_small").fancybox( {
88 'overlayOpacity' : 0.0,
89 'showCloseButton' : true,
90 'frameHeight' : 300,
91 'frameWidth' : 500
92 });
94 $(function(){
95 // add drag and drop functionality to fancybox
96 $("#fancy_outer").easydrag();
97 });
98 });
100 </script>
102 </head>
103 <body class="body_top">
105 <?php
106 // Collect all users
107 $u_res = sqlStatement("select * from `users` WHERE `username` != '' AND `active` = 1 order by `username`");
109 // Collect all facilities and store them in an array
110 $f_res = sqlStatement("select * from `facility` order by `name`");
111 $f_arr = array();
112 for($i=0; $row=sqlFetchArray($f_res); $i++) {
113 $f_arr[$i]=$row;
116 // Collect layout information and store them in an array
117 $l_res = sqlStatement("SELECT * FROM layout_options " .
118 "WHERE form_id = 'FACUSR' AND uor > 0 AND field_id != '' " .
119 "ORDER BY group_name, seq");
120 $l_arr = array();
121 for($i=0; $row=sqlFetchArray($l_res); $i++) {
122 $l_arr[$i]=$row;
127 <div>
128 <div>
129 <table>
130 <tr >
131 <td><b><?php echo xlt('Facility Specific User Information'); ?></b></td>
132 <td><a href="usergroup_admin.php" class="css_button" onclick="top.restoreSession()"><span><?php echo xlt('Back to Users'); ?></span></a>
133 </td>
134 </tr>
135 </table>
136 </div>
138 <div style="width:400px;">
139 <div>
141 <table cellpadding="1" cellspacing="0" class="showborder">
142 <tbody><tr height="22" class="showborder_head">
143 <th width="180px"><b><?php echo xlt('Username'); ?></b></th>
144 <th width="270px"><b><?php echo xlt('Full Name'); ?></b></th>
145 <th width="190px"><b><span class="bold"><?php echo xlt('Facility'); ?></span></b></th>
146 <?php
147 foreach ($l_arr as $layout_entry) {
148 echo "<th width='100px'><b><span class='bold'>" . text(xl_layout_label($layout_entry['title'])) . "&nbsp;</span></b></th>";
151 </tr>
152 <?php
153 while ($user = sqlFetchArray($u_res)) {
154 foreach ($f_arr as $facility) {
156 <tr height="20" class="text" style="border-bottom: 1px dashed;">
157 <td class="text"><b><a href="facility_user_admin.php?user_id=<?php echo attr($user['id']);?>&fac_id=<?php echo attr($facility['id']);?>" class="iframe_small" onclick="top.restoreSession()"><span><?php echo text($user['username']);?></span></a></b>&nbsp;</td>
158 <td><span class="text"><?php echo text($user['fname'] . " " . $user['lname']);?></span>&nbsp;</td>
159 <td><span class="text"><?php echo text($facility['name']);?>&nbsp;</td>
160 <?php
161 foreach ($l_arr as $layout_entry) {
162 $entry_data = sqlQuery("SELECT `field_value` FROM `facility_user_ids` " .
163 "WHERE `uid` = ? AND `facility_id` = ? AND `field_id` = ?", array($user['id'],$facility['id'],$layout_entry['field_id']) );
164 echo "<td><span class='text'>" . generate_display_field($layout_entry,$entry_data['field_value']) . "&nbsp;</td>";
167 </tr>
168 <?php
171 </tbody>
172 </table>
173 </div>
174 </div>
175 </div>
176 </body>
177 </html>