Add bonus points calculation to table total.

This commit is contained in:
2018-02-21 23:19:03 +01:00
parent 3b47093a3a
commit 4b627586f8
6 changed files with 37 additions and 10 deletions

View File

@@ -42,4 +42,6 @@ define('UP_WINS', 1);
define('UP_POINTS', 2);
define('LEAGUE_CHAMP', 1);
define('LEAGUE_KO', 2);
define('FOOTB_BONUS_DAY', $table_prefix . 'footb_bonuspoints_day');
?>

View File

@@ -1697,9 +1697,13 @@ function get_order_team_compare($team_ary, $season, $league, $group, $ranks, $ma
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))
)
) - IF(t.team_id = 20 AND t.season = 2011 AND $matchday > 7, 2, 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_home , goals_guest)) AS goals,
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)
@@ -1711,7 +1715,7 @@ function get_order_team_compare($team_ary, $season, $league, $group, $ranks, $ma
AND (m.team_id_home='" . implode("' OR m.team_id_home='", $team_ary) . "')
AND (m.team_id_guest='" . implode("' OR m.team_id_guest='", $team_ary) . "')
GROUP BY t.team_id
ORDER BY t.group_id ASC, points DESC, goals_diff DESC, goals DESC";
ORDER BY t.group_id ASC, points DESC, goals_diff DESC, goals DESC, bonus DESC";
$result = $db->sql_query($sql);