2 // Copyright (C) 2006-2010 Rod Roark <rod@sunsetsystems.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 // Improved slightly by tony@mi-squared.com 2011, added organization to view
12 require_once("../globals.php");
13 require_once("$srcdir/acl.inc");
14 require_once("$srcdir/formdata.inc.php");
15 require_once("$srcdir/options.inc.php");
17 $popup = empty($_GET['popup']) ?
0 : 1;
19 $form_fname = formData("form_fname","P",true);
20 $form_lname = formData("form_lname","P",true);
21 $form_specialty = formData("form_specialty","P",true);
22 $form_abook_type = formData("form_abook_type","R",true);
23 $form_external = $_POST['form_external'] ?
1 : 0;
25 $query = "SELECT u.*, lo.option_id AS ab_name, lo.option_value as ab_option FROM users AS u " .
26 "LEFT JOIN list_options AS lo ON " .
27 "list_id = 'abook_type' AND option_id = u.abook_type " .
28 "WHERE u.active = 1 AND ( u.authorized = 1 OR u.username = '' ) ";
29 if ($form_organization) $query .= "AND u.organization LIKE '$form_organization%' ";
30 if ($form_lname) $query .= "AND u.lname LIKE '$form_lname%' ";
31 if ($form_fname) $query .= "AND u.fname LIKE '$form_fname%' ";
32 if ($form_specialty) $query .= "AND u.specialty LIKE '%$form_specialty%' ";
33 if ($form_abook_type) $query .= "AND u.abook_type LIKE '$form_abook_type' ";
34 if ($form_external) $query .= "AND u.username = '' ";
36 $query .= "ORDER BY u.lname, u.fname, u.mname";
37 } else if ($form_organization) {
38 $query .= "ORDER BY u.organization";
40 $query .= "ORDER BY u.organization, u.lname, u.fname";
42 $query .= " LIMIT 500";
43 $res = sqlStatement($query);
49 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
50 <title
><?php
xl('Address Book','e'); ?
></title
>
52 <!-- style tag moved into proper CSS file
-->
54 <?php
if ($popup) { ?
>
55 <script type
="text/javascript" src
="../../library/topdialog.js"></script
>
57 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
59 <script language
="JavaScript">
61 <?php
if ($popup) require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
63 // Callback from popups to refresh this display.
64 function refreshme() {
66 document
.forms
[0].submit();
69 // Process click to pop up the add window.
70 function doedclick_add(type
) {
72 dlgopen('addrbook_edit.php?type=' + type
, '_blank', 700, 550);
75 // Process click to pop up the edit window.
76 function doedclick_edit(userid
) {
78 dlgopen('addrbook_edit.php?userid=' + userid
, '_blank', 700, 550);
85 <body
class="body_top">
87 <div id
="addressbook_list">
88 <form method
='post' action
='addrbook_list.php'>
91 <tr
class='search'> <!-- bgcolor
='#ddddff' -->
93 <?php
xl('Organization','e')?
>:
94 <input type
='text' name
='form_organization' size
='10' value
='<?php echo htmlspecialchars(strip_escape_custom($_POST['form_organization
']),ENT_QUOTES); ?>'
95 class='inputtext' title
='<?php xl("All or part of the organization","e") ?>' /> 
;
96 <?php
xl('First Name','e')?
>:
97 <input type
='text' name
='form_fname' size
='10' value
='<?php echo htmlspecialchars(strip_escape_custom($_POST['form_fname
']),ENT_QUOTES); ?>'
98 class='inputtext' title
='<?php xl("All or part of the first name","e") ?>' /> 
;
99 <?php
xl('Last Name','e')?
>:
100 <input type
='text' name
='form_lname' size
='10' value
='<?php echo htmlspecialchars(strip_escape_custom($_POST['form_lname
']),ENT_QUOTES); ?>'
101 class='inputtext' title
='<?php xl("All or part of the last name","e") ?>' /> 
;
102 <?php
xl('Specialty','e')?
>:
103 <input type
='text' name
='form_specialty' size
='10' value
='<?php echo htmlspecialchars(strip_escape_custom($_POST['form_specialty
']),ENT_QUOTES); ?>'
104 class='inputtext' title
='<?php xl("Any part of the desired specialty","e") ?>' /> 
;
106 echo xl('Type') . ": ";
107 // Generates a select list named form_abook_type:
108 echo generate_select_list("form_abook_type", "abook_type", strip_escape_custom($_REQUEST['form_abook_type']), '', 'All');
110 <input type
='checkbox' name
='form_external' value
='1'<?php
if ($form_external) echo ' checked'; ?
>
111 title
='<?php xl("Omit internal users?","e") ?>' />
112 <?php
xl('External Only','e')?
> 
; 
;
113 <input type
='submit' title
='<?php xl("Use % alone in a field to just sort on that column","e") ?>' class='button' name
='form_search' value
='<?php xl("Search","e")?>' />
114 <input type
='button' class='button' value
='<?php xl("Add New","e"); ?>' onclick
='doedclick_add(document.forms[0].form_abook_type.value)' />
121 <td title
=<?php
xl('Click to view or edit','e','\'','\''); ?
>><?php
xl('Organization','e'); ?
></td
>
122 <td
><?php
xl('Name','e'); ?
></td
>
123 <td
><?php
xl('Local','e'); ?
></td
><!-- empty for external
-->
124 <td
><?php
xl('Type','e'); ?
></td
>
125 <td
><?php
xl('Specialty','e'); ?
></td
>
126 <td
><?php
xl('Phone','e'); ?
></td
>
127 <td
><?php
xl('Mobile','e'); ?
></td
>
128 <td
><?php
xl('Fax','e'); ?
></td
>
129 <td
><?php
xl('Email','e'); ?
></td
>
130 <td
><?php
xl('Street','e'); ?
></td
>
131 <td
><?php
xl('City','e'); ?
></td
>
132 <td
><?php
xl('State','e'); ?
></td
>
133 <td
><?php
xl('Postal','e'); ?
></td
>
138 while ($row = sqlFetchArray($res)) {
140 //$bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
141 $bgclass = (($encount & 1) ?
"evenrow" : "oddrow");
142 $username = $row['username'];
143 if (! $row['active']) $username = '--';
145 $displayName = $row['fname'] . ' ' . $row['mname'] . ' ' . $row['lname']; // Person Name
147 if ( acl_check('admin', 'practice' ) ||
(empty($username) && empty($row['ab_name'])) ) {
148 // Allow edit, since have access or (no item type and not a local user)
149 $trTitle = xl('Edit','','',' ') . $displayName;
150 echo " <tr class='detail $bgclass' style='cursor:pointer' " .
151 "onclick='doedclick_edit(" . $row['id'] . ")' title='$trTitle'>\n";
154 // Do not allow edit, since no access and (item is a type or is a local user)
155 $trTitle = $displayName . " (" . xl("Not Allowed to Edit") . ")";
156 echo " <tr class='detail $bgclass' title='$trTitle'>\n";
158 echo " <td>" . $row['organization'] . "</td>\n";
159 echo " <td>" . $displayName . "</td>\n";
160 echo " <td>" . ($username ?
'*' : '') . "</td>\n";
161 echo " <td>" . generate_display_field(array('data_type'=>'1','list_id'=>'abook_type'),$row['ab_name']) . "</td>\n";
162 echo " <td>" . $row['specialty'] . "</td>\n";
163 echo " <td>" . $row['phonew1'] . "</td>\n";
164 echo " <td>" . $row['phonecell'] . "</td>\n";
165 echo " <td>" . $row['fax'] . "</td>\n";
166 echo " <td>" . $row['email'] . "</td>\n";
167 echo " <td>" . $row['street'] . "</td>\n";
168 echo " <td>" . $row['city'] . "</td>\n";
169 echo " <td>" . $row['state'] . "</td>\n";
170 echo " <td>" . $row['zip'] . "</td>\n";