diff --git a/acp/update_module.php b/acp/update_module.php
index 55169b1..e6acf91 100644
--- a/acp/update_module.php
+++ b/acp/update_module.php
@@ -512,9 +512,9 @@ class update_module
$league_info = league_info($season, $league);
if ($league_info['bet_in_time'])
{
- $sql = 'REPLACE INTO ' . FOOTB_MATCHDAYS . ' (season, league, matchday, delivery_date, matchday_name, matches)
- SELECT m.season, m.league, m.matchday, min(m.match_datetime) AS delivery_date, md.matchday_name, md.matches
- FROM ' . FOOTB_MATCHES . ' AS m
+ $sql = 'REPLACE INTO ' . FOOTB_MATCHDAYS . " (season, league, matchday, delivery_date, delivery_date_2, delivery_date_3, matchday_name, matches)
+ SELECT m.season, m.league, m.matchday, min(m.match_datetime) AS delivery_date, '' AS delivery_date_2, '' AS delivery_date_3, md.matchday_name, md.matches
+ FROM " . FOOTB_MATCHES . ' AS m
JOIN ' . FOOTB_LEAGUES . ' AS l ON (l.season = m.season AND l.league = m.league)
JOIN ' . FOOTB_MATCHDAYS . " AS md ON (md.season = m.season AND md.league = m.league AND md.matchday = m.matchday)
WHERE m.season = $season
@@ -667,7 +667,7 @@ class update_module
// check status of matchdays
$local_board_time = time() + (($this->config['board_timezone'] - $this->config['football_host_timezone']) * 3600);
- $sql = "UPDATE phpbb_footb_matchdays AS target
+ $sql = $sql = 'UPDATE ' . FOOTB_MATCHDAYS . " AS target
INNER JOIN
(
SELECT md.season
diff --git a/adm/style/acp_football_bets.html b/adm/style/acp_football_bets.html
index 93f4e3d..f0c9b7e 100644
--- a/adm/style/acp_football_bets.html
+++ b/adm/style/acp_football_bets.html
@@ -72,6 +72,7 @@
{L_GOALS_HOME} |
|
{L_GOALS_GUEST} |
+ {L_BET_TIME} |
@@ -92,6 +93,7 @@
: |
|
+ {bet_edit.BET_TIME} |
diff --git a/block/rules_popup.php b/block/rules_popup.php
index ccff232..723c051 100644
--- a/block/rules_popup.php
+++ b/block/rules_popup.php
@@ -180,7 +180,8 @@ if ($data_rules)
'JOIN_MODE' => ($league_info['join_by_user']) ? (($league_info['join_in_season']) ? sprintf($user->lang['JOIN_IN_SEASON']) : sprintf($user->lang['JOIN_BY_USER'])) : sprintf($user->lang['JOIN_BY_ADMIN']),
'POINTS_HIT' => sprintf($user->lang['POINTS_HIT'], $league_info['points_result']) . '
',
'POINTS_TENDENCY' => $points_tendency . '
',
- 'POINTS_DIFF' => ($league_info['points_mode'] == 4) ? sprintf($user->lang['POINTS_DIFFERENCE'], $league_info['points_diff']) . '
' : '',
+ 'POINTS_DIFF' => ($league_info['points_mode'] == 4) ? sprintf($user->lang['POINTS_DIFFERENCE'], $league_info['points_diff']) . '
' :
+ (($league_info['points_mode'] == 5) ? sprintf($user->lang['POINTS_DIFFERENCE_DRAW'], $league_info['points_diff']) . '
' : ''),
'POINTS_LAST' => ($league_info['points_last']) ? sprintf($user->lang['POINTS_NO_BET']) . '
' : '',
'LINK_RULES' => sprintf($user->lang['LINK_RULES'], $link_rules),
'SEASONNAME' => $season_info['season_name'],
diff --git a/block/side_table.php b/block/side_table.php
new file mode 100644
index 0000000..6ee1e2f
--- /dev/null
+++ b/block/side_table.php
@@ -0,0 +1,145 @@
+phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
+
+$sql = 'SELECT *
+ FROM ' . FOOTB_RANKS . "
+ WHERE season = $season
+ AND league = $league
+ AND matchday = $matchday";
+$result = $db->sql_query($sql);
+$row = $db->sql_fetchrow($result);
+$db->sql_freeresult($result);
+
+if ($row)
+{
+ include($this->football_root_path . 'block/rank_matchday.' . $this->php_ext);
+}
+else
+{
+ $rank = 0;
+ // Get table-information
+ $sql = "SELECT
+ t.*,
+ SUM(1) AS matches,
+ 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,
+ 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
+ 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 <= $matchday
+ AND m.status IN (2,3,5,6)
+ GROUP BY t.team_id
+ ORDER BY t.group_id ASC, points DESC, goals_diff DESC, goals DESC, t.team_name ASC";
+
+ $result = $db->sql_query($sql);
+
+ $table_ary = array();
+ $points_ary = array();
+ $ranks_ary = array();
+ while( $row = $db->sql_fetchrow($result))
+ {
+ $table_ary[$row['team_id']] = $row;
+ $points_ary[$row['group_id']][$row['points']][]=$row['team_id'];
+ $ranks_ary[] = $row['team_id'];
+ }
+ $last_group = '';
+ $rank = 0;
+ $current_rank = 0;
+ $last_goals = 0;
+ $last_goals_againts = 0;
+ $last_points = 0;
+ foreach($points_ary as $group_id => $points)
+ {
+ $data_table = true;
+ if ($last_group != $group_id)
+ {
+ $last_group =$group_id;
+ $rank = 0;
+ $last_goals = 0;
+ $last_goals_againts = 0;
+ $last_points = 0;
+ $template->assign_block_vars('side_total', array(
+ 'GROUP' => sprintf($user->lang['GROUP']) . ' ' .$group_id,
+ )
+ );
+ }
+
+ foreach($points as $point => $teams)
+ {
+ if(count($teams) > 1 AND $group_id != '')
+ {
+ // Compare teams with equal points and sort
+ $teams = get_order_team_compare($teams, $season, $league, $group_id, $ranks_ary, $matchday);
+ }
+ foreach($teams as $key => $team)
+ {
+ $row = $table_ary[$team];
+ $rank++;
+ if ($last_points <> $row['points'] OR $last_goals <> $row['goals'] OR $last_goals_againts <> $row['goals_against'])
+ {
+ $current_rank = $rank . '.';
+ }
+ else
+ {
+ $current_rank = '';
+ }
+ $last_points = $row['points'];
+ $last_goals = $row['goals'];
+ $last_goals_againts = $row['goals_against'];
+ $row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
+ if ($row['team_symbol'] <> '')
+ {
+ $logo = "
" ;
+ }
+ else
+ {
+ $logo = "
" ;
+ }
+
+ $template->assign_block_vars('side_total', array(
+ 'RANK' => $current_rank,
+ 'ROW_CLASS' => $row_class,
+ 'LOGO' => $logo,
+ 'TEAM_ID' => $row['team_id'],
+ 'TEAM_SHORT' => $row['team_name_short'],
+ 'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $row['league'],
+ 'tid' => $row['team_id'], 'mode' => 'played')),
+ 'GAMES' => $row['matches'],
+ 'POINTS' => $row['points'],
+ )
+ );
+ }
+ }
+ }
+ $db->sql_freeresult($result);
+
+ $template->assign_vars(array(
+ 'S_DISPLAY_SIDE_TABLE' => true,
+ 'S_DATA_SIDE_TABLE' => $data_table,
+ )
+ );
+}
+?>
\ No newline at end of file
diff --git a/block/table.php b/block/table.php
index 52ad240..33b3911 100644
--- a/block/table.php
+++ b/block/table.php
@@ -12,6 +12,7 @@ if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
exit;
}
+
$data_table = false;
$data_form = false;
@@ -58,76 +59,101 @@ $sql = "SELECT
WHERE t.season = $season
AND t.league = $league
AND m.matchday <= $matchday
- AND m.status IN (2, 3,5,6)
+ AND m.status IN (2,3,5,6)
GROUP BY t.team_id
ORDER BY t.group_id ASC, points DESC, goals_diff DESC, goals DESC, t.team_name ASC";
$result = $db->sql_query($sql);
+
+$table_ary = array();
+$points_ary = array();
+$ranks_ary = array();
+$rank = 0;
+while( $row = $db->sql_fetchrow($result))
+{
+ $rank++;
+ $table_ary[$row['team_id']] = $row;
+ $points_ary[$row['group_id']][$row['points']][]=$row['team_id'];
+ $ranks_ary[] = $row['team_id'];
+}
+
$last_group = '';
+$rank = 0;
$current_rank = 0;
$last_goals = 0;
$last_goals_againts = 0;
$last_points = 0;
-while($row = $db->sql_fetchrow($result))
+foreach($points_ary as $group_id => $points)
{
- if ($last_group != $row['group_id'])
+ $data_table = true;
+ if ($last_group != $group_id)
{
- $last_group = $row['group_id'];
+ $last_group =$group_id;
$rank = 0;
$last_goals = 0;
$last_goals_againts = 0;
$last_points = 0;
$template->assign_block_vars('total', array(
- 'GROUP' => sprintf($user->lang['GROUP']) . ' ' . $row['group_id'],
+ 'GROUP' => sprintf($user->lang['GROUP']) . ' ' .$group_id,
)
);
}
- if ($league_type != 2 OR $row['group_id'] != '')
+
+ foreach($points as $point => $teams)
{
- $data_table = true;
- $rank++;
- if ($last_points <> $row['points'] OR $last_goals <> $row['goals'] OR $last_goals_againts <> $row['goals_against'])
+ if(count($teams) > 1 AND $group_id != '')
{
- $current_rank = $rank . '.';
+ // Compare teams with equal points and sort
+ $teams = get_order_team_compare($teams, $season, $league, $group_id, $ranks_ary, $matchday);
}
- else
+ foreach($teams as $key => $team)
{
- $current_rank = '';
- }
- $last_points = $row['points'];
- $last_goals = $row['goals'];
- $last_goals_againts = $row['goals_against'];
- $row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
- if ($row['team_symbol'] <> '')
- {
- $logo = "
" ;
- }
- else
- {
- $logo = "
" ;
- }
-
- $template->assign_block_vars('total', array(
- 'RANK' => $current_rank,
- 'ROW_CLASS' => $row_class,
- 'LOGO' => $logo,
- 'TEAM_ID' => $row['team_id'],
- 'TEAM' => $row['team_name'],
- 'TEAM_SHORT' => $row['team_name_short'],
- 'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $row['league'],
- 'tid' => $row['team_id'], 'mode' => 'played')),
- 'GAMES' => $row['matches'],
- 'WIN' => $row['win'],
- 'DRAW' => $row['draw'],
- 'LOST' => $row['lost'],
- 'GOALS' => $row['goals'],
- 'GOALS_AGAINST' => $row['goals_against'],
- 'GOALS_DIFF' => $row['goals_diff'],
- 'POINTS' => $row['points'],
- )
- );
- }
+ $row = $table_ary[$team];
+ $rank++;
+ if ($last_points <> $row['points'] OR $last_goals <> $row['goals'] OR $last_goals_againts <> $row['goals_against'])
+ {
+ $current_rank = $rank . '.';
+ }
+ else
+ {
+ $current_rank = '';
+ }
+ $last_points = $row['points'];
+ $last_goals = $row['goals'];
+ $last_goals_againts = $row['goals_against'];
+ $row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
+ if ($row['team_symbol'] <> '')
+ {
+ $logo = "
" ;
+ }
+ else
+ {
+ $logo = "
" ;
+ }
+
+ $template->assign_block_vars('total', array(
+ 'RANK' => $current_rank,
+ 'ROW_CLASS' => $row_class,
+ 'LOGO' => $logo,
+ 'TEAM_ID' => $row['team_id'],
+ 'TEAM' => $row['team_name'],
+ 'TEAM_SHORT' => $row['team_name_short'],
+ 'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $row['league'],
+ 'tid' => $row['team_id'], 'mode' => 'played')),
+ 'GAMES' => $row['matches'],
+ 'WIN' => $row['win'],
+ 'DRAW' => $row['draw'],
+ 'LOST' => $row['lost'],
+ 'GOALS' => $row['goals'],
+ 'GOALS_AGAINST' => $row['goals_against'],
+ 'GOALS_DIFF' => $row['goals_diff'],
+ 'POINTS' => $row['points'],
+ )
+ );
+ }
+ }
}
+
$db->sql_freeresult($result);
$rank = 0;
// Get form-table-information
diff --git a/composer.json b/composer.json
index 54884e3..f827586 100644
--- a/composer.json
+++ b/composer.json
@@ -3,8 +3,8 @@
"type": "phpbb-extension",
"description": "Football Prediction League for phpBB 3.1",
"homepage": "http://football.bplaced.net",
- "version": "0.9.5",
- "time": "2016-04-22",
+ "version": "0.9.6",
+ "time": "2016-05-29",
"license": "GPL-2.0",
"authors": [{
"name": "J. Helmke",
diff --git a/controller/main.php b/controller/main.php
index dc7e085..635a8ce 100644
--- a/controller/main.php
+++ b/controller/main.php
@@ -902,7 +902,14 @@ class main
if (!$user->data['football_mobile'])
{
// Start matchday list
- include($this->football_root_path . 'block/rank_matchday.' . $this->php_ext);
+ if ($side == 'bet')
+ {
+ include($this->football_root_path . 'block/side_table.' . $this->php_ext);
+ }
+ else
+ {
+ include($this->football_root_path . 'block/rank_matchday.' . $this->php_ext);
+ }
// End matchday list
//*****************************************************************************
diff --git a/includes/functions.php b/includes/functions.php
index a298721..2bb4b67 100644
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -1641,6 +1641,78 @@ function color_points($text, $status)
return $color_points;
}
+/**
+* get table order on teams with equal points.
+*/
+function get_order_team_compare($team_ary, $season, $league, $group, $ranks, $matchday = 999, $first = true)
+{
+ global $db;
+ $sql = "
+ SELECT
+ t.*,
+ 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,
+ 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
+ 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 <= $matchday
+ AND m.status IN (2,3,5,6)
+ AND m.group_id = '$group'
+ 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";
+
+ $result = $db->sql_query($sql);
+
+ $tmp = array();
+ $rank_ary = array();
+ $rank = 0;
+ $last_points = 0;
+ $last_goals_diff = 0;
+ $last_goals = 0;
+
+ while( $row = $db->sql_fetchrow($result))
+ {
+ if ($last_points <> $row['points'] OR $last_goals_diff <> $row['goals_diff'] OR $last_goals <> $row['goals'])
+ {
+ $rank++;
+ }
+ $rank_ary[$rank][]=$row['team_id'];
+ $last_points = $row['points'];
+ $last_goals_diff = $row['goals_diff'];
+ $last_goals = $row['goals'];
+ }
+ foreach($rank_ary as $rank => $teams)
+ {
+ if(count($teams) > 1)
+ {
+ if ($first)
+ {
+ // Compare teams with equal ranks
+ $teams = get_order_team_compare($teams, $season, $league, $group, $ranks, $matchday, false);
+ }
+ else
+ {
+ // Second compare is still equal, so look on total rank
+ $teams = array_intersect($ranks, $teams);
+ }
+ }
+ foreach($teams as $key => $team)
+ {
+ $tmp[] = $team;
+ }
+ }
+ return $tmp;
+}
+
/**
* determine team items from formula.
*/
@@ -1653,6 +1725,147 @@ function get_team($season, $league, $matchnumber, $field, $formula)
switch($first_letter)
{
+ case '3':
+ // 3. Place Euro 2106
+ $groups = substr($para_ary[0], 0, 5);
+ $sql = '
+ SELECT
+ SUM(1) AS matches,
+ SUM(IF(m.status = 3, 1, 0)) AS played
+ FROM ' . FOOTB_MATCHES . " AS m
+ WHERE m.season = $season AND m.league = $league AND m.group_id <> ''
+ GROUP BY m.group_id
+ ";
+ $result = $db->sql_query($sql);
+
+ if ( $row = $db->sql_fetchrow($result))
+ {
+ if ($row['matches'] == $row['played'])
+ {
+ $rank = 0;
+ // Get table-information
+ $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)),
+ IF(goals_home + 0 < goals_guest, 3, IF(goals_home = goals_guest, 1, 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
+ 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.status IN (2,3,5,6)
+ GROUP BY t.team_id
+ ORDER BY t.group_id ASC, points DESC, goals_diff DESC, goals DESC, t.team_name ASC";
+
+ $result = $db->sql_query($sql);
+
+ $table_ary = array();
+ $points_ary = array();
+ $ranks_ary = array();
+ $third_team = array();
+ $third_group = array();
+ $points3 = array();
+ $diff3 = array();
+ $goals3 = array();
+ $rank = 0;
+ while( $row = $db->sql_fetchrow($result))
+ {
+ $rank++;
+ $table_ary[$row['team_id']] = $row;
+ $points_ary[$row['group_id']][$row['points']][]=$row['team_id'];
+ $ranks_ary[] = $row['team_id'];
+ }
+
+ foreach($points_ary as $group_id => $points)
+ {
+ $rank = 0;
+
+ //sort on points descending
+ krsort($points);
+
+ foreach($points as $point => $teams)
+ {
+ if(count($teams) > 1)
+ {
+ // Compare teams with equal points
+ $teams = get_order_team_compare($teams, $season, $league, $group_id, $ranks_ary);
+ }
+ foreach($teams as $key => $team)
+ {
+ $row = $table_ary[$team];
+ $rank++;
+ if ($rank == 3)
+ {
+ $points3[$team] = $row['points'];
+ $diff3[$team] = $row['goals_diff'];
+ $goals3[$team] = $row['goals'];
+ $third_team[$team]= $team;
+ $third_group[$team]= $row['group_id'];
+ }
+ }
+ }
+ }
+ // Sort 3. Place on points, diff, goals
+ array_multisort($points3, SORT_DESC, $diff3, SORT_DESC, $goals3, SORT_DESC, $third_team, $third_group);
+ $qualified_groups = array();
+ for($i = 0; $i < 4; $i++)
+ {
+ $qualified_groups[$i] = $third_group[$i];
+ $team_of[$third_group[$i]] = $third_team[$i];
+ }
+ asort($qualified_groups);
+ $qualified_groups_string = '';
+ foreach($qualified_groups as $key => $letter)
+ {
+ $qualified_groups_string .= $letter;
+ }
+ $modus = array('ABCD' => 'CDAB', 'ABCE' => 'CABE', 'ABCF' => 'CABF', 'ABDE' => 'DABE', 'ABDF' => 'DABF',
+ 'ABEF' => 'EABF', 'ACDE' => 'CDAE', 'ACDF' => 'CDAF', 'ACEF' => 'CAFE', 'ADEF' => 'DAFE',
+ 'BCDE' => 'CDBE', 'BCDF' => 'CDBF', 'BCEF' => 'ECBF', 'BDEF' => 'EDBF', 'CDEF' => 'CDFE');
+ $form_para = array('CDE', 'ACD', 'ABF', 'BEF');
+ $mode = $modus[$qualified_groups_string];
+ for($i = 0; $i < 4; $i++)
+ {
+ $team = $team_of[substr($mode, $i, 1)];
+
+ $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET team_id_guest = $team WHERE season = $season AND league = $league AND formula_guest = '3 $form_para[$i]'";
+ $resultup = $db->sql_query($sqlup);
+ $sqlup = 'UPDATE ' . FOOTB_TEAMS . ' SET matchday = (SELECT max(matchday) FROM ' . FOOTB_MATCHES . "
+ WHERE season = $season AND league = $league AND (team_id_home= $team OR team_id_guest = $team))
+ WHERE season = $season AND league = $league AND team_id = $team";
+ $resultup = $db->sql_query($sqlup);
+ if ($form_para[$i] == $groups)
+ {
+ $team_id = $team;
+ $row = $table_ary[$team];
+ $team_symbol = $row['team_symbol'];
+ $team_name = $row['team_name'];
+ $team_name_short = $row['team_name_short'];
+ }
+ }
+ return $team_symbol . '#' . $team_id . '#' . $team_name . '#' . $team_name_short;
+
+ }
+ else
+ {
+ return '#0#' . '3. ' . sprintf($user->lang['GROUP']) . ' ' . $groups . '#' . '3. ' . sprintf($user->lang['GROUP']) . ' ' . $groups;
+ }
+ }
+ else
+ {
+ return '#0#' . '3. ' . sprintf($user->lang['GROUP']) . ' ' . $groups . '#' . '3. ' . sprintf($user->lang['GROUP']) . ' ' . $groups;
+ }
+ break;
case 'D':
// Drawing
return '#0#' . sprintf($user->lang['DRAWING']) . '#' . sprintf($user->lang['DRAWING']);
@@ -1675,31 +1888,16 @@ function get_team($season, $league, $matchnumber, $field, $formula)
{
if ($row['matches'] == $row['played'])
{
+ $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 lose,
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(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,
- SUM(IF(m.team_id_home = t.team_id, goals_home - goals_guest, goals_guest - goals_home)) AS goal_diff,
+ 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_get
FROM ' . FOOTB_TEAMS . ' AS t
@@ -1707,48 +1905,44 @@ function get_team($season, $league, $matchnumber, $field, $formula)
(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.group_id = '$group'
GROUP BY t.team_id
- ORDER BY points DESC, goal_diff DESC, goals DESC
+ ORDER BY points DESC, goals_diff DESC, goals DESC
";
$result = $db->sql_query($sql);
- $rowset = $db->sql_fetchrowset($result);
- $db->sql_freeresult($result);
-
- if (1 == $place)
+ $table_ary = array();
+ $points_ary = array();
+ $ranks_ary = array();
+ while( $row = $db->sql_fetchrow($result))
{
- if ($rowset[0]['points'] == $rowset[1]['points'] AND $rowset[0]['goal_diff'] == $rowset[1]['goal_diff'] AND $rowset[0]['goals'] == $rowset[1]['goals'])
- {
- return '#0#' . $place . '. ' . sprintf($user->lang['GROUP']) . ' ' . $place . '#' . $place . '. ' . sprintf($user->lang['GROUP']) . ' ' . $group;
- }
- else
- {
- $new_id = $rowset[0]['team_id'];
- $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET $field = $new_id WHERE season = $season AND league = $league AND match_no = $matchnumber";
- $resultup = $db->sql_query($sqlup);
- $sqlup = 'UPDATE ' . FOOTB_TEAMS . ' SET matchday = (SELECT max(matchday) FROM ' . FOOTB_MATCHES . "
- WHERE season = $season AND league = $league AND (team_id_home= $new_id OR team_id_guest = $new_id))
- WHERE season = $season AND league = $league AND team_id = $new_id";
- $resultup = $db->sql_query($sqlup);
- return $rowset[0]['team_symbol'] . '#' . $new_id . '#' . $rowset[0]['team_name'] . '#' . $rowset[0]['team_name_short'];
- }
+ $table_ary[$row['team_id']] = $row;
+ $points_ary[$row['points']][]=$row['team_id'];
+ $ranks_ary[] = $row['team_id'];
}
- else
+ $db->sql_freeresult($result);
+
+ //sort on points descending
+ krsort($points_ary);
+
+ foreach($points_ary as $point => $teams)
{
- // second
- if (($rowset[0]['points'] == $rowset[1]['points'] AND $rowset[0]['goal_diff'] == $rowset[1]['goal_diff'] AND $rowset[0]['goals'] == $rowset[1]['goals'] ) OR
- ($rowset[2]['points'] == $rowset[1]['points'] AND $rowset[2]['goal_diff'] == $rowset[1]['goal_diff'] AND $rowset[2]['goals'] == $rowset[1]['goals'] ))
+ if(count($teams) > 1)
{
- return '#0#' . $place . '. ' . sprintf($user->lang['GROUP']) . ' ' . $group . '#' . $place . '. ' . sprintf($user->lang['GROUP']) . ' ' . $group;
+ // Compare teams with equal points
+ $teams = get_order_team_compare($teams, $season, $league, $group, $ranks_ary);
}
- else
+ foreach($teams as $key => $team)
{
- $new_id = $rowset[1]['team_id'];
- $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET $field = $new_id WHERE season = $season AND league = $league AND match_no = $matchnumber";
- $resultup = $db->sql_query($sqlup);
- $sqlup = 'UPDATE ' . FOOTB_TEAMS . ' SET matchday = (SELECT max(matchday) FROM ' . FOOTB_MATCHES . "
- WHERE season = $season AND league = $league AND (team_id_home= $new_id OR team_id_guest = $new_id))
- WHERE season = $season AND league = $league AND team_id = $new_id";
- $resultup = $db->sql_query($sqlup);
- return $rowset[1]['team_symbol'] . '#' . $new_id . '#' . $rowset[1]['team_name'] . '#' . $rowset[1]['team_name_short'];
+ $row = $table_ary[$team];
+ $rank++;
+ if ($rank == $place)
+ {
+ $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET $field = $team WHERE season = $season AND league = $league AND match_no = $matchnumber";
+ $resultup = $db->sql_query($sqlup);
+ $sqlup = 'UPDATE ' . FOOTB_TEAMS . ' SET matchday = (SELECT max(matchday) FROM ' . FOOTB_MATCHES . "
+ WHERE season = $season AND league = $league AND (team_id_home= $team OR team_id_guest = $team))
+ WHERE season = $season AND league = $league AND team_id = $team";
+ $resultup = $db->sql_query($sqlup);
+ return $row['team_symbol'] . '#' . $team . '#' . $row['team_name'] . '#' . $row['team_name_short'];
+ }
}
}
}
@@ -2112,37 +2306,53 @@ function ko_group_next_round($season, $league, $matchday_from, $matchday_to, $ma
ORDER BY group_id ASC,points DESC, goal_diff DESC, goals DESC
";
$result = $db->sql_query($sql);
+
+ $table_ary = array();
+ $points_ary = array();
+ $ranks_ary = array();
+ while( $row = $db->sql_fetchrow($result))
+ {
+ $table_ary[$row['team_id']] = $row;
+ $points_ary[$row['group_id']][$row['points']][]=$row['team_id'];
+ $ranks_ary[] = $row['team_id'];
+ }
$message = sprintf($user->lang['KO_NEXT_CHECK']) . ':
';
$message .= sprintf($user->lang['KO_NEXT']) . ':
';
$messag_moved = '
' . sprintf($user->lang['KO_MOVED']) . ':
';
$group_id = 'XX';
- while ($row = $db->sql_fetchrow($result))
+ foreach($points_ary as $group_id => $points)
{
- if ($group_id != $row['group_id'])
+ $place = 1;
+ foreach($points as $point => $teams)
{
- $place = 1;
- $group_id = $row['group_id'];
- }
+ if(count($teams) > 1)
+ {
+ // Compare teams with equal points
+ $teams = get_order_team_compare($teams, $season, $league, $group_id, $ranks_ary);
+ }
+ foreach($teams as $key => $team_id)
+ {
+ $row = $table_ary[$team_id];
- if ($place <= $rank)
- {
- $team_id = $row['team_id'];
- $sqlup = 'UPDATE ' . FOOTB_TEAMS . " SET matchday = $matchday_new WHERE season = $season AND league = $league AND team_id = $team_id";
- $resultup = $db->sql_query($sqlup);
- $message .= $row['team_name'] . '
';
+ if ($place <= $rank)
+ {
+ $sqlup = 'UPDATE ' . FOOTB_TEAMS . " SET matchday = $matchday_new WHERE season = $season AND league = $league AND team_id = $team_id";
+ $resultup = $db->sql_query($sqlup);
+ $message .= $row['team_name'] . '
';
+ }
+ if ($move_rank > 0 AND $move_league > 0 AND $place == $move_rank)
+ {
+ $team_name = $row['team_name'];
+ $short_name = $row['team_name_short'];
+ $team_sign = $row['team_symbol'];
+ $sqlinsert = 'INSERT INTO ' . FOOTB_TEAMS . " VALUES($season, $move_league, $team_id, '$team_name', '$short_name', '$team_sign', '', $move_matchday)";
+ $resultinsert = $db->sql_query($sqlinsert);
+ $messag_moved .= $row['team_name'] . '
';
+ }
+ $place++;
+ }
}
- if ($move_rank > 0 AND $move_league > 0 AND $place == $move_rank)
- {
- $team_id = $row['team_id'];
- $team_name = $row['team_name'];
- $short_name = $row['team_name_short'];
- $team_sign = $row['team_symbol'];
- $sqlinsert = 'INSERT INTO ' . FOOTB_TEAMS . " VALUES($season, $move_league, $team_id, '$team_name', '$short_name', '$team_sign', '', $move_matchday)";
- $resultinsert = $db->sql_query($sqlinsert);
- $messag_moved .= $row['team_name'] . '
';
- }
- $place++;
}
}
$db->sql_freeresult($result);
diff --git a/language/de/football.php b/language/de/football.php
index 1a96cb7..955d474 100644
--- a/language/de/football.php
+++ b/language/de/football.php
@@ -58,6 +58,7 @@ $lang = array_merge($lang, array(
'BET_KOEFF' => 'Tippkoeffizient ',
'BET_OF' => 'Tipp',
'BET_POINTS' => 'Einsatz',
+ 'BET_TIME' => 'Tipp Zeit',
'BET_UNTIL_DELIVERY' => 'Die Spiele eines Spieltags können nur bis zum Abgabetermin des Spieltags getippt werden. Danach werden die Tipps der anderen Tipper für alle sichtbar. ',
'BETS' => 'Tipps',
'BETS_AND_RANKS' => 'Tipps und Ranglisten der',
@@ -290,6 +291,7 @@ $lang = array_merge($lang, array(
'POINTS' => 'Punkte',
'POINTS_DIFF' => 'Punktedifferenz',
'POINTS_DIFFERENCE' => 'Punkte für die richtige Tordifferenz: %s',
+ 'POINTS_DIFFERENCE_DRAW' => 'Punkte für die richtige Tordifferenz (außer bei Unentschieden): %s',
'POINTS_DOT' => 'Pk. ',
'POINTS_HIT' => 'Für die Vorhersage des richtigen Ergebnisses (Volltreffer) gibt es %s Punkte. ',
'POINTS_LAST' => 'Punkte des letzten für Nichttipper',
diff --git a/language/en/football.php b/language/en/football.php
index 4d8ada8..ce8042d 100644
--- a/language/en/football.php
+++ b/language/en/football.php
@@ -60,6 +60,7 @@ $lang = array_merge($lang, array(
'BET_KOEFF' => 'Bet coefficient',
'BET_OF' => 'Bet',
'BET_POINTS' => 'Bet',
+ 'BET_TIME' => 'Bet time',
'BET_UNTIL_DELIVERY' => 'The matches of a matchday can be entered only up to the deadline of the matchday. Then the bets of others Users become visible for everybody. ',
'BETS' => 'Bets',
'BETS_AND_RANKS' => 'Bets and ranking of',
@@ -277,6 +278,7 @@ $lang = array_merge($lang, array(
'POINTS' => 'Points',
'POINTS_DIFF' => 'Point difference',
'POINTS_DIFFERENCE' => 'Points for the correct Goal difference: %s',
+ 'POINTS_DIFFERENCE_DRAW' => 'Points for the correct Goal difference (except in case of draw): %s',
'POINTS_DOT' => 'Pt. ',
'POINTS_HIT' => 'For the prediction of the correct result (direct hit) there is %s points. ',
'POINTS_LAST' => 'Points of the last one for non-betting members',
diff --git a/migrations/v094_beta.php b/migrations/v094_beta.php
index 8a55808..67633e1 100644
--- a/migrations/v094_beta.php
+++ b/migrations/v094_beta.php
@@ -274,7 +274,6 @@ class v094_beta extends \phpbb\db\migration\migration
array('config.remove', array('football_menu_forumid4')),
array('config.remove', array('football_menu_forumid5')),
array('config.remove', array('football_menu_forumid6')),
- array('config.remove', array('football_side')),
array('config.add', array('football_bank', '0', '0')),
array('config.add', array('football_code', '0000', '0')),
array('config.add', array('football_disable', '0', '0')),
diff --git a/migrations/v096_beta.php b/migrations/v096_beta.php
new file mode 100644
index 0000000..5b9a86d
--- /dev/null
+++ b/migrations/v096_beta.php
@@ -0,0 +1,30 @@
+config['football_version']) && version_compare($this->config['football_version'], '0.9.6', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array('\football\football\migrations\v095_beta');
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('football_version', '0.9.6', '0')),
+ );
+ }
+}
diff --git a/styles/prosilver/template/event/overall_header_navigation_prepend.html b/styles/prosilver/template/event/overall_header_navigation_prepend.html
index 45fa598..3cd90fa 100644
--- a/styles/prosilver/template/event/overall_header_navigation_prepend.html
+++ b/styles/prosilver/template/event/overall_header_navigation_prepend.html
@@ -12,12 +12,11 @@
{L_BET}
{L_ALL_BETS}
{L_RESULTS}
- {L_TABLE}
- {L_RANK_TOTAL}
{L_RANK_MATCHDAY}
+ {L_RANK_TOTAL}
+ {L_TABLE}
{L_FOOTBALL_BANK}
{L_RULES}
- {L_EXPORT}
{L_ODDS}
@@ -38,6 +37,7 @@
{L_MY_KOEFF}
{L_STAT_POINTS}
{L_STAT_RESULTS}
+ {L_EXPORT}
diff --git a/styles/prosilver/template/football_body.html b/styles/prosilver/template/football_body.html
index 007c16b..4a382f2 100644
--- a/styles/prosilver/template/football_body.html
+++ b/styles/prosilver/template/football_body.html
@@ -19,9 +19,9 @@
{L_BET}
{L_ALL_BETS}
{L_RESULTS}
- {L_TABLE}
- {L_RANK_TOTAL}
{L_RANK_MATCHDAY}
+ {L_RANK_TOTAL}
+ {L_TABLE}
{L_FOOTBALL_BANK}
{L_RULES}
{L_ODDS}
@@ -197,6 +197,9 @@
+
+
+
diff --git a/styles/prosilver/template/mobile_football_body.html b/styles/prosilver/template/mobile_football_body.html
index 42a3d26..ba28567 100644
--- a/styles/prosilver/template/mobile_football_body.html
+++ b/styles/prosilver/template/mobile_football_body.html
@@ -10,10 +10,10 @@