1 |
<?php |
2 |
if (isset($_GET["print"]) && $_GET["print"] == "1") { |
3 |
$print = 1; |
4 |
} else { |
5 |
$print = 0; |
6 |
} |
7 |
|
8 |
if ($print == 0) { |
9 |
include "header.php"; |
10 |
} else { |
11 |
$tablestyle = " border='1' width='100%' cellpadding='15' cellspacing='0' "; |
12 |
} |
13 |
|
14 |
include "inc/mysql.php"; |
15 |
?> |
16 |
|
17 |
<script> |
18 |
$(document).ready( function() { |
19 |
$('#persontable').dataTable( { |
20 |
"bPaginate": false, |
21 |
"bLengthChange": false, |
22 |
"bFilter": true, |
23 |
"bSort": true, |
24 |
"bInfo": false, |
25 |
"bAutoWidth": false |
26 |
} |
27 |
); |
28 |
}); |
29 |
</script> |
30 |
|
31 |
|
32 |
<?php |
33 |
if ( isset($_GET["enhed"]) ) { |
34 |
$enhed = $_GET["enhed"]; |
35 |
$filter = "WHERE r.enhed = '$enhed'"; |
36 |
|
37 |
echo "<H2>$enhed</H2>"; |
38 |
if ($print == 0) { |
39 |
echo "<a target='_blank' href='personer.php?enhed={$enhed}&print=1'>[Udskriv]</a><br>"; |
40 |
} |
41 |
} else { |
42 |
$filter = ""; |
43 |
echo "<H2>Medlemmer</H2>"; |
44 |
} |
45 |
|
46 |
|
47 |
|
48 |
$sql = "select fornavn, efternavn, mobil, email, group_concat(enhed) as enhed,group_concat( rolle) as rolle from |
49 |
stamdata s left join roller r on (s.id = r.medlemsid) |
50 |
$filter |
51 |
group by s.id order by fornavn,efternavn"; |
52 |
$rows = query($sql); |
53 |
|
54 |
|
55 |
echo "<table {$tablestyle} id='persontable'>"; |
56 |
echo "<thead>\n"; |
57 |
echo "<tr><th width='100'>Fornavn</th><th>Efternavn</th><th>Mobil</th><th>Email</th>"; |
58 |
if (isset($enhed)) { |
59 |
echo "<th>Rolle</th>"; |
60 |
} else { |
61 |
echo "<th>Enheder</td>"; |
62 |
} |
63 |
echo "</tr>\n"; |
64 |
echo "</thead>\n"; |
65 |
echo "<tbody>\n"; |
66 |
|
67 |
$i = 0; |
68 |
|
69 |
foreach($rows as $row) { |
70 |
echo "<tr><td>{$row->fornavn}</td><td>{$row->efternavn}</td><td>{$row->mobil}</td><td>{$row->email}</td>"; |
71 |
if (isset($enhed)) { |
72 |
echo "<td>{$row->rolle}</td>"; |
73 |
} else { |
74 |
echo "<td>{$row->enhed}</td>"; |
75 |
} |
76 |
echo "</tr>\n"; |
77 |
|
78 |
$i = ($i+1)%2; |
79 |
} |
80 |
echo "</tbody>\n"; |
81 |
echo "</table>"; |
82 |
echo "<font size='-1'>Antal: " . sizeof($rows) . "</font>"; |
83 |
|
84 |
if ($print == 0) { |
85 |
require("footer.php"); |
86 |
} |
87 |
?> |