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 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 (!acl_check('admin', 'users')) {
23 die(xlt("Unauthorized"));
28 if (isset($_POST["mode"]) && $_POST["mode"] == "facility_user_id" && isset($_POST["user_id"]) && isset($_POST["fac_id"])) {
29 // Inserting/Updating new facility specific user information
30 $fres = sqlStatement("SELECT * FROM `layout_options` " .
31 "WHERE `form_id` = 'FACUSR' AND `uor` > 0 AND `field_id` != '' " .
32 "ORDER BY `group_id`, `seq`");
33 while ($frow = sqlFetchArray($fres)) {
34 $value = get_layout_form_value($frow);
35 $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']));
36 if (empty($entry_id)) {
38 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));
40 // Update existing entry
41 sqlStatement("UPDATE `facility_user_ids` SET `field_value` = ? WHERE `id` = ?", array($value,$entry_id['id']));
50 <title
><?php
echo xlt("Facility Specific User Information"); ?
></title
>
52 <?php Header
::setupHeader(['common','jquery-ui']); ?
>
54 <script type
="text/javascript">
55 function refreshme() {
57 document
.location
.reload();
60 $
(document
).ready(function(){
61 $
(".small_modal").on('click', function(e
) {
62 e
.preventDefault();e
.stopPropagation();
63 dlgopen('', '', 500, 200, '', '', {
64 //onClosed: 'refreshme',
70 url
: $
(this
).attr('href')
76 <body
class="body_top">
79 $u_res = sqlStatement("select * from `users` WHERE `username` != '' AND `active` = 1 order by `username`");
81 // Collect all facilities and store them in an array
82 $f_res = sqlStatement("select * from `facility` order by `name`");
84 for ($i=0; $row=sqlFetchArray($f_res); $i++
) {
88 // Collect layout information and store them in an array
89 $l_res = sqlStatement("SELECT * FROM layout_options " .
90 "WHERE form_id = 'FACUSR' AND uor > 0 AND field_id != '' " .
91 "ORDER BY group_id, seq");
93 for ($i=0; $row=sqlFetchArray($l_res); $i++
) {
98 <div
class="container">
100 <div
class="col-xs-12">
101 <div
class="page-title">
102 <h2
><?php
echo xlt('Facility Specific User Information'); ?
></h2
>
107 <div
class="col-xs-12">
108 <div
class="btn-group">
109 <a href
="usergroup_admin.php" class="btn btn-default btn-back" onclick
="top.restoreSession()"><?php
echo xlt('Back to Users'); ?
></a
>
114 <div
class="table-responsive">
115 <table
class="table table-striped">
118 <th
><b
><?php
echo xlt('Username'); ?
></b
></th
>
119 <th
><b
><?php
echo xlt('Full Name'); ?
></b
></th
>
120 <th
><b
><span
class="bold"><?php
echo xlt('Facility'); ?
></span
></b
></th
>
122 foreach ($l_arr as $layout_entry) {
123 echo "<th>" . text(xl_layout_label($layout_entry['title'])) . " </th>";
130 while ($user = sqlFetchArray($u_res)) {
131 foreach ($f_arr as $facility) { ?
>
133 <td
><a href
="facility_user_admin.php?user_id=<?php echo attr($user['id']);?>&fac_id=<?php echo attr($facility['id']);?>" class="small_modal" onclick
="top.restoreSession()"><b
><?php
echo text($user['username']);?
></b
></a
> 
;</td
>
134 <td
><?php
echo text($user['fname'] . " " . $user['lname']);?
></td
>
135 <td
><?php
echo text($facility['name']);?
> 
;</td
>
137 foreach ($l_arr as $layout_entry) {
138 $entry_data = sqlQuery("SELECT `field_value` FROM `facility_user_ids` " .
139 "WHERE `uid` = ? AND `facility_id` = ? AND `field_id` = ?", array($user['id'],$facility['id'],$layout_entry['field_id']));
140 echo "<td>" . generate_display_field($layout_entry, $entry_data['field_value']) . " </td>";