-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvolunteer.php
208 lines (172 loc) · 4.61 KB
/
volunteer.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
<html>
<head>
<title>Volunteer Control Panel</title>
</head>
<body>
<h1>WMFO Volunteer Control Panel</h1><br>
<table border="3">
<tr><h2>Display History</h2></tr>
<form action="./volunteer.php" method="post">
<tr>
<td>Semester: </td><td>
<select name="Semester">
<?php
include 'commlib.php';
$conn = mysql_init();
$stmt = $conn->prepare("SELECT ID,TITLE FROM SEMESTER ORDER BY CREATION_TIME DESC");
$stmt->execute();
$stmt->bind_result($id, $title);
while ($stmt->fetch())
{
#printf("<option value='%s'>%s</option>\n", $id, $title);
echo "<option value='$id'";
if ($_POST['Semester'] == $id)
echo " selected";
echo ">$title</option>\n";
}
$stmt->close();
?>
</select></td></tr>
<tr><td>DJ: </td><td>
<select name="DJ">
<?php
$stmt = $conn->prepare("SELECT ID,L_NAME,F_NAME FROM DJ ORDER BY L_NAME ASC");
$stmt->execute();
$stmt->bind_result($id, $lname, $fname);
while ($stmt->fetch())
{
#printf("<option value='%s'>%s, %s</option>\n", $id, $lname, $fname);
echo "<option value='$id'";
if ($_POST['DJ'] == $id)
echo " selected";
echo ">$lname, $fname</option>\n";
}
$stmt->close();
?>
</select></td></tr><tr><td>
<input type="submit" value="Display Records">
</form></td></tr></table>
<h2>Add Hours</h2>
<form action="./volunteer.php" method="post">
<table border="3"><tr><td>
Semester: </td><td>
<select name="Semester">
<?php
$stmt = $conn->prepare("SELECT ID,TITLE FROM SEMESTER ORDER BY CREATION_TIME DESC");
$stmt->execute();
$stmt->bind_result($id, $title);
while ($stmt->fetch())
{
printf("<option value='%s'>%s</option>\n", $id, $title);
}
$stmt->close();
?>
</select></td></tr><tr><td>
DJ: </td><td>
<select name="DJ">
<?php
$stmt = $conn->prepare("SELECT ID,L_NAME,F_NAME FROM DJ ORDER BY L_NAME ASC");
$stmt->execute();
$stmt->bind_result($id, $lname, $fname);
while ($stmt->fetch())
{
printf("<option value='%s'>%s, %s</option>\n", $id, $lname, $fname);
}
$stmt->close();
?>
</select></td></tr><tr><td>
Date: </td><td>
<input name="Month" size="2" maxlength="2" placeholder="mm">/<input name="Day" size="2" maxlength="2" placeholder="dd">/<input name="Year" size="4" maxlength="4" placeholder="yyyy"></td></tr><tr><td>
Hours: </td><td>
<input name="Hours" size="5"></td></tr><tr><td>
Type: </td><td>
<input type="radio" name="Sub" value="0"> Volunteer<br>
<input type="radio" name="Sub" value="1"> Sub<br>
</td></tr><tr><td>
Description: </td><td>
<textarea name="Description" rows="3" cols="80" placeholder="Description..."></textarea></td></tr><tr><td>
<input type="submit" value="Add Volunteer Event">
</td></tr></table>
</form>
<hr>
<?php
if (
isset($_REQUEST['DJ']) &&
isset($_REQUEST['Semester']) )
{
$stmt = $conn->prepare("SELECT F_NAME,L_NAME,TITLE FROM DJ,SEMESTER WHERE DJ.ID=? AND SEMESTER.ID=?");
$stmt->bind_param("ii", $_REQUEST['DJ'], $_REQUEST['Semester']);
$stmt->execute();
$stmt->bind_result($first, $last, $semester);
$stmt->fetch();
printf("<h1>Volunteer Record for %s %s in %s</h1>", $first, $last, $semester);
$stmt->close();
}
?>
<?php
if (
isset($_POST['Semester']) &&
isset($_POST['DJ']) &&
isset($_POST['Day']) &&
isset($_POST['Month']) &&
isset($_POST['Year']) &&
isset($_POST['Hours']) &&
isset($_POST['Description']) &&
isset($_POST['Sub']) &&
is_numeric($_POST['Day']) &&
is_numeric($_POST['Month']) &&
is_numeric($_POST['Year']) &&
is_numeric($_POST['Hours']) )
{
add_volunteer($conn, $_POST['DJ'], $_POST['Semester'],
$_POST['Day'], $_POST['Month'], $_POST['Year'],
$_POST['Hours'], $_POST['Description'], $_POST['Sub']);
}
?>
<?php
if (isset($_REQUEST['delete']))
{
$stmt = $conn->prepare("DELETE FROM VOLUNTEER WHERE ID=?");
$stmt->bind_param("i", $_REQUEST['delete']);
$stmt->execute();
$stmt->close();
}
?>
<table border="3">
<tr>
<th>Month</th>
<th>Day</th>
<th>Year</th>
<th>Hours</th>
<th>Type</th>
<th>Description</th>
<th>Delete</th>
</tr>
<?php
if (
isset($_REQUEST['DJ']) &&
isset($_REQUEST['Semester']) )
{
$stmt = $conn->prepare("SELECT DDAY,DMONTH,DYEAR,NUM_HOURS,DESCRIPTION,SUB_BOOL,ID FROM VOLUNTEER WHERE DJ_ID=? AND SEMESTER_ID=? ORDER BY DYEAR DESC, DMONTH DESC, DDAY DESC");
$stmt->bind_param("ii", $_REQUEST['DJ'], $_REQUEST['Semester']);
$stmt->execute();
$stmt->bind_result($month, $day, $year, $hours, $desc, $sub_bool, $id);
while ($stmt->fetch())
{
if ($sub_bool == 0)
{
$type = "VOL";
}
else
{
$type = "SUB";
}
printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td><a href='./volunteer?delete=%s&DJ=%s&Semester=%s'>X</a></td></tr>",
$day, $month, $year, $hours, $type, $desc, $id, $_REQUEST['DJ'], $_REQUEST['Semester']
);
}
}
?>
</table>
<?php footer(); ?>
</body></html>