3 * Facility user-specific settings.
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
;
22 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
28 if (!acl_check('admin', 'users')) {
29 die(xlt("Unauthorized"));
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)) {
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));
46 // Update existing entry
47 sqlStatement("UPDATE `facility_user_ids` SET `field_value` = ? WHERE `id` = ?", array($value,$entry_id['id']));
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() {
63 document
.location
.reload();
67 $
(".small_modal").on('click', function(e
) {
68 e
.preventDefault();e
.stopPropagation();
69 dlgopen('', '', 500, 200, '', '', {
70 //onClosed: 'refreshme',
76 url
: $
(this
).attr('href')
82 <body
class="body_top">
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`");
90 for ($i=0; $row=sqlFetchArray($f_res); $i++
) {
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");
99 for ($i=0; $row=sqlFetchArray($l_res); $i++
) {
104 <div
class="container">
106 <div
class="col-xs-12">
107 <div
class="page-title">
108 <h2
><?php
echo xlt('Facility Specific User Information'); ?
></h2
>
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
>
120 <div
class="table-responsive">
121 <table
class="table table-striped">
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
>
128 foreach ($l_arr as $layout_entry) {
129 echo "<th>" . text(xl_layout_label($layout_entry['title'])) . " </th>";
136 while ($user = sqlFetchArray($u_res)) {
137 foreach ($f_arr as $facility) { ?
>
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
> 
;</td
>
140 <td
><?php
echo text($user['fname'] . " " . $user['lname']);?
></td
>
141 <td
><?php
echo text($facility['name']);?
> 
;</td
>
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']) . " </td>";