Fully responsive globals.php with vertical menu (#2460)
[openemr.git] / interface / usergroup / addrbook_list.php
blob41c69263af90c959471e75da722aaf639ef89f88
1 <?php
2 /**
3 * The address book entry editor.
4 * Available from Administration->Addr Book in the concurrent layout.
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author tony@mi-squared.com
10 * @author Jerry Padgett <sjpadgett@gmail.com>
11 * @author Brady Miller <brady.g.miller@gmail.com>
12 * @copyright Copyright (c) 2006-2010, 2016 Rod Roark <rod@sunsetsystems.com>
13 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
14 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
18 require_once("../globals.php");
19 require_once("$srcdir/acl.inc");
20 require_once("$srcdir/options.inc.php");
22 use OpenEMR\Core\Header;
24 if (!empty($_POST)) {
25 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
26 csrfNotVerified();
30 $popup = empty($_GET['popup']) ? 0 : 1;
31 $rtn_selection = 0;
32 if ($popup) {
33 $rtn_selection = $_GET['popup'] == 2 ? 1 : 0;
36 $form_fname = trim($_POST['form_fname']);
37 $form_lname = trim($_POST['form_lname']);
38 $form_specialty = trim($_POST['form_specialty']);
39 $form_organization = trim($_POST['form_organization']);
40 $form_abook_type = trim($_REQUEST['form_abook_type']);
41 $form_external = $_POST['form_external'] ? 1 : 0;
43 $sqlBindArray = array();
44 $query = "SELECT u.*, lo.option_id AS ab_name, lo.option_value as ab_option FROM users AS u " .
45 "LEFT JOIN list_options AS lo ON " .
46 "list_id = 'abook_type' AND option_id = u.abook_type AND activity = 1 " .
47 "WHERE u.active = 1 AND ( u.authorized = 1 OR u.username = '' ) ";
48 if ($form_organization) {
49 $query .= "AND u.organization LIKE ? ";
50 array_push($sqlBindArray, $form_organization."%");
53 if ($form_lname) {
54 $query .= "AND u.lname LIKE ? ";
55 array_push($sqlBindArray, $form_lname."%");
58 if ($form_fname) {
59 $query .= "AND u.fname LIKE ? ";
60 array_push($sqlBindArray, $form_fname."%");
63 if ($form_specialty) {
64 $query .= "AND u.specialty LIKE ? ";
65 array_push($sqlBindArray, "%".$form_specialty."%");
68 if ($form_abook_type) {
69 $query .= "AND u.abook_type LIKE ? ";
70 array_push($sqlBindArray, $form_abook_type);
73 if ($form_external) {
74 $query .= "AND u.username = '' ";
77 if ($form_lname) {
78 $query .= "ORDER BY u.lname, u.fname, u.mname";
79 } else if ($form_organization) {
80 $query .= "ORDER BY u.organization";
81 } else {
82 $query .= "ORDER BY u.organization, u.lname, u.fname";
85 $query .= " LIMIT 500";
86 $res = sqlStatement($query, $sqlBindArray);
89 <!DOCTYPE html>
90 <html>
92 <head>
94 <?php Header::setupHeader(['common']); ?>
96 <title><?php echo xlt('Address Book'); ?></title>
98 <!-- style tag moved into proper CSS file -->
100 </head>
102 <body class="body_top">
104 <div class="container-fluid">
105 <div class="nav navbar-fixed-top body_title">
106 <div class="col-md-12">
107 <h3><?php echo xlt('Address Book'); ?></h3>
109 <form class='navbar-form' method='post' action='addrbook_list.php'
110 onsubmit='return top.restoreSession()'>
111 <input type="hidden" name="csrf_token_form" value="<?php echo attr(collectCsrfToken()); ?>" />
113 <div class="text-center">
114 <div class="form-group">
115 <label><?php echo xlt('Organization') ?>:</label>
116 <input type='text' name='form_organization' size='10'
117 value='<?php echo attr($_POST['form_organization']); ?>'
118 class='inputtext' title='<?php echo xla("All or part of the organization") ?>'/>&nbsp;
119 <label><?php echo xlt('First Name') ?>:</label>
120 <input type='text' name='form_fname' size='10' value='<?php echo attr($_POST['form_fname']); ?>'
121 class='inputtext' title='<?php echo xla("All or part of the first name") ?>'/>&nbsp;
122 <label><?php echo xlt('Last Name') ?>:</label>
123 <input type='text' name='form_lname' size='10' value='<?php echo attr($_POST['form_lname']); ?>'
124 class='inputtext' title='<?php echo xla("All or part of the last name") ?>'/>&nbsp;
125 <label><?php echo xlt('Specialty') ?>:</label>
126 <input type='text' name='form_specialty' size='10' value='<?php echo attr($_POST['form_specialty']); ?>'
127 class='inputtext' title='<?php echo xla("Any part of the desired specialty") ?>'/>&nbsp;
128 <?php
129 echo xlt('Type') . ": ";
130 // Generates a select list named form_abook_type:
131 echo generate_select_list("form_abook_type", "abook_type", $_REQUEST['form_abook_type'], '', 'All');
133 <input type='checkbox' name='form_external' value='1'<?php echo ($form_external) ? ' checked ' : ''; ?>
134 title='<?php echo xla("Omit internal users?") ?>'/>
135 <?php echo xlt('External Only') ?>
136 <input type='button' class='btn btn-primary' value='<?php echo xla("Add New"); ?>'
137 onclick='doedclick_add(document.forms[0].form_abook_type.value)'/>&nbsp;&nbsp;
138 <input type='submit' title='<?php echo xla("Use % alone in a field to just sort on that column") ?>'
139 class='btn btn-primary' name='form_search' value='<?php echo xla("Search") ?>'/>
140 </div>
141 </div>
142 </form>
143 </div>
144 </div>
145 <div style="margin-top: 110px;" class="table-responsive">
146 <table class="table table-condensed table-bordered table-striped table-hover">
147 <thead>
148 <th title='<?php echo xla('Click to view or edit'); ?>'><?php echo xlt('Organization'); ?></th>
149 <th><?php echo xlt('Name'); ?></th>
150 <th><?php echo xlt('Local'); ?></th><!-- empty for external -->
151 <th><?php echo xlt('Type'); ?></th>
152 <th><?php echo xlt('Specialty'); ?></th>
153 <th><?php echo xlt('Phone(W)'); ?></th>
154 <th><?php echo xlt('Mobile'); ?></th>
155 <th><?php echo xlt('Fax'); ?></th>
156 <th><?php echo xlt('Email'); ?></th>
157 <th><?php echo xlt('Street'); ?></th>
158 <th><?php echo xlt('City'); ?></th>
159 <th><?php echo xlt('State'); ?></th>
160 <th><?php echo xlt('Postal'); ?></th>
161 </thead>
162 <?php
163 $encount = 0;
164 while ($row = sqlFetchArray($res)) {
165 ++$encount;
166 $username = $row['username'];
167 if (! $row['active']) {
168 $username = '--';
171 $displayName = $row['fname'] . ' ' . $row['mname'] . ' ' . $row['lname']; // Person Name
172 if ($row['suffix'] >'') {
173 $displayName .=", ".$row['suffix'];
176 if (acl_check('admin', 'practice') || (empty($username) && empty($row['ab_name']))) {
177 // Allow edit, since have access or (no item type and not a local user)
178 $trTitle = xl('Edit'). ' ' . $displayName;
179 echo " <tr class='address_names detail' style='cursor:pointer' " .
180 "onclick='doedclick_edit(" . attr_js($row['id']) . ")' title='".attr($trTitle)."'>\n";
181 } else {
182 // Do not allow edit, since no access and (item is a type or is a local user)
183 $trTitle = $displayName . " (" . xl("Not Allowed to Edit") . ")";
184 echo " <tr class='address_names detail' title='".attr($trTitle)."'>\n";
187 echo " <td>" . text($row['organization']) . "</td>\n";
188 echo " <td>" . text($displayName) . "</td>\n";
189 echo " <td>" . ($username ? '*' : '') . "</td>\n";
190 echo " <td>" . generate_display_field(array('data_type'=>'1','list_id'=>'abook_type'), $row['ab_name']) . "</td>\n";
191 echo " <td>" . text($row['specialty']) . "</td>\n";
192 echo " <td>" . text($row['phonew1']) . "</td>\n";
193 echo " <td>" . text($row['phonecell']) . "</td>\n";
194 echo " <td>" . text($row['fax']) . "</td>\n";
195 echo " <td>" . text($row['email']) . "</td>\n";
196 echo " <td>" . text($row['street']) . "</td>\n";
197 echo " <td>" . text($row['city']) . "</td>\n";
198 echo " <td>" . text($row['state']) . "</td>\n";
199 echo " <td>" . text($row['zip']) . "</td>\n";
200 echo " </tr>\n";
203 </table>
204 </div>
206 <?php if ($popup) { ?>
207 <script type="text/javascript" src="../../library/topdialog.js"></script>
208 <?php } ?>
209 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
211 <script language="JavaScript">
213 <?php if ($popup) {
214 require($GLOBALS['srcdir'] . "/restoreSession.php");
215 } ?>
217 // Callback from popups to refresh this display.
218 function refreshme() {
219 // location.reload();
220 document.forms[0].submit();
223 // Process click to pop up the add window.
224 function doedclick_add(type) {
225 top.restoreSession();
226 dlgopen('addrbook_edit.php?type=' + encodeURIComponent(type), '_blank', 650, (screen.availHeight * 75/100));
229 // Process click to pop up the edit window.
230 function doedclick_edit(userid) {
231 let rtn_selection = <?php echo js_escape($rtn_selection); ?>;
232 if(rtn_selection) {
233 dlgclose('contactCallBack', userid);
235 top.restoreSession();
236 dlgopen('addrbook_edit.php?userid=' + encodeURIComponent(userid), '_blank', 650, (screen.availHeight * 75/100));
239 </script>
240 </div>
241 </body>
242 </html>