diff --git a/block/table.php b/block/table.php index 87a5226..b8e4e12 100644 --- a/block/table.php +++ b/block/table.php @@ -42,17 +42,23 @@ $rank = 0; $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)) ) - ) - 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_guest , goals_home)) AS goals_against + 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) @@ -147,7 +153,8 @@ foreach($points_ary as $group_id => $points) '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), ) ); } @@ -424,6 +431,11 @@ while($row = $db->sql_fetchrow($result)) } } +if($league < 51) +{ + // Activate bonus coloumn only for tippers. + $data_bns = true; +} $db->sql_freeresult($result); $sidename = sprintf($user->lang['TABLE']); $template->assign_vars(array( @@ -434,6 +446,7 @@ $template->assign_vars(array( 'SEASON' => $season, 'LEAGUE' => $league, 'TEXT_FORM' => $text_form, + 'S_DATA_BNS' => $data_bns, ) ); diff --git a/includes/constants.php b/includes/constants.php index c4e3677..9f00b9d 100644 --- a/includes/constants.php +++ b/includes/constants.php @@ -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'); ?> \ No newline at end of file diff --git a/includes/functions.php b/includes/functions.php index 06c3955..101e604 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -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); diff --git a/language/de/football.php b/language/de/football.php index 2c043d2..1e41627 100644 --- a/language/de/football.php +++ b/language/de/football.php @@ -66,6 +66,7 @@ $lang = array_merge($lang, array( 'BETS_OF_ALL' => 'Die Tipps aller Tipper', 'BETSAVED' => 'Dein Tipp wurde erfolgreich gespeichert. ', 'BETSSAVED' => 'Deine %d Tipps wurden erfolgreich gespeichert. ', + 'BONUS_SHORT' => 'BNS', 'BOOK_TYPE' => 'Buchungstyp', 'CASH_POINTS' => 'Verrechnung in Ultimate Points', diff --git a/styles/prosilver/template/table.html b/styles/prosilver/template/table.html index 5556e41..777615a 100644 --- a/styles/prosilver/template/table.html +++ b/styles/prosilver/template/table.html @@ -14,6 +14,9 @@