minor fix to prior commit
[openemr.git] / interface / usergroup / addrbook_list.php
blob1a95cad40632ab816904e26d15b5aa6234f16b62
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 * @link http://open-emr.org
21 require_once("../globals.php");
22 require_once("$srcdir/acl.inc");
23 require_once("$srcdir/options.inc.php");
25 $popup = empty($_GET['popup']) ? 0 : 1;
27 $form_fname = trim($_POST['form_fname']);
28 $form_lname = trim($_POST['form_lname']);
29 $form_specialty = trim($_POST['form_specialty']);
30 $form_organization = trim($_POST['form_organization']);
31 $form_abook_type = trim($_REQUEST['form_abook_type']);
32 $form_external = $_POST['form_external'] ? 1 : 0;
34 $sqlBindArray = array();
35 $query = "SELECT u.*, lo.option_id AS ab_name, lo.option_value as ab_option FROM users AS u " .
36 "LEFT JOIN list_options AS lo ON " .
37 "list_id = 'abook_type' AND option_id = u.abook_type AND activity = 1 " .
38 "WHERE u.active = 1 AND ( u.authorized = 1 OR u.username = '' ) ";
39 if ($form_organization) {
40 $query .= "AND u.organization LIKE ? ";
41 array_push($sqlBindArray,$form_organization."%");
43 if ($form_lname) {
44 $query .= "AND u.lname LIKE ? ";
45 array_push($sqlBindArray,$form_lname."%");
47 if ($form_fname) {
48 $query .= "AND u.fname LIKE ? ";
49 array_push($sqlBindArray,$form_fname."%");
51 if ($form_specialty) {
52 $query .= "AND u.specialty LIKE ? ";
53 array_push($sqlBindArray,"%".$form_specialty."%");
55 if ($form_abook_type) {
56 $query .= "AND u.abook_type LIKE ? ";
57 array_push($sqlBindArray,$form_abook_type);
59 if ($form_external) {
60 $query .= "AND u.username = '' ";
62 if ($form_lname) {
63 $query .= "ORDER BY u.lname, u.fname, u.mname";
64 } else if ($form_organization) {
65 $query .= "ORDER BY u.organization";
66 } else {
67 $query .= "ORDER BY u.organization, u.lname, u.fname";
69 $query .= " LIMIT 500";
70 $res = sqlStatement($query,$sqlBindArray);
72 <html>
74 <head>
76 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
77 <title><?php echo xlt('Address Book'); ?></title>
79 <!-- style tag moved into proper CSS file -->
81 </head>
83 <body class="body_top">
85 <div id="addressbook_list">
86 <form method='post' action='addrbook_list.php' onsubmit='return top.restoreSession()'>
88 <table>
89 <tr class='search'> <!-- bgcolor='#ddddff' -->
90 <td>
91 <?php echo xlt('Organization')?>:
92 <input type='text' name='form_organization' size='10' value='<?php echo attr($_POST['form_organization']); ?>'
93 class='inputtext' title='<?php echo xla("All or part of the organization") ?>' />&nbsp;
94 <?php echo xlt('First Name')?>:
95 <input type='text' name='form_fname' size='10' value='<?php echo attr($_POST['form_fname']); ?>'
96 class='inputtext' title='<?php echo xla("All or part of the first name") ?>' />&nbsp;
97 <?php echo xlt('Last Name')?>:
98 <input type='text' name='form_lname' size='10' value='<?php echo attr($_POST['form_lname']); ?>'
99 class='inputtext' title='<?php echo xla("All or part of the last name") ?>' />&nbsp;
100 <?php echo xlt('Specialty')?>:
101 <input type='text' name='form_specialty' size='10' value='<?php echo attr($_POST['form_specialty']); ?>'
102 class='inputtext' title='<?php echo xla("Any part of the desired specialty") ?>' />&nbsp;
103 <?php
104 echo xlt('Type') . ": ";
105 // Generates a select list named form_abook_type:
106 echo generate_select_list("form_abook_type", "abook_type", $_REQUEST['form_abook_type'], '', 'All');
108 <input type='checkbox' name='form_external' value='1'<?php if ($form_external) echo ' checked'; ?>
109 title='<?php echo xla("Omit internal users?") ?>' />
110 <?php echo xlt('External Only')?>&nbsp;&nbsp;
111 <input type='submit' title='<?php echo xla("Use % alone in a field to just sort on that column") ?>' class='button' name='form_search' value='<?php echo xla("Search")?>' />
112 <input type='button' class='button' value='<?php echo xla("Add New"); ?>' onclick='doedclick_add(document.forms[0].form_abook_type.value)' />
113 </td>
114 </tr>
115 </table>
117 <table>
118 <tr class='head'>
119 <td title='<?php echo xla('Click to view or edit'); ?>'><?php echo xlt('Organization'); ?></td>
120 <td><?php echo xlt('Name'); ?></td>
121 <td><?php echo xlt('Local'); ?></td><!-- empty for external -->
122 <td><?php echo xlt('Type'); ?></td>
123 <td><?php echo xlt('Specialty'); ?></td>
124 <td><?php echo xlt('Phone'); ?></td>
125 <td><?php echo xlt('Mobile'); ?></td>
126 <td><?php echo xlt('Fax'); ?></td>
127 <td><?php echo xlt('Email'); ?></td>
128 <td><?php echo xlt('Street'); ?></td>
129 <td><?php echo xlt('City'); ?></td>
130 <td><?php echo xlt('State'); ?></td>
131 <td><?php echo xlt('Postal'); ?></td>
132 </tr>
134 <?php
135 $encount = 0;
136 while ($row = sqlFetchArray($res)) {
137 ++$encount;
138 //$bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
139 $bgclass = (($encount & 1) ? "evenrow" : "oddrow");
140 $username = $row['username'];
141 if (! $row['active']) $username = '--';
143 $displayName = $row['fname'] . ' ' . $row['mname'] . ' ' . $row['lname']; // Person Name
144 if ($row['suffix'] >'') $displayName .=", ".$row['suffix'];
145 if ( acl_check('admin', 'practice' ) || (empty($username) && empty($row['ab_name'])) ) {
146 // Allow edit, since have access or (no item type and not a local user)
147 $trTitle = xl('Edit'). ' ' . $displayName;
148 echo " <tr class='detail $bgclass' style='cursor:pointer' " .
149 "onclick='doedclick_edit(" . $row['id'] . ")' title='".attr($trTitle)."'>\n";
151 else {
152 // Do not allow edit, since no access and (item is a type or is a local user)
153 $trTitle = $displayName . " (" . xl("Not Allowed to Edit") . ")";
154 echo " <tr class='detail $bgclass' title='".attr($trTitle)."'>\n";
156 echo " <td>" . text($row['organization']) . "</td>\n";
157 echo " <td>" . text($displayName) . "</td>\n";
158 echo " <td>" . ($username ? '*' : '') . "</td>\n";
159 echo " <td>" . generate_display_field(array('data_type'=>'1','list_id'=>'abook_type'),$row['ab_name']) . "</td>\n";
160 echo " <td>" . text($row['specialty']) . "</td>\n";
161 echo " <td>" . text($row['phonew1']) . "</td>\n";
162 echo " <td>" . text($row['phonecell']) . "</td>\n";
163 echo " <td>" . text($row['fax']) . "</td>\n";
164 echo " <td>" . text($row['email']) . "</td>\n";
165 echo " <td>" . text($row['street']) . "</td>\n";
166 echo " <td>" . text($row['city']) . "</td>\n";
167 echo " <td>" . text($row['state']) . "</td>\n";
168 echo " <td>" . text($row['zip']) . "</td>\n";
169 echo " </tr>\n";
172 </table>
173 <div style="display: none;">
174 <a class="iframe addrbookedit_modal"></a>
175 </div>
177 <?php if ($popup) { ?>
178 <script type="text/javascript" src="../../library/topdialog.js"></script>
179 <?php } ?>
180 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
182 <script language="JavaScript">
184 <?php if ($popup) require($GLOBALS['srcdir'] . "/restoreSession.php"); ?>
186 // Callback from popups to refresh this display.
187 function refreshme() {
188 // location.reload();
189 document.forms[0].submit();
192 // Process click to pop up the add window.
193 function doedclick_add(type) {
194 top.restoreSession();
195 dlgopen('addrbook_edit.php?type=' + type, '_blank', 700, 550);
198 // Process click to pop up the edit window.
199 function doedclick_edit(userid) {
200 top.restoreSession();
201 dlgopen('addrbook_edit.php?userid=' + userid, '_blank', 700, 550);
204 $(document).ready(function(){
205 // initialise fancy box
206 enable_modals();
208 // initialise a link
209 $(".addrbookedit_modal").fancybox( {
210 'overlayOpacity' : 0.0,
211 'showCloseButton' : true,
212 'frameHeight' : 550,
213 'frameWidth' : 700
217 </script>
219 </body>
220 </html>