Add bonus points to the missing tables and make non relevant teams invisible in tables.

This commit is contained in:
2018-04-02 22:23:01 +02:00
parent 268ca763f7
commit 4a64eb71a3
2 changed files with 74 additions and 33 deletions

View File

@@ -66,6 +66,7 @@ $sql = "SELECT
AND t.league = $league
AND m.matchday <= $matchday
AND m.status IN (2,3,5,6)
AND m.show_table = 0
GROUP BY t.team_id
ORDER BY t.group_id ASC, points DESC, goals_diff DESC, goals DESC, t.team_name ASC";
@@ -164,27 +165,34 @@ foreach($points_ary as $group_id => $points)
$db->sql_freeresult($result);
$rank = 0;
// Get form-table-information
$sql = 'SELECT
$sql = "SELECT
t.*,
SUM(1) AS matches,
SUM(IF((m.team_id_home = t.team_id), IF(goals_home + 0 > goals_guest, 1, 0), IF(goals_home + 0 < goals_guest, 1, 0))) AS win,
SUM(IF(goals_home = goals_guest, 1, 0)) AS draw,
SUM(IF((m.team_id_home = t.team_id), IF(goals_home + 0 < goals_guest, 1, 0), IF(goals_home + 0 > goals_guest, 1, 0))) AS lost,
SUM(IF((m.team_id_home = t.team_id), IF(goals_home + 0 > goals_guest, 1, 0), IF(goals_home + 0 < goals_guest, 1, 0)))
+ IFNULL((SELECT SUM(c.win) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday),0)AS win,
SUM(IF(goals_home = goals_guest, 1, 0))
+ IFNULL((SELECT SUM(c.draw) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday),0)AS draw,
SUM(IF((m.team_id_home = t.team_id), IF(goals_home + 0 < goals_guest, 1, 0), IF(goals_home + 0 > goals_guest, 1, 0)))
+ IFNULL((SELECT SUM(c.lost) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday),0)AS lost,
SUM(IF(m.team_id_home = t.team_id,
IF(goals_home + 0 > goals_guest, 3, IF(goals_home = goals_guest, 1, 0)),
IF(goals_home + 0 < goals_guest, 3, IF(goals_home = goals_guest, 1, 0))
)
) AS points,
) + IFNULL((SELECT SUM(b.bonuspoints) FROM " . FOOTB_BONUS_DAY . " AS b WHERE b.team_id = t.team_id AND b.season = t.season AND b.league = t.league AND b.matchday <= $matchday),0)
+ IFNULL((SELECT SUM(c.points) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday),0)
- IF(t.team_id = 20 AND t.season = 2011 AND $matchday > 7, 2, 0) AS points,
SUM(IF(m.team_id_home = t.team_id, goals_home - goals_guest , goals_guest - goals_home)) AS goals_diff,
SUM(IF(m.team_id_home = t.team_id, goals_home , goals_guest)) AS goals,
SUM(IF(m.team_id_home = t.team_id, goals_guest, goals_home)) AS goals_against
FROM ' . FOOTB_TEAMS . ' AS t
SUM(IF(m.team_id_home = t.team_id, goals_guest , goals_home)) AS goals_against,
IFNULL((SELECT SUM(b.bonuspoints) FROM " . FOOTB_BONUS_DAY . " AS b WHERE b.team_id = t.team_id AND b.season = t.season AND b.league = t.league AND b.matchday <= $matchday),0) AS bonus
FROM " . FOOTB_TEAMS . ' AS t
LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = t.season AND m.league = t.league
AND (m.team_id_home = t.team_id OR m.team_id_guest = t.team_id) AND m.group_id = t.group_id)
WHERE t.season = $season
AND t.league = $league
AND m.matchday >= $form_from
AND m.status IN (2, 3,5,6)
AND m.show_table = 0
GROUP BY t.team_id
ORDER BY t.group_id ASC, points DESC, goals_diff DESC, goals DESC, t.team_name ASC";
@@ -249,7 +257,8 @@ while($row = $db->sql_fetchrow($result))
'GOALS' => $row['goals'],
'GOALS_AGAINST' => $row['goals_against'],
'GOALS_DIFF' => $row['goals_diff'],
'POINTS' => $row['points'],
'BONUS' => round($row['bonus'],2),
'POINTS' => round($row['points'],2),
)
);
}
@@ -257,23 +266,29 @@ while($row = $db->sql_fetchrow($result))
$db->sql_freeresult($result);
$rank = 0;
// Get home-table-information
$sql = 'SELECT
$sql = "SELECT
t.*,
SUM(1) AS matches,
SUM(IF(goals_home + 0 > goals_guest, 1, 0)) AS win,
SUM(IF(goals_home = goals_guest, 1, 0)) AS draw,
SUM(IF(goals_home + 0 < goals_guest, 1, 0)) AS lost,
SUM(IF(goals_home + 0 > goals_guest, 3, IF(goals_home = goals_guest, 1, 0))) AS points,
SUM(IF(goals_home + 0 > goals_guest, 1, 0))
+ IFNULL((SELECT SUM(c.win) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday AND c.home = 1 ),0)AS win,
SUM(IF(goals_home = goals_guest, 1, 0))
+ IFNULL((SELECT SUM(c.draw) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday AND c.home = 1 ),0)AS draw,
SUM(IF(goals_home + 0 < goals_guest, 1, 0))
+ IFNULL((SELECT SUM(c.lost) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday AND c.home = 1 ),0)AS lost,
SUM(IF(goals_home + 0 > goals_guest, 3, IF(goals_home = goals_guest, 1, 0)))+ IFNULL((SELECT SUM(b.bonuspoints) FROM " . FOOTB_BONUS_DAY . " AS b WHERE b.team_id = t.team_id AND b.season = t.season AND b.league = t.league AND b.matchday <= $matchday AND home = '1'),0)
+ IFNULL((SELECT SUM(c.points) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday AND c.home = 1 ),0)AS points,
SUM(goals_home - goals_guest) AS goals_diff,
SUM(goals_home) AS goals,
SUM(goals_guest) AS goals_against
FROM ' . FOOTB_TEAMS . ' AS t
SUM(goals_guest) AS goals_against,
IFNULL((SELECT SUM(b.bonuspoints) FROM " . FOOTB_BONUS_DAY . " AS b WHERE b.team_id = t.team_id AND b.season = t.season AND b.league = t.league AND home = '1'),0) AS bonus
FROM " . FOOTB_TEAMS . ' AS t
LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = t.season AND m.league = t.league
AND m.team_id_home = t.team_id AND m.group_id = t.group_id)
WHERE t.season = $season
AND t.league = $league
AND m.matchday <= $matchday
AND m.status IN (2, 3,5,6)
AND m.show_table = 0
GROUP BY t.team_id
ORDER BY t.group_id ASC, points DESC, goals_diff DESC, goals DESC, t.team_name ASC";
@@ -337,7 +352,8 @@ while($row = $db->sql_fetchrow($result))
'GOALS' => $row['goals'],
'GOALS_AGAINST' => $row['goals_against'],
'GOALS_DIFF' => $row['goals_diff'],
'POINTS' => $row['points'],
'BONUS' => round($row['bonus'],2),
'POINTS' => round($row['points'],2),
)
);
}
@@ -345,23 +361,29 @@ while($row = $db->sql_fetchrow($result))
$db->sql_freeresult($result);
$rank = 0;
// Get away-table-information
$sql = 'SELECT
$sql = "SELECT
t.*,
SUM(1) AS matches,
SUM(IF(goals_home + 0 < goals_guest, 1, 0)) AS win,
SUM(IF(goals_home = goals_guest, 1, 0)) AS draw,
SUM(IF(goals_home + 0 > goals_guest, 1, 0)) AS lost,
SUM(IF(goals_home + 0 < goals_guest, 3, IF(goals_home = goals_guest, 1, 0))) AS points,
SUM(IF(goals_home + 0 < goals_guest, 1, 0))
+ IFNULL((SELECT SUM(c.win) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday AND c.home = 0 ),0)AS win,
SUM(IF(goals_home = goals_guest, 1, 0))
+ IFNULL((SELECT SUM(c.draw) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday AND c.home = 0 ),0)AS draw,
SUM(IF(goals_home + 0 > goals_guest, 1, 0))
+ IFNULL((SELECT SUM(c.lost) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday AND c.home = 0 ),0)AS lost,
SUM(IF(goals_home + 0 < goals_guest, 3, IF(goals_home = goals_guest, 1, 0))) + IFNULL((SELECT SUM(b.bonuspoints) FROM " . FOOTB_BONUS_DAY . " AS b WHERE b.team_id = t.team_id AND b.season = t.season AND b.league = t.league AND b.matchday <= $matchday AND home = '0'),0)
+ IFNULL((SELECT SUM(c.points) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday AND c.home = 0 ),0)AS points,
SUM(goals_guest - goals_home) AS goals_diff,
SUM(goals_guest) AS goals,
SUM(goals_home) AS goals_against
FROM ' . FOOTB_TEAMS . ' AS t
SUM(goals_home) AS goals_against,
IFNULL((SELECT SUM(b.bonuspoints) FROM " . FOOTB_BONUS_DAY . " AS b WHERE b.team_id = t.team_id AND b.season = t.season AND b.league = t.league AND home = '0'),0) AS bonus
FROM " . FOOTB_TEAMS . ' AS t
LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = t.season AND m.league = t.league
AND m.team_id_guest = t.team_id AND m.group_id = t.group_id)
WHERE t.season = $season
AND t.league = $league
AND m.matchday <= $matchday
AND m.status IN (2, 3,5,6)
AND m.show_table = 0
GROUP BY t.team_id
ORDER BY t.group_id ASC, points DESC, goals_diff DESC, goals DESC, t.team_name ASC";
@@ -425,7 +447,8 @@ while($row = $db->sql_fetchrow($result))
'GOALS' => $row['goals'],
'GOALS_AGAINST' => $row['goals_against'],
'GOALS_DIFF' => $row['goals_diff'],
'POINTS' => $row['points'],
'BONUS' => round($row['bonus'],2),
'POINTS' => round($row['points'],2),
)
);
}

View File

@@ -68,6 +68,9 @@
<th>{L_LOST_SHORT}</th>
<th colspan="3">{L_GOALS}</th>
<th>{L_GOALS_DIFF_SHORT}</th>
<!-- IF S_DATA_BNS -->
<th>{L_BONUS_SHORT}</th>
<!-- ENDIF -->
<th style="text-align: right;">{L_POINTS_SHORT}</th>
</tr>
</thead>
@@ -91,6 +94,9 @@
<td class="td_vs">:</td>
<td class="td_goals_guest">{form.GOALS_AGAINST}</td>
<td class="td_hits">{form.GOALS_DIFF}</td>
<!-- IF S_DATA_BNS -->
<td class="td_bonus">{form.BONUS}</td>
<!-- ENDIF -->
<td class="td_pts">{form.POINTS}</td>
</tr>
<!-- ENDIF -->
@@ -122,6 +128,9 @@
<th>{L_LOST_SHORT}</th>
<th colspan="3">{L_GOALS}</th>
<th>{L_GOALS_DIFF_SHORT}</th>
<!-- IF S_DATA_BNS -->
<th>{L_BONUS_SHORT}</th>
<!-- ENDIF -->
<th style="text-align: right;">{L_POINTS_SHORT}</th>
</tr>
</thead>
@@ -145,6 +154,9 @@
<td class="td_vs">:</td>
<td class="td_goals_guest">{home.GOALS_AGAINST}</td>
<td class="td_hits">{home.GOALS_DIFF}</td>
<!-- IF S_DATA_BNS -->
<td class="td_bonus">{home.BONUS}</td>
<!-- ENDIF -->
<td class="td_pts">{home.POINTS}</td>
</tr>
<!-- ENDIF -->
@@ -167,6 +179,9 @@
<th>{L_LOST_SHORT}</th>
<th colspan="3">{L_GOALS}</th>
<th>{L_GOALS_DIFF_SHORT}</th>
<!-- IF S_DATA_BNS -->
<th>{L_BONUS_SHORT}</th>
<!-- ENDIF -->
<th style="text-align: right;">{L_POINTS_SHORT}</th>
</tr>
</thead>
@@ -190,6 +205,9 @@
<td class="td_vs">:</td>
<td class="td_goals_guest">{away.GOALS_AGAINST}</td>
<td class="td_hits">{away.GOALS_DIFF}</td>
<!-- IF S_DATA_BNS -->
<td class="td_bonus">{away.BONUS}</td>
<!-- ENDIF -->
<td class="td_pts">{away.POINTS}</td>
</tr>
<!-- ENDIF -->