-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathevents.php
151 lines (144 loc) · 6.39 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
<?php
require "logged_in_check.php";
require "set_session_vars_short.php";
require "database_connect.php";
$month=isset($_POST['dateMonth']) ? $_POST['dateMonth'] : '';
//$month=$_POST['dateMonth'];
if($month=='' || !isset($month)){
$month=date('m');
}
if($month=='01'){$monthName='January';}
if($month=='02'){$monthName='February';}
if($month=='03'){$monthName='March';}
if($month=='04'){$monthName='April';}
if($month=='05'){$monthName='May';}
if($month=='06'){$monthName='June';}
if($month=='07'){$monthName='July';}
if($month=='08'){$monthName='August';}
if($month=='09'){$monthName='September';}
if($month=='10'){$monthName='October';}
if($month=='11'){$monthName='November';}
if($month=='12'){$monthName='December';}
if($month=='all') {
$pageTitle = "All Events";
} else {
$pageTitle = $monthName." Events";
}
?>
<!DOCTYPE html>
<html>
<?php require "partials/head.php"; ?>
<body>
<?php require "partials/header.php"; ?>
<div class="container">
<?php
// CREATE FORM FOR UPDATING USER'S POINTS
//---------------------------------------------------------
echo "<div class=\"row\">
<div class=\"col-12\">";
echo "<h2 class=\"float-left\">Events</h2>";
if($month=='all') {
$query = $db->query("SELECT * FROM Event WHERE isFamilyEvent = '0' ORDER BY dateYear, dateMonth, dateDay, eventName");
$query->setFetchMode(PDO::FETCH_ASSOC);
} else {
$query = $db->prepare("SELECT * FROM Event WHERE isFamilyEvent = '0' AND dateMonth = :month ORDER BY dateYear, dateMonth, dateDay, eventName");
$query->execute(array('month'=>$month));
$query->setFetchMode(PDO::FETCH_ASSOC);
}
?>
<div class="float-right">
<form id="monthSelect" action="/events.php" method="post">
<select name="dateMonth" class="form-control custom-select" onchange="this.form.submit()">
<option value="01" <?PHP if($month=='01') echo "selected";?>>January</option>
<option value="02" <?PHP if($month=='02') echo "selected";?>>February</option>
<option value="03" <?PHP if($month=='03') echo "selected";?>>March</option>
<option value="04" <?PHP if($month=='04') echo "selected";?>>April</option>
<option value="05" <?PHP if($month=='05') echo "selected";?>>May</option>
<option value="06" <?PHP if($month=='06') echo "selected";?>>June</option>
<option value="07" <?PHP if($month=='07') echo "selected";?>>July</option>
<option value="08" <?PHP if($month=='08') echo "selected";?>>August</option>
<option value="09" <?PHP if($month=='09') echo "selected";?>>September</option>
<option value="10" <?PHP if($month=='10') echo "selected";?>>October</option>
<option value="11" <?PHP if($month=='11') echo "selected";?>>November</option>
<option value="12" <?PHP if($month=='12') echo "selected";?>>December</option>
<option value="all" <?PHP if($month=='all') echo "selected";?>>All Events</option>
</select>
</form>
</div>
<form id="updatePoints" name="updatePoints" action="/updatePoints.php" method="POST">
<?php
if ($query->rowCount() == 0) {
echo "</div></div><div class=\"row\">
<div class=\"col-12\">";
if($month=='all'){
echo "<p>There are currently no events recorded.</p>";
} else {
echo "<p>There are currently no events recorded for the month of ".$monthName.".</p>";
}
} else {
echo "<table class='table table-hover table-sm mb-3'><thead>
<tr>
<th scope=\"col\"></th>
<th scope=\"col\">Date</th>
<th scope=\"col\">Name</th>
<th scope=\"col\" style=\"text-align:right !important;\">Points</th>
</tr>
</thead>
<tbody>";
$count = 0;
while($row = $query->fetch()) {
// $counter = $counter + 1;
$tempEventID = $row['eventID'];
$attends_query = $db->query("SELECT * FROM AttendsEvent WHERE eventID = $tempEventID AND memberID = $memberID");
$attends_query->setFetchMode(PDO::FETCH_ASSOC);
$num_results3 = $attends_query->rowCount();
echo "<tr id=\"event-" . $row['eventID'] ."\">";
echo "<th scope='row'><input id=\"event".$count."\" class='event-checkbox' type=\"checkbox\" name=\"";
echo $row['eventID'];
echo "\" ";
if($num_results3 == 1) {
echo " CHECKED";
} else { }
echo "></th><label for=\"event".$count."\"></label>";
echo "<td>".$row['dateMonth']."-".$row['dateDay']."</td><td><a href='/event.php?id=". $row['eventID']."'>".$row['eventName'] . "</a>";
if($row['isBonus'] == 1) {
echo " <span class=\"text-muted\">(BONUS)</span>";
} else { }
$typeClass = '';
if ($row['type'] == 'mandatory') {
$typeClass = 'event-type-mandatory';
} else if ($row['type'] == 'sports') {
$typeClass = 'event-type-sports';
} else if ($row['type'] == 'social') {
$typeClass = 'event-type-social';
} else if ($row['type'] == 'work') {
$typeClass = 'event-type-work';
} else {
$typeClass = '';
}
echo " <span class=\"badge badge-primary " . $typeClass ."\">" . $row['type'] ."</span></td>";
echo "</div><td align='right'>".$row['pointValue']."</td></tr>";
$count++;
echo "<input type=\"hidden\" name=\"query_bound\" value=\"recent\">";
}
echo "</tbody></table></div></div>";
echo "<div class=\"row mb-3\">
<div class=\"col-12\">
<div class=\"float-right\">
<input type=\"submit\" class=\"btn btn-primary\" id=\"submit-points-button\" form='updatePoints' value='Update'>
</div>
</div>
</div>";
}
if($month=='all') {
echo "<input type=\"hidden\" name=\"query_bound\" value=\"all\">";
} else {
echo "<input type=\"hidden\" name=\"query_bound\" value=\"".$month."\">";
}
echo "</form>";
?>
</div>
<?php require "partials/footer.php"; ?>
<?php require "partials/scripts.php"; ?>
</body>
</html>