-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathview_all.php
113 lines (94 loc) · 2.36 KB
/
view_all.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
/*
* view_participants.php
*
* Display the entire people table
*
*/
include_once 'checkinstance.php';
if ( !isset($_SESSION['userlevel']) ||
( ($_SESSION['userlevel'] != 0) &&
($_SESSION['userlevel'] != 3) &&
($_SESSION['userlevel'] != 4) &&
($_SESSION['userlevel'] != 5) ) ) // Super user, admin and super admin only
{
header('Location: index.php');
exit();
}
include 'config.php';
include 'db.php';
// ini_set('display_errors', 'On');
// Start displaying page
$page_title = 'View Users';
$js = 'js/export.js,js/sorttable.js';
include 'header.php';
?>
<div id='content'>
<h1 class='title'>View Users</h1>
<?php
// Display a table
$table = create_table($link);
echo $table;
$_SESSION['print_title'] = "LIMS Users";
$_SESSION['print_text'] = $table;
?>
</div>
<?php
include 'footer.php';
exit();
// Function to create a table of all records
function create_table($link)
{
$querywhere = "";
if ( $_SESSION['userlevel'] == 0 ) {
$querywhere = "WHERE userlevel <= 3 ";
}
$query = "SELECT personID, lname, fname, " .
"organization, address, city, state, zip, country, " .
"phone, email " .
"FROM people " .
$querywhere .
"ORDER BY lname, fname ";
$result = mysqli_query($link, $query)
or die("Query failed : $query<br />\n" . mysqli_error($link));
$table = <<<HTML
<table cellspacing='0' cellpadding='7' class='style1 sortable' style='width:95%;'>
<thead>
<tr>
<th>Name</th>
<th>Organization</th>
<th>Phone</th>
<th>Email</th>
</tr>
</thead>
<tfoot>
<tr><td colspan='5'><input type='button' value='Print Version'
onclick='print_version();' /></td></tr>
</tfoot>
<tbody>
HTML;
while ( $row = mysqli_fetch_array($result) )
{
foreach ($row as $key => $value)
{
$$key = (empty($value)) ? "" : html_entity_decode(stripslashes( nl2br($value)) );
}
$table .= <<<HTML
<tr>
<td><a href='view_users.php?personID=$personID'>$lname, $fname</a></td>
<td>$organization<br />
$address<br />
$city, $state $zip<br />
$country</td>
<td>$phone</td>
<td>$email</td>
</tr>
HTML;
}
$table .= <<<HTML
</tbody>
</table>
HTML;
return $table;
}
?>