diff --git a/block/table.php b/block/table.php index 10fb0ed..2fc4258 100644 --- a/block/table.php +++ b/block/table.php @@ -52,13 +52,13 @@ $sql = "SELECT 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)) ) - ) + 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(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, - 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 + 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) @@ -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, 3, IF(goals_home = goals_guest, 1, 0)), + 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 - LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = t.season AND m.league = t.league + 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) 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"; @@ -248,8 +256,9 @@ while($row = $db->sql_fetchrow($result)) 'LOST' => $row['lost'], 'GOALS' => $row['goals'], 'GOALS_AGAINST' => $row['goals_against'], - 'GOALS_DIFF' => $row['goals_diff'], - 'POINTS' => $row['points'], + 'GOALS_DIFF' => $row['goals_diff'], + '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"; @@ -336,8 +351,9 @@ while($row = $db->sql_fetchrow($result)) 'LOST' => $row['lost'], 'GOALS' => $row['goals'], 'GOALS_AGAINST' => $row['goals_against'], - 'GOALS_DIFF' => $row['goals_diff'], - 'POINTS' => $row['points'], + 'GOALS_DIFF' => $row['goals_diff'], + '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"; @@ -424,8 +446,9 @@ while($row = $db->sql_fetchrow($result)) 'LOST' => $row['lost'], 'GOALS' => $row['goals'], 'GOALS_AGAINST' => $row['goals_against'], - 'GOALS_DIFF' => $row['goals_diff'], - 'POINTS' => $row['points'], + 'GOALS_DIFF' => $row['goals_diff'], + 'BONUS' => round($row['bonus'],2), + 'POINTS' => round($row['points'],2), ) ); } diff --git a/styles/prosilver/template/table.html b/styles/prosilver/template/table.html index 777615a..c159795 100644 --- a/styles/prosilver/template/table.html +++ b/styles/prosilver/template/table.html @@ -68,6 +68,9 @@