bug fix march continued (#1921)
[openemr.git] / interface / usergroup / addrbook_list.php
blob1de6bcd421cc650464254d0ad876e965b0bd585d
1 <?php
2 /**
3 * The address book entry editor.
4 * Available from Administration->Addr Book in the concurrent layout.
6 * Copyright (C) 2006-2010, 2016 Rod Roark <rod@sunsetsystems.com>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * Improved slightly by tony@mi-squared.com 2011, added organization to view
14 * and search
16 * @package OpenEMR
17 * @author Rod Roark <rod@sunsetsystems.com>
18 * @author Jerry Padgett <sjpadgett@gmail.com>
19 * @link http://open-emr.org
22 require_once("../globals.php");
23 require_once("$srcdir/acl.inc");
24 require_once("$srcdir/options.inc.php");
25 use OpenEMR\Core\Header;
27 $popup = empty($_GET['popup']) ? 0 : 1;
28 $rtn_selection = 0;
29 if ($popup) {
30 $rtn_selection = $_GET['popup'] == 2 ? 1 : 0;
33 $form_fname = trim($_POST['form_fname']);
34 $form_lname = trim($_POST['form_lname']);
35 $form_specialty = trim($_POST['form_specialty']);
36 $form_organization = trim($_POST['form_organization']);
37 $form_abook_type = trim($_REQUEST['form_abook_type']);
38 $form_external = $_POST['form_external'] ? 1 : 0;
40 $sqlBindArray = array();
41 $query = "SELECT u.*, lo.option_id AS ab_name, lo.option_value as ab_option FROM users AS u " .
42 "LEFT JOIN list_options AS lo ON " .
43 "list_id = 'abook_type' AND option_id = u.abook_type AND activity = 1 " .
44 "WHERE u.active = 1 AND ( u.authorized = 1 OR u.username = '' ) ";
45 if ($form_organization) {
46 $query .= "AND u.organization LIKE ? ";
47 array_push($sqlBindArray, $form_organization."%");
50 if ($form_lname) {
51 $query .= "AND u.lname LIKE ? ";
52 array_push($sqlBindArray, $form_lname."%");
55 if ($form_fname) {
56 $query .= "AND u.fname LIKE ? ";
57 array_push($sqlBindArray, $form_fname."%");
60 if ($form_specialty) {
61 $query .= "AND u.specialty LIKE ? ";
62 array_push($sqlBindArray, "%".$form_specialty."%");
65 if ($form_abook_type) {
66 $query .= "AND u.abook_type LIKE ? ";
67 array_push($sqlBindArray, $form_abook_type);
70 if ($form_external) {
71 $query .= "AND u.username = '' ";
74 if ($form_lname) {
75 $query .= "ORDER BY u.lname, u.fname, u.mname";
76 } else if ($form_organization) {
77 $query .= "ORDER BY u.organization";
78 } else {
79 $query .= "ORDER BY u.organization, u.lname, u.fname";
82 $query .= " LIMIT 500";
83 $res = sqlStatement($query, $sqlBindArray);
86 <!DOCTYPE html>
87 <html>
89 <head>
91 <?php Header::setupHeader(['common']); ?>
93 <title><?php echo xlt('Address Book'); ?></title>
95 <!-- style tag moved into proper CSS file -->
97 </head>
99 <body class="body_top">
101 <div class="container-fluid">
102 <div class="nav navbar-fixed-top body_title">
103 <div class="col-md-12">
104 <h3><?php echo xlt('Address Book'); ?></h3>
106 <form class='navbar-form' method='post' action='addrbook_list.php'
107 onsubmit='return top.restoreSession()'>
109 <div class="text-center">
110 <div class="form-group">
111 <label><?php echo xlt('Organization') ?>:</label>
112 <input type='text' name='form_organization' size='10'
113 value='<?php echo attr($_POST['form_organization']); ?>'
114 class='inputtext' title='<?php echo xla("All or part of the organization") ?>'/>&nbsp;
115 <label><?php echo xlt('First Name') ?>:</label>
116 <input type='text' name='form_fname' size='10' value='<?php echo attr($_POST['form_fname']); ?>'
117 class='inputtext' title='<?php echo xla("All or part of the first name") ?>'/>&nbsp;
118 <label><?php echo xlt('Last Name') ?>:</label>
119 <input type='text' name='form_lname' size='10' value='<?php echo attr($_POST['form_lname']); ?>'
120 class='inputtext' title='<?php echo xla("All or part of the last name") ?>'/>&nbsp;
121 <label><?php echo xlt('Specialty') ?>:</label>
122 <input type='text' name='form_specialty' size='10' value='<?php echo attr($_POST['form_specialty']); ?>'
123 class='inputtext' title='<?php echo xla("Any part of the desired specialty") ?>'/>&nbsp;
124 <?php
125 echo xlt('Type') . ": ";
126 // Generates a select list named form_abook_type:
127 echo generate_select_list("form_abook_type", "abook_type", $_REQUEST['form_abook_type'], '', 'All');
129 <input type='checkbox' name='form_external' value='1'<?php if ($form_external) {
130 echo ' checked ';} ?>
131 title='<?php echo xla("Omit internal users?") ?>'/>
132 <?php echo xlt('External Only') ?>
133 <input type='button' class='btn btn-primary' value='<?php echo xla("Add New"); ?>'
134 onclick='doedclick_add(document.forms[0].form_abook_type.value)'/>&nbsp;&nbsp;
135 <input type='submit' title='<?php echo xla("Use % alone in a field to just sort on that column") ?>'
136 class='btn btn-primary' name='form_search' value='<?php echo xla("Search") ?>'/>
137 </div>
138 </div>
139 </form>
140 </div>
141 </div>
142 <div style="margin-top: 110px;" class="table-responsive">
143 <table class="table table-condensed table-bordered table-striped table-hover">
144 <thead>
145 <th title='<?php echo xla('Click to view or edit'); ?>'><?php echo xlt('Organization'); ?></th>
146 <th><?php echo xlt('Name'); ?></th>
147 <th><?php echo xlt('Local'); ?></th><!-- empty for external -->
148 <th><?php echo xlt('Type'); ?></th>
149 <th><?php echo xlt('Specialty'); ?></th>
150 <th><?php echo xlt('Phone(W)'); ?></th>
151 <th><?php echo xlt('Mobile'); ?></th>
152 <th><?php echo xlt('Fax'); ?></th>
153 <th><?php echo xlt('Email'); ?></th>
154 <th><?php echo xlt('Street'); ?></th>
155 <th><?php echo xlt('City'); ?></th>
156 <th><?php echo xlt('State'); ?></th>
157 <th><?php echo xlt('Postal'); ?></th>
158 </thead>
159 <?php
160 $encount = 0;
161 while ($row = sqlFetchArray($res)) {
162 ++$encount;
163 $username = $row['username'];
164 if (! $row['active']) {
165 $username = '--';
168 $displayName = $row['fname'] . ' ' . $row['mname'] . ' ' . $row['lname']; // Person Name
169 if ($row['suffix'] >'') {
170 $displayName .=", ".$row['suffix'];
173 if (acl_check('admin', 'practice') || (empty($username) && empty($row['ab_name']))) {
174 // Allow edit, since have access or (no item type and not a local user)
175 $trTitle = xl('Edit'). ' ' . $displayName;
176 echo " <tr class='address_names detail' style='cursor:pointer' " .
177 "onclick='doedclick_edit(" . $row['id'] . ")' title='".attr($trTitle)."'>\n";
178 } else {
179 // Do not allow edit, since no access and (item is a type or is a local user)
180 $trTitle = $displayName . " (" . xl("Not Allowed to Edit") . ")";
181 echo " <tr class='address_names detail' title='".attr($trTitle)."'>\n";
184 echo " <td>" . text($row['organization']) . "</td>\n";
185 echo " <td>" . text($displayName) . "</td>\n";
186 echo " <td>" . ($username ? '*' : '') . "</td>\n";
187 echo " <td>" . generate_display_field(array('data_type'=>'1','list_id'=>'abook_type'), $row['ab_name']) . "</td>\n";
188 echo " <td>" . text($row['specialty']) . "</td>\n";
189 echo " <td>" . text($row['phonew1']) . "</td>\n";
190 echo " <td>" . text($row['phonecell']) . "</td>\n";
191 echo " <td>" . text($row['fax']) . "</td>\n";
192 echo " <td>" . text($row['email']) . "</td>\n";
193 echo " <td>" . text($row['street']) . "</td>\n";
194 echo " <td>" . text($row['city']) . "</td>\n";
195 echo " <td>" . text($row['state']) . "</td>\n";
196 echo " <td>" . text($row['zip']) . "</td>\n";
197 echo " </tr>\n";
200 </table>
201 </div>
203 <?php if ($popup) { ?>
204 <script type="text/javascript" src="../../library/topdialog.js"></script>
205 <?php } ?>
206 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
208 <script language="JavaScript">
210 <?php if ($popup) {
211 require($GLOBALS['srcdir'] . "/restoreSession.php");
212 } ?>
214 // Callback from popups to refresh this display.
215 function refreshme() {
216 // location.reload();
217 document.forms[0].submit();
220 // Process click to pop up the add window.
221 function doedclick_add(type) {
222 top.restoreSession();
223 dlgopen('addrbook_edit.php?type=' + type, '_blank', 650, (screen.availHeight * 75/100));
226 // Process click to pop up the edit window.
227 function doedclick_edit(userid) {
228 let rtn_selection = <?php echo $rtn_selection ?>;
229 if(rtn_selection) {
230 dlgclose('contactCallBack', userid);
232 top.restoreSession();
233 dlgopen('addrbook_edit.php?userid=' + userid, '_blank', 650, (screen.availHeight * 75/100));
236 // Removed .ready and fancy box (no longer used here) - 10/23/17 sjp
238 </script>
239 </div>
240 </body>
241 </html>