-
Notifications
You must be signed in to change notification settings - Fork 3
/
events.php
153 lines (133 loc) · 3.85 KB
/
events.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
<?php
session_start();
require_once('./services/chkSession.php');
require_once('./includes/head.php');
require_once('./includes/globalnav.php');
require_once('./classes/events.class.php');
require_once('./classes/users.class.php');
$user = new users();
$event = new events();
?>
<style type="text/css">
select{
width: 6em;
padding-bottom: 0;
margin-bottom:0;
}
</style>
<div class="container">
<h1>Scheduled Events</h1>
<p class="info">Welcome to the events page. Here you can see events at a glance by month. You can quickly signup for one here. To see details or make changes, click on the date of the event.</p>
<h5>Change Month </h5>
<form id="selMonth" method="GET" action="/events.php">
<select id="selEvMonth" name="month">
<option value='' disabled>Month</option>
<?php
if (isset($_GET['month'])){
$mon = $_GET['month'];
}else{
$mon = date('m');
}
$i = 1;
while ($i <= 12){
echo "<option value='$i'";
if ($i == $mon){
echo " selected='selected'";
}
echo ">$i</option>";
$i= $i + 1;
}
?>
</select>
<select id="selEvYear" name="year">
<option value='' disabled>Year</option>
<?php
if (isset($_POST['year'])){
$yr = $_GET['year'];
}else{
$yr = date('Y');
}
$year = $yr + 1;
$i = 1;
while ($i <= 3){
echo "<option value='$year'";
if ($year == $yr){
echo " selected='selected'";
}
echo ">$year</option>";
$year = $year - 1;
$i = $i + 1;
}
?>
</select>
</form>
<?php
if (isset($_GET['month']) and isset($_GET['year'])){
$month = $_GET['month'];
$year = $_GET['year'];
$txtMonth = date("F",mktime(0,0,0,$month,10));
}else{
$month = date('m');
$year = date('Y');
$txtMonth = date('F');
}
echo "<h3 id=\"events-h3\">Events for $txtMonth $year</h3>";
$level = $user->getUserRoleId($_SESSION['username']);
if ($level <= 2){
echo '<p><a href="/utils/addEvent.php">Add a new event</a></p>';
}
function drawEvent($ev){
$event = new events();
$user = new users;
echo "<div class=\"event";
echo "\">";
echo "<h4 class=\"event-h4\" id='h4-event" . $ev['eventid'] . "'><a href='/event.php?id=" . $ev['eventid'] . "'>" . date("F j, Y", strtotime($ev['date'])) . "</a></h4>";
$state = $event->getEventStatus($ev['status']);
echo "Event Status: " . ucfirst($state['status']) . "<br/>";
if ($ev['status'] != 2){
if ($ev['leader'] == Null){
echo 'There is no leader assigned yet for this event.<br/>';
}else{
$leader = $user->getUserNiceName($ev['leader']);
echo $leader['first_name'] . " " . $leader['last_name'] . " is leading this event.<br/>";
}
$status = $event->chkUserEventStatus($ev['eventid'],$_SESSION['username']);
echo '<div id="divstat' . $ev['eventid'] . '">';
if ($status == Null){
echo "You are not yet signed up for this date.<br/></div>";
echo "<button type='button' class=\"btn btn-primary btnEventConfirm\" id=\"btnConfirm" . $ev['eventid'] . "\" value=\"" . $ev['eventid'] . "\">Sign up</button>";
}else{
echo "Your status for this event: " . ucfirst($status['status']) . "</div>" ;
echo "<a href=\"./event.php?id=" . $ev['eventid'] . "\"><button type='button' class=\"btn btn-success btnDetails\" id=\"btnDetail" . $ev['eventid'] . "\" value=\"" . $ev['eventid'] . "\">Details</button>";
}
}
echo "</div>";
}
function date_compare($a, $b)
{
$t1 = strtotime($a['date']);
$t2 = strtotime($b['date']);
return $t1 - $t2;
}
$curEvents = $event->getEventsForMonth($month,$year);
usort($curEvents,'date_compare');
if ($curEvents == Null){
echo "There are no events scheduled yet for this month.";
}else{
foreach ($curEvents as $ev){
drawEvent($ev);
}
}
?>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#selEvYear').change(function(){
$('form#selMonth').submit();
});
$('#selEvMonth').change(function(){
$('form#selMonth').submit();
});
});
</script>
<?php require_once('./includes/footer.php'); ?>