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 require_once("../globals.php");
10 require_once("$srcdir/acl.inc");
11 require_once("$srcdir/formdata.inc.php");
12 require_once("$srcdir/options.inc.php");
14 $popup = empty($_GET['popup']) ?
0 : 1;
16 $form_fname = formData("form_fname","P",true);
17 $form_lname = formData("form_lname","P",true);
18 $form_specialty = formData("form_specialty","P",true);
19 $form_abook_type = formData("form_abook_type","R",true);
20 $form_external = $_POST['form_external'] ?
1 : 0;
22 $query = "SELECT u.*, lo.option_id AS ab_name FROM users AS u " .
23 "LEFT JOIN list_options AS lo ON " .
24 "list_id = 'abook_type' AND option_id = u.abook_type " .
25 "WHERE u.active = 1 AND ( u.authorized = 1 OR u.username = '' ) ";
26 if ($form_lname) $query .= "AND u.lname LIKE '$form_lname%' ";
27 if ($form_fname) $query .= "AND u.fname LIKE '$form_fname%' ";
28 if ($form_specialty) $query .= "AND u.specialty LIKE '%$form_specialty%' ";
29 if ($form_abook_type) $query .= "AND u.abook_type LIKE '$form_abook_type' ";
30 if ($form_external) $query .= "AND u.username = '' ";
31 $query .= "ORDER BY u.lname, u.fname, u.mname LIMIT 500";
32 $res = sqlStatement($query);
38 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
39 <title
><?php
xl('Address Book','e'); ?
></title
>
41 <!-- style tag moved into proper CSS file
-->
43 <?php
if ($popup) { ?
>
44 <script type
="text/javascript" src
="../../library/topdialog.js"></script
>
46 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
48 <script language
="JavaScript">
50 <?php
if ($popup) require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
52 // Callback from popups to refresh this display.
53 function refreshme() {
55 document
.forms
[0].submit();
58 // Process click to pop up the add window.
59 function doedclick_add(type
) {
61 dlgopen('addrbook_edit.php?type=' + type
, '_blank', 700, 550);
64 // Process click to pop up the edit window.
65 function doedclick_edit(userid
) {
67 dlgopen('addrbook_edit.php?userid=' + userid
, '_blank', 700, 550);
74 <body
class="body_top">
76 <div id
="addressbook_list">
77 <form method
='post' action
='addrbook_list.php'>
80 <tr
class='search'> <!-- bgcolor
='#ddddff' -->
82 <?php
xl('First Name','e')?
>:
83 <input type
='text' name
='form_fname' size
='10' value
='<?php echo htmlspecialchars(strip_escape_custom($_POST['form_fname
']),ENT_QUOTES); ?>'
84 class='inputtext' title
='<?php xl("All or part of the first name","e") ?>' /> 
;
85 <?php
xl('Last Name','e')?
>:
86 <input type
='text' name
='form_lname' size
='10' value
='<?php echo htmlspecialchars(strip_escape_custom($_POST['form_lname
']),ENT_QUOTES); ?>'
87 class='inputtext' title
='<?php xl("All or part of the last name","e") ?>' /> 
;
88 <?php
xl('Specialty','e')?
>:
89 <input type
='text' name
='form_specialty' size
='10' value
='<?php echo htmlspecialchars(strip_escape_custom($_POST['form_specialty
']),ENT_QUOTES); ?>'
90 class='inputtext' title
='<?php xl("Any part of the desired specialty","e") ?>' /> 
;
92 echo xl('Type') . ": ";
93 // Generates a select list named form_abook_type:
94 echo generate_select_list("form_abook_type", "abook_type", strip_escape_custom($_REQUEST['form_abook_type']), '', 'All');
96 <input type
='checkbox' name
='form_external' value
='1'<?php
if ($form_external) echo ' checked'; ?
>
97 title
='<?php xl("Omit internal users?","e") ?>' />
98 <?php
xl('External Only','e')?
> 
; 
;
99 <input type
='submit' class='button' name
='form_search' value
='<?php xl("Search","e")?>' />
102 <input type
='button' class='button' value
='<?php xl("Add New","e"); ?>' onclick
='doedclick_add(document.forms[0].form_abook_type.value)' />
109 <td title
=<?php
xl('Click to view or edit','e','\'','\''); ?
>><?php
xl('Name','e'); ?
></td
>
110 <td
><?php
xl('Local','e'); ?
></td
><!-- empty for external
-->
111 <td
><?php
xl('Type','e'); ?
></td
>
112 <td
><?php
xl('Specialty','e'); ?
></td
>
113 <td
><?php
xl('Phone','e'); ?
></td
>
114 <td
><?php
xl('Mobile','e'); ?
></td
>
115 <td
><?php
xl('Fax','e'); ?
></td
>
116 <td
><?php
xl('Email','e'); ?
></td
>
117 <td
><?php
xl('Street','e'); ?
></td
>
118 <td
><?php
xl('City','e'); ?
></td
>
119 <td
><?php
xl('State','e'); ?
></td
>
120 <td
><?php
xl('Postal','e'); ?
></td
>
125 while ($row = sqlFetchArray($res)) {
127 //$bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
128 $bgclass = (($encount & 1) ?
"evenrow" : "oddrow");
129 $username = $row['username'];
130 if (! $row['active']) $username = '--';
131 if ( empty($row['fname']) && empty($row['mname']) && empty($row['lname']) ) {
132 $displayName = $row['organization'];
135 $displayName = $row['fname'] . ' ' . $row['mname'] . ' ' . $row['lname'];
137 if ( acl_check('admin', 'practice' ) ||
(empty($username) && empty($row['ab_name'])) ) {
138 // Allow edit, since have access or (no item type and not a local user)
139 $trTitle = xl('Edit','','',' ') . $displayName;
140 echo " <tr class='detail $bgclass' style='cursor:pointer' " .
141 "onclick='doedclick_edit(" . $row['id'] . ")' title='$trTitle'>\n";
144 // Do not allow edit, since no access and (item is a type or is a local user)
145 $trTitle = $displayName . " (" . xl("Not Allowed to Edit") . ")";
146 echo " <tr class='detail $bgclass' title='$trTitle'>\n";
148 echo " <td>" . $displayName . "</td>\n";
149 echo " <td>" . ($username ?
'*' : '') . "</td>\n";
150 echo " <td>" . generate_display_field(array('data_type'=>'1','list_id'=>'abook_type'),$row['ab_name']) . "</td>\n";
151 echo " <td>" . $row['specialty'] . "</td>\n";
152 echo " <td>" . $row['phonew1'] . "</td>\n";
153 echo " <td>" . $row['phonecell'] . "</td>\n";
154 echo " <td>" . $row['fax'] . "</td>\n";
155 echo " <td>" . $row['email'] . "</td>\n";
156 echo " <td>" . $row['street'] . "</td>\n";
157 echo " <td>" . $row['city'] . "</td>\n";
158 echo " <td>" . $row['state'] . "</td>\n";
159 echo " <td>" . $row['zip'] . "</td>\n";