added Urdu language
[openemr.git] / interface / usergroup / facility_user.php
blobe5f6bee80af915ee247203f3c1beaadcced01e0c
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/options.inc.php");
37 require_once("$srcdir/acl.inc");
39 // Ensure authorized
40 if (!acl_check('admin', 'users')) {
41 die(xlt("Unauthorized"));
44 $alertmsg = '';
46 if ( isset($_POST["mode"]) && $_POST["mode"] == "facility_user_id" && isset($_POST["user_id"]) && isset($_POST["fac_id"]) ) {
47 // Inserting/Updating new facility specific user information
48 $fres = sqlStatement("SELECT * FROM `layout_options` " .
49 "WHERE `form_id` = 'FACUSR' AND `uor` > 0 AND `field_id` != '' " .
50 "ORDER BY `group_name`, `seq`");
51 while ($frow = sqlFetchArray($fres)) {
52 $value = get_layout_form_value($frow);
53 $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']) );
54 if (empty($entry_id)) {
55 // Insert new entry
56 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) );
58 else {
59 // Update existing entry
60 sqlStatement("UPDATE `facility_user_ids` SET `field_value` = ? WHERE `id` = ?", array($value,$entry_id['id']) );
66 <html>
67 <head>
68 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
69 <link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
70 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
71 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script>
72 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/common.js"></script>
73 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
74 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-ui.js"></script>
75 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.easydrag.handler.beta2.js"></script>
77 <script type="text/javascript">
79 $(document).ready(function(){
81 // fancy box
82 enable_modals();
84 // special size for
85 $(".iframe_small").fancybox( {
86 'overlayOpacity' : 0.0,
87 'showCloseButton' : true,
88 'frameHeight' : 300,
89 'frameWidth' : 500
90 });
92 $(function(){
93 // add drag and drop functionality to fancybox
94 $("#fancy_outer").easydrag();
95 });
96 });
98 </script>
100 </head>
101 <body class="body_top">
103 <?php
104 // Collect all users
105 $u_res = sqlStatement("select * from `users` WHERE `username` != '' AND `active` = 1 order by `username`");
107 // Collect all facilities and store them in an array
108 $f_res = sqlStatement("select * from `facility` order by `name`");
109 $f_arr = array();
110 for($i=0; $row=sqlFetchArray($f_res); $i++) {
111 $f_arr[$i]=$row;
114 // Collect layout information and store them in an array
115 $l_res = sqlStatement("SELECT * FROM layout_options " .
116 "WHERE form_id = 'FACUSR' AND uor > 0 AND field_id != '' " .
117 "ORDER BY group_name, seq");
118 $l_arr = array();
119 for($i=0; $row=sqlFetchArray($l_res); $i++) {
120 $l_arr[$i]=$row;
125 <div>
126 <div>
127 <table>
128 <tr >
129 <td><b><?php echo xlt('Facility Specific User Information'); ?></b></td>
130 <td><a href="usergroup_admin.php" class="css_button" onclick="top.restoreSession()"><span><?php echo xlt('Back to Users'); ?></span></a>
131 </td>
132 </tr>
133 </table>
134 </div>
136 <div style="width:400px;">
137 <div>
139 <table cellpadding="1" cellspacing="0" class="showborder">
140 <tbody><tr height="22" class="showborder_head">
141 <th width="180px"><b><?php echo xlt('Username'); ?></b></th>
142 <th width="270px"><b><?php echo xlt('Full Name'); ?></b></th>
143 <th width="190px"><b><span class="bold"><?php echo xlt('Facility'); ?></span></b></th>
144 <?php
145 foreach ($l_arr as $layout_entry) {
146 echo "<th width='100px'><b><span class='bold'>" . text(xl_layout_label($layout_entry['title'])) . "&nbsp;</span></b></th>";
149 </tr>
150 <?php
151 while ($user = sqlFetchArray($u_res)) {
152 foreach ($f_arr as $facility) {
154 <tr height="20" class="text" style="border-bottom: 1px dashed;">
155 <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>
156 <td><span class="text"><?php echo text($user['fname'] . " " . $user['lname']);?></span>&nbsp;</td>
157 <td><span class="text"><?php echo text($facility['name']);?>&nbsp;</td>
158 <?php
159 foreach ($l_arr as $layout_entry) {
160 $entry_data = sqlQuery("SELECT `field_value` FROM `facility_user_ids` " .
161 "WHERE `uid` = ? AND `facility_id` = ? AND `field_id` = ?", array($user['id'],$facility['id'],$layout_entry['field_id']) );
162 echo "<td><span class='text'>" . generate_display_field($layout_entry,$entry_data['field_value']) . "&nbsp;</td>";
165 </tr>
166 <?php
169 </tbody>
170 </table>
171 </div>
172 </div>
173 </div>
174 </body>
175 </html>