Fully responsive globals.php with vertical menu (#2460)
[openemr.git] / interface / usergroup / facility_user.php
blobb39ed16b2ff8901784c53a8b26dd4bf0b6bb04c9
1 <?php
2 /**
3 * Facility user-specific settings.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Scott Wakefield <scott@npclinics.com.au>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2012 NP Clinics <info@npclinics.com.au>
10 * @copyright Copyright (c) 2017-2018 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../globals.php");
16 require_once("$srcdir/options.inc.php");
17 require_once("$srcdir/acl.inc");
19 use OpenEMR\Core\Header;
21 if (!empty($_POST)) {
22 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
23 csrfNotVerified();
27 // Ensure authorized
28 if (!acl_check('admin', 'users')) {
29 die(xlt("Unauthorized"));
32 $alertmsg = '';
34 if (isset($_POST["mode"]) && $_POST["mode"] == "facility_user_id" && isset($_POST["user_id"]) && isset($_POST["fac_id"])) {
35 // Inserting/Updating new facility specific user information
36 $fres = sqlStatement("SELECT * FROM `layout_options` " .
37 "WHERE `form_id` = 'FACUSR' AND `uor` > 0 AND `field_id` != '' " .
38 "ORDER BY `group_id`, `seq`");
39 while ($frow = sqlFetchArray($fres)) {
40 $value = get_layout_form_value($frow);
41 $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']));
42 if (empty($entry_id)) {
43 // Insert new entry
44 sqlStatement("INSERT INTO `facility_user_ids` (`uid`, `facility_id`, `field_id`, `field_value`) VALUES (?,?,?,?)", array($_POST["user_id"],$_POST["fac_id"],$frow['field_id'], $value));
45 } else {
46 // Update existing entry
47 sqlStatement("UPDATE `facility_user_ids` SET `field_value` = ? WHERE `id` = ?", array($value,$entry_id['id']));
53 <html>
54 <head>
56 <title><?php echo xlt("Facility Specific User Information"); ?></title>
58 <?php Header::setupHeader(['common','jquery-ui']); ?>
60 <script type="text/javascript">
61 function refreshme() {
62 top.restoreSession();
63 document.location.reload();
66 $(function(){
67 $(".small_modal").on('click', function(e) {
68 e.preventDefault();e.stopPropagation();
69 dlgopen('', '', 500, 200, '', '', {
70 //onClosed: 'refreshme',
71 sizeHeight: 'auto',
72 allowResize: true,
73 allowDrag: true,
74 dialogId: '',
75 type: 'iframe',
76 url: $(this).attr('href')
77 });
78 });
79 });
80 </script>
81 </head>
82 <body class="body_top">
83 <?php
84 // Collect all users
85 $u_res = sqlStatement("select * from `users` WHERE `username` != '' AND `active` = 1 order by `username`");
87 // Collect all facilities and store them in an array
88 $f_res = sqlStatement("select * from `facility` order by `name`");
89 $f_arr = array();
90 for ($i=0; $row=sqlFetchArray($f_res); $i++) {
91 $f_arr[$i]=$row;
94 // Collect layout information and store them in an array
95 $l_res = sqlStatement("SELECT * FROM layout_options " .
96 "WHERE form_id = 'FACUSR' AND uor > 0 AND field_id != '' " .
97 "ORDER BY group_id, seq");
98 $l_arr = array();
99 for ($i=0; $row=sqlFetchArray($l_res); $i++) {
100 $l_arr[$i]=$row;
104 <div class="container">
105 <div class="row">
106 <div class="col-xs-12">
107 <div class="page-title">
108 <h2><?php echo xlt('Facility Specific User Information'); ?></h2>
109 </div>
110 </div>
111 </div>
112 <div class="row">
113 <div class="col-xs-12">
114 <div class="btn-group">
115 <a href="usergroup_admin.php" class="btn btn-default btn-back" onclick="top.restoreSession()"><?php echo xlt('Back to Users'); ?></a>
116 </div>
117 </div>
118 </div>
119 <div class="row">
120 <div class="table-responsive">
121 <table class="table table-striped">
122 <thead>
123 <tr>
124 <th><b><?php echo xlt('Username'); ?></b></th>
125 <th><b><?php echo xlt('Full Name'); ?></b></th>
126 <th><b><span class="bold"><?php echo xlt('Facility'); ?></span></b></th>
127 <?php
128 foreach ($l_arr as $layout_entry) {
129 echo "<th>" . text(xl_layout_label($layout_entry['title'])) . "&nbsp;</th>";
132 </tr>
133 </thead>
134 <tbody>
135 <?php
136 while ($user = sqlFetchArray($u_res)) {
137 foreach ($f_arr as $facility) { ?>
138 <tr>
139 <td><a href="facility_user_admin.php?user_id=<?php echo attr_url($user['id']);?>&fac_id=<?php echo attr_url($facility['id']); ?>" class="small_modal" onclick="top.restoreSession()"><b><?php echo text($user['username']);?></b></a>&nbsp;</td>
140 <td><?php echo text($user['fname'] . " " . $user['lname']);?></td>
141 <td><?php echo text($facility['name']);?>&nbsp;</td>
142 <?php
143 foreach ($l_arr as $layout_entry) {
144 $entry_data = sqlQuery("SELECT `field_value` FROM `facility_user_ids` " .
145 "WHERE `uid` = ? AND `facility_id` = ? AND `field_id` = ?", array($user['id'],$facility['id'],$layout_entry['field_id']));
146 echo "<td>" . generate_display_field($layout_entry, $entry_data['field_value']) . "&nbsp;</td>";
149 </tr>
150 <?php
154 </tbody>
155 </table>
156 </div>
157 </div>
158 </div>
159 </body>
160 </html>