-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·257 lines (236 loc) · 17.4 KB
/
index.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
<?php
/*
* Copyright 2015 by Jerrick Hoang, Ivy Xing, Sam Roberts, James Cook,
* Johnny Coster, Judy Yang, Jackson Moniaga, Oliver Radwan,
* Maxwell Palmer, Nolan McNair, Taylor Talmage, and Allen Tucker.
* This program is part of RMH Homebase, which is free software. It comes with
* absolutely no warranty. You can redistribute and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation
* (see <http://www.gnu.org/licenses/ for more information).
*
*/
session_start();
session_cache_expire(30);
?>
<!-- page generated by the BowdoinRMH software package -->
<html>
<head>
<title>
RMH Homebase
</title>
<link rel="stylesheet" href="styles.css" type="text/css" />
<style>
#appLink:visited {
color: gray;
}
</style>
</head>
<body>
<div id="container">
<?PHP include('header.php'); ?>
<div id="content">
<?PHP
include_once('database/dbPersons.php');
include_once('domain/Person.php');
include_once('database/dbLog.php');
include_once('domain/Shift.php');
include_once('database/dbShifts.php');
if ($_SESSION['_id'] != "guest") {
$person = retrieve_person($_SESSION['_id']);
echo "<p>Welcome, " . $person->get_first_name() . ", to Homebase!";
}
else
echo "<p>Welcome to Homebase!";
$today = time();
echo " Today is " . date('l F j, Y', $today) . ".<p>";
?>
<!-- your main page data goes here. This is the place to enter content -->
<p>
<?PHP
if ($_SESSION['access_level'] == 1)
echo('<p>
This is your personal homepage:
your upcoming scheduled shifts will always be posted here.
');
if ($_SESSION['access_level'] == 0)
echo('<p> To apply for a volunteer position at the Ronald McDonald House, select <a href="' . $path . 'personEdit.php?id=' . 'new' . '">apply</a>.');
?>
<br>If you just want an overview of Homebase, select <a href="<?php echo($path); ?>dataSearch.php">about</a>.
<?PHP
if ($person)
echo ('<p>If you want to learn the details of using Homebase, select <a href="' . $path . 'help.php">help</a>.');
?>
</ul>
<p> When you are finished, please remember to <a href="<?php echo($path); ?>logout.php">logout</a>.</li>
<?PHP
if ($person) {
/*
* Check type of person, and display home page based on that.
* all: password check
* guests: show link to application form
* applicants: show status of application form
* Volunteers, subs: show upcoming schedule
* Managers: show vacancies, birthdays, anniversaries, applicants
*/
//DEFAULT PASSWORD CHECK
if (md5($person->get_id()) == $person->get_password()) {
if (!isset($_POST['_rp_submitted']))
echo('<div class="warning"><form method="post"><p><strong>We recommend that you change your password, which is currently default.</strong><table class="warningTable"><tr><td class="warningTable">Old Password:</td><td class="warningTable"><input type="password" name="_rp_old"></td></tr><tr><td class="warningTable">New password</td><td class="warningTable"><input type="password" name="_rp_newa"></td></tr><tr><td class="warningTable">New password<br />(confirm)</td><td class="warningTable"><input type="password" name="_rp_newb"></td></tr><tr><td colspan="2" align="right" class="warningTable"><input type="hidden" name="_rp_submitted" value="1"><input type="submit" value="Change Password"></td></tr></table></p></form></div>');
else {
//they've submitted
if (($_POST['_rp_newa'] != $_POST['_rp_newb']) || (!$_POST['_rp_newa']))
echo('<div class="warning"><form method="post"><p>Error with new password. Ensure passwords match.</p><br /><table class="warningTable"><tr><td class="warningTable">Old Password:</td><td class="warningTable"><input type="password" name="_rp_old"></td></tr><tr><td class="warningTable">New password</td><td class="warningTable"><input type="password" name="_rp_newa"></td></tr><tr><td class="warningTable">New password<br />(confirm)</td><td class="warningTable"><input type="password" name="_rp_newb"></td></tr><tr><td colspan="2" align="center" class="warningTable"><input type="hidden" name="_rp_submitted" value="1"><input type="submit" value="Change Password"></form></td></tr></table></div>');
else if (md5($_POST['_rp_old']) != $person->get_password())
echo('<div class="warning"><form method="post"><p>Error with old password.</p><br /><table class="warningTable"><tr><td class="warningTable">Old Password:</td><td class="warningTable"><input type="password" name="_rp_old"></td></tr><tr><td class="warningTable">New password</td><td class="warningTable"><input type="password" name="_rp_newa"></td></tr><tr><td class="warningTable">New password<br />(confirm)</td><td class="warningTable"><input type="password" name="_rp_newb"></td></tr><tr><td colspan="2" align="center" class="warningTable"><input type="hidden" name="_rp_submitted" value="1"><input type="submit" value="Change Password"></form></td></tr></table></div>');
else if ((md5($_POST['_rp_old']) == $person->get_password()) && ($_POST['_rp_newa'] == $_POST['_rp_newb'])) {
$newPass = md5($_POST['_rp_newa']);
change_password($person->get_id(), $newPass);
}
}
echo('<br clear="all">');
}
//NOTES OUTPUT
echo('<div class="infobox"><p class="notes"><strong>Notes from House Manager:</strong><br />');
echo($person->get_notes() . '</p></div><br>');
//APPLICANT CHECK
if ($person->get_first_name() != 'guest' && $person->get_status() == 'applicant') {
//SHOW STATUS
echo('<div class="infobox"><p><strong>Your application has been filed.</strong><br><br /><table><tr><td><strong>Step</strong></td><td><strong>Completed?</strong></td></tr><tr><td>Background Check</td><td>' . $person['background_check'] . '</td></tr><tr><td>Interview</td><td>' . $person['interview'] . '</td></tr><tr><td>Shadow</td><td>' . $person['shadow'] . '</td></tr></table></p></div>');
}
//VOLUNTEER CHECK
if ($_SESSION['access_level'] == 1) {
//we need to populate their schedule.
$shifts = selectScheduled_dbShifts($person->get_id());
$scheduled_shifts = array();
foreach ($shifts as $shift) {
$shift_month = get_shift_month($shift);
$shift_day = get_shift_day($shift);
$shift_year = get_shift_year($shift);
$shift_time_s = get_shift_start($shift);
$shift_time_e = get_shift_end($shift);
$cur_month = date("m");
$cur_day = date("d");
$cur_year = date("y");
if ($shift_year > $cur_year)
$upcoming_shifts[] = $shift;
else if ($shift_year == $cur_year) {
if ($cur_month < $shift_month)
$upcoming_shifts[] = $shift;
else if ($shift_month == $cur_month) {
if ($cur_day <= $shift_day) {
$upcoming_shifts[] = $shift;
}
}
}
}
if ($upcoming_shifts) {
echo('<div class="scheduleBox"><p><strong>Your Upcoming Schedule:</strong><br /></p><ul>');
foreach ($upcoming_shifts as $tableId) {
echo('<li type="circle">' . get_shift_name_from_id($tableId)) . '</li>';
}
echo('</ul><p>If you need to cancel an upcoming shift, please contact House Manager (207-980-6282 or <a href="mailto:[email protected]>">[email protected]</a>).</p></div>');
}
}
if ($_SESSION['access_level'] == 2) {
//We have a manager authenticated
//log box
echo('<div class="logBox"><p><strong>Recent Schedule Changes:</strong><br />');
echo('<table class="searchResults">');
echo('<tr><td class="searchResults"><u>Time</u></td><td class="searchResults"><u>Message</u></td></tr>');
$log = get_last_log_entries(5);
for ($i = 4; $i >= 0; --$i) {
echo('<tr><td class="searchResults">' . $log[$i][1] . '</td>' .
'<td class="searchResults">' . $log[$i][2] . '</td></tr>');
}
echo ('</table><br><a href="' . $path . 'log.php">View full log</a></p></div><br>');
//beginning of vacancy box
//For checking time
$today = mktime(0, 0, 0, date('m'), date('d'), date('y'));
$two_weeks = $today + 14 * 86400;
connect();
$vacancy_query = "SELECT id,vacancies FROM dbShifts " .
"WHERE vacancies > 0 ORDER BY id;";
$vacancy_list = mysql_query($vacancy_query);
if (!$vacancy_list)
echo mysql_error();
//upcoming vacancies
if (mysql_num_rows($vacancy_list) > 0) {
echo('<div class="vacancyBox">');
echo('<p><strong>Upcoming Vacancies:</strong><ul>');
while ($thisRow = mysql_fetch_array($vacancy_list, MYSQL_ASSOC)) {
$shift_date = mktime(0, 0, 0, substr($thisRow['id'], 0, 2), substr($thisRow['id'], 3, 2), substr($thisRow['id'], 6, 2));
if ($shift_date > $today && $shift_date < $two_weeks) {
echo('<li type="circle"><a href="' . $path . 'editShift.php?shift=' . $thisRow['id'] . '">' . get_shift_name_from_id($thisRow['id']) . '</a></li>');
}
}
echo('</ul></p></div><br>');
}
//active applicants
connect();
$app_query = "SELECT first_name,last_name,id,start_date FROM dbPersons WHERE status LIKE '%applicant%' order by start_date desc";
$applicants_tab = mysql_query($app_query);
$numLines = 0;
// if (mysql_num_rows($applicants_tab) > 0) {
echo('<div class="applicantsBox"><p><strong>Open Applications / Dates:</strong><ul>');
while ($thisRow = mysql_fetch_array($applicants_tab, MYSQL_ASSOC)) {
echo('<li type="circle"><a href="' . $path . 'personEdit.php?id=' . $thisRow['id'] .'" id = "appLink">' .
$thisRow['last_name'] . ', ' . $thisRow['first_name'] . '</a> / '.
$thisRow['start_date'] . '</li>');
}
echo('</ul></p></div><br>');
// }
mysql_close();
//volunteer birthdays and anniversary days
connect();
$anniv_query = "SELECT id,first_name,last_name,birthday,start_date FROM dbPersons WHERE status LIKE '%active%'";
$anniversaries = mysql_query($anniv_query);
if (!$anniversaries)
echo mysql_error();
if (mysql_num_rows($anniversaries) > 0) {
echo('<div class="anniversaryBox">');
echo('<p><strong>Upcoming Birthdays and Anniversaries:</strong>');
echo('<table class="searchResults"><tr><td class="searchResults"><u>Name</u></td><td class="searchResults"><u>Birthday</u></td><td class="searchResults"><u>Start Date</u></td></tr>');
while ($thisRow = mysql_fetch_array($anniversaries, MYSQL_ASSOC)) {
if ($thisRow['birthday'] != null && $thisRow['start_date'] != null) {
$birthday_val = mktime(0, 0, 0, (int) substr($thisRow['birthday'], 0, 2), (int) substr($thisRow['birthday'], 3, 2), date('y'));
$startdate_val = mktime(0, 0, 0,(int) substr($thisRow['start_date'], 0, 2), (int) substr($thisRow['start_date'], 3, 2), date('y'));
if (($birthday_val >= $today && $birthday_val <= $two_weeks) || ($startdate_val >= $today && $startdate_val <= $two_weeks))
echo('<tr><td class="searchResults"><a href="personEdit.php?id=' . $thisRow['id'] . '">' . $thisRow['first_name'] . ' ' . $thisRow['last_name'] . '</a></td><td class="searchResults">' . $thisRow['birthday'] . '</td><td class="searchResults">' . $thisRow['start_date'] . '</td></tr>');
}
}
echo('</table></p></div><br>');
}
mysql_close();
// active volunteers who haven't worked recently
$everyone = getall_names("active", "volunteer");
if ($everyone && mysql_num_rows($everyone) > 0) {
//active volunteers who haven't worked for the last two months
$two_months_ago = $today - 60 * 86400;
echo('<div class="inactiveBox">');
echo('<p><strong>Unscheduled active house volunteers who haven\'t worked during the last two months:</strong>');
echo('<table class="searchResults"><tr><td class="searchResults"><u>Name</u></td><td class="searchResults"><u>Date Last Worked</u></td></tr>');
while ($thisRow = mysql_fetch_array($everyone, MYSQL_ASSOC)) {
if (!preg_match("/manager/", $thisRow['type'])) {
$shifts = selectScheduled_dbShifts($thisRow['id']);
$havent_worked = true;
$last_worked = "";
for ($i = 0; $i < count($shifts) && $havent_worked; $i++) {
$date_worked = mktime(0, 0, 0, get_shift_month($shifts[$i]), get_shift_day($shifts[$i]), get_shift_year($shifts[$i]));
$last_worked = substr($shifts[$i], 0, 8);
if ($date_worked > $two_months_ago)
$havent_worked = false;
}
if ($havent_worked)
echo('<tr><td class="searchResults"><a href="personEdit.php?id=' . $thisRow['id'] . '">' . $thisRow['first_name'] . ' ' . $thisRow['last_name'] . '</a></td><td class="searchResults">' . $last_worked . '</td></tr>');
}
}
echo('</table></p></div><br>');
}
}
}
?>
</div>
<?PHP include('footer.inc'); ?>
</div>
</body>
</html>