-
Notifications
You must be signed in to change notification settings - Fork 11
/
seriesreport.php
95 lines (81 loc) · 2.57 KB
/
seriesreport.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
<?php
session_start();
include 'lib.php';
print_header("Season Report");
?>
<div class="grid_10 prefix_1 suffix_1">
<div id="gatherling_main" class="box">
<div class="uppertitle"> Season Report </div>
<?php
selectSeason();
if (isset($_GET['series']) && isset($_GET['season'])) {
$series = new Series($_GET['series']);
showReport($series, $_GET['season']);
}
?>
</div>
</div>
<?php print_footer(); ?>
<?php
function selectSeason() {
echo "<form action=\"seriesreport.php\" method=\"get\">";
echo "<table class=\"form\" style=\"border-width: 0px\" align=\"center\">";
echo "<tr><th>Series</th><td>";
Series::dropMenu($_GET['series'], 1);
echo "</td></tr>";
echo "<tr><th>Season</th><td>";
seasonDropMenu($_GET['season'], 1);
echo "</td></tr>";
echo "<tr><td> </td></tr>";
echo "<tr><td colspan=\"2\" class=\"buttons\">";
echo "<input type=\"submit\" value=\"Get Season Scoreboard\" />\n";
echo "</td></tr></table></form>";
}
function reverse_total_sort($a, $b) {
if ($a['.total'] == $b['.total']) {
return 0;
}
return ($a['.total'] < $b['.total']) ? 1 : -1;
}
function showReport($series, $season) {
$seasonevents = $series->getSeasonEventNames($season);
$points = $series->seasonPointsTable($season);
$cutoff = $series->getSeasonCutoff($season);
uasort($points, 'reverse_total_sort');
echo "<h3><center>Scoreboard for {$series->name} season {$season}</center></h3>";
echo "<table class=\"scoreboard\">";
echo "<tr class=\"top\"> <th> Place </th> <th> Player </th> <th> Total </th>";
foreach ($seasonevents as $evname) {
$shortname = preg_replace("/^{$series->name} /", '', $evname);
$reportlink = "eventreport.php?event=" . urlencode($evname);
echo "<th> <a href=\"{$reportlink}\">{$shortname}</a> </th>";
}
echo "</tr>";
$count = 0;
foreach ($points as $playername => $pointar) {
$player = new Player($playername);
$count++;
$classes = "";
if ($count % 2 != 0) {
$classes .= "odd";
}
if ($count == $cutoff) {
$classes .= " cutoff";
}
echo "<tr class=\"{$classes}\"> ";
echo "<td> {$count} </td> <td class=\"playername\"> {$player->linkTo()} </td> <td> {$pointar['.total']} </td> ";
foreach ($seasonevents as $evname) {
if (isset($pointar[$evname])) {
if (is_array($pointar[$evname])) {
echo "<td> <span title=\"{$pointar[$evname]['why']}\"> {$pointar[$evname]['points']} </span> </td>";
} else {
echo "<td> {$pointar[$evname]} </td>";
}
} else {
echo "<td> </td> ";
}
}
echo "</tr> ";
}
echo "</table>";
}