forked from mholt/ysaward
-
Notifications
You must be signed in to change notification settings - Fork 0
/
callings.php
111 lines (96 loc) · 2.38 KB
/
callings.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
<?php
require_once "lib/init.php";
protectPage();
// Build list of callings and members who hold those callings
// to render it below.
$list = '';
$r = DB::Run("SELECT ID FROM Callings WHERE WardID={$MEMBER->WardID} ORDER BY Name ASC");
if (!$r)
fail("ERROR > Could not request callings. Please report this: ".mysql_error());
$callings = array();
while ($row = mysql_fetch_array($r))
{
$c = Calling::Load($row['ID']);
if (!$c)
continue;
$r2 = DB::Run("SELECT MemberID FROM MembersCallings WHERE CallingID={$c->ID()}");
if (!$r2)
fail("ERROR > Can't list members' callings. Please report this: ".mysql_error());
if (mysql_num_rows($r2) > 0)
{
$callings[$c->Name] = array();
// Get a list of members with this calling
while ($row2 = mysql_fetch_array($r2))
{
$m = Member::Load($row2['MemberID']);
if (!$m)
continue;
$callings[$c->Name][] = $m;
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Callings — <?php echo $WARD ? $WARD->Name." Ward" : SITE_NAME; ?></title>
<?php include "includes/head.php"; ?>
<style>
.calling-name {
background: #EFEFEF;
font-size: 14px;
padding: 10px 15px;
line-height: 1em;
font-weight: bold;
}
</style>
</head>
<body>
<?php include "includes/header.php"; ?>
<h1>Callings</h1>
<div class="grid-container">
<?php
foreach ($callings as $callingName => $members):
?>
<div class="grid-25 mobile-grid-50 calling">
<div class="card">
<div class="calling-name">
<?php echo $callingName; ?>
</div>
<?php
foreach ($members as $mem):
?>
<a href="/member?id=<?php echo $mem->ID(); ?>" class="member-link">
<?php echo $mem->ProfilePicImgTag(true, true, "45px"); ?>
<?php echo $mem->FirstName().' '.$mem->LastName; ?>
</a>
<?php
endforeach;
?>
</div>
</div>
<?php
endforeach;
?>
</div>
<?php include "includes/footer.php"; ?>
<?php include "includes/nav.php"; ?>
<script>
$(function()
{
// For callings boxes of different heights,
// these 'clear' divs will force them to fold
// under each other properly. Mobile layout
// only shows 2 boxes per row; desktop 4.
// We employ a similar tactic on the FHE groups page.
$('.calling').each(function(i)
{
if ((i + 1) % 2 == 0)
$(this).after('<div class="clear hide-on-desktop"></div>');
if ((i + 1) % 4 == 0)
$(this).after('<div class="clear hide-on-mobile"></div>');
});
});
</script>
</body>
</html>