This repository has been archived by the owner on Mar 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clubmember.php
338 lines (241 loc) · 13.1 KB
/
clubmember.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
<!DOCTYPE html>
<html lang="en">
<?php
include "Stylesheet_PHP_Files/loginSys.php";
if(!(isset($_SESSION['loggedIn']))) {
header("Location: login.php");
}
?>
<head>
<!-- metadata allows search engines to efficiently index the content -->
<meta charset="UTF-8">
<meta name="description" content="about Ormiston Athletics Club">
<meta name="keywords" content="Ormiston Athletics Club, athletics, club">
<meta name="author" content="Lia">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- linking to css stylesheet -->
<link rel="stylesheet" type="text/css" href="Stylesheet_PHP_Files/style.css">
<!-- Varela Round font --->
<link href="https://fonts.googleapis.com/css?family=Varela+Round&display=swap" rel="stylesheet">
<!-- Linking to Fontawesome's icon library -->
<script src="https://kit.fontawesome.com/26c8b54824.js"></script>
<title>Ormiston Athletics Club</title>
</head>
<body>
<header>
<div id="logo"><a href="index.php"><img src="Images/editedImages/Logo.png" alt="Ormiston Athletics Club Logo" class="logoImage"></a></div>
<a href="index.php">Home</a>
<a href="contact.php">Contact</a>
<?php
include "Stylesheet_PHP_Files/loginSys.php";
if(!(isset($_SESSION['loggedIn']))) {
echo '<a href="login.php">Login</a>';
}
else {
echo '<div class="dropdownLogin">
<a href="login.php" class="active">'.$_SESSION['adminName'].'<i class="fas fa-chevron-down"></i></a> <!-- fas fa-chevron down is an arrow pointing down -->
<div class="dropdownContent">
<a href="members.php">Members</a>
<a href="fees.php">Fees</a>
<a href="events.php">Events</a>
<form method="post">
<button name="logout" type="submit">Logout</button>
</form>
</div> <!-- end of dropdownContent div -->
</div> <!-- end of dropdownLogin div-- >';
}
?>
<!-- end of navLinks div -->
</header>
<button id="backButton" onclick="location.href='members.php'"> <<< Back to members page... </button>
<div class="adminContent" id="memberPage">
<?php
$ID = $_POST['submitID'];
$sql = "SELECT members.*, SUM(memberevents.points) as points
FROM members
JOIN memberevents ON memberevents.memberID = members.ID
WHERE members.ID = '$ID'";
$query = mysqli_query($conn, $sql);
$member = mysqli_fetch_array($query);
$firstName = $member['firstName'];
$lastName = $member['lastName'];
$grade = $member['grade'];
$phone = $member['telephone'];
$annualFee = $member['annualFee'];
$address = $member['streetAddress'];
$birthday = $member['dateOfBirth'];
$mother = $member['motherInitial'];
$father = $member['fatherInitial'];
$parents = $father." and ".$mother." ".$lastName;
$totalPoints = $member['points'];
$amountPaid = $member['amountPaid'];
$overdue = $annualFee - $amountPaid;
$lastPaid = $member['datePaid'];
$suburbID = $member['suburbID'];
$suburbSQL = "SELECT * FROM suburb WHERE suburb.ID = '$suburbID'";
$suburbQuery = mysqli_query($conn, $suburbSQL);
$suburbFetch = mysqli_fetch_array($suburbQuery);
$suburb = $suburbFetch['name'];
?>
<div id="memberDetails">
<div id="memberInfo">
<h1><?php echo $firstName." ".$lastName; ?> </h1><button type="button" onclick="show('editDetails')" >Edit Details</button>
<br><br>
<p><label>Grade:</label> <?php echo $grade;?></p>
<p><label>Telephone:</label> <?php echo $phone;?></p>
<p><label>Annual Fee:</label> $<?php echo number_format($annualFee, 2);?></p>
<br>
<p><label>Address:</label> <?php echo $address;?></p>
<p><label>Suburb:</label> <?php echo $suburb;?></p>
<p><label>Date Of Birth:</label> <?php echo $birthday;?></p>
<p><label>Legal Guardian/s:</label> <?php echo $parents;?></p>
</div> <!-- end of memberInfo -->
<div id="memberTotal">
<div class="memberTotalBlock" id="memberPoints">
<h3>Total Points</h3>
<p><?php echo $totalPoints?></p>
</div> <!-- end of memberTotalBlock -->
<div class="memberTotalBlock" id="memberOutstandingFees">
<h3>Outstanding Fees</h3>
<?php
if($overdue < $annualFee){
echo "<p>$".number_format($overdue,2)."</p>";
echo "Last Paid: ".$lastPaid;
}
else{
echo "<p id='overdue'>$".number_format($overdue,2)."</p>";
}
?>
</div> <!-- end of memberTotalBlock -->
</div> <!-- end of memberTotal -->
</div> <!-- end of memberDetails div -->
</div> <!-- end of adminContent, memberPage div -->
<div class="adminContent" id="editDetails">
<h2>Edit Member Details</h2>
<form action="Stylesheet_PHP_Files/editingMember.php" method="post">
<input type="hidden" value="<?php echo $ID; ?>" name="ID">
<!-- this is to post the member ID in order to edit their details -->
<div id="editFlex">
<div id="formLabels">
<label>First Name:</label>
<br>
<label>Last Name: </label>
<br>
<label>Grade: </label>
<br>
<label>Telephone</label>
<br>
<label>Annual Fee: </label>
<br>
<label>Address:</label>
<br>
<label>Suburb:</label>
<br>
<label>Date of Birth:</label>
<br>
<label>Parents' First Initial:</label>
</div><!-- end of formLabels -->
<div id="formInput">
<input type="text" value="<?php echo $firstName; ?>" name="newFirstName">
<br>
<input type="text" value="<?php echo $lastName;?>" name="newLastName">
<br>
<select name="newGrade">
<option value="<?php echo $grade;?>"><?php echo $grade;?></option>
<option value="Junior">Junior</option>
<option value="Intermediate">Intermediate</option>
<option value="Senior">Senior</option>
</select>
<br>
<input type="text" value="<?php echo $phone;?>" name="newPhone">
<br>
$<input type="number" value="<?php echo $annualFee;?>" name ="newAnnualFee">
<br>
<input type="text" value="<?php echo $address; ?>" name="newAddress">
<br>
<select name="newSuburb">
<option value="<?php echo $suburbID;?>"><?php echo $suburb;?></option>
<?php
$suburbsSQL = "SELECT * FROM suburb";
$suburbsQuery = mysqli_query($conn, $suburbsSQL);
while ($suburbs = mysqli_fetch_array($suburbsQuery)){
echo "<option value='".$suburbs['ID']."'>".$suburbs['name']."</option>";
}
?>
</select>
<br>
<input type="date" value="<?php echo $birthday; ?>" name="newBirthday">
<br>
<input type="text" name="newFather" value="<?php echo $father;?>" id="formInitials">
and
<input type="text" name="newMother" value="<?php echo $mother;?>" id="formInitials">
</div><!-- end of formInput -->
</div> <!-- end of editFlex -->
<br>
<button type="submit" name="edit">Update Details</button>
</form>
</div><!-- end of editDetails div -->
<div class="adminContent" id="memberEvents">
<h2>Events Attended</h2>
<button onclick="show('editMemberEvent')">Edit Event</button>
<br>
<br>
<table>
<tr>
<th>Event Date</th>
<th>Points</th>
</tr>
<?php
$eventsSQL = "SELECT memberevents.*, events.* FROM memberevents INNER JOIN events ON memberevents.eventID = events.ID WHERE memberevents.memberID = '$ID'";
$eventsQuery = mysqli_query($conn, $eventsSQL);
while($events = mysqli_fetch_array($eventsQuery)){
echo "<tr>";
echo "<td>".$events['eventDate']."</td>";
echo "<td>".$events['points']."</td>";
echo "</tr>";
}
?>
</table>
</div><!-- end of adminContent, memberEvents div -->
<div class="adminContent" id="editMemberEvent">
<h2>Edit Event</h2>
<form method="post" id="editEventForm" action="Stylesheet_PHP_Files/editingMember.php">
<label>Choose Event: </label>
<select name="eventDate">
<?php
$eventsSQL = "SELECT memberevents.*, events.* FROM memberevents INNER JOIN events ON memberevents.eventID = events.ID WHERE memberevents.memberID = '$ID'";
$eventsQuery = mysqli_query($conn, $eventsSQL);
while($events = mysqli_fetch_array($eventsQuery)){
echo "<option value='".$events['eventID']."'>".$events['eventDate']."</option>";
$memberID = $events['memberID'];
}
?>
</select>
<br><br>
<input type="hidden" name="memberID" value="<?php echo $memberID;?>">
<label>Points: </label>
<input type="number" name="newPoints">
<br>
<br>
<button type="submit" name="updateEvent">Update Event</button>
</form> <!-- end of submitDate form -->
</div><!--end of editMemberEvent -->
<footer>
<img src="Images/editedImages/Logo.png" alt="Ormiston Athletics Club logo" class="footerLogo">
<p>Copyright 2019
<br> Created my free logo @ <a href="https://logomakr.com/" target="_blank">logomakr.com</a></p>
</footer>
</body>
<script>
function show(active) {
// this function opens the separate edit containers for both editing member details and editing member events.
var active = document.getElementById(active);
if(active.style.display === "block") {
active.style.display = "none";
}
else{
active.style.display = "block";
}
}
</script>
</html>