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, lo.option_value as ab_option 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 = '--';
132 // Collect the display name
133 if ($row['ab_option'] == 3) {
134 // Company centric listing
135 $displayName = $row['organization'];
138 // Person centric listing
139 $displayName = $row['fname'] . ' ' . $row['mname'] . ' ' . $row['lname'];
142 if ( acl_check('admin', 'practice' ) ||
(empty($username) && empty($row['ab_name'])) ) {
143 // Allow edit, since have access or (no item type and not a local user)
144 $trTitle = xl('Edit','','',' ') . $displayName;
145 echo " <tr class='detail $bgclass' style='cursor:pointer' " .
146 "onclick='doedclick_edit(" . $row['id'] . ")' title='$trTitle'>\n";
149 // Do not allow edit, since no access and (item is a type or is a local user)
150 $trTitle = $displayName . " (" . xl("Not Allowed to Edit") . ")";
151 echo " <tr class='detail $bgclass' title='$trTitle'>\n";
153 echo " <td>" . $displayName . "</td>\n";
154 echo " <td>" . ($username ?
'*' : '') . "</td>\n";
155 echo " <td>" . generate_display_field(array('data_type'=>'1','list_id'=>'abook_type'),$row['ab_name']) . "</td>\n";
156 echo " <td>" . $row['specialty'] . "</td>\n";
157 echo " <td>" . $row['phonew1'] . "</td>\n";
158 echo " <td>" . $row['phonecell'] . "</td>\n";
159 echo " <td>" . $row['fax'] . "</td>\n";
160 echo " <td>" . $row['email'] . "</td>\n";
161 echo " <td>" . $row['street'] . "</td>\n";
162 echo " <td>" . $row['city'] . "</td>\n";
163 echo " <td>" . $row['state'] . "</td>\n";
164 echo " <td>" . $row['zip'] . "</td>\n";