-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvolunteer_position.php
166 lines (135 loc) · 4.59 KB
/
volunteer_position.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
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@lightbox.org>
Copyright (C) 2007 David Grant <dave@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require_once("common.inc.php");
require_once("user.inc.php");
require_once("volunteer.inc.php");
if($_SESSION['embed'] == true) {
$u = user_load($_SESSION['embed_edit_id']);
} else {
user_auth_required('volunteer');
$u = user_load($_SESSION['users_id']);
}
if($_POST['action']=="save")
{
$vals = '';
if(is_array($_POST['posn'])) {
/* Load available IDs */
$posns = array();
$q = "SELECT * FROM volunteer_positions WHERE year='{$config['FAIRYEAR']}'";
$r = mysql_query($q);
while($p = mysql_fetch_object($r)) {
$posns[] = $p->id;
}
/* Match selections with avaiulable positions */
foreach($_POST['posn'] as $id=>$val) {
if(!in_array($id, $posns)) continue;
if($vals != '') $vals .=',';
$vals .= "('{$u['id']}','$id','{$config['FAIRYEAR']}')";
}
}
/* Delete existing selections */
mysql_query("DELETE FROM volunteer_positions_signup
WHERE
users_id='{$u['id']}'
AND year='{$config['FAIRYEAR']}' ");
echo mysql_error();
/* Add new selections if there are any */
if($vals != '') {
$q = "INSERT INTO volunteer_positions_signup (users_id, volunteer_positions_id,year)
VALUES $vals";
$r=mysql_query($q);
echo mysql_error();
}
message_push(notice(i18n("Volunteer Positions successfully updated")));
}
/* update overall status */
volunteer_status_update($u);
if($_SESSION['embed'] != true) {
//output the current status
$newstatus=volunteer_status_position($u);
if($newstatus!='complete')
message_push(error(i18n("Volunteer Position Selection Incomplete")));
else
message_push(happy(i18n("Volunteer Position Selection Complete")));
}
if($_SESSION['embed'] == true) {
echo "<br />";
display_messages();
echo "<h3>".i18n('Volutneer Positions')."</h3>";
echo "<br />";
} else {
//send the header
send_header("Volunteer Positions",
array("Volunteer Registration" => "volunteer_main.php")
);
}
$s = ($_SESSION['embed'] == true) ? $_SESSION['embed_submit_url'] : 'volunteer_position.php';
echo "<form name=\"personalform\" method=\"post\" action=\"$s\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"save\" />\n";
echo "<table>\n";
/* Read current selections */
$q = "SELECT * FROM volunteer_positions_signup WHERE
users_id = '{$u['id']}'
AND year='{$config['FAIRYEAR']}'";
$r = mysql_query($q);
$checked_positions = array();
while($p = mysql_fetch_object($r)) {
$checked_positions[] = $p->volunteer_positions_id;
}
/* Load available volunteer positions */
$q = "SELECT *,UNIX_TIMESTAMP(start) as ustart, UNIX_TIMESTAMP(end) as uend
FROM volunteer_positions WHERE year='{$config['FAIRYEAR']}'";
$r = mysql_query($q);
while($p = mysql_fetch_object($r)) {
echo '<tr><td>';
$checked = false;
if($_SESSION['lang'] == 'en') {
$sday = strftime("%a. %B %e, %Y", $p->ustart);
$stime = strftime("%H:%M", $p->ustart);
$eday = strftime("%a. %B %e, %Y", $p->uend);
$etime = strftime("%H:%M", $p->uend);
if($sday == $eday) {
$start = $stime;
$end = "$etime, $sday";
} else {
$start = "$sday, $stime";
$end = "$eday, $etime";
}
} else {
$start = $p->start;
$end = $p->end;
}
$ch = in_array($p->id, $checked_positions) ? 'checked="checked"' : '';
echo "<input $ch type=\"checkbox\" name=\"posn[$p->id]\" value=\"checked\" />";
echo '</td><td>';
echo '<b>'.i18n($p->name).'</b></td>' ;
echo "<td align=\"right\">($start - $end)</td></tr>";
echo '<tr><td></td><td colspan="2"><div style="font-size: 0.75em;">';
echo i18n($p->desc);
echo '<br /><br /></div></td></tr>';
}
echo "</table>";
echo "<input type=\"submit\" value=\"".i18n("Save Position Selection")."\" />\n";
echo "</form>";
echo "<br />";
if($_SESSION['embed'] != true) send_footer();
?>