-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwinners.php
More file actions
296 lines (267 loc) · 8.24 KB
/
winners.php
File metadata and controls
296 lines (267 loc) · 8.24 KB
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
<?
/*
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>
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("common.inc.php");
require("projects.inc.php");
send_header("Winners");
if($_GET['edit']) $edit=$_GET['edit'];
if($_POST['edit']) $edit=$_POST['edit'];
if($_GET['action']) $action=$_GET['action'];
if($_POST['action']) $action=$_POST['action'];
if($_GET['year'] && $_GET['type'])
{
$show_unawarded_awards="no";
$show_unawarded_prizes="no";
echo "<h2>".i18n("%1 %2 Award Winners",array($_GET['year'],$_GET['type']))."</h2>";
$year=$_GET['year'];
$ok=true;
//first, lets make sure someone isnt tryint to see something that they arent allowed to!
//but only if the year they want is the FAIRYEAR. If they want a past year, thats cool
if($_GET['year']>=$config['FAIRYEAR']) {
$q=mysql_query("SELECT (NOW()>'".$config['dates']['postwinners']."') AS test");
$r=mysql_fetch_object($q);
if($r->test!=1)
{
echo error(i18n("Crystal ball says future is very hard to see!"));
$ok=false;
}
}
if($ok)
{
$q=mysql_query("SELECT
award_awards.id,
award_awards.name,
award_awards.order AS awards_order,
award_types.type
FROM
award_awards,
award_types
WHERE
award_awards.year='$year'
AND award_awards.award_types_id=award_types.id
AND award_types.type='".$_GET['type']."'
AND award_types.year='$year'
ORDER BY
awards_order");
echo mysql_error();
if(mysql_num_rows($q))
{
echo "<a href=\"winners.php\">".i18n("Back to Winners main page")."</a>";
echo "<br />";
while($r=mysql_fetch_object($q))
{
$pq=mysql_query("SELECT
award_prizes.prize,
award_prizes.number,
award_prizes.id,
award_prizes.cash,
award_prizes.scholarship,
winners.projects_id,
projects.projectnumber,
projects.title,
projects.registrations_id AS reg_id
FROM
award_prizes
LEFT JOIN winners ON winners.awards_prizes_id=award_prizes.id
LEFT JOIN projects ON projects.id=winners.projects_id
WHERE
award_awards_id='$r->id'
AND award_prizes.year='$year'
ORDER BY
`order`");
echo mysql_error();
$awarded_count = 0;
if($show_unawarded_awards=="no")
{
while($pr=mysql_fetch_object($pq))
{
if($pr->projectnumber)
{
$awarded_count++;
}
}
mysql_data_seek($pq, 0);
}
if($show_unawarded_awards=="yes" || $awarded_count > 0)
{
echo "<h3>".i18n($r->name)."</h3> \n";
}
$prevprizeid=-1;
while($pr=mysql_fetch_object($pq))
{
if(!($pr->projectnumber) && $show_unawarded_prizes=="no")
{
continue;
}
if($prevprizeid!=$pr->id)
{
echo " ";
echo " ";
echo "<b>";
echo i18n($pr->prize);
if(($pr->cash || $pr->scholarship) && $config['winners_show_prize_amounts'] == 'yes')
{
echo " (";
if($pr->cash && $pr->scholarship)
echo i18n("\$%1 cash / \$%2 scholarship",array($pr->cash,$pr->scholarship),array("Cash dollar value","Scholarship dollar value"));
else if($pr->cash)
echo i18n("\$%1 cash",array($pr->cash),array("Cash dollar value"));
else if($pr->scholarship)
echo i18n("\$%1 scholarship",array($pr->scholarship),array("Scholarship dollar value"));
echo ")";
}
echo "</b>";
echo "<br />";
$prevprizeid=$pr->id;
}
if($pr->projectnumber)
{
echo "  ";
echo "($pr->projectnumber) $pr->title";
$sq=mysql_query("SELECT students.firstname,
students.lastname,
students.schools_id,
students.webfirst,
students.weblast,
students.webphoto,
schools.school
FROM
students,
schools
WHERE
students.registrations_id='$pr->reg_id'
AND students.schools_id=schools.id
");
$studnum=0;
$students="";
$schools=array();
while($studentinfo=mysql_fetch_object($sq))
{
if($studnum>0 && $prev) $students.=", ";
if($studentinfo->webfirst=="yes")
$students.="$studentinfo->firstname ";
if($studentinfo->weblast=="yes")
$students.="$studentinfo->lastname ";
if($r->studentinfo->webfirst=="yes" || $studentinfo->weblast=="yes")
$prev=true;
else
$prev=false;
// $students.="$studentinfo->firstname $studentinfo->lastname";
$studnum++;
//we will assume that they are coming from the same school, so lets just grab the last students school
//and use it.
if(!in_array($studentinfo->school,$schools))
$schools[]=$studentinfo->school;
// $school=$studentinfo->school;
}
echo "<br />";
echo "  ";
echo "  ";
if($studnum > 1)
echo i18n("Students").": $students";
else
echo i18n("Student").": $students";
echo "<br />";
echo "  ";
echo "  ";
echo i18n("School").": ";
$schoollist="";
foreach($schools AS $school) $schoollist.=$school.", ";
$schoollist=substr($schoollist,0,-2);
echo $schoollist;
echo "<br />";
}
else
{
echo "  ";
echo i18n("Prize not awarded");
echo "<br />";
}
echo "<br />";
}
}
}
}
}
else
{
$q=mysql_query("SELECT
DISTINCT(winners.year) AS year,
dates.date
FROM
winners,
dates
WHERE
winners.year=dates.year
AND dates.name='postwinners'
AND dates.date<=NOW()
ORDER BY
year DESC");
$first=true;
if(mysql_num_rows($q))
{
while($r=mysql_fetch_object($q))
{
if($first && $r->year != $config['FAIRYEAR'])
{
list($d,$t)=split(" ",$config['dates']['postwinners']);
echo "<h2>".i18n("%1 Winners",array($config['FAIRYEAR']))."</h2>";
echo i18n("Winners of the %1 %2 will be posted here on %3 at %4",array($config['FAIRYEAR'],$config['fairname'],format_date($d),format_time($t)));
echo "<br />\n";
echo "<br />\n";
$first=false;
}
//get the "winnersposted" date for the year, and make
echo "<h2>".i18n("%1 Winners",array($r->year))."</h2>";
//do this each time, because each year the names of the award types could change, along with what is actually given out.
//
$tq=mysql_query("SELECT
DISTINCT(award_types.type) AS type
FROM
winners,
award_types,
award_awards,
award_prizes
WHERE
award_awards.award_types_id=award_types.id
AND winners.awards_prizes_id=award_prizes.id
AND award_prizes.award_awards_id=award_awards.id
AND winners.year='$r->year'
ORDER BY
award_types.order
");
echo mysql_error();
while($tr=mysql_fetch_object($tq))
{
echo " <a href=\"winners.php?year=$r->year&type=$tr->type\">".i18n("%1 %2 award winners",array($r->year,$tr->type))."</a><br />";
}
echo "<br />";
$first=false;
}
}
else
{
list($d,$t)=split(" ",$config['dates']['postwinners']);
echo "<h2>".i18n("%1 Winners",array($config['FAIRYEAR']))."</h2>";
echo i18n("Winners of the %1 %2 will be posted here on %3 at %4",array($config['FAIRYEAR'],$config['fairname'],format_date($d),format_time($t)));
}
}
send_footer();
?>