-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathteamlistadvavg.php
130 lines (114 loc) · 4.78 KB
/
teamlistadvavg.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
<?php include_once("inc/header1.php");
// if you need to return header() statements, do them here. SQL connection has already been established.
include_once("inc/header2.php"); ?>
BBDB</title>
<script>
$(document).ready(function()
{
$("#teamTable").tablesorter();
}
);
</script>
<?php // include anything else you want to put in <head> here.
if ((!permission_check(4)) || (!isset($_SESSION['domain_id']))) { // standard read privilages
include_once("inc/no_permission.php");
}
include_once("inc/header3.php");
$domain_id = $_SESSION['domain_id'];
?>
<h2>Averages by team</h2>
<p><strong>Minimum of 10 games required.</strong></p>
<table id="teamTable" class="tablesorter">
<thead>
<tr><th>Team Name</th><th>Race</th><th>Coach</th><th>Value</th><th title="Matches played">Pl</th><th>W</th><th>D</th><th>L</th><th title="Points (win=3, draw=1)">Pts</th><th title="Touchdowns Scored">F</th>
<th title="Touchdowns Conceded">A</th><th title="Passes">Ps</th>
<th title="Interceptions">I</th>
<th title="Knockdowns caused">KDF</th><th title="Knockdowns suffered">KDA</th>
<th title="KO's caused">KOF</th><th title="KO's suffered">KOA</th>
<th title="Casualties caused">CASF</th><th title="Casualties suffered">CASA</th>
<th title="Kills inflicted">KF</th><th title="Kills suffered">KA</th>
<th title="Meters Run">MR</th><th title="Meters Passed">MP</th></tr>
</thead>
<tbody>
<?php
$sql = $conn->prepare("SELECT t.team_id
, t.description AS team_name
, t.race_id
, r.description AS race_name
, t.coach_id
, COALESCE(c.description, '???') AS coach_name
, t.str_logo
, t.motto
, t.background
, t.value
, t.rerolls
, t.fan_factor
, t.cheerleaders
, t.apothecary
, t.balms
, t.cash
, t.assistant_coaches
, t.meters_run
, t.meters_pass
, t.touchdowns
, t.sustained_touchdowns
, t.inflicted_injury
, t.sustained_injury
, t.wins
, t.draws
, t.losses
, t.passes
, t.inflicted_ko
, t.sustained_ko
, t.interceptions
, t.inflicted_dead
, t.sustained_dead
, t.inflicted_knockdown
, t.sustained_knockdown
FROM bb_team t
INNER JOIN bb_lkp_race r ON t.race_id = r.race_id
LEFT JOIN bb_coach c ON t.coach_id = c.coach_id
WHERE EXISTS (SELECT * FROM bb_match m WHERE t.team_id IN (m.home_team_id, m.away_team_id) AND m.domain_id = ?)
AND t.wins + t.draws + t.losses >= 10
ORDER BY t.description ASC");
$sql->execute(array($domain_id));
$match_data = $sql->fetchAll(PDO::FETCH_ASSOC);
foreach ($match_data as $row)
{
$total_played = $row['wins']+$row['draws']+$row['losses'];
$total_pts = ($row['wins']*3)+($row['draws']);
echo "<tr>";
echo '<td><a href="team.php?team_id=' . $row['team_id'] . '">'. $row['team_name'] . '</a></td>'.PHP_EOL;
echo '<td><a href="race.php?race_id=' . $row['race_id'] . '">'. $row['race_name'] . '</a></td>'.PHP_EOL;
if ($row['coach_name']=="???")
{ echo '<td>???</td>'.PHP_EOL; }
else
{ echo '<td><a href="coach.php?coach_id=' . $row['coach_id'] . '">'. $row['coach_name'] . '</a></td>'.PHP_EOL; }
echo '<td>'. $row['value'] . '</td>'.PHP_EOL;
echo '<td>'. $total_played . '</td>'.PHP_EOL;
echo '<td>'. $row['wins'] . '</td>'.PHP_EOL;
echo '<td>'. $row['draws'] . '</td>'.PHP_EOL;
echo '<td>'. $row['losses'] . '</td>'.PHP_EOL;
echo '<td>'. round($total_pts/$total_played, 2) . '</td>'.PHP_EOL;
echo '<td>'. round($row['touchdowns']/$total_played, 2) . '</td>'.PHP_EOL;
echo '<td>'. round($row['sustained_touchdowns']/$total_played, 2) . '</td>'.PHP_EOL;
echo '<td>'. round($row['passes']/$total_played, 2) . '</td>'.PHP_EOL;
echo '<td>'. round($row['interceptions']/$total_played, 2) . '</td>'.PHP_EOL;
echo '<td>'. round($row['inflicted_knockdown']/$total_played, 2) . '</td>'.PHP_EOL;
echo '<td>'. round($row['sustained_knockdown']/$total_played, 2) . '</td>'.PHP_EOL;
echo '<td>'. round($row['inflicted_ko']/$total_played, 2) . '</td>'.PHP_EOL;
echo '<td>'. round($row['sustained_ko']/$total_played, 2) . '</td>'.PHP_EOL;
echo '<td>'. round($row['inflicted_injury']/$total_played, 2) . '</td>'.PHP_EOL;
echo '<td>'. round($row['sustained_injury']/$total_played, 2) . '</td>'.PHP_EOL;
echo '<td>'. round($row['inflicted_dead']/$total_played, 2) . '</td>'.PHP_EOL;
echo '<td>'. round($row['sustained_dead']/$total_played, 2) . '</td>'.PHP_EOL;
echo '<td>'. round($row['meters_run']/$total_played, 2) . '</td>'.PHP_EOL;
echo '<td>'. round($row['meters_pass']/$total_played, 2) . '</td>'.PHP_EOL;
echo "</tr>".PHP_EOL;
}
?>
</tbody>
</table>
<p>Disclaimer - these stats aim to be as accurate as possible as of the end of the team's last match. Hiring/firing since then will not be included, neither is cash earned as a result of their last match.</p>
<p>To do - nothing, unless anyone has any suggestions.</p>
<?php include_once("inc/footer.php"); ?>