change viewer calling paths (#1410)
[openemr.git] / interface / usergroup / addrbook_list.php
blob64e2dc346c45ead10ba442608b8f5412afa6ba6d
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;
29 $form_fname = trim($_POST['form_fname']);
30 $form_lname = trim($_POST['form_lname']);
31 $form_specialty = trim($_POST['form_specialty']);
32 $form_organization = trim($_POST['form_organization']);
33 $form_abook_type = trim($_REQUEST['form_abook_type']);
34 $form_external = $_POST['form_external'] ? 1 : 0;
36 $sqlBindArray = array();
37 $query = "SELECT u.*, lo.option_id AS ab_name, lo.option_value as ab_option FROM users AS u " .
38 "LEFT JOIN list_options AS lo ON " .
39 "list_id = 'abook_type' AND option_id = u.abook_type AND activity = 1 " .
40 "WHERE u.active = 1 AND ( u.authorized = 1 OR u.username = '' ) ";
41 if ($form_organization) {
42 $query .= "AND u.organization LIKE ? ";
43 array_push($sqlBindArray, $form_organization."%");
46 if ($form_lname) {
47 $query .= "AND u.lname LIKE ? ";
48 array_push($sqlBindArray, $form_lname."%");
51 if ($form_fname) {
52 $query .= "AND u.fname LIKE ? ";
53 array_push($sqlBindArray, $form_fname."%");
56 if ($form_specialty) {
57 $query .= "AND u.specialty LIKE ? ";
58 array_push($sqlBindArray, "%".$form_specialty."%");
61 if ($form_abook_type) {
62 $query .= "AND u.abook_type LIKE ? ";
63 array_push($sqlBindArray, $form_abook_type);
66 if ($form_external) {
67 $query .= "AND u.username = '' ";
70 if ($form_lname) {
71 $query .= "ORDER BY u.lname, u.fname, u.mname";
72 } else if ($form_organization) {
73 $query .= "ORDER BY u.organization";
74 } else {
75 $query .= "ORDER BY u.organization, u.lname, u.fname";
78 $query .= " LIMIT 500";
79 $res = sqlStatement($query, $sqlBindArray);
82 <!DOCTYPE html>
83 <html>
85 <head>
87 <?php Header::setupHeader(['common']); ?>
89 <title><?php echo xlt('Address Book'); ?></title>
91 <!-- style tag moved into proper CSS file -->
93 </head>
95 <body class="body_top">
97 <div class="container-fluid">
98 <div class="nav navbar-fixed-top body_title">
99 <div class="col-md-12">
100 <h3><?php echo xlt('Address Book'); ?></h3>
102 <form class='navbar-form' method='post' action='addrbook_list.php'
103 onsubmit='return top.restoreSession()'>
105 <div class="text-center">
106 <div class="form-group">
107 <label><?php echo xlt('Organization') ?>:</label>
108 <input type='text' name='form_organization' size='10'
109 value='<?php echo attr($_POST['form_organization']); ?>'
110 class='inputtext' title='<?php echo xla("All or part of the organization") ?>'/>&nbsp;
111 <label><?php echo xlt('First Name') ?>:</label>
112 <input type='text' name='form_fname' size='10' value='<?php echo attr($_POST['form_fname']); ?>'
113 class='inputtext' title='<?php echo xla("All or part of the first name") ?>'/>&nbsp;
114 <label><?php echo xlt('Last Name') ?>:</label>
115 <input type='text' name='form_lname' size='10' value='<?php echo attr($_POST['form_lname']); ?>'
116 class='inputtext' title='<?php echo xla("All or part of the last name") ?>'/>&nbsp;
117 <label><?php echo xlt('Specialty') ?>:</label>
118 <input type='text' name='form_specialty' size='10' value='<?php echo attr($_POST['form_specialty']); ?>'
119 class='inputtext' title='<?php echo xla("Any part of the desired specialty") ?>'/>&nbsp;
120 <?php
121 echo xlt('Type') . ": ";
122 // Generates a select list named form_abook_type:
123 echo generate_select_list("form_abook_type", "abook_type", $_REQUEST['form_abook_type'], '', 'All');
125 <input type='checkbox' name='form_external' value='1'<?php if ($form_external) {
126 echo ' checked ';} ?>
127 title='<?php echo xla("Omit internal users?") ?>'/>
128 <?php echo xlt('External Only') ?>
129 <input type='button' class='btn btn-primary' value='<?php echo xla("Add New"); ?>'
130 onclick='doedclick_add(document.forms[0].form_abook_type.value)'/>&nbsp;&nbsp;
131 <input type='submit' title='<?php echo xla("Use % alone in a field to just sort on that column") ?>'
132 class='btn btn-primary' name='form_search' value='<?php echo xla("Search") ?>'/>
133 </div>
134 </div>
135 </form>
136 </div>
137 </div>
138 <div style="margin-top: 110px;" class="table-responsive">
139 <table class="table table-condensed table-bordered table-striped table-hover">
140 <thead>
141 <th title='<?php echo xla('Click to view or edit'); ?>'><?php echo xlt('Organization'); ?></th>
142 <th><?php echo xlt('Name'); ?></th>
143 <th><?php echo xlt('Local'); ?></th><!-- empty for external -->
144 <th><?php echo xlt('Type'); ?></th>
145 <th><?php echo xlt('Specialty'); ?></th>
146 <th><?php echo xlt('Phone(W)'); ?></th>
147 <th><?php echo xlt('Mobile'); ?></th>
148 <th><?php echo xlt('Fax'); ?></th>
149 <th><?php echo xlt('Email'); ?></th>
150 <th><?php echo xlt('Street'); ?></th>
151 <th><?php echo xlt('City'); ?></th>
152 <th><?php echo xlt('State'); ?></th>
153 <th><?php echo xlt('Postal'); ?></th>
154 </thead>
155 <?php
156 $encount = 0;
157 while ($row = sqlFetchArray($res)) {
158 ++$encount;
159 $username = $row['username'];
160 if (! $row['active']) {
161 $username = '--';
164 $displayName = $row['fname'] . ' ' . $row['mname'] . ' ' . $row['lname']; // Person Name
165 if ($row['suffix'] >'') {
166 $displayName .=", ".$row['suffix'];
169 if (acl_check('admin', 'practice') || (empty($username) && empty($row['ab_name']))) {
170 // Allow edit, since have access or (no item type and not a local user)
171 $trTitle = xl('Edit'). ' ' . $displayName;
172 echo " <tr class='address_names detail' style='cursor:pointer' " .
173 "onclick='doedclick_edit(" . $row['id'] . ")' title='".attr($trTitle)."'>\n";
174 } else {
175 // Do not allow edit, since no access and (item is a type or is a local user)
176 $trTitle = $displayName . " (" . xl("Not Allowed to Edit") . ")";
177 echo " <tr class='address_names detail' title='".attr($trTitle)."'>\n";
180 echo " <td>" . text($row['organization']) . "</td>\n";
181 echo " <td>" . text($displayName) . "</td>\n";
182 echo " <td>" . ($username ? '*' : '') . "</td>\n";
183 echo " <td>" . generate_display_field(array('data_type'=>'1','list_id'=>'abook_type'), $row['ab_name']) . "</td>\n";
184 echo " <td>" . text($row['specialty']) . "</td>\n";
185 echo " <td>" . text($row['phonew1']) . "</td>\n";
186 echo " <td>" . text($row['phonecell']) . "</td>\n";
187 echo " <td>" . text($row['fax']) . "</td>\n";
188 echo " <td>" . text($row['email']) . "</td>\n";
189 echo " <td>" . text($row['street']) . "</td>\n";
190 echo " <td>" . text($row['city']) . "</td>\n";
191 echo " <td>" . text($row['state']) . "</td>\n";
192 echo " <td>" . text($row['zip']) . "</td>\n";
193 echo " </tr>\n";
196 </table>
197 </div>
199 <?php if ($popup) { ?>
200 <script type="text/javascript" src="../../library/topdialog.js"></script>
201 <?php } ?>
202 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
204 <script language="JavaScript">
206 <?php if ($popup) {
207 require($GLOBALS['srcdir'] . "/restoreSession.php");
208 } ?>
210 // Callback from popups to refresh this display.
211 function refreshme() {
212 // location.reload();
213 document.forms[0].submit();
216 // Process click to pop up the add window.
217 function doedclick_add(type) {
218 top.restoreSession();
219 dlgopen('addrbook_edit.php?type=' + type, '_blank', 650, (screen.availHeight * 75/100));
222 // Process click to pop up the edit window.
223 function doedclick_edit(userid) {
224 top.restoreSession();
225 dlgopen('addrbook_edit.php?userid=' + userid, '_blank', 650, (screen.availHeight * 75/100));
228 // Removed .ready and fancy box (no longer used here) - 10/23/17 sjp
230 </script>
231 </div>
232 </body>
233 </html>