-
Notifications
You must be signed in to change notification settings - Fork 0
/
board-meetings.php
171 lines (153 loc) · 4.48 KB
/
board-meetings.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
/**
* Template Name: Board Meetings
*
* @package BAT
*/
get_header();
?>
<div id="page-overlay">
<div id="primary" class="content-area">
<main id="main" class="site-main">
<?php
while ( have_posts() ) : the_post();
$featured_image = get_the_post_thumbnail_url( $post->ID, 'full');
$archive_year = date("Y");
if(isset($_GET['archiveyear'])) {
$archive_year = sanitize_text_field($_GET['archiveyear']);
}
?>
<article <?php post_class(); ?>>
<?php
$header_class = 'page-header';
if ($featured_image) :
$header_class = 'page-header hero-header';
?>
<style>
.page-header {
background-repeat: no-repeat;
background-size: cover;
background-position: center;
background-image: url(<?php echo $featured_image; ?>);
}
</style>
<?php endif; ?>
<header class="<?php echo $header_class; ?>">
<div class="container">
<div class="wrapper sm-max-width">
<?php the_title( '<h1 class="entry-title main">', '</h1>' ); ?>
</div>
</div>
</header>
<br>
<hr>
<div class="container">
<div class="wrapper sm-max-width">
<div class="entry-content">
<?php the_content(); ?>
<form method="get" action="">
<label for="archiveyear">Show different year: </label>
<select name="archiveyear" id="archiveyear">
<?php
$cur = date("Y");
$first = 2012;
$range = range($cur, $first);
foreach($range as $r) {
$selected = '';
if ($r == $archive_year) {
$selected = ' selected ';
}
echo '<option value="'.$r.'"'.$selected.'>'.$r.'</option>';
}
?>
</select>
<input type="submit" class="btn" value="Get Meetings">
</form>
<div id="board-meetings">
<?php
$start = $archive_year . '0101';
$end = $archive_year . '1231';
$args = array(
'post_type' => 'board-meeting',
'meta_key' => 'meeting_date',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'posts_per_page' => -1,
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'meeting_date',
'value' => $start,
'compare' => '>=',
'type' => 'NUMERIC',
),
array(
'key' => 'meeting_date',
'value' => $end,
'compare' => '<=',
'type' => 'NUMERIC',
),
)
);
$q = new WP_Query($args);
if ( $q->have_posts() ) : ?>
<h2><?php echo $archive_year; ?> Meeting dates and agendas</h2>
<table id="board-meeting-table" class="table table-striped">
<thead>
<tr>
<th>Meeting</th>
<th>Date</th>
<th>Agenda (PDF)</th>
<th>Packet (PDF)</th>
<th>Minutes (PDF)</th>
</tr>
</thead>
<tbody>
<?php while ( $q->have_posts() ) : $q->the_post(); ?>
<?php
$agenda = get_field('agenda') ? get_field('agenda') : null;
$packet = get_field('packet') ? get_field('packet') : null;
$minutes = get_field('minutes') ? get_field('minutes') : null;
?>
<tr>
<td><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></td>
<td><?php the_field('meeting_date'); ?></td>
<td>
<?php if ($agenda) : ?>
<a href="<?php echo $agenda ?> " target="_blank">Agenda</a>
<?php else: echo '—'; ?>
<?php endif; ?>
</td>
<td>
<?php if ($packet) : ?>
<a href="<?php echo $packet ?> " target="_blank">Packet</a>
<?php else: echo '—'; ?>
<?php endif; ?>
</td>
<td>
<?php if ($minutes) : ?>
<a href="<?php echo $minutes ?>" target="_blank">Minutes</a>
<?php else: echo '—'; ?>
<?php endif; ?>
</td>
</tr>
<?php endwhile; wp_reset_postdata(); ?>
</tbody>
</table>
<?php else : ?>
<br>
<h3>There are no meetings available.</h3>
<?php endif; ?>
</div>
</div>
</div>
</div>
</article>
<?php
endwhile; // End of the loop.
?>
</main><!-- #main -->
</div><!-- #primary -->
</div><!-- #page-overlay -->
<?php
get_footer();