3 * The address book entry editor.
4 * Available from Administration->Addr Book in the concurrent layout.
6 * Copyright (C) 2006-2010 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
17 * @author Rod Roark <rod@sunsetsystems.com>
18 * @link http://open-emr.org
21 //SANITIZE ALL ESCAPES
22 $sanitize_all_escapes=true;
25 //STOP FAKE REGISTER GLOBALS
26 $fake_register_globals=false;
29 require_once("../globals.php");
30 require_once("$srcdir/acl.inc");
31 require_once("$srcdir/formdata.inc.php");
32 require_once("$srcdir/options.inc.php");
33 require_once("$srcdir/htmlspecialchars.inc.php");
35 $popup = empty($_GET['popup']) ?
0 : 1;
37 $form_fname = trim($_POST['form_fname']);
38 $form_lname = trim($_POST['form_lname']);
39 $form_specialty = trim($_POST['form_specialty']);
40 $form_organization = trim($_POST['form_organization']);
41 $form_abook_type = trim($_REQUEST['form_abook_type']);
42 $form_external = $_POST['form_external'] ?
1 : 0;
44 $sqlBindArray = array();
45 $query = "SELECT u.*, lo.option_id AS ab_name, lo.option_value as ab_option FROM users AS u " .
46 "LEFT JOIN list_options AS lo ON " .
47 "list_id = 'abook_type' AND option_id = u.abook_type " .
48 "WHERE u.active = 1 AND ( u.authorized = 1 OR u.username = '' ) ";
49 if ($form_organization) {
50 $query .= "AND u.organization LIKE ? ";
51 array_push($sqlBindArray,$form_organization."%");
54 $query .= "AND u.lname LIKE ? ";
55 array_push($sqlBindArray,$form_lname."%");
58 $query .= "AND u.fname LIKE ? ";
59 array_push($sqlBindArray,$form_fname."%");
61 if ($form_specialty) {
62 $query .= "AND u.specialty LIKE ? ";
63 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 $query .= "AND u.username = '' ";
73 $query .= "ORDER BY u.lname, u.fname, u.mname";
74 } else if ($form_organization) {
75 $query .= "ORDER BY u.organization";
77 $query .= "ORDER BY u.organization, u.lname, u.fname";
79 $query .= " LIMIT 500";
80 $res = sqlStatement($query,$sqlBindArray);
86 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
87 <title
><?php
echo xlt('Address Book'); ?
></title
>
89 <!-- style tag moved into proper CSS file
-->
93 <body
class="body_top">
95 <div id
="addressbook_list">
96 <form method
='post' action
='addrbook_list.php' onsubmit
='return top.restoreSession()'>
99 <tr
class='search'> <!-- bgcolor
='#ddddff' -->
101 <?php
echo xlt('Organization')?
>:
102 <input type
='text' name
='form_organization' size
='10' value
='<?php echo attr($_POST['form_organization
']); ?>'
103 class='inputtext' title
='<?php echo xla("All or part of the organization") ?>' /> 
;
104 <?php
echo xlt('First Name')?
>:
105 <input type
='text' name
='form_fname' size
='10' value
='<?php echo attr($_POST['form_fname
']); ?>'
106 class='inputtext' title
='<?php echo xla("All or part of the first name") ?>' /> 
;
107 <?php
echo xlt('Last Name')?
>:
108 <input type
='text' name
='form_lname' size
='10' value
='<?php echo attr($_POST['form_lname
']); ?>'
109 class='inputtext' title
='<?php echo xla("All or part of the last name") ?>' /> 
;
110 <?php
echo xlt('Specialty')?
>:
111 <input type
='text' name
='form_specialty' size
='10' value
='<?php echo attr($_POST['form_specialty
']); ?>'
112 class='inputtext' title
='<?php echo xla("Any part of the desired specialty") ?>' /> 
;
114 echo xlt('Type') . ": ";
115 // Generates a select list named form_abook_type:
116 echo generate_select_list("form_abook_type", "abook_type", $_REQUEST['form_abook_type'], '', 'All');
118 <input type
='checkbox' name
='form_external' value
='1'<?php
if ($form_external) echo ' checked'; ?
>
119 title
='<?php echo xla("Omit internal users?") ?>' />
120 <?php
echo xlt('External Only')?
> 
; 
;
121 <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")?>' />
122 <input type
='button' class='button' value
='<?php echo xla("Add New"); ?>' onclick
='doedclick_add(document.forms[0].form_abook_type.value)' />
129 <td title
='<?php echo xla('Click to view
or edit
'); ?>'><?php
echo xlt('Organization'); ?
></td
>
130 <td
><?php
echo xlt('Name'); ?
></td
>
131 <td
><?php
echo xlt('Local'); ?
></td
><!-- empty for external
-->
132 <td
><?php
echo xlt('Type'); ?
></td
>
133 <td
><?php
echo xlt('Specialty'); ?
></td
>
134 <td
><?php
echo xlt('Phone'); ?
></td
>
135 <td
><?php
echo xlt('Mobile'); ?
></td
>
136 <td
><?php
echo xlt('Fax'); ?
></td
>
137 <td
><?php
echo xlt('Email'); ?
></td
>
138 <td
><?php
echo xlt('Street'); ?
></td
>
139 <td
><?php
echo xlt('City'); ?
></td
>
140 <td
><?php
echo xlt('State'); ?
></td
>
141 <td
><?php
echo xlt('Postal'); ?
></td
>
146 while ($row = sqlFetchArray($res)) {
148 //$bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
149 $bgclass = (($encount & 1) ?
"evenrow" : "oddrow");
150 $username = $row['username'];
151 if (! $row['active']) $username = '--';
153 $displayName = $row['fname'] . ' ' . $row['mname'] . ' ' . $row['lname']; // Person Name
155 if ( acl_check('admin', 'practice' ) ||
(empty($username) && empty($row['ab_name'])) ) {
156 // Allow edit, since have access or (no item type and not a local user)
157 $trTitle = xl('Edit'). ' ' . $displayName;
158 echo " <tr class='detail $bgclass' style='cursor:pointer' " .
159 "onclick='doedclick_edit(" . $row['id'] . ")' title='".attr($trTitle)."'>\n";
162 // Do not allow edit, since no access and (item is a type or is a local user)
163 $trTitle = $displayName . " (" . xl("Not Allowed to Edit") . ")";
164 echo " <tr class='detail $bgclass' title='".attr($trTitle)."'>\n";
166 echo " <td>" . text($row['organization']) . "</td>\n";
167 echo " <td>" . text($displayName) . "</td>\n";
168 echo " <td>" . ($username ?
'*' : '') . "</td>\n";
169 echo " <td>" . generate_display_field(array('data_type'=>'1','list_id'=>'abook_type'),$row['ab_name']) . "</td>\n";
170 echo " <td>" . text($row['specialty']) . "</td>\n";
171 echo " <td>" . text($row['phonew1']) . "</td>\n";
172 echo " <td>" . text($row['phonecell']) . "</td>\n";
173 echo " <td>" . text($row['fax']) . "</td>\n";
174 echo " <td>" . text($row['email']) . "</td>\n";
175 echo " <td>" . text($row['street']) . "</td>\n";
176 echo " <td>" . text($row['city']) . "</td>\n";
177 echo " <td>" . text($row['state']) . "</td>\n";
178 echo " <td>" . text($row['zip']) . "</td>\n";
183 <div style
="display: none;">
184 <a
class="iframe addrbookedit_modal"></a
>
187 <?php
if ($popup) { ?
>
188 <script type
="text/javascript" src
="../../library/topdialog.js"></script
>
190 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
192 <script language
="JavaScript">
194 <?php
if ($popup) require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
196 // Callback from popups to refresh this display.
197 function refreshme() {
198 // location.reload();
199 document
.forms
[0].submit();
202 // Process click to pop up the add window.
203 function doedclick_add(type
) {
204 top
.restoreSession();
205 dlgopen('addrbook_edit.php?type=' + type
, '_blank', 700, 550);
208 // Process click to pop up the edit window.
209 function doedclick_edit(userid
) {
210 top
.restoreSession();
211 dlgopen('addrbook_edit.php?userid=' + userid
, '_blank', 700, 550);
214 $
(document
).ready(function(){
215 // initialise fancy box
219 $
(".addrbookedit_modal").fancybox( {
220 'overlayOpacity' : 0.0,
221 'showCloseButton' : true,