Clarify Address Book gui for laboratories:
[openemr.git] / interface / usergroup / addrbook_list.php
blob64d29ab50f7f0d022e0ccd56fb02349225cfe75e
1 <?php
2 // Copyright (C) 2006-2010 Rod Roark <rod@sunsetsystems.com>
3 //
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);
34 <html>
36 <head>
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>
45 <?php } ?>
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() {
54 // location.reload();
55 document.forms[0].submit();
58 // Process click to pop up the add window.
59 function doedclick_add(type) {
60 top.restoreSession();
61 dlgopen('addrbook_edit.php?type=' + type, '_blank', 700, 550);
64 // Process click to pop up the edit window.
65 function doedclick_edit(userid) {
66 top.restoreSession();
67 dlgopen('addrbook_edit.php?userid=' + userid, '_blank', 700, 550);
70 </script>
72 </head>
74 <body class="body_top">
76 <div id="addressbook_list">
77 <form method='post' action='addrbook_list.php'>
79 <table>
80 <tr class='search'> <!-- bgcolor='#ddddff' -->
81 <td>
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") ?>' />&nbsp;
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") ?>' />&nbsp;
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") ?>' />&nbsp;
91 <?php
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')?>&nbsp;&nbsp;
99 <input type='submit' class='button' name='form_search' value='<?php xl("Search","e")?>' />
100 </td>
101 <td align='right'>
102 <input type='button' class='button' value='<?php xl("Add New","e"); ?>' onclick='doedclick_add(document.forms[0].form_abook_type.value)' />
103 </td>
104 </tr>
105 </table>
107 <table>
108 <tr class='head'>
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>
121 </tr>
123 <?php
124 $encount = 0;
125 while ($row = sqlFetchArray($res)) {
126 ++$encount;
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'];
134 else {
135 $displayName = $row['fname'] . ' ' . $row['mname'] . ' ' . $row['lname'];
137 $trTitle = xl('Edit','','',' ') . $displayName;
138 echo " <tr class='detail $bgclass' style='cursor:pointer' " .
139 "onclick='doedclick_edit(" . $row['id'] . ")' title='$trTitle'>\n";
140 echo " <td>" . $displayName . "</td>\n";
141 echo " <td>" . ($username ? '*' : '') . "</td>\n";
142 echo " <td>" . generate_display_field(array('data_type'=>'1','list_id'=>'abook_type'),$row['ab_name']) . "</td>\n";
143 echo " <td>" . $row['specialty'] . "</td>\n";
144 echo " <td>" . $row['phonew1'] . "</td>\n";
145 echo " <td>" . $row['phonecell'] . "</td>\n";
146 echo " <td>" . $row['fax'] . "</td>\n";
147 echo " <td>" . $row['email'] . "</td>\n";
148 echo " <td>" . $row['street'] . "</td>\n";
149 echo " <td>" . $row['city'] . "</td>\n";
150 echo " <td>" . $row['state'] . "</td>\n";
151 echo " <td>" . $row['zip'] . "</td>\n";
152 echo " </tr>\n";
155 </table>
157 </body>
158 </html>