Version 0.9.6

This commit is contained in:
football
2016-05-29 15:51:04 +02:00
parent 01ca41655f
commit caeec03da8
16 changed files with 601 additions and 138 deletions

View File

@@ -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

View File

@@ -72,6 +72,7 @@
<th style="text-align:right">{L_GOALS_HOME}</th>
<th></th>
<th>{L_GOALS_GUEST}</th>
<th>{L_BET_TIME}</th>
</tr>
</thead>
<tbody>
@@ -92,6 +93,7 @@
<td class="td_vs">:</td>
<td class="td_goals_guest"><input style="margin:0; width:30px;" type="number"
name="goalsg{bet_edit.MATCH_NUMBER}" min="0" max="20" size="2" value="{bet_edit.BET_GUEST}" /></td>
<td>{bet_edit.BET_TIME}</td>
</tr>
<!-- END bet_edit -->
</tbody>

View File

@@ -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']) . '<br/>',
'POINTS_TENDENCY' => $points_tendency . '<br/>',
'POINTS_DIFF' => ($league_info['points_mode'] == 4) ? sprintf($user->lang['POINTS_DIFFERENCE'], $league_info['points_diff']) . '<br/>' : '',
'POINTS_DIFF' => ($league_info['points_mode'] == 4) ? sprintf($user->lang['POINTS_DIFFERENCE'], $league_info['points_diff']) . '<br/>' :
(($league_info['points_mode'] == 5) ? sprintf($user->lang['POINTS_DIFFERENCE_DRAW'], $league_info['points_diff']) . '<br/>' : ''),
'POINTS_LAST' => ($league_info['points_last']) ? sprintf($user->lang['POINTS_NO_BET']) . '<br/>' : '',
'LINK_RULES' => sprintf($user->lang['LINK_RULES'], $link_rules),
'SEASONNAME' => $season_info['season_name'],

145
block/side_table.php Normal file
View File

@@ -0,0 +1,145 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
$data_table = false;
$ext_path = $this->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 = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logo = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
$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,
)
);
}
?>

View File

@@ -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 = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logo = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
$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 = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logo = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
$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

View File

@@ -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",

View File

@@ -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
//*****************************************************************************

View File

@@ -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']) . ': <br /><br />';
$message .= sprintf($user->lang['KO_NEXT']) . ': <br /><br />';
$messag_moved = '<br /><br />' . sprintf($user->lang['KO_MOVED']) . ': <br />';
$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'] . '<br />';
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'] . '<br />';
}
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'] . '<br />';
}
$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'] . '<br />';
}
$place++;
}
}
$db->sql_freeresult($result);

View File

@@ -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',

View File

@@ -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',

View File

@@ -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')),

30
migrations/v096_beta.php Normal file
View File

@@ -0,0 +1,30 @@
<?php
/**
*
* @package Football Football v0.96
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace football\football\migrations;
class v096_beta extends \phpbb\db\migration\migration
{
public function effectively_installed()
{
return isset($this->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')),
);
}
}

View File

@@ -12,12 +12,11 @@
<li class="small-icon icon-bet"><a href="{U_BET}" role="menuitem">{L_BET}</a></li>
<li class="small-icon icon-allbets"><a href="{U_ALL_BETS}" role="menuitem">{L_ALL_BETS}</a></li>
<li class="small-icon icon-results"><a href="{U_RESULTS}" role="menuitem">{L_RESULTS}</a></li>
<li class="small-icon icon-list"><a href="{U_TABLE}" role="menuitem">{L_TABLE}</a></li>
<li class="small-icon icon-rank"><a href="{U_RANKS_TOTAL}" role="menuitem">{L_RANK_TOTAL}</a></li>
<li class="small-icon icon-rank"><a href="{U_RANKS_MATCHDAY}" role="menuitem">{L_RANK_MATCHDAY}</a></li>
<li class="small-icon icon-rank"><a href="{U_RANKS_TOTAL}" role="menuitem">{L_RANK_TOTAL}</a></li>
<li class="small-icon icon-list"><a href="{U_TABLE}" role="menuitem">{L_TABLE}</a></li>
<li class="small-icon icon-points"><a href="{U_FOOTBALL_BANK}" role="menuitem">{L_FOOTBALL_BANK}</a></li>
<li class="small-icon icon-rules"><a href="{U_RULES}" role="menuitem" target="popup" onclick="popup('{U_RULES}', 625,625);return false;">{L_RULES}</a></li>
<li class="small-icon icon-download"><a href="{U_EXPORT}" role="menuitem">{L_EXPORT}</a></li>
<li class="small-icon icon-odds"><a href="{U_ODDS}" role="menuitem">{L_ODDS}</a></li>
<li class="separator"></li>
<!-- IF S_MENU_LINK1-->
@@ -38,6 +37,7 @@
<li class="small-icon icon-statistics"><a href="{U_MY_KOEFF}" role="menuitem">{L_MY_KOEFF}</a></li>
<li class="small-icon icon-statistics"><a href="{U_STAT_POINTS}" role="menuitem">{L_STAT_POINTS}</a></li>
<li class="small-icon icon-statistics"><a href="{U_STAT_RESULTS}" role="menuitem">{L_STAT_RESULTS}</a></li>
<li class="small-icon icon-download"><a href="{U_EXPORT}" role="menuitem">{L_EXPORT}</a></li>
<!-- ENDIF -->
<!-- IF S_DISPLAY_FOOTBALL -->
<li class="separator"></li>

View File

@@ -19,9 +19,9 @@
<li class="tab <!-- IF S_DISPLAY_BET -->activetab<!-- ENDIF --> small-icon icon-bet"><a href="{U_BET}"><span>{L_BET}</span></a></li>
<li class="tab <!-- IF S_DISPLAY_ALL_BETS -->activetab<!-- ENDIF --> small-icon icon-allbets"><a href="{U_ALL_BETS}"><span>{L_ALL_BETS}</span></a></li>
<li class="tab <!-- IF S_DISPLAY_RESULTS -->activetab<!-- ENDIF --> small-icon icon-results"><a href="{U_RESULTS}"><span>{L_RESULTS}</span></a></li>
<li class="tab <!-- IF S_DISPLAY_TABLE -->activetab<!-- ENDIF --> small-icon icon-list"><a href="{U_TABLE}"><span>{L_TABLE}</span></a></li>
<li class="tab <!-- IF S_DISPLAY_RANKS_TOTAL -->activetab<!-- ENDIF --> small-icon icon-rank"><a href="{U_RANKS_TOTAL}"><span>{L_RANK_TOTAL}</span></a></li>
<li class="tab <!-- IF S_DISPLAY_RANKS_MATCHDAY -->activetab<!-- ENDIF --> small-icon icon-rank"><a href="{U_RANKS_MATCHDAY}"><span>{L_RANK_MATCHDAY}</span></a></li>
<li class="tab <!-- IF S_DISPLAY_RANKS_TOTAL -->activetab<!-- ENDIF --> small-icon icon-rank"><a href="{U_RANKS_TOTAL}"><span>{L_RANK_TOTAL}</span></a></li>
<li class="tab <!-- IF S_DISPLAY_TABLE -->activetab<!-- ENDIF --> small-icon icon-list"><a href="{U_TABLE}"><span>{L_TABLE}</span></a></li>
<li class="tab <!-- IF S_DISPLAY_BANK -->activetab<!-- ENDIF --> small-icon icon-points"><a href="{U_FOOTBALL_BANK}"><span>{L_FOOTBALL_BANK}</span></a></li>
<li class="tab small-icon icon-rules"><a href="{U_RULES}" target="popup" onclick="popup('{U_RULES}', 625,625);return false;"><span>{L_RULES}</span></a></li>
<li class="tab <!-- IF S_DISPLAY_ODDS -->activetab<!-- ENDIF --> small-icon icon-odds"><a href="{U_ODDS}"><span>{L_ODDS}</span></a></li>
@@ -197,6 +197,9 @@
<!-- IF S_DISPLAY_RANK_MATCHDAY -->
<!-- INCLUDE rank_matchday.html -->
<!-- ENDIF -->
<!-- IF S_DISPLAY_SIDE_TABLE -->
<!-- INCLUDE side_table.html -->
<!-- ENDIF -->
<!-- IF S_DISPLAY_DELIVERY -->
<!-- INCLUDE delivery.html -->
<!-- ENDIF -->

View File

@@ -10,10 +10,10 @@
<ul>
<li class="tab <!-- IF S_DISPLAY_BET -->activetab<!-- ENDIF --> small-icon icon-bet"><a href="{U_BET}"><span>{L_BET}</span></a></li>
<li class="tab <!-- IF S_DISPLAY_ALL_BETS -->activetab<!-- ENDIF --> small-icon icon-allbets"><a href="{U_ALL_BETS}"><span>{L_BETS}</span></a></li>
<li class="tab <!-- IF S_DISPLAY_RESULTS -->activetab<!-- ENDIF --> small-icon icon-results"><a href="{U_RESULTS}"><span>{L_RESULTS}</span></a></li>
<li class="tab <!-- IF S_DISPLAY_TABLE -->activetab<!-- ENDIF --> small-icon icon-list"><a href="{U_TABLE}"><span>{L_TABLE}</span></a></li>
<li class="tab <!-- IF S_DISPLAY_RANKS_TOTAL -->activetab<!-- ENDIF --> small-icon icon-rank"><a href="{U_RANKS_TOTAL}"><span>{L_TOTAL}</span></a></li>
<li class="tab <!-- IF S_DISPLAY_RESULTS -->activetab<!-- ENDIF --> small-icon icon-results"><a href="{U_RESULTS}"><span>{L_RESULTS_SHORT_DOT}</span></a></li>
<li class="tab <!-- IF S_DISPLAY_RANKS_MATCHDAY -->activetab<!-- ENDIF --> small-icon icon-rank"><a href="{U_RANKS_MATCHDAY}"><span>{L_MATCHDAY_SHORT}</span></a></li>
<li class="tab <!-- IF S_DISPLAY_RANKS_TOTAL -->activetab<!-- ENDIF --> small-icon icon-rank"><a href="{U_RANKS_TOTAL}"><span>{L_TOTAL}</span></a></li>
<li class="tab <!-- IF S_DISPLAY_TABLE -->activetab<!-- ENDIF --> small-icon icon-list"><a href="{U_TABLE}"><span>{L_TABLE}</span></a></li>
<li class="tab <!-- IF S_DISPLAY_DELIVERY -->activetab<!-- ENDIF --> small-icon icon-bet"><a href="{U_DELIVERY_LIST}"><span>{L_DATES}</span></a></li>
<li class="tab <!-- IF S_DISPLAY_LAST_USERS -->activetab<!-- ENDIF --> small-icon icon-allbets"><a href="{U_LAST_VISITORS}"><span>{L_USERS}</span></a></li>
<li class="tab <!-- IF S_DISPLAY_BANK -->activetab<!-- ENDIF --> small-icon icon-points"><a href="{U_FOOTBALL_BANK}"><span>{L_FOOTBALL_BANK}</span></a></li>

View File

@@ -0,0 +1,36 @@
<div class="panel">
<h3><span class="small-icon icon-rank"></span>&nbsp;{L_TABLE_TOTAL}</h3>
<!-- IF S_DATA_SIDE_TABLE -->
<table class="forabg rank">
<thead>
<tr>
<th>{L_RANK_SHORT}</th>
<th colspan="2" style="text-align: center;">{L_TEAM}</th>
<th>{L_GAMES_SHORT}</th>
<th style="text-align: right;">{L_POINTS_SHORT}</th>
</tr>
</thead>
<tbody>
<!-- BEGIN side_total -->
<!-- IF side_total.GROUP <> '' -->
<tr class="row_group">
<td colspan="12" style="text-align: center;">{side_total.GROUP}</td>
</tr>
<!-- ELSE -->
<tr class="{side_total.ROW_CLASS}" style="cursor:pointer;" title="{L_SHOW_PLAYED}" onclick="popup('{side_total.U_PLAN_TEAM}');return false;">
<td class="td_rank">{side_total.RANK}</td>
<td class="td_logo">{side_total.LOGO}</td>
<td class="td_team">{side_total.TEAM_SHORT}</td>
<td class="td_hits">{side_total.GAMES}</td>
<td class="td_pts">{side_total.POINTS}</td>
</tr>
<!-- ENDIF -->
<!-- END side_total -->
</tbody>
</table>
<!-- ELSE -->
<div class="message">{L_NO_TABLE}</div>
<br />
<!-- ENDIF -->
</div>